commit e2000e883ef104fbb9b6c3b41a06aadaf75939af Author: xiongcz Date: Wed May 21 10:43:12 2025 +0800 备份 diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..e3e0bb8 --- /dev/null +++ b/.classpath @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..35410ca --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..539af4a --- /dev/null +++ b/.idea/encodings.xml @@ -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..7dc1249 --- /dev/null +++ b/.idea/git_toolbox_blame.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..385999e --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ 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..15b4eb4 --- /dev/null +++ b/.project @@ -0,0 +1,39 @@ + + + cn.com.ebewin.ysr + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + + + 1737218542352 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..25b2cbf --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +encoding//src/cn/com/ebewin/ysr/dialog/AssignProjectDialog.java=GBK +encoding/=GBK diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..274ae9a --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,26 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.builder.cleanOutputFolder=clean +org.eclipse.jdt.core.builder.duplicateResourceTask=warning +org.eclipse.jdt.core.builder.invalidClasspath=abort +org.eclipse.jdt.core.builder.recreateModifiedClassFileInOutputFolder=ignore +org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch +org.eclipse.jdt.core.circularClasspath=error +org.eclipse.jdt.core.classpath.exclusionPatterns=enabled +org.eclipse.jdt.core.classpath.mainOnlyProjectHasTestOnlyDependency=error +org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled +org.eclipse.jdt.core.classpath.outputOverlappingAnotherSource=error +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.maxProblemPerUnit=100 +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.7 +org.eclipse.jdt.core.incompatibleJDKLevel=ignore +org.eclipse.jdt.core.incompleteClasspath=error diff --git a/.settings/org.eclipse.jdt.launching.prefs b/.settings/org.eclipse.jdt.launching.prefs new file mode 100644 index 0000000..f8a131b --- /dev/null +++ b/.settings/org.eclipse.jdt.launching.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.launching.PREF_COMPILER_COMPLIANCE_DOES_NOT_MATCH_JRE=warning +org.eclipse.jdt.launching.PREF_STRICTLY_COMPATIBLE_JRE_NOT_AVAILABLE=warning diff --git a/.settings/org.eclipse.ltk.core.refactoring.prefs b/.settings/org.eclipse.ltk.core.refactoring.prefs new file mode 100644 index 0000000..b196c64 --- /dev/null +++ b/.settings/org.eclipse.ltk.core.refactoring.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false diff --git a/Image/0.png b/Image/0.png new file mode 100644 index 0000000..d4965e0 Binary files /dev/null and b/Image/0.png differ diff --git a/Image/1.png b/Image/1.png new file mode 100644 index 0000000..fdc5a6b Binary files /dev/null and b/Image/1.png differ diff --git a/Image/2.png b/Image/2.png new file mode 100644 index 0000000..4c311f4 Binary files /dev/null and b/Image/2.png differ diff --git a/Image/3.png b/Image/3.png new file mode 100644 index 0000000..33a3847 Binary files /dev/null and b/Image/3.png differ diff --git a/Image/4.png b/Image/4.png new file mode 100644 index 0000000..558686e Binary files /dev/null and b/Image/4.png differ diff --git a/Image/5.png b/Image/5.png new file mode 100644 index 0000000..0d8968a Binary files /dev/null and b/Image/5.png differ diff --git a/Image/下发流程1.png b/Image/下发流程1.png new file mode 100644 index 0000000..0cbd70f Binary files /dev/null and b/Image/下发流程1.png differ diff --git a/Image/下发流程2.png b/Image/下发流程2.png new file mode 100644 index 0000000..c58305d Binary files /dev/null and b/Image/下发流程2.png differ diff --git a/Image/下发流程3.png b/Image/下发流程3.png new file mode 100644 index 0000000..7626900 Binary files /dev/null and b/Image/下发流程3.png differ diff --git a/Image/下发流程4.png b/Image/下发流程4.png new file mode 100644 index 0000000..7626900 Binary files /dev/null and b/Image/下发流程4.png differ diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF new file mode 100644 index 0000000..aeecb4c --- /dev/null +++ b/META-INF/MANIFEST.MF @@ -0,0 +1,133 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: cn.com.ebewin.ysr +Bundle-SymbolicName: cn.com.ebewin.ysr;singleton:=true +Bundle-Version: 1.0.0 +Bundle-Vendor: ebewin +Bundle-RequiredExecutionEnvironment: JavaSE-1.7, + JavaSE-1.8 +Require-Bundle: org.eclipse.ui;bundle-version="3.8.0", + org.eclipse.core.runtime;bundle-version="3.8.0", + com.teamcenter.rac.aifrcp;bundle-version="11000.2.0", + com.teamcenter.rac.common;bundle-version="11000.2.0", + com.teamcenter.rac.kernel;bundle-version="11000.2.0", + com.teamcenter.rac.tcapps;bundle-version="11000.2.0", + com.teamcenter.rac.util;bundle-version="11000.2.0", + com.teamcenter.rac.external;bundle-version="11000.2.0", + com.teamcenter.rac.ui;bundle-version="11000.2.0", + com.teamcenter.rac.workflow;bundle-version="11000.2.0", + org.apache.poi.39;bundle-version="3.9.0", + com.teamcenter.rac.schedule;bundle-version="11000.2.0", + TcSoaCoreRac;bundle-version="11000.2.0", + TcSoaCoreTypes;bundle-version="11000.2.0", + TcSoaWorkflowRac;bundle-version="11000.2.0", + TcSoaWorkflowTypes;bundle-version="11000.2.0" +Bundle-ClassPath: ., + sqljdbc4.jar, + jxl.jar, + ojdbc6.jar, + libs/axiom-api-1.2.20.jar, + libs/axiom-impl-1.2.20.jar, + libs/axis2-adb-1.7.8.jar, + libs/axis2-kernel-1.7.8.jar, + libs/axis2-transport-base-1.7.8.jar, + libs/axis2-transport-http-1.7.8.jar, + libs/axis2-transport-local-1.7.8.jar, + libs/classes12.jar, + libs/com.kostech.DesignChickList_1.0.0.0.jar, + libs/commons-beanutils-1.7.0.jar, + libs/commons-codec-1.2.jar, + libs/commons-collections-3.2.jar, + libs/commons-httpclient-3.1.jar, + libs/commons-io-2.1.jar, + libs/commons-lang-2.4.jar, + libs/commons-logging-1.1.1.jar, + libs/commons-logging-1.1.jar, + libs/dom4j-1.6.1.jar, + libs/ezmorph-1.0.4.jar, + libs/httpcore-4.4.6.jar, + libs/jdom.jar, + libs/json-lib-2.2.2-jdk15.jar, + libs/json-lib-2.2.3-jdk13.jar, + libs/log4j-1.2.15.jar, + libs/neethi-3.0.3.jar, + libs/ojdbc6.jar, + libs/soap-2.1.jar, + libs/woden-core-1.0M10.jar, + libs/wsdl4j-1.6.2.jar, + libs/xmlbeans-2.5.0.jar, + libs/xmlschema-core-2.2.1.jar, + libs/hutool-all-5.8.25.jar, + libs/easyexcel-4.0.3.jar, + libs/aspose-words-17.4.0-jdk16.jar, + libs/poi-3.17.jar, + libs/poi-examples-3.17.jar, + libs/poi-excelant-3.17.jar, + libs/poi-ooxml-3.17.jar, + libs/poi-ooxml-schemas-3.17.jar, + libs/poi-scratchpad-3.17.jar +Bundle-ActivationPolicy: lazy +Export-Package: cn.com.ebewin.ysr.dialog, + cn.com.ebewin.ysr.dialog.systemdatadistribution, + cn.com.ebewin.ysr.form, + cn.com.ebewin.ysr.handlers, + cn.com.ebewin.ysr.util, + cn.com.ebewin.ysr.view, + com.microsoft.sqlserver.jdbc, + common, + common.log, + jxl, + jxl.biff, + jxl.biff.drawing, + jxl.biff.formula, + jxl.demo, + jxl.format, + jxl.read.biff, + jxl.write, + jxl.write.biff, + microsoft.sql, + oracle.core.lmx, + oracle.core.lvf, + oracle.jdbc, + oracle.jdbc.aq, + oracle.jdbc.babelfish, + oracle.jdbc.connector, + oracle.jdbc.dcn, + oracle.jdbc.diagnostics, + oracle.jdbc.driver, + oracle.jdbc.internal, + oracle.jdbc.oci, + oracle.jdbc.oracore, + oracle.jdbc.pool, + oracle.jdbc.pooling, + oracle.jdbc.proxy, + oracle.jdbc.proxy.annotation, + oracle.jdbc.replay, + oracle.jdbc.replay.driver, + oracle.jdbc.replay.internal, + oracle.jdbc.rowset, + oracle.jdbc.util, + oracle.jdbc.xa, + oracle.jdbc.xa.client, + oracle.jpub.runtime, + oracle.net.ano, + oracle.net.aso, + oracle.net.jdbc.TNSAddress, + oracle.net.jdbc.nl, + oracle.net.jdbc.nl.mesg, + oracle.net.jndi, + oracle.net.ns, + oracle.net.nt, + oracle.net.resolver, + oracle.security.o3logon, + oracle.security.o5logon, + oracle.sql, + oracle.sql.converter +Import-Package: com.teamcenter.services.internal.rac.projectmanagement._2007_01, + com.teamcenter.services.internal.rac.projectmanagement._2011_06, + com.teamcenter.services.internal.rac.projectmanagement._2014_10, + com.teamcenter.services.rac.projectmanagement, + com.teamcenter.services.rac.projectmanagement._2011_06, + com.teamcenter.services.rac.projectmanagement._2012_02, + com.teamcenter.soa.exceptions + diff --git a/Rendering.xml b/Rendering.xml new file mode 100644 index 0000000..fcdd89c --- /dev/null +++ b/Rendering.xml @@ -0,0 +1,4770 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + > + + + + + + + > + + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Rendering1.xml b/Rendering1.xml new file mode 100644 index 0000000..f5d2443 --- /dev/null +++ b/Rendering1.xml @@ -0,0 +1,4411 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + > + + + + + + + > + + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Rendering2.xml b/Rendering2.xml new file mode 100644 index 0000000..9f53c82 --- /dev/null +++ b/Rendering2.xml @@ -0,0 +1,4657 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + > + + + + + + + > + + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Rendering20240822备份.xml b/Rendering20240822备份.xml new file mode 100644 index 0000000..80af3b9 --- /dev/null +++ b/Rendering20240822备份.xml @@ -0,0 +1,4764 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + > + + + + + + + > + + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/axiom-api-1.2.20.jar b/axiom-api-1.2.20.jar new file mode 100644 index 0000000..c7fca6c Binary files /dev/null and b/axiom-api-1.2.20.jar differ diff --git a/axis2-kernel-1.7.8.jar b/axis2-kernel-1.7.8.jar new file mode 100644 index 0000000..13eeb69 Binary files /dev/null and b/axis2-kernel-1.7.8.jar differ diff --git a/build.properties b/build.properties new file mode 100644 index 0000000..ac2afee --- /dev/null +++ b/build.properties @@ -0,0 +1,51 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + Image/,\ + Rendering.xml,\ + plugin.xml,\ + sqljdbc4.jar,\ + jxl.jar,\ + ojdbc6.jar,\ + libs/axiom-api-1.2.20.jar,\ + libs/axiom-impl-1.2.20.jar,\ + libs/axis2-adb-1.7.8.jar,\ + libs/axis2-kernel-1.7.8.jar,\ + libs/axis2-transport-base-1.7.8.jar,\ + libs/axis2-transport-http-1.7.8.jar,\ + libs/axis2-transport-local-1.7.8.jar,\ + libs/classes12.jar,\ + libs/com.kostech.DesignChickList_1.0.0.0.jar,\ + libs/commons-beanutils-1.7.0.jar,\ + libs/commons-codec-1.2.jar,\ + libs/commons-collections-3.2.jar,\ + libs/commons-httpclient-3.1.jar,\ + libs/commons-io-2.1.jar,\ + libs/commons-lang-2.4.jar,\ + libs/commons-logging-1.1.1.jar,\ + libs/commons-logging-1.1.jar,\ + libs/dom4j-1.6.1.jar,\ + libs/ezmorph-1.0.4.jar,\ + libs/httpcore-4.4.6.jar,\ + libs/jdom.jar,\ + libs/json-lib-2.2.2-jdk15.jar,\ + libs/json-lib-2.2.3-jdk13.jar,\ + libs/log4j-1.2.15.jar,\ + libs/neethi-3.0.3.jar,\ + libs/ojdbc6.jar,\ + libs/soap-2.1.jar,\ + libs/woden-core-1.0M10.jar,\ + libs/wsdl4j-1.6.2.jar,\ + libs/xmlbeans-2.5.0.jar,\ + libs/xmlschema-core-2.2.1.jar,\ + libs/hutool-all-5.8.25.jar,\ + libs/easyexcel-4.0.3.jar,\ + libs/aspose-words-17.4.0-jdk16.jar,\ + libs/poi-3.17.jar,\ + libs/poi-examples-3.17.jar,\ + libs/poi-excelant-3.17.jar,\ + libs/poi-ooxml-3.17.jar,\ + libs/poi-ooxml-schemas-3.17.jar,\ + libs/poi-scratchpad-3.17.jar +jars.compile.order = . diff --git a/jxl.jar b/jxl.jar new file mode 100644 index 0000000..b210c06 Binary files /dev/null and b/jxl.jar differ diff --git a/libs/aspose-words-17.4.0-jdk16.jar b/libs/aspose-words-17.4.0-jdk16.jar new file mode 100644 index 0000000..e8bd66c Binary files /dev/null and b/libs/aspose-words-17.4.0-jdk16.jar differ diff --git a/libs/axiom-api-1.2.20.jar b/libs/axiom-api-1.2.20.jar new file mode 100644 index 0000000..c7fca6c Binary files /dev/null and b/libs/axiom-api-1.2.20.jar differ diff --git a/libs/axiom-impl-1.2.20.jar b/libs/axiom-impl-1.2.20.jar new file mode 100644 index 0000000..2fd9d43 Binary files /dev/null and b/libs/axiom-impl-1.2.20.jar differ diff --git a/libs/axis2-adb-1.7.8.jar b/libs/axis2-adb-1.7.8.jar new file mode 100644 index 0000000..39459cd Binary files /dev/null and b/libs/axis2-adb-1.7.8.jar differ diff --git a/libs/axis2-kernel-1.7.8.jar b/libs/axis2-kernel-1.7.8.jar new file mode 100644 index 0000000..13eeb69 Binary files /dev/null and b/libs/axis2-kernel-1.7.8.jar differ diff --git a/libs/axis2-transport-base-1.7.8.jar b/libs/axis2-transport-base-1.7.8.jar new file mode 100644 index 0000000..f109cd3 Binary files /dev/null and b/libs/axis2-transport-base-1.7.8.jar differ diff --git a/libs/axis2-transport-http-1.7.8.jar b/libs/axis2-transport-http-1.7.8.jar new file mode 100644 index 0000000..d34c116 Binary files /dev/null and b/libs/axis2-transport-http-1.7.8.jar differ diff --git a/libs/axis2-transport-local-1.7.8.jar b/libs/axis2-transport-local-1.7.8.jar new file mode 100644 index 0000000..817280c Binary files /dev/null and b/libs/axis2-transport-local-1.7.8.jar differ diff --git a/libs/classes12.jar b/libs/classes12.jar new file mode 100644 index 0000000..9eaf0b4 Binary files /dev/null and b/libs/classes12.jar differ diff --git a/libs/com.kostech.DesignChickList_1.0.0.0.jar b/libs/com.kostech.DesignChickList_1.0.0.0.jar new file mode 100644 index 0000000..bd9294f Binary files /dev/null and b/libs/com.kostech.DesignChickList_1.0.0.0.jar differ diff --git a/libs/commons-beanutils-1.7.0.jar b/libs/commons-beanutils-1.7.0.jar new file mode 100644 index 0000000..b1b89c9 Binary files /dev/null and b/libs/commons-beanutils-1.7.0.jar differ diff --git a/libs/commons-codec-1.2.jar b/libs/commons-codec-1.2.jar new file mode 100644 index 0000000..67cb720 Binary files /dev/null and b/libs/commons-codec-1.2.jar differ diff --git a/libs/commons-collections-3.2.jar b/libs/commons-collections-3.2.jar new file mode 100644 index 0000000..75580be Binary files /dev/null and b/libs/commons-collections-3.2.jar differ diff --git a/libs/commons-httpclient-3.1.jar b/libs/commons-httpclient-3.1.jar new file mode 100644 index 0000000..7c59774 Binary files /dev/null and b/libs/commons-httpclient-3.1.jar differ diff --git a/libs/commons-io-2.1.jar b/libs/commons-io-2.1.jar new file mode 100644 index 0000000..b5c7d69 Binary files /dev/null and b/libs/commons-io-2.1.jar differ diff --git a/libs/commons-lang-2.4.jar b/libs/commons-lang-2.4.jar new file mode 100644 index 0000000..532939e Binary files /dev/null and b/libs/commons-lang-2.4.jar differ diff --git a/libs/commons-logging-1.1.1.jar b/libs/commons-logging-1.1.1.jar new file mode 100644 index 0000000..1deef14 Binary files /dev/null and b/libs/commons-logging-1.1.1.jar differ diff --git a/libs/commons-logging-1.1.jar b/libs/commons-logging-1.1.jar new file mode 100644 index 0000000..2ff9bbd Binary files /dev/null and b/libs/commons-logging-1.1.jar differ diff --git a/libs/dom4j-1.6.1.jar b/libs/dom4j-1.6.1.jar new file mode 100644 index 0000000..c8c4dbb Binary files /dev/null and b/libs/dom4j-1.6.1.jar differ diff --git a/libs/easyexcel-4.0.3.jar b/libs/easyexcel-4.0.3.jar new file mode 100644 index 0000000..f40b0ff Binary files /dev/null and b/libs/easyexcel-4.0.3.jar differ diff --git a/libs/ezmorph-1.0.4.jar b/libs/ezmorph-1.0.4.jar new file mode 100644 index 0000000..7625af6 Binary files /dev/null and b/libs/ezmorph-1.0.4.jar differ diff --git a/libs/httpcore-4.4.6.jar b/libs/httpcore-4.4.6.jar new file mode 100644 index 0000000..16ed0d1 Binary files /dev/null and b/libs/httpcore-4.4.6.jar differ diff --git a/libs/hutool-all-5.8.25.jar b/libs/hutool-all-5.8.25.jar new file mode 100644 index 0000000..c0d7831 Binary files /dev/null and b/libs/hutool-all-5.8.25.jar differ diff --git a/libs/jdom.jar b/libs/jdom.jar new file mode 100644 index 0000000..65a1b3f Binary files /dev/null and b/libs/jdom.jar differ diff --git a/libs/jfxrt.jar b/libs/jfxrt.jar new file mode 100644 index 0000000..cfe922d Binary files /dev/null and b/libs/jfxrt.jar differ diff --git a/libs/json-lib-2.2.2-jdk15.jar b/libs/json-lib-2.2.2-jdk15.jar new file mode 100644 index 0000000..27e7c7c Binary files /dev/null and b/libs/json-lib-2.2.2-jdk15.jar differ diff --git a/libs/json-lib-2.2.3-jdk13.jar b/libs/json-lib-2.2.3-jdk13.jar new file mode 100644 index 0000000..a6513db Binary files /dev/null and b/libs/json-lib-2.2.3-jdk13.jar differ diff --git a/libs/log4j-1.2.15.jar b/libs/log4j-1.2.15.jar new file mode 100644 index 0000000..c930a6a Binary files /dev/null and b/libs/log4j-1.2.15.jar differ diff --git a/libs/neethi-3.0.3.jar b/libs/neethi-3.0.3.jar new file mode 100644 index 0000000..38b77ff Binary files /dev/null and b/libs/neethi-3.0.3.jar differ diff --git a/libs/ojdbc6.jar b/libs/ojdbc6.jar new file mode 100644 index 0000000..c14cac4 Binary files /dev/null and b/libs/ojdbc6.jar differ diff --git a/libs/poi-3.17.jar b/libs/poi-3.17.jar new file mode 100644 index 0000000..353ce76 Binary files /dev/null and b/libs/poi-3.17.jar differ diff --git a/libs/poi-examples-3.17.jar b/libs/poi-examples-3.17.jar new file mode 100644 index 0000000..a923b04 Binary files /dev/null and b/libs/poi-examples-3.17.jar differ diff --git a/libs/poi-excelant-3.17.jar b/libs/poi-excelant-3.17.jar new file mode 100644 index 0000000..da9f5ed Binary files /dev/null and b/libs/poi-excelant-3.17.jar differ diff --git a/libs/poi-ooxml-3.17.jar b/libs/poi-ooxml-3.17.jar new file mode 100644 index 0000000..68086e8 Binary files /dev/null and b/libs/poi-ooxml-3.17.jar differ diff --git a/libs/poi-ooxml-schemas-3.17.jar b/libs/poi-ooxml-schemas-3.17.jar new file mode 100644 index 0000000..2e9b3e7 Binary files /dev/null and b/libs/poi-ooxml-schemas-3.17.jar differ diff --git a/libs/poi-scratchpad-3.17.jar b/libs/poi-scratchpad-3.17.jar new file mode 100644 index 0000000..12ba1f1 Binary files /dev/null and b/libs/poi-scratchpad-3.17.jar differ diff --git a/libs/soap-2.1.jar b/libs/soap-2.1.jar new file mode 100644 index 0000000..744ec3c Binary files /dev/null and b/libs/soap-2.1.jar differ diff --git a/libs/woden-core-1.0M10.jar b/libs/woden-core-1.0M10.jar new file mode 100644 index 0000000..9777ad9 Binary files /dev/null and b/libs/woden-core-1.0M10.jar differ diff --git a/libs/wsdl4j-1.6.2.jar b/libs/wsdl4j-1.6.2.jar new file mode 100644 index 0000000..b9ffc36 Binary files /dev/null and b/libs/wsdl4j-1.6.2.jar differ diff --git a/libs/xmlbeans-2.5.0.jar b/libs/xmlbeans-2.5.0.jar new file mode 100644 index 0000000..c368fb2 Binary files /dev/null and b/libs/xmlbeans-2.5.0.jar differ diff --git a/libs/xmlschema-core-2.2.1.jar b/libs/xmlschema-core-2.2.1.jar new file mode 100644 index 0000000..cab69fd Binary files /dev/null and b/libs/xmlschema-core-2.2.1.jar differ diff --git a/ojdbc6.jar b/ojdbc6.jar new file mode 100644 index 0000000..d273b89 Binary files /dev/null and b/ojdbc6.jar differ diff --git a/plugin.xml b/plugin.xml new file mode 100644 index 0000000..dd26c90 --- /dev/null +++ b/plugin.xml @@ -0,0 +1,411 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sqljdbc4.jar b/sqljdbc4.jar new file mode 100644 index 0000000..b73ace0 Binary files /dev/null and b/sqljdbc4.jar differ diff --git a/src/cn/com/ebewin/ysr/dialog/AssignProjectDialog.java b/src/cn/com/ebewin/ysr/dialog/AssignProjectDialog.java new file mode 100644 index 0000000..f85198c --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/AssignProjectDialog.java @@ -0,0 +1,345 @@ +/* +#============================================================================= +# +# 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.com.ebewin.ysr.dialog; + +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.util.Enumeration; +import java.util.Hashtable; +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.TCComponentContextList; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentProjectType; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTextService; +import com.teamcenter.rac.util.ButtonLayout; +import com.teamcenter.rac.util.HorizontalLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.VerticalLayout; + +import cn.com.ebewin.ysr.util.TCUtil; + +/** + * @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 jt2; + private InterfaceAIFComponent[] targets; + + 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 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 TCComponentProjectType tccomponentprojecttype = (TCComponentProjectType) session.getTypeComponent("TC_Project"); + final Vector list = new Vector<>();//listPro("*"); + if(targets.length==1) { + TCComponent[] projects = ((TCComponent)targets[0]).getReferenceListProperty("project_list"); + for(TCComponent p : projects) { + String id = p.getProperty("project_id"); + list.add(id); + targetM.addElement(id); + } + } + String user = session.getUser().getUserId(); + final Vector projs = new Vector<>(); +// Vector prov = new Vector<>();//listDCProjTemplFolder(); + //TODO +// String options[] = session.getPreferenceService().getStringValues("Meling_SqlServer"); +// Connection connection = SqlUtil.getSqlserverConnection(options[0], options[1], options[2], options[3]); +// List> search = SqlUtil.getDBInfo(connection, "select a0.pproject_id as id " + Connection connection = TCUtil.getDBConn(session); +// String sql = "select a0.pproject_id as id " +// + "from PTC_PROJECT a0,PPROJECT_MEMBERS a,PPOM_MEMBER b,PPOM_USER c,PPOM_GROUP d " +// + "where a0.rproject_teamu=a.puid and a.pvalu_0=b.puid and b.ruseru=c.puid and b.rgroupu=d.puid " +// + "and d.pprivilege=1 and a0.pis_visible=1 and c.puser_id='"+user+"'"; + String sql = "select distinct a.pproject_id as ID from PTC_PROJECT a,PPOM_MEMBER b,PPOM_USER c " + + "where a.rproject_teamu=b.rgroupu and b.ruseru=c.puid and a.pis_visible=1 and c.puser_id='"+user+"'"; + Vector> search = TCUtil.getDBInfo3Sub(connection, sql); + for(Hashtable t : search) { + String id = t.get("ID").toString(); + projs.add(id); + if(!list.contains(id)) + projectM.addElement(id); + } + 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(210,310)); + 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(210,310)); + + 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); + addbtn.setEnabled(false); + } + }); + removebtn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent actionevent) { + String select = targetList.getSelectedValue(); + if(select==null) + return; + projectM.addElement(select); + targetM.removeElement(select); + if(targetM.isEmpty()) + addbtn.setEnabled(true); + else + addbtn.setEnabled(false); + } + }); + 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", removebtn); + 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 HorizontalLayout()); + jt2 = new JTextField(20); + JButton screenbtn = new JButton("ɸѡ"); + screenbtn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent actionevent) { + String text = jt2.getText(); + Enumeration e = targetM.elements(); + Vector v = new Vector<>(); + while(e.hasMoreElements()) { + v.add(e.nextElement()); + } + projectM.removeAllElements(); + for(String t : projs) { + if(t.contains(text) && !v.contains(t)) + projectM.addElement(t); + } + } + }); + jt2.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent actionevent) { + String text = jt2.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("left.bind.center.center", new JLabel("Ŀɸѡ")); + jp1.add("unbound.bind.center.center", jt2); + jp1.add("right.bind.center.center", screenbtn); + + JPanel butPanel = new JPanel(new ButtonLayout()); + JButton okbtn = new JButton("ȷ"); + JButton canceltn = new JButton("ȡ"); + butPanel.add(okbtn); + 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); + okbtn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent actionevent) { + try { + Enumeration e = targetM.elements(); + Vector v = new Vector<>(); + while(e.hasMoreElements()) { + v.add(e.nextElement()); + } +// for(String s : list) { +// if(!v.contains(s)) { +// TCComponentProject ps = listPro(s).get(0); +// tccomponentprojecttype.removeFromProject(ps, new TCComponent[] { targets }); +// } +// } + if(v.size()==0) { + for(InterfaceAIFComponent c : targets) { + TCComponent[] projects = ((TCComponent)c).getReferenceListProperty("project_list"); + for(TCComponent p : projects) { + tccomponentprojecttype.removeFromProject((TCComponentProject) p, new TCComponent[] { (TCComponent) c }); + } + } + MessageBox.post(AIFUtility.getActiveDesktop(), "ѴĿƳ", "ʾ", MessageBox.INFORMATION); + dispose(); + return; + } + TCComponentProject ps = listPro(v.get(0)).get(0); + for(InterfaceAIFComponent c : targets) { + TCComponent[] projects = ((TCComponent)c).getReferenceListProperty("project_list"); + for(TCComponent p : projects) { + if(!v.contains(p.getProperty(""))) { + tccomponentprojecttype.removeFromProject((TCComponentProject) p, new TCComponent[] { (TCComponent) c }); + } + } + tccomponentprojecttype.assignToProject(ps, (TCComponent) c); + } + MessageBox.post(AIFUtility.getActiveDesktop(), "ָĿɣ", "ʾ", MessageBox.INFORMATION); + dispose(); + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post(AssignProjectDialog.this, ""+TCUtil.getStackTrace(e), "", MessageBox.ERROR); + } + } + }); + + add(jpx); +// setResizable(false); + pack(); + centerToScreen(); + setVisible(true); + } + + /** + * listPro:ȡϵͳеĿ + */ + private Vector listPro(String str_value) { + Vector result = new Vector(); + try { + String str_key = "project_id"; + TCTextService textService = session.getTextService(); + TCComponentQueryType querytype = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) querytype.find("Ŀ..."); + if (null == query) { + MessageBox.post(AIFUtility.getActiveDesktop(), "ȴѯ Ŀ... ", "", MessageBox.ERROR); + return null; + } + + querytype.clearCache(); + String as[] = { textService.getTextValue(str_key), textService.getTextValue("is_active")}; + // String as[] = { "project_name" }; + System.out.println("getTextValue===========" + textService.getTextValue(str_key)); + String as1[] = new String[2]; + as1[0] = str_value; + as1[1] = "true"; + query.clearCache(); + TCComponentContextList list = query.getExecuteResultsList(as, as1); // as + // =ѯkey + // ; + // as1 + // =ѯvalue + TCComponentProject tcpro = null; + + if (list != null) { + int count = list.getListCount(); + System.out.println(" pro coutn " + count); + for (int i = 0; i < count; i++) { + tcpro = (TCComponentProject) list.get(i).getComponent(); + result.add(tcpro); + } + } + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post(AssignProjectDialog.this, ""+TCUtil.getStackTrace(e), "", MessageBox.ERROR); + } + return result; + } + +} diff --git a/src/cn/com/ebewin/ysr/dialog/AssignProjectHandler.java b/src/cn/com/ebewin/ysr/dialog/AssignProjectHandler.java new file mode 100644 index 0000000..3ec3b67 --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/AssignProjectHandler.java @@ -0,0 +1,38 @@ +package cn.com.ebewin.ysr.dialog; + +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(); + final InterfaceAIFComponent[] pasteTargets = app.getTargetComponents(); + 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/com/ebewin/ysr/dialog/ConditionMapper.java b/src/cn/com/ebewin/ysr/dialog/ConditionMapper.java new file mode 100644 index 0000000..6aeccd7 --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/ConditionMapper.java @@ -0,0 +1,25 @@ +package cn.com.ebewin.ysr.dialog; + +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/com/ebewin/ysr/dialog/CustomizationDialog.java b/src/cn/com/ebewin/ysr/dialog/CustomizationDialog.java new file mode 100644 index 0000000..dd1e45f --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/CustomizationDialog.java @@ -0,0 +1,444 @@ +package cn.com.ebewin.ysr.dialog; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.Date; +import java.util.HashMap; +import java.util.Vector; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableRowSorter; + +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +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 com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +import cn.com.ebewin.ysr.util.DialogUtil; +import cn.com.ebewin.ysr.util.FormUtil; +import cn.com.ebewin.ysr.util.TCUtil; +import cn.com.ebewin.ysr.util.UIUtil.JTableInfo; +import jxl.Workbook; +import jxl.format.Alignment; +import jxl.format.Border; +import jxl.format.BorderLineStyle; +import jxl.format.VerticalAlignment; +import jxl.write.Label; +import jxl.write.WritableCellFormat; +import jxl.write.WritableFont; +import jxl.write.WritableSheet; +import jxl.write.WritableWorkbook; +import jxl.write.WriteException; + +public class CustomizationDialog extends JFrame { + private static final long serialVersionUID = 1L; + DialogUtil fu = new DialogUtil(this, "Ƽ", "YSR8_CustomizationDialog"); + + + TCSession session; + HashMap mcslMap = new HashMap();// map + HashMap> tymlMap = new HashMap>();//ͼĿ¼ map + protected String xmhStr; + public CustomizationDialog(TCSession session) throws TCException { + + fu.initializeUI(session); + Comparator comparator = new Comparator() { + public int compare(Object arg0, Object arg1) { + try { + int a = Integer.parseInt(arg0.toString()); + int b = Integer.parseInt(arg1.toString()); + return a - b; + } catch (NumberFormatException e) { + return 0; + } + } + }; + // lidy20180824ҡšаֵС + JTable table = (JTable) fu.allComponentMap.get("a.21.11.11"); + JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.21.11.11"); + final TableRowSorter sorter = new TableRowSorter(ci.dataTableModel); + sorter.setComparator(0, comparator); + table.setRowSorter(sorter); + + + this.setLocationRelativeTo(null); + this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); + this.session = session; + //loadRendering(); + addActionListener(); + setVisible(true); + } + +// private void loadRendering() throws TCException {} +// + private void addActionListener() { + //ѯĿ + JButton btn = (JButton)fu.allComponentMap.get("b.11.12"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + JTextField xmhText = (JTextField)fu.allComponentMap.get("XMH"); + xmhStr = xmhText.getText(); + if(xmhStr == null || xmhStr.isEmpty()) { + MessageBox.post("дĿţ","ʾ",2); + return; + }else { + //ѯĿ + String XTZML = xmhStr+"_XTZML"; + TCComponentItem item = null; + try { + + TCComponentItemType itemType = (TCComponentItemType) session + .getTypeComponent("Item"); + item = itemType.find(XTZML); + TCComponentForm form = TCUtil.getItemRevisionMasterForm(item.getLatestItemRevision()); + //ȡ + TCProperty ysr8_ID = form.getTCProperty("ysr8_ID"); + String[] Ysr8_IDs = ysr8_ID.getStringArrayValue(); + //ȡ + TCProperty ysr8_Quantity = form.getTCProperty("ysr8_Quantity"); + double[] ysr8_Quantitys = ysr8_Quantity.getDoubleArrayValue(); + JComboBox zxmhCom = (JComboBox)fu.allComponentMap.get("ZXMH"); + //ԭid + zxmhCom.removeAllItems(); + zxmhCom.setSelectedItem(""); + for (int i = 0; i < Ysr8_IDs.length; i++) { + zxmhCom.addItem(Ysr8_IDs[i]); + mcslMap.put(Ysr8_IDs[i], ysr8_Quantitys[i]+""); + } + } catch (Exception e2) { + e2.printStackTrace(); + if(item == null) { + MessageBox.post("дĿϵͳĿ¼δҵ","ʾ",2); + } + + return; + } + + } + } + }); + + btn = (JButton)fu.allComponentMap.get("b.11.15"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + JComboBox zxmhCom = (JComboBox)fu.allComponentMap.get("ZXMH"); + String selectZXMH = (String)zxmhCom.getSelectedItem(); + + if(selectZXMH == null || selectZXMH.isEmpty()) {//ѯ + JTextField xmhText = (JTextField)fu.allComponentMap.get("XMH"); + xmhStr = xmhText.getText(); + String XTZML = xmhStr+"_XTZML"; + TCComponentItem item = null; + String[] Ysr8_IDs= {}; + try { + TCComponentItemType itemType = (TCComponentItemType) session + .getTypeComponent("Item"); + item = itemType.find(XTZML); + TCComponentForm tymlForm = TCUtil.getItemRevisionMasterForm(item.getLatestItemRevision()); + //ȡ + TCProperty ysr8_ID = tymlForm.getTCProperty("ysr8_ID"); + Ysr8_IDs = ysr8_ID.getStringArrayValue(); + //ȡ + TCProperty ysr8_Quantity = tymlForm.getTCProperty("ysr8_Quantity"); + double[] ysr8_Quantitys = ysr8_Quantity.getDoubleArrayValue(); + for (int i = 0; i < Ysr8_IDs.length; i++) { + mcslMap.put(Ysr8_IDs[i], ysr8_Quantitys[i]+""); + } + }catch (Exception e1) { + // TODO: handle exception + e1.printStackTrace(); + } + //table + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a.21.11.11"); + int rowCount = ci.dataTableModel.getRowCount(); + for(int i = rowCount - 1; i >= 0; i--){ + ci.dataTableModel.removeRow(i); + } + ci.dataTableModel.getDataVector().clear(); + + for (String key : Ysr8_IDs) { + //ѯѡĿ + //ȡ table + System.out.println("111"); + + try { + //ѯͼĿ¼ + TCComponentItem tyml= getTYML(key); + //ȡѯ + if(tyml != null) { + TCComponentForm form = TCUtil.getItemRevisionMasterForm(tyml.getLatestItemRevision()); + //ȡ + TCProperty th = form.getTCProperty("ysr8_Code"); + String[] ths = th.getStringArrayValue(); + //ȡ + TCProperty sl = form.getTCProperty("ysr8_TotalCount"); + String[] sls = sl.getStringArrayValue(); + //ȡע + TCProperty bz = form.getTCProperty("ysr8_DrawingRemark"); + String[] bzs = bz.getStringArrayValue(); + //ȡ + TCProperty mc = form.getTCProperty("ysr8_Name"); + String[] mcs = mc.getStringArrayValue(); + //ȡ + TCProperty xh = form.getTCProperty("ysr8_SerialNo"); + String[] xhs = mc.getStringArrayValue(); + + //ͨע ǶƼ + System.out.println("222"); + for (int i = 0; i < ths.length; i++) { + if(sls[i] != null && !(sls[i].equals("")) && xhs[i] != null && !(xhs[i].equals("0")) && bzs[i] != null && bzs[i].equals("Ƽ")) { + Vector vec = new Vector<>(); + vec.add(xmhStr);//Ŀ + vec.add(key);//Ŀ + vec.add(ths[i]);//ͼ + vec.add(mcs[i]);// + vec.add(transform(mcslMap.get(key)));//о + vec.add(transform(sls[i]));// + vec.add(getTotal(mcslMap.get(key),sls[i]));// = * о + vec.add(getGc(ths[i]));//Ƽ ͨͼŲѯysr8_DZJCJ,°汾 + ci.dataTableModel.addRow(vec); + } + } + } + + + } catch (Exception e2) { + // TODO: handle exception + e2.printStackTrace(); + } + + + } + }else {//ѯѡĿ + //ȡ table + System.out.println("111"); + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a.21.11.11"); + int rowCount = ci.dataTableModel.getRowCount(); + for(int i = rowCount - 1; i >= 0; i--){ + ci.dataTableModel.removeRow(i); + } + ci.dataTableModel.getDataVector().clear(); + try { + //ѯͼĿ¼ + TCComponentItem tyml= getTYML(selectZXMH); + //ȡѯ + if(tyml != null) { + TCComponentForm form = TCUtil.getItemRevisionMasterForm(tyml.getLatestItemRevision()); + //ȡ + TCProperty th = form.getTCProperty("ysr8_Code"); + String[] ths = th.getStringArrayValue(); + //ȡ + TCProperty sl = form.getTCProperty("ysr8_TotalCount"); + String[] sls = sl.getStringArrayValue(); + //ȡע + TCProperty bz = form.getTCProperty("ysr8_DrawingRemark"); + String[] bzs = bz.getStringArrayValue(); + //ȡ + TCProperty mc = form.getTCProperty("ysr8_Name"); + String[] mcs = mc.getStringArrayValue(); + //ȡ + TCProperty xh = form.getTCProperty("ysr8_SerialNo"); + String[] xhs = mc.getStringArrayValue(); + + //ͨע ǶƼ + System.out.println("222"); + for (int i = 0; i < ths.length; i++) { + if(sls[i] != null && !(sls[i].equals("")) && xhs[i] != null && !(xhs[i].equals("0")) && bzs[i] != null && bzs[i].equals("Ƽ")) { + Vector vec = new Vector<>(); + vec.add(xmhStr);//Ŀ + vec.add(selectZXMH);//Ŀ + vec.add(ths[i]);//ͼ + vec.add(mcs[i]);// + vec.add(transform(mcslMap.get(selectZXMH)));//о + vec.add(transform(sls[i]));// + vec.add(getTotal(mcslMap.get(selectZXMH),sls[i]));// = * о + vec.add(getGc(ths[i]));//Ƽ ͨͼŲѯysr8_DZJCJ,°汾 + ci.dataTableModel.addRow(vec); + } + } + } + + + } catch (Exception e2) { + // TODO: handle exception + e2.printStackTrace(); + } + + } + } + }); + + btn = (JButton)fu.allComponentMap.get("b.11.16"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + outputERPInfo(); + } + }); + } + + + + protected String getGc(String string) { + // TODO Auto-generated method stub + String stringProperty=""; + try{ + TCComponentItemType itemType = (TCComponentItemType) session + .getTypeComponent("Item"); + TCComponentItem item = itemType.find(string); + TCComponentForm form = TCUtil.getItemRevisionMasterForm(item.getLatestItemRevision()); + stringProperty = form.getStringProperty("ysr8_DZJCJ"); + }catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + return stringProperty; +} + + //ȥС + public String transform(String str) { + String intNumber=str; + if(str.contains(".")) { + intNumber = str.substring(0,str.indexOf(".")); + } + return intNumber; + } + + protected String getTotal(String mc, String jj) { + // TODO Auto-generated method stub + double dMc = Double.parseDouble(mc); + double dJj = Double.parseDouble(jj); + int total = (int)(dMc*dJj); + + return total+""; +} + + protected TCComponentItem getTYML(String selectZXMH) { + // TODO Auto-generated method stub + //ƴӲѯid + String id = selectZXMH+"_TM*"; + TCComponent[] search; + try { + search = session.search(" ID", new String[] { " ID" }, new String[] { id }); + for (int i = 0; i < search.length; i++) { + TCComponentItem item = (TCComponentItem) search[i]; + //TCComponent referenceProperty = item.getLatestItemRevision().getReferenceProperty("release_status_list"); + + TCComponent[] statuss = item.getLatestItemRevision().getReferenceListProperty("release_status_list"); + for (int j = 0; j < statuss.length; j++) { + String status = statuss[j].getStringProperty("name"); + //״̬Ϊ ʽ· + System.out.println("status==="+status); + System.out.println("id==="+id); + if(status != null && status.equals("YSR8_customY")) { + return item; + } + } + + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; +} + + private void outputERPInfo() { + final JTable table = (JTable)fu.allComponentMap.get("a.21.11.11"); + final JButton btn = (JButton)fu.allComponentMap.get("b.11.16"); + btn.setEnabled(false); + final ProgressReporterDialog reporter = new ProgressReporterDialog(); + reporter.reportProgressMessage("ڵ,Ժ..."); + new Thread(reporter).start(); + new Thread() { + public void run() { + try { + Date date = new Date(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + String time = sdf.format(date); + String toPath = System.getProperty("java.io.tmpdir") + "Ƽ" + time + ".xls"; + // һдWorkbook + WritableWorkbook writeWorkBook = Workbook.createWorkbook(new File(toPath)); + // + WritableSheet wsheet = writeWorkBook.createSheet("Ƽ", 0); + + //д + int columnCount = table.getColumnCount(); // + int rowCount = table.getRowCount(); // + String[] titles = new String[columnCount]; // ͷ + + // ȡͷ + for (int i = 0; i < columnCount; i++) { + titles[i] = table.getColumnName(i); + } + + int current_row = 0; // ʼǰΪʼ + + try { + // ʽ + WritableFont titleFont = new WritableFont(WritableFont.createFont(""), 13,WritableFont.BOLD); + WritableCellFormat titleCellFormat = new WritableCellFormat(titleFont); + titleCellFormat.setBorder(Border.ALL, BorderLineStyle.MEDIUM); + titleCellFormat.setAlignment(Alignment.CENTRE); + titleCellFormat.setVerticalAlignment(VerticalAlignment.CENTRE); + titleCellFormat.setWrap(true); + + // ʽ + WritableFont contentFont = new WritableFont(WritableFont.createFont(""), 12); + WritableCellFormat contentCellFormat = new WritableCellFormat(contentFont); + contentCellFormat.setBorder(Border.ALL, BorderLineStyle.THIN); + contentCellFormat.setAlignment(Alignment.CENTRE); + contentCellFormat.setVerticalAlignment(VerticalAlignment.CENTRE); + contentCellFormat.setWrap(true); + + // дб + for (int i = 0; i < columnCount; i++) { + Label labelTitle = new Label(i, current_row, titles[i], titleCellFormat); + wsheet.addCell(labelTitle); + } + + current_row = current_row + 1; + // д + for (int i = 0; i < rowCount; i++) { + for (int j = 0; j < columnCount; j++) { + Object objValue = table.getValueAt(i, j); + Label labelContent = new Label(j, i + current_row, String.valueOf(objValue), contentCellFormat); + wsheet.addCell(labelContent); + } + } + + // øʽ + wsheet.getSettings().setDefaultColumnWidth(20); + writeWorkBook.write(); + writeWorkBook.close(); + } catch (WriteException e) { + e.printStackTrace(); + } + + // 򿪵ıļ + Runtime.getRuntime().exec("cmd /c \"" + toPath + "\""); + + } catch (IOException e) { + e.printStackTrace(); + } + reporter.requestCanceling(); + btn.setEnabled(true); + } + }.start(); + } + +} diff --git a/src/cn/com/ebewin/ysr/dialog/FuzzySearchComboBox.java b/src/cn/com/ebewin/ysr/dialog/FuzzySearchComboBox.java new file mode 100644 index 0000000..a4890d4 --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/FuzzySearchComboBox.java @@ -0,0 +1,60 @@ +package cn.com.ebewin.ysr.dialog; +import javax.swing.*; +import java.awt.event.*; + +public class FuzzySearchComboBox extends JComboBox { + + private DefaultComboBoxModel model; + private String currentText = ""; + private String[] items; + public FuzzySearchComboBox(String[] items) { + super(items); + this.items = items; + model = (DefaultComboBoxModel) getModel(); + setEditable(true); + final JTextField textField = (JTextField) getEditor().getEditorComponent(); + textField.addKeyListener(new KeyAdapter() { + @Override + public void keyReleased(KeyEvent e) { + currentText = textField.getText(); + filterItems(currentText); + } + }); + } + + private void filterItems(String text) { + String[] filteredItems = new String[items.length]; + int count = 0; + + for (String item : items) { + if (item.toLowerCase().contains(text.toLowerCase())) { + filteredItems[count++] = item; + } + } + + String[] finalFilteredItems = new String[count]; + System.arraycopy(filteredItems, 0, finalFilteredItems, 0, count); + + model.removeAllElements(); + for (String item : finalFilteredItems) { + model.addElement(item); + } + + if (finalFilteredItems.length > 0) { + setSelectedItem(finalFilteredItems[0]); + } + } + +// public static void main(String[] args) { +// String[] items = {"Apple", "Banana", "Cherry", "Date", "Elderberry", "Fig", "Grape"}; +// JFrame frame = new JFrame("Fuzzy Search ComboBox Example"); +// frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); +// frame.setSize(300, 200); +// frame.setLayout(new java.awt.FlowLayout()); +// +// FuzzySearchComboBox comboBox = new FuzzySearchComboBox(items); +// frame.add(comboBox); +// +// frame.setVisible(true); +// } +} \ No newline at end of file diff --git a/src/cn/com/ebewin/ysr/dialog/KBatchImportBean.java b/src/cn/com/ebewin/ysr/dialog/KBatchImportBean.java new file mode 100644 index 0000000..df778ca --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/KBatchImportBean.java @@ -0,0 +1,152 @@ +package cn.com.ebewin.ysr.dialog; + +import java.io.File; + +import com.teamcenter.rac.kernel.TCComponentDataset; + +public class KBatchImportBean { + private TCComponentDataset dataset; + private boolean isSelected; + private boolean isDuplicate; + private String filePath; + private String fileName; + + KBatchImportBean(File file) { + this.filePath = file.getAbsolutePath(); + int index=filePath.lastIndexOf("\\"); + if(index>0) { + this.fileName=filePath.substring(index+1); + }else { + this.fileName=filePath; + } + this.isSelected = true; + } + + public void setSelected(boolean isSelected) { + this.isSelected = isSelected; + } + + public boolean isSelected() { + return this.isSelected; + } + + public boolean isDuplicated(String filePath) { + if(this.filePath.equals(filePath)) { + return true; + } + return false; + } + + + public void resetDuplicate() { + this.isDuplicate=false; + } + + public TCComponentDataset getDataset() { + return this.dataset; + } + + public boolean isDupicated() { + return this.isDuplicate; + } + + public String getFileName() { + return this.fileName; + } + + public String getPath() { + return this.filePath; + } + + /*private File[] getFiles() throws Exception { + File[] files = dataset.getFiles(""); + if (files == null || files.length == 0) { + throw new Exception("ݼ " + dataset + " ļ"); + } + return files; + }*/ + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof KBatchImportBean) { + KBatchImportBean bean = (KBatchImportBean) obj; + return bean.fileName.equals(this.fileName); + } + return false; + } + + @Override + public String toString() { + return this.fileName; + } + + public void download(String path) throws Exception { + /*for (File file : this.files) { + download(file, path); + }*/ + } + + /** + * ļ + * + * @param targetFile + * Ҫصļ + * @param path + * · + * @return trueسɹfalseʧ + */ + @SuppressWarnings("unused") + private File download(File targetFile, String path) throws Exception { + return null; + /*String fileName=targetFile.getName(); + int length = 2097152; + path = path + "\\"; + if (!new File(path).isDirectory()) { + if (new File(path).mkdirs()) { + System.out.println("·ɹ" + path); + } else { + System.out.println("·ʧܣ" + path); + throw new TCException("·ʧܣ" + path); + } + } + String outPath = path + fileName; + int i = 1; + int indexOfDot = outPath.lastIndexOf("."); + if(isDuplicated(fileName)) { + outPath = outPath.substring(0, indexOfDot) + "-[" + this.uid + "]" + outPath.substring(indexOfDot); + } + String overridePath = outPath; + indexOfDot = overridePath.lastIndexOf("."); + while (new File(overridePath).exists()) { + overridePath = outPath.substring(0, indexOfDot) + "-(" + (i++) + ")" + outPath.substring(indexOfDot); + } + outPath=overridePath; + FileOutputStream out = new FileOutputStream(outPath); + FileInputStream in = new FileInputStream(targetFile); + byte[] buffer = new byte[length]; + while (true) { + int ins = in.read(buffer); + if (ins == -1) { + in.close(); + out.flush(); + out.close(); + return new File(outPath); + } else + out.write(buffer, 0, ins); + }*/ + } + + /*public static void main(String[] args) { + String outPath = "C:\\test\\1.txt"; + String overridePath = outPath; + int i = 1; + int indexOfDot = outPath.lastIndexOf("."); + overridePath = outPath.substring(0, indexOfDot) + "(" + (i++) + ")" + outPath.substring(indexOfDot); + overridePath = outPath.substring(0, indexOfDot) + "(" + (i++) + ")" + outPath.substring(indexOfDot); + overridePath = outPath.substring(0, indexOfDot) + "(" + (i++) + ")" + outPath.substring(indexOfDot); + System.out.println(overridePath); + }*/ +} diff --git a/src/cn/com/ebewin/ysr/dialog/KBatchImportDialog.java b/src/cn/com/ebewin/ysr/dialog/KBatchImportDialog.java new file mode 100644 index 0000000..f2112c8 --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/KBatchImportDialog.java @@ -0,0 +1,168 @@ +package cn.com.ebewin.ysr.dialog; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.GridBagConstraints; +import java.awt.Insets; +import java.io.File; +import java.util.LinkedHashMap; +import java.util.Map; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JFileChooser; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; +import javax.swing.ListCellRenderer; +import javax.swing.ListSelectionModel; +import javax.swing.filechooser.FileSystemView; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.FileFilter; +import com.teamcenter.rac.util.MessageBox; + +public class KBatchImportDialog extends AbstractAIFDialog { + + private static final long serialVersionUID = 2009624329447981859L; +// private TCSession session; + + public KBatchImportDialog(TCSession session) { + super(false); +// this.session=session; + } + + @Override + public void run() { + 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(this); + if(state==1) { + return; + }else { + File folder = fileChooser.getSelectedFile(); + System.out.println("ѡ·"+folder.getAbsolutePath()); + String[] filters=new String[] {"*.xlsx","*.txt"}; + Map fileMap=readFiles(folder,filters); + if(fileMap!=null&&fileMap.size()>0) { + initUI(fileMap); + }else { + MessageBox.post("·ûҵxxxļ","ʾ",MessageBox.INFORMATION); + } + } + + } + + private void initUI(Map fileMap) { + this.setTitle("ļ"); + this.setPreferredSize(new Dimension(500, 300)); + this.setLayout(new BorderLayout()); + JTabbedPane tabPane=new JTabbedPane(JTabbedPane.LEFT); + JPanel btnPanel=new JPanel(new FlowLayout(FlowLayout.CENTER,15,3)); + + GridBagConstraints s=new GridBagConstraints(); + s.gridwidth=1; + s.gridheight=1; + s.gridx=0; + s.gridy=0; + s.weightx=1; + s.weighty=1; + s.insets=new Insets(5, 5, 0, 5); + // + for (String filter : fileMap.keySet()) { + JPanel aPanel=new JPanel(new BorderLayout()); + tabPane.add(filter, aPanel); + JList fileList = new JList<>(); + fileList.setPreferredSize(new Dimension(200, 200)); + //mainPanel.add(new JCheckBox(filter),s); + //s.gridy++; + File[] files = fileMap.get(filter); + int len=files.length; + KBatchImportBean[] listData=new KBatchImportBean[len]; + for(int i=0;i readFiles(File folder,String[] filters) { + Map result=new LinkedHashMap<>(); + if(folder!=null&&folder.isDirectory()) { + for (String filter : filters) { + File[] files = folder.listFiles(new FileFilter(filter)); + if(files.length>0) { + result.put(filter,files); + } + } + } + return result; + } + + /* JListʾѡ */ + @SuppressWarnings("serial") + class CheckBoxRenderer extends JCheckBox implements ListCellRenderer { + CheckBoxRenderer() { + } + + public Component getListCellRendererComponent(JList listBox, KBatchImportBean obj, int currentindex, boolean isChecked, boolean hasFocus) { + setSelected(obj.isSelected()); + if (isChecked) { + setForeground(Color.WHITE); + setBackground(new Color(51, 153, 255)); + if (obj.isDupicated()) { + setText(obj.toString() + "---ļظ:·" + obj.getPath() + ""); + } else { + setText(obj.toString()); + } + } else { + setBackground(Color.WHITE); + if (obj.isDupicated()) { + setForeground(new Color(51, 103, 205)); + setText(obj.toString() + "---ļظ:·" + obj.getPath() + ""); + } else { + setForeground(Color.BLACK); + setText(obj.toString()); + } + } + return this; + } + + } + + + + +} diff --git a/src/cn/com/ebewin/ysr/dialog/MachiningDynamicsColorRender.java b/src/cn/com/ebewin/ysr/dialog/MachiningDynamicsColorRender.java new file mode 100644 index 0000000..8812e47 --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/MachiningDynamicsColorRender.java @@ -0,0 +1,124 @@ +package cn.com.ebewin.ysr.dialog; + +import java.awt.Color; +import java.awt.Component; +import javax.swing.JTable; +import cn.com.ebewin.ysr.util.TableColorRender; + +public class MachiningDynamicsColorRender extends TableColorRender { + + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + Component renderer = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + if(isSelected) + renderer.setBackground(Color.BLUE); + else if(getTableVal(table, row, MachiningDynamicsManageDialog.BJ6).startsWith("׷滻")) + return renderer; + else if(getTableVal(table, row, MachiningDynamicsManageDialog.BJ21).equals("ϸ")) + renderer.setBackground(Color.GREEN); + else if(getTableVal(table, row, MachiningDynamicsManageDialog.BJ22).equals("ϸ")) + renderer.setBackground(Color.GREEN); + + /*if (column == 15) { + String ysr8_TechPlanDateVal = table.getValueAt(row, 15).toString(); + String ysr8_TechFinishDateVal = table.getValueAt(row, 16).toString(); + if (!ysr8_TechFinishDateVal.equals("-") && !ysr8_TechPlanDateVal.equals("-")) { + int nday = CommonUtil.getDaysBetween(ysr8_TechPlanDateVal, ysr8_TechFinishDateVal); + System.out.println("ysr8_TechFinishDateVal-ysr8_TechPlanDateVal====" + ysr8_TechFinishDateVal + "====" + + ysr8_TechPlanDateVal + "====" + nday); + if (nday > 0) { + renderer.setBackground(Color.RED); + } + } else { + if (ysr8_TechPlanDateVal.equals("-")) { + //renderer.setBackground(Color.RED); + } else { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + String currDate = sdf.format(new Date()); + int nday = CommonUtil.getDaysBetween(ysr8_TechPlanDateVal, currDate); + System.out.println("currDate-ysr8_TechPlanDateVal====" + currDate + "====" + ysr8_TechPlanDateVal + "====" + nday); + if (nday > 0) { + renderer.setBackground(Color.RED); + } + } + } + } else if (column == 18) { + String ysr8_PurchPlanDateVal = table.getValueAt(row, 18).toString(); + String ysr8_PurchFinishDateVal = table.getValueAt(row, 19).toString(); + if (!ysr8_PurchPlanDateVal.equals("-") && !ysr8_PurchFinishDateVal.equals("-")) { + int nday = CommonUtil.getDaysBetween(ysr8_PurchPlanDateVal, ysr8_PurchFinishDateVal); + System.out.println("ysr8_PurchFinishDateVal-ysr8_PurchPlanDateVal====" + ysr8_PurchFinishDateVal + "====" + + ysr8_PurchPlanDateVal + "====" + nday); + if (nday > 0) { + renderer.setBackground(Color.RED); + } + } else { + if (ysr8_PurchPlanDateVal.equals("-")) { + //renderer.setBackground(Color.RED); + } else { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + String currDate = sdf.format(new Date()); + int nday = CommonUtil.getDaysBetween(ysr8_PurchPlanDateVal, currDate); + System.out.println("currDate-ysr8_PurchPlanDateVal====" + currDate + "====" + ysr8_PurchPlanDateVal + "====" + nday); + if (nday > 0) { + renderer.setBackground(Color.RED); + } + } + } + } else if (column == 21) { + String ysr8_MachinPlanDateVal = table.getValueAt(row, 21).toString(); + String ysr8_PurchFinishDate2Val = table.getValueAt(row, 22).toString(); + if (!ysr8_MachinPlanDateVal.equals("-") && !ysr8_PurchFinishDate2Val.equals("-")) { + int nday = CommonUtil.getDaysBetween(ysr8_MachinPlanDateVal, ysr8_PurchFinishDate2Val); + System.out.println("ysr8_PurchFinishDateVal-ysr8_MachinPlanDateVal====" + ysr8_PurchFinishDate2Val + "====" + + ysr8_MachinPlanDateVal + "====" + nday); + if (nday > 0) { + renderer.setBackground(Color.RED); + } + } else { + if (ysr8_MachinPlanDateVal.equals("-")) { + //renderer.setBackground(Color.RED); + } else { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + String currDate = sdf.format(new Date()); + int nday = CommonUtil.getDaysBetween(ysr8_MachinPlanDateVal, currDate); + System.out.println("currDate-ysr8_PurchPlanDateVal====" + currDate + "====" + ysr8_MachinPlanDateVal + "====" + nday); + if (nday > 0) { + renderer.setBackground(Color.RED); + } + } + } + } else if (column == 25) { + String ysr8_EnginePlanDateVal = table.getValueAt(row, 25).toString(); + String ysr8_FinishDateVal = table.getValueAt(row, 26).toString(); + if (!ysr8_EnginePlanDateVal.equals("-") && !ysr8_FinishDateVal.equals("-")) { + int nday = CommonUtil.getDaysBetween(ysr8_EnginePlanDateVal, ysr8_FinishDateVal); + System.out.println("ysr8_PurchFinishDateVal-ysr8_EnginePlanDateVal====" + ysr8_FinishDateVal + "====" + + ysr8_EnginePlanDateVal + "====" + nday); + if (nday > 0) { + renderer.setBackground(Color.RED); + } + } else { + if (ysr8_EnginePlanDateVal.equals("-")) { + //renderer.setBackground(Color.RED); + } else { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + String currDate = sdf.format(new Date()); + int nday = CommonUtil.getDaysBetween(ysr8_EnginePlanDateVal, currDate); + System.out.println("currDate-ysr8_PurchPlanDateVal====" + currDate + "====" + ysr8_EnginePlanDateVal + "====" + nday); + if (nday > 0) { + renderer.setBackground(Color.RED); + } + } + } + }*/ + + return renderer; + } + private String getTableVal(JTable table, int row, int col) { + Object o = table.getValueAt(row, col); + if(o == null) + return ""; + else + return o.toString(); + } +} \ No newline at end of file diff --git a/src/cn/com/ebewin/ysr/dialog/MachiningDynamicsExWarehouseDialog.java b/src/cn/com/ebewin/ysr/dialog/MachiningDynamicsExWarehouseDialog.java new file mode 100644 index 0000000..0df7998 --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/MachiningDynamicsExWarehouseDialog.java @@ -0,0 +1,135 @@ +package cn.com.ebewin.ysr.dialog; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.text.SimpleDateFormat; +import java.util.Date; + +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +import cn.com.ebewin.ysr.dialog.MachiningDynamicsManageDialog.EditObjectInfo; +import cn.com.ebewin.ysr.util.KUtil; +import cn.com.ebewin.ysr.util.TCUtil; + +@SuppressWarnings("deprecation") +public class MachiningDynamicsExWarehouseDialog extends AbstractAIFDialog { + private static final long serialVersionUID = 1L; + private JButton okBtn; + private JButton cancelBtn; + private JTextField person; + private DateButton date; + + public MachiningDynamicsExWarehouseDialog(MachiningDynamicsManageDialog mdm, EditObjectInfo editObjectInfo) throws Exception { + super(mdm); + setTitle("Ϣ"); + JPanel propPanel = new JPanel(new PropertyLayout(70, 20, 10, 5, 20, 5)); +// TCComponentListOfValues[] lov = lovType.find("ML8_ProjectCategory_LOV"); +// String[] vals = getDynamicLOV(lov[0]); +// System.out.println("ML8_ProjectCategory_LOV:"+lov[0].getType()+"=="+vals.length); + JLabel label1 = new JLabel(" "); + propPanel.add("1.1.left.center", label1); + date = new DateButton(null, "yyyy-MM-dd", false, false, false); + date.setPreferredSize(new Dimension(150, 23)); + date.setDate(new Date()); + propPanel.add("1.2.left.center", date); + JLabel label2 = new JLabel(" "); + propPanel.add("2.1.left.center", label2); + person = new JTextField(); + person.setPreferredSize(new Dimension(150, 23)); + propPanel.add("2.2.left.center", person); + okBtn = new JButton("ȷ"); + cancelBtn = new JButton("ȡ"); + JPanel btnPanel = new JPanel(new FlowLayout()); + btnPanel.add(okBtn); + btnPanel.add(cancelBtn); + setLayout(new BorderLayout()); + add(BorderLayout.CENTER, propPanel); + add(BorderLayout.SOUTH, btnPanel); +// add(new JLabel("")); + addActionListener(mdm, editObjectInfo); + + pack(); + setSize(new Dimension(370, 180)); + setDefaultLookAndFeelDecorated(true); + Dimension screen = getToolkit().getScreenSize(); + setLocation((screen.width - getSize().width) / 2, (screen.height - getSize().height) / 2); +// setAlwaysOnTop(true); + setVisible(true); + } + + private void addActionListener(final MachiningDynamicsManageDialog mdm, final EditObjectInfo editObjectInfo) { + okBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent arg0) { + try { + String ysr8_ExWarehousePerson = person.getText(); + Date ysr8_ExWarehouseDate = date.getDate(); + if(ysr8_ExWarehousePerson.isEmpty() || ysr8_ExWarehouseDate==null) + throw new Exception("δд"); + String keys = "ysr8_ExWarehousePerson@@@@ysr8_ExWarehouseDate@@@@ysr8_ExWarehouseState@@@@ysr8_ExWarehouseQuantity", + date1 = getDateTimeString2(ysr8_ExWarehouseDate), date2 = String.format("%tF", ysr8_ExWarehouseDate); + for(int i=0; i allObjectMap1 = new HashMap(); + HashMap allObjectMap1Idx = new HashMap(); + HashMap allObjectMap2 = new HashMap(); + HashMap allObjectMap2Idx = new HashMap(); + int currTable = 0; + + public TCSession session; + LinkedHashMap lovysr8_SubTaskManuState; + LinkedHashMap lovysr8_SubChangeScheme; + LinkedHashMap lovysr8_Measures; + LinkedHashMap lovysr8_ExWarehouse; + private JButton searBtn; + private boolean isRemarkEditable; + private Date date1 = null; + private Date date2 = null; + +// private static final int T1_TASKNAME_INDEX = 6; + protected static final int BJ1_PROJECTID = 1; + protected static final int BJ2 = 2; + protected static final int BJ3 = 3; + protected static final int BJ4 = 4; + protected static final int BJ5 = 5; + protected static final int BJ6 = 6; + protected static final int BJ7 = 7; + protected static final int BJ8 = 8; + protected static final int BJ9 = 9; + protected static final int BJ10 = 10; + protected static final int BJ11 = 11; + protected static final int BJ12 = 12; + protected static final int BJ13 = 13; + protected static final int BJ14 = 14; + protected static final int BJ15 = 15; + protected static final int BJ16 = 16; + protected static final int BJ17 = 17; + protected static final int BJ18 = 18; + protected static final int BJ19 = 19; + protected static final int BJ20 = 20; + protected static final int BJ21 = 21; + protected static final int BJ22 = 22; + protected static final int BJ25 = 25; + protected static final int SJ1 = 1; + protected static final int SJ2 = 2; + protected static final int SJ3 = 3; + protected static final int SJ4 = 4; + protected static final int SJ5 = 5; + protected static final int SJ6 = 6; + protected static final int SJ7 = 7; + protected static final int SJ8 = 8; + protected static final int SJ9 = 9; + protected static final int SJ10 = 10; + protected static final int SJ11 = 11; + protected static final int SJ12 = 12; + protected static final int SJ13 = 13; + protected static final int SJ14 = 14; + protected static final int SJ15 = 15; + protected static final int SJ16 = 16; + protected static final int SJ17 = 17; + protected static final int SJ18 = 18; + protected static final int SJ19 = 19; + protected static final int SJ20 = 20; + protected static final int SJ21 = 21; + protected static final int SJ22 = 22; + protected static final int SJ23 = 23; + protected static final int SJ27 = 24; + protected static final int SJ24 = 25; + protected static final int FXZT = 26; + protected static final int SJ25 = 27; + protected static final int SJ26 = 28; + protected static final int SJ28 = 29; + protected static final int SJ29 = 30; + protected static final int SJ30 = 31; + protected static final int SJ31 = 32; + protected static final int SJ32 = 33; + protected static final int SJ33 = 34; + protected static final int SJ34 = 35; + + public class EditObjectInfo { + public Vector editObjects = new Vector(); + public Vector editObjectListIdxs = new Vector(); + public Vector editObjectMaterialID = new Vector(); + public Vector editObjectQuantity = new Vector(); + public Vector isLeadings = new Vector(); + public Vector rows = new Vector(); + } + + public MachiningDynamicsManageDialog(TCSession session) throws Exception { + // super(true);// + + this.session = session; + lovysr8_SubTaskManuState = TCUtil.getlovValues(session, "YSR8_ScheduleTask02_LOV"); + lovysr8_SubChangeScheme = TCUtil.getlovValues(session, "YSR8_ECN3_LOV"); + lovysr8_Measures = TCUtil.getlovValues(session, "YSR8_INSPR2_LOV"); + lovysr8_ExWarehouse = TCUtil.getlovValues(session, "YSR8_ExWarehouse_LOV"); + + // JScrollPane sp = (JScrollPane)fu.allComponentMap.get("sp"); + // sp.setRowHeaderView(view); + + fu.initializeUI(session); + + Comparator comparator = new Comparator() { + public int compare(Object arg0, Object arg1) { + try { + int a = Integer.parseInt(arg0.toString()); + int b = Integer.parseInt(arg1.toString()); + return a - b; + } catch (NumberFormatException e) { + return 0; + } + } + }; + // lidy20180824ҡšаֵС + JTable table = (JTable) fu.allComponentMap.get("a.41.11.11"); + JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.41.11.11"); + final TableRowSorter sorter = new TableRowSorter(ci.dataTableModel); + sorter.setComparator(0, comparator); + table.setRowSorter(sorter); + table.setDefaultRenderer(Object.class, new MachiningDynamicsColorRender()); + table = (JTable) fu.allComponentMap.get("a.61.11.11"); + ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.61.11.11"); + final TableRowSorter sorter2 = new TableRowSorter(ci.dataTableModel); + sorter2.setComparator(0, comparator); + table.setRowSorter(sorter2); + // centerToScreen(); + this.setLocationRelativeTo(null); + this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); + + loadRendering(); + addActionListener(); + setVisible(true); + } + + public class ColorTableRenderer extends DefaultTableCellRenderer { + + /** + * + */ + private static final long serialVersionUID = 1L; + private Color DEFBLUE = new Color(51, 153, 255); + private Color DEFGREEN = new Color(158, 234, 106); + + @Override + public Component getTableCellRendererComponent(JTable t, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + if (hasFocus) { + setBackground(DEFBLUE); + } else { + setBackground(Color.WHITE); + Object state = getTableVal(t, row, BJ19); + if(state!=null && column==BJ1_PROJECTID) { + String content = state.toString(); + if(content.equals("Ѽ")) { + setBackground(DEFGREEN); + } + } + } + return super.getTableCellRendererComponent(t, value, isSelected, hasFocus, row, column); + } + + } + + private void loadRendering() throws Exception { + } + + private void setEnableBtns(boolean b) { + JButton btn; + btn = (JButton) fu.allComponentMap.get("b.11.16"); + btn.setEnabled(b); + btn = (JButton) fu.allComponentMap.get("b.11.17"); + btn.setEnabled(b); + btn = (JButton) fu.allComponentMap.get("b.21.17"); + btn.setEnabled(b); + btn = (JButton) fu.allComponentMap.get("b.21.18"); + btn.setEnabled(b); + // ע + btn = (JButton) fu.allComponentMap.get("b.11.18"); +// System.out.println("ע:"+b +"||"+ isRemarkEditable); + btn.setEnabled(b || isRemarkEditable); + btn = (JButton) fu.allComponentMap.get("b.71.17"); + btn.setEnabled(b); + btn = (JButton) fu.allComponentMap.get("b.71.18"); + btn.setEnabled(b); + } + + private void addActionListener() { + searBtn = (JButton) fu.allComponentMap.get("b.11.16"); + searBtn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + new Thread(new Runnable() { + @Override + public void run() { + searBtn.setText("ѯ..."); + setEnableBtns(false); + try { + searchMachiningInfo(); + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post(MachiningDynamicsManageDialog.this, e.toString(), "ѯ", MessageBox.ERROR); + } + setEnableBtns(true); + searBtn.setText("ѯ"); + } + }).start(); + } + }); + + JButton btn; + btn = (JButton) fu.allComponentMap.get("b.11.17"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + editMachiningInfo(); + } + }); + + JButton btn1; + btn1 = (JButton) fu.allComponentMap.get("b.11.19"); + btn1.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + editTardiness();//ԭ + } + }); + /* + * btn = (JButton)fu.allComponentMap.get("b.11.18"); btn.addActionListener(new + * ActionListener() { public void actionPerformed(ActionEvent e) { + * submitInspectionProcess(); } }); + */ + + // btn = (JButton)fu.allComponentMap.get("b.11.19"); + // btn.addActionListener(new ActionListener() { + // public void actionPerformed(ActionEvent e) { + // startNextTask(); + // } + // }); + + btn = (JButton) fu.allComponentMap.get("b.21.17"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + outputMachiningInfo(); + } + }); + + btn = (JButton) fu.allComponentMap.get("b.21.18"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + pipingLinePlanningManagement(); + } + }); + + final JButton rbtn = (JButton) fu.allComponentMap.get("b.11.18"); + final TCComponentUser user = fu.session.getUser(); + isRemarkEditable = false; + // kk עť + btn = (JButton) fu.allComponentMap.get("b.11.18"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + try { + editRemark(); + } catch (Exception e1) { + MessageBox.post(MachiningDynamicsManageDialog.this, e1.toString(), "", MessageBox.ERROR); + e1.printStackTrace(); + } + } + }); + + try { + String machiningManager = + TCUtil.getPreference2(fu.session, TCPreferenceService.TC_preference_site, "YSR8_MachiningDynamics_MachiningManager"); + String userName = user.getProperty("user_name"); +// System.out.println("ע:"+machiningManager +"||"+ userName); + if (machiningManager.equals(userName)) { + isRemarkEditable = true; + } + String[] machiningManagers = + TCUtil.getPreference(fu.session, TCPreferenceService.TC_preference_site, "YSR8_MachiningDynamics_OnDutyMan"); + for (String s : machiningManagers) { +// System.out.println("ע:"+s +"||"+ userName); + if (s.equals(userName)) { + isRemarkEditable = true; + break; + } + } + btn.setEnabled(isRemarkEditable); + } catch (Exception e1) { + e1.printStackTrace(); + } + + final JTable table1 = (JTable) fu.allComponentMap.get("a.41.11.11"); + final JTable table2 = (JTable) fu.allComponentMap.get("a.61.11.11"); + + btn = (JButton) fu.allComponentMap.get("b.71.17"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + try { + System.out.println(""); + int[] rows = table2.getSelectedRows(); + if(rows==null || rows.length==0) { + MessageBox.post(MachiningDynamicsManageDialog.this, "ѡҪ༭ɢ", "ʾ", MessageBox.ERROR); + return; + } + String[] options = + TCUtil.getPreference(fu.session, TCPreferenceService.TC_preference_site, "YSR8_MachiningDynamics_ExWarehouse"); + boolean can = false; + if (options!=null && options.length>0) { + String name = user.getProperty("user_name"); + for (String onDutyMan : options) { + if (onDutyMan.equals(name)) { + can = true; + break; + } + } + } + if(!can) { + MessageBox.post(MachiningDynamicsManageDialog.this, "ǰû߱Ȩ", "ʾ", MessageBox.ERROR); + return; + } + EditObjectInfo editObjectInfo = new EditObjectInfo(); + for(int i : rows) { + String ysr8_ArrivedQuantity = getTableVal(table2, i, SJ23); + if(!getTableVal(table2, i, SJ14).equals(ysr8_ArrivedQuantity)) { + MessageBox.post(MachiningDynamicsManageDialog.this, ""+(i+1)+"δȫ޷޸ij״̬", "ʾ", MessageBox.ERROR); + return; + } + if(getTableVal(table2, i, SJ29).equals("ѳ")) { + MessageBox.post(MachiningDynamicsManageDialog.this, ""+(i+1)+"ѳ⣬ٲ", "ʾ", MessageBox.ERROR); + return; + } + int idx = Integer.parseInt(getTableVal(table2, i, 0)); + editObjectInfo.editObjects.add(allObjectMap2.get(idx - 1)); + editObjectInfo.editObjectListIdxs.add(allObjectMap2Idx.get(idx - 1)); + editObjectInfo.rows.add(i); + editObjectInfo.editObjectMaterialID.add(getTableVal(table2, i, SJ10)); + editObjectInfo.editObjectQuantity.add(getTableVal(table2, i, SJ23)); + } + new MachiningDynamicsExWarehouseDialog(MachiningDynamicsManageDialog.this, editObjectInfo); + } catch (Exception e1) { + e1.printStackTrace(); + MessageBox.post(MachiningDynamicsManageDialog.this, ""+e1.getMessage(), "", MessageBox.ERROR); + } + } + }); + + btn = (JButton) fu.allComponentMap.get("b.71.18"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + try { + int[] rows = table2.getSelectedRows(); + if(rows==null || rows.length==0) { + MessageBox.post(MachiningDynamicsManageDialog.this, "ѡҪ༭ɢ", "ʾ", MessageBox.ERROR); + return; + } + String[] options = + TCUtil.getPreference(fu.session, TCPreferenceService.TC_preference_site, "YSR8_MachiningDynamics_ExWarehouse"); + boolean can = false; + if (options!=null && options.length>0) { + String name = user.getProperty("user_name"); + for (String onDutyMan : options) { + if (onDutyMan.equals(name)) { + can = true; + break; + } + } + } + if(!can) { + MessageBox.post(MachiningDynamicsManageDialog.this, "ǰû߱Ȩ", "ʾ", MessageBox.ERROR); + return; + } + EditObjectInfo editObjectInfo = new EditObjectInfo(); + for(int i : rows) { +// if(!table2, i, 28).toString().equals("δ")) { +// MessageBox.post(MachiningDynamicsManageDialog.this, ""+(i+1)+"ѳ⣬ٲ", "ʾ", MessageBox.ERROR); +// return; +// } + String ysr8_ArrivedQuantity = getTableVal(table2, i, SJ23); + if(!getTableVal(table2, i, SJ14).equals(ysr8_ArrivedQuantity)) { + MessageBox.post(MachiningDynamicsManageDialog.this, ""+(i+1)+"δȫ޷޸ijⱸע", "ʾ", MessageBox.ERROR); + return; + } + int idx = Integer.parseInt(getTableVal(table2, i, 0)); + editObjectInfo.editObjects.add(allObjectMap2.get(idx - 1)); + editObjectInfo.editObjectListIdxs.add(allObjectMap2Idx.get(idx - 1)); + editObjectInfo.rows.add(i); + editObjectInfo.editObjectMaterialID.add(getTableVal(table2, i, SJ10)); + editObjectInfo.editObjectQuantity.add(getTableVal(table2, i, SJ33)); + } + new MachiningExWarehouseRemarkDialog(MachiningDynamicsManageDialog.this, editObjectInfo); + } catch (Exception e1) { + e1.printStackTrace(); + MessageBox.post(MachiningDynamicsManageDialog.this, ""+e1.getMessage(), "", MessageBox.ERROR); + } + } + }); + table1.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseReleased(MouseEvent e) {// 굥ʱӦ + String machiningManager = + TCUtil.getPreference2(fu.session, TCPreferenceService.TC_preference_site, "YSR8_MachiningDynamics_MachiningManager"); + currTable = 1; + table2.clearSelection(); + //lidy20181220 + int[] rows = table1.getSelectedRows(); + try { +// System.out.println("rows:"+rows.length); + if(user.getProperty("user_name").equals(machiningManager)) { + rbtn.setEnabled(true); +// System.out.println("machiningManager remark:true"); + }else if(rows.length==1 && user.getProperty("user_name").equals(getTableVal(table1, rows[0], BJ6))) { + rbtn.setEnabled(true); +// System.out.println("remark:true"); + } else if(rows.length>1){//lidy20190604 + for(int i : rows) { +// System.out.println("row:"+i); + String manuPerson = getTableVal(table1, i, BJ6); + if(!user.getProperty("user_name").equals(manuPerson)) { + rbtn.setEnabled(isRemarkEditable); + System.out.println(user.getProperty("user_name")+"=="+manuPerson+"=="+isRemarkEditable); + return; + } + } + rbtn.setEnabled(true); +// System.out.println("remark:true"); + }else { + rbtn.setEnabled(isRemarkEditable); +// System.out.println("else"); + } +// StringBuilder sb = new StringBuilder(""); +// TableColumnModel colModel = table1.getColumnModel(); +// for(int i=0; i1){//lidy20190604 + for(int i : rows) { +// System.out.println("row:"+i); + String manuPerson = getTableVal(table2, i, SJ10); + if(!user.getProperty("user_name").equals(getTableVal(table2, i, SJ10))) { + rbtn.setEnabled(isRemarkEditable); + System.out.println(user.getProperty("user_name")+"=="+manuPerson+"=="+isRemarkEditable); + return; + } + } + rbtn.setEnabled(true); +// System.out.println("remark:true"); + }else { + rbtn.setEnabled(isRemarkEditable); +// System.out.println("else"); + } +// else if(!isRemarkEditable) +// rbtn.setEnabled(isRemarkEditable); +// StringBuilder sb = new StringBuilder(""); +// TableColumnModel colModel = table2.getColumnModel(); +// for(int i=0; i= 0; i--) { + ci1.dataTableModel.removeRow(i); + } + ci1.dataTableModel.getDataVector().clear(); + + JTableInfo ci2 = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.61.11.11"); + rowCount = ci2.dataTableModel.getRowCount(); + for (int i = rowCount - 1; i >= 0; i--) { + ci2.dataTableModel.removeRow(i); + } + ci2.dataTableModel.getDataVector().clear(); + + iTextField textField = (iTextField) fu.allComponentMap.get("XMH"); + String XMH = textField.getText().toString(); + + JComboBox cbx = (JComboBox) fu.allComponentMap.get("JGC"); + JComboBoxInfo cii = (JComboBoxInfo) fu.allComponentInfos.get("JGC"); + String JGC = cbx.getSelectedItem().toString(); + if (cii.lovVal != null) { + Iterator iter = cii.lovVal.keySet().iterator(); + while (iter.hasNext()) { + String lovKey = iter.next(); + String lovValue = cii.lovVal.get(lovKey); + if (lovValue.equalsIgnoreCase(JGC)) { + JGC = lovKey; + break; + } + } + } + + textField = (iTextField) fu.allComponentMap.get("FZR"); + String FZR = textField.getText().toString(); + + cbx = (JComboBox) fu.allComponentMap.get("JGZT"); + String JGZT = cbx.getSelectedItem().toString(); + // cii = (JComboBoxInfo)fu.allComponentInfos.get("JGZT"); + // if (cii.lovVal != null) { + // Iterator iter = cii.lovVal.keySet().iterator(); + // while (iter.hasNext()) { + // String lovKey = iter.next(); + // String lovValue = cii.lovVal.get(lovKey); + // if (lovValue.equalsIgnoreCase(JGZT)) { + // JGZT = lovKey; + // break; + // } + // } + // } + cbx = (JComboBox) fu.allComponentMap.get("FHZT"); + String FHZT = cbx.getSelectedItem().toString();//==null ? "":cbx.getSelectedItem().toString(); + + cbx = (JComboBox) fu.allComponentMap.get("ZJZT");//TODO ZJZT + String ZJZT = cbx.getSelectedItem().toString(); + + textField = (iTextField) fu.allComponentMap.get("ZGDH"); + String ZGDH = textField.getText().toString(); + + JCheckBox ckb1 = (JCheckBox) fu.allComponentMap.get("XMJH"); + JCheckBox ckb2 = (JCheckBox) fu.allComponentMap.get("THZJ"); + JCheckBox ckb3 = (JCheckBox) fu.allComponentMap.get("ZG"); + JCheckBox ckb4 = (JCheckBox) fu.allComponentMap.get("FXD"); + + date1 = null; + date2 = null; + DateButton db = (DateButton)fu.allComponentMap.get("c_ysr8_Date1"); + date1 = db.getDate(); + String ysr8_Date1 = ""; + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-d"); + if (date1 != null) { + ysr8_Date1 = sdf.format(date1) + " 00:00"; + } + + db = (DateButton)fu.allComponentMap.get("c_ysr8_Date2"); + date2 = db.getDate(); + String ysr8_Date2 = ""; + if (date2 != null) { + ysr8_Date2 = sdf.format(date2) + " 23:59"; + } + + if (ckb1.isSelected()) { + Vector attrVec = new Vector(); + Vector valVec = new Vector(); + Vector attrVec2 = new Vector(); + Vector valVec2 = new Vector(); + +// attrVec.add("״̬"); +// valVec.add("not_started"); +// attrVec2.add("״̬"); +// valVec2.add("not_started"); + attrVec.add("fnd0status1"); + valVec.add("aborted"); + attrVec2.add("fnd0status1"); + valVec2.add("aborted"); + + attrVec.add(";"); + valVec.add("2"); + attrVec2.add(";"); + valVec2.add("2"); + + if (!XMH.isEmpty()) { + attrVec.add("Ŀ ID"); + valVec.add(XMH); + attrVec2.add("Ŀ ID"); + valVec2.add(XMH); + }else { + attrVec.add("Ŀ ID"); + valVec.add("*"); + attrVec2.add("Ŀ ID"); + valVec2.add("*"); + } + if (!JGC.isEmpty()) { + attrVec.add("ӹ1"); + valVec.add(JGC); + attrVec2.add("ӹ2"); + valVec2.add(JGC); + } + if (!FZR.isEmpty()) { + attrVec.add("ӹ"); + valVec.add(FZR); + attrVec2.add("ӹ"); + valVec2.add(FZR); + } + String dateType = "ͼ"; + if(!ysr8_Date1.isEmpty()) { + if(JGZT.equals("ӹ")) { + dateType = "ͼ"; + attrVec.add(dateType + "1"); + valVec.add(ysr8_Date1); + attrVec2.add(dateType + "1"); + valVec2.add(ysr8_Date1); + }else if(JGZT.equals("ѵ") || JGZT.equals("ɼӹ")) { + dateType = ""; + attrVec.add(dateType + "1"); + valVec.add(ysr8_Date1); + attrVec2.add(dateType + "1"); + valVec2.add(ysr8_Date1); + } + } + if(!ysr8_Date2.isEmpty()) { + if(JGZT.equals("ӹ")) { + dateType = "ͼ"; + attrVec.add(dateType + "2"); + valVec.add(ysr8_Date2); + attrVec2.add(dateType + "2"); + valVec2.add(ysr8_Date2); + }else if(JGZT.equals("ѵ") || JGZT.equals("ɼӹ")) { + dateType = ""; + attrVec.add(dateType + "2"); + valVec.add(ysr8_Date2); + attrVec2.add(dateType + "2"); + valVec2.add(ysr8_Date2); + } + } + if(JGZT.equals("ӹ")) { + attrVec.add("ӹ״̬"); + valVec.add("1;5"); + attrVec2.add("ӹ״̬"); + valVec2.add("1;5"); + }else if(JGZT.equals("ѵ")) { + attrVec.add("ӹ״̬"); + valVec.add("2;3;4;5"); + attrVec2.add("ӹ״̬"); + valVec2.add("2;3;4;5"); + }else if(JGZT.equals("ɼӹ")) { + attrVec.add("ӹ״̬"); + valVec.add("2;3;4"); + attrVec2.add("ӹ״̬"); + valVec2.add("2;3;4"); + }else if(JGZT.equals("ӹ")) { + attrVec.add("ӹ״̬"); + valVec.add("1"); + attrVec2.add("ӹ״̬"); + valVec2.add("1"); + } + + String[] attrs = (String[]) attrVec.toArray(new String[attrVec.size()]); + String[] vals = (String[]) valVec.toArray(new String[attrVec.size()]); + System.out.println(attrVec); + System.out.println(valVec); + searchMachiningInfo_SchedulTask(attrs, vals, JGZT, ZJZT); + + if(!JGC.isEmpty()) { + String[] attrs2 = (String[]) attrVec2.toArray(new String[attrVec2.size()]); + String[] vals2 = (String[]) valVec2.toArray(new String[attrVec2.size()]); + searchMachiningInfo_SchedulTask(attrs2, vals2, JGZT, ZJZT); + } + } + + + + + if (ckb2.isSelected()) { + Vector attrVec = new Vector(); + Vector valVec = new Vector(); + Vector attrVec2 = new Vector(); + Vector valVec2 = new Vector(); + + attrVec.add("ysr8_Classfication"); + valVec.add("2"); + attrVec2.add("ysr8_Classfication"); + valVec2.add("2"); + + if (!XMH.isEmpty()) { + attrVec.add("ysr8_ProjectCode"); + valVec.add(XMH); + attrVec2.add("ysr8_ProjectCode"); + valVec2.add(XMH); + }else { + attrVec.add("ysr8_ProjectCode"); + valVec.add("*"); + attrVec2.add("ysr8_ProjectCode"); + valVec2.add("*"); + } + if (!FZR.isEmpty()) { + attrVec.add("ysr8_ManuPerson"); + valVec.add(FZR); + attrVec2.add("ysr8_ManuPerson"); + valVec2.add(FZR); + } +// if (!JGZT.isEmpty()) { +// attrVec.add("ysr8_TaskManuState"); +// valVec.add(JGZT); +// attrVec2.add("ysr8_TaskManuState"); +// valVec2.add(JGZT); +// } + if (!JGC.isEmpty()) { + attrVec.add("ysr8_ManuFactory1"); + valVec.add(JGC); + attrVec2.add("ysr8_ManuFactory2"); + valVec2.add(JGC); + } + String dateType = "ͼ"; + if(!ysr8_Date1.isEmpty()) { + if(JGZT.equals("ӹ")) { + dateType = "ͼ"; + }else if(JGZT.equals("ѵ") || JGZT.equals("ɼӹ")) { + dateType = ""; + } + attrVec.add(dateType + "1"); + valVec.add(ysr8_Date1); + attrVec2.add(dateType + "1"); + valVec2.add(ysr8_Date1); + } + if(!ysr8_Date2.isEmpty()) { + if(JGZT.equals("ӹ")) { + dateType = "ͼ"; + }else if(JGZT.equals("ѵ") || JGZT.equals("ɼӹ")) { + dateType = ""; + } + attrVec.add(dateType + "2"); + valVec.add(ysr8_Date2); + attrVec2.add(dateType + "2"); + valVec2.add(ysr8_Date2); + } + if(JGZT.equals("ӹ")) { + attrVec.add("ysr8_TaskManuState"); + valVec.add("1;5"); + attrVec2.add("ysr8_TaskManuState"); + valVec2.add("1;5"); + }else if(JGZT.equals("ѵ")) { + attrVec.add("ysr8_TaskManuState"); + valVec.add("2;3;4;5"); + attrVec2.add("ysr8_TaskManuState"); + valVec2.add("2;3;4;5"); + }else if(JGZT.equals("ɼӹ")) { + attrVec.add("ysr8_TaskManuState"); + valVec.add("2;3;4"); + attrVec2.add("ysr8_TaskManuState"); + valVec2.add("2;3;4"); + }else if(JGZT.equals("ӹ")) { + attrVec.add("ysr8_TaskManuState"); + valVec.add("1"); + attrVec2.add("ysr8_TaskManuState"); + valVec2.add("1"); + } + + String[] attrs = (String[]) attrVec.toArray(new String[attrVec.size()]); + String[] vals = (String[]) valVec.toArray(new String[attrVec.size()]); + searchMachiningInfo_YSR8_DrawingList(attrs, vals, JGZT, ZJZT); + if (!JGC.isEmpty()) { + attrs = (String[]) attrVec2.toArray(new String[attrVec2.size()]); + vals = (String[]) valVec2.toArray(new String[attrVec2.size()]); + searchMachiningInfo_YSR8_DrawingList(attrs, vals, JGZT, ZJZT); + } + } + if (ckb3.isSelected()) { + Vector attrVec = new Vector(); + Vector valVec = new Vector(); +// Vector attrVec2 = new Vector(); +// Vector valVec2 = new Vector(); + + if (!XMH.isEmpty()) { + attrVec.add("ysr8_ProjectCode"); + valVec.add(XMH); +// attrVec2.add("ysr8_ProjectCode"); +// valVec2.add(XMH); + }else { + attrVec.add("ysr8_ProjectCode"); + valVec.add("*"); + } + String ManuFactory = ""; + if (!JGC.isEmpty()) { + ManuFactory = JGC; +// attrVec.add("ysr8_ManuFactory1"); +// valVec.add(JGC); +// attrVec2.add("ysr8_ManuFactory2"); +// valVec2.add(JGC); + } + if (!FZR.isEmpty()) { + attrVec.add("ysr8_ManuPerson"); + valVec.add(FZR); +// attrVec2.add("ysr8_ManuPerson"); +// valVec2.add(FZR); + } + if (!ZGDH.isEmpty()) { + attrVec.add("ID"); + valVec.add(ZGDH); +// attrVec2.add("ID"); +// valVec2.add(ZGDH); + } + String dateType = "ͼ"; + if(!ysr8_Date1.isEmpty()) { + if(JGZT.equals("ӹ")) { + dateType = "ͼ"; + }else if(JGZT.equals("ѵ") || JGZT.equals("ɼӹ")) { + dateType = ""; + } + attrVec.add(dateType + "1"); + valVec.add(ysr8_Date1); + } + if(!ysr8_Date2.isEmpty()) { + if(JGZT.equals("ӹ")) { + dateType = "ͼ"; + }else if(JGZT.equals("ѵ") || JGZT.equals("ɼӹ")) { + dateType = ""; + } + attrVec.add(dateType + "2"); + valVec.add(ysr8_Date2); + } + if(JGZT.equals("ӹ")) { + attrVec.add("ӹ״̬"); + valVec.add("1;5"); + }else if(JGZT.equals("ѵ")) { + attrVec.add("ӹ״̬"); + valVec.add("2;3;4;5"); + }else if(JGZT.equals("ɼӹ")) { + attrVec.add("ӹ״̬"); + valVec.add("2;3;4"); + }else if(JGZT.equals("ӹ")) { + attrVec.add("ӹ״̬"); + valVec.add("1"); + } + + System.out.println(attrVec+":"+valVec); + String[] attrs = (String[]) attrVec.toArray(new String[attrVec.size()]); + String[] vals = (String[]) valVec.toArray(new String[attrVec.size()]); + searchMachiningInfo_YSR8_ECN2(attrs, vals, JGZT, FHZT, ManuFactory, ZJZT); + searchMachiningInfo_YSR8_ECN4(attrs, vals, JGZT, FHZT, ManuFactory, ZJZT); + } + if (ckb4.isSelected()) { + Vector attrVec1 = new Vector(); + Vector valVec1 = new Vector(); +// Vector attrVec2 = new Vector(); +// Vector valVec2 = new Vector(); + +// attrVec1.add("ysr8_PartType"); +// valVec1.add("2"); + attrVec1.add("ysr8_UnqualifiedQuantity"); + valVec1.add("0"); + +// attrVec2.add("ysr8_PartType"); +// valVec2.add("1"); + + if (!XMH.isEmpty()) { + attrVec1.add("ysr8_ProjectCode"); + valVec1.add(XMH); + + }else { + attrVec1.add("ysr8_ProjectCode"); + valVec1.add("*"); + } + String ManuFactory = ""; + if (!JGC.isEmpty()) { + ManuFactory = JGC; + } +// if (!JGC.isEmpty()) { +// attrVec1.add("ysr8_ManuFactory1"); +// valVec1.add(JGC); +// +// } + if (!FZR.isEmpty()) { + attrVec1.add("ysr8_ManuPerson"); + valVec1.add(FZR); + + } + if (!ZGDH.isEmpty()) { + attrVec1.add("ysr8_ReworkOrderNo"); + valVec1.add(ZGDH); + } + String dateType = "ͼ"; + if(!ysr8_Date1.isEmpty()) { + if(JGZT.equals("ӹ")) { + dateType = "ͼ"; + }else if(JGZT.equals("ѵ") || JGZT.equals("ɼӹ")) { + dateType = ""; + } + attrVec1.add(dateType + "1"); + valVec1.add(ysr8_Date1); + } + if(!ysr8_Date2.isEmpty()) { + if(JGZT.equals("ӹ")) { + dateType = "ͼ"; + }else if(JGZT.equals("ѵ") || JGZT.equals("ɼӹ")) { + dateType = ""; + } + attrVec1.add(dateType + "2"); + valVec1.add(ysr8_Date2); + } + if(JGZT.equals("ӹ")) { + attrVec1.add("ӹ״̬"); + valVec1.add("1;5"); + }else if(JGZT.equals("ѵ")) { + attrVec1.add("ӹ״̬"); + valVec1.add("2;3;4;5"); + }else if(JGZT.equals("ɼӹ")) { + attrVec1.add("ӹ״̬"); + valVec1.add("2;3;4"); + }else if(JGZT.equals("ӹ")) { + attrVec1.add("ӹ״̬"); + valVec1.add("1"); + } + + String[] attrs1 = (String[]) attrVec1.toArray(new String[attrVec1.size()]); + String[] vals1 = (String[]) valVec1.toArray(new String[attrVec1.size()]); + +// String[] attrs2 = (String[]) attrVec2.toArray(new String[attrVec2.size()]); +// String[] vals2 = (String[]) valVec2.toArray(new String[attrVec2.size()]); + + searchMachiningInfo_YSR8_SingleRepairBJ(attrs1, vals1, JGZT, FHZT, ManuFactory, ZJZT); +// searchMachiningInfo_YSR8_SingleRepairSJ(JGZT, attrs2, vals2); + } + } + + private void searchMachiningInfo_SchedulTask(String[] attrs, String[] vals, String JGZT, String ZJZT) throws Exception { + JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.41.11.11"); + String searchName = "SearchSchedulTask"; +// if (JGZT.equals("ӹ")) { +// searchName = "SearchSchedulTask1"; +// } else if (JGZT.equals("ɼӹ")) { +// searchName = "SearchSchedulTask2"; +// } else if (JGZT.equals("ӹ")) { +// searchName = "SearchSchedulTask0"; +// } + + TCComponent[] tcComponents = TCUtil.query(fu.session, searchName, attrs, vals); + tcComponents = TCUtil.TCsort(tcComponents, "object_name"); + Integer idx = ci.dataTableModel.getRowCount(); + //жǷ 0 1δ 2 + int judge = 0; + for (int i = 0; i < tcComponents.length; i++) { + TCComponentScheduleTask scheduTask = (TCComponentScheduleTask) tcComponents[i]; + scheduTask.refresh(); + +// String ysr8_ManuFactory1Val = scheduTask.getProperty("ysr8_ManuFactory1"); +// if (ysr8_ManuFactory1Val == null) { +// ysr8_ManuFactory1Val = ""; +// } +// String ysr8_ManuFactory2Val = scheduTask.getProperty("ysr8_ManuFactory2"); +// if (ysr8_ManuFactory2Val == null) { +// ysr8_ManuFactory2Val = ""; +// } +// String ysr8_SubTaskManuStateVal = scheduTask.getStringProperty("ysr8_TaskManuState"); +// if (ysr8_SubTaskManuStateVal == null) { +// ysr8_SubTaskManuStateVal = ""; +// } +// String ysr8_DrawingReleaseDateVal = scheduTask.getProperty("ysr8_DrawingReleaseDate"); +// if (ysr8_DrawingReleaseDateVal == null) { +// ysr8_DrawingReleaseDateVal = ""; +// } +// String ysr8_PurchFinishDateVal = scheduTask.getProperty("ysr8_PurchFinishDateVal"); +// if (ysr8_PurchFinishDateVal == null) { +// ysr8_PurchFinishDateVal = ""; +// } +// if (JGZT.equals("ӹ")) { +// if (ysr8_DrawingReleaseDateVal.isEmpty() || !ysr8_SubTaskManuStateVal.equals("1") +// && !ysr8_SubTaskManuStateVal.equals("5")) { +// continue; +// } +// } else if (JGZT.equals("ɼӹ")) { +// if (ysr8_PurchFinishDateVal.isEmpty() || !ysr8_SubTaskManuStateVal.equals("2") +// && !ysr8_SubTaskManuStateVal.equals("3") && !ysr8_SubTaskManuStateVal.equals("4")) { +// continue; +// } +// } else if (JGZT.equals("ӹ")) { +// if (!ysr8_DrawingReleaseDateVal.isEmpty() || !ysr8_SubTaskManuStateVal.equals("1")) { +// continue; +// } +// } else if (JGZT.equals("ѵ")) { +// if (ysr8_PurchFinishDateVal.isEmpty() || !ysr8_SubTaskManuStateVal.equals("2") && !ysr8_SubTaskManuStateVal.equals("3") +// && !ysr8_SubTaskManuStateVal.equals("4") && !ysr8_SubTaskManuStateVal.equals("5")) { +// continue; +// } +// } + Date ysr8_DrawingReleaseDateVal = scheduTask.getDateProperty("ysr8_DrawingReleaseDate"); + Date ysr8_PurchFinishDateVal = scheduTask.getDateProperty("ysr8_PurchFinishDate"); + String ysr8_SubTaskManuStateVal = scheduTask.getStringProperty("ysr8_TaskManuState"); + String ysr8_SubQualityResult = scheduTask.getProperty("ysr8_SubQualityResult"); + if(ysr8_SubTaskManuStateVal==null) + ysr8_SubTaskManuStateVal = ""; + if (JGZT.equals("ӹ")) { + if (ysr8_DrawingReleaseDateVal == null || (!ysr8_SubTaskManuStateVal.equals("1") && !ysr8_SubTaskManuStateVal.equals("5"))) { + continue; + } + } else if (JGZT.equals("ɼӹ")) { + if (ysr8_PurchFinishDateVal == null || (!ysr8_SubTaskManuStateVal.equals("2") && !ysr8_SubTaskManuStateVal.equals("3") + && !ysr8_SubTaskManuStateVal.equals("4"))) { + continue; + } + } else if (JGZT.equals("ӹ")) { + if(ysr8_DrawingReleaseDateVal != null || !ysr8_SubTaskManuStateVal.equals("1")) + continue; + } else if (JGZT.equals("ѵ")) { + if (ysr8_PurchFinishDateVal == null || ysr8_SubTaskManuStateVal.equals("1")) { + continue; + } + } + + String object_nameVal = scheduTask.getProperty("object_name"), inspResult = ""; + StringBuilder partCode = new StringBuilder("");//TODO ȡ + String[] object_nameVals = object_nameVal.split("-"); + if (object_nameVals.length > 1) { + for (int j=0; j=0) { + object_nameVal = object_nameVal.substring(object_nameVal.indexOf("")+1, object_nameVal.length()); + } + Vector itemIdPart = CommonUtil.split2Vector(object_nameVal, "-"); + if (itemIdPart.size() > 1) { + itemID = itemIdPart.get(0) +"-"+ itemIdPart.get(1); + } + String owning_userVal = "", date_releasedVal = ""; + if (!itemID.isEmpty()) { + TCComponentItem partItem = TCUtil.findItemByID(fu.session, itemID); + if (partItem != null) { + owning_userVal = partItem.getProperty("owning_user"); + + String oldEnd = "2900-01-01"; + AIFComponentContext[] contexts = partItem.getChildren("revision_list"); + if (contexts != null && contexts.length > 0) { + for (int r = 0; r < contexts.length; r++) { + InterfaceAIFComponent componentR = contexts[r].getComponent(); + if (componentR instanceof TCComponentItemRevision) { + TCComponentItemRevision revision = (TCComponentItemRevision) componentR; + TCComponent[] status = revision.getReferenceListProperty("release_status_list"); +// System.out.println("status:"+status.length); + if(status.length>0) { + for(TCComponent release : status) { +// System.out.println("status_name:"+release.getProperty("name")); + if(release.getProperty("name").equals("ʽ·")) { + String endTime = fu.getDateString(release.getDateProperty("date_released")); + if (oldEnd.compareTo(endTime) > 0) { + oldEnd = endTime; + } + } + } + } +// String release = revision.getProperty("release_status_list").trim();//lidy20190604ȡ緢ʱ +// if (release.equals("ʽ·")) { +// String endTime = fu.getDateString(revision.getDateProperty("date_released")); +// if (!endTime.isEmpty()) { +// if (oldEnd.compareTo(endTime) > 0) { +// oldEnd = endTime; +// } +// } +// } + } + } + } + if (!oldEnd.equals("2900-01-01")) { + date_releasedVal = oldEnd; + } + } + } + if (JGZT.equals("ӹ") && date_releasedVal == "") + continue; + if(JGZT.isEmpty() || JGZT.equals("ӹ")) { + if(date1 != null) { + if (date_releasedVal.compareTo(fu.getDateString(date1)) < 0) + continue; + } + if(date2 != null) { + if (date_releasedVal.compareTo(fu.getDateString(date2)) > 0) + continue; + } + } + + Vector vec = new Vector<>(); + vec.add((++idx) + "");// + String ysr8_ProjectCodeVal = scheduTask.getProperty("ysr8_ProjectCode"); + vec.add(ysr8_ProjectCodeVal);// Ŀ + //20230928 Ŀ + System.out.println(scheduTask.getProperty("owning_user")); + vec.add(scheduTask.getProperty("owning_user").split(" \\(")[0]);// Ŀ owning_user + vec.add(scheduTask.getProperty("ysr8_ManuFactory1"));// ӹ1 + vec.add(scheduTask.getProperty("ysr8_ManuFactory2"));// ӹ2 + TCComponentForm xmqdForm = null; + { + System.out.println("ysr8_ProjectCodeVal==================================="+ysr8_ProjectCodeVal); + TCComponentItem xmqdItem = TCUtil.findItemByID(fu.session, ysr8_ProjectCodeVal + "_XMQD"); + + if (xmqdItem != null) { + TCComponentItemRevision xmqdRevision = xmqdItem.getLatestItemRevision(); + xmqdForm = TCUtil.getItemRevisionMasterForm(xmqdRevision); + vec.add(xmqdForm.getProperty("ysr8_Factory"));// + } else { + vec.add("");// + } + } + vec.add(scheduTask.getProperty("ysr8_ManuPerson"));// ӹ + vec.add(object_nameVal);// + vec.add(scheduTask.getProperty("ysr8_PartNumber"));// + + if(owning_userVal.indexOf(" (")>0) + vec.add(owning_userVal.substring(0, owning_userVal.indexOf(" (")));// + else + vec.add(owning_userVal);// + vec.add(date_releasedVal);// ͼ + vec.add(fu.getDateString(scheduTask.getDateProperty("start_date")));// ƻʼ + vec.add(fu.getDateString(scheduTask.getDateProperty("finish_date")));// ƻ + vec.add(fu.getDateString(scheduTask.getDateProperty("ysr8_DrawingReleaseDate")));// ͼ + vec.add(fu.getDateString(scheduTask.getDateProperty("ysr8_PurchPlanDate")));// ɹҪ + vec.add(fu.getDateString(scheduTask.getDateProperty("ysr8_PurchFinishDate")));// ʵʱ + //жǷ + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + String strPlan = fu.getDateString(scheduTask.getDateProperty("finish_date")); + String strFinish = fu.getDateString(scheduTask.getDateProperty("ysr8_PurchFinishDate")); + if(strPlan != null && strPlan.length() > 0 && strFinish != null && strFinish.length() > 0) { + //жʱȺ + if(sdf.parse(strFinish).compareTo(sdf.parse(strPlan)) > 0) { + judge = 2; + }else { + judge = 1; + } + } + // kk + vec.add(scheduTask.getProperty("ysr8_ArrivingQuantity"));// ε + vec.add(scheduTask.getProperty("ysr8_ArrivedQuantity"));// ѵ + vec.add(scheduTask.getProperty("ysr8_PurchRemark"));// ע + vec.add(lovysr8_SubTaskManuState.get(scheduTask.getStringProperty("ysr8_TaskManuState")));// ״̬ + vec.add("");// + vec.add(fu.getDateString(scheduTask.getDateProperty("ysr8_SubQualityFinishDate")));// ʼʱ + vec.add(ysr8_SubQualityResult);// ʼ + /*if(!ysr8_SubQualityResult.isEmpty() && !ysr8_SubQualityResult.equals("ϸ")) { + TCComponent[] insps = TCUtil.query(fu.session, "SearchINSPCode", new String[]{ "ysr8_AssemCode" }, + new String[]{ partCode.toString() }); +// System.out.println("partCode:"+partCode+" insps:"+insps.length); + boolean ok = true; + if(insps.length==0) + ok = false; + else { + for(TCComponent c : insps) { + TCComponentForm form = TCUtil.getItemRevisionMasterForm((TCComponentItemRevision) c); + if(form.getProperty("ysr8_UnqualifiedQuantity").equals("0")) + continue; + String[] results = form.getTCProperty("ysr8_SubQualityResult").getStringArrayValue(); +// if(results==null || results.length==0) +// continue; + for(String s : results) { + if(s==null || !s.equals("ϸ")) { + ok = false; + break; + } + } + } + } + if(ok) + vec.add("ϸ");// ״̬ + else + vec.add("");// ״̬ + }else*/ + vec.add(inspResult);// ״̬ + + //20230922 Ƿ Ԥԭ + if(judge == 0) { + vec.add(""); + }else if(judge == 1) { + vec.add(""); + }else { + vec.add(""); + } + //ԭ + vec.add(scheduTask.getProperty("ysr8_DelayReason")); + + //20240816ֶ + //ұ + if(xmqdForm != null) { + System.out.println("ysr8_ProjectName==="+xmqdForm.getProperty("ysr8_ProjectName")); + vec.add(xmqdForm.getProperty("ysr8_ProjectName")); + vec.add(xmqdForm.getProperty("ysr8_Product")); + vec.add(xmqdForm.getProperty("ysr8_Use")); + }else { + System.out.println("xmqdForm==========null"); + vec.add(""); + vec.add(""); + vec.add(""); + } + + //ʱ + String[] split = object_nameVal.split("-"); + String substring = ""; + boolean isYz = false;//Ƿֵ + if(split.length >= 3) { + //int lastIndexOf = object_nameVal.lastIndexOf("-"); + + + // ҵһ "-" λ + int firstDashIndex = object_nameVal.indexOf('-'); + + // ҵڶ "-" λãӵһ "-" 濪ʼ + int secondDashIndex = object_nameVal.indexOf('-', firstDashIndex + 1); + + // ӿʼλýȡڶ "-" λãڶ "-" + substring = object_nameVal.substring(0, secondDashIndex); + + System.out.println("substring============="+substring); + TCComponent[] scheduleComponents = TCUtil.query(fu.session, "SearchSchedulTask5", new String[] {""}, new String[] {substring+"-·ͼֽ"}); + System.out.println("scheduleComponents.size========================="+scheduleComponents.length); + if(scheduleComponents.length > 0) { + System.out.println("start_date=========================="+fu.getDateString(scheduleComponents[0].getDateProperty("start_date"))); + vec.add(fu.getDateString(scheduleComponents[0].getDateProperty("start_date"))); + vec.add(fu.getDateString(scheduleComponents[0].getDateProperty("finish_date"))); + vec.add(fu.getDateString(scheduleComponents[0].getDateProperty("actual_start_date"))); + vec.add(fu.getDateString(scheduleComponents[0].getDateProperty("actual_finish_date"))); + isYz = true; + } + } + if(!isYz) {//ûҵ + vec.add(""); + vec.add(""); + vec.add(""); + vec.add(""); + } + + //ͼĿ¼ + TCComponentItem tymlItem = TCUtil.findItemByID(fu.session, substring + "_TM01"); + System.out.println("tymlItem.size========================="+tymlItem); + if (tymlItem != null) { + + TCComponentItemRevision tymlRevision = tymlItem.getLatestItemRevision(); + TCComponentForm tymlForm = TCUtil.getItemRevisionMasterForm(tymlRevision); + System.out.println("ysr8_PartQuantity================="+tymlForm.getProperty("ysr8_PartQuantity")); + vec.add(tymlForm.getProperty("ysr8_PartQuantity"));// + } else { + vec.add(""); + } + + ci.dataTableModel.addRow(vec); + allObjectMap1.put(idx - 1, scheduTask); + allObjectMap1Idx.put(idx - 1, 0); + } + } + + private void searchMachiningInfo_YSR8_DrawingList(String[] attrs, String[] vals, String JGZT, String ZJZT) throws Exception { + JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.41.11.11"); + TCComponent[] tcComponents = TCUtil.query(fu.session, "SearchDrawingListForMD", attrs, vals); + if(tcComponents == null) + return; + tcComponents = TCUtil.TCsort(tcComponents, "item_id"); + Integer idx = ci.dataTableModel.getRowCount(); + for (int i = 0; i < tcComponents.length; i++) { + TCComponentItemRevision dlRevision = (TCComponentItemRevision) tcComponents[i]; + TCComponentItem dlItem = dlRevision.getItem(); + TCComponentForm dlForm = TCUtil.getItemRevisionMasterForm(dlRevision); + dlForm.refresh(); + + Date date_releasedVal = dlForm.getDateProperty("date_released"); + Date ysr8_DrawingReleaseDateVal = dlForm.getDateProperty("ysr8_DrawingReleaseDate"); + Date ysr8_PurchFinishDateVal = dlForm.getDateProperty("ysr8_PurchFinishDate"); + String ysr8_SubTaskManuStateVal = dlForm.getStringProperty("ysr8_TaskManuState"); + if(ysr8_SubTaskManuStateVal==null) + ysr8_SubTaskManuStateVal = ""; + if (JGZT.equals("ӹ")) { + if (ysr8_DrawingReleaseDateVal == null || (!ysr8_SubTaskManuStateVal.equals("1") && !ysr8_SubTaskManuStateVal.equals("5"))) { + continue; + } + } else if (JGZT.equals("ɼӹ")) { + if (ysr8_PurchFinishDateVal == null || (!ysr8_SubTaskManuStateVal.equals("2") && !ysr8_SubTaskManuStateVal.equals("3") + && !ysr8_SubTaskManuStateVal.equals("4"))) { + continue; + } + } else if (JGZT.equals("ӹ")) { + if(date_releasedVal == null || ysr8_DrawingReleaseDateVal != null || !ysr8_SubTaskManuStateVal.equals("1")) + continue; + } else if (JGZT.equals("ѵ")) { + if (ysr8_PurchFinishDateVal == null || ysr8_SubTaskManuStateVal.equals("1")) { + continue; + } + } + String ysr8_SubQualityResult = dlForm.getProperty("ysr8_SubQualityResult"); + if(!ZJZT.isEmpty()) { + if(ZJZT.equals("")) { + if(!ysr8_SubTaskManuStateVal.equals("3") || !ysr8_SubQualityResult.isEmpty()) + continue; + }else if(ZJZT.equals("ϸ")) { + if(!ysr8_SubQualityResult.equals("ϸ") && !ysr8_SubQualityResult.equals("ֱ")) + continue; + }else if(ZJZT.equals("ϸ")) { + if(!ysr8_SubQualityResult.equals("ϸ") && !ysr8_SubQualityResult.equals("ɵ")) + continue; + } + } + + Vector vec = new Vector<>(); + vec.add((++idx) + "");// + String ysr8_ProjectCodeVal = dlForm.getProperty("ysr8_ProjectCode"); + vec.add(ysr8_ProjectCodeVal);// Ŀ + //20230928 Ŀ + vec.add(getName(ysr8_ProjectCodeVal));// Ŀ owning_user + vec.add(dlForm.getProperty("ysr8_ManuFactory1"));// ӹ1 + vec.add(dlForm.getProperty("ysr8_ManuFactory2"));// ӹ2 +// vec.add("");// + { + TCComponentItem xmqdItem = TCUtil.findItemByID(fu.session, ysr8_ProjectCodeVal + "_XMQD"); + if (xmqdItem != null) { + TCComponentItemRevision xmqdRevision = xmqdItem.getLatestItemRevision(); + TCComponentForm xmqdForm = TCUtil.getItemRevisionMasterForm(xmqdRevision); + vec.add(xmqdForm.getProperty("ysr8_Factory"));// + } else { + vec.add("");// + } + } + vec.add(dlForm.getProperty("ysr8_ManuPerson"));// ӹ + + String object_nameVal = "׷滻" + dlRevision.getProperty("item_id"); + vec.add(object_nameVal);// + + vec.add(dlForm.getProperty("ysr8_AddOrReplaceQuantity"));// + String owning_userVal = dlForm.getProperty("owning_user"); + if(owning_userVal.indexOf(" (")>0) + vec.add(owning_userVal.substring(0, owning_userVal.indexOf(" (")));// + else + vec.add(owning_userVal);// +// vec.add(dlForm.getProperty("owning_user"));// + vec.add(fu.getDateString(dlForm.getDateProperty("date_released")));// ͼ kk 181011 ysr8_ReleaseDate ij date_released + vec.add("");// ƻʼ + vec.add("");// ƻ + vec.add(fu.getDateString(dlForm.getDateProperty("ysr8_DrawingReleaseDate")));// ͼ + vec.add(fu.getDateString(dlForm.getDateProperty("ysr8_PurchPlanDate")));// Ҫӹʱ + vec.add(fu.getDateString(dlForm.getDateProperty("ysr8_PurchFinishDate")));// ӹʵʱ + // kk + vec.add(dlForm.getProperty("ysr8_ArrivingQuantity"));// ε + vec.add(dlForm.getProperty("ysr8_ArrivedQuantity"));// ѵ +// TCProperty ysr8_PurchRemark = dlForm.getFormTCProperty("ysr8_PurchRemark"); +// ysr8_PurchRemark.isNotArray(); + vec.add(dlForm.getProperty("ysr8_PurchRemark"));// ע + vec.add(lovysr8_SubTaskManuState.get(dlForm.getStringProperty("ysr8_TaskManuState")));// ״̬ + vec.add("");// + vec.add(fu.getDateString(dlForm.getDateProperty("ysr8_SubQualityFinishDate")));// ʼʱ + vec.add(ysr8_SubQualityResult);// ʼ + vec.add("");// ״̬ + + ci.dataTableModel.addRow(vec); + allObjectMap1.put(idx - 1, dlItem); + allObjectMap1Idx.put(idx - 1, 0); + } + } + + private void searchMachiningInfo_YSR8_ECN2(String[] attrs, String[] vals, String JGZT, String FHZT, String ManuFactory, String ZJZT) throws Exception { + JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.61.11.11"); + TCComponent[] tcComponents = TCUtil.query(fu.session, "SearchECN2ForMD", attrs, vals); + tcComponents = TCUtil.TCsort(tcComponents, "item_id"); + Integer idx = ci.dataTableModel.getRowCount(); + Vector schemes = new Vector<>(); + schemes.add("װͼ"); + schemes.add("ԭ޸"); + schemes.add("װʾͼ"); + for (int i = 0; i < tcComponents.length; i++) { + TCComponentItemRevision ecn2Revision = (TCComponentItemRevision) tcComponents[i]; + String ecnid = ecn2Revision.getProperty("item_id"); + System.out.println(ecnid); + TCComponentItem ecn2Item = ecn2Revision.getItem(); + TCComponentForm ecn2Form = TCUtil.getItemRevisionMasterForm(ecn2Revision); + ecn2Form.refresh(); + String prId = ""; +// TCComponentForm prForm = null; + String ysr8_TechPlanDate = "", ysr8_MachinPlanDate = ""; + String ysr8_TechPlanDateMin = "9900-01-01", ysr8_MachinPlanDateMin = "9900-01-01"; + //TODO ͼֽĵ + String[] problemID = ecn2Form.getFormTCProperty("ysr8_Ecn2SolveQueId").getStringArrayValue(); + String[] materialID2 = ecn2Form.getFormTCProperty("ysr8_Ecn2Id").getStringArrayValue(); +// Map prMap = new HashMap<>(); + if(materialID2.length>0) { +// for(String prID : problemID) { +// if(prID!=null && !prID.isEmpty() && !prMap.containsKey(prID)) { +// TCComponentForm prForm = TCUtil.getItemRevisionMasterForm(TCUtil.findItemByID(session, prID).getLatestItemRevision()); +// prMap.put(prID, prForm); +// } +// } + }else { + AIFComponentContext[] prs = ecn2Item.whereReferenced(); + for(int s=0; s0) { + ysr8_TechPlanDateMin = ysr8_TechPlanDate; + } + } + if(prForm.getDateProperty("ysr8_MachinPlanDate")!=null) { + ysr8_MachinPlanDate = String.format("%tF", prForm.getDateProperty("ysr8_MachinPlanDate")); + if(ysr8_MachinPlanDateMin.compareTo(ysr8_MachinPlanDate)>0) { + ysr8_MachinPlanDateMin = ysr8_MachinPlanDate; + } + } + prId += ";"+prComponent.getProperty("item_id"); + } + } + } + if(prId.length()>0) + prId = prId.substring(1); + if(ysr8_TechPlanDateMin.equals("9900-01-01")) + ysr8_TechPlanDateMin=""; + if(ysr8_MachinPlanDateMin.equals("9900-01-01")) + ysr8_MachinPlanDateMin=""; + + if(ysr8_TechPlanDateMin.isEmpty() && ysr8_MachinPlanDateMin.isEmpty() || ecn2Form.getDateProperty("ysr8_TechFinishDate")==null) { + ysr8_MachinPlanDateMin = ""; + }else if(!ysr8_MachinPlanDateMin.isEmpty()){ + int day = 0; + if(!ysr8_TechPlanDateMin.isEmpty()) + day = CommonUtil.getDaysBetween2(getDate(ysr8_TechPlanDateMin), ecn2Form.getDateProperty("ysr8_TechFinishDate")); + if(day>0) { + Calendar c = Calendar.getInstance(); + c.setTime(getDate(ysr8_MachinPlanDateMin)); + c.add(Calendar.DAY_OF_MONTH, day); + ysr8_MachinPlanDateMin = fu.getDateString(c.getTime()); + } + } + } +// System.out.println(ecn2Item.getProperty("item_id")+"⣺"+prId); + + TCProperty ysr8_SerialNo = ecn2Form.getFormTCProperty("ysr8_SerialNo"); + int[] ysr8_SerialNoVals = ysr8_SerialNo.getIntArrayValue(); +// System.out.println(ecn2Revision.getProperty("ysr8_SerialNoVals.length:"+ysr8_SerialNoVals.length)); + if(ysr8_SerialNoVals==null||ysr8_SerialNoVals.length==0) + continue; + int length = ysr8_SerialNoVals.length; + String[] nullArray = new String[length]; + Date[] nullDates = new Date[length]; + for(int j=0; j 0) + continue; + } else if (JGZT.equals("ɼӹ")) { + if (ysr8_SubPurchFinishDateVal == null || (!ysr8_SubTaskManuStateVal.equals("2") && !ysr8_SubTaskManuStateVal.equals("3") + && !ysr8_SubTaskManuStateVal.equals("4"))) { + continue; + } + if(date1 != null && fu.getDateString(ysr8_SubPurchFinishDateVal).compareTo(fu.getDateString(date1)) < 0) + continue; + if(date2 != null && fu.getDateString(ysr8_SubPurchFinishDateVal).compareTo(fu.getDateString(date2)) > 0) + continue; + } else if (JGZT.equals("ӹ")) { + if(ysr8_TechFinishDateVal == null || ysr8_DrawingReleaseDateVal != null || !ysr8_SubTaskManuStateVal.equals("1")) + continue; + if(date1 != null && fu.getDateString(ysr8_TechFinishDateVal).compareTo(fu.getDateString(date1)) < 0) + continue; + if(date2 != null && fu.getDateString(ysr8_TechFinishDateVal).compareTo(fu.getDateString(date2)) > 0) + continue; + } else if (JGZT.equals("ѵ")) { + if (ysr8_SubPurchFinishDateVal == null || ysr8_SubTaskManuStateVal.equals("1")) { + continue; + } + if(date1 != null && fu.getDateString(ysr8_SubPurchFinishDateVal).compareTo(fu.getDateString(date1)) < 0) + continue; + if(date2 != null && fu.getDateString(ysr8_SubPurchFinishDateVal).compareTo(fu.getDateString(date2)) > 0) + continue; + } else if (JGZT.isEmpty()) { + if(date1 != null && fu.getDateString(ysr8_TechFinishDateVal).compareTo(fu.getDateString(date1)) < 0) + continue; + if(date2 != null && fu.getDateString(ysr8_TechFinishDateVal).compareTo(fu.getDateString(date2)) > 0) + continue; + } + if (FHZT.equals("δ")) { + if(ysr8_ExWarehouseStateVals[j]==null) + continue; + else if(!ysr8_ExWarehouseStateVals[j].equals("1")) + continue; + else if(ysr8_ArrivedQuantityVals[j].isEmpty()) + continue; + else if(schemes.contains(ysr8_SubChangeSchemeVals[j])) + continue; + if(ysr8_SubQualityResultVals[j]!=null && ysr8_SubQualityResultVals[j].equals("ϸ")) + continue; + }else if (FHZT.equals("ѳ")) { + if(ysr8_ExWarehouseStateVals[j]==null) + continue; + else if(!ysr8_ExWarehouseStateVals[j].equals("2")) + continue; + else if(ysr8_ArrivedQuantityVals[j].isEmpty()) + continue; + } + + String ysr8_SubManuFactory1Val = ysr8_SubManuFactory1Vals[j]; + if (ysr8_SubManuFactory1Val == null) { + ysr8_SubManuFactory1Val = ""; + } + String ysr8_SubManuFactory2Val = ysr8_SubManuFactory2Vals[j]; + if (ysr8_SubManuFactory2Val == null) { + ysr8_SubManuFactory2Val = ""; + } + if (!ManuFactory.isEmpty()) { + if (!ysr8_SubManuFactory1Val.equals(ManuFactory) && !ysr8_SubManuFactory2Val.equals(ManuFactory)) { + continue; + } + } + String fxzt = ""; + if(ysr8_SubQualityResultVals[j]==null) + ysr8_SubQualityResultVals[j] = ""; +// System.out.println("ysr8_SubQualityResultVals:"+ysr8_SubQualityResultVals[j]); + if(ysr8_SubQualityResultVals[j].equals("ϸ") || ysr8_SubQualityResultVals[j].equals("ɵ")) { + TCComponent[] insps = TCUtil.query(fu.session, "SearchINSRepairECN", new String[] { "ysr8_RepairECN" }, new String[] { ecnid }); + if(insps.length>0) { + TCComponentForm inspForm = TCUtil.getItemRevisionMasterForm((TCComponentItemRevision) insps[0]); + String[] codes = inspForm.getTCProperty("ysr8_PartCode").getStringArrayValue(); +// String[] state = inspForm.getTCProperty("ysr8_SubTaskManuState").getStringArrayValue(); + String[] state = inspForm.getProperty("ysr8_SubQualityResult").split(","); + for(int k=0; k vec = new Vector<>(); + vec.add((++idx) + "");// + vec.add(ecn2Item.getProperty("item_id"));// /޵ + // ͼֽĵ + if(materialID2.length>0) { + prId = ""; + ysr8_TechPlanDate = ""; + ysr8_MachinPlanDate = ""; + ysr8_TechPlanDateMin = "9900-01-01"; + ysr8_MachinPlanDateMin = "9900-01-01"; + for(int k=0; k0) { + ysr8_TechPlanDateMin = ysr8_TechPlanDate; + } + } +// Date MachinPlanDate = prMap.get(problemID[k]).getDateProperty("ysr8_MachinPlanDate"); + TCProperty ysr8_Ecn2IntialFinTime = ecn2Form.getFormTCProperty("ysr8_Ecn2IntialFinTime"); + Date MachinPlanDate = ysr8_Ecn2IntialFinTime.getDateValueArray()[k]; + if(MachinPlanDate != null) { + ysr8_MachinPlanDate = fu.getDateString(MachinPlanDate); + if(ysr8_MachinPlanDateMin.compareTo(ysr8_MachinPlanDate)>0) { + ysr8_MachinPlanDateMin = ysr8_MachinPlanDate; + } + } + } + } + if(ysr8_TechPlanDateMin.equals("9900-01-01")) + ysr8_TechPlanDateMin=""; + if(ysr8_MachinPlanDateMin.equals("9900-01-01")) + ysr8_MachinPlanDateMin=""; + + if(ysr8_TechPlanDateMin.isEmpty() && ysr8_MachinPlanDateMin.isEmpty() || ecn2Form.getDateProperty("ysr8_TechFinishDate")==null) { + ysr8_MachinPlanDateMin = ""; + }else if(!ysr8_MachinPlanDateMin.isEmpty()){ + int day = 0; + if(!ysr8_TechPlanDateMin.isEmpty()) + day = CommonUtil.getDaysBetween2(getDate(ysr8_TechPlanDateMin), ecn2Form.getDateProperty("ysr8_TechFinishDate")); + if(day>0) { + Calendar c = Calendar.getInstance(); + c.setTime(getDate(ysr8_MachinPlanDateMin)); + c.add(Calendar.DAY_OF_MONTH, day); + ysr8_MachinPlanDateMin = fu.getDateString(c.getTime()); + } + } + if(prId.length()>0) + prId = prId.substring(1); + } + vec.add(prId);//ldy 20180225 + vec.add("");//kk 1011 ĵ + vec.add("");// + String ysr8_ProjectCodeVal = ecn2Form.getProperty("ysr8_ProjectCode"); + vec.add(ysr8_ProjectCodeVal);// Ŀ + //20230928 Ŀ + vec.add(getName(ysr8_ProjectCodeVal));// Ŀ owning_user + vec.add(ysr8_SubManuFactory1Vals[j]);// ӹ1 + vec.add(ysr8_SubManuFactory2Vals[j]);// ӹ2 + { + TCComponentItem xmqdItem = TCUtil.findItemByID(fu.session, ysr8_ProjectCodeVal + "_XMQD"); + if (xmqdItem != null) { + TCComponentItemRevision xmqdRevision = xmqdItem.getLatestItemRevision(); + TCComponentForm xmqdForm = TCUtil.getItemRevisionMasterForm(xmqdRevision); + vec.add(xmqdForm.getProperty("ysr8_Factory"));// + } else { + vec.add("");// + } + } + vec.add(ecn2Form.getProperty("ysr8_ManuPerson"));// + + vec.add(lovysr8_SubChangeScheme.get(ysr8_SubChangeSchemeVals[j]));// ķ + vec.add(ysr8_MaterialIDVals[j]);// + vec.add(ysr8_MaterialNameVals[j]);// + if(ysr8_QuantityVals==null||ysr8_QuantityVals.length==0) + vec.add(""); + else + vec.add(Double.toString(ysr8_QuantityVals[j]).split("\\.")[0]);// +// vec.add(ysr8_OriginalDesignerVals[j]);// + vec.add(ecn2Form.getProperty("ysr8_Changer"));// + vec.add(fu.getDateString(ecn2Form.getDateProperty("ysr8_TechFinishDate")));// ͼ + +// vec.add(ecn2Form.getProperty("ysr8_TechFinishDate"));// kk 1011 ƻ +// if(prForm!=null) { +// vec.add(fu.getDateString(prForm.getDateProperty("ysr8_TechPlanDate")));// lidy 20190225 ƻ +// }else +// vec.add("");// lidy 20190225 ƻ + vec.add(ysr8_TechPlanDateMin);// lidy 20190225 ƻ + + vec.add(fu.getDateString(ysr8_DrawingReleaseDateVals[j]));// ͼֽӹʱ +// if(prForm!=null) { +// vec.add(fu.getDateString(prForm.getDateProperty("ysr8_MachinPlanDate")));// lidy 20190225 ӹƻ +// }else +// vec.add("");// lidy 20190225 ӹƻ + vec.add(ysr8_MachinPlanDateMin);// lidy 20190225 ӹƻ + vec.add(fu.getDateString(ysr8_SubPurchPlanDateVals[j]));// ɹҪ + vec.add(fu.getDateString(ysr8_SubPurchFinishDateVals[j]));// ӹʵʱ + // kk + vec.add(ysr8_ArrivingQuantityVals[j]==null?"":ysr8_ArrivingQuantityVals[j].split("\\.")[0]);// ε + vec.add(ysr8_ArrivedQuantityVals[j]==null?"":ysr8_ArrivedQuantityVals[j].split("\\.")[0]);// ѵ + vec.add(ysr8_RemarkVals[j]);// ע + vec.add(ysr8_SubQualityResultVals[j]);// ʼ + vec.add(fxzt);// ״̬ + vec.add("");// ϸ + + vec.add(lovysr8_SubTaskManuState.get(ysr8_SubTaskManuStateVals[j]));// ״̬ + vec.add(fu.getDateString(ysr8_SubQualityFinishDateVals[j]));// ʼʱ + vec.add(lovysr8_ExWarehouse.get(ysr8_ExWarehouseStateVals[j]));// ״̬ + vec.add(fu.getDateString(ysr8_ExWarehouseDateVals[j]));// + vec.add(ysr8_ExWarehouseQuantityVals[j]);// + vec.add(ysr8_ExWarehousePersonVals[j]);// + vec.add(ysr8_ExWarehouseRemarkVals[j]);// ⱸע + //20230921 ԭ Ƿ + //ƻʱͼƻʱΪ Ͳ + String techPlan = ysr8_MachinPlanDateMin; + String machPlan = fu.getDateString(ysr8_SubPurchFinishDateVals[j]); + String fangan = ysr8_SubChangeSchemeVals[j];//ķ + System.out.println("fangan================="+fangan); + System.out.println("techPlan================="+techPlan); + System.out.println("machPlan================="+machPlan); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + if(fangan != null && fangan.equals("װͼ")) { + vec.add(""); + }else { + if(!techPlan.isEmpty() && !machPlan.isEmpty()) { + if(sdf.parse(machPlan).compareTo(sdf.parse(techPlan)) > 0) { + vec.add(""); + }else { + vec.add(""); + } + }else if(!techPlan.isEmpty() && machPlan.isEmpty()) { + Date date = new Date(); + if(date.compareTo(sdf.parse(techPlan)) > 0) { + vec.add(""); + }else { + vec.add(""); + } + }else { + vec.add(""); + } + } + + + + + vec.add(ysr8_Ecn2DelayReasonVals.length < j+1 ? "" : ysr8_Ecn2DelayReasonVals[j]);// ԭ + vec.add(ecn2Form.getStringProperty("ysr8_SubProjectCode")); + ci.dataTableModel.addRow(vec); + allObjectMap2.put(idx - 1, ecn2Item); + allObjectMap2Idx.put(idx - 1, j); + } + } + } + + private void searchMachiningInfo_YSR8_ECN4(String[] attrs, String[] vals, String JGZT, String FHZT, String ManuFactory, String ZJZT) throws Exception { + JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.61.11.11"); + TCComponent[] tcComponents = TCUtil.query(fu.session, "SearchECN4ForMD", attrs, vals); + tcComponents = TCUtil.TCsort(tcComponents, "item_id"); + Integer idx = ci.dataTableModel.getRowCount(); + Vector schemes = new Vector<>(); + schemes.add("װͼ"); + schemes.add("ԭ޸"); + schemes.add("װʾͼ"); + for (int i = 0; i < tcComponents.length; i++) { + TCComponentItemRevision ecn4Revision = (TCComponentItemRevision) tcComponents[i]; + String ecnid = ecn4Revision.getProperty("item_id"); + System.out.println(ecnid); + TCComponentItem ecn4Item = ecn4Revision.getItem(); + TCComponentForm ecn4Form = TCUtil.getItemRevisionMasterForm(ecn4Revision); + ecn4Form.refresh(); + String prId = ""; + String ysr8_TechPlanDate = "", ysr8_MachinPlanDate = ""; + String ysr8_TechPlanDateMin = "9900-01-01", ysr8_MachinPlanDateMin = "9900-01-01"; + TCComponentForm prForm = null; + //TODO ļӹ + String[] problemID = ecn4Form.getFormTCProperty("ysr8_Ecn4SolveQueId").getStringArrayValue(); + String[] materialID2 = ecn4Form.getFormTCProperty("ysr8_Ecn4Id").getStringArrayValue(); +// Map prMap = new HashMap<>(); + if(materialID2.length>0) { +// for(String prID : problemID) { +// if(prID!=null && !prID.isEmpty() && !prMap.containsKey(prID)) { +// prForm = TCUtil.getItemRevisionMasterForm(TCUtil.findItemByID(session, prID).getLatestItemRevision()); +// prMap.put(prID, prForm); +// } +// } + }else { + AIFComponentContext[] prs = ecn4Item.whereReferenced(); + for(int s=0; s0) { + ysr8_TechPlanDateMin = ysr8_TechPlanDate; + } + } + if(prForm.getDateProperty("ysr8_MachinPlanDate")!=null) { + ysr8_MachinPlanDate = String.format("%tF", prForm.getDateProperty("ysr8_MachinPlanDate")); + if(ysr8_MachinPlanDateMin.compareTo(ysr8_MachinPlanDate)>0) { + ysr8_MachinPlanDateMin = ysr8_MachinPlanDate; + } + } + if(prId.isEmpty()){ + prId = prComponent.getProperty("item_id"); + }else { + prId += ";"+prComponent.getProperty("item_id"); + } + } + } + } + if(prId.length()>0) + prId = prId.substring(1); + if(ysr8_TechPlanDateMin.equals("9900-01-01")) + ysr8_TechPlanDateMin=""; + if(ysr8_MachinPlanDateMin.equals("9900-01-01")) + ysr8_MachinPlanDateMin=""; + + if(ysr8_TechPlanDateMin.isEmpty() && ysr8_MachinPlanDateMin.isEmpty() || ecn4Form.getDateProperty("ysr8_TechFinishDate")==null) { + ysr8_MachinPlanDateMin = ""; + }else if(!ysr8_MachinPlanDateMin.isEmpty()){ + int day = 0; + if(!ysr8_TechPlanDateMin.isEmpty()) + day = CommonUtil.getDaysBetween2(getDate(ysr8_TechPlanDateMin), ecn4Form.getDateProperty("ysr8_TechFinishDate")); + if(day>0) { + Calendar c = Calendar.getInstance(); + c.setTime(getDate(ysr8_MachinPlanDateMin)); + c.add(Calendar.DAY_OF_MONTH, day); + ysr8_MachinPlanDateMin = fu.getDateString(c.getTime()); + } + } + } + + TCProperty ysr8_SerialNo = ecn4Form.getFormTCProperty("ysr8_SerialNo"); + int[] ysr8_SerialNoVals = ysr8_SerialNo.getIntArrayValue(); + if(ysr8_SerialNoVals==null||ysr8_SerialNoVals.length==0) + continue; + int length = ysr8_SerialNoVals.length; + String[] nullArray = new String[length]; + Date[] nullDates = new Date[length]; + for(int j=0; j 0) + continue; + } else if (JGZT.equals("ɼӹ")) { + if (ysr8_SubPurchFinishDateVal == null || (!ysr8_SubTaskManuStateVal.equals("2") && !ysr8_SubTaskManuStateVal.equals("3") + && !ysr8_SubTaskManuStateVal.equals("4"))) { + continue; + } + if(date1 != null && fu.getDateString(ysr8_SubPurchFinishDateVal).compareTo(fu.getDateString(date1)) < 0) + continue; + if(date2 != null && fu.getDateString(ysr8_SubPurchFinishDateVal).compareTo(fu.getDateString(date2)) > 0) + continue; + } else if (JGZT.equals("ӹ")) { + if(ysr8_TechFinishDateVal == null || ysr8_DrawingReleaseDateVal != null || !ysr8_SubTaskManuStateVal.equals("1")) + continue; + if(date1 != null && fu.getDateString(ysr8_TechFinishDateVal).compareTo(fu.getDateString(date1)) < 0) + continue; + if(date2 != null && fu.getDateString(ysr8_TechFinishDateVal).compareTo(fu.getDateString(date2)) > 0) + continue; + } else if (JGZT.equals("ѵ")) { + if (ysr8_SubPurchFinishDateVal == null || ysr8_SubTaskManuStateVal.equals("1")) { + continue; + } + if(date1 != null && fu.getDateString(ysr8_SubPurchFinishDateVal).compareTo(fu.getDateString(date1)) < 0) + continue; + if(date2 != null && fu.getDateString(ysr8_SubPurchFinishDateVal).compareTo(fu.getDateString(date2)) > 0) + continue; + } else if (JGZT.isEmpty()) { + if(date1 != null && fu.getDateString(ysr8_TechFinishDateVal).compareTo(fu.getDateString(date1)) < 0) + continue; + if(date2 != null && fu.getDateString(ysr8_TechFinishDateVal).compareTo(fu.getDateString(date2)) > 0) + continue; + } + if (FHZT.equals("δ")) { + if(ysr8_ExWarehouseStateVals[j]==null) + continue; + else if(!ysr8_ExWarehouseStateVals[j].equals("1")) + continue; + else if(ysr8_ArrivedQuantityVals[j].isEmpty()) + continue; + if(ysr8_SubQualityResultVals[j]!=null && ysr8_SubQualityResultVals[j].equals("ϸ")) + continue; + }else if (FHZT.equals("ѳ")) { + if(ysr8_ExWarehouseStateVals[j]==null) + continue; + else if(!ysr8_ExWarehouseStateVals[j].equals("2")) + continue; + else if(ysr8_ArrivedQuantityVals[j].isEmpty()) + continue; + } + + String ysr8_SubManuFactory1Val = ysr8_SubManuFactory1Vals[j]; + if (ysr8_SubManuFactory1Val == null) { + ysr8_SubManuFactory1Val = ""; + } + String ysr8_SubManuFactory2Val = ysr8_SubManuFactory2Vals[j]; + if (ysr8_SubManuFactory2Val == null) { + ysr8_SubManuFactory2Val = ""; + } + if (!ManuFactory.isEmpty()) { + if (!ysr8_SubManuFactory1Val.equals(ManuFactory) && !ysr8_SubManuFactory2Val.equals(ManuFactory)) { + continue; + } + } + String fxzt = ""; + if(ysr8_SubQualityResultVals[j]==null) + ysr8_SubQualityResultVals[j] = ""; + if(ysr8_SubQualityResultVals[j].equals("ϸ") || ysr8_SubQualityResultVals[j].equals("ɵ")) { + TCComponent[] insps = TCUtil.query(fu.session, "SearchINSRepairECN", new String[] { "ysr8_RepairECN" }, new String[] { ecnid }); + if(insps.length>0) { + TCComponentForm inspForm = TCUtil.getItemRevisionMasterForm((TCComponentItemRevision) insps[0]); + String[] codes = inspForm.getTCProperty("ysr8_PartCode").getStringArrayValue(); +// String[] state = inspForm.getTCProperty("ysr8_SubTaskManuState").getStringArrayValue(); + String[] state = inspForm.getProperty("ysr8_SubQualityResult").split(","); + for(int k=0; k vec = new Vector<>(); + vec.add((++idx) + "");// + vec.add(ecn4Item.getProperty("item_id"));// ĵ + // ļӹ +// String ysr8_TechPlanDate = "", ysr8_MachinPlanDate = ""; +// String ysr8_TechPlanDateMin = "9900-01-01", ysr8_MachinPlanDateMin = "9900-01-01"; + if(materialID2.length>0) { + prId = ""; + ysr8_TechPlanDate = ""; + ysr8_MachinPlanDate = ""; + ysr8_TechPlanDateMin = "9900-01-01"; + ysr8_MachinPlanDateMin = "9900-01-01"; + for(int k=0; k0) { + ysr8_TechPlanDateMin = ysr8_TechPlanDate; + } + } +// Date MachinPlanDate = prMap.get(problemID[k]).getDateProperty("ysr8_MachinPlanDate"); + TCProperty ysr8_Ecn4IntialFinTime = ecn4Form.getFormTCProperty("ysr8_Ecn4IntialFinTime"); + Date MachinPlanDate = ysr8_Ecn4IntialFinTime.getDateValueArray()[k]; + if(MachinPlanDate != null) { + ysr8_MachinPlanDate = fu.getDateString(MachinPlanDate); + if(ysr8_MachinPlanDateMin.compareTo(ysr8_MachinPlanDate)>0) { + ysr8_MachinPlanDateMin = ysr8_MachinPlanDate; + } + } + } + } + if(ysr8_TechPlanDateMin.equals("9900-01-01")) + ysr8_TechPlanDateMin=""; + if(ysr8_MachinPlanDateMin.equals("9900-01-01")) + ysr8_MachinPlanDateMin=""; + + if(ysr8_TechPlanDateMin.isEmpty() && ysr8_MachinPlanDateMin.isEmpty() || ecn4Form.getDateProperty("ysr8_TechFinishDate")==null) { + ysr8_MachinPlanDateMin = ""; + }else if(!ysr8_MachinPlanDateMin.isEmpty()){ + int day = 0; + if(!ysr8_TechPlanDateMin.isEmpty()) + day = CommonUtil.getDaysBetween2(getDate(ysr8_TechPlanDateMin), ecn4Form.getDateProperty("ysr8_TechFinishDate")); + if(day>0) { + Calendar c = Calendar.getInstance(); + c.setTime(getDate(ysr8_MachinPlanDateMin)); + c.add(Calendar.DAY_OF_MONTH, day); + ysr8_MachinPlanDateMin = fu.getDateString(c.getTime()); + } + } + if(prId.length()>0) + prId = prId.substring(1); + } + vec.add(prId);//ldy 20180225 + + vec.add("");// kk 1011 ĵ + + vec.add("");// + String ysr8_ProjectCodeVal = ecn4Form.getProperty("ysr8_ProjectCode"); + vec.add(ysr8_ProjectCodeVal);// Ŀ + //20230928 Ŀ + vec.add(getName(ysr8_ProjectCodeVal));// Ŀ owning_user + vec.add(ysr8_SubManuFactory1Vals[j]);// ӹ1 + vec.add(ysr8_SubManuFactory2Vals[j]);// ӹ2 + { + TCComponentItem xmqdItem = TCUtil.findItemByID(fu.session, ysr8_ProjectCodeVal + "_XMQD"); + if (xmqdItem != null) { + TCComponentItemRevision xmqdRevision = xmqdItem.getLatestItemRevision(); + TCComponentForm xmqdForm = TCUtil.getItemRevisionMasterForm(xmqdRevision); + vec.add(xmqdForm.getProperty("ysr8_Factory"));// + } else { + vec.add("");// + } + } + vec.add(ecn4Form.getProperty("ysr8_ManuPerson"));// + + vec.add("");// ķ + vec.add(ysr8_MaterialIDVals[j]);// + vec.add(ysr8_MaterialNameVals[j]);// + if(ysr8_QuantityVals==null||ysr8_QuantityVals.length==0) + vec.add(""); + else + vec.add(Double.toString(ysr8_QuantityVals[j]).split("\\.")[0]);// +// vec.add(ysr8_OriginalDesignerVals[j]);// + vec.add(ecn4Form.getProperty("ysr8_Changer"));// + vec.add(fu.getDateString(ecn4Form.getDateProperty("ysr8_TechFinishDate")));// ͼ + +// vec.add(ecn4Form.getProperty("ysr8_TechFinishDate"));// kk 1011 ƻ +// if(prForm!=null) { +// vec.add(fu.getDateString(prForm.getDateProperty("ysr8_TechPlanDate")));// lidy 20190225 ƻ +// }else +// vec.add("");// lidy 20190225 ƻ + vec.add(ysr8_TechPlanDateMin);// lidy 20190225 ƻ + + vec.add(fu.getDateString(ysr8_DrawingReleaseDateVals[j]));// ͼֽӹʱ +// if(prForm!=null) { +// vec.add(fu.getDateString(prForm.getDateProperty("ysr8_MachinPlanDate")));// lidy 20190225 ӹƻ +// }else +// vec.add("");// lidy 20190225 ӹƻ + vec.add(ysr8_MachinPlanDateMin);// lidy 20190225 ӹƻ + vec.add(fu.getDateString(ysr8_SubPurchPlanDateVals[j]));// ɹҪ + vec.add(fu.getDateString(ysr8_SubPurchFinishDateVals[j]));// ӹʵʱ + // kk + vec.add(ysr8_ArrivingQuantityVals[j]==null?"":ysr8_ArrivingQuantityVals[j].split("\\.")[0]);// ε + vec.add(ysr8_ArrivedQuantityVals[j]==null?"":ysr8_ArrivedQuantityVals[j].split("\\.")[0]);// ѵ + vec.add(ysr8_RemarkVals[j]);// ע + vec.add(ysr8_SubQualityResultVals[j]);// ʼ + vec.add(fxzt);// ״̬ + vec.add("");// ϸ + + vec.add(lovysr8_SubTaskManuState.get(ysr8_SubTaskManuStateVals[j]));// ״̬ + vec.add(fu.getDateString(ysr8_SubQualityFinishDateVals[j]));// ʼʱ + vec.add(lovysr8_ExWarehouse.get(ysr8_ExWarehouseStateVals[j]));// ״̬ + vec.add(fu.getDateString(ysr8_ExWarehouseDateVals[j]));// + vec.add(ysr8_ExWarehouseQuantityVals[j]);// + vec.add(ysr8_ExWarehousePersonVals[j]);// + vec.add(ysr8_ExWarehouseRemarkVals[j]);// ⱸע + + + //20230921 ԭ Ƿ + //ƻʱͼƻʱΪ Ͳ +// TCProperty ysr8_SubChangeScheme = ecn4Form.getFormTCProperty("ysr8_SubChangeScheme"); +// String[] ysr8_SubChangeSchemeVals = ysr8_SubChangeScheme.getStringArrayValue(); +// if(ysr8_SubChangeSchemeVals==null||ysr8_SubChangeSchemeVals.length==0) +// ysr8_SubChangeSchemeVals = nullArray; + + String techPlan = ysr8_MachinPlanDateMin; + String machPlan = fu.getDateString(ysr8_SubPurchFinishDateVals[j]); + // String fangan = ysr8_SubChangeSchemeVals[j];//ķ + System.out.println("techPlan================="+techPlan); + System.out.println("machPlan================="+machPlan); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); +// if(fangan != null && fangan.equals("װͼ")) { +// vec.add(""); +// }else { + if(!techPlan.isEmpty() && !machPlan.isEmpty()) { + if(sdf.parse(machPlan).compareTo(sdf.parse(techPlan)) > 0) { + vec.add(""); + }else { + vec.add(""); + } + }else if(!techPlan.isEmpty() && machPlan.isEmpty()) { + Date date = new Date(); + if(date.compareTo(sdf.parse(techPlan)) > 0) { + vec.add(""); + }else { + vec.add(""); + } + }else { + vec.add(""); + } + + TCProperty ysr8_Ecn4DelayReason = KUtil.getNewlyAddedArrayProperty("ysr8_Ecn4DelayReason", ecn4Form, cnt); + String[] ysr8_Ecn4DelayReasonVals = ysr8_Ecn4DelayReason.getStringArrayValue(); + if(ysr8_Ecn4DelayReasonVals==null || ysr8_Ecn4DelayReasonVals.length==0) + ysr8_Ecn4DelayReasonVals = nullArray; + + + vec.add(ysr8_Ecn4DelayReasonVals.length < j+1 ? "" : ysr8_Ecn4DelayReasonVals[j]);// ԭ + vec.add(ecn4Form.getStringProperty("ysr8_SubProjectCode")); + ci.dataTableModel.addRow(vec); + allObjectMap2.put(idx - 1, ecn4Item); + allObjectMap2Idx.put(idx - 1, j); + } + } + } + + private void searchMachiningInfo_YSR8_SingleRepairBJ(String[] attrs, String[] vals, String JGZT, String FHZT, String ManuFactory, String ZJZT) throws Exception { + JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.61.11.11"); + TCComponent[] tcComponents = TCUtil.query(fu.session, "SearchINSPRecordRevision", attrs, vals); + tcComponents = TCUtil.TCsort(tcComponents, "item_id"); + Integer idx = ci.dataTableModel.getRowCount(); + Vector schemes = new Vector<>(); + schemes.add("װͼ"); + schemes.add("ԭ޸"); + schemes.add("װʾͼ"); + for (int i = 0; i < tcComponents.length; i++) { + TCComponentItemRevision ipRevision = (TCComponentItemRevision) tcComponents[i]; + String ecnid = ipRevision.getProperty("item_id"); + System.out.println(ecnid); + TCComponentItem ipItem = ipRevision.getItem(); + TCComponentForm ipForm = TCUtil.getItemRevisionMasterForm(ipRevision); + ipForm.refresh(); + + String ysr8_SubManuFactory1Val = ipForm.getProperty("ysr8_ManuFactory1"); + if (ysr8_SubManuFactory1Val == null) { + ysr8_SubManuFactory1Val = ""; + } + String ysr8_SubManuFactory2Val = ipForm.getProperty("ysr8_ManuFactory2"); + if (ysr8_SubManuFactory2Val == null) { + ysr8_SubManuFactory2Val = ""; + } + if (!ManuFactory.isEmpty()) { + if (!ysr8_SubManuFactory1Val.equals(ManuFactory) && !ysr8_SubManuFactory2Val.equals(ManuFactory)) { + continue; + } + } + + TCProperty ysr8_PartCode = ipForm.getFormTCProperty("ysr8_PartCode"); + String[] ysr8_PartCodeVals = ysr8_PartCode.getStringArrayValue(); + if(ysr8_PartCodeVals==null||ysr8_PartCodeVals.length==0) + continue; + int length = ysr8_PartCodeVals.length; + String[] nullArray = new String[length]; + Date[] nullDates = new Date[length]; + for(int j=0; j0 + String numStr = ysr8_SubUnqualifiedQuantityVals[j]; + if (numStr != null && !"".equals(numStr)) { + try { + double num = Double.parseDouble(TCUtil.getNumber(numStr.trim())); + if (num <= 0) { + continue; + } + } catch (NumberFormatException e) { + System.out.println(ipItem.getProperty("item_id")+""+(j+1)+"вϸ = " + numStr); +// e.printStackTrace(); + continue; + } + } else { + continue; + } + Date ysr8_TechFinishDateVal = ipItem.getDateProperty("creation_date"); + Date ysr8_DrawingReleaseDateVal = ysr8_DrawingReleaseDateVals[j]; + Date ysr8_SubPurchFinishDateVal = ysr8_SubPurchFinishDateVals[j]; + String ysr8_SubTaskManuStateVal = ysr8_SubTaskManuStateVals[j]; + if (ysr8_SubTaskManuStateVal == null) { + ysr8_SubTaskManuStateVal = ""; + } + if (JGZT.equals("ӹ")) { + if (ysr8_DrawingReleaseDateVal == null || (!ysr8_SubTaskManuStateVal.equals("1") && !ysr8_SubTaskManuStateVal.equals("5"))) { + continue; + } + if(date1 != null && fu.getDateString(ysr8_DrawingReleaseDateVal).compareTo(fu.getDateString(date1)) < 0) + continue; + if(date2 != null && fu.getDateString(ysr8_DrawingReleaseDateVal).compareTo(fu.getDateString(date2)) > 0) + continue; + } else if (JGZT.equals("ɼӹ")) { + if (ysr8_SubPurchFinishDateVal == null || (!ysr8_SubTaskManuStateVal.equals("2") && !ysr8_SubTaskManuStateVal.equals("3") + && !ysr8_SubTaskManuStateVal.equals("4"))) { + continue; + } + if(date1 != null && fu.getDateString(ysr8_SubPurchFinishDateVal).compareTo(fu.getDateString(date1)) < 0) + continue; + if(date2 != null && fu.getDateString(ysr8_SubPurchFinishDateVal).compareTo(fu.getDateString(date2)) > 0) + continue; + } else if (JGZT.equals("ӹ")) { + if(ysr8_TechFinishDateVal == null || ysr8_DrawingReleaseDateVal != null || !ysr8_SubTaskManuStateVal.equals("1")) + continue; + if(date1 != null && fu.getDateString(ysr8_TechFinishDateVal).compareTo(fu.getDateString(date1)) < 0) + continue; + if(date2 != null && fu.getDateString(ysr8_TechFinishDateVal).compareTo(fu.getDateString(date2)) > 0) + continue; + } else if (JGZT.equals("ѵ")) { + if (ysr8_SubPurchFinishDateVal == null || ysr8_SubTaskManuStateVal.equals("1")) { + continue; + } + if(date1 != null && fu.getDateString(ysr8_SubPurchFinishDateVal).compareTo(fu.getDateString(date1)) < 0) + continue; + if(date2 != null && fu.getDateString(ysr8_SubPurchFinishDateVal).compareTo(fu.getDateString(date2)) > 0) + continue; + } else if (JGZT.isEmpty()) { + if(date1 != null && fu.getDateString(ysr8_TechFinishDateVal).compareTo(fu.getDateString(date1)) < 0) + continue; + if(date2 != null && fu.getDateString(ysr8_TechFinishDateVal).compareTo(fu.getDateString(date2)) > 0) + continue; + } + if (FHZT.equals("δ")) { + if(ysr8_ExWarehouseStateVals[j]==null) + continue; + else if(!ysr8_ExWarehouseStateVals[j].equals("1")) + continue; + else if(ysr8_ArrivedQuantityVals[j].isEmpty()) + continue; + else if(schemes.contains(lovysr8_Measures.get(ysr8_MeasuresVals[j]))) + continue; + if(ipForm.getProperty("ysr8_PartType").equals("")) + continue; + if(ysr8_SubQualityResultVals[j]!=null && ysr8_SubQualityResultVals[j].equals("ϸ")) + continue; + }else if (FHZT.equals("ѳ")) { + if(ysr8_ExWarehouseStateVals[j]==null) + continue; + else if(!ysr8_ExWarehouseStateVals[j].equals("2")) + continue; + else if(ysr8_ArrivedQuantityVals[j].isEmpty()) + continue; + } + String fxzt = ""; + if(ysr8_SubQualityResultVals[j]==null) + ysr8_SubQualityResultVals[j] = ""; + if(ysr8_SubQualityResultVals[j].equals("ϸ") || ysr8_SubQualityResultVals[j].equals("ɵ")) { + TCComponent[] insps = TCUtil.query(fu.session, "SearchINSRepairECN", new String[] { "ysr8_RepairECN" }, new String[] { ecnid }); + if(insps.length>1 && !insps[0].equals(ipRevision)) { + TCComponentForm inspForm = TCUtil.getItemRevisionMasterForm((TCComponentItemRevision) insps[0]); + String[] codes = inspForm.getTCProperty("ysr8_PartCode").getStringArrayValue(); +// String[] state = inspForm.getTCProperty("ysr8_SubTaskManuState").getStringArrayValue(); + String[] state = inspForm.getProperty("ysr8_SubQualityResult").split(","); + for(int k=0; k vec = new Vector<>(); + vec.add((++idx) + "");// +// vec.add(ipForm.getProperty("ysr8_ReworkOrderNo"));// ĵ + + vec.add(ipItem.getProperty("item_id")); + vec.add("");//ldy 20180225 + if(ysr8_RepairECNVals==null||ysr8_RepairECNVals.length==0) + vec.add(""); + else + vec.add(ysr8_RepairECNVals[j]);//kk 1011 ĵ + + vec.add(ipForm.getProperty("ysr8_PartType"));// + String ysr8_ProjectCodeVal = ipForm.getProperty("ysr8_ProjectCode"); + vec.add(ysr8_ProjectCodeVal);// Ŀ + //20230928 Ŀ + vec.add(getName(ysr8_ProjectCodeVal));// Ŀ owning_user + vec.add(ipForm.getProperty("ysr8_ManuFactory1"));// ӹ1 + vec.add(ipForm.getProperty("ysr8_ManuFactory2"));// ӹ2 + { + TCComponentItem xmqdItem = TCUtil.findItemByID(fu.session, ysr8_ProjectCodeVal + "_XMQD"); + if (xmqdItem != null) { + TCComponentItemRevision xmqdRevision = xmqdItem.getLatestItemRevision(); + TCComponentForm xmqdForm = TCUtil.getItemRevisionMasterForm(xmqdRevision); + vec.add(xmqdForm.getProperty("ysr8_Factory"));// + } else { + vec.add("");// + } + } + vec.add(ipForm.getProperty("ysr8_ManuPerson"));// ӹ + +// vec.add("");// ķ + vec.add(lovysr8_Measures.get(ysr8_MeasuresVals[j]));// ķ + vec.add(ysr8_PartCodeVals[j]);// + vec.add(ysr8_PartNameVals[j]);// + vec.add(ysr8_SubUnqualifiedQuantityVals[j].split("\\.")[0]);// + vec.add("");// + vec.add(fu.getDateString(ipItem.getDateProperty("creation_date")));// ͼ + vec.add("");//ƻ + vec.add(fu.getDateString(ysr8_DrawingReleaseDateVals[j]));// ͼֽӹʱ + vec.add("");// lidy 20190225 ӹƻ + vec.add(fu.getDateString(ysr8_PurchPlanDate1Vals[j]));// ɹҪ + vec.add(fu.getDateString(ysr8_SubPurchFinishDateVals[j]));// ӹʵʱ + // kk + vec.add(ysr8_ArrivingQuantityVals[j]==null?"":ysr8_ArrivingQuantityVals[j].split("\\.")[0]);// ε + vec.add(ysr8_ArrivedQuantityVals[j]==null?"":ysr8_ArrivedQuantityVals[j].split("\\.")[0]);// ѵ + + if(ysr8_RemarkVals==null||ysr8_RemarkVals.length==0) + vec.add(""); + else + vec.add(ysr8_RemarkVals[j]);// ע + vec.add(ysr8_SubQualityResultVals[j]);// ʼ + vec.add(fxzt);// ״̬ + if(ysr8_UnqualifiedDescVals==null||ysr8_UnqualifiedDescVals.length==0) + vec.add(""); + else + vec.add(ysr8_UnqualifiedDescVals[j]);// ϸ + + vec.add(lovysr8_SubTaskManuState.get(ysr8_SubTaskManuStateVals[j]));// ״̬ + vec.add(fu.getDateString(ysr8_SubQualityFinishDateVals[j]));// ʼʱ + vec.add(lovysr8_ExWarehouse.get(ysr8_ExWarehouseStateVals[j]));// ״̬ + vec.add(fu.getDateString(ysr8_ExWarehouseDateVals[j]));// + vec.add(ysr8_ExWarehouseQuantityVals[j]);// + vec.add(ysr8_ExWarehousePersonVals[j]);// + vec.add(ysr8_ExWarehouseRemarkVals[j]);// ⱸע + + ci.dataTableModel.addRow(vec); + allObjectMap2.put(idx - 1, ipItem); + allObjectMap2Idx.put(idx - 1, j); + } + } + } + + + + private void editRemark() throws Exception { + + System.out.println("༭ע..."); + if (currTable == 1) { + JTable table = (JTable) fu.allComponentMap.get("a.41.11.11"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post(this, "ѡҪ༭ݣ", "ʾ", MessageBox.INFORMATION); + return; + } + EditObjectInfo editObjectInfo = new EditObjectInfo(); + for(int i=0; i1 && !taskState.equals("δ") ) { +// MessageBox.post("ѡа[ѵ][ѱ][Ѽ][]״̬У޷༭飡", "ʾ" +// , MessageBox.INFORMATION); +// return; +// } + if (taskState == null || !(taskState.equals("δ") || taskState.equals(""))) { + MessageBox.post("״̬Ϊ[δ][]ݲܽб༭", "ʾ", MessageBox.INFORMATION); + return; + } + if (getTableVal(table, rows[i], BJ8).isEmpty() || getTableVal(table, rows[i], BJ8).equals("0")) { + MessageBox.post("ΪջΪв༭ϵĿƻԱ", "ʾ", MessageBox.INFORMATION); + return; + } +// String subProject = table.getValueAt(rows[i], T1_TASKNAME_INDEX).toString(); +// if(subProject.startsWith("׷滻")) { +// subProject = subProject.substring(4, subProject.indexOf("_")); +// } +// if(taskName.isEmpty()) { +// taskName = subProject; +// } else { +// if(!isMachiningManager && !taskName.equals(subProject)) { +// MessageBox.post("ѡевͬһĿ༭", "ʾ", MessageBox.INFORMATION); +// return; +// } +// } + Boolean isLeading = getTableVal(table, rows[i], BJ6).equals(user.getProperty("user_name")); +// if (table.getValueAt(rows[i], T1_NAME_INDEX).toString().equals(user.getProperty("user_name"))) { +// isLeading = true; +// } else { +// isLeading = onDuty; +// /* +// * String onDutyMan = TCUtil.getPreference2(fu.session, +// * TCPreferenceService.TC_preference_site, "YSR8_MachiningDynamics_OnDutyMan"); +// * if (onDutyMan.equals(user.getProperty("user_name"))) { isLeading = true; } +// */ +// } + if (!isMachiningManager && !isLeading && !onDuty) { + MessageBox.post("Ǽӹܻӹ˻ֵԱܽб༭", "ʾ", MessageBox.INFORMATION); + return; + } + if (!isMachiningManager && (getTableVal(table, rows[i], BJ13).isEmpty() || getTableVal(table, rows[i], BJ2).isEmpty())) { + MessageBox.post("ͼڻӹΪյֻɼӹܱ༭", "ʾ", MessageBox.INFORMATION); + return; + } + //lidy20190606༭ǩ + if(allObjectMap1.get(idx - 1) instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem) allObjectMap1.get(idx - 1); + TCComponentItemRevision revision = item.getLatestItemRevision(); + TCComponentForm form = TCUtil.getItemRevisionMasterForm(revision); + if(form.isCheckedOut()) { + MessageBox.post("汾" + form + "ѱǩ޷༭", "ʾ", MessageBox.INFORMATION); + return; + } + } + editObjectInfo.editObjects.add(allObjectMap1.get(idx - 1)); + editObjectInfo.editObjectListIdxs.add(allObjectMap1Idx.get(idx - 1)); + editObjectInfo.rows.add(idx - 1); + editObjectInfo.isLeadings.add(isLeading || onDuty); + } + if (editObjectInfo.editObjects.size() == 0) { + return; + } + MachiningDynamicsManageEditDialog dialog = + new MachiningDynamicsManageEditDialog(this, currTable, isMachiningManager, editObjectInfo); + System.out.println("1");// + dialogResult = dialog.dialogResult(); + } else if (currTable == 2) { + JTable table = (JTable) fu.allComponentMap.get("a.61.11.11"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪ༭ݣ", "ʾ", MessageBox.INFORMATION); + return; + } + TCComponentUser user = fu.session.getUser(); + String machiningManager = + TCUtil.getPreference2(fu.session, TCPreferenceService.TC_preference_site, "YSR8_MachiningDynamics_MachiningManager"); + Boolean isMachiningManager = false; + if (machiningManager.equals(user.getProperty("user_name"))) { + isMachiningManager = true; + } + + EditObjectInfo editObjectInfo = new EditObjectInfo(); + Boolean onDuty = checkLeader(user); + + for (int i = 0; i < rows.length; i++) { + int idx = Integer.parseInt(getTableVal(table, rows[i], 0)); + Object taskState = getTableVal(table, rows[i], SJ26); + if (!taskState.equals("δ") && !taskState.equals("")) { + MessageBox.post("" + idx + "״̬Ϊ[δ][]ݲܽб༭", "ʾ", MessageBox.INFORMATION); + continue; + } + Boolean isLeading = getTableVal(table, rows[i], SJ10).equals(user.getProperty("user_name")); +// if (table.getValueAt(rows[i], T2_NAME_INDEX).toString().equals(user.getProperty("user_name"))) { +// isLeading = true; +// } else { +// isLeading = checkLeader(user); +// /* +// * String onDutyMan = TCUtil.getPreference2(fu.session, +// * TCPreferenceService.TC_preference_site, "YSR8_MachiningDynamics_OnDutyMan"); +// * if (onDutyMan.equals(user.getProperty("user_name"))) { isLeading = true; } +// */ +// } + if (!isMachiningManager && !isLeading && !onDuty) { + MessageBox.post("ǰûǼӹܻ" + idx + "ļӹ˲ܽб༭", "ʾ", MessageBox.INFORMATION); + return; + } + TCComponentItem item = (TCComponentItem) allObjectMap2.get(idx - 1); + + if (!item.getProperty("object_type").equals("YSR8_INSPRecord")&&!isMachiningManager && + (getTableVal(table, rows[i], SJ18).isEmpty() || getTableVal(table, rows[i], SJ7).isEmpty())) { + MessageBox.post("ͼڻӹΪյֻɼӹܱ༭", "ʾ", MessageBox.INFORMATION); + return; + } + //lidy20190606༭ǩ + TCComponentItemRevision revision = item.getLatestItemRevision(); + TCComponentForm form = TCUtil.getItemRevisionMasterForm(revision); + if(form.isCheckedOut()) { + MessageBox.post("汾" + form + "ѱǩ޷༭", "ʾ", MessageBox.INFORMATION); + return; + } + editObjectInfo.editObjects.add(allObjectMap2.get(idx - 1)); + editObjectInfo.editObjectListIdxs.add(allObjectMap2Idx.get(idx - 1)); + editObjectInfo.rows.add(idx - 1); + editObjectInfo.editObjectMaterialID.add(getTableVal(table, rows[i], SJ10)); + editObjectInfo.isLeadings.add(isLeading || onDuty); + } + if (editObjectInfo.editObjects.size() == 0) { + return; + } + MachiningDynamicsManageEditDialog dialog = + new MachiningDynamicsManageEditDialog(this, currTable, isMachiningManager, editObjectInfo); + System.out.println("2"); + dialogResult = dialog.dialogResult(); + + } + } catch (Exception e) { + e.printStackTrace(); + } +// catch (InterruptedException e) { +// e.printStackTrace(); +// } + if (dialogResult == AbstractAIFDialog.ID_OK) { +// if (searBtn.isEnabled()) { +// searBtn.doClick(); +// } + } + } + + // ԭ + private void editTardiness() { + int dialogResult = AbstractAIFDialog.ID_CANCEL; + try { + if (currTable == 1) { + JTable table = (JTable) fu.allComponentMap.get("a.41.11.11"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪ༭ݣ", "ʾ", MessageBox.INFORMATION); + return; + } + + TCComponentUser user = fu.session.getUser(); + String machiningManager = + TCUtil.getPreference2(fu.session, TCPreferenceService.TC_preference_site, "YSR8_MachiningDynamics_MachiningManager"); + Boolean isMachiningManager = false; + if (machiningManager.equals(user.getProperty("user_name"))) { + isMachiningManager = true; + } + + EditObjectInfo editObjectInfo = new EditObjectInfo(); + Boolean onDuty = checkLeader(user); +// String taskName = ""; + + for (int i = 0; i < rows.length; i++) { + int idx = Integer.parseInt(getTableVal(table, rows[i], 0)); + Object taskState = getTableVal(table, rows[i], BJ19); +// if (rows.length>1 && !taskState.equals("δ") ) { +// MessageBox.post("ѡа[ѵ][ѱ][Ѽ][]״̬У޷༭飡", "ʾ" +// , MessageBox.INFORMATION); +// return; +// } +// if (taskState == null || !(taskState.equals("δ") || taskState.equals(""))) { +// MessageBox.post("״̬Ϊ[δ][]ݲܽб༭", "ʾ", MessageBox.INFORMATION); +// return; +// } + if (getTableVal(table, rows[i], BJ8).isEmpty() || getTableVal(table, rows[i], BJ8).equals("0")) { + MessageBox.post("ΪջΪв༭ϵĿƻԱ", "ʾ", MessageBox.INFORMATION); + return; + } +// String subProject = table.getValueAt(rows[i], T1_TASKNAME_INDEX).toString(); +// if(subProject.startsWith("׷滻")) { +// subProject = subProject.substring(4, subProject.indexOf("_")); +// } +// if(taskName.isEmpty()) { +// taskName = subProject; +// } else { +// if(!isMachiningManager && !taskName.equals(subProject)) { +// MessageBox.post("ѡевͬһĿ༭", "ʾ", MessageBox.INFORMATION); +// return; +// } +// } + Boolean isLeading = getTableVal(table, rows[i], BJ6).equals(user.getProperty("user_name")); +// if (table.getValueAt(rows[i], T1_NAME_INDEX).toString().equals(user.getProperty("user_name"))) { +// isLeading = true; +// } else { +// isLeading = onDuty; +// /* +// * String onDutyMan = TCUtil.getPreference2(fu.session, +// * TCPreferenceService.TC_preference_site, "YSR8_MachiningDynamics_OnDutyMan"); +// * if (onDutyMan.equals(user.getProperty("user_name"))) { isLeading = true; } +// */ +// } + if (!isMachiningManager && !isLeading && !onDuty) { + MessageBox.post("Ǽӹܻӹ˻ֵԱܽб༭", "ʾ", MessageBox.INFORMATION); + return; + } + if (!isMachiningManager && (getTableVal(table, rows[i], BJ13).isEmpty() || getTableVal(table, rows[i], BJ2).isEmpty())) { + MessageBox.post("ͼڻӹΪյֻɼӹܱ༭", "ʾ", MessageBox.INFORMATION); + return; + } + //lidy20190606༭ǩ + if(allObjectMap1.get(idx - 1) instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem) allObjectMap1.get(idx - 1); + TCComponentItemRevision revision = item.getLatestItemRevision(); + TCComponentForm form = TCUtil.getItemRevisionMasterForm(revision); + if(form.isCheckedOut()) { + MessageBox.post("汾" + form + "ѱǩ޷༭", "ʾ", MessageBox.INFORMATION); + return; + } + } + editObjectInfo.editObjects.add(allObjectMap1.get(idx - 1)); + editObjectInfo.editObjectListIdxs.add(allObjectMap1Idx.get(idx - 1)); + editObjectInfo.rows.add(idx - 1); + editObjectInfo.isLeadings.add(isLeading || onDuty); + } + if (editObjectInfo.editObjects.size() == 0) { + return; + } + TardinessEditDialog dialog = + new TardinessEditDialog(this, currTable, isMachiningManager, editObjectInfo); + System.out.println("1");// + dialogResult = dialog.dialogResult(); + }else if (currTable == 2) { + JTable table = (JTable) fu.allComponentMap.get("a.61.11.11"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪ༭ݣ", "ʾ", MessageBox.INFORMATION); + return; + } + TCComponentUser user = fu.session.getUser(); + String machiningManager = + TCUtil.getPreference2(fu.session, TCPreferenceService.TC_preference_site, "YSR8_MachiningDynamics_MachiningManager"); + Boolean isMachiningManager = false; + if (machiningManager.equals(user.getProperty("user_name"))) { + isMachiningManager = true; + } + + EditObjectInfo editObjectInfo = new EditObjectInfo(); + Boolean onDuty = checkLeader(user); + + for (int i = 0; i < rows.length; i++) { + int idx = Integer.parseInt(getTableVal(table, rows[i], 0)); + Object taskState = getTableVal(table, rows[i], SJ26); +// if (!taskState.equals("δ") && !taskState.equals("")) { +// MessageBox.post("" + idx + "״̬Ϊ[δ][]ݲܽб༭", "ʾ", MessageBox.INFORMATION); +// continue; +// } + Boolean isLeading = getTableVal(table, rows[i], SJ10).equals(user.getProperty("user_name")); +// if (table.getValueAt(rows[i], T2_NAME_INDEX).toString().equals(user.getProperty("user_name"))) { +// isLeading = true; +// } else { +// isLeading = checkLeader(user); +// /* +// * String onDutyMan = TCUtil.getPreference2(fu.session, +// * TCPreferenceService.TC_preference_site, "YSR8_MachiningDynamics_OnDutyMan"); +// * if (onDutyMan.equals(user.getProperty("user_name"))) { isLeading = true; } +// */ +// } + if (!isMachiningManager && !isLeading && !onDuty) { + MessageBox.post("ǰûǼӹܻ" + idx + "ļӹ˲ܽб༭", "ʾ", MessageBox.INFORMATION); + return; + } + TCComponentItem item = (TCComponentItem) allObjectMap2.get(idx - 1); + + if (!item.getProperty("object_type").equals("YSR8_INSPRecord")&&!isMachiningManager && + (getTableVal(table, rows[i], SJ18).isEmpty() || getTableVal(table, rows[i], SJ7).isEmpty())) { + MessageBox.post("ͼڻӹΪյֻɼӹܱ༭", "ʾ", MessageBox.INFORMATION); + return; + } + //lidy20190606༭ǩ + TCComponentItemRevision revision = item.getLatestItemRevision(); + TCComponentForm form = TCUtil.getItemRevisionMasterForm(revision); + if(form.isCheckedOut()) { + MessageBox.post("汾" + form + "ѱǩ޷༭", "ʾ", MessageBox.INFORMATION); + return; + } + editObjectInfo.editObjects.add(allObjectMap2.get(idx - 1)); + editObjectInfo.editObjectListIdxs.add(allObjectMap2Idx.get(idx - 1)); + editObjectInfo.rows.add(idx - 1); + editObjectInfo.editObjectMaterialID.add(getTableVal(table, rows[i], SJ10)); + editObjectInfo.isLeadings.add(isLeading || onDuty); + } + if (editObjectInfo.editObjects.size() == 0) { + return; + } + TardinessEditDialog dialog = + new TardinessEditDialog(this, currTable, isMachiningManager, editObjectInfo); + System.out.println("2"); + dialogResult = dialog.dialogResult(); + + } + } catch (Exception e) { + e.printStackTrace(); + } +} + + + // kk Ϊֵ + private boolean checkLeader(TCComponentUser user) throws Exception { + String[] onDutyMans = TCUtil.getPreference(fu.session, TCPreferenceService.TC_preference_site, "YSR8_MachiningDynamics_OnDutyMan"); + if (onDutyMans == null || onDutyMans.length == 0) { + return false; + } + String name = user.getProperty("user_name"); + for (String onDutyMan : onDutyMans) { + if (onDutyMan.equals(name)) { + return true; + } + } + return false; + } + + private void outputMachiningInfo() { + final JButton btn = (JButton) fu.allComponentMap.get("b.21.17"); + btn.setEnabled(false); + // final JComboBox cbx = + // (JComboBox)fu.allComponentMap.get("BBLX"); + // String bblx = cbx.getSelectedItem().toString(); + final JTable table1 = (JTable) fu.allComponentMap.get("a.41.11.11"); + final JTable table2 = (JTable) fu.allComponentMap.get("a.61.11.11"); + + final ProgressReporterDialog reporter = new ProgressReporterDialog(); + reporter.reportProgressMessage("ڵ,Ժ..."); + new Thread(reporter).start(); + new Thread() { + public void run() { + File tempFile = TCUtil.findTemplete(session, "YSR8_MachiningDynamicsTemplate", "ӹ̬ģ"); + if(tempFile==null) { + return; + } + InputStream input = null; + FileOutputStream output = null; + try { + Date date = new Date(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + String time = sdf.format(date); + String toPath = System.getProperty("java.io.tmpdir") + "ӹ̬" + time + ".xls"; + System.out.println(toPath); + input = new FileInputStream(tempFile); + HSSFWorkbook wb = new HSSFWorkbook(input); + HSSFSheet sheet = wb.getSheetAt(0); + //д + int columnCount = table1.getColumnCount(); // + int rowCount1 = table1.getRowCount(); // + if(rowCount1>0) { + int startRow = 1; // ʼǰΪʼ + // + POIUtil.insertRow(sheet, 1, rowCount1); + //д + HSSFRow row; + HSSFCell cell; + for (int i = 0; i < rowCount1; i++) { + row = sheet.getRow(startRow+i); + for (int j = 0; j < columnCount; j++) { + cell = row.getCell(j); + if(cell==null) { + cell = row.createCell(j); + } + POIUtil.setCellData(cell, getTableVal(table1, i, j)); + } + } + } + sheet = wb.getSheetAt(1); + //д + columnCount = table2.getColumnCount(); // + int rowCount2 = table2.getRowCount(); // + if(rowCount2>0) { + int startRow = 1; // ʼǰΪʼ + // + POIUtil.insertRow(sheet, 1, rowCount2); + //д + HSSFRow row; + HSSFCell cell; + for (int i = 0; i < rowCount2; i++) { + row=sheet.getRow(startRow+i); + for (int j = 0; j < columnCount; j++) { + cell=row.getCell(j); + if(cell==null) { + cell=row.createCell(j); + } + POIUtil.setCellData(cell, getTableVal(table2, i, j)); + } + } + } + + output=new FileOutputStream(toPath); + wb.write(output); + + // 򿪵ıļ + Runtime.getRuntime().exec("cmd /c \"" + toPath + "\""); + + } catch (Exception e) { + e.printStackTrace(); + }finally { + if(output!=null) { + try { + output.close(); + } catch (IOException e) { + } + } + if(input!=null) { + try { + input.close(); + } catch (IOException e) { + } + } + tempFile.delete(); + } + reporter.requestCanceling(); + btn.setEnabled(true); + } + }.start(); + } + + private void pipingLinePlanningManagement() { + try { + new PipingLinePlanningManagementDialog(fu.session); + } catch (Exception e) { + e.printStackTrace(); + } + } + + protected void updateValues(HashMap tableMap) { + JTable table = null; + if(currTable==1) { + table = (JTable) fu.allComponentMap.get("a.41.11.11"); + } else if(currTable==2) { + table = (JTable) fu.allComponentMap.get("a.61.11.11"); + } + int[] rows = table.getSelectedRows(); + for(int i : rows) { + for(String s : tableMap.keySet()) { + String value = tableMap.get(s); + if(currTable==1) { + if(s.equals("ysr8_ManuPersonVal")) { + table.setValueAt(value, i, BJ6); + } else if(s.equals("ysr8_DelayReason")) { + table.setValueAt(value, i, BJ25); + }else if(s.equals("ysr8_ManuFactory1Val")) { + table.setValueAt(value, i, BJ3); + } else if(s.equals("ysr8_ManuFactory2Val")) { + table.setValueAt(value, i, BJ4); + } else if(s.equals("ysr8_DrawingReleaseDateVal")) { + if(value.length()>10) + table.setValueAt(value.substring(0, 10), i, BJ13); + else + table.setValueAt(value, i, 12); + } else if(s.equals("ysr8_PurchPlanDateVal")) { + if(value.length()>10) + table.setValueAt(value.substring(0, 10), i, BJ14); + else + table.setValueAt(value, i, BJ14); + } else if(s.equals("ysr8_PurchFinishDateVal")) { + if(value.length()>10) + table.setValueAt(value.substring(0, 10), i, BJ15); + else + table.setValueAt(value, i, BJ15); + } else if(s.equals("ysr8_ArrivingQuantityVal")) { + table.setValueAt(value, i, BJ16); + } else if(s.equals("ysr8_ArrivedQuantity")) { + table.setValueAt(value, i, BJ17); + } else if(s.equals("remark")) { + table.setValueAt(value, i, BJ18); + } else if(s.equals("ysr8_SubTaskManuState") || s.equals("ysr8_TaskManuState")) { + if(value.equals("1")) { + table.setValueAt("δ", i, BJ19); + } else if(value.equals("2")) { + table.setValueAt("ѵ", i, BJ19); + } else if(value.equals("3")) { + table.setValueAt("ѱ", i, BJ19); + } else if(value.equals("4")) { + table.setValueAt("Ѽ", i, BJ19); + } else if(value.equals("5")) { + table.setValueAt("", i, BJ19); + } + } + } else if(currTable==2) { + if(s.equals("ysr8_ManuFactory1Val")) { + table.setValueAt(value, i, SJ7); + }else if(s.equals("ysr8_DelayReason")) { + table.setValueAt(value, i, 36); + } + else if(s.equals("ysr8_ManuFactory2Val")) { + table.setValueAt(value, i, SJ8); + } else if(s.equals("ysr8_ManuPersonVal")) { + table.setValueAt(value, i, SJ10); + } else if(s.equals("ysr8_DrawingReleaseDateVal")) { +// table.setValueAt(value, i, 17); + if(value.length()>10) + table.setValueAt(value.substring(0, 10), i, SJ18); + else + table.setValueAt(value, i, SJ18); + } else if(s.equals("ysr8_PurchPlanDateVal")) { +// table.setValueAt(value, i, 19); + if(value.length()>10) + table.setValueAt(value.substring(0, 10), i, SJ20); + else + table.setValueAt(value, i, SJ20); + } else if(s.equals("ysr8_PurchFinishDateVal")) { + if(value.length()>10) + table.setValueAt(value.substring(0, 10), i, SJ21); + else + table.setValueAt(value, i, SJ21); + } else if(s.equals("ysr8_ArrivingQuantityVal")) { + table.setValueAt(value, i, SJ22); + } else if(s.equals("ysr8_ArrivedQuantity")) { + table.setValueAt(value, i, SJ23); + } else if(s.equals("remark")) { + table.setValueAt(value, i, 24); + } else if(s.equals("ysr8_SubTaskManuState") || s.equals("ysr8_TaskManuState")) { + if(value.equals("1")) { + table.setValueAt("δ", i, SJ26); + } else if(value.equals("2")) { + table.setValueAt("ѵ", i, SJ26); + } else if(value.equals("3")) { + table.setValueAt("ѱ", i, SJ26); + } else if(value.equals("4")) { + table.setValueAt("Ѽ", i, SJ26); + } else if(value.equals("5")) { + table.setValueAt("", i, SJ26); + } + } else if(s.equals("ysr8_ExWarehouseState")) { + if(value.equals("1")) { + table.setValueAt("δ", i, SJ29); + } else if(value.equals("2")) { + table.setValueAt("ѳ", i, SJ29); + } + } + } + } + } + } + protected void updateValue(String ing, String ed, int idx) { +// MessageBox.post("updateValue:"+currTable+"="+val+"="+idx, "ʾ", MessageBox.INFORMATION); +// System.out.println("updateValue:"+currTable+"="+ing+"="+idx); + if(currTable==1) { + JTable table = (JTable) fu.allComponentMap.get("a.41.11.11"); + table.setValueAt(ing, idx, BJ16); + table.setValueAt(ed, idx, BJ17); + } else if(currTable==2) { + JTable table = (JTable) fu.allComponentMap.get("a.61.11.11"); + table.setValueAt(ing, idx, SJ22); + table.setValueAt(ed, idx, SJ23); + } + } + protected void updateExWarehouseValue(String person, String date, int idx, boolean remark) throws Exception { +// MessageBox.post("updateValue:"+currTable+"="+val+"="+idx, "ʾ", MessageBox.INFORMATION); +// System.out.println("updateValue:"+currTable+"="+ing+"="+idx); + JTable table = (JTable) fu.allComponentMap.get("a.61.11.11"); + if(remark) { + table.setValueAt(getTableVal(table, idx, SJ33) + person, idx, SJ33); + }else { + table.setValueAt("ѳ", idx, SJ29); + table.setValueAt(date, idx, SJ30); + table.setValueAt(getTableVal(table, idx, SJ23), idx, SJ31); + table.setValueAt(person, idx, SJ32); + } + } + private Date getDate(String s) throws ParseException { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + if(s==null || s.isEmpty()) + return null; + if(s.length()>10) + sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + return sdf.parse(s); + } + private String getTableVal(JTable table, int row, int col) { + Object o = table.getValueAt(row, col); + if(o == null) + return ""; + else + return o.toString(); + } + + private HashMap nameMap = new HashMap(); + public String getName(String str) { + if(nameMap.containsKey(str)) { + System.out.println("9999999999999999999999999999999999999"); + return nameMap.get(str); + } + TCComponent[] projects = null; + String stringOwner = ""; + try { + projects = session.search("ĿŲѯĿ", new String[] { "Ŀ ID" }, + new String[] { str }); + if(projects.length > 0) { + TCComponentProject TCComponentProject = (TCComponentProject)projects[0]; + stringOwner = TCComponentProject.getProperty("owning_user"); + System.out.println("stringOwner=============================="+stringOwner); + stringOwner = stringOwner.split(" \\(")[0]; + nameMap.put(str, stringOwner); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return stringOwner; + } +} diff --git a/src/cn/com/ebewin/ysr/dialog/MachiningDynamicsManageEditDialog.java b/src/cn/com/ebewin/ysr/dialog/MachiningDynamicsManageEditDialog.java new file mode 100644 index 0000000..fcdd1cb --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/MachiningDynamicsManageEditDialog.java @@ -0,0 +1,1343 @@ +package cn.com.ebewin.ysr.dialog; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.Map.Entry; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.om.OMNamespace; +import org.apache.axis2.addressing.EndpointReference; +import org.apache.axis2.client.Options; +import org.apache.axis2.client.ServiceClient; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.ServiceData; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +import com.teamcenter.rac.kernel.TCComponentTask; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.iTextField; +import com.teamcenter.services.rac.core.DataManagementService; +import cn.com.ebewin.ysr.dialog.MachiningDynamicsManageDialog.EditObjectInfo; +import cn.com.ebewin.ysr.util.CommonUtil; +import cn.com.ebewin.ysr.util.DialogUtil; +import cn.com.ebewin.ysr.util.KUtil; +import cn.com.ebewin.ysr.util.TCUtil; + +@SuppressWarnings("deprecation") +public class MachiningDynamicsManageEditDialog extends AbstractAIFDialog { + private static final long serialVersionUID = 1L; + private DialogUtil fu = new DialogUtil(this, "ӹ̬", "YSR8_MachiningDynamicsManageEditDialog"); + + private int currTable = 0; + private Boolean isMachiningManager = false; + private Boolean isAllLeading = true; + private EditObjectInfo editObjectInfo = null; + + private Boolean setArrivalState = false; + private boolean isSingleEdit = true; + private MachiningDynamicsManageDialog mdm; + double arrivedNum; + + public MachiningDynamicsManageEditDialog(MachiningDynamicsManageDialog mdm, int currTable, Boolean isMachiningManager, + EditObjectInfo editObjectInfo) throws Exception { + super(true); + + this.mdm = mdm; + this.currTable = currTable; + this.editObjectInfo = editObjectInfo; + this.isMachiningManager = isMachiningManager; + if (this.editObjectInfo.editObjects.size() > 1) { + this.isSingleEdit = false; + } + fu.initializeUI(mdm.fu.session); + centerToScreen(); + loadRendering(); + addActionListener(); + getDefVal(); + setVisible(true); + } + + @SuppressWarnings("unchecked") + private void loadRendering() throws Exception { + iTextField ysr8_ManuPerson = (iTextField) fu.allComponentMap.get("ysr8_ManuPerson"); + JComboBox ysr8_ManuFactory1 = (JComboBox) fu.allComponentMap.get("ysr8_ManuFactory1"); + JComboBox ysr8_ManuFactory2 = (JComboBox) fu.allComponentMap.get("ysr8_ManuFactory2"); + DateButton ysr8_PurchPlanDate = (DateButton) fu.allComponentMap.get("ysr8_PurchPlanDate"); + DateButton ysr8_DrawingReleaseDate = (DateButton) fu.allComponentMap.get("ysr8_DrawingReleaseDate"); + DateButton ysr8_PurchFinishDate = (DateButton) fu.allComponentMap.get("ysr8_PurchFinishDate"); + iTextField ysr8_ArrivingQuantity = (iTextField) fu.allComponentMap.get("ysr8_ArrivingQuantity"); + if(!isMachiningManager) + ysr8_PurchFinishDate.setDate(new Date()); + if (!isSingleEdit) { + ysr8_ArrivingQuantity.setEditable(false); + } + if (currTable == 1) { + System.out.println("޸" + editObjectInfo.editObjects.size()); + for (int i = 0; i < editObjectInfo.editObjects.size(); i++) { + if (editObjectInfo.editObjects.get(i) instanceof TCComponentScheduleTask) { + TCComponentScheduleTask scheduTask = (TCComponentScheduleTask) editObjectInfo.editObjects.get(i); + if (isSingleEdit) { + ysr8_ArrivingQuantity.setText(scheduTask.getStringProperty("ysr8_ArrivingQuantity")); + } + ysr8_ManuPerson.setText(scheduTask.getStringProperty("ysr8_ManuPerson")); + ysr8_ManuFactory1.setSelectedItem(scheduTask.getStringProperty("ysr8_ManuFactory1")); + ysr8_ManuFactory2.setSelectedItem(scheduTask.getStringProperty("ysr8_ManuFactory2")); + if (!scheduTask.getTCProperty("ysr8_PurchPlanDate").isPropValueNull()) { + ysr8_PurchPlanDate.setDate(scheduTask.getTCProperty("ysr8_PurchPlanDate").getDateValue()); + } + if (!scheduTask.getTCProperty("ysr8_DrawingReleaseDate").isPropValueNull()) { + ysr8_DrawingReleaseDate.setDate(scheduTask.getTCProperty("ysr8_DrawingReleaseDate").getDateValue()); + } +// if (!scheduTask.getTCProperty("ysr8_PurchFinishDate").isPropValueNull()) { +// ysr8_PurchFinishDate.setDate(scheduTask.getTCProperty("ysr8_PurchFinishDate").getDateValue()); +// } + } else if (editObjectInfo.editObjects.get(i) instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem) editObjectInfo.editObjects.get(i); + TCComponentItemRevision revision = item.getLatestItemRevision(); + TCComponentForm form = TCUtil.getItemRevisionMasterForm(revision); + + String object_typeVal = item.getProperty("object_type"); + if (object_typeVal.equals("ͼĿ¼")) { + if (isSingleEdit) { + ysr8_ArrivingQuantity.setText(form.getStringProperty("ysr8_ArrivingQuantity")); + } + ysr8_ManuPerson.setText(form.getStringProperty("ysr8_ManuPerson")); + ysr8_ManuFactory1.setSelectedItem(form.getStringProperty("ysr8_ManuFactory1")); + ysr8_ManuFactory2.setSelectedItem(form.getStringProperty("ysr8_ManuFactory2")); + if (!form.getTCProperty("ysr8_PurchPlanDate").isPropValueNull()) { + ysr8_PurchPlanDate.setDate(form.getTCProperty("ysr8_PurchPlanDate").getDateValue()); + } + if (!form.getTCProperty("ysr8_DrawingReleaseDate").isPropValueNull()) { + ysr8_DrawingReleaseDate.setDate(form.getTCProperty("ysr8_DrawingReleaseDate").getDateValue()); + } +// if (!form.getTCProperty("ysr8_PurchFinishDate").isPropValueNull()) { +// ysr8_PurchFinishDate.setDate(form.getTCProperty("ysr8_PurchFinishDate").getDateValue()); +// } + } + } + } + if(editObjectInfo.editObjects.size() > 1){ + for (int i = 0; i < editObjectInfo.editObjects.size(); i++) { + if (!editObjectInfo.isLeadings.get(i)) { + JLabel lable = (JLabel) fu.allComponentMap.get("l.61.11"); + lable.setText("вΪӹ˵ݣ޷趨ʱ..."); + ysr8_PurchFinishDate.setEnabled(false); +// fu.allComponentMap.get("b.51.14").setEnabled(false); + isAllLeading = false; + break; + } + } + } + } else if (currTable == 2) { + if (editObjectInfo.editObjects.size() == 1) { + if (editObjectInfo.editObjects.get(0) instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem) editObjectInfo.editObjects.get(0); + TCComponentItemRevision revision = item.getLatestItemRevision(); + TCComponentForm form = TCUtil.getItemRevisionMasterForm(revision); + + String object_typeVal = item.getProperty("object_type"); + if (object_typeVal.equals("ͼֽĵ")) { + if (isSingleEdit) { + TCProperty ysr8_ArrivingQuantityPro = form.getFormTCProperty("ysr8_ArrivingQuantity"); + String[] ysr8_ArrivingQuantityVal = ysr8_ArrivingQuantityPro.getStringArrayValue(); + if (ysr8_ArrivingQuantityVal != null && ysr8_ArrivingQuantityVal.length > editObjectInfo.editObjectListIdxs.get(0)) { + ysr8_ArrivingQuantity.setText(ysr8_ArrivingQuantityVal[editObjectInfo.editObjectListIdxs.get(0)]); + } + } + ysr8_ManuPerson.setText(form.getStringProperty("ysr8_ManuPerson")); + TCProperty ysr8_ManuFactory1Pro = form.getFormTCProperty("ysr8_SubManuFactory1"); + String[] ysr8_ManuFactory1Val = ysr8_ManuFactory1Pro.getStringArrayValue(); + if (ysr8_ManuFactory1Val != null && ysr8_ManuFactory1Val.length > editObjectInfo.editObjectListIdxs.get(0)) { + ysr8_ManuFactory1.setSelectedItem(ysr8_ManuFactory1Val[editObjectInfo.editObjectListIdxs.get(0)]); + } + TCProperty ysr8_ManuFactory2Pro = form.getFormTCProperty("ysr8_SubManuFactory2"); + String[] ysr8_ManuFactory2Val = ysr8_ManuFactory2Pro.getStringArrayValue(); + if (ysr8_ManuFactory2Val != null && ysr8_ManuFactory2Val.length > editObjectInfo.editObjectListIdxs.get(0)) { + ysr8_ManuFactory2.setSelectedItem(ysr8_ManuFactory2Val[editObjectInfo.editObjectListIdxs.get(0)]); + } + TCProperty ysr8_SubPurchPlanDatePro = form.getFormTCProperty("ysr8_SubPurchPlanDate"); + Date[] ysr8_SubPurchPlanDateVals = ysr8_SubPurchPlanDatePro.getDateValueArray(); + if (ysr8_SubPurchPlanDateVals != null && ysr8_SubPurchPlanDateVals.length > editObjectInfo.editObjectListIdxs.get(0) + && ysr8_SubPurchPlanDateVals[editObjectInfo.editObjectListIdxs.get(0)] != null) { + ysr8_PurchPlanDate.setDate(ysr8_SubPurchPlanDateVals[editObjectInfo.editObjectListIdxs.get(0)]); + } + TCProperty ysr8_DrawingReleaseDatePro = form.getFormTCProperty("ysr8_DrawingReleaseDate"); + Date[] ysr8_DrawingReleaseDateVals = ysr8_DrawingReleaseDatePro.getDateValueArray(); + if (ysr8_DrawingReleaseDateVals != null && ysr8_DrawingReleaseDateVals.length > editObjectInfo.editObjectListIdxs.get(0) + && ysr8_DrawingReleaseDateVals[editObjectInfo.editObjectListIdxs.get(0)] != null) { + ysr8_DrawingReleaseDate.setDate(ysr8_DrawingReleaseDateVals[editObjectInfo.editObjectListIdxs.get(0)]); + } +// TCProperty ysr8_SubPurchFinishDate = form.getFormTCProperty("ysr8_SubPurchFinishDate"); +// Date[] ysr8_SubPurchFinishDateVals = ysr8_SubPurchFinishDate.getDateValueArray(); +// if (ysr8_SubPurchFinishDateVals != null && ysr8_SubPurchFinishDateVals.length > editObjectInfo.editObjectListIdxs.get(0) +// && ysr8_SubPurchFinishDateVals[editObjectInfo.editObjectListIdxs.get(0)] != null) { +// ysr8_PurchFinishDate.setDate(ysr8_SubPurchFinishDateVals[editObjectInfo.editObjectListIdxs.get(0)]); +// } + } else if (object_typeVal.equals("ļӹ")) { + ysr8_ManuPerson.setText(form.getStringProperty("ysr8_ManuPerson")); + if (isSingleEdit) { + TCProperty ysr8_ArrivingQuantityPro = form.getFormTCProperty("ysr8_ArrivingQuantity"); + String[] ysr8_ArrivingQuantityVal = ysr8_ArrivingQuantityPro.getStringArrayValue(); + if (ysr8_ArrivingQuantityVal != null && ysr8_ArrivingQuantityVal.length > editObjectInfo.editObjectListIdxs.get(0)) { + ysr8_ArrivingQuantity.setText(ysr8_ArrivingQuantityVal[editObjectInfo.editObjectListIdxs.get(0)]); + } + } + TCProperty ysr8_ManuFactory1Pro = form.getFormTCProperty("ysr8_SubManuFactory1"); + String[] ysr8_ManuFactory1Val = ysr8_ManuFactory1Pro.getStringArrayValue(); + if (ysr8_ManuFactory1Val != null && ysr8_ManuFactory1Val.length > editObjectInfo.editObjectListIdxs.get(0)) { + ysr8_ManuFactory1.setSelectedItem(ysr8_ManuFactory1Val[editObjectInfo.editObjectListIdxs.get(0)]); + } + TCProperty ysr8_ManuFactory2Pro = form.getFormTCProperty("ysr8_SubManuFactory2"); + String[] ysr8_ManuFactory2Val = ysr8_ManuFactory2Pro.getStringArrayValue(); + if (ysr8_ManuFactory2Val != null && ysr8_ManuFactory2Val.length > editObjectInfo.editObjectListIdxs.get(0)) { + ysr8_ManuFactory2.setSelectedItem(ysr8_ManuFactory2Val[editObjectInfo.editObjectListIdxs.get(0)]); + } + TCProperty ysr8_SubPurchPlanDatePro = form.getFormTCProperty("ysr8_SubPurchPlanDate"); + Date[] ysr8_SubPurchPlanDateVals = ysr8_SubPurchPlanDatePro.getDateValueArray(); + if (ysr8_SubPurchPlanDateVals != null && ysr8_SubPurchPlanDateVals.length > editObjectInfo.editObjectListIdxs.get(0) + && ysr8_SubPurchPlanDateVals[editObjectInfo.editObjectListIdxs.get(0)] != null) { + ysr8_PurchPlanDate.setDate(ysr8_SubPurchPlanDateVals[editObjectInfo.editObjectListIdxs.get(0)]); + } + TCProperty ysr8_DrawingReleaseDatePro = form.getFormTCProperty("ysr8_DrawingReleaseDate"); + Date[] ysr8_DrawingReleaseDateVals = ysr8_DrawingReleaseDatePro.getDateValueArray(); + if (ysr8_DrawingReleaseDateVals != null && ysr8_DrawingReleaseDateVals.length > editObjectInfo.editObjectListIdxs.get(0) + && ysr8_DrawingReleaseDateVals[editObjectInfo.editObjectListIdxs.get(0)] != null) { + ysr8_DrawingReleaseDate.setDate(ysr8_DrawingReleaseDateVals[editObjectInfo.editObjectListIdxs.get(0)]); + } +// TCProperty ysr8_SubPurchFinishDate = form.getFormTCProperty("ysr8_SubPurchFinishDate"); +// Date[] ysr8_SubPurchFinishDateVals = ysr8_SubPurchFinishDate.getDateValueArray(); +// if (ysr8_SubPurchFinishDateVals != null && ysr8_SubPurchFinishDateVals.length > editObjectInfo.editObjectListIdxs.get(0) +// && ysr8_SubPurchFinishDateVals[editObjectInfo.editObjectListIdxs.get(0)] != null) { +// ysr8_PurchFinishDate.setDate(ysr8_SubPurchFinishDateVals[editObjectInfo.editObjectListIdxs.get(0)]); +// } + } else if (object_typeVal.equals("ɢ¼")) { + ysr8_ManuPerson.setText(form.getStringProperty("ysr8_ManuPerson")); + ysr8_ManuFactory1.setSelectedItem(form.getStringProperty("ysr8_ManuFactory1")); + ysr8_ManuFactory2.setSelectedItem(form.getStringProperty("ysr8_ManuFactory2")); + if (isSingleEdit) { + TCProperty ysr8_ArrivingQuantityPro = form.getFormTCProperty("ysr8_ArrivingQuantity"); + String[] ysr8_ArrivingQuantityVal = ysr8_ArrivingQuantityPro.getStringArrayValue(); + if (ysr8_ArrivingQuantityVal != null && ysr8_ArrivingQuantityVal.length > editObjectInfo.editObjectListIdxs.get(0)) { + ysr8_ArrivingQuantity.setText(ysr8_ArrivingQuantityVal[editObjectInfo.editObjectListIdxs.get(0)]); + } + } + TCProperty ysr8_PurchPlanDate1 = form.getFormTCProperty("ysr8_PurchPlanDate1"); + Date[] ysr8_PurchPlanDate1Vals = ysr8_PurchPlanDate1.getDateValueArray(); + if (ysr8_PurchPlanDate1Vals != null && ysr8_PurchPlanDate1Vals.length > editObjectInfo.editObjectListIdxs.get(0) + && ysr8_PurchPlanDate1Vals[editObjectInfo.editObjectListIdxs.get(0)] != null) { + ysr8_PurchPlanDate.setDate(ysr8_PurchPlanDate1Vals[editObjectInfo.editObjectListIdxs.get(0)]); + } + TCProperty ysr8_DrawingReleaseDatePro = form.getFormTCProperty("ysr8_DrawingReleaseDate"); + Date[] ysr8_DrawingReleaseDateVals = ysr8_DrawingReleaseDatePro.getDateValueArray(); + if (ysr8_DrawingReleaseDateVals != null && ysr8_DrawingReleaseDateVals.length > editObjectInfo.editObjectListIdxs.get(0) + && ysr8_DrawingReleaseDateVals[editObjectInfo.editObjectListIdxs.get(0)] != null) { + ysr8_DrawingReleaseDate.setDate(ysr8_DrawingReleaseDateVals[editObjectInfo.editObjectListIdxs.get(0)]); + } +// TCProperty ysr8_SubPurchFinishDate = form.getFormTCProperty("ysr8_SubPurchFinishDate"); +// Date[] ysr8_SubPurchFinishDateVals = ysr8_SubPurchFinishDate.getDateValueArray(); +// if (ysr8_SubPurchFinishDateVals != null && ysr8_SubPurchFinishDateVals.length > editObjectInfo.editObjectListIdxs.get(0) +// && ysr8_SubPurchFinishDateVals[editObjectInfo.editObjectListIdxs.get(0)] != null) { +// ysr8_PurchFinishDate.setDate(ysr8_SubPurchFinishDateVals[editObjectInfo.editObjectListIdxs.get(0)]); +// } + } + } + } else { + for (int i = 0; i < editObjectInfo.editObjects.size(); i++) { + if (!editObjectInfo.isLeadings.get(i)) { + JLabel lable = (JLabel) fu.allComponentMap.get("l.61.11"); + lable.setText("вΪӹ˵ݣ޷趨ʱ..."); + ysr8_PurchFinishDate.setEnabled(false); +// fu.allComponentMap.get("b.51.14").setEnabled(false); + isAllLeading = false; + break; + } + } + } + } + + if (!isMachiningManager) { + ysr8_ManuPerson.setEnabled(false); + fu.allComponentMap.get("ysr8_ManuPerson_Select").setEnabled(false); + ysr8_ManuFactory1.setEnabled(false); + ysr8_ManuFactory2.setEnabled(false); + ysr8_PurchPlanDate.setEnabled(false); + ysr8_DrawingReleaseDate.setEnabled(false); +// fu.allComponentMap.get("b.51.12").setEnabled(false); + }else { + ysr8_PurchFinishDate.setEnabled(false); + ysr8_ArrivingQuantity.setEnabled(false); + } + } + + private void addActionListener() { + JButton btn1 = (JButton) fu.allComponentMap.get("b.51.12"); +// JButton btn2 = (JButton) fu.allComponentMap.get("b.51.14"); + JButton btn3 = (JButton) fu.allComponentMap.get("b.51.16"); + btn1.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + saveRendering(); + } + }); + +// btn2.addActionListener(new ActionListener() { +// public void actionPerformed(ActionEvent e) { +// setArrivalState = false; +// saveRendering(); +// } +// }); + + btn3.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + dialogResultId = ID_CANCEL; + disposeDialog(); + } + }); + } + + @SuppressWarnings("unchecked") + private void saveRendering() { + try { + if (!checkCanSave()) { + return; + } + } catch (Exception e1) { + e1.printStackTrace(); + MessageBox.post(this, "ʱ\n" + e1.getMessage(), "", MessageBox.WARNING); + return; + } + JButton btn1 = (JButton) fu.allComponentMap.get("b.51.12"); +// JButton btn2 = (JButton) fu.allComponentMap.get("b.51.14"); + JButton btn3 = (JButton) fu.allComponentMap.get("b.51.16"); + btn1.setText("ڱ"); +// btn2.setText("ڱ"); + btn1.setEnabled(false); +// btn2.setEnabled(false); + btn3.setEnabled(false); + System.out.println("Save"); + iTextField ysr8_ManuPerson = (iTextField) fu.allComponentMap.get("ysr8_ManuPerson"); + JComboBox ysr8_ManuFactory1 = (JComboBox) fu.allComponentMap.get("ysr8_ManuFactory1"); + JComboBox ysr8_ManuFactory2 = (JComboBox) fu.allComponentMap.get("ysr8_ManuFactory2"); + DateButton ysr8_PurchPlanDate = (DateButton) fu.allComponentMap.get("ysr8_PurchPlanDate"); + DateButton ysr8_DrawingReleaseDate = (DateButton) fu.allComponentMap.get("ysr8_DrawingReleaseDate"); + DateButton ysr8_PurchFinishDate = (DateButton) fu.allComponentMap.get("ysr8_PurchFinishDate"); + iTextField ysr8_ArrivingQuantity = (iTextField) fu.allComponentMap.get("ysr8_ArrivingQuantity"); + + String ysr8_ManuPersonVal = "", ysr8_ManuFactory1Val = "", ysr8_ManuFactory2Val = "", ysr8_PurchPlanDateVal = ""; + String ysr8_DrawingReleaseDateVal = "", ysr8_PurchFinishDateVal = ""; + String ysr8_ArrivingQuantityVal = ""; + HashMap tableMap = new HashMap(); + ysr8_ManuPersonVal = ysr8_ManuPerson.getText().toString(); + ysr8_ArrivingQuantityVal = ysr8_ArrivingQuantity.getText().toString(); + if (ysr8_ManuFactory1.getSelectedItem() != null) { + ysr8_ManuFactory1Val = ysr8_ManuFactory1.getSelectedItem().toString(); + } + if (ysr8_ManuFactory2.getSelectedItem() != null) { + ysr8_ManuFactory2Val = ysr8_ManuFactory2.getSelectedItem().toString(); + } + ysr8_PurchPlanDateVal = fu.getDateTimeString2(ysr8_PurchPlanDate.getDate()); + ysr8_DrawingReleaseDateVal = fu.getDateTimeString2(ysr8_DrawingReleaseDate.getDate()); + ysr8_PurchFinishDateVal = fu.getDateTimeString2(ysr8_PurchFinishDate.getDate()); + if(isMachiningManager) { + tableMap.put("ysr8_ManuPersonVal", ysr8_ManuPersonVal); + tableMap.put("ysr8_ManuFactory1Val", ysr8_ManuFactory1Val); + tableMap.put("ysr8_ManuFactory2Val", ysr8_ManuFactory2Val); + } + if(ysr8_PurchPlanDateVal!=null && !ysr8_PurchPlanDateVal.isEmpty()) + tableMap.put("ysr8_PurchPlanDateVal", ysr8_PurchPlanDateVal); + if(ysr8_DrawingReleaseDateVal!=null && !ysr8_DrawingReleaseDateVal.isEmpty()) + tableMap.put("ysr8_DrawingReleaseDateVal", ysr8_DrawingReleaseDateVal); + tableMap.put("ysr8_PurchFinishDateVal", ysr8_PurchFinishDateVal==null?"":ysr8_PurchFinishDateVal); + if(isSingleEdit) + tableMap.put("ysr8_ArrivingQuantityVal", ysr8_ArrivingQuantityVal==null?"":ysr8_ArrivingQuantityVal); + + try { + HashMap valMap = new HashMap(); + if (currTable == 1) { + for (int i = 0; i < editObjectInfo.editObjects.size(); i++) { + if (editObjectInfo.editObjects.get(i) instanceof TCComponentScheduleTask) { + TCComponentScheduleTask scheduTask = (TCComponentScheduleTask) editObjectInfo.editObjects.get(i); + if (isMachiningManager) { + valMap.put("ysr8_ManuPerson", ysr8_ManuPersonVal); + valMap.put("ysr8_ManuFactory1", ysr8_ManuFactory1Val); + valMap.put("ysr8_ManuFactory2", ysr8_ManuFactory2Val); + if (!ysr8_PurchPlanDateVal.equals("")) { + valMap.put("ysr8_PurchPlanDate", ysr8_PurchPlanDateVal); + } + if (!ysr8_DrawingReleaseDateVal.equals("")) { + valMap.put("ysr8_DrawingReleaseDate", ysr8_DrawingReleaseDateVal); + } + } + if (editObjectInfo.isLeadings.get(i)) { + if (!ysr8_PurchFinishDateVal.equals("")) { + valMap.put("ysr8_PurchFinishDate", ysr8_PurchFinishDateVal); + if (setArrivalState) { + valMap.put("ysr8_TaskManuState", "2"); + } + } + // kk + System.out.println(i+"=>"+editObjectInfo.rows.get(i)); + setTable1Nums(ysr8_ArrivingQuantityVal, scheduTask, valMap, editObjectInfo.rows.get(i)); + } + if (!isMachiningManager) { + System.out.println("ysr8_ArrivedQuantity1:"+valMap.get("ysr8_ArrivedQuantity")); + resetScheduleTaskByArrivedNum(scheduTask, valMap.get("ysr8_ArrivedQuantity"), tableMap);//lidy20181220 + } + + CommonUtil.setByPass(true); + for (Entry entry : valMap.entrySet()) { + String key1 = entry.getKey(); + String key2 = entry.getValue(); + TCProperty property = (TCProperty) scheduTask.getTCProperty(key1); + switch (property.getPropertyType()) { + case TCProperty.PROP_string: + case TCProperty.PROP_long_string: + scheduTask.setStringProperty(key1, key2); + break; + case TCProperty.PROP_short: + case TCProperty.PROP_int: + scheduTask.setIntProperty(key1, Integer.parseInt(key2)); + break; + case TCProperty.PROP_double: + case TCProperty.PROP_float: + scheduTask.setDoubleProperty(key1, Double.parseDouble(key2)); + break; + case TCProperty.PROP_date: + if (!key2.equals("")) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss"); + Date date = sdf.parse(key2); + if (date != null) { + scheduTask.setDateProperty(key1, date); + } + } + break; + default: + scheduTask.setStringProperty(key1, key2); + break; + } + } + CommonUtil.setByPass(false); + + // kk +// resetScheduleTaskByArrivedNum(scheduTask); + + } else if (editObjectInfo.editObjects.get(i) instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem) editObjectInfo.editObjects.get(i); + TCComponentItemRevision revision = item.getLatestItemRevision(); + TCComponentForm form = TCUtil.getItemRevisionMasterForm(revision); + + String object_typeVal = item.getProperty("object_type"); + if (object_typeVal.equals("ͼĿ¼")) { + if (isMachiningManager) { + valMap.put("ysr8_ManuPerson", ysr8_ManuPersonVal); + valMap.put("ysr8_ManuFactory1", ysr8_ManuFactory1Val); + valMap.put("ysr8_ManuFactory2", ysr8_ManuFactory2Val); + valMap.put("ysr8_PurchPlanDate", ysr8_PurchPlanDateVal); + if (!ysr8_DrawingReleaseDateVal.equals("")) { + valMap.put("ysr8_DrawingReleaseDate", ysr8_DrawingReleaseDateVal); + } + } + if (editObjectInfo.isLeadings.get(i)) { + if (!ysr8_PurchFinishDateVal.equals("")) { + valMap.put("ysr8_PurchFinishDate", ysr8_PurchFinishDateVal); + if (setArrivalState) { + valMap.put("ysr8_TaskManuState", "2"); + } + } + // kk + setTable1Nums(ysr8_ArrivingQuantityVal, form, valMap, editObjectInfo.rows.get(i)); + } + if (!isMachiningManager) { + String ysr8_SubTaskManuState = resetDrawingListByArrivedNum(form, valMap.get("ysr8_ArrivedQuantity")); + if(!ysr8_SubTaskManuState.isEmpty()) + valMap.put("ysr8_TaskManuState", ysr8_SubTaskManuState); + } + } + + String params = "", proName = "", proVal = "###"; + if (object_typeVal.equals("ͼĿ¼")) { + for (Entry entry : valMap.entrySet()) { + String key1 = entry.getKey(); + if (proName.equals("")) { + proName = key1; + } else { + proName += "@@@@" + key1; + } + String key2 = entry.getValue(); + if (key1.equals("ysr8_SubManuFactory1") || key1.equals("ysr8_SubManuFactory2") + || key1.equals("ysr8_SubPurchPlanDate") || key1.equals("ysr8_DrawingReleaseDate") + || key1.equals("ysr8_SubPurchFinishDate") || key1.equals("ysr8_SubTaskManuState")) { + key2 = Integer.toString(editObjectInfo.editObjectListIdxs.get(i)) + "$$$$" + key2; + } + if (proVal.equals("###")) { + proVal = key2; + } else { + proVal += "@@@@" + key2; + } + } + } + params = item.getProperty("item_id") + "^^^^" + proName + "^^^^" + proVal; + + TCUserService userService = fu.session.getUserService(); + Object[] objParams = new Object[2]; + String cmd = "Update_ItemRevForm_TCProperty"; + objParams[0] = cmd; + objParams[1] = params; + long startime = System.currentTimeMillis(); + String result = (String) userService.call("YSR8UserService", objParams); + long endtime = System.currentTimeMillis(); + System.out.println("Cʱ" + (endtime - startime) + ""); + System.out.println(result); + form.refresh(); + } + } + + } else if (currTable == 2) { + for (int i = 0; i < editObjectInfo.editObjects.size(); i++) { + Object editObject = editObjectInfo.editObjects.get(i); + if (editObject instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem) editObject; + TCComponentItemRevision revision = item.getLatestItemRevision(); + TCComponentForm form = TCUtil.getItemRevisionMasterForm(revision); + + String object_typeVal = item.getProperty("object_type"); + if (object_typeVal.equals("ͼֽĵ")) { + if (isMachiningManager) { + valMap.put("ysr8_ManuPerson", ysr8_ManuPersonVal); + valMap.put("ysr8_SubManuFactory1", ysr8_ManuFactory1Val); + valMap.put("ysr8_SubManuFactory2", ysr8_ManuFactory2Val); + if (!ysr8_PurchPlanDateVal.equals("")) { + valMap.put("ysr8_SubPurchPlanDate", ysr8_PurchPlanDateVal); + } + if (!ysr8_DrawingReleaseDateVal.equals("")) { + valMap.put("ysr8_DrawingReleaseDate", ysr8_DrawingReleaseDateVal); + } + } + if (isAllLeading) { + if (!ysr8_PurchFinishDateVal.equals("")) {//TODO + valMap.put("ysr8_SubPurchFinishDate", ysr8_PurchFinishDateVal); + valMap.put("ysr8_ExWarehouseState", "1"); + if (setArrivalState) { + valMap.put("ysr8_SubTaskManuState", "2"); + } + } + // kk + setTable2Nums(ysr8_ArrivingQuantityVal, form, i, valMap, editObjectInfo.rows.get(i)); + } + } else if (object_typeVal.equals("ļӹ")) { + if (isMachiningManager) { + valMap.put("ysr8_ManuPerson", ysr8_ManuPersonVal); + valMap.put("ysr8_SubManuFactory1", ysr8_ManuFactory1Val); + valMap.put("ysr8_SubManuFactory2", ysr8_ManuFactory2Val); + if (!ysr8_PurchPlanDateVal.equals("")) { + valMap.put("ysr8_SubPurchPlanDate", ysr8_PurchPlanDateVal); + } + if (!ysr8_DrawingReleaseDateVal.equals("")) { + valMap.put("ysr8_DrawingReleaseDate", ysr8_DrawingReleaseDateVal); + } + } + if (isAllLeading) { + if (!ysr8_PurchFinishDateVal.equals("")) { + valMap.put("ysr8_SubPurchFinishDate", ysr8_PurchFinishDateVal); + valMap.put("ysr8_ExWarehouseState", "1"); + if (setArrivalState) { + valMap.put("ysr8_SubTaskManuState", "2"); + } + } + // kk + setTable2Nums(ysr8_ArrivingQuantityVal, form, i, valMap, editObjectInfo.rows.get(i)); + } + } else if (object_typeVal.equals("ɢ¼")) { + if (isMachiningManager) { + valMap.put("ysr8_ManuPerson", ysr8_ManuPersonVal); + valMap.put("ysr8_ManuFactory1", ysr8_ManuFactory1Val); + valMap.put("ysr8_ManuFactory2", ysr8_ManuFactory2Val); + if (!ysr8_PurchPlanDateVal.equals("")) { + valMap.put("ysr8_PurchPlanDate1", ysr8_PurchPlanDateVal); + } + if (!ysr8_DrawingReleaseDateVal.equals("")) { + valMap.put("ysr8_DrawingReleaseDate", ysr8_DrawingReleaseDateVal); + } + } + if (isAllLeading) { + if (!ysr8_PurchFinishDateVal.equals("")) { + valMap.put("ysr8_SubPurchFinishDate", ysr8_PurchFinishDateVal); + valMap.put("ysr8_ExWarehouseState", "1"); + if (setArrivalState) { + valMap.put("ysr8_SubTaskManuState", "2"); + } + } + // kk + setTable2Nums(ysr8_ArrivingQuantityVal, form, i, valMap, editObjectInfo.rows.get(i)); + } + } + + String params = "", proName = "", proVal = "###"; + if (object_typeVal.equals("ͼֽĵ")) { + for (Entry entry : valMap.entrySet()) { + String key1 = entry.getKey(); + if (proName.equals("")) { + proName = key1; + } else { + proName += "@@@@" + key1; + } + String key2 = entry.getValue(); + if (key1.equals("ysr8_SubManuFactory1") || key1.equals("ysr8_SubManuFactory2") + || key1.equals("ysr8_SubPurchPlanDate") || key1.equals("ysr8_DrawingReleaseDate") + || key1.equals("ysr8_SubPurchFinishDate") || key1.equals("ysr8_SubTaskManuState") + || key1.equals("ysr8_ArrivedQuantity") || key1.equals("ysr8_ArrivingQuantity") + || key1.equals("ysr8_ExWarehouseState")) { + key2 = Integer.toString(editObjectInfo.editObjectListIdxs.get(i)) + "$$$$" + key2; + } + if (proVal.equals("###")) { + proVal = key2; + } else { + proVal += "@@@@" + key2; + } + } + } else if (object_typeVal.equals("ļӹ")) { + for (Entry entry : valMap.entrySet()) { + String key1 = entry.getKey(); + if (proName.equals("")) { + proName = key1; + } else { + proName += "@@@@" + key1; + } + String key2 = entry.getValue(); + if (key1.equals("ysr8_SubManuFactory1") || key1.equals("ysr8_SubManuFactory2") + || key1.equals("ysr8_SubPurchPlanDate") || key1.equals("ysr8_DrawingReleaseDate") + || key1.equals("ysr8_SubPurchFinishDate") || key1.equals("ysr8_SubTaskManuState") + || key1.equals("ysr8_ArrivedQuantity") || key1.equals("ysr8_ArrivingQuantity") + || key1.equals("ysr8_ExWarehouseState")) { + key2 = Integer.toString(editObjectInfo.editObjectListIdxs.get(i)) + "$$$$" + key2; + } + if (proVal.equals("###")) { + proVal = key2; + } else { + proVal += "@@@@" + key2; + } + } + } else if (object_typeVal.equals("ɢ¼")) { + for (Entry entry : valMap.entrySet()) { + String key1 = entry.getKey(); + if (proName.equals("")) { + proName = key1; + } else { + proName += "@@@@" + key1; + } + String key2 = entry.getValue(); + if (key1.equals("ysr8_PurchPlanDate1") || key1.equals("ysr8_DrawingReleaseDate") + || key1.equals("ysr8_SubPurchFinishDate") || key1.equals("ysr8_SubTaskManuState") + || key1.equals("ysr8_ArrivedQuantity") || key1.equals("ysr8_ArrivingQuantity") + || key1.equals("ysr8_ExWarehouseState")) { + key2 = Integer.toString(editObjectInfo.editObjectListIdxs.get(i)) + "$$$$" + key2; + } + if (proVal.equals("###")) { + proVal = key2; + } else { + proVal += "@@@@" + key2; + } + } + } + KUtil.setNewArrayProperty(form);//TODO setNewArrayProperty18-SR0004-TZZG0010 + + params = item.getProperty("item_id") + "^^^^" + proName + "^^^^" + proVal; + + TCUserService userService = fu.session.getUserService(); + Object[] objParams = new Object[2]; + String cmd = "Update_ItemRevForm_TCProperty"; + objParams[0] = cmd; + objParams[1] = params; + System.out.println(params); + long startime = System.currentTimeMillis(); + String result = (String) userService.call("YSR8UserService", objParams); + long endtime = System.currentTimeMillis(); + System.out.println(item.getProperty("item_id") + " " + editObjectInfo.editObjectMaterialID.get(i) + + " Cʱ" + (endtime - startime) + " " + result); + Thread.sleep(1000); + form.refresh(); + //lidy20181222 + TCProperty ysr8_SubPurchFinishDate = form.getFormTCProperty("ysr8_SubPurchFinishDate"); + Date[] ysr8_SubPurchFinishDateVals = ysr8_SubPurchFinishDate.getDateValueArray(); + TCProperty ysr8_SubChangeScheme; + String[] ysr8_SubChangeSchemeVals = null; + if (object_typeVal.equals("ͼֽĵ")) { + ysr8_SubChangeScheme = form.getFormTCProperty("ysr8_SubChangeScheme"); + ysr8_SubChangeSchemeVals = ysr8_SubChangeScheme.getStringArrayValue(); + } + Boolean finish = true; + for(int j=0; j tableMap)throws Exception{ + String taskType = task.getPropertyDisplayableValue("ysr8_TaskUse"); + if (!"ӹ".equals(taskType)) { + System.out.println("ʱͣ" + taskType + "Ǽӹ"); + return; + } + System.out.println("ͬ\nѵӹ..."); + // ȡ + String arrivedStr = task.getProperty("ysr8_ArrivedQuantity"); + String totalStr = task.getProperty("ysr8_PartNumber"); + double arrivedNum = 0; + double arrivedNumVal = 0; + double totalNum = 0; + System.out.println("ysr8_ArrivedQuantity2:"+arrivedVal); + if (arrivedStr != null && !"".equals(arrivedStr)) { + try { + arrivedNum = Double.parseDouble(arrivedStr); + } catch (NumberFormatException e) { + e.printStackTrace(); + throw new Exception("ѵ" + arrivedStr); + } + } + try { + arrivedNumVal = Double.parseDouble(arrivedVal); + } catch (NumberFormatException e) { + e.printStackTrace(); + throw new Exception("ѵ" + arrivedVal); + } +// else { +// return; +// } + if (totalStr != null && !"".equals(totalStr)) { + try { + totalNum = Double.parseDouble(totalStr); + } catch (NumberFormatException e) { + e.printStackTrace(); + throw new Exception("" + totalStr); + } + } else { + return; + } + System.out.println("ӹѵ" + arrivedNum); + System.out.println("ӹ" + totalNum); + System.out.println("ӹ޸ĺѵ" + arrivedNumVal); + // lidy20181220ѯʱ + TCComponentQueryType queryType = (TCComponentQueryType) fu.session.getTypeComponent("ImanQuery"); + TCComponent taskQuery = queryType.find("SearchSchedulTask-SZBPX"); + if (taskQuery == null) { + throw new Exception("ûҵѯSearchSchedulTask-SZBPX"); + } + String taskName = task.getStringProperty("object_name"); + String projId = task.getStringProperty("ysr8_ProjectCode"); + System.out.println("ƣ" + taskName); + System.out.println("Ŀ ID" + projId); + String[] keys = new String[] { "", "Ŀ ID", ";" }; + String[] vals = new String[] { taskName, projId, "6;11" }; + AIFComponentContext[] searchRes = ((TCComponentQuery) taskQuery).getExecuteResults(keys, vals); + System.out.println("ѯʱ" + searchRes.length); + Date actual_finish_date = null; + TCComponent[] owners = task.getAssignedUsers(); + String user = mdm.session.getUser().getUserId(); + Boolean isOwner = false; + for(TCComponent u : owners) { + if(u instanceof TCComponentUser) { + String owner = ((TCComponentUser)u).getUserId(); + if(user.equals(owner)) { + isOwner = true; + break; + } + } + } + if (arrivedNum == 0) { + // ʱ + CommonUtil.setByPass(true); + try { + completeTask(task); + actual_finish_date = task.getDateProperty("actual_finish_date"); + if(isOwner) { + task.setDateProperty("actual_finish_date", null); + }else + updateScheduleTask(task, "0001-1-1 00:00"); +// for (AIFComponentContext c : searchRes) { +// TCComponentScheduleTask t = (TCComponentScheduleTask) c.getComponent(); +// // startWorkflow(t); +// WorkflowLaunchOperation wl = new WorkflowLaunchOperation(t); +// wl.executeOperation(); +// } + } catch (Exception e) { + MessageBox.post(this, "ʱ" + "\n" + e.getMessage(), "ʾ", MessageBox.ERROR); + e.printStackTrace(); + } + CommonUtil.setByPass(false); + } + if (arrivedNumVal>0 && arrivedNumVal < totalNum) { + System.out.println("״̬Ϊ"); + CommonUtil.setByPass(true); + task.setStringProperty("ysr8_TaskManuState", "5"); + tableMap.put("ysr8_TaskManuState", "5"); + for (AIFComponentContext c : searchRes) { + TCComponentScheduleTask t = (TCComponentScheduleTask) c.getComponent(); +// System.out.println(t+" ;"+t.getProperty("ysr8_TaskUse")); + if(t.getProperty("ysr8_TaskUse").equals("")) + t.setStringProperty("ysr8_TaskManuState", "5"); + } + CommonUtil.setByPass(false); + } else if (arrivedNumVal>0 && arrivedNumVal == totalNum) { + System.out.println("״̬Ϊѱ"); + CommonUtil.setByPass(true); + task.setStringProperty("ysr8_TaskManuState", "3"); + tableMap.put("ysr8_TaskManuState", "3"); + for (AIFComponentContext c : searchRes) { + TCComponentScheduleTask t = (TCComponentScheduleTask) c.getComponent(); +// System.out.println(t+" ;"+t.getProperty("ysr8_TaskUse")); + if(t.getProperty("ysr8_TaskUse").equals("")) + t.setStringProperty("ysr8_TaskManuState", "2"); + } +// task.setDateProperty("actual_finish_date", actual_finish_date); + try { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-d HH:mm"); + if(actual_finish_date!=null) { + long time = actual_finish_date.getTime(); + if(isOwner) { + task.setDateProperty("actual_finish_date", actual_finish_date); + }else + updateScheduleTask(task, sdf.format(new Date(time - 8*60*60*1000))); + }else { + DateButton ysr8_PurchFinishDate = (DateButton) fu.allComponentMap.get("ysr8_PurchFinishDate"); + if(ysr8_PurchFinishDate.getDate()!=null) { + long time = ysr8_PurchFinishDate.getDate().getTime(); + if(isOwner) { + task.setDateProperty("actual_finish_date", ysr8_PurchFinishDate.getDate()); + }else + updateScheduleTask(task, sdf.format(new Date(time - 8*60*60*1000))); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + CommonUtil.setByPass(false); +// try { +// completeTask(task); +// } catch (Exception e) { +// MessageBox.post(this, "ʱ" + task + "\n" + e.getMessage(), "ʾ", MessageBox.ERROR); +// e.printStackTrace(); +// } + } + } + + private String resetDrawingListByArrivedNum(TCComponentForm task, String arrivedVal) throws Exception { + System.out.println("ͬ\nѵӹ..."); + // ȡ + String arrivedStr = task.getProperty("ysr8_ArrivedQuantity"); + String totalStr = task.getProperty("ysr8_AddOrReplaceQuantity"); + double arrivedNum = 0; + double arrivedNumVal = 0; + double totalNum = 0; + if (arrivedStr != null && !"".equals(arrivedStr)) { + try { + arrivedNum = Double.parseDouble(arrivedStr); + } catch (NumberFormatException e) { + e.printStackTrace(); + throw new Exception("ѵ" + arrivedStr); + } + } + try { + arrivedNumVal = Double.parseDouble(arrivedVal); + } catch (NumberFormatException e) { + e.printStackTrace(); + throw new Exception("ѵ" + arrivedVal); + } +// else { +// return; +// } + if (totalStr != null && !"".equals(totalStr)) { + try { + totalNum = Double.parseDouble(totalStr); + } catch (NumberFormatException e) { + e.printStackTrace(); + throw new Exception("" + totalStr); + } + } else { + return ""; + } + System.out.println("ͼĿ¼ѵ" + arrivedNum); + System.out.println("ͼĿ¼ͼֽ" + totalNum); + System.out.println("ͼĿ¼޸ĺѵ" + arrivedNumVal); + + if (arrivedNumVal>0 && arrivedNumVal < totalNum) { + System.out.println("״̬Ϊ"); + return "5"; + } else if (arrivedNumVal>0 && arrivedNumVal == totalNum) { + System.out.println("״̬Ϊѱ"); + return "3"; + } + return ""; + } + + 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()); + } + } + +// private static final String EPM_promote_action = "SOA_EPM_promote_action"; + + // kk + private void completeTask(TCComponentScheduleTask scheduTask) throws Exception { + scheduTask.setStringProperty("ysr8_TaskManuState", "3"); + TCComponent[] tasks = scheduTask.getRelatedComponents("fnd0ActuatedInteractiveTsks"); + if (tasks != null && tasks.length > 0) { + TCComponent task1 = null; + TCComponent task2 = null; + for (int i = 0; i < tasks.length; i++) { + TCComponent task = tasks[i]; + String object_type = task.getProperty("object_type"); + System.out.println("object_type object_name1======" + task.getUid() + "======" + task.getProperty("object_type") + "======" + + task.getProperty("object_name")); + if (object_type.equals("Signoff")) { + task1 = task; + } else if (object_type.equals("Ͽɡ")) { + task2 = task; + } + } + if (task1 != null && task2 != null) { + TCComponent[] childTasks = task2.getRelatedComponents("child_tasks"); + if (childTasks != null && childTasks.length > 0) { + for (int j = 0; j < childTasks.length; j++) { + TCComponent childTask = childTasks[j]; + String childObject_type = childTask.getProperty("object_type"); + System.out.println("object_type object_type2======"+ childTask.getUid() +"======"+ childTask.getProperty("object_type") + + "======" + childTask.getProperty("object_name")); + if (childObject_type.equals("ִǩ")) { + // kk ֱӽ״̬Ϊ ѱ + TCComponentTask targetTask = (TCComponentTask) childTask; + String taskState = targetTask.getProperty("fnd0state"); + System.out.println("״̬: " + taskState); + if (!taskState.equals("")) { + System.out.println("Զ"); + TCComponentUser curUser = fu.session.getUser(); + TCComponent userBox =curUser.getReferenceProperty("userinbox"); + TCComponent taskBox = curUser.getReferenceProperty("taskinbox"); + System.out.println(taskBox); + DataManagementService service=DataManagementService.getService(fu.session); + service.refreshObjects(new TCComponent[] {taskBox,userBox}); + taskBox.refresh(); + userBox.refresh(); + System.out.println(childTask); + +// targetTask.performTaskAction(106, "Զ", "", "Ͽ", task1, null, null); + targetTask = (TCComponentTask) task2; + targetTask.performTaskAction(106, "Զ", "", "Ͽ", task1, null, null); + + } else { + System.out.println("Զ"); + } + } + } + } + } + } + } + + /*private void startWorkflow(TCComponentScheduleTask task) throws Exception { + System.out.println("ʱ" + task + "|" + task.getPropertyDisplayableValue("ysr8_TaskUse")); + String template = task.getProperty("workflow_template"); + if (template == null || "".equals(template)) { + throw new Exception("ʱ" + task + "ûù"); + } + TCComponent process = TaskHelper.getWorkflowProcess(task); + if (process != null) { + // 20181219 ʾ + System.out.println("ʱ" + task + "Ĺѱ"); + return; + // throw new Exception("ʱ" + task + "Ĺѱ"); + } + TaskHelper.isMsIntegLink(task); + if (TaskHelper.isMsIntegLink(task)) { + String arg16 = TaskHelper.getMsIntegLinkSite(task); + if (arg16 != null) { + String arg11 = "վ {0} ϴҪԣ¼վ {0} ԡ"; + arg11 = MessageFormat.format(arg11, new Object[] { arg16 }); + throw new Exception(arg11); + } else { + System.out.println("ʱ" + task + "Ĺѱ"); + return; + // throw new Exception("ʱ" + task + "Ĺѱ"); + } + } + UpdateContainer updateContainer = new UpdateContainer(); + updateContainer.setUpdatedObjectID(task.getUid()); + ArrayList arraylist = new ArrayList<>(); + arraylist.add(new StringValuePair("workflow_launch", "true")); + updateContainer.setExtendObjectKeyValuePairs(arraylist); + ArrayList arraylist1 = new ArrayList<>(); + arraylist1.add(updateContainer); + ModelFactory mf = ModelFactory.singleton(task.getSession()); + TaskModel taskmodel = mf.getTaskModel(); + taskmodel.updateTasks(arraylist1, null, null, TaskHelper.getMasterScheduleUid()); + System.out.println("ʱ"); + }*/ + + private void setTable1Nums(String ysr8_ArrivingQuantityVal, TCComponent form, HashMap valMap, int idx) throws Exception { + if (isSingleEdit) { + if (ysr8_ArrivingQuantityVal != null && !"".equals(ysr8_ArrivingQuantityVal)) { + String arrivedStr = ""; + arrivedStr = form.getProperty("ysr8_ArrivedQuantity"); + double arrivedNum = 0; + double arrivingNum = 0; + if (arrivedStr != null && !"".equals(arrivedStr)) { + try { + arrivedNum = Double.parseDouble(arrivedStr); + } catch (NumberFormatException e) { + e.printStackTrace(); + throw new Exception("ѵ" + arrivedStr); + } + } + try { + arrivingNum = Double.parseDouble(ysr8_ArrivingQuantityVal); + } catch (NumberFormatException e) { + e.printStackTrace(); + throw new Exception("ε" + ysr8_ArrivingQuantityVal); + } + valMap.put("ysr8_ArrivingQuantity", ysr8_ArrivingQuantityVal); + valMap.put("ysr8_ArrivedQuantity", new Double(arrivedNum + arrivingNum).intValue() + ""); +// mdm.updateValue(ysr8_ArrivingQuantityVal, new Double(arrivedNum + arrivingNum).intValue() + "", idx); + } + } else { + String ArrivedStr = form.getProperty("ysr8_ArrivedQuantity"); + String totalStr = ""; + if (form instanceof TCComponentForm) { + totalStr = form.getProperty("ysr8_AddOrReplaceQuantity"); + } else { + totalStr = form.getProperty("ysr8_PartNumber"); + } + double totalNum = 0; + double ArrivedNum = 0; + if (totalStr != null && !"".equals(totalStr)) { + try { + totalNum = Double.parseDouble(totalStr); + if(ArrivedStr != null && !"".equals(ArrivedStr)) + ArrivedNum = Double.parseDouble(ArrivedStr); + } catch (NumberFormatException e) { + e.printStackTrace(); + throw new Exception("" + totalStr); + } + valMap.put("ysr8_ArrivingQuantity", new Double(totalNum - ArrivedNum).intValue() + ""); + valMap.put("ysr8_ArrivedQuantity", new Double(totalNum).intValue() + ""); + mdm.updateValue(valMap.get("ysr8_ArrivingQuantity"), valMap.get("ysr8_ArrivedQuantity"), idx); + } + } + } + + private void setTable2Nums(String ysr8_ArrivingQuantityVal,TCComponentForm form,int i,HashMap valMap,int idx)throws Exception{ + String arrivedStr = ""; + TCProperty ysr8_ArrivedQuantity = form.getFormTCProperty("ysr8_ArrivedQuantity"); + String[] ysr8_ArrivedQuantityVals = ysr8_ArrivedQuantity.getStringArrayValue(); + if (ysr8_ArrivedQuantityVals != null && ysr8_ArrivedQuantityVals.length > editObjectInfo.editObjectListIdxs.get(i)) { + arrivedStr = ysr8_ArrivedQuantityVals[editObjectInfo.editObjectListIdxs.get(i)]; + } + double arrivedNum = 0; + double arrivingNum = 0; + if (arrivedStr != null && !"".equals(arrivedStr)) { + try { + arrivedNum = Double.parseDouble(arrivedStr); + } catch (NumberFormatException e) { + e.printStackTrace(); + throw new Exception("ѵ" + arrivedStr); + } + } + if (ysr8_ArrivingQuantityVal != null && !"".equals(ysr8_ArrivingQuantityVal)) { + try { + arrivingNum = Double.parseDouble(ysr8_ArrivingQuantityVal); + } catch (NumberFormatException e) { + e.printStackTrace(); + throw new Exception("ε" + ysr8_ArrivingQuantityVal); + } + } + String totalStr = ""; + TCProperty ysr8_Quantity = form.getFormTCProperty("ysr8_SubUnqualifiedQuantity"); + if (ysr8_Quantity == null) { + ysr8_Quantity = form.getFormTCProperty("ysr8_Quantity"); + double[] ysr8_QuantityVals = ysr8_Quantity.getDoubleArrayValue(); + if (ysr8_QuantityVals != null && ysr8_QuantityVals.length > editObjectInfo.editObjectListIdxs.get(i)) { + totalStr = ysr8_QuantityVals[editObjectInfo.editObjectListIdxs.get(i)] + ""; + } + } else { + String[] ysr8_QuantityVals = ysr8_Quantity.getStringArrayValue(); + if (ysr8_QuantityVals != null && ysr8_QuantityVals.length > editObjectInfo.editObjectListIdxs.get(i)) { + totalStr = ysr8_QuantityVals[editObjectInfo.editObjectListIdxs.get(i)]; + } + } + double totalNum = 0; + if (totalStr != null && !"".equals(totalStr)) { + try { + totalNum = Double.parseDouble(TCUtil.getNumber(totalStr)); + } catch (NumberFormatException e) { + e.printStackTrace(); + throw new Exception("" + totalStr); + } + } + + if (isSingleEdit) { + if (ysr8_ArrivingQuantityVal != null && !"".equals(ysr8_ArrivingQuantityVal)) { + valMap.put("ysr8_ArrivingQuantity", ysr8_ArrivingQuantityVal); +// mdm.updateValue(ysr8_ArrivingQuantityVal, new Double(arrivedNum + arrivingNum).intValue() + "", idx); + valMap.put("ysr8_ArrivedQuantity", new Double(arrivedNum + arrivingNum).intValue() + ""); + if (arrivedNum + arrivingNum < totalNum) { + System.out.println("״̬Ϊ"); + valMap.put("ysr8_SubTaskManuState", "5"); + } else if (arrivedNum + arrivingNum == totalNum) { + System.out.println("״̬Ϊѱ"); + valMap.put("ysr8_SubTaskManuState", "3"); + } + } + } else { + if (totalStr != null && !"".equals(totalStr)) { + valMap.put("ysr8_ArrivingQuantity", new Double(totalNum-arrivedNum).intValue() + ""); + mdm.updateValue(new Double(totalNum-arrivedNum).intValue() + "", new Double(totalNum).intValue() + "", idx); + valMap.put("ysr8_ArrivedQuantity", new Double(totalNum).intValue() + ""); + System.out.println("״̬Ϊѱ"); + valMap.put("ysr8_SubTaskManuState", "3"); + } + } + } + + private void getDefVal() { + fu.getDefVal(); + } + + public boolean checkCanSave() throws Exception { + if(isMachiningManager) { + System.out.println("MachiningManagerȡ"); + return true; + } + if (isSingleEdit) { + DateButton ysr8_PurchFinishDate = (DateButton) fu.allComponentMap.get("ysr8_PurchFinishDate"); + iTextField ysr8_ArrivingQuantity = (iTextField) fu.allComponentMap.get("ysr8_ArrivingQuantity"); + String fDate = fu.getDateString(ysr8_PurchFinishDate.getDate()); + String ANum = ysr8_ArrivingQuantity.getText(); + double aNumInt; + try { + aNumInt = Double.parseDouble(ANum); + if (aNumInt <= 0) { + MessageBox.post(this, "εд0", "ʾ", MessageBox.INFORMATION); + return false; + } + } catch (NumberFormatException e) { + MessageBox.post(this, "εд0", "ʾ", MessageBox.INFORMATION); + return false; + } + if (!"".equals(fDate) && "".equals(ANum)) { + MessageBox.post(this, "δдε", "ʾ", MessageBox.INFORMATION); + return false; + } + if (!"".equals(ANum) && "".equals(fDate)) { + MessageBox.post(this, "δдʵ", "ʾ", MessageBox.INFORMATION); + return false; + } + // + String arrivedStr = ""; + String totalStr = ""; + if (currTable == 1) {// + if (editObjectInfo.editObjects.get(0) instanceof TCComponentScheduleTask) { + TCComponentScheduleTask scheduTask = (TCComponentScheduleTask) editObjectInfo.editObjects.get(0); + arrivedStr = scheduTask.getProperty("ysr8_ArrivedQuantity"); + totalStr = scheduTask.getProperty("ysr8_PartNumber"); + } else if (editObjectInfo.editObjects.get(0) instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem) editObjectInfo.editObjects.get(0); + TCComponentItemRevision revision = item.getLatestItemRevision(); + TCComponentForm form = TCUtil.getItemRevisionMasterForm(revision); + arrivedStr = form.getProperty("ysr8_ArrivedQuantity"); + totalStr = form.getProperty("ysr8_AddOrReplaceQuantity"); + } + } else if (currTable == 2) {// ɢ + if (editObjectInfo.editObjects.get(0) instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem) editObjectInfo.editObjects.get(0); + TCComponentItemRevision revision = item.getLatestItemRevision(); + TCComponentForm form = TCUtil.getItemRevisionMasterForm(revision); + TCProperty ysr8_ArrivedQuantity = form.getFormTCProperty("ysr8_ArrivedQuantity"); + String[] ysr8_ArrivedQuantityVals = ysr8_ArrivedQuantity.getStringArrayValue(); + if (ysr8_ArrivedQuantityVals != null && ysr8_ArrivedQuantityVals.length > editObjectInfo.editObjectListIdxs.get(0)) { + arrivedStr = ysr8_ArrivedQuantityVals[editObjectInfo.editObjectListIdxs.get(0)]; + } + TCProperty ysr8_Quantity = form.getFormTCProperty("ysr8_SubUnqualifiedQuantity"); + if (ysr8_Quantity == null) { + // System.out.println("no ysr8_SubUnqualifiedQuantity"); + ysr8_Quantity = form.getFormTCProperty("ysr8_Quantity"); + double[] ysr8_QuantityVals = ysr8_Quantity.getDoubleArrayValue(); + if (ysr8_QuantityVals != null && ysr8_QuantityVals.length > editObjectInfo.editObjectListIdxs.get(0)) { + totalStr = ysr8_QuantityVals[editObjectInfo.editObjectListIdxs.get(0)] + ""; + } + } else { + + String[] ysr8_QuantityVals = ysr8_Quantity.getStringArrayValue(); + if (ysr8_QuantityVals != null && ysr8_QuantityVals.length > editObjectInfo.editObjectListIdxs.get(0)) { + totalStr = ysr8_QuantityVals[editObjectInfo.editObjectListIdxs.get(0)]; + } + } + } + } + arrivedNum = 0; + double totalNum = 0; + if (arrivedStr != null && !"".equals(arrivedStr)) { + try { + arrivedNum = Double.parseDouble(arrivedStr); + } catch (NumberFormatException e) { + e.printStackTrace(); + MessageBox.post(this, "ѵ" + arrivedStr, "ʾ", MessageBox.INFORMATION); + return false; + } + } + if (totalStr != null && !"".equals(totalStr)) { + try { + totalNum = Double.parseDouble(totalStr); + } catch (NumberFormatException e) { + e.printStackTrace(); + MessageBox.post(this, "" + arrivedStr, "ʾ", MessageBox.INFORMATION); + return false; + } + } + if (aNumInt + arrivedNum > totalNum) { + MessageBox.post(this, "δ㣺ε+ѵ<=", "ʾ", MessageBox.INFORMATION); + return false; + } + } + return true; + } + + + private String updateScheduleTask(TCComponentScheduleTask task,String timeStr) throws Exception { + String taskUid = task.getUid(); + System.out.println("ʱ"+taskUid+"ʵʱΪ"+timeStr); + ServiceClient sc = new ServiceClient(); + Options opts = new Options(); + String[] parameters = TCUtil.getPreference(mdm.session, TCPreferenceService.TC_preference_site, "YSR_webservices"); + if(parameters==null || parameters.length!=4) { + MessageBox.post(this, "ѡYSR_webservicesòȷϵϵͳԱ", "ʾ", MessageBox.INFORMATION); + throw new Exception("ѡYSR_webservicesòȷ"); + } + EndpointReference end = new EndpointReference(parameters[0]); + opts.setTo(end); + String methodName = "updateScheduleTaskActualFinishDate"; + opts.setAction("http://tempuri.org/" + methodName); + opts.setTimeOutInMilliSeconds(5000); + sc.setOptions(opts); + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", ""); // ռ + OMElement method = fac.createOMElement(methodName, omNs); // õķ + OMElement xmlStr = fac.createOMElement("userId", omNs); // xml ǰû + xmlStr.setText(mdm.session.getUser().getUserId()); + method.addChild(xmlStr); + OMElement xmlStr2 = fac.createOMElement("taskUid", omNs); // xml UID + xmlStr2.setText(taskUid); + method.addChild(xmlStr2); + OMElement xmlStr3 = fac.createOMElement("timeStr", omNs); // xml ʱ + xmlStr3.setText(timeStr); + method.addChild(xmlStr3); + OMElement xmlStr4 = fac.createOMElement("loginName", omNs); // xml û + xmlStr4.setText(parameters[1]); + method.addChild(xmlStr4); + OMElement xmlStr5 = fac.createOMElement("loginPassword", omNs); // xml û + xmlStr5.setText(parameters[2]); + method.addChild(xmlStr5); + OMElement xmlStr6 = fac.createOMElement("loginGroup", omNs); // xml û + xmlStr6.setText(parameters[3]); + method.addChild(xmlStr6); + OMElement res = sc.sendReceive(method); + if (res.getFirstElement() != null) { + String result = res.getFirstElement().getText(); + System.out.println("res:"+result); + if(!"true".equals(result.trim())) { + MessageBox.post(this, "ʱ"+task.getProperty("object_name")+"⣺"+result, "ʾ", MessageBox.INFORMATION); + } + return result; + } + return null; + } +} diff --git a/src/cn/com/ebewin/ysr/dialog/MachiningDynamicsRemarkDialog.java b/src/cn/com/ebewin/ysr/dialog/MachiningDynamicsRemarkDialog.java new file mode 100644 index 0000000..cbfe575 --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/MachiningDynamicsRemarkDialog.java @@ -0,0 +1,306 @@ +package cn.com.ebewin.ysr.dialog; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.HashMap; +import java.util.Map.Entry; + +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.util.MessageBox; + +import cn.com.ebewin.ysr.dialog.MachiningDynamicsManageDialog.EditObjectInfo; +import cn.com.ebewin.ysr.util.TCUtil; + +@SuppressWarnings("deprecation") +public class MachiningDynamicsRemarkDialog extends AbstractAIFDialog { + + private static final long serialVersionUID = 5789155622890673496L; + private JTextArea remarkArea; + private JButton okBtn; + private JButton celBtn; + private TCSession session; + private int currTable; + private EditObjectInfo editObjectInfo; + public boolean isChanged = false; + public String remark = ""; + private MachiningDynamicsManageDialog mdm; + + public MachiningDynamicsRemarkDialog(MachiningDynamicsManageDialog mdm, int currTable, EditObjectInfo editObjectInfo) { + super(true); + this.mdm = mdm; + this.session = mdm.fu.session; + this.currTable = currTable; + this.editObjectInfo = editObjectInfo; + } + + public void editRemark() throws Exception { + initUI(); + } + + private void initUI() throws Exception { + this.remark = getRemark(); + if(this.remark==null) { + this.remark=""; + } + this.setTitle("༭ע"); + this.setLayout(new BorderLayout()); + this.setPreferredSize(new Dimension(300, 250)); + JPanel mainPanel = new JPanel(new GridBagLayout()); + GridBagConstraints s = new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0); + mainPanel.add(new JLabel("ע"), s); + s.gridy++; + remarkArea = new JTextArea(); + remarkArea.setText(remark); + JScrollPane scroll = new JScrollPane(remarkArea); + s.weightx = 1; + s.weighty = 1; + s.insets = new Insets(0, 5, 0, 5); + mainPanel.add(scroll, s); + JPanel btnPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 15, 5)); + okBtn = new JButton("ȷ"); + celBtn = new JButton("ȡ"); + okBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent arg0) { + try { + saveRemark(); + } catch (Exception e) { + MessageBox.post(MachiningDynamicsRemarkDialog.this, e.toString(), "ʱ", MessageBox.ERROR); + e.printStackTrace(); + } + } + }); + celBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + btnPanel.add(okBtn); + btnPanel.add(celBtn); + this.add(BorderLayout.CENTER, mainPanel); + this.add(BorderLayout.SOUTH, btnPanel); + this.showDialog(); + } + + protected void saveRemark() throws Exception { + String remark = remarkArea.getText(); + HashMap valMap = new HashMap(); + if (currTable == 1) { + for(int i=0; i entry : valMap.entrySet()) { + String key1 = entry.getKey(); + if (proName.equals("")) { + proName = key1; + } else { + proName += "@@@@" + key1; + } + String key2 = entry.getValue(); + if (proVal.equals("")) { + proVal = key2; + } else { + proVal += "@@@@" + key2; + } + } + } + params = item.getProperty("item_id") + "^^^^" + proName + "^^^^" + proVal; + + TCUserService userService = this.session.getUserService(); + Object[] objParams = new Object[2]; + String cmd = "Update_ItemRevForm_TCProperty"; + objParams[0] = cmd; + objParams[1] = params; + long startime = System.currentTimeMillis(); + String result = (String) userService.call("YSR8UserService", objParams); + long endtime = System.currentTimeMillis(); + System.out.println("Cʱ" + (endtime - startime) + ""); + System.out.println(result); + form.refresh(); + } + } + + } else if (currTable == 2) { + for (int i = 0; i < editObjectInfo.editObjects.size(); i++) { + Object editObject = editObjectInfo.editObjects.get(i); + if (editObject instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem) editObject; + TCComponentItemRevision revision = item.getLatestItemRevision(); + TCComponentForm form = TCUtil.getItemRevisionMasterForm(revision); + + String object_typeVal = item.getProperty("object_type"); + if (object_typeVal.equals("ͼֽĵ")) { + valMap.put("ysr8_PurchRemark", remark); + } else if (object_typeVal.equals("ļӹ")) { + valMap.put("ysr8_PurchRemark", remark); + } else if (object_typeVal.equals("ɢ¼")) { + valMap.put("ysr8_PurchRemark", remark); + } + + String params = "", proName = "", proVal = ""; + if (object_typeVal.equals("ͼֽĵ")) { + for (Entry entry : valMap.entrySet()) { + String key1 = entry.getKey(); + if (proName.equals("")) { + proName = key1; + } else { + proName += "@@@@" + key1; + } + String key2 = entry.getValue(); + if (key1.equals("ysr8_SubManuFactory1") || key1.equals("ysr8_SubManuFactory2") || key1.equals("ysr8_SubPurchPlanDate") || key1.equals("ysr8_DrawingReleaseDate") + || key1.equals("ysr8_SubPurchFinishDate") || key1.equals("ysr8_SubTaskManuState")||key1.equals("ysr8_PurchRemark")) { + key2 = Integer.toString(editObjectInfo.editObjectListIdxs.get(i)) + "$$$$" + key2; + } + if (proVal.equals("")) { + proVal = key2; + } else { + proVal += "@@@@" + key2; + } + } + } else if (object_typeVal.equals("ļӹ")) { + for (Entry entry : valMap.entrySet()) { + String key1 = entry.getKey(); + if (proName.equals("")) { + proName = key1; + } else { + proName += "@@@@" + key1; + } + String key2 = entry.getValue(); + if (key1.equals("ysr8_SubManuFactory1") || key1.equals("ysr8_SubManuFactory2") || key1.equals("ysr8_SubPurchPlanDate") || key1.equals("ysr8_DrawingReleaseDate") + || key1.equals("ysr8_SubPurchFinishDate") || key1.equals("ysr8_SubTaskManuState")||key1.equals("ysr8_PurchRemark")) { + key2 = Integer.toString(editObjectInfo.editObjectListIdxs.get(i)) + "$$$$" + key2; + } + if (proVal.equals("")) { + proVal = key2; + } else { + proVal += "@@@@" + key2; + } + } + } else if (object_typeVal.equals("ɢ¼")) { + for (Entry entry : valMap.entrySet()) { + String key1 = entry.getKey(); + if (proName.equals("")) { + proName = key1; + } else { + proName += "@@@@" + key1; + } + String key2 = entry.getValue(); + if (key1.equals("ysr8_PurchPlanDate1") || key1.equals("ysr8_DrawingReleaseDate") || key1.equals("ysr8_SubPurchFinishDate") || key1.equals("ysr8_SubTaskManuState")||key1.equals("ysr8_PurchRemark")) { + key2 = Integer.toString(editObjectInfo.editObjectListIdxs.get(i)) + "$$$$" + key2; + } + if (proVal.equals("")) { + proVal = key2; + } else { + proVal += "@@@@" + key2; + } + } + } + params = item.getProperty("item_id") + "^^^^" + proName + "^^^^" + proVal; + + TCUserService userService = this.session.getUserService(); + Object[] objParams = new Object[2]; + String cmd = "Update_ItemRevForm_TCProperty"; + objParams[0] = cmd; + objParams[1] = params; + System.out.println(params); + long startime = System.currentTimeMillis(); + String result = (String) userService.call("YSR8UserService", objParams); + long endtime = System.currentTimeMillis(); + System.out.println(item.getProperty("item_id") + " " + editObjectInfo.editObjectMaterialID.get(i) + " Cʱ" + (endtime - startime) + " " + result); + Thread.sleep(1000); + form.refresh(); + } + } + } + System.out.println(this.remark+"|"+remark); + if (!this.remark.equals(remark)) { + this.isChanged = true; + } + HashMap tableMap = new HashMap(); + tableMap.put("remark", remark); + mdm.updateValues(tableMap); + disposeDialog(); + } + + private String getRemark() throws Exception { + if (editObjectInfo.editObjects.size() == 0) { + return "<û>"; + } + if (currTable == 1) { + if (editObjectInfo.editObjects.get(0) instanceof TCComponentScheduleTask) { + TCComponentScheduleTask scheduTask = (TCComponentScheduleTask) editObjectInfo.editObjects.get(0); + return scheduTask.getStringProperty("ysr8_PurchRemark"); + } else if (editObjectInfo.editObjects.get(0) instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem) editObjectInfo.editObjects.get(0); + TCComponentItemRevision revision = item.getLatestItemRevision(); + TCComponentForm form = TCUtil.getItemRevisionMasterForm(revision); + + String object_typeVal = item.getProperty("object_type"); + if (object_typeVal.equals("ͼĿ¼")) { + return form.getStringProperty("ysr8_PurchRemark"); + } + } + } else if (currTable == 2) { + if (editObjectInfo.editObjects.get(0) instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem) editObjectInfo.editObjects.get(0); + TCComponentItemRevision revision = item.getLatestItemRevision(); + TCComponentForm form = TCUtil.getItemRevisionMasterForm(revision); + String object_typeVal = item.getProperty("object_type"); + if (object_typeVal.equals("ͼֽĵ")) { + TCProperty ysr8_PurchRemarkProp = form.getFormTCProperty("ysr8_PurchRemark"); + String[] ysr8_PurchRemarkVal = ysr8_PurchRemarkProp.getStringArrayValue(); + if (ysr8_PurchRemarkVal != null && ysr8_PurchRemarkVal.length > editObjectInfo.editObjectListIdxs.get(0)) { + return ysr8_PurchRemarkVal[editObjectInfo.editObjectListIdxs.get(0)]; + } + } else if (object_typeVal.equals("ļӹ")) { + TCProperty ysr8_PurchRemarkProp = form.getFormTCProperty("ysr8_PurchRemark"); + String[] ysr8_PurchRemarkVal = ysr8_PurchRemarkProp.getStringArrayValue(); + if (ysr8_PurchRemarkVal != null && ysr8_PurchRemarkVal.length > editObjectInfo.editObjectListIdxs.get(0)) { + return ysr8_PurchRemarkVal[editObjectInfo.editObjectListIdxs.get(0)]; + } + } else if (object_typeVal.equals("ɢ¼")) { + TCProperty ysr8_PurchRemarkProp = form.getFormTCProperty("ysr8_PurchRemark"); + String[] ysr8_PurchRemarkVal = ysr8_PurchRemarkProp.getStringArrayValue(); + if (ysr8_PurchRemarkVal != null && ysr8_PurchRemarkVal.length > editObjectInfo.editObjectListIdxs.get(0)) { + return ysr8_PurchRemarkVal[editObjectInfo.editObjectListIdxs.get(0)]; + } + } + } + } + return "<û>"; + } + +} diff --git a/src/cn/com/ebewin/ysr/dialog/MachiningExWarehouseRemarkDialog.java b/src/cn/com/ebewin/ysr/dialog/MachiningExWarehouseRemarkDialog.java new file mode 100644 index 0000000..f1c15d2 --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/MachiningExWarehouseRemarkDialog.java @@ -0,0 +1,114 @@ +package cn.com.ebewin.ysr.dialog; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +import cn.com.ebewin.ysr.dialog.MachiningDynamicsManageDialog.EditObjectInfo; +import cn.com.ebewin.ysr.util.KUtil; +import cn.com.ebewin.ysr.util.TCUtil; + +@SuppressWarnings("deprecation") +public class MachiningExWarehouseRemarkDialog extends AbstractAIFDialog { + private static final long serialVersionUID = 1L; + private JButton okBtn; + private JButton cancelBtn; + private JTextArea remark; + + public MachiningExWarehouseRemarkDialog(MachiningDynamicsManageDialog mdm, EditObjectInfo editObjectInfo) throws Exception { + super(mdm); + setTitle("Ϣ"); + JPanel propPanel = new JPanel(new PropertyLayout(40, 20, 10, 5, 10, 5)); +// TCComponentListOfValues[] lov = lovType.find("ML8_ProjectCategory_LOV"); +// String[] vals = getDynamicLOV(lov[0]); +// System.out.println("ML8_ProjectCategory_LOV:"+lov[0].getType()+"=="+vals.length); + JLabel label2 = new JLabel("ⱸע"); + propPanel.add("1.1.left.center", label2); + remark = new JTextArea(); + remark.setText(""); + JScrollPane scroll = new JScrollPane(remark); + remark.setPreferredSize(new Dimension(240, 100)); + propPanel.add("1.2.left.center", scroll); + okBtn = new JButton("ȷ"); + cancelBtn = new JButton("ȡ"); + JPanel btnPanel = new JPanel(new FlowLayout()); + btnPanel.add(okBtn); + btnPanel.add(cancelBtn); + setLayout(new BorderLayout()); + add(BorderLayout.CENTER, propPanel); + add(BorderLayout.SOUTH, btnPanel); +// add(new JLabel("")); + addActionListener(mdm, editObjectInfo); + + pack(); + setSize(new Dimension(370, 200)); + setDefaultLookAndFeelDecorated(true); + Dimension screen = getToolkit().getScreenSize(); + setLocation((screen.width - getSize().width) / 2, (screen.height - getSize().height) / 2); +// setAlwaysOnTop(true); + setVisible(true); + } + + private void addActionListener(final MachiningDynamicsManageDialog mdm, final EditObjectInfo editObjectInfo) { + okBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent arg0) { + try { + String ysr8_ExWarehouseRemark = remark.getText(); + if(ysr8_ExWarehouseRemark.isEmpty()) + throw new Exception("δд"); + String keys = "ysr8_ExWarehouseRemark"; + for(int i=0; i> searchInfos = new Vector>(); + Vector> fieldInfos = new Vector>(); + + public MaterialPurchasingSearchDialog(TCSession session) throws TCException { + //super(true); +// TCComponentItemRevision rev; + fu.initializeUI(session); + //centerToScreen(); + this.setLocationRelativeTo(null); + this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); + + loadRendering(); + addActionListener(); + setVisible(true); + } + + private void loadRendering() throws TCException { + Vector loginInfos; + String loginInfo = TCUtil.getPreference2(fu.session, TCPreferenceService.TC_preference_site, "YSR_ERPPurchSearchDialog_ERPServerInfo"); +System.out.println("YSR_ERPPurchSearchDialog_ERPServerInfo----------" + loginInfo); + if (loginInfo.equals("")) { + MessageBox.post("޷ȡERPݿϢ,鿴ѡYSR_ERPPurchSearchDialog_ERPServerInfo!", "", MessageBox.ERROR); + return; + } + loginInfos = CommonUtil.split2Vector(loginInfo, "="); + if (loginInfos.size() != 5) { + MessageBox.post("ERPݿϢøʽȷ,鿴ѡYSR_ERPPurchSearchDialog_ERPServerInfo!", "", MessageBox.ERROR); + return; + } + + serverName = loginInfos.get(0); + dbName = loginInfos.get(1); + tableName = loginInfos.get(2); + userName = loginInfos.get(3); + password = loginInfos.get(4); + + String[] fieldMapInfos = TCUtil.getPreference(fu.session, TCPreferenceService.TC_preference_site, "YSR_ERPPurchSearchDialog_FieldMap"); + for (int i = 0; i < fieldMapInfos.length; i++) { + String fieldMapInfo = fieldMapInfos[i]; + Vector fieldMapInfoParts = CommonUtil.split2Vector(fieldMapInfo, "@@"); + if (fieldMapInfoParts.get(0).startsWith("Search")) { + searchInfos.add(fieldMapInfoParts); + } else if (fieldMapInfoParts.get(0).startsWith("Field")) { + System.out.println("б===" + fieldMapInfoParts); + fieldInfos.add(fieldMapInfoParts); + } + } + } + + private void addActionListener() { + JButton btn = (JButton)fu.allComponentMap.get("b.11.15"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + searchERPInfo(); + } + }); + + btn = (JButton)fu.allComponentMap.get("b.11.16"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + outputERPInfo(); + } + }); + } + + private void searchERPInfo() { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a.21.11.11"); + int rowCount = ci.dataTableModel.getRowCount(); + for(int i = rowCount - 1; i >= 0; i--){ + ci.dataTableModel.removeRow(i); + } + ci.dataTableModel.getDataVector().clear(); + + iTextField textField = (iTextField)fu.allComponentMap.get("CGDID"); + String CGDID = textField.getText().toString();//ѯɹID + textField = (iTextField)fu.allComponentMap.get("XMH"); + String XMH = textField.getText().toString();//ѯĿ + if (CGDID.equals("") && XMH.equals("")) { + MessageBox.post("ѯ", "ʾ", MessageBox.INFORMATION); + return; + } + String where = ""; + if (!CGDID.equals("")) { + for (int j = 0; j < searchInfos.size(); j++) { + if (searchInfos.get(j).get(1).equals("CGDID")) { + where += "(" + searchInfos.get(j).get(3) + searchInfos.get(j).get(2) + "'" + CGDID + "'"; + break; + } + } + } + if (!XMH.equals("")) { + for (int j = 0; j < searchInfos.size(); j++) { + if (searchInfos.get(j).get(1).equals("XMH")) { + if (where.equals("")) { + where += "(" + searchInfos.get(j).get(3) + searchInfos.get(j).get(2) + "'" + XMH + "')"; + } else { + where += " AND " + searchInfos.get(j).get(3) + searchInfos.get(j).get(2) + "'" + XMH + "')"; + } + break; + } + } + } + if (where.equals("")) { + for (int j = 0; j < searchInfos.size(); j++) { + if (searchInfos.get(j).get(1).equals("CGDID")) { + where += "(" + searchInfos.get(j).get(3) + " LIKE '%')"; + break; + } + } + } + System.out.println("####"+where); + try { + Connection connection = null; + Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); + System.out.println("ݿسɹ"); +// connection = DriverManager.getConnection("jdbc:sqlserver://192.168.0.26:1433;DatabaseName=UFDATA_201_2013","user11","Aa123"); + connection = DriverManager.getConnection("jdbc:sqlserver://"+serverName+":1433;DatabaseName="+dbName,userName,password); + if(connection == null){ + System.out.println("ݿʧ"); + MessageBox.post("ݿʧ!","",MessageBox.ERROR); + return; + }else { + System.out.println("ݿӳɹ"); + } + +// PreparedStatement pstmt = connection.prepareStatement("{call dbo.zzz_ۺϲѯ(?)}"); + PreparedStatement pstmt = connection.prepareStatement("{call dbo."+tableName+"(?)}"); + pstmt.setString(1, where); + System.out.println("ִд洢begin====" + where); + ResultSet rs = pstmt.executeQuery(); + System.out.println("ִд洢end====" + rs.getRow()); + Integer idx = 0; + while (rs.next()) { + System.out.println("====" + (idx + 1)); + Vector vec = new Vector<>(); + vec.add((++idx) + "");// + for (int j = 0; j < fieldInfos.size(); j++) { + System.out.println("б===" + fieldInfos.get(j).get(2)); + vec.add(rs.getString(fieldInfos.get(j).get(2))); + } + ci.dataTableModel.addRow(vec); + } + rs.close(); + pstmt.close(); + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post(e.getMessage(),"",MessageBox.ERROR); + } + } + + private void outputERPInfo() { + final JTable table = (JTable)fu.allComponentMap.get("a.21.11.11"); + final JButton btn = (JButton)fu.allComponentMap.get("b.11.16"); + btn.setEnabled(false); + final ProgressReporterDialog reporter = new ProgressReporterDialog(); + reporter.reportProgressMessage("ڵ,Ժ..."); + new Thread(reporter).start(); + new Thread() { + public void run() { + try { + Date date = new Date(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + String time = sdf.format(date); + String toPath = System.getProperty("java.io.tmpdir") + "ɹѯ" + time + ".xls"; + // һдWorkbook + WritableWorkbook writeWorkBook = Workbook.createWorkbook(new File(toPath)); + // + WritableSheet wsheet = writeWorkBook.createSheet("ɹѯ", 0); + + //д + int columnCount = table.getColumnCount(); // + int rowCount = table.getRowCount(); // + String[] titles = new String[columnCount]; // ͷ + + // ȡͷ + for (int i = 0; i < columnCount; i++) { + titles[i] = table.getColumnName(i); + } + + int current_row = 0; // ʼǰΪʼ + + try { + // ʽ + WritableFont titleFont = new WritableFont(WritableFont.createFont(""), 13,WritableFont.BOLD); + WritableCellFormat titleCellFormat = new WritableCellFormat(titleFont); + titleCellFormat.setBorder(Border.ALL, BorderLineStyle.MEDIUM); + titleCellFormat.setAlignment(Alignment.CENTRE); + titleCellFormat.setVerticalAlignment(VerticalAlignment.CENTRE); + titleCellFormat.setWrap(true); + + // ʽ + WritableFont contentFont = new WritableFont(WritableFont.createFont(""), 12); + WritableCellFormat contentCellFormat = new WritableCellFormat(contentFont); + contentCellFormat.setBorder(Border.ALL, BorderLineStyle.THIN); + contentCellFormat.setAlignment(Alignment.CENTRE); + contentCellFormat.setVerticalAlignment(VerticalAlignment.CENTRE); + contentCellFormat.setWrap(true); + + // дб + for (int i = 0; i < columnCount; i++) { + Label labelTitle = new Label(i, current_row, titles[i], titleCellFormat); + wsheet.addCell(labelTitle); + } + + current_row = current_row + 1; + // д + for (int i = 0; i < rowCount; i++) { + for (int j = 0; j < columnCount; j++) { + Object objValue = table.getValueAt(i, j); + Label labelContent = new Label(j, i + current_row, String.valueOf(objValue), contentCellFormat); + wsheet.addCell(labelContent); + } + } + + // øʽ + wsheet.getSettings().setDefaultColumnWidth(20); + writeWorkBook.write(); + writeWorkBook.close(); + } catch (WriteException e) { + e.printStackTrace(); + } + + // 򿪵ıļ + Runtime.getRuntime().exec("cmd /c \"" + toPath + "\""); + + } catch (IOException e) { + e.printStackTrace(); + } + reporter.requestCanceling(); + btn.setEnabled(true); + } + }.start(); + } + +} diff --git a/src/cn/com/ebewin/ysr/dialog/PipingLinePlanningManagementDialog.java b/src/cn/com/ebewin/ysr/dialog/PipingLinePlanningManagementDialog.java new file mode 100644 index 0000000..112a769 --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/PipingLinePlanningManagementDialog.java @@ -0,0 +1,774 @@ +package cn.com.ebewin.ysr.dialog; + +import java.awt.Color; +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Vector; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JTable; +import javax.swing.table.DefaultTableCellRenderer; + +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentSchedule; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +import com.teamcenter.rac.kernel.TCComponentTask; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.iTextField; +import com.teamcenter.services.rac.core.DataManagementService; + +import cn.com.ebewin.ysr.util.CommonUtil; +import cn.com.ebewin.ysr.util.DialogUtil; +import cn.com.ebewin.ysr.util.FormUtil; +import cn.com.ebewin.ysr.util.KUtil; +import cn.com.ebewin.ysr.util.TCUtil; +import cn.com.ebewin.ysr.util.UIUtil.JComboBoxInfo; +import cn.com.ebewin.ysr.util.UIUtil.JTableInfo; +import jxl.Workbook; +import jxl.format.Alignment; +import jxl.format.Border; +import jxl.format.BorderLineStyle; +import jxl.format.VerticalAlignment; +import jxl.write.Label; +import jxl.write.WritableCellFormat; +import jxl.write.WritableFont; +import jxl.write.WritableSheet; +import jxl.write.WritableWorkbook; +import jxl.write.WriteException; + +@SuppressWarnings("deprecation") +public class PipingLinePlanningManagementDialog extends JFrame { + private static final long serialVersionUID = 1L; + DialogUtil fu = new DialogUtil(this, "߼ƻ", "YSR8_PipingLinePlanningManagementDialog"); + HashMap allObjectMap1 = new HashMap(); + private static final int TASKSTATE_INDEX = 22; +// private static final int T1_PROJECTID_INDEX = 1; + private static final int WIRING_INDEX = 10; // + private static final int WIRED_INDEX = 11; // + private static final int ARRIVED_INDEX = 8; // ѵ + private static final int TOTAL_INDEX = 7; // + private static final int START_INDEX = 14; //߿ʼʱ + private Date Date1 = null; + private Date Date2 = null; + + public PipingLinePlanningManagementDialog(TCSession session) throws TCException { + // super(true); + + fu.initializeUI(session); + JTable table = (JTable) fu.allComponentMap.get("a.31.11.11"); + table.setAutoCreateRowSorter(true); + + // centerToScreen(); + this.setLocationRelativeTo(null); + this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); + + loadRendering(); + addActionListener(); + + setVisible(true); + } + + private void loadRendering() throws TCException { + JTable table = (JTable) fu.allComponentMap.get("a.31.11.11"); + table.setDefaultRenderer(Object.class, new ColorTableRenderer()); + @SuppressWarnings("unchecked") + JComboBox cbx = (JComboBox) fu.allComponentMap.get("ysr8_TaskManuState");//lidy20190322 +// cbx.addItem(""); + cbx.addItem(""); + cbx.addItem(""); + cbx.addItem("ѵ"); + cbx.addItem("δ"); + cbx.addItem("Ѽ"); + } + + public class ColorTableRenderer extends DefaultTableCellRenderer { + + /** + * + */ + private static final long serialVersionUID = 1L; + private Color DEFBLUE = new Color(51, 153, 255); +// private Color DEFGREEN = new Color(158, 234, 106); +// private Color DEFYELLOW = new Color(245, 245, 43); + private Color DEFORANGE = new Color(249, 116, 7); + + @Override + public Component getTableCellRendererComponent(JTable t, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + if (hasFocus) { + setBackground(DEFBLUE); + } else { + setBackground(Color.WHITE); + String state = t.getValueAt(row, TASKSTATE_INDEX)==null?"":t.getValueAt(row, TASKSTATE_INDEX).toString(); + String WiringStartDate = t.getValueAt(row, START_INDEX)==null?"":t.getValueAt(row, START_INDEX).toString(); + String Quantity = t.getValueAt(row, TOTAL_INDEX)==null?"":t.getValueAt(row, TOTAL_INDEX).toString(); + String ArrivedQuantity = t.getValueAt(row, ARRIVED_INDEX)==null?"":t.getValueAt(row, ARRIVED_INDEX).toString(); + String WiredQuantity = t.getValueAt(row, WIRED_INDEX)==null?"":t.getValueAt(row, WIRED_INDEX).toString(); + String PurchFinishDate = t.getValueAt(row, 17)==null?"":t.getValueAt(row, 17).toString(); + if((state.equals("ѱ") || state.equals("") || state.equals("Ѽ")) && Quantity.equals(WiredQuantity)) {// + setBackground(Color.GREEN); + } else if(!WiringStartDate.equals("") && PurchFinishDate.equals("")) {// + setBackground(Color.YELLOW); + } else if(!ArrivedQuantity.equals("") && !ArrivedQuantity.equals("0") && WiringStartDate.equals("")) {//ѵ + setBackground(DEFORANGE); + } +// if(state!=null) { +// String content=state.toString(); +// if(content.equals("Ѽ")) { +// setBackground(DEFGREEN); +// } +// } + } + return super.getTableCellRendererComponent(t, value, isSelected, hasFocus, row, column); + } + + } + + private void addActionListener() { + JButton btn = (JButton) fu.allComponentMap.get("b.11.110"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + searchMachiningInfo(); + } + }); + + btn = (JButton) fu.allComponentMap.get("b.11.111"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + editMachiningInfo(); + } + }); + + btn = (JButton) fu.allComponentMap.get("b.21.18"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + outputMachiningInfo(); + } + }); + + btn = (JButton) fu.allComponentMap.get("b.21.19"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + try { + submitInspectionProcess2(); + } catch (Exception e1) { + MessageBox.post(PipingLinePlanningManagementDialog.this,e.toString(),"",MessageBox.ERROR); + e1.printStackTrace(); + } + } + }); + } + + @SuppressWarnings("unchecked") + private void searchMachiningInfo() { + allObjectMap1.clear(); + + JTableInfo ci1 = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.31.11.11"); + int rowCount = ci1.dataTableModel.getRowCount(); + for (int i = rowCount - 1; i >= 0; i--) { + ci1.dataTableModel.removeRow(i); + } + ci1.dataTableModel.getDataVector().clear(); + + iTextField textField = (iTextField) fu.allComponentMap.get("XMH"); + String XMH = textField.getText().toString(); + + JComboBox cbx = (JComboBox) fu.allComponentMap.get("JGC"); + JComboBoxInfo cii = (JComboBoxInfo) fu.allComponentInfos.get("JGC"); + String JGC = cbx.getSelectedItem().toString(); + if (cii.lovVal != null) { + Iterator iter = cii.lovVal.keySet().iterator(); + while (iter.hasNext()) { + String lovKey = iter.next(); + String lovValue = cii.lovVal.get(lovKey); + if (lovValue.equalsIgnoreCase(JGC)) { + JGC = lovKey; + break; + } + } + } + + Date1=null; + Date2=null; + DateButton db = (DateButton) fu.allComponentMap.get("ysr8_FixturePlanDate1"); + Date1 = db.getDate(); + String Date1s = ""; + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-d"); + if (Date1 != null) { + Date1s = sdf.format(Date1) + " 00:00"; + } + + db = (DateButton) fu.allComponentMap.get("ysr8_FixturePlanDate2"); + Date2 = db.getDate(); + String Date2s = ""; + if (Date2 != null) { + Date2s = sdf.format(Date2) + " 23:59"; + } + + textField = (iTextField) fu.allComponentMap.get("FZR"); + String FZR = textField.getText().toString(); + + textField = (iTextField) fu.allComponentMap.get("JJPXDD"); + String JJPXDD = textField.getText().toString(); + + cbx = (JComboBox) fu.allComponentMap.get("ysr8_TaskManuState"); +// cii = (JComboBoxInfo) fu.allComponentInfos.get("ysr8_TaskManuState"); + final String ysr8_TaskManuState = cbx.getSelectedItem().toString(); + + Vector attrVec = new Vector(); + Vector valVec = new Vector(); + + attrVec.add(";"); + valVec.add("6"); + + if (!XMH.equals("")) { + attrVec.add("Ŀ ID"); + valVec.add(XMH); + } + if (!JGC.equals("")) { + attrVec.add("ӹ1"); + valVec.add(JGC); + } + if (!FZR.equals("")) { + attrVec.add("ӹ"); + valVec.add(FZR); + } + if (!JJPXDD.equals("")) { + attrVec.add("оߵ"); + valVec.add(JJPXDD); + } + String type = ""; + if (!ysr8_TaskManuState.equals("")) { + if(ysr8_TaskManuState.equals("")) { + attrVec.add("ӹ״̬"); + valVec.add("2;5"); + type = "߿ʼ"; + }else if(ysr8_TaskManuState.equals("")) { + attrVec.add("ӹ״̬"); + valVec.add("3;4"); + type = ""; + }else if(ysr8_TaskManuState.equals("ѵ")) { + + }else if(ysr8_TaskManuState.equals("δ")) { + attrVec.add("ӹ״̬"); + valVec.add("1"); + }else if(ysr8_TaskManuState.equals("Ѽ")) { + attrVec.add("ӹ״̬"); + valVec.add("4"); + type = ""; + } + } + if (!Date1s.equals("") && !type.equals("")) { + attrVec.add(type+"1"); + valVec.add(Date1s); + } + if (!Date2s.equals("") && !type.equals("")) { + attrVec.add(type+"2"); + valVec.add(Date2s); + } + + final String[] attrs = (String[]) attrVec.toArray(new String[attrVec.size()]); + final String[] vals = (String[]) valVec.toArray(new String[attrVec.size()]); + new Thread(new Runnable() { + public void run() { + JButton btn = (JButton) fu.allComponentMap.get("b.11.110"); + btn.setText("ѯ..."); + setEnableBtns(false); + searchMachiningInfo_SchedulTask(attrs, vals, ysr8_TaskManuState); + setEnableBtns(true); + btn.setText("ѯ"); + } + }).start(); + } + + private void setEnableBtns(boolean b) { + JButton btn = (JButton) fu.allComponentMap.get("b.11.110"); + btn.setEnabled(b); + btn = (JButton) fu.allComponentMap.get("b.11.111"); + btn.setEnabled(b); + btn = (JButton) fu.allComponentMap.get("b.21.18"); + btn.setEnabled(b); + btn = (JButton) fu.allComponentMap.get("b.21.19"); + btn.setEnabled(b); + } + + private void searchMachiningInfo_SchedulTask(String[] attrs, String[] vals, String ysr8_TaskManuState) { + JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.31.11.11"); + try { + TCComponent[] tcComponents = TCUtil.query(fu.session, "SearchSchedulTaskPLP", attrs, vals); + + HashMap map = new HashMap<>(); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + HashMap ysr8_ArrivedQuantitys = new HashMap<>(); + HashMap ysr8_ArrivingQuantitys = new HashMap<>(); + HashMap ysr8_PurchPlanDates = new HashMap<>(); + HashMap ysr8_PurchFinishDates = new HashMap<>(); + for (int i = 0; i < tcComponents.length; i++) { + TCComponentScheduleTask scheduTask = (TCComponentScheduleTask) tcComponents[i]; + TCComponentScheduleTask searScheduleTask = searchScheduleTask(scheduTask.getProperty("ysr8_ProjectCode"), "2", scheduTask.getProperty("object_name")); +// System.out.println(Date1+"=="+Date2+"--"+ysr8_TaskManuState); + Date MachPlanDate = null, MachFinishDate = null; + String ArrivedQuantity = ""; + if(searScheduleTask != null) { + MachPlanDate = searScheduleTask.getDateProperty("ysr8_PurchPlanDate"); + MachFinishDate = searScheduleTask.getDateProperty("ysr8_PurchFinishDate"); + ArrivedQuantity = searScheduleTask.getProperty("ysr8_ArrivedQuantity"); + } + if(!ysr8_TaskManuState.equals("") && !ysr8_TaskManuState.equals("δ") && !ysr8_TaskManuState.equals("Ѽ")) { + String TaskManuState = scheduTask.getProperty("ysr8_TaskManuState"); + String Quantity = scheduTask.getProperty("ysr8_PartNumber"); + String WiredQuantity = scheduTask.getProperty("ysr8_WiredQuantity"); + String WiringStartDate = scheduTask.getProperty("ysr8_WiringStartDate"); + String PurchFinishDate = scheduTask.getProperty("ysr8_PurchFinishDate"); + if(ysr8_TaskManuState.equals("")) { +// System.out.println(scheduTask.getProperty("object_name")+"=="+TaskManuState+"=="+Quantity+"=="+WiredQuantity); + if((!TaskManuState.equals("ѱ") && !TaskManuState.equals("Ѽ")) || !Quantity.equals(WiredQuantity)) + continue; + } else if(ysr8_TaskManuState.equals("")) { +// System.out.println(scheduTask.getProperty("object_name")+"=="+WiringStartDate+"=="+Quantity+"=="+WiredQuantity); + if(WiringStartDate.equals("") || !PurchFinishDate.equals("") || (!WiringStartDate.equals("") && Quantity.equals(WiredQuantity))) { +// System.out.println("continue"); + continue; + } + } else if(ysr8_TaskManuState.equals("ѵ")) { + System.out.println(scheduTask.getProperty("object_name")+"=="+WiringStartDate+"=="+Quantity+"=="+ArrivedQuantity); + if(ArrivedQuantity.equals("") || ArrivedQuantity.equals("0") || !WiringStartDate.equals("")) { +// System.out.println("continue"); + continue; + } + } +// System.out.println("add"); + } + if(Date1 != null) { + if(ysr8_TaskManuState.equals("ѵ") && (MachFinishDate==null || MachFinishDate.compareTo(Date1)<0)) + continue; + else if(ysr8_TaskManuState.equals("δ") && (MachPlanDate==null || MachPlanDate.compareTo(Date1)<0)) + continue; + else if(ysr8_TaskManuState.equals("") && (MachPlanDate==null || MachPlanDate.compareTo(Date1)<0)) + continue; + } + if(Date2 != null) { + if(ysr8_TaskManuState.equals("ѵ") && (MachFinishDate==null || MachFinishDate.compareTo(Date2)>0)) + continue; + else if(ysr8_TaskManuState.equals("δ") && (MachPlanDate==null || MachPlanDate.compareTo(Date2)>0)) + continue; + else if(ysr8_TaskManuState.equals("") && (MachPlanDate==null || MachPlanDate.compareTo(Date2)>0)) { +// System.out.println(MachPlanDate+"=="+Date2+"--"+MachPlanDate.compareTo(Date2)); + continue; + } + } + Date ysr8_PurchFinishDate = null; + if(searScheduleTask != null) { + ysr8_PurchFinishDate = searScheduleTask.getDateProperty("ysr8_PurchFinishDate");// оߵʱ + ysr8_ArrivedQuantitys.put(scheduTask, ArrivedQuantity); + ysr8_ArrivingQuantitys.put(scheduTask, searScheduleTask.getProperty("ysr8_ArrivingQuantity")); + ysr8_PurchPlanDates.put(scheduTask, fu.getDateString(MachPlanDate)); + ysr8_PurchFinishDates.put(scheduTask, fu.getDateString(MachFinishDate)); + }else { + ysr8_ArrivedQuantitys.put(scheduTask, ""); + ysr8_ArrivingQuantitys.put(scheduTask, ""); + ysr8_PurchPlanDates.put(scheduTask, ""); + ysr8_PurchFinishDates.put(scheduTask, ""); + } + if(ysr8_PurchFinishDate==null) + ysr8_PurchFinishDate = dateFormat.parse("9900-01-01"); + map.put(scheduTask, ysr8_PurchFinishDate); + } + TCComponent[] tcComponents2 = Pipingsort(map); + + Integer idx = ci.dataTableModel.getRowCount(); + for (int i = 0; i < tcComponents2.length; i++) { + TCComponentScheduleTask scheduTask = (TCComponentScheduleTask) tcComponents2[i]; + scheduTask.refresh(); + + String ysr8_ProjectCodeVal = scheduTask.getProperty("ysr8_ProjectCode"); + TCComponentSchedule schedule = TCUtil.findScheduleByID(fu.session, ysr8_ProjectCodeVal + "-00"); + TCComponentForm projectForm = null; + if (schedule != null) { + projectForm = (TCComponentForm) schedule.getRelatedComponent("IMAN_reference"); + } + + Vector vec = new Vector<>(); + vec.add((++idx) + "");// + vec.add(scheduTask.getProperty("ysr8_ProjectCode"));// Ŀ + vec.add(scheduTask.getProperty("object_name"));// + if (projectForm != null) {// ӹ + vec.add(projectForm.getProperty("ysr8_Machiner")); + } else { + vec.add(""); + } + if (projectForm != null) {// ɹ + vec.add(projectForm.getProperty("ysr8_Purcher")); + } else { + vec.add(""); + } + vec.add(scheduTask.getProperty("ysr8_WiringPerson"));// оߵ + vec.add(scheduTask.getProperty("ysr8_ManuFactory1"));// ӹ + vec.add(scheduTask.getProperty("ysr8_PartNumber"));// + + // kk 20180907 + vec.add(ysr8_ArrivedQuantitys.get(scheduTask));// ѵ + vec.add(ysr8_ArrivingQuantitys.get(scheduTask));// ε + + vec.add(scheduTask.getProperty("ysr8_WiringQuantity"));// + vec.add(scheduTask.getProperty("ysr8_WiredQuantity"));// + + // vec.add(scheduTask.getProperty("ysr8_FixturePlanDate"));//оԤƵʱ + vec.add(ysr8_PurchPlanDates.get(scheduTask));// оԤƵʱ//lidy20190429 + vec.add(ysr8_PurchFinishDates.get(scheduTask));// оߵʱ + + vec.add(fu.getDateString(scheduTask.getDateProperty("ysr8_WiringStartDate")));// ߿ʼʱ + vec.add(fu.getDateString(scheduTask.getDateProperty("finish_date")));// ƻ + vec.add(fu.getDateString(scheduTask.getDateProperty("ysr8_PurchPlanDate")));// ɹƻ + + // kk 20180905 +// vec.add(fu.getDateString(scheduTask.getDateProperty("ysr8_PurchPlanDate")));// ʵ + vec.add(fu.getDateString(scheduTask.getDateProperty("ysr8_PurchFinishDate")));// ʵ + + vec.add(scheduTask.getProperty("ysr8_GasWiring"));// · + vec.add(scheduTask.getProperty("ysr8_CircuitWiring"));// · + vec.add(scheduTask.getProperty("ysr8_Remark"));// ע + if (projectForm != null) {// + vec.add(projectForm.getProperty("ysr8_Factory")); + } else { + vec.add(""); + } + vec.add(scheduTask.getProperty("ysr8_TaskManuState"));// ״̬ + vec.add(fu.getDateString(scheduTask.getDateProperty("ysr8_SubQualityFinishDate")));// ʼʱ + vec.add(scheduTask.getProperty("ysr8_SubQualityResult"));// ʼ + + ci.dataTableModel.addRow(vec); + allObjectMap1.put(idx - 1, scheduTask); + } + } catch (Exception ex) { + ex.printStackTrace(); + MessageBox.post(ex); + } + } + + private TCComponentScheduleTask searchScheduleTask(String projectCode, String taskUse, String name) throws TCException { + Vector attrVec = new Vector(); + Vector valVec = new Vector(); + attrVec.add("Ŀ"); + valVec.add(projectCode); + attrVec.add(";"); + valVec.add(taskUse); + attrVec.add(""); + valVec.add(name); + String[] attrs = (String[]) attrVec.toArray(new String[attrVec.size()]); + String[] vals = (String[]) valVec.toArray(new String[attrVec.size()]); + TCComponent[] tcComponents = TCUtil.query(fu.session, "SearchSchedulTaskPLP_02", attrs, vals); + if (tcComponents == null) { + return null; + } +// System.out.println(tcComponents.length); + if (tcComponents.length > 0) { + return (TCComponentScheduleTask) tcComponents[0]; + } + return null; + } + + private void editMachiningInfo() { + try { + JTable table = (JTable) fu.allComponentMap.get("a.31.11.11"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪ༭ݣ", "ʾ", MessageBox.INFORMATION); + return; + } + Object taskState = table.getValueAt(rows[0], TASKSTATE_INDEX); + if (taskState != null && (taskState.toString().equals("ѱ") || taskState.toString().equals("Ѽ"))) { + MessageBox.post("״̬Ϊ[ѱ졢Ѽ]ݲܽб༭", "ʾ", MessageBox.INFORMATION); + return; + } + TCComponentUser user = fu.session.getUser(); + String coordinationManager = TCUtil.getPreference2(fu.session, TCPreferenceService.TC_preference_site, "YSR8_MachiningDynamics_CoordinationManager"); + Boolean iscoordinationManager = false; + if (coordinationManager.equals(user.getProperty("user_name"))) { + iscoordinationManager = true; + } + if (!iscoordinationManager) { + MessageBox.post("ЭʩԱܽб༭", "ʾ", MessageBox.INFORMATION); + return; + } + int idx = Integer.parseInt(table.getValueAt(rows[0], 0).toString()); + TCComponentScheduleTask scheduTask = (TCComponentScheduleTask) allObjectMap1.get(idx - 1); + new PipingLinePlanningManagementEditDialog(this, scheduTask); + } catch (TCException e) { + e.printStackTrace(); + } +// searchMachiningInfo(); + } + + + + private void outputMachiningInfo() { + final JButton btn = (JButton) fu.allComponentMap.get("b.21.18"); + btn.setEnabled(false); + final JTable table1 = (JTable) fu.allComponentMap.get("a.31.11.11"); + + final ProgressReporterDialog reporter = new ProgressReporterDialog(); + reporter.reportProgressMessage("ڵ,Ժ..."); + new Thread(reporter).start(); + new Thread() { + public void run() { + try { + Date date = new Date(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + String time = sdf.format(date); + String toPath = System.getProperty("java.io.tmpdir") + "ӹ̬" + time + ".xls"; + // һдWorkbook + WritableWorkbook writeWorkBook = Workbook.createWorkbook(new File(toPath)); + // + WritableSheet wsheet = writeWorkBook.createSheet("ӹ̬", 0); + + // д + int columnCount = table1.getColumnCount(); // + int rowCount = table1.getRowCount(); // + String[] titles = new String[columnCount]; // ͷ + + // ȡͷ + for (int i = 0; i < columnCount; i++) { + titles[i] = table1.getColumnName(i); + } + + int current_row = 0; // ʼǰΪʼ + + try { + // ʽ + WritableFont titleFont = new WritableFont(WritableFont.createFont(""), 13, WritableFont.BOLD); + WritableCellFormat titleCellFormat = new WritableCellFormat(titleFont); + titleCellFormat.setBorder(Border.ALL, BorderLineStyle.MEDIUM); + titleCellFormat.setAlignment(Alignment.CENTRE); + titleCellFormat.setVerticalAlignment(VerticalAlignment.CENTRE); + titleCellFormat.setWrap(true); + + // ʽ + WritableFont contentFont = new WritableFont(WritableFont.createFont(""), 12); + WritableCellFormat contentCellFormat = new WritableCellFormat(contentFont); + contentCellFormat.setBorder(Border.ALL, BorderLineStyle.THIN); + contentCellFormat.setAlignment(Alignment.CENTRE); + contentCellFormat.setVerticalAlignment(VerticalAlignment.CENTRE); + contentCellFormat.setWrap(true); + + // дб + for (int i = 0; i < columnCount; i++) { + Label labelTitle = new Label(i, current_row, titles[i], titleCellFormat); + wsheet.addCell(labelTitle); + } + + current_row = current_row + 1; + // д + for (int i = 0; i < rowCount; i++) { + for (int j = 0; j < columnCount; j++) { + Object objValue = table1.getValueAt(i, j); + Label labelContent = new Label(j, i + current_row, String.valueOf(objValue), contentCellFormat); + wsheet.addCell(labelContent); + } + } + + // øʽ + wsheet.getSettings().setDefaultColumnWidth(20); + writeWorkBook.write(); + writeWorkBook.close(); + } catch (WriteException e) { + e.printStackTrace(); + } + + // 򿪵ıļ + Runtime.getRuntime().exec("cmd /c \"" + toPath + "\""); + + } catch (IOException e) { + e.printStackTrace(); + } + reporter.requestCanceling(); + btn.setEnabled(true); + } + }.start(); + } + + // kk 20180907 ύ߼ + private void submitInspectionProcess2() throws Exception { + JTable table = (JTable) fu.allComponentMap.get("a.31.11.11"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post(PipingLinePlanningManagementDialog.this,"ѡҪ༭ݣ", "ʾ", MessageBox.INFORMATION); + return; + } + if (!table.getValueAt(rows[0], TASKSTATE_INDEX).toString().equals("ѵ")&&!table.getValueAt(rows[0], TASKSTATE_INDEX).toString().equals("")) { + MessageBox.post(PipingLinePlanningManagementDialog.this,"״̬Ϊ[ѵ][]ݲύ̣", "ʾ", MessageBox.INFORMATION); + return; + } + TCComponentUser user = fu.session.getUser(); + String coordinationManager = TCUtil.getPreference2(fu.session, TCPreferenceService.TC_preference_site, "YSR8_MachiningDynamics_CoordinationManager"); + Boolean iscoordinationManager = false; + if (coordinationManager.equals(user.getProperty("user_name"))) { + iscoordinationManager = true; + } + if (!iscoordinationManager) { + MessageBox.post(PipingLinePlanningManagementDialog.this,"ЭʩԱܽб༭", "ʾ", MessageBox.INFORMATION); + return; + } + //<ѵ + Object wiredNumStr=table.getValueAt(rows[0], WIRED_INDEX); + Object arrivedNumStr=table.getValueAt(rows[0], ARRIVED_INDEX); + Object totalNumStr=table.getValueAt(rows[0], TOTAL_INDEX); + double wiredNum=KUtil.getDoubleFromString(wiredNumStr, ""); + double arrivedNum=KUtil.getDoubleFromString(arrivedNumStr, "ѵ"); + double totalNum=KUtil.getDoubleFromString(totalNumStr, ""); + if(wiredNum>=arrivedNum) { + MessageBox.post(PipingLinePlanningManagementDialog.this,"޷ύ<ѵ","ʾ",MessageBox.WARNING); + return; + } + //༭ + Object wiringNumStr=table.getValueAt(rows[0], WIRING_INDEX); + double wiringNum=KUtil.getDoubleFromString(wiringNumStr, ""); + double newNum=new PipingLinePlanningWiringDialog(wiringNum,wiredNum,arrivedNum).getWiringNum(); + if(newNum<=0) { + System.out.println("δ޸"); + return; + } + System.out.println(""+newNum); + //޸ + int idx = Integer.parseInt(table.getValueAt(rows[0], 0).toString()); + TCComponentScheduleTask scheduTask = (TCComponentScheduleTask) allObjectMap1.get(idx - 1); + wiredNum=wiredNum+newNum; + CommonUtil.setByPass(true); + scheduTask.setStringProperty("ysr8_WiringQuantity",fu.getDoubleString(newNum));// + table.setValueAt(fu.getDoubleString(newNum), rows[0], WIRING_INDEX); + scheduTask.setStringProperty("ysr8_WiredQuantity",fu.getDoubleString(wiredNum));// + table.setValueAt(fu.getDoubleString(wiredNum), rows[0], WIRED_INDEX); + System.out.println("wiredNum:"+wiredNum+"&totalNum:"+totalNum); + if(wiredNum==totalNum) { + scheduTask.setStringProperty("ysr8_TaskManuState", "3");//ѱ + table.setValueAt("ѱ", rows[0], TASKSTATE_INDEX); + scheduTask.setDateProperty("ysr8_PurchFinishDate", new Date());//ʵʱ + table.setValueAt(fu.getDateString(new Date()), rows[0], 17); + completeTask(scheduTask); + }else if(wiredNum 0) { + TCComponent task1 = null; + TCComponent task2 = null; + for (int i = 0; i < tasks.length; i++) { + TCComponent task = tasks[i]; + String object_type = task.getProperty("object_type"); + System.out.println("object_type object_name1======" + task.getUid() + "======" + task.getProperty("object_type") + "======" + task.getProperty("object_name")); + if (object_type.equals("Signoff")) { + task1 = task; + } else if (object_type.equals("Ͽɡ")) { + task2 = task; + } + } + if (task1 != null && task2 != null) { + TCComponent[] childTasks = task2.getRelatedComponents("child_tasks"); + if (childTasks != null && childTasks.length > 0) { + for (int j = 0; j < childTasks.length; j++) { + TCComponent childTask = childTasks[j]; + String childObject_type = childTask.getProperty("object_type"); + System.out.println("object_type object_type2======" + childTask.getUid() + "======" + childTask.getProperty("object_type") + "======" + childTask.getProperty("object_name")); + if (childObject_type.equals("ִǩ")) { + // kk ֱӽ״̬Ϊ ѱ + TCComponentTask targetTask = (TCComponentTask) childTask; + String taskState = targetTask.getProperty("fnd0state"); + System.out.println("״̬: " + taskState); + if (!taskState.equals("")) { + System.out.println("Զ"); + TCComponentUser curUser = fu.session.getUser(); + TCComponent userBox =curUser.getReferenceProperty("userinbox"); + TCComponent taskBox = curUser.getReferenceProperty("taskinbox"); + System.out.println(taskBox); + DataManagementService service=DataManagementService.getService(fu.session); + service.refreshObjects(new TCComponent[] {taskBox,userBox}); + taskBox.refresh(); + userBox.refresh(); + System.out.println(childTask); + + targetTask.performTaskAction(106, "Զ", "", "Ͽ", task1, null, null); + + } else { + System.out.println("Զ"); + } + } + } + } + } + } + } + + protected void updateValues(HashMap tableMap) { + JTable table = (JTable) fu.allComponentMap.get("a.31.11.11"); + int rows[] = table.getSelectedRows(); + for(int i : rows) { + for(Entry e : tableMap.entrySet()) { + if(e.getKey().equals("ysr8_WiringPerson")) { + table.setValueAt(e.getValue(), i, 5); + } else if(e.getKey().equals("ysr8_ManuFactory1")) { + table.setValueAt(e.getValue(), i, 6); + } else if(e.getKey().equals("ysr8_WiringStartDate")) { + table.setValueAt(e.getValue(), i, START_INDEX); + } else if(e.getKey().equals("ysr8_PurchPlanDate")) { + table.setValueAt(e.getValue(), i, 16); + } else if(e.getKey().equals("ysr8_GasWiring")) { + table.setValueAt(e.getValue(), i, 18); + } else if(e.getKey().equals("ysr8_CircuitWiring")) { + table.setValueAt(e.getValue(), i, 19); + } else if(e.getKey().equals("ysr8_Remark")) { + table.setValueAt(e.getValue(), i, 20); + } + } + } + + } + private TCComponent[] Pipingsort(HashMap map) { + int count = map.size(); + // ͨArrayList캯map.entrySet()תlist + List> list = new ArrayList>(map.entrySet()); + // ͨȽʵֱȽ + Collections.sort(list, new Comparator>() { + public int compare(Map.Entry mapping1, Map.Entry mapping2) { +// System.out.println(mapping1.getValue()+"=="+mapping2.getValue()+"--"+mapping1.getValue().compareTo(mapping2.getValue())); + return mapping1.getValue().compareTo(mapping2.getValue()); + } + }); + TCComponent[] TCComponent = new TCComponent[count]; + int i=0; + for(Map.Entry mapping : list) { + TCComponent[i] = mapping.getKey(); + i++; + } + return TCComponent; + } +} diff --git a/src/cn/com/ebewin/ysr/dialog/PipingLinePlanningManagementEditDialog.java b/src/cn/com/ebewin/ysr/dialog/PipingLinePlanningManagementEditDialog.java new file mode 100644 index 0000000..db14598 --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/PipingLinePlanningManagementEditDialog.java @@ -0,0 +1,184 @@ +package cn.com.ebewin.ysr.dialog; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.Map.Entry; + +import javax.swing.JButton; +import javax.swing.JComboBox; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.iTextField; + +import cn.com.ebewin.ysr.util.DialogUtil; + +@SuppressWarnings("deprecation") +public class PipingLinePlanningManagementEditDialog extends AbstractAIFDialog { + private static final long serialVersionUID = 1L; + private DialogUtil fu = new DialogUtil(this, "༭", "YSR8_PipingLinePlanningManagementEditDialog"); + + private TCComponentScheduleTask scheduTask = null; + private PipingLinePlanningManagementDialog ppmDialog; + //private Boolean setArrivalState = false; + + public PipingLinePlanningManagementEditDialog(PipingLinePlanningManagementDialog ppmDialog, TCComponentScheduleTask scheduTask) throws TCException { + super(true); + + this.ppmDialog = ppmDialog; + this.scheduTask = scheduTask; + + fu.initializeUI(ppmDialog.fu.session); + centerToScreen(); + loadRendering(); + addActionListener(); + getDefVal(); + setVisible(true); + } + + @SuppressWarnings("unchecked") + private void loadRendering() throws TCException { + iTextField ysr8_WiringPerson = (iTextField)fu.allComponentMap.get("ysr8_WiringPerson"); + ysr8_WiringPerson.setText(scheduTask.getStringProperty("ysr8_WiringPerson")); + JComboBox ysr8_ManuFactory1 = (JComboBox)fu.allComponentMap.get("ysr8_ManuFactory1"); + ysr8_ManuFactory1.setSelectedItem(scheduTask.getStringProperty("ysr8_ManuFactory1")); + + /*DateButton ysr8_FixturePlanDate = (DateButton)fu.allComponentMap.get("ysr8_FixturePlanDate"); + if (!scheduTask.getTCProperty("ysr8_FixturePlanDate").isPropValueNull()) { + System.out.println(ysr8_FixturePlanDate); + ysr8_FixturePlanDate.setDate(scheduTask.getTCProperty("ysr8_FixturePlanDate").getDateValue()); + } + + DateButton ysr8_PurchFinishDate = (DateButton)fu.allComponentMap.get("ysr8_PurchFinishDate"); + if (!scheduTask.getTCProperty("ysr8_PurchFinishDate").isPropValueNull()) { + ysr8_PurchFinishDate.setDate(scheduTask.getTCProperty("ysr8_PurchFinishDate").getDateValue()); + }*/ + + DateButton ysr8_WiringStartDate = (DateButton)fu.allComponentMap.get("ysr8_WiringStartDate"); + if (!scheduTask.getTCProperty("ysr8_WiringStartDate").isPropValueNull()) { + ysr8_WiringStartDate.setDate(scheduTask.getTCProperty("ysr8_WiringStartDate").getDateValue()); + } + DateButton ysr8_PurchPlanDate = (DateButton)fu.allComponentMap.get("ysr8_PurchPlanDate"); + if (!scheduTask.getTCProperty("ysr8_PurchPlanDate").isPropValueNull()) { + ysr8_PurchPlanDate.setDate(scheduTask.getTCProperty("ysr8_PurchPlanDate").getDateValue()); + } + + iTextField ysr8_GasWiring = (iTextField)fu.allComponentMap.get("ysr8_GasWiring"); + ysr8_GasWiring.setText(scheduTask.getStringProperty("ysr8_GasWiring")); + iTextField ysr8_CircuitWiring = (iTextField)fu.allComponentMap.get("ysr8_CircuitWiring"); + ysr8_CircuitWiring.setText(scheduTask.getStringProperty("ysr8_CircuitWiring")); + iTextField ysr8_Remark = (iTextField)fu.allComponentMap.get("ysr8_Remark"); + ysr8_Remark.setText(scheduTask.getStringProperty("ysr8_Remark")); + } + + private void addActionListener() { + JButton btn = (JButton)fu.allComponentMap.get("b.81.12"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + saveRendering(); + } + }); + + btn = (JButton)fu.allComponentMap.get("b.81.14"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + } + + @SuppressWarnings("unchecked") + private void saveRendering() { + if (!checkCanSave()) { + return; + } + + HashMap valMap1 = new HashMap(); +// HashMap tableMap = new HashMap(); + + iTextField ysr8_WiringPerson = (iTextField)fu.allComponentMap.get("ysr8_WiringPerson"); + valMap1.put("ysr8_WiringPerson", ysr8_WiringPerson.getText().toString()); + JComboBox ysr8_ManuFactory1 = (JComboBox)fu.allComponentMap.get("ysr8_ManuFactory1"); + valMap1.put("ysr8_ManuFactory1", ysr8_ManuFactory1.getSelectedItem().toString()); + + /*DateButton ysr8_FixturePlanDate = (DateButton)fu.allComponentMap.get("ysr8_FixturePlanDate"); + valMap1.put("ysr8_FixturePlanDate", fu.getDateString(ysr8_FixturePlanDate.getDate())); + + DateButton ysr8_PurchFinishDate = (DateButton)fu.allComponentMap.get("ysr8_PurchFinishDate"); + valMap1.put("ysr8_PurchFinishDate", fu.getDateString(ysr8_PurchFinishDate.getDate())); + */ + DateButton ysr8_WiringStartDate = (DateButton)fu.allComponentMap.get("ysr8_WiringStartDate"); + valMap1.put("ysr8_WiringStartDate", fu.getDateString(ysr8_WiringStartDate.getDate())); + DateButton ysr8_PurchPlanDate = (DateButton)fu.allComponentMap.get("ysr8_PurchPlanDate"); + valMap1.put("ysr8_PurchPlanDate", fu.getDateString(ysr8_PurchPlanDate.getDate())); + + iTextField ysr8_GasWiring = (iTextField)fu.allComponentMap.get("ysr8_GasWiring"); + valMap1.put("ysr8_GasWiring", ysr8_GasWiring.getText().toString()); + iTextField ysr8_CircuitWiring = (iTextField)fu.allComponentMap.get("ysr8_CircuitWiring"); + valMap1.put("ysr8_CircuitWiring", ysr8_CircuitWiring.getText().toString()); + iTextField ysr8_Remark = (iTextField)fu.allComponentMap.get("ysr8_Remark"); + valMap1.put("ysr8_Remark", ysr8_Remark.getText().toString()); + + try { + for(Entry entry: valMap1.entrySet()){ + String key1 = entry.getKey(); + String key2 = entry.getValue(); + TCProperty property = (TCProperty)scheduTask.getTCProperty(key1); + switch (property.getPropertyType()) { + case TCProperty.PROP_string: + case TCProperty.PROP_long_string: + scheduTask.setStringProperty(key1, key2); + break; + case TCProperty.PROP_short: + case TCProperty.PROP_int: + scheduTask.setIntProperty(key1, Integer.parseInt(key2)); + break; + case TCProperty.PROP_double: + case TCProperty.PROP_float: + scheduTask.setDoubleProperty(key1, Double.parseDouble(key2)); + break; + case TCProperty.PROP_date: + if (!key2.equals("")) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date date = sdf.parse(key2); + if (date != null) { + scheduTask.setDateProperty(key1, date); + } + } + break; + default: + scheduTask.setStringProperty(key1, key2); + break; + } + } + + ppmDialog.updateValues(valMap1); + disposeDialog(); + } catch (TCException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } catch (ParseException e) { + e.printStackTrace(); + MessageBox.post(e); + return; + } + } + + private void getDefVal() { + fu.getDefVal(); + } + + public boolean checkCanSave() { + return true; + } + +} diff --git a/src/cn/com/ebewin/ysr/dialog/PipingLinePlanningWiringDialog.java b/src/cn/com/ebewin/ysr/dialog/PipingLinePlanningWiringDialog.java new file mode 100644 index 0000000..8e8b888 --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/PipingLinePlanningWiringDialog.java @@ -0,0 +1,108 @@ +package cn.com.ebewin.ysr.dialog; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.util.MessageBox; + +public class PipingLinePlanningWiringDialog extends AbstractAIFDialog { + private static final long serialVersionUID = -8956889736040215103L; + private JButton okBtn; + private JButton celBtn; + public boolean isChanged = false; + public String wiringNumStr = ""; + private JTextField wiringNumField; + private double res=-1; + private double wiredNum; + private double arrivedNum; + + public PipingLinePlanningWiringDialog(double wiringNum, double wiredNum, double arrivedNum) { + super(true); + this.res=wiringNum; + this.wiringNumStr = wiringNum+""; + this.wiredNum=wiredNum; + this.arrivedNum=arrivedNum; + } + + public double getWiringNum() throws Exception { + initUI(); + return res; + } + + private void initUI() throws Exception { + this.setTitle("༭"); + this.setLayout(new BorderLayout()); + this.setPreferredSize(new Dimension(300, 150)); + JPanel mainPanel = new JPanel(new GridBagLayout()); + GridBagConstraints s = new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0); + mainPanel.add(new JLabel(""), s); + s.gridx++; + this.wiringNumField = new JTextField(); + //wiringNumField.setText(wiringNumStr); + s.weightx = 1; + s.insets = new Insets(5, 0, 5, 5); + mainPanel.add(wiringNumField, s); + JPanel btnPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 15, 5)); + okBtn = new JButton("ȷ"); + celBtn = new JButton("ȡ"); + okBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent arg0) { + if(checkWiringNum()) { + disposeDialog(); + } + } + }); + celBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + btnPanel.add(okBtn); + btnPanel.add(celBtn); + this.add(BorderLayout.CENTER, mainPanel); + this.add(BorderLayout.SOUTH, btnPanel); + this.showDialog(); + } + + protected boolean checkWiringNum() { + wiringNumStr = wiringNumField.getText(); + double wiringNum; + if(!"".equals(wiringNumStr)) { + try { + wiringNum=Double.parseDouble(wiringNumStr); + } catch (NumberFormatException e) { + MessageBox.post(PipingLinePlanningWiringDialog.this,"дȷ","ʾ",MessageBox.WARNING); + e.printStackTrace(); + return false; + } + }else { + MessageBox.post(PipingLinePlanningWiringDialog.this,"д","ʾ",MessageBox.WARNING); + return false; + } + if(wiringNum<=0) { + MessageBox.post(PipingLinePlanningWiringDialog.this,"д0","ʾ",MessageBox.WARNING); + return false; + } + if(wiringNum>(arrivedNum-wiredNum)) { + MessageBox.post(PipingLinePlanningWiringDialog.this,"ɴڣѵ-","ʾ",MessageBox.WARNING); + return false; + } + this.res=wiringNum; + return true; + } + +} diff --git a/src/cn/com/ebewin/ysr/dialog/ProblemBoardDialog.java b/src/cn/com/ebewin/ysr/dialog/ProblemBoardDialog.java new file mode 100644 index 0000000..d0086ff --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/ProblemBoardDialog.java @@ -0,0 +1,2966 @@ +package cn.com.ebewin.ysr.dialog; + +import java.awt.Color; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; +import java.util.Vector; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JTable; +import javax.swing.RowSorter; +import javax.swing.SortOrder; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; + +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.Drawing; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.util.IOUtils; +import org.apache.poi.xssf.usermodel.XSSFClientAnchor; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCFormProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.iTextField; + +import cn.com.ebewin.ysr.util.CommonUtil; +import cn.com.ebewin.ysr.util.DialogUtil; +import cn.com.ebewin.ysr.util.FormUtil; +import cn.com.ebewin.ysr.util.TCUtil; +import cn.com.ebewin.ysr.util.UIUtil.ComponentInfo; +import cn.com.ebewin.ysr.util.UIUtil.JComboBoxInfo; +import cn.com.ebewin.ysr.util.UIUtil.JTableInfo; + +//import jxl.Workbook; +//import jxl.format.Alignment; +//import jxl.format.Border; +//import jxl.format.BorderLineStyle; +//import jxl.format.VerticalAlignment; +//import jxl.write.Label; +//import jxl.write.WritableCellFormat; +//import jxl.write.WritableFont; +//import jxl.write.WritableSheet; +//import jxl.write.WritableWorkbook; +//import jxl.write.WriteException; +//import jxl.write.WritableImage; + +@SuppressWarnings("deprecation") +public class ProblemBoardDialog extends JFrame { + private static final long serialVersionUID = 1L; + DialogUtil fu = new DialogUtil(this, "ۺϿ", "YSR8_PRRevisionSearchDialog"); + HashMap prRevisions = new HashMap(); + private JTable table; + + public ProblemBoardDialog(TCSession session) throws TCException { + // super(true); + + fu.initializeUI(session); + table = (JTable) fu.allComponentMap.get("a.31.11.11"); + + Comparator comparator = new Comparator() { + public int compare(Object arg0, Object arg1) { + try{ + int a = Integer.parseInt(arg0.toString()); + int b = Integer.parseInt(arg1.toString()); + return a-b; + }catch(NumberFormatException e){ + return 0; + } + } + }; + + table.setAutoCreateRowSorter(true); + ArrayList sortKeys = new ArrayList(); + sortKeys.add(new RowSorter.SortKey(2, SortOrder.ASCENDING)); + TableRowSorter sorter = new TableRowSorter(table.getModel()); + sorter.setComparator(0, comparator); + sorter.setSortKeys(sortKeys); + table.setRowSorter(sorter); + //lidy20180827Զ +// table.setDefaultRenderer(Object.class, new TableViewRenderer()); + { + ProblemBoardDialogTableColorRender tcr = new ProblemBoardDialogTableColorRender(); + HashMap bgc; + + bgc = new HashMap(); + bgc.put("ѹر", Color.GREEN); + tcr.allBackgroundInfos.put(35, bgc); + tcr.allBColorColumn.put(0, 35); + + bgc = new HashMap(); + bgc.put("", Color.PINK); + tcr.allBackgroundInfos.put(59, bgc); + tcr.allBColorColumn.put(5, 59); + + bgc = new HashMap(); + bgc.put("", Color.RED); + bgc.put("", Color.YELLOW); + bgc.put("", Color.GREEN); + tcr.allBackgroundInfos.put(2, bgc); + tcr.allBColorColumn.put(2, 2); + + bgc = new HashMap(); + bgc.put("ļװ", Color.RED); + bgc.put("֤", Color.RED); + bgc.put("", Color.RED); + tcr.allBackgroundInfos.put(34, bgc); + tcr.allBColorColumn.put(34, 34); + + table.setDefaultRenderer(Object.class, tcr); + } + + // TODOcenterToScreen(); + this.setLocationRelativeTo(null); + this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); + + loadRendering(); + addActionListener(); + setVisible(true); + } + + private void loadRendering() throws TCException { + // JTable table = (JTable)fu.allComponentMap.get("a.31.11.11"); + // JTableHeader header = table.getTableHeader(); + // header.postEvent(new ComponentEvent(header, )) + } + + private void addActionListener() { + JButton btn = (JButton) fu.allComponentMap.get("b.11.12.11"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + searchYSR8_PR(); + } + }); + + btn = (JButton) fu.allComponentMap.get("b.11.12.21"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + outputYSR8_PR(); + } + }); + + btn = (JButton) fu.allComponentMap.get("b.11.12.31"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + viewYSR8_PRPic(); + } + }); + + JTable table = (JTable) fu.allComponentMap.get("a.31.11.11"); + table.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(MouseEvent e) {// 굥ʱӦ +// System.out.println("mouseClicked------------------------------- "); + ViewSelInfo(); + } + }); + } + + @SuppressWarnings("unchecked") + private void searchYSR8_PR() { + prRevisions.clear(); + + JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.21.11.11"); + int rowCount = ci.dataTableModel.getRowCount(); + for (int i = rowCount - 1; i >= 0; i--) { + ci.dataTableModel.removeRow(i); + } + ci.dataTableModel.getDataVector().clear(); + ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.31.11.11"); + rowCount = ci.dataTableModel.getRowCount(); + for (int i = rowCount - 1; i >= 0; i--) { + ((DefaultTableModel) table.getModel()).removeRow(i); + } + ci.dataTableModel.getDataVector().clear(); + System.out.println("tableRow:"+ci.dataTableModel.getRowCount()); + + iTextField textField = (iTextField) fu.allComponentMap.get("c_ysr8_ProjectCode"); + String ysr8_ProjectCode = textField.getText().toString(); + + JComboBox cbx = (JComboBox) fu.allComponentMap.get("c_ysr8_Importance"); + ComponentInfo cii = fu.allComponentInfos.get("c_ysr8_Importance"); + String ysr8_Importance = cbx.getSelectedItem().toString(); + if (((JComboBoxInfo) cii).lovVal != null) { + Iterator iter = ((JComboBoxInfo) cii).lovVal.keySet().iterator(); + while (iter.hasNext()) { + String lovKey = iter.next(); + String lovValue = ((JComboBoxInfo) cii).lovVal.get(lovKey); + if (lovValue.equalsIgnoreCase(ysr8_Importance)) { + ysr8_Importance = lovKey; + break; + } + } + } + + cbx = (JComboBox) fu.allComponentMap.get("c_ysr8_ProblemStatus"); + cii = fu.allComponentInfos.get("c_ysr8_ProblemStatus"); + String ysr8_ProblemStatus = cbx.getSelectedItem().toString(); + if (((JComboBoxInfo) cii).lovVal != null) { + Iterator iter = ((JComboBoxInfo) cii).lovVal.keySet().iterator(); + while (iter.hasNext()) { + String lovKey = iter.next(); + String lovValue = ((JComboBoxInfo) cii).lovVal.get(lovKey); + if (lovValue.equalsIgnoreCase(ysr8_ProblemStatus)) { + ysr8_ProblemStatus = lovKey; + break; + } + } + } + + textField = (iTextField) fu.allComponentMap.get("c_ysr8_Submiter"); + String ysr8_Submiter = textField.getText().toString(); + + cbx = (JComboBox) fu.allComponentMap.get("c_ysr8_ProblemType"); + cii = fu.allComponentInfos.get("c_ysr8_ProblemType"); + String ysr8_ProblemType = cbx.getSelectedItem().toString(); + if (((JComboBoxInfo) cii).lovVal != null) { + Iterator iter = ((JComboBoxInfo) cii).lovVal.keySet().iterator(); + while (iter.hasNext()) { + String lovKey = iter.next(); + String lovValue = ((JComboBoxInfo) cii).lovVal.get(lovKey); + if (lovValue.equalsIgnoreCase(ysr8_ProblemType)) { + ysr8_ProblemType = lovKey; + break; + } + } + } + + DateButton db = (DateButton) fu.allComponentMap.get("c_ysr8_ProblemDate1"); + Date date = db.getDate(); + String ysr8_ProblemDate1 = ""; + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-d"); + if (date != null) { + ysr8_ProblemDate1 = sdf.format(date) + " 00:00"; + } + + db = (DateButton) fu.allComponentMap.get("c_ysr8_ProblemDate2"); + date = db.getDate(); + String ysr8_ProblemDate2 = ""; + if (date != null) { + ysr8_ProblemDate2 = sdf.format(date) + " 23:59"; + } + + { + Vector attrVec = new Vector(); + Vector valVec = new Vector(); + if (!ysr8_ProjectCode.isEmpty()) { + attrVec.add("ysr8_ProjectCode"); + valVec.add(ysr8_ProjectCode); + try { + String[] attrs = (String[]) attrVec.toArray(new String[attrVec.size()]); + String[] vals = (String[]) valVec.toArray(new String[attrVec.size()]); + TCComponent[] tcComponents = TCUtil.query(fu.session, "SearchProjectRevisionWithProjectCode", attrs, vals); + if (tcComponents != null && tcComponents.length > 0) { + TCComponentItemRevision psRevision = (TCComponentItemRevision) tcComponents[0]; + TCComponentForm psRevisionForm = TCUtil.getItemRevisionMasterForm(psRevision); + psRevisionForm.refresh(); + iTextField textfieldForm; + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ProjectManager"); + textfieldForm.setText(psRevisionForm.getProperty("ysr8_ProjectManager")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_Planner"); + textfieldForm.setText(psRevisionForm.getProperty("ysr8_Planner")); + } + } catch (TCException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } + } + } + + Vector attrVec = new Vector(); + Vector valVec = new Vector(); + if (!ysr8_ProjectCode.isEmpty()) { + attrVec.add("ysr8_ProjectCode"); + valVec.add(ysr8_ProjectCode); + } + if (!ysr8_Importance.isEmpty()) { + attrVec.add("ysr8_Importance"); + valVec.add(ysr8_Importance); + } + if (!ysr8_ProblemStatus.isEmpty()) { + attrVec.add("ysr8_ProblemStatus"); + valVec.add(ysr8_ProblemStatus); + } + if (!ysr8_Submiter.isEmpty()) { + attrVec.add("ysr8_Submiter"); + valVec.add(ysr8_Submiter); + } + if (!ysr8_ProblemType.isEmpty()) { + attrVec.add("ysr8_ProblemType"); + valVec.add(ysr8_ProblemType); + } + if (!ysr8_ProblemDate1.isEmpty()) { + attrVec.add("ysr8_ProblemDate1"); + valVec.add(ysr8_ProblemDate1); + } + if (!ysr8_ProblemDate2.isEmpty()) { + attrVec.add("ysr8_ProblemDate2"); + valVec.add(ysr8_ProblemDate2); + } + + try { + String[] attrs = (String[]) attrVec.toArray(new String[attrVec.size()]); + String[] vals = (String[]) valVec.toArray(new String[attrVec.size()]); + TCComponent[] tcComponents = TCUtil.query(fu.session, "SearchPRRevision", attrs, vals); + + //lidy20180824ȥδ߹̵Ķ + Vector tcComponents0 = new Vector<>(); + for(TCComponent TCComponent : tcComponents) { + // + AIFComponentContext[] parents = TCComponent.whereReferencedByTypeRelation(new String[] { "EPMTask" }, new String[] { "Fnd0EPMTarget" }); + if(parents.length==0) { + System.out.println(TCComponent); + } else { + tcComponents0.add(TCComponent); + } + } + tcComponents = new TCComponent[tcComponents0.size()]; + for(int i=0;i _prRevisions = new HashMap(); + Iterator> iter = prRevisions.entrySet().iterator(); + while (iter.hasNext()) { + Map.Entry entry = (Map.Entry) iter.next(); + _prRevisions.put((String) entry.getKey(), (TCComponentItemRevision) entry.getValue()); + } + prRevisions.clear(); + for (int i = 0; i < rowCount; i++) { + String oldIdx = table.getValueAt(i, 0).toString(); + String newIdx = (i + 1) + ""; + //System.out.println(i + "===========" + oldIdx + "====================new====" + newIdx); + table.setValueAt(newIdx, i, 0); + prRevisions.put(newIdx, _prRevisions.get(oldIdx)); + } + } + + private void searchYSR8_PR_Sub(TCComponent[] tcComponents) { + LinkedHashMap ysr8_ClassLovVal = TCUtil.getlovValues(fu.session, "YSR8_Pr03_LOV"); + JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.31.11.11"); + try { + Integer idx = 0; + for (int i = 0; i < tcComponents.length; i++) { + TCComponentItemRevision prRevision = (TCComponentItemRevision) tcComponents[i]; + String prId = prRevision.getProperty("item_id"); + System.out.println("⣺" + prId); + TCComponentForm prRevisionForm = TCUtil.getItemRevisionMasterForm(prRevision); + prRevisionForm.refresh(); + + String ysr8_TechStaffVal = prRevisionForm.getProperty("ysr8_TechStaff");// + + boolean bFind = false; + TCComponent[] context3 = prRevision.getRelatedComponents("YSR8_ChangeForm"); + String today = fu.getDateString(new Date()); + if (context3 != null && context3.length > 0) { + for (int j = 0; j < context3.length; j++) { + if (context3[j] instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem) context3[j]; + String objectType = item.getProperty("object_type"); + + if (objectType.equalsIgnoreCase("IJɹ")) { + bFind = true; + TCComponentItemRevision ecn1Revision = item.getLatestItemRevision(); + TCComponentForm ecn1RevisionForm = TCUtil.getItemRevisionMasterForm(ecn1Revision); + ecn1RevisionForm.refresh(); + + Vector vec = new Vector<>(); + vec.add((++idx) + "");// + vec.add(prRevisionForm.getProperty("ysr8_ProblemNo"));// + vec.add(prRevisionForm.getProperty("ysr8_Importance"));// Ҫ + vec.add(fu.getDateString(prRevisionForm.getDateProperty("ysr8_ProblemDate")));// ύ + vec.add(fu.getDateString(prRevisionForm.getDateProperty("ysr8_RequirementDate")));// ûҪ + vec.add(prRevisionForm.getProperty("ysr8_Submiter"));// ύ + vec.add(prRevisionForm.getProperty("ysr8_SubmitTimes"));// ύ + String ysr8_ReplyDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_ReplyDate")); + vec.add(ysr8_ReplyDate);// ظʱ + vec.add(prRevisionForm.getProperty("ysr8_StationNo"));// Ŀ + vec.add(prRevisionForm.getProperty("ysr8_ProblemExplain"));// ˵ + vec.add(prRevisionForm.getProperty("ysr8_ReasonAnalysis"));// ԭ + vec.add(prRevisionForm.getProperty("ysr8_ChangeMeasures"));// Ĵʩ + //20241113 ĵ + TCComponent[] comps = prRevision.getRelatedComponents("YSR8_ChangeForm"); +// String ecnId = ""; +// if(comps != null && comps.length > 0) { +// for (int k = 0; k < comps.length; k++) { +// if(comps[k].getType().equals("YSR8_ECN1")) { +// System.out.println("comps[k].getType()============"+comps[k].getType()); +// String item_id = comps[k].getStringProperty("item_id"); +// ecnId = item_id; +// System.out.println("item_id==="+item_id); +// } +// } +// } + String ecnId = item.getProperty("item_id"); + vec.add(ecnId == null?"":ecnId); + // IJɹidSetͼ + String[] drawingNo2 = ecn1RevisionForm.getFormTCProperty("ysr8_Ecn1PicNo").getStringArrayValue(); + Set idSet = new HashSet<>(); + if(drawingNo2.length>0) { + String[] problemID = ecn1RevisionForm.getFormTCProperty("ysr8_Ecn1SolveQueId").getStringArrayValue(); + for(int k=0; k0 && !idSet.contains(ysr8_DrawingNoVals[m])) { + continue; + } + ysr8_DrawingNoVal += ysr8_DrawingNoVals[m]; + ysr8_DrawingNoVal += ""; + } + if(ysr8_DrawingNoVal.length()>0) + vec.add(ysr8_DrawingNoVal.substring(0, ysr8_DrawingNoVal.length()-1));// ͼŻɹͺ + else + vec.add(ysr8_DrawingNoVal); + } + ////////////////////////////////// + vec.add(prRevisionForm.getProperty("ysr8_ChangeDept"));// ĵβ + vec.add(ysr8_TechStaffVal);// + String ysr8_TechPlanDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_TechPlanDate")); + vec.add(ysr8_TechPlanDate);// ļƻʱ + int techPlanDate = 0; + if (!ysr8_ReplyDate.isEmpty() && !ysr8_TechPlanDate.isEmpty()) { + techPlanDate = CommonUtil.getDaysBetween(ysr8_ReplyDate, ysr8_TechPlanDate); + } + String ysr8_TechFinishDate = fu.getDateString(ecn1RevisionForm.getDateProperty("ysr8_TechFinishDate")); + vec.add(ysr8_TechFinishDate);// ʵʱ + String techResult = ""; + int days = 0; + if (!ysr8_TechPlanDate.isEmpty() && !ysr8_TechFinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_TechPlanDate, ysr8_TechFinishDate); + if (days > 0) { + techResult = "NG"; + } else { + techResult = "OK"; + } + }else if (!ysr8_TechPlanDate.isEmpty() && ysr8_TechFinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_TechPlanDate, today); + if (days > 0) { + techResult = "NG"; + } else { + techResult = ""; + } + } + ////////////////////////////////// + vec.add(prRevisionForm.getProperty("ysr8_Purcher2"));// ɹ + String ysr8_PurchPlanDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_PurchPlanDate")); + vec.add(ysr8_PurchPlanDate);// ɹƻʱ + + // IJɹӹʵʱ +// String ysr8_PurchFinishDate = ecn1RevisionForm.getProperty("ysr8_PurchFinishDate"); + String ysr8_PurchFinishDate = ""; + if(drawingNo2.length>0) { + String[] Ecn1SolveQueId = ecn1RevisionForm.getFormTCProperty("ysr8_Ecn1SolveQueId").getStringArrayValue(); + String[] Ecn1GoodsId = ecn1RevisionForm.getFormTCProperty("ysr8_Ecn1GoodsId").getStringArrayValue(); + String[] MaterialID = ecn1RevisionForm.getFormTCProperty("ysr8_MaterialID").getStringArrayValue(); + Date[] subPurchFinishDate = ecn1RevisionForm.getFormTCProperty("ysr8_SubPurchFinishDate").getDateValueArray(); +// String purchFinishDate = ""; + for(int k=0; k0) + ysr8_PurchFinishDate = fu.getDateString(PurchFinishDate); + }else { + ysr8_PurchFinishDate = fu.getDateString(PurchFinishDate); + } + } else { + ysr8_PurchFinishDate = ""; + break; + } + } + } + }else + ysr8_PurchFinishDate = fu.getDateString(ecn1RevisionForm.getDateProperty("ysr8_PurchFinishDate")); + vec.add(ysr8_PurchFinishDate);// ɹʵʱ + String purchResult = "";//TODO Ƿ񰴼ƻ + int purchPlanDay = 0; + if(!ysr8_PurchPlanDate.isEmpty()) { + if(!ysr8_TechPlanDate.isEmpty()) + purchPlanDay = CommonUtil.getDaysBetween(ysr8_TechPlanDate, ysr8_PurchPlanDate); + else if(!ysr8_ReplyDate.isEmpty()) + purchPlanDay = CommonUtil.getDaysBetween(ysr8_ReplyDate, ysr8_PurchPlanDate); + + if (!ysr8_TechPlanDate.isEmpty() && techResult.equals("NG")) { + if (!ysr8_TechFinishDate.isEmpty() && purchPlanDay != 0) { + if(ysr8_PurchFinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_TechFinishDate, today) - purchPlanDay; + if (days <= 0) { + purchResult = ""; + } else { + purchResult = "NG"; + } + }else { + days = CommonUtil.getDaysBetween(ysr8_TechFinishDate, ysr8_PurchFinishDate) - purchPlanDay; + if (days <= 0) { + purchResult = "OK"; + } else { + purchResult = "NG"; + } + } + } + }else if(ysr8_TechPlanDate.isEmpty() || !ysr8_TechFinishDate.isEmpty()){ + if (!ysr8_PurchFinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_PurchPlanDate, ysr8_PurchFinishDate); + if (days > 0) { + purchResult = "NG"; + } else { + purchResult = "OK"; + } + }else{ + days = CommonUtil.getDaysBetween(ysr8_PurchPlanDate, today); + if (days > 0) { + purchResult = "NG"; + } else { + purchResult = ""; + } + } + } + } +// System.out.println("purchPlanDay:"+purchPlanDay+" days:"+days); +// vec.add(prRevisionForm.getProperty("ysr8_Machiner2"));// ӹ + vec.add("");// ӹ +// String ysr8_MachinPlanDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_MachinPlanDate")); + //vec.add(ysr8_MachinPlanDate);// ӹƻʱ + //lidy20180826IJɹӦвʾӹƻʱ20190520ӹ + vec.add("");// ӹƻʱ + vec.add("");// ӹʵʱ + ///////////////////////////////// + //20240722 + vec.add(prRevisionForm.getProperty("ysr8_ElecDebug2"));// + String ysr8_ElecDebug2PlanDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_ElecDebug2PlanDate")); + vec.add(ysr8_ElecDebug2PlanDate);// ƻʱ + String ysr8_ElecDebug2FinishDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_ElecDebug2FinishDate")); + vec.add(ysr8_ElecDebug2FinishDate);// ʵʱ + + vec.add(prRevisionForm.getProperty("ysr8_TechCenter"));// + String ysr8_TechCenterPlanDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_TechCenterPlanDate")); + vec.add(ysr8_TechCenterPlanDate);// ʱ + String ysr8_TechCenterFinishDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_TechCenterFinishDate")); + vec.add(ysr8_TechCenterFinishDate);// ʵʱ + + ////////////////////////////////// + vec.add(prRevisionForm.getProperty("ysr8_ImplementDept"));// ʵʩβ + vec.add(prRevisionForm.getProperty("ysr8_Engineer"));// ʵʩ + String ysr8_EnginePlanDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_EnginePlanDate")); + vec.add(ysr8_EnginePlanDate);// ʵʩƻʱ + int engineerPlanDay = 0; + if (!ysr8_PurchPlanDate.isEmpty() && !ysr8_EnginePlanDate.isEmpty()) { + engineerPlanDay = CommonUtil.getDaysBetween(ysr8_PurchPlanDate, ysr8_EnginePlanDate); + }else if(!ysr8_PurchPlanDate.isEmpty() && !ysr8_EnginePlanDate.isEmpty()) { + engineerPlanDay = CommonUtil.getDaysBetween(ysr8_PurchPlanDate, ysr8_EnginePlanDate); + } + String ysr8_FinishDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_FinishDate")); + vec.add(ysr8_FinishDate);// ʵʩʵʱ + String engineerResult = "";//TODO Ƿ񰴼ƻ + if (!ysr8_EnginePlanDate.isEmpty()) { + if (!ysr8_PurchPlanDate.isEmpty()) + engineerPlanDay = CommonUtil.getDaysBetween(ysr8_PurchPlanDate, ysr8_EnginePlanDate); + else if (!ysr8_TechPlanDate.isEmpty()) + engineerPlanDay = CommonUtil.getDaysBetween(ysr8_TechPlanDate, ysr8_EnginePlanDate); + else if (!ysr8_ReplyDate.isEmpty()) + engineerPlanDay = CommonUtil.getDaysBetween(ysr8_ReplyDate, ysr8_EnginePlanDate); + + if (!ysr8_PurchPlanDate.isEmpty()) { + if (purchResult.equals("NG") && !ysr8_PurchFinishDate.isEmpty()) { + if(!ysr8_FinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_PurchFinishDate, ysr8_FinishDate) - engineerPlanDay; + if (days <= 0) { + engineerResult = "OK"; + } else { + engineerResult = "NG"; + } + }else { + days = CommonUtil.getDaysBetween(ysr8_PurchFinishDate, today) - engineerPlanDay; + if (days <= 0) { + engineerResult = ""; + } else { + engineerResult = "NG"; + } + } + } else if (purchResult.equals("OK")) { + if(!ysr8_FinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_EnginePlanDate, ysr8_FinishDate); + if (days <= 0) { + engineerResult = "OK"; + } else { + engineerResult = "NG"; + } + }else{ + days = CommonUtil.getDaysBetween(ysr8_EnginePlanDate, today); + if (days <= 0) { + engineerResult = ""; + } else { + engineerResult = "NG"; + } + } + } else if (ysr8_PurchFinishDate.isEmpty()) { + engineerResult = ""; + } + }else if (!ysr8_TechPlanDate.isEmpty()) { + if (techResult.equals("NG") && !ysr8_TechFinishDate.isEmpty()) { + if(!ysr8_FinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_TechFinishDate, ysr8_FinishDate) - engineerPlanDay; + if (days <= 0) { + engineerResult = "OK"; + } else { + engineerResult = "NG"; + } + }else{ + days = CommonUtil.getDaysBetween(ysr8_TechFinishDate, today) - engineerPlanDay; + if (days <= 0) { + engineerResult = ""; + } else { + engineerResult = "NG"; + } + } + } else if (techResult.equals("OK")) { + if(!ysr8_FinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_EnginePlanDate, ysr8_FinishDate); + if (days <= 0) { + engineerResult = "OK"; + } else { + engineerResult = "NG"; + } + }else{ + days = CommonUtil.getDaysBetween(ysr8_EnginePlanDate, today); + if (days <= 0) { + engineerResult = ""; + } else { + engineerResult = "NG"; + } + } + } else if (ysr8_TechFinishDate.isEmpty()) { + engineerResult = ""; + } + }else { + if(!ysr8_FinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_EnginePlanDate, ysr8_FinishDate); + if (days <= 0) { + engineerResult = "OK"; + } else { + engineerResult = "NG"; + } + }else{ + days = CommonUtil.getDaysBetween(ysr8_EnginePlanDate, today); + if (days <= 0) { + engineerResult = ""; + } else { + engineerResult = "NG"; + } + } + } + } + ////////////////////////////////// + vec.add(prRevisionForm.getProperty("ysr8_ChangeStatus"));// ĺ״̬ + vec.add(prRevisionForm.getProperty("ysr8_ProblemStatus"));// + vec.add("");// ע + vec.add(prRevisionForm.getProperty("ysr8_ProblemType"));// + String ysr8_ClassVal = prRevisionForm.getProperty("ysr8_Class"); + String ysr8_PartVal = prRevisionForm.getProperty("ysr8_Part"); + String ysr8_ProjectVal = prRevisionForm.getProperty("ysr8_Project"); + Iterator iter = ysr8_ClassLovVal.keySet().iterator(); + while (iter.hasNext()) { + String lovKey = iter.next(); + String lovValue = ysr8_ClassLovVal.get(lovKey); + if (lovValue.equalsIgnoreCase(ysr8_ClassVal)) { + LinkedHashMap ysr8_PartLovVal = TCUtil.getlovValues(fu.session, lovKey); + Iterator iter1 = ysr8_PartLovVal.keySet().iterator(); + while (iter1.hasNext()) { + String lovKey1 = iter1.next(); + String lovValue1 = ysr8_PartLovVal.get(lovKey1); + if (lovKey1.equalsIgnoreCase(ysr8_PartVal)) { + ysr8_PartVal = lovValue1; + LinkedHashMap ysr8_ProjectLovVal = TCUtil.getlovValues(fu.session, lovKey1); + Iterator iter2 = ysr8_ProjectLovVal.keySet().iterator(); + while (iter2.hasNext()) { + String lovKey2 = iter2.next(); + String lovValue2 = ysr8_ProjectLovVal.get(lovKey2); + if (lovKey2.equalsIgnoreCase(ysr8_ProjectVal)) { + ysr8_ProjectVal = lovValue2; + break; + } + } + break; + } + } + break; + } + } + vec.add(ysr8_ClassVal);// + vec.add(ysr8_PartVal);// + vec.add(ysr8_ProjectVal);// Ŀ + ////////////////////////////////// + vec.add(Integer.toString(techPlanDate));// ʱƻ + vec.add(techResult);// Ƿ񰴼ƻ + vec.add(ecn1RevisionForm.getProperty("ysr8_TechReasonAnalysis") + "" + ecn1RevisionForm.getProperty("ysr8_TechReasonDesc"));// ԭ + + vec.add(Integer.toString(purchPlanDay));// ɹʱƻ + vec.add(purchResult);// ɹǷ񰴼ƻ + vec.add(ecn1RevisionForm.getProperty("ysr8_PurchReasonDesc"));// ɹԭ + + vec.add("");// ӹʱƻ + vec.add("");// ӹǷ񰴼ƻ + vec.add("");// ӹԭ + ////////////////////////////////// + vec.add(Integer.toString(engineerPlanDay));// ʵʩʱƻ + vec.add(engineerResult);// ʵʩǷ񰴼ƻ + vec.add(prRevisionForm.getProperty("ysr8_ImplementReason") + "" + prRevisionForm.getProperty("ysr8_ReasonAnalysis2"));// ʵʩԭ + + + + int dqPlanDate = 0; + if (!ysr8_ReplyDate.isEmpty() && !ysr8_ElecDebug2PlanDate.isEmpty()) { + dqPlanDate = CommonUtil.getDaysBetween(ysr8_ReplyDate, ysr8_ElecDebug2PlanDate); + } + vec.add(Integer.toString(dqPlanDate)); + + String dqResult = ""; + int dqDays = 0; + if (!ysr8_ElecDebug2PlanDate.isEmpty() && !ysr8_ElecDebug2FinishDate.isEmpty()) { + dqDays = CommonUtil.getDaysBetween(ysr8_ElecDebug2PlanDate, ysr8_ElecDebug2FinishDate); + if (dqDays > 0) { + dqResult = "NG"; + } else { + dqResult = "OK"; + } + }else if (!ysr8_ElecDebug2PlanDate.isEmpty() && ysr8_ElecDebug2FinishDate.isEmpty()) { + dqDays = CommonUtil.getDaysBetween(ysr8_ElecDebug2PlanDate, today); + if (dqDays > 0) { + dqResult = "NG"; + } else { + dqResult = ""; + } + } + vec.add(dqResult); + vec.add(prRevisionForm.getProperty("ysr8_ElecReason")); + + + + + int jszxPlanDate = 0; + if (!ysr8_ReplyDate.isEmpty() && !ysr8_TechCenterPlanDate.isEmpty()) { + jszxPlanDate = CommonUtil.getDaysBetween(ysr8_ReplyDate, ysr8_TechCenterPlanDate); + } + vec.add(Integer.toString(jszxPlanDate)); + + String jszxResult = ""; + int jszxDays = 0; + if (!ysr8_TechCenterPlanDate.isEmpty() && !ysr8_TechCenterFinishDate.isEmpty()) { + jszxDays = CommonUtil.getDaysBetween(ysr8_TechCenterPlanDate, ysr8_TechCenterFinishDate); + if (jszxDays > 0) { + jszxResult = "NG"; + } else { + jszxResult = "OK"; + } + }else if (!ysr8_TechCenterPlanDate.isEmpty() && ysr8_TechCenterFinishDate.isEmpty()) { + jszxDays = CommonUtil.getDaysBetween(ysr8_TechCenterPlanDate, today); + if (jszxDays > 0) { + jszxResult = "NG"; + } else { + jszxResult = ""; + } + } + vec.add(jszxResult); + vec.add(prRevisionForm.getProperty("ysr8_TechCenterReason")); + + + + + ////////////////////////////////// + { + String hasPic = ""; + TCComponent[] components = prRevision.getRelatedComponents("IMAN_specification"); + if (components != null && components.length > 0) { + for (int k = 0; k < components.length; k++) { + TCComponentDataset dataset = (TCComponentDataset) components[k]; + String object_typeVal = dataset.getProperty("object_type"); + if (object_typeVal.equalsIgnoreCase("JPEG") || + // object_typeVal.equalsIgnoreCase("λͼ") || + object_typeVal.equalsIgnoreCase("GIF") || object_typeVal.equalsIgnoreCase("Image") || object_typeVal.equalsIgnoreCase("ͼ") + || object_typeVal.equalsIgnoreCase("Яʽͼͼ")) { + hasPic = ""; + break; + } + } + } + vec.add(hasPic);// ǷϴͼƬ + } + + for (int k = 0; k < vec.size(); k++) { + if (vec.get(k).isEmpty()) { + vec.set(k, "-"); + } + } + ci.dataTableModel.addRow(vec); + // prRevisions.add(prRevision); +// System.out.println(vec.get(0) + "=======" + prId); + prRevisions.put(vec.get(0), prRevision); + } else if (objectType.equalsIgnoreCase("ͼֽĵ")) {/////////////////////////////////////////////////// + bFind = true; + TCComponentItemRevision ecn2Revision = item.getLatestItemRevision(); + TCComponentForm ecn2RevisionForm = TCUtil.getItemRevisionMasterForm(ecn2Revision); + ecn2RevisionForm.refresh(); + + Vector vec = new Vector<>(); + vec.add((++idx) + "");// + vec.add(prRevisionForm.getProperty("ysr8_ProblemNo"));// + vec.add(prRevisionForm.getProperty("ysr8_Importance"));// Ҫ + vec.add(fu.getDateString(prRevisionForm.getDateProperty("ysr8_ProblemDate")));// ύ + vec.add(fu.getDateString(prRevisionForm.getDateProperty("ysr8_RequirementDate")));// ûҪ + vec.add(prRevisionForm.getProperty("ysr8_Submiter"));// ύ˹ID + vec.add(prRevisionForm.getProperty("ysr8_SubmitTimes"));// ύ + String ysr8_ReplyDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_ReplyDate")); + vec.add(ysr8_ReplyDate);// ظʱ + vec.add(prRevisionForm.getProperty("ysr8_StationNo"));// λ/վ + vec.add(prRevisionForm.getProperty("ysr8_ProblemExplain"));// ˵ + vec.add(prRevisionForm.getProperty("ysr8_ReasonAnalysis"));// ԭ + vec.add(prRevisionForm.getProperty("ysr8_ChangeMeasures"));// Ĵʩ + //20241113 ĵ +// TCComponent[] comps = prRevision.getRelatedComponents("YSR8_ChangeForm"); +// String ecnId = ""; +// if(comps != null && comps.length > 0) { +// for (int k = 0; k < comps.length; k++) { +// if(comps[k].getType().equals("YSR8_ECN2")) { +// System.out.println("comps[k].getType()============"+comps[k].getType()); +// String item_id = comps[k].getStringProperty("item_id"); +// ecnId = item_id; +// System.out.println("item_id==="+item_id); +// } +// } +// } + String ecnId = item.getProperty("item_id"); + vec.add(ecnId == null?"":ecnId); + //TODO ͼֽĵidSetͼ + String[] materialID2 = ecn2RevisionForm.getFormTCProperty("ysr8_Ecn2Id").getStringArrayValue(); + Set idSet = new HashSet<>(); + if(materialID2.length>0) { + String[] problemID = ecn2RevisionForm.getFormTCProperty("ysr8_Ecn2SolveQueId").getStringArrayValue(); + for(int k=0; k0 && !idSet.contains(ysr8_MaterialIDVals[m])) { + continue; + } + ysr8_MaterialIDVal += ysr8_MaterialIDVals[m]; + ysr8_MaterialIDVal += ""; + } + if(ysr8_MaterialIDVal.length()>0) + vec.add(ysr8_MaterialIDVal.substring(0, ysr8_MaterialIDVal.length()-1));// ͼŻɹͺ + else + vec.add(ysr8_MaterialIDVal); + } + ////////////////////////////////// + vec.add(prRevisionForm.getProperty("ysr8_ChangeDept"));// ĵβ + vec.add(ysr8_TechStaffVal);// + String ysr8_TechPlanDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_TechPlanDate")); + vec.add(ysr8_TechPlanDate);// ļƻʱ + int techPlanDate = 0; + if (!ysr8_ReplyDate.isEmpty() && !ysr8_TechPlanDate.isEmpty()) { + techPlanDate = CommonUtil.getDaysBetween(ysr8_ReplyDate, ysr8_TechPlanDate); + } + String ysr8_TechFinishDate = fu.getDateString(ecn2RevisionForm.getDateProperty("ysr8_TechFinishDate")); + vec.add(ysr8_TechFinishDate);// ʵʱ + String techResult = ""; + int days = 0; + if (!ysr8_TechPlanDate.isEmpty() && !ysr8_TechFinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_TechPlanDate, ysr8_TechFinishDate); + if (days > 0) { + techResult = "NG"; + } else { + techResult = "OK"; + } + }else if (!ysr8_TechPlanDate.isEmpty() && ysr8_TechFinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_TechPlanDate, today); + if (days > 0) { + techResult = "NG"; + } else { + techResult = ""; + } + } + ////////////////////////////////// +// vec.add(prRevisionForm.getProperty("ysr8_Purcher2"));// ɹ + vec.add("");// ɹ +// String ysr8_PurchPlanDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_PurchPlanDate")); + //vec.add(ysr8_PurchPlanDate);// ɹƻʱ + //lidy20180826ͼֽĵӦвʾɹƻʱ20190520ɹ + vec.add("");// ɹƻʱ + vec.add("");// ɹʵʱ + ////////////////////////////////// + vec.add(prRevisionForm.getProperty("ysr8_Machiner2"));// ӹ + String ysr8_MachinPlanDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_MachinPlanDate")); + vec.add(ysr8_MachinPlanDate);// ӹƻʱ + //TODO ͼֽĵӹʵʱ + String ysr8_PurchFinishDate = ""; + if(materialID2.length>0) { + String[] Ecn2SolveQueId = ecn2RevisionForm.getFormTCProperty("ysr8_Ecn2SolveQueId").getStringArrayValue(); + String[] Ecn2Id = ecn2RevisionForm.getFormTCProperty("ysr8_Ecn2Id").getStringArrayValue(); + String[] subChangeScheme = ecn2RevisionForm.getFormTCProperty("ysr8_SubChangeScheme").getStringArrayValue(); + String[] MaterialID = ecn2RevisionForm.getFormTCProperty("ysr8_MaterialID").getStringArrayValue(); + Date[] subPurchFinishDate = ecn2RevisionForm.getFormTCProperty("ysr8_SubPurchFinishDate").getDateValueArray(); +// String purchFinishDate = ""; + TABLE2:for(int k=0; k0) + ysr8_PurchFinishDate = fu.getDateString(PurchFinishDate); + }else { + ysr8_PurchFinishDate = fu.getDateString(PurchFinishDate); + } + } + } + } + }else + ysr8_PurchFinishDate = fu.getDateString(ecn2RevisionForm.getDateProperty("ysr8_PurchFinishDate")); + + vec.add(ysr8_PurchFinishDate);// ӹʵʱ + String machinResult = "";//TODO Ƿ񰴼ƻ + int machinPlanDay = 0; + if(!ysr8_MachinPlanDate.isEmpty()) { + if(!ysr8_TechPlanDate.isEmpty()) + machinPlanDay = CommonUtil.getDaysBetween(ysr8_TechPlanDate, ysr8_MachinPlanDate); + else if(!ysr8_ReplyDate.isEmpty()) + machinPlanDay = CommonUtil.getDaysBetween(ysr8_ReplyDate, ysr8_MachinPlanDate); + + if (!ysr8_TechPlanDate.isEmpty() && techResult.equals("NG")) { + if (!ysr8_TechFinishDate.isEmpty() && machinPlanDay != 0) { + if(ysr8_PurchFinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_TechFinishDate, today) - machinPlanDay; + if (days <= 0) { + machinResult = ""; + } else { + machinResult = "NG"; + } + }else { +// System.out.println("days:"+CommonUtil.getDaysBetween(ysr8_TechFinishDate, ysr8_PurchFinishDate)+"=="+machinPlanDay); + days = CommonUtil.getDaysBetween(ysr8_TechFinishDate, ysr8_PurchFinishDate) - machinPlanDay; + if (days <= 0) { + machinResult = "OK"; + } else { + machinResult = "NG"; + } + } + } + }else if(ysr8_TechPlanDate.isEmpty() || !ysr8_TechFinishDate.isEmpty()){ + if (!ysr8_PurchFinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_MachinPlanDate, ysr8_PurchFinishDate); + if (days > 0) { + machinResult = "NG"; + } else { + machinResult = "OK"; + } + }else{ + days = CommonUtil.getDaysBetween(ysr8_MachinPlanDate, today); + if (days > 0) { + machinResult = "NG"; + } else { + machinResult = ""; + } + } + } + } +// System.out.println("purchPlanDay:"+machinPlanDay+" days:"+days); + ///////////////////////////////// + //20240722 + vec.add(prRevisionForm.getProperty("ysr8_ElecDebug2"));// + String ysr8_ElecDebug2PlanDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_ElecDebug2PlanDate")); + vec.add(ysr8_ElecDebug2PlanDate);// ƻʱ + String ysr8_ElecDebug2FinishDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_ElecDebug2FinishDate")); + vec.add(ysr8_ElecDebug2FinishDate);// ʵʱ + + vec.add(prRevisionForm.getProperty("ysr8_TechCenter"));// + String ysr8_TechCenterPlanDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_TechCenterPlanDate")); + vec.add(ysr8_TechCenterPlanDate);// ʱ + String ysr8_TechCenterFinishDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_TechCenterFinishDate")); + vec.add(ysr8_TechCenterFinishDate);// ʵʱ + ////////////////////////////////// + vec.add(prRevisionForm.getProperty("ysr8_ImplementDept"));// ʵʩβ + vec.add(prRevisionForm.getProperty("ysr8_Engineer"));// ʵʩ + String ysr8_EnginePlanDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_EnginePlanDate")); + vec.add(ysr8_EnginePlanDate);// ʵʩƻʱ + int engineerPlanDay = 0; + String ysr8_FinishDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_FinishDate")); + vec.add(ysr8_FinishDate);// ʵʩʵʱ + String engineerResult = "";//TODO Ƿ񰴼ƻ + if (!ysr8_EnginePlanDate.isEmpty()) { + if (!ysr8_MachinPlanDate.isEmpty()) + engineerPlanDay = CommonUtil.getDaysBetween(ysr8_MachinPlanDate, ysr8_EnginePlanDate); + else if (!ysr8_TechPlanDate.isEmpty()) + engineerPlanDay = CommonUtil.getDaysBetween(ysr8_TechPlanDate, ysr8_EnginePlanDate); + else if (!ysr8_ReplyDate.isEmpty()) + engineerPlanDay = CommonUtil.getDaysBetween(ysr8_ReplyDate, ysr8_EnginePlanDate); + + if (!ysr8_MachinPlanDate.isEmpty()) { + if (machinResult.equals("NG") && !ysr8_PurchFinishDate.isEmpty()) { + if(!ysr8_FinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_PurchFinishDate, ysr8_FinishDate) - engineerPlanDay; + if (days <= 0) { + engineerResult = "OK"; + } else { + engineerResult = "NG"; + } + }else { + days = CommonUtil.getDaysBetween(ysr8_PurchFinishDate, today) - engineerPlanDay; + if (days <= 0) { + engineerResult = ""; + } else { + engineerResult = "NG"; + } + } + } else if (machinResult.equals("OK")) { + if(!ysr8_FinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_EnginePlanDate, ysr8_FinishDate); + if (days <= 0) { + engineerResult = "OK"; + } else { + engineerResult = "NG"; + } + }else{ + days = CommonUtil.getDaysBetween(ysr8_EnginePlanDate, today); + if (days <= 0) { + engineerResult = ""; + } else { + engineerResult = "NG"; + } + } + } else if (ysr8_PurchFinishDate.isEmpty()) { + engineerResult = ""; + } + }else if (!ysr8_TechPlanDate.isEmpty()) { + if (techResult.equals("NG") && !ysr8_TechFinishDate.isEmpty()) { + if(!ysr8_FinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_TechFinishDate, ysr8_FinishDate) - engineerPlanDay; + if (days <= 0) { + engineerResult = "OK"; + } else { + engineerResult = "NG"; + } + }else{ + days = CommonUtil.getDaysBetween(ysr8_TechFinishDate, today) - engineerPlanDay; + if (days <= 0) { + engineerResult = ""; + } else { + engineerResult = "NG"; + } + } + } else if (techResult.equals("OK")) { + if(!ysr8_FinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_EnginePlanDate, ysr8_FinishDate); + if (days <= 0) { + engineerResult = "OK"; + } else { + engineerResult = "NG"; + } + }else{ + days = CommonUtil.getDaysBetween(ysr8_EnginePlanDate, today); + if (days <= 0) { + engineerResult = ""; + } else { + engineerResult = "NG"; + } + } + } else if (ysr8_TechFinishDate.isEmpty()) { + engineerResult = ""; + } + }else { + if(!ysr8_FinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_EnginePlanDate, ysr8_FinishDate); + if (days <= 0) { + engineerResult = "OK"; + } else { + engineerResult = "NG"; + } + }else{ + days = CommonUtil.getDaysBetween(ysr8_EnginePlanDate, today); + if (days <= 0) { + engineerResult = ""; + } else { + engineerResult = "NG"; + } + } + } + } + ////////////////////////////////// + vec.add(prRevisionForm.getProperty("ysr8_ChangeStatus"));// ĺ״̬ + vec.add(prRevisionForm.getProperty("ysr8_ProblemStatus"));// + vec.add("");// ע + vec.add(prRevisionForm.getProperty("ysr8_ProblemType"));// + String ysr8_ClassVal = prRevisionForm.getProperty("ysr8_Class"); + String ysr8_PartVal = prRevisionForm.getProperty("ysr8_Part"); + String ysr8_ProjectVal = prRevisionForm.getProperty("ysr8_Project"); + Iterator iter = ysr8_ClassLovVal.keySet().iterator(); + while (iter.hasNext()) { + String lovKey = iter.next(); + String lovValue = ysr8_ClassLovVal.get(lovKey); + if (lovValue.equalsIgnoreCase(ysr8_ClassVal)) { + LinkedHashMap ysr8_PartLovVal = TCUtil.getlovValues(fu.session, lovKey); + Iterator iter1 = ysr8_PartLovVal.keySet().iterator(); + while (iter1.hasNext()) { + String lovKey1 = iter1.next(); + String lovValue1 = ysr8_PartLovVal.get(lovKey1); + if (lovKey1.equalsIgnoreCase(ysr8_PartVal)) { + ysr8_PartVal = lovValue1; + LinkedHashMap ysr8_ProjectLovVal = TCUtil.getlovValues(fu.session, lovKey1); + Iterator iter2 = ysr8_ProjectLovVal.keySet().iterator(); + while (iter2.hasNext()) { + String lovKey2 = iter2.next(); + String lovValue2 = ysr8_ProjectLovVal.get(lovKey2); + if (lovKey2.equalsIgnoreCase(ysr8_ProjectVal)) { + ysr8_ProjectVal = lovValue2; + break; + } + } + break; + } + } + break; + } + } + vec.add(ysr8_ClassVal);// + vec.add(ysr8_PartVal);// + vec.add(ysr8_ProjectVal);// Ŀ + ////////////////////////////////// + vec.add(Integer.toString(techPlanDate));// ʱƻ + vec.add(techResult);// Ƿ񰴼ƻ + vec.add(ecn2RevisionForm.getProperty("ysr8_TechReasonAnalysis") + "" + ecn2RevisionForm.getProperty("ysr8_TechReasonDesc"));// ԭ + + vec.add("");// ɹʱƻ + vec.add("");// ɹǷ񰴼ƻ + vec.add("");// ɹԭ + + vec.add(Integer.toString(machinPlanDay));// ӹʱƻ + vec.add(machinResult);// ӹǷ񰴼ƻ + vec.add(ecn2RevisionForm.getProperty("ysr8_PurchReasonDesc"));// ӹԭ + ////////////////////////////////// + vec.add(Integer.toString(engineerPlanDay));// ʵʩʱƻ + vec.add(engineerResult);// ʵʩǷ񰴼ƻ + vec.add(prRevisionForm.getProperty("ysr8_ImplementReason") + "" + prRevisionForm.getProperty("ysr8_ReasonAnalysis2"));// ʵʩԭ + + int dqPlanDate = 0; + if (!ysr8_ReplyDate.isEmpty() && !ysr8_ElecDebug2PlanDate.isEmpty()) { + dqPlanDate = CommonUtil.getDaysBetween(ysr8_ReplyDate, ysr8_ElecDebug2PlanDate); + } + vec.add(Integer.toString(dqPlanDate)); + + String dqResult = ""; + int dqDays = 0; + if (!ysr8_ElecDebug2PlanDate.isEmpty() && !ysr8_ElecDebug2FinishDate.isEmpty()) { + dqDays = CommonUtil.getDaysBetween(ysr8_ElecDebug2PlanDate, ysr8_ElecDebug2FinishDate); + if (dqDays > 0) { + dqResult = "NG"; + } else { + dqResult = "OK"; + } + }else if (!ysr8_ElecDebug2PlanDate.isEmpty() && ysr8_ElecDebug2FinishDate.isEmpty()) { + dqDays = CommonUtil.getDaysBetween(ysr8_ElecDebug2PlanDate, today); + if (dqDays > 0) { + dqResult = "NG"; + } else { + dqResult = ""; + } + } + vec.add(dqResult); + vec.add(prRevisionForm.getProperty("ysr8_ElecReason")); + + + + + int jszxPlanDate = 0; + if (!ysr8_ReplyDate.isEmpty() && !ysr8_TechCenterPlanDate.isEmpty()) { + jszxPlanDate = CommonUtil.getDaysBetween(ysr8_ReplyDate, ysr8_TechCenterPlanDate); + } + vec.add(Integer.toString(jszxPlanDate)); + + String jszxResult = ""; + int jszxDays = 0; + if (!ysr8_TechCenterPlanDate.isEmpty() && !ysr8_TechCenterFinishDate.isEmpty()) { + jszxDays = CommonUtil.getDaysBetween(ysr8_TechCenterPlanDate, ysr8_TechCenterFinishDate); + if (jszxDays > 0) { + jszxResult = "NG"; + } else { + jszxResult = "OK"; + } + }else if (!ysr8_TechCenterPlanDate.isEmpty() && ysr8_TechCenterFinishDate.isEmpty()) { + jszxDays = CommonUtil.getDaysBetween(ysr8_TechCenterPlanDate, today); + if (jszxDays > 0) { + jszxResult = "NG"; + } else { + jszxResult = ""; + } + } + vec.add(jszxResult); + vec.add(prRevisionForm.getProperty("ysr8_TechCenterReason")); + + + ////////////////////////////////// + { + String hasPic = ""; + TCComponent[] components = prRevision.getRelatedComponents("IMAN_specification"); + if (components != null && components.length > 0) { + for (int k = 0; k < components.length; k++) { + if(components[k] instanceof TCComponentDataset) {//lidy20190305 + TCComponentDataset dataset = (TCComponentDataset) components[k]; + String object_typeVal = dataset.getProperty("object_type"); + if (object_typeVal.equalsIgnoreCase("JPEG") || + // object_typeVal.equalsIgnoreCase("λͼ") || + object_typeVal.equalsIgnoreCase("GIF") || object_typeVal.equalsIgnoreCase("Image") || object_typeVal.equalsIgnoreCase("ͼ") + || object_typeVal.equalsIgnoreCase("Яʽͼͼ")) { + hasPic = ""; + break; + } + } + } + } + vec.add(hasPic);// ǷϴͼƬ + } + + for (int k = 0; k < vec.size(); k++) { + if (vec.get(k).isEmpty()) { + vec.set(k, "-"); + } + } + ci.dataTableModel.addRow(vec); + // prRevisions.add(prRevision); +// System.out.println(vec.get(0) + "=======" + prId); + prRevisions.put(vec.get(0), prRevision); + } else if (objectType.equalsIgnoreCase("IJɹ")) {/////////////////////////////////////////////////// + bFind = true; + TCComponentItemRevision ecn3Revision = item.getLatestItemRevision(); + TCComponentForm ecn3RevisionForm = TCUtil.getItemRevisionMasterForm(ecn3Revision); + ecn3RevisionForm.refresh(); + + Vector vec = new Vector<>(); + vec.add((++idx) + "");// + vec.add(prRevisionForm.getProperty("ysr8_ProblemNo"));// + vec.add(prRevisionForm.getProperty("ysr8_Importance"));// Ҫ + vec.add(fu.getDateString(prRevisionForm.getDateProperty("ysr8_ProblemDate")));// ύ + vec.add(fu.getDateString(prRevisionForm.getDateProperty("ysr8_RequirementDate")));// ûҪ + vec.add(prRevisionForm.getProperty("ysr8_Submiter"));// ύ˹ID + vec.add(prRevisionForm.getProperty("ysr8_SubmitTimes"));// ύ + String ysr8_ReplyDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_ReplyDate")); + vec.add(ysr8_ReplyDate);// ظʱ + vec.add(prRevisionForm.getProperty("ysr8_Statiodayso"));// λ/վ + vec.add(prRevisionForm.getProperty("ysr8_ProblemExplain"));// ˵ + vec.add(prRevisionForm.getProperty("ysr8_ReasonAnalysis"));// ԭ + vec.add(prRevisionForm.getProperty("ysr8_ChangeMeasures"));// Ĵʩ + //20241113 ĵ +// TCComponent[] comps = prRevision.getRelatedComponents("YSR8_ChangeForm"); +// String ecnId = ""; +// if(comps != null && comps.length > 0) { +// for (int k = 0; k < comps.length; k++) { +// if(comps[k].getType().equals("YSR8_ECN3")) { +// System.out.println("comps[k].getType()============"+comps[k].getType()); +// String item_id = comps[k].getStringProperty("item_id"); +// ecnId = item_id; +// System.out.println("item_id==="+item_id); +// } +// } +// } + String ecnId = item.getProperty("item_id"); + vec.add(ecnId == null?"":ecnId); + //TODO IJɹidSetͼ + String[] drawingNo2 = ecn3RevisionForm.getFormTCProperty("ysr8_Ecn3PicNo").getStringArrayValue(); + Set idSet = new HashSet<>(); + if(drawingNo2.length>0) { + String[] problemID = ecn3RevisionForm.getFormTCProperty("ysr8_Ecn3SolveQueId").getStringArrayValue(); + for(int k=0; k0 && !idSet.contains(ysr8_DrawingNoVals[m])) { + continue; + } + ysr8_DrawingNoVal += ysr8_DrawingNoVals[m]; + ysr8_DrawingNoVal += ""; + } + if(ysr8_DrawingNoVal.length()>0) + vec.add(ysr8_DrawingNoVal.substring(0, ysr8_DrawingNoVal.length()-1));// ͼŻɹͺ + else + vec.add(ysr8_DrawingNoVal); + } + ////////////////////////////////// + vec.add(prRevisionForm.getProperty("ysr8_ChangeDept"));// ĵβ + vec.add(ysr8_TechStaffVal);// + String ysr8_TechPlanDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_TechPlanDate")); + vec.add(ysr8_TechPlanDate);// ļƻʱ + int techPlanDate = 0; + if (!ysr8_ReplyDate.isEmpty() && !ysr8_TechPlanDate.isEmpty()) { + techPlanDate = CommonUtil.getDaysBetween(ysr8_ReplyDate, ysr8_TechPlanDate); + } + String ysr8_TechFinishDate = fu.getDateString(ecn3RevisionForm.getDateProperty("ysr8_TechFinishDate")); + vec.add(ysr8_TechFinishDate);// ʵʱ + String techResult = ""; + int days = 0; + if (!ysr8_TechPlanDate.isEmpty() && !ysr8_TechFinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_TechPlanDate, ysr8_TechFinishDate); + if (days > 0) { + techResult = "NG"; + } else { + techResult = "OK"; + } + }else if (!ysr8_TechPlanDate.isEmpty() && ysr8_TechFinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_TechPlanDate, today); + if (days > 0) { + techResult = "NG"; + } else { + techResult = ""; + } + } + ////////////////////////////////// + vec.add(prRevisionForm.getProperty("ysr8_Purcher2"));// ɹ + String ysr8_PurchPlanDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_PurchPlanDate")); + vec.add(ysr8_PurchPlanDate);// ɹƻʱ + + //TODO IJɹӹʵʱ +// String ysr8_PurchFinishDate = ecn3RevisionForm.getProperty("ysr8_PurchFinishDate"); + String ysr8_PurchFinishDate = ""; + if(drawingNo2.length>0) { + String[] Ecn3SolveQueId = ecn3RevisionForm.getFormTCProperty("ysr8_Ecn3SolveQueId").getStringArrayValue(); + String[] Ecn3GoodsId = ecn3RevisionForm.getFormTCProperty("ysr8_Ecn3GoodsId").getStringArrayValue(); + String[] MaterialID = ecn3RevisionForm.getFormTCProperty("ysr8_MaterialID").getStringArrayValue(); + Date[] subPurchFinishDate = ecn3RevisionForm.getFormTCProperty("ysr8_SubPurchFinishDate").getDateValueArray(); +// String purchFinishDate = ""; + for(int k=0; k0) + ysr8_PurchFinishDate = fu.getDateString(PurchFinishDate); + }else { + ysr8_PurchFinishDate = fu.getDateString(PurchFinishDate); + } + } else { + ysr8_PurchFinishDate = ""; + break; + } + } + } + }else + ysr8_PurchFinishDate = fu.getDateString(ecn3RevisionForm.getDateProperty("ysr8_PurchFinishDate")); + vec.add(ysr8_PurchFinishDate);// ɹʵʱ + String purchResult = "";//TODO Ƿ񰴼ƻ + int purchPlanDay = 0; + if(!ysr8_PurchPlanDate.isEmpty()) { + if(!ysr8_TechPlanDate.isEmpty()) + purchPlanDay = CommonUtil.getDaysBetween(ysr8_TechPlanDate, ysr8_PurchPlanDate); + else if(!ysr8_ReplyDate.isEmpty()) + purchPlanDay = CommonUtil.getDaysBetween(ysr8_ReplyDate, ysr8_PurchPlanDate); + + if (!ysr8_TechPlanDate.isEmpty() && techResult.equals("NG")) { + if (!ysr8_TechFinishDate.isEmpty() && purchPlanDay != 0) { + if(ysr8_PurchFinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_TechFinishDate, today) - purchPlanDay; + if (days <= 0) { + purchResult = ""; + } else { + purchResult = "NG"; + } + }else { + days = CommonUtil.getDaysBetween(ysr8_TechFinishDate, ysr8_PurchFinishDate) - purchPlanDay; + if (days <= 0) { + purchResult = "OK"; + } else { + purchResult = "NG"; + } + } + } + }else if(ysr8_TechPlanDate.isEmpty() || !ysr8_TechFinishDate.isEmpty()){ + if (!ysr8_PurchFinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_PurchPlanDate, ysr8_PurchFinishDate); + if (days > 0) { + purchResult = "NG"; + } else { + purchResult = "OK"; + } + }else{ + days = CommonUtil.getDaysBetween(ysr8_PurchPlanDate, today); + if (days > 0) { + purchResult = "NG"; + } else { + purchResult = ""; + } + } + } + } +// System.out.println("purchPlanDay:"+purchPlanDay+" days:"+days); + ////////////////////////////////// +// vec.add(prRevisionForm.getProperty("ysr8_Machiner2"));// ӹ + vec.add("");// ӹ +// String ysr8_MachinPlanDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_MachinPlanDate")); + //vec.add(ysr8_MachinPlanDate);// ӹƻʱ + //lidy20180826IJɹӦвʾӹƻʱ20190520ӹ + vec.add("");// ӹƻʱ + vec.add("");// ӹʵʱ + ///////////////////////////////// + //20240722 + vec.add(prRevisionForm.getProperty("ysr8_ElecDebug2"));// + String ysr8_ElecDebug2PlanDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_ElecDebug2PlanDate")); + vec.add(ysr8_ElecDebug2PlanDate);// ƻʱ + String ysr8_ElecDebug2FinishDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_ElecDebug2FinishDate")); + vec.add(ysr8_ElecDebug2FinishDate);// ʵʱ + + vec.add(prRevisionForm.getProperty("ysr8_TechCenter"));// + String ysr8_TechCenterPlanDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_TechCenterPlanDate")); + vec.add(ysr8_TechCenterPlanDate);// ʱ + String ysr8_TechCenterFinishDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_TechCenterFinishDate")); + vec.add(ysr8_TechCenterFinishDate);// ʵʱ + ////////////////////////////////// + vec.add(prRevisionForm.getProperty("ysr8_ImplementDept"));// ʵʩβ + vec.add(prRevisionForm.getProperty("ysr8_Engineer"));// ʵʩ + String ysr8_EnginePlanDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_EnginePlanDate")); + vec.add(ysr8_EnginePlanDate);// ʵʩƻʱ + int engineerPlanDay = 0; +// if (!ysr8_PurchPlanDate.isEmpty() && ysr8_MachinPlanDate.isEmpty() && !ysr8_EnginePlanDate.isEmpty()) { +// engineerPlanDay = CommonUtil.getDaysBetween(ysr8_PurchPlanDate, ysr8_EnginePlanDate); +// } + String ysr8_FinishDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_FinishDate")); + vec.add(ysr8_FinishDate);// ʵʩʵʱ + String engineerResult = "";//TODO Ƿ񰴼ƻ + if (!ysr8_EnginePlanDate.isEmpty()) { + if (!ysr8_PurchPlanDate.isEmpty()) + engineerPlanDay = CommonUtil.getDaysBetween(ysr8_PurchPlanDate, ysr8_EnginePlanDate); + else if (!ysr8_TechPlanDate.isEmpty()) + engineerPlanDay = CommonUtil.getDaysBetween(ysr8_TechPlanDate, ysr8_EnginePlanDate); + else if (!ysr8_ReplyDate.isEmpty()) + engineerPlanDay = CommonUtil.getDaysBetween(ysr8_ReplyDate, ysr8_EnginePlanDate); + + if (!ysr8_PurchPlanDate.isEmpty()) { + if (purchResult.equals("NG") && !ysr8_PurchFinishDate.isEmpty()) { + if(!ysr8_FinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_PurchFinishDate, ysr8_FinishDate) - engineerPlanDay; + if (days <= 0) { + engineerResult = "OK"; + } else { + engineerResult = "NG"; + } + }else { + days = CommonUtil.getDaysBetween(ysr8_PurchFinishDate, today) - engineerPlanDay; + if (days <= 0) { + engineerResult = ""; + } else { + engineerResult = "NG"; + } + } + } else if (purchResult.equals("OK")) { + if(!ysr8_FinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_EnginePlanDate, ysr8_FinishDate); + if (days <= 0) { + engineerResult = "OK"; + } else { + engineerResult = "NG"; + } + }else{ + days = CommonUtil.getDaysBetween(ysr8_EnginePlanDate, today); + if (days <= 0) { + engineerResult = ""; + } else { + engineerResult = "NG"; + } + } + } else if (ysr8_PurchFinishDate.isEmpty()) { + engineerResult = ""; + } + }else if (!ysr8_TechPlanDate.isEmpty()) { + if (techResult.equals("NG") && !ysr8_TechFinishDate.isEmpty()) { + if(!ysr8_FinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_TechFinishDate, ysr8_FinishDate) - engineerPlanDay; + if (days <= 0) { + engineerResult = "OK"; + } else { + engineerResult = "NG"; + } + }else{ + days = CommonUtil.getDaysBetween(ysr8_TechFinishDate, today) - engineerPlanDay; + if (days <= 0) { + engineerResult = ""; + } else { + engineerResult = "NG"; + } + } + } else if (techResult.equals("OK")) { + if(!ysr8_FinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_EnginePlanDate, ysr8_FinishDate); + if (days <= 0) { + engineerResult = "OK"; + } else { + engineerResult = "NG"; + } + }else{ + days = CommonUtil.getDaysBetween(ysr8_EnginePlanDate, today); + if (days <= 0) { + engineerResult = ""; + } else { + engineerResult = "NG"; + } + } + } else if (ysr8_TechFinishDate.isEmpty()) { + engineerResult = ""; + } + }else { + if(!ysr8_FinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_EnginePlanDate, ysr8_FinishDate); + if (days <= 0) { + engineerResult = "OK"; + } else { + engineerResult = "NG"; + } + }else{ + days = CommonUtil.getDaysBetween(ysr8_EnginePlanDate, today); + if (days <= 0) { + engineerResult = ""; + } else { + engineerResult = "NG"; + } + } + } + } + ////////////////////////////////// + vec.add(prRevisionForm.getProperty("ysr8_ChangeStatus"));// ĺ״̬ + vec.add(prRevisionForm.getProperty("ysr8_ProblemStatus"));// + vec.add("");// ע + vec.add(prRevisionForm.getProperty("ysr8_ProblemType"));// + String ysr8_ClassVal = prRevisionForm.getProperty("ysr8_Class"); + String ysr8_PartVal = prRevisionForm.getProperty("ysr8_Part"); + String ysr8_ProjectVal = prRevisionForm.getProperty("ysr8_Project"); + Iterator iter = ysr8_ClassLovVal.keySet().iterator(); + while (iter.hasNext()) { + String lovKey = iter.next(); + String lovValue = ysr8_ClassLovVal.get(lovKey); + if (lovValue.equalsIgnoreCase(ysr8_ClassVal)) { + LinkedHashMap ysr8_PartLovVal = TCUtil.getlovValues(fu.session, lovKey); + Iterator iter1 = ysr8_PartLovVal.keySet().iterator(); + while (iter1.hasNext()) { + String lovKey1 = iter1.next(); + String lovValue1 = ysr8_PartLovVal.get(lovKey1); + if (lovKey1.equalsIgnoreCase(ysr8_PartVal)) { + ysr8_PartVal = lovValue1; + LinkedHashMap ysr8_ProjectLovVal = TCUtil.getlovValues(fu.session, lovKey1); + Iterator iter2 = ysr8_ProjectLovVal.keySet().iterator(); + while (iter2.hasNext()) { + String lovKey2 = iter2.next(); + String lovValue2 = ysr8_ProjectLovVal.get(lovKey2); + if (lovKey2.equalsIgnoreCase(ysr8_ProjectVal)) { + ysr8_ProjectVal = lovValue2; + break; + } + } + break; + } + } + break; + } + } + vec.add(ysr8_ClassVal);// + vec.add(ysr8_PartVal);// + vec.add(ysr8_ProjectVal);// Ŀ + ////////////////////////////////// + vec.add(Integer.toString(techPlanDate));// ʱƻ + vec.add(techResult);// Ƿ񰴼ƻ + vec.add(ecn3RevisionForm.getProperty("ysr8_TechReasonAnalysis") + "" + ecn3RevisionForm.getProperty("ysr8_TechReasonDesc"));// ԭ + + vec.add(Integer.toString(purchPlanDay));// ɹʱƻ + vec.add(purchResult);// ɹǷ񰴼ƻ + vec.add(ecn3RevisionForm.getProperty("ysr8_PurchReasonDesc"));// ɹԭ + + vec.add("");// ӹʱƻ + vec.add("");// ӹǷ񰴼ƻ + vec.add("");// ӹԭ + ////////////////////////////////// + vec.add(Integer.toString(engineerPlanDay));// ʵʩʱƻ + vec.add(engineerResult);// ʵʩǷ񰴼ƻ + vec.add(prRevisionForm.getProperty("ysr8_ImplementReason") + "" + prRevisionForm.getProperty("ysr8_ReasonAnalysis2"));// ʵʩԭ + + + ////////////////////////////////// + + + int dqPlanDate = 0; + if (!ysr8_ReplyDate.isEmpty() && !ysr8_ElecDebug2PlanDate.isEmpty()) { + dqPlanDate = CommonUtil.getDaysBetween(ysr8_ReplyDate, ysr8_ElecDebug2PlanDate); + } + vec.add(Integer.toString(dqPlanDate)); + + String dqResult = ""; + int dqDays = 0; + if (!ysr8_ElecDebug2PlanDate.isEmpty() && !ysr8_ElecDebug2FinishDate.isEmpty()) { + dqDays = CommonUtil.getDaysBetween(ysr8_ElecDebug2PlanDate, ysr8_ElecDebug2FinishDate); + if (dqDays > 0) { + dqResult = "NG"; + } else { + dqResult = "OK"; + } + }else if (!ysr8_ElecDebug2PlanDate.isEmpty() && ysr8_ElecDebug2FinishDate.isEmpty()) { + dqDays = CommonUtil.getDaysBetween(ysr8_ElecDebug2PlanDate, today); + if (dqDays > 0) { + dqResult = "NG"; + } else { + dqResult = ""; + } + } + vec.add(dqResult); + vec.add(prRevisionForm.getProperty("ysr8_ElecReason")); + + + + + int jszxPlanDate = 0; + if (!ysr8_ReplyDate.isEmpty() && !ysr8_TechCenterPlanDate.isEmpty()) { + jszxPlanDate = CommonUtil.getDaysBetween(ysr8_ReplyDate, ysr8_TechCenterPlanDate); + } + vec.add(Integer.toString(jszxPlanDate)); + + String jszxResult = ""; + int jszxDays = 0; + if (!ysr8_TechCenterPlanDate.isEmpty() && !ysr8_TechCenterFinishDate.isEmpty()) { + jszxDays = CommonUtil.getDaysBetween(ysr8_TechCenterPlanDate, ysr8_TechCenterFinishDate); + if (jszxDays > 0) { + jszxResult = "NG"; + } else { + jszxResult = "OK"; + } + }else if (!ysr8_TechCenterPlanDate.isEmpty() && ysr8_TechCenterFinishDate.isEmpty()) { + jszxDays = CommonUtil.getDaysBetween(ysr8_TechCenterPlanDate, today); + if (jszxDays > 0) { + jszxResult = "NG"; + } else { + jszxResult = ""; + } + } + vec.add(jszxResult); + vec.add(prRevisionForm.getProperty("ysr8_TechCenterReason")); + + + + + { + String hasPic = ""; + TCComponent[] components = prRevision.getRelatedComponents("IMAN_specification"); + if (components != null && components.length > 0) { + for (int k = 0; k < components.length; k++) { + TCComponentDataset dataset = (TCComponentDataset) components[k]; + String object_typeVal = dataset.getProperty("object_type"); + if (object_typeVal.equalsIgnoreCase("JPEG") || + // object_typeVal.equalsIgnoreCase("λͼ") || + object_typeVal.equalsIgnoreCase("GIF") || object_typeVal.equalsIgnoreCase("Image") || object_typeVal.equalsIgnoreCase("ͼ") + || object_typeVal.equalsIgnoreCase("Яʽͼͼ")) { + hasPic = ""; + break; + } + } + } + vec.add(hasPic);// ǷϴͼƬ + } + + for (int k = 0; k < vec.size(); k++) { + if (vec.get(k).isEmpty()) { + vec.set(k, "-"); + } + } + ci.dataTableModel.addRow(vec); + // prRevisions.add(prRevision); +// System.out.println(vec.get(0) + "=======" + prId); + prRevisions.put(vec.get(0), prRevision); + } else if (objectType.equalsIgnoreCase("ļӹ")) {/////////////////////////////////////////////////// + bFind = true; + TCComponentItemRevision ecn4Revision = item.getLatestItemRevision(); + TCComponentForm ecn4RevisionForm = TCUtil.getItemRevisionMasterForm(ecn4Revision); + ecn4RevisionForm.refresh(); + + Vector vec = new Vector<>(); + vec.add((++idx) + "");// + vec.add(prRevisionForm.getProperty("ysr8_ProblemNo"));// + vec.add(prRevisionForm.getProperty("ysr8_Importance"));// Ҫ + vec.add(fu.getDateString(prRevisionForm.getDateProperty("ysr8_ProblemDate")));// ύ + vec.add(fu.getDateString(prRevisionForm.getDateProperty("ysr8_RequirementDate")));// ûҪ + vec.add(prRevisionForm.getProperty("ysr8_Submiter"));// ύ˹ID + vec.add(prRevisionForm.getProperty("ysr8_SubmitTimes"));// ύ + String ysr8_ReplyDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_ReplyDate")); + vec.add(ysr8_ReplyDate);// ظʱ + vec.add(prRevisionForm.getProperty("ysr8_StationNo"));// λ/վ + vec.add(prRevisionForm.getProperty("ysr8_ProblemExplain"));// ˵ + vec.add(prRevisionForm.getProperty("ysr8_ReasonAnalysis"));// ԭ + vec.add(prRevisionForm.getProperty("ysr8_ChangeMeasures"));// Ĵʩ + //20241113 ĵ +// TCComponent[] comps = prRevision.getRelatedComponents("YSR8_ChangeForm"); +// String ecnId = ""; +// if(comps != null && comps.length > 0) { +// for (int k = 0; k < comps.length; k++) { +// if(comps[k].getType().equals("YSR8_ECN4")) { +// System.out.println("comps[k].getType()============"+comps[k].getType()); +// String item_id = comps[k].getStringProperty("item_id"); +// ecnId = item_id; +// System.out.println("item_id==="+item_id); +// } +// } +// } + String ecnId = item.getProperty("item_id"); + vec.add(ecnId == null?"":ecnId); + //TODO ļӹidSetͼ + String[] materialID2 = ecn4RevisionForm.getFormTCProperty("ysr8_Ecn4Id").getStringArrayValue(); + Set idSet = new HashSet<>(); + if(materialID2.length>0) { + String[] problemID = ecn4RevisionForm.getFormTCProperty("ysr8_Ecn4SolveQueId").getStringArrayValue(); + for(int k=0; k0 && !idSet.contains(ysr8_MaterialIDVals[m])) { + continue; + } + ysr8_MaterialIDVal += ysr8_MaterialIDVals[m]; + ysr8_MaterialIDVal += ""; + } + if(ysr8_MaterialIDVal.length()>0) + vec.add(ysr8_MaterialIDVal.substring(0, ysr8_MaterialIDVal.length()-1));// ͼŻɹͺ + else + vec.add(ysr8_MaterialIDVal); + } + ////////////////////////////////// + vec.add(prRevisionForm.getProperty("ysr8_ChangeDept"));// ĵβ + vec.add(ysr8_TechStaffVal);// + String ysr8_TechPlanDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_TechPlanDate")); + vec.add(ysr8_TechPlanDate);// ļƻʱ + int techPlanDate = 0; + if (!ysr8_ReplyDate.isEmpty() && !ysr8_TechPlanDate.isEmpty()) { + techPlanDate = CommonUtil.getDaysBetween(ysr8_ReplyDate, ysr8_TechPlanDate); + } + String ysr8_TechFinishDate = fu.getDateString(ecn4RevisionForm.getDateProperty("ysr8_TechFinishDate")); + vec.add(ysr8_TechFinishDate);// ʵʱ + String techResult = ""; + int days = 0; + if (!ysr8_TechPlanDate.isEmpty() && !ysr8_TechFinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_TechPlanDate, ysr8_TechFinishDate); + if (days > 0) { + techResult = "NG"; + } else { + techResult = "OK"; + } + }else if (!ysr8_TechPlanDate.isEmpty() && ysr8_TechFinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_TechPlanDate, today); + if (days > 0) { + techResult = "NG"; + } else { + techResult = ""; + } + } + ////////////////////////////////// +// vec.add(prRevisionForm.getProperty("ysr8_Purcher2"));// ɹ + vec.add("");// ɹ +// String ysr8_PurchPlanDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_PurchPlanDate")); + //vec.add(ysr8_PurchPlanDate);// ɹƻʱ + //lidy20180826ļӹӦвʾɹƻʱ20190520ɹ + vec.add("");// ɹƻʱ + vec.add("");// ɹʵʱ + ////////////////////////////////// + vec.add(prRevisionForm.getProperty("ysr8_Machiner2"));// ӹ + String ysr8_MachinPlanDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_MachinPlanDate")); + vec.add(ysr8_MachinPlanDate);// ӹƻʱ + + //TODO ͼֽĵӹʵʱ +// String ysr8_PurchFinishDate = ecn4RevisionForm.getProperty("ysr8_PurchFinishDate"); + String ysr8_PurchFinishDate = ""; + if(materialID2.length>0) { + String[] Ecn4SolveQueId = ecn4RevisionForm.getFormTCProperty("ysr8_Ecn4SolveQueId").getStringArrayValue(); + String[] Ecn4Id = ecn4RevisionForm.getFormTCProperty("ysr8_Ecn4Id").getStringArrayValue(); + String[] MaterialID = ecn4RevisionForm.getFormTCProperty("ysr8_MaterialID").getStringArrayValue(); + Date[] subPurchFinishDate = ecn4RevisionForm.getFormTCProperty("ysr8_SubPurchFinishDate").getDateValueArray(); +// String purchFinishDate = ""; + for(int k=0; k0) + ysr8_PurchFinishDate = fu.getDateString(PurchFinishDate); + }else { + ysr8_PurchFinishDate = fu.getDateString(PurchFinishDate); + } + } else { + ysr8_PurchFinishDate = ""; + break; + } + } + } + }else + ysr8_PurchFinishDate = fu.getDateString(ecn4RevisionForm.getDateProperty("ysr8_PurchFinishDate")); + vec.add(ysr8_PurchFinishDate);// ӹʵʱ + String machinResult = "";//TODO Ƿ񰴼ƻ + int machinPlanDay = 0; + if(!ysr8_MachinPlanDate.isEmpty()) { + if(!ysr8_TechPlanDate.isEmpty()) + machinPlanDay = CommonUtil.getDaysBetween(ysr8_TechPlanDate, ysr8_MachinPlanDate); + else if(!ysr8_ReplyDate.isEmpty()) + machinPlanDay = CommonUtil.getDaysBetween(ysr8_ReplyDate, ysr8_MachinPlanDate); + + if (!ysr8_TechPlanDate.isEmpty() && techResult.equals("NG")) { + if (!ysr8_TechFinishDate.isEmpty() && machinPlanDay != 0) { + if(ysr8_PurchFinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_TechFinishDate, today) - machinPlanDay; + if (days <= 0) { + machinResult = ""; + } else { + machinResult = "NG"; + } + }else { + days = CommonUtil.getDaysBetween(ysr8_TechFinishDate, ysr8_PurchFinishDate) - machinPlanDay; + if (days <= 0) { + machinResult = "OK"; + } else { + machinResult = "NG"; + } + } + } + }else if(ysr8_TechPlanDate.isEmpty() || !ysr8_TechFinishDate.isEmpty()){ + if (!ysr8_PurchFinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_MachinPlanDate, ysr8_PurchFinishDate); + if (days > 0) { + machinResult = "NG"; + } else { + machinResult = "OK"; + } + }else{ + days = CommonUtil.getDaysBetween(ysr8_MachinPlanDate, today); + if (days > 0) { + machinResult = "NG"; + } else { + machinResult = ""; + } + } + } + } +// System.out.println("purchPlanDay:"+machinPlanDay+" days:"+days); + ///////////////////////////////// + //20240722 + vec.add(prRevisionForm.getProperty("ysr8_ElecDebug2"));// + String ysr8_ElecDebug2PlanDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_ElecDebug2PlanDate")); + vec.add(ysr8_ElecDebug2PlanDate);// ƻʱ + String ysr8_ElecDebug2FinishDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_ElecDebug2FinishDate")); + vec.add(ysr8_ElecDebug2FinishDate);// ʵʱ + + vec.add(prRevisionForm.getProperty("ysr8_TechCenter"));// + String ysr8_TechCenterPlanDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_TechCenterPlanDate")); + vec.add(ysr8_TechCenterPlanDate);// ʱ + String ysr8_TechCenterFinishDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_TechCenterFinishDate")); + vec.add(ysr8_TechCenterFinishDate);// ʵʱ + ////////////////////////////////// + vec.add(prRevisionForm.getProperty("ysr8_ImplementDept"));// ʵʩβ + vec.add(prRevisionForm.getProperty("ysr8_Engineer"));// ʵʩ + String ysr8_EnginePlanDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_EnginePlanDate")); + vec.add(ysr8_EnginePlanDate);// ʵʩƻʱ + int engineerPlanDay = 0; + String ysr8_FinishDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_FinishDate")); + vec.add(ysr8_FinishDate);// ʵʩʵʱ + String engineerResult = "";//TODO Ƿ񰴼ƻ + if (!ysr8_EnginePlanDate.isEmpty()) { + if (!ysr8_MachinPlanDate.isEmpty()) + engineerPlanDay = CommonUtil.getDaysBetween(ysr8_MachinPlanDate, ysr8_EnginePlanDate); + else if (!ysr8_TechPlanDate.isEmpty()) + engineerPlanDay = CommonUtil.getDaysBetween(ysr8_TechPlanDate, ysr8_EnginePlanDate); + else if (!ysr8_ReplyDate.isEmpty()) + engineerPlanDay = CommonUtil.getDaysBetween(ysr8_ReplyDate, ysr8_EnginePlanDate); + + if (!ysr8_MachinPlanDate.isEmpty()) { + if (machinResult.equals("NG") && !ysr8_PurchFinishDate.isEmpty()) { + if(!ysr8_FinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_PurchFinishDate, ysr8_FinishDate) - engineerPlanDay; + if (days <= 0) { + engineerResult = "OK"; + } else { + engineerResult = "NG"; + } + }else { + days = CommonUtil.getDaysBetween(ysr8_PurchFinishDate, today) - engineerPlanDay; + if (days <= 0) { + engineerResult = ""; + } else { + engineerResult = "NG"; + } + } + } else if (machinResult.equals("OK")) { + if(!ysr8_FinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_EnginePlanDate, ysr8_FinishDate); + if (days <= 0) { + engineerResult = "OK"; + } else { + engineerResult = "NG"; + } + }else{ + days = CommonUtil.getDaysBetween(ysr8_EnginePlanDate, today); + if (days <= 0) { + engineerResult = ""; + } else { + engineerResult = "NG"; + } + } + } else if (ysr8_PurchFinishDate.isEmpty()) { + engineerResult = ""; + } + }else if (!ysr8_TechPlanDate.isEmpty()) { + if (techResult.equals("NG") && !ysr8_TechFinishDate.isEmpty()) { + if(!ysr8_FinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_TechFinishDate, ysr8_FinishDate) - engineerPlanDay; + if (days <= 0) { + engineerResult = "OK"; + } else { + engineerResult = "NG"; + } + }else{ + days = CommonUtil.getDaysBetween(ysr8_TechFinishDate, today) - engineerPlanDay; + if (days <= 0) { + engineerResult = ""; + } else { + engineerResult = "NG"; + } + } + } else if (techResult.equals("OK")) { + if(!ysr8_FinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_EnginePlanDate, ysr8_FinishDate); + if (days <= 0) { + engineerResult = "OK"; + } else { + engineerResult = "NG"; + } + }else{ + days = CommonUtil.getDaysBetween(ysr8_EnginePlanDate, today); + if (days <= 0) { + engineerResult = ""; + } else { + engineerResult = "NG"; + } + } + } else if (ysr8_TechFinishDate.isEmpty()) { + engineerResult = ""; + } + }else { + if(!ysr8_FinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_EnginePlanDate, ysr8_FinishDate); + if (days <= 0) { + engineerResult = "OK"; + } else { + engineerResult = "NG"; + } + }else{ + days = CommonUtil.getDaysBetween(ysr8_EnginePlanDate, today); + if (days <= 0) { + engineerResult = ""; + } else { + engineerResult = "NG"; + } + } + } + } + ////////////////////////////////// + vec.add(prRevisionForm.getProperty("ysr8_ChangeStatus"));// ĺ״̬ + vec.add(prRevisionForm.getProperty("ysr8_ProblemStatus"));// + vec.add("");// ע + vec.add(prRevisionForm.getProperty("ysr8_ProblemType"));// + String ysr8_ClassVal = prRevisionForm.getProperty("ysr8_Class"); + String ysr8_PartVal = prRevisionForm.getProperty("ysr8_Part"); + String ysr8_ProjectVal = prRevisionForm.getProperty("ysr8_Project"); + Iterator iter = ysr8_ClassLovVal.keySet().iterator(); + while (iter.hasNext()) { + String lovKey = iter.next(); + String lovValue = ysr8_ClassLovVal.get(lovKey); + if (lovValue.equalsIgnoreCase(ysr8_ClassVal)) { + LinkedHashMap ysr8_PartLovVal = TCUtil.getlovValues(fu.session, lovKey); + Iterator iter1 = ysr8_PartLovVal.keySet().iterator(); + while (iter1.hasNext()) { + String lovKey1 = iter1.next(); + String lovValue1 = ysr8_PartLovVal.get(lovKey1); + if (lovKey1.equalsIgnoreCase(ysr8_PartVal)) { + ysr8_PartVal = lovValue1; + LinkedHashMap ysr8_ProjectLovVal = TCUtil.getlovValues(fu.session, lovKey1); + Iterator iter2 = ysr8_ProjectLovVal.keySet().iterator(); + while (iter2.hasNext()) { + String lovKey2 = iter2.next(); + String lovValue2 = ysr8_ProjectLovVal.get(lovKey2); + if (lovKey2.equalsIgnoreCase(ysr8_ProjectVal)) { + ysr8_ProjectVal = lovValue2; + break; + } + } + break; + } + } + break; + } + } + vec.add(ysr8_ClassVal);// + vec.add(ysr8_PartVal);// + vec.add(ysr8_ProjectVal);// Ŀ + ////////////////////////////////// + vec.add(Integer.toString(techPlanDate));// ʱƻ + vec.add(techResult);// Ƿ񰴼ƻ + vec.add(ecn4RevisionForm.getProperty("ysr8_TechReasonAnalysis") + "" + ecn4RevisionForm.getProperty("ysr8_TechReasonDesc"));// ԭ + + vec.add("");// ɹʱƻ + vec.add("");// ɹǷ񰴼ƻ + vec.add("");// ɹԭ + + vec.add(Integer.toString(machinPlanDay));// ӹʱƻ + vec.add(machinResult);// ӹǷ񰴼ƻ + vec.add(ecn4RevisionForm.getProperty("ysr8_PurchReasonDesc"));// ӹԭ + ////////////////////////////////// + vec.add(Integer.toString(engineerPlanDay));// ʵʩʱƻ + vec.add(engineerResult);// ʵʩǷ񰴼ƻ + vec.add(prRevisionForm.getProperty("ysr8_ImplementReason") + "" + prRevisionForm.getProperty("ysr8_ReasonAnalysis2"));// ʵʩԭ + + + + int dqPlanDate = 0; + if (!ysr8_ReplyDate.isEmpty() && !ysr8_ElecDebug2PlanDate.isEmpty()) { + dqPlanDate = CommonUtil.getDaysBetween(ysr8_ReplyDate, ysr8_ElecDebug2PlanDate); + } + vec.add(Integer.toString(dqPlanDate)); + + String dqResult = ""; + int dqDays = 0; + if (!ysr8_ElecDebug2PlanDate.isEmpty() && !ysr8_ElecDebug2FinishDate.isEmpty()) { + dqDays = CommonUtil.getDaysBetween(ysr8_ElecDebug2PlanDate, ysr8_ElecDebug2FinishDate); + if (dqDays > 0) { + dqResult = "NG"; + } else { + dqResult = "OK"; + } + }else if (!ysr8_ElecDebug2PlanDate.isEmpty() && ysr8_ElecDebug2FinishDate.isEmpty()) { + dqDays = CommonUtil.getDaysBetween(ysr8_ElecDebug2PlanDate, today); + if (dqDays > 0) { + dqResult = "NG"; + } else { + dqResult = ""; + } + } + vec.add(dqResult); + vec.add(prRevisionForm.getProperty("ysr8_ElecReason")); + + + + + int jszxPlanDate = 0; + if (!ysr8_ReplyDate.isEmpty() && !ysr8_TechCenterPlanDate.isEmpty()) { + jszxPlanDate = CommonUtil.getDaysBetween(ysr8_ReplyDate, ysr8_TechCenterPlanDate); + } + vec.add(Integer.toString(jszxPlanDate)); + + String jszxResult = ""; + int jszxDays = 0; + if (!ysr8_TechCenterPlanDate.isEmpty() && !ysr8_TechCenterFinishDate.isEmpty()) { + jszxDays = CommonUtil.getDaysBetween(ysr8_TechCenterPlanDate, ysr8_TechCenterFinishDate); + if (jszxDays > 0) { + jszxResult = "NG"; + } else { + jszxResult = "OK"; + } + }else if (!ysr8_TechCenterPlanDate.isEmpty() && ysr8_TechCenterFinishDate.isEmpty()) { + jszxDays = CommonUtil.getDaysBetween(ysr8_TechCenterPlanDate, today); + if (jszxDays > 0) { + jszxResult = "NG"; + } else { + jszxResult = ""; + } + } + vec.add(jszxResult); + vec.add(prRevisionForm.getProperty("ysr8_TechCenterReason")); + + + ////////////////////////////////// + { + String hasPic = ""; + TCComponent[] components = prRevision.getRelatedComponents("IMAN_specification"); + if (components != null && components.length > 0) { + for (int k = 0; k < components.length; k++) { + TCComponentDataset dataset = (TCComponentDataset) components[k]; + String object_typeVal = dataset.getProperty("object_type"); + if (object_typeVal.equalsIgnoreCase("JPEG") || + // object_typeVal.equalsIgnoreCase("λͼ") || + object_typeVal.equalsIgnoreCase("GIF") || object_typeVal.equalsIgnoreCase("Image") || object_typeVal.equalsIgnoreCase("ͼ") + || object_typeVal.equalsIgnoreCase("Яʽͼͼ")) { + hasPic = ""; + break; + } + } + } + vec.add(hasPic);// ǷϴͼƬ + } + + for (int k = 0; k < vec.size(); k++) { + if (vec.get(k).isEmpty()) { + vec.set(k, "-"); + } + } + ci.dataTableModel.addRow(vec); + // prRevisions.add(prRevision); +// System.out.println(vec.get(0) + "=======" + prId); + prRevisions.put(vec.get(0), prRevision); + } + } + } + } + + if (!bFind) { + Vector vec = new Vector<>(); + vec.add((++idx) + "");// + vec.add(prRevisionForm.getProperty("ysr8_ProblemNo"));// + vec.add(prRevisionForm.getProperty("ysr8_Importance"));// Ҫ + vec.add(fu.getDateString(prRevisionForm.getDateProperty("ysr8_ProblemDate")));// ύ + vec.add(fu.getDateString(prRevisionForm.getDateProperty("ysr8_RequirementDate")));// ûҪ + vec.add(prRevisionForm.getProperty("ysr8_Submiter"));// ύ + vec.add(prRevisionForm.getProperty("ysr8_SubmitTimes"));// ύ + String ysr8_ReplyDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_ReplyDate")); + vec.add(ysr8_ReplyDate);// ظʱ + vec.add(prRevisionForm.getProperty("ysr8_StationNo"));// Ŀ + vec.add(prRevisionForm.getProperty("ysr8_ProblemExplain"));// ˵ + vec.add(prRevisionForm.getProperty("ysr8_ReasonAnalysis"));// ԭ + vec.add(prRevisionForm.getProperty("ysr8_ChangeMeasures"));// Ĵʩ + //20241113 ĵ + TCComponent[] comps = prRevision.getRelatedComponents("YSR8_ChangeForm"); + if(comps != null && comps.length > 0) { + String item_id = comps[0].getStringProperty("item_id"); + vec.add(item_id); + System.out.println("item_id==="+item_id); + }else { + vec.add(""); + } + vec.add("");// ͼŻɹͺ + ////////////////////////////////// + vec.add(prRevisionForm.getProperty("ysr8_ChangeDept"));// ĵβ + vec.add(ysr8_TechStaffVal);// + String ysr8_TechPlanDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_TechPlanDate")); + vec.add(ysr8_TechPlanDate);// ļƻʱ + vec.add("");// ʵʱ + ////////////////////////////////// + vec.add(prRevisionForm.getProperty("ysr8_Purcher2"));// ɹ + String ysr8_PurchPlanDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_PurchPlanDate")); + vec.add(ysr8_PurchPlanDate);// ɹƻʱ + String ysr8_PurchFinishDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_PurchFinishDate")); + vec.add(ysr8_PurchFinishDate);// ɹʵʱ + ////////////////////////////////// + vec.add(prRevisionForm.getProperty("ysr8_Machiner2"));// ӹ + String ysr8_MachinPlanDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_MachinPlanDate")); + vec.add(ysr8_MachinPlanDate);// ӹƻʱ + String ysr8_MachFinishDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_MachFinishDate")); + vec.add(ysr8_MachFinishDate);// ӹʵʱ + + ///////////////////////////////// + //20240722 + vec.add(prRevisionForm.getProperty("ysr8_ElecDebug2"));// + String ysr8_ElecDebug2PlanDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_ElecDebug2PlanDate")); + vec.add(ysr8_ElecDebug2PlanDate);// ƻʱ + String ysr8_ElecDebug2FinishDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_ElecDebug2FinishDate")); + vec.add(ysr8_ElecDebug2FinishDate);// ʵʱ + + vec.add(prRevisionForm.getProperty("ysr8_TechCenter"));// + String ysr8_TechCenterPlanDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_TechCenterPlanDate")); + vec.add(ysr8_TechCenterPlanDate);// ʱ + String ysr8_TechCenterFinishDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_TechCenterFinishDate")); + vec.add(ysr8_TechCenterFinishDate);// ʵʱ + + ////////////////////////////////// + vec.add(prRevisionForm.getProperty("ysr8_ImplementDept"));// ʵʩβ + vec.add(prRevisionForm.getProperty("ysr8_Engineer"));// ʵʩ + String ysr8_EnginePlanDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_EnginePlanDate")); + vec.add(ysr8_EnginePlanDate);// ʵʩƻʱ + String ysr8_FinishDate = fu.getDateString(prRevisionForm.getDateProperty("ysr8_FinishDate")); + vec.add(ysr8_FinishDate);// ʵʩʵʱ + ////////////////////////////////// + vec.add(prRevisionForm.getProperty("ysr8_ChangeStatus"));// ĺ״̬ + vec.add(prRevisionForm.getProperty("ysr8_ProblemStatus"));// + vec.add("");// ע + vec.add(prRevisionForm.getProperty("ysr8_ProblemType"));// + String ysr8_ClassVal = prRevisionForm.getProperty("ysr8_Class"); + String ysr8_PartVal = prRevisionForm.getProperty("ysr8_Part"); + String ysr8_ProjectVal = prRevisionForm.getProperty("ysr8_Project"); + Iterator iter = ysr8_ClassLovVal.keySet().iterator(); + while (iter.hasNext()) { + String lovKey = iter.next(); + String lovValue = ysr8_ClassLovVal.get(lovKey); + if (lovValue.equalsIgnoreCase(ysr8_ClassVal)) { + LinkedHashMap ysr8_PartLovVal = TCUtil.getlovValues(fu.session, lovKey); + Iterator iter1 = ysr8_PartLovVal.keySet().iterator(); + while (iter1.hasNext()) { + String lovKey1 = iter1.next(); + String lovValue1 = ysr8_PartLovVal.get(lovKey1); + if (lovKey1.equalsIgnoreCase(ysr8_PartVal)) { + ysr8_PartVal = lovValue1; + LinkedHashMap ysr8_ProjectLovVal = TCUtil.getlovValues(fu.session, lovKey1); + Iterator iter2 = ysr8_ProjectLovVal.keySet().iterator(); + while (iter2.hasNext()) { + String lovKey2 = iter2.next(); + String lovValue2 = ysr8_ProjectLovVal.get(lovKey2); + if (lovKey2.equalsIgnoreCase(ysr8_ProjectVal)) { + ysr8_ProjectVal = lovValue2; + break; + } + } + break; + } + } + break; + } + } + vec.add(ysr8_ClassVal);// + vec.add(ysr8_PartVal);// + vec.add(ysr8_ProjectVal);// Ŀ + ////////////////////////////////// + String techResult = "", purchResult = "", machinResult = ""; + int days = 0, techDays = 0, purchDays = 0, machinDays = 0; + if(!ysr8_TechPlanDate.isEmpty()) { + techDays = CommonUtil.getDaysBetween(ysr8_ReplyDate, ysr8_TechPlanDate); + techResult = "NG"; + } + vec.add(Integer.toString(techDays));// ʱƻ + vec.add(techResult);// Ƿ񰴼ƻ + vec.add("");// ԭ + + if(!ysr8_PurchPlanDate.isEmpty()) { + if(!ysr8_TechPlanDate.isEmpty()) { + purchDays = CommonUtil.getDaysBetween(ysr8_TechPlanDate, ysr8_PurchPlanDate); + purchResult = ""; + }else if (!ysr8_PurchFinishDate.isEmpty()) { + purchDays = CommonUtil.getDaysBetween(ysr8_ReplyDate, ysr8_PurchPlanDate); + days = CommonUtil.getDaysBetween(ysr8_PurchPlanDate, ysr8_PurchFinishDate); + if (days > 0) { + purchResult = "NG"; + } else { + purchResult = "OK"; + } + }else if (!ysr8_PurchPlanDate.isEmpty() && ysr8_PurchFinishDate.isEmpty()) { + purchDays = CommonUtil.getDaysBetween(ysr8_ReplyDate, ysr8_PurchPlanDate); + days = CommonUtil.getDaysBetween(ysr8_PurchPlanDate, today); + if (days > 0) { + purchResult = "NG"; + } else { + purchResult = ""; + } + } + } + vec.add(Integer.toString(purchDays));// ɹʱƻ + vec.add(purchResult);// ɹǷ񰴼ƻ + vec.add("");// ɹԭ + + days = 0; + if(!ysr8_MachinPlanDate.isEmpty()) { + if(!ysr8_TechPlanDate.isEmpty()) { + machinDays = CommonUtil.getDaysBetween(ysr8_TechPlanDate, ysr8_MachinPlanDate); + machinResult = ""; + }else if (!ysr8_MachFinishDate.isEmpty()) { + machinDays = CommonUtil.getDaysBetween(ysr8_ReplyDate, ysr8_MachinPlanDate); + days = CommonUtil.getDaysBetween(ysr8_MachinPlanDate, ysr8_MachFinishDate); + if (days > 0) { + machinResult = "NG"; + } else { + machinResult = "OK"; + } + }else if (ysr8_MachFinishDate.isEmpty()) { + machinDays = CommonUtil.getDaysBetween(ysr8_ReplyDate, ysr8_MachinPlanDate); + days = CommonUtil.getDaysBetween(ysr8_MachinPlanDate, today); + if (days > 0) { + machinResult = "NG"; + } else { + machinResult = ""; + } + } + } + vec.add(Integer.toString(machinDays));// ӹʱƻ + vec.add(machinResult);// ӹǷ񰴼ƻ + vec.add(prRevisionForm.getProperty("ysr8_MachReason2") + "" + prRevisionForm.getProperty("ysr8_MachReason"));// ӹԭ + ////////////////////////////////// + String engineerResult = "";//TODO Ƿ񰴼ƻ + int engineerPlanDay = 0; + if (!ysr8_EnginePlanDate.isEmpty()) { + if (!ysr8_MachinPlanDate.isEmpty()) + engineerPlanDay = CommonUtil.getDaysBetween(ysr8_MachinPlanDate, ysr8_EnginePlanDate); + else if (!ysr8_PurchPlanDate.isEmpty()) + engineerPlanDay = CommonUtil.getDaysBetween(ysr8_PurchPlanDate, ysr8_EnginePlanDate); + else if (!ysr8_TechPlanDate.isEmpty()) + engineerPlanDay = CommonUtil.getDaysBetween(ysr8_TechPlanDate, ysr8_EnginePlanDate); + else if (!ysr8_ReplyDate.isEmpty()) + engineerPlanDay = CommonUtil.getDaysBetween(ysr8_ReplyDate, ysr8_EnginePlanDate); + + if (!ysr8_MachinPlanDate.isEmpty()) { + if (machinResult.equals("NG") && !ysr8_PurchFinishDate.isEmpty()) { + if(!ysr8_FinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_PurchFinishDate, ysr8_FinishDate) - engineerPlanDay; + if (days <= 0) { + engineerResult = "OK"; + } else { + engineerResult = "NG"; + } + }else { + days = CommonUtil.getDaysBetween(ysr8_PurchFinishDate, today) - engineerPlanDay; + if (days <= 0) { + engineerResult = ""; + } else { + engineerResult = "NG"; + } + } + } else if (machinResult.equals("OK")) { + if(!ysr8_FinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_EnginePlanDate, ysr8_FinishDate); + if (days <= 0) { + engineerResult = "OK"; + } else { + engineerResult = "NG"; + } + }else{ + days = CommonUtil.getDaysBetween(ysr8_EnginePlanDate, today); + if (days <= 0) { + engineerResult = ""; + } else { + engineerResult = "NG"; + } + } + } else if (ysr8_PurchFinishDate.isEmpty()) { + engineerResult = ""; + } + }else if (!ysr8_PurchPlanDate.isEmpty()) { + if (purchResult.equals("NG") && !ysr8_PurchFinishDate.isEmpty()) { + if(!ysr8_FinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_PurchFinishDate, ysr8_FinishDate) - engineerPlanDay; + if (days <= 0) { + engineerResult = "OK"; + } else { + engineerResult = "NG"; + } + }else{ + days = CommonUtil.getDaysBetween(ysr8_PurchFinishDate, today) - engineerPlanDay; + if (days <= 0) { + engineerResult = ""; + } else { + engineerResult = "NG"; + } + } + } else if (purchResult.equals("OK")) { + if(!ysr8_FinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_EnginePlanDate, ysr8_FinishDate); + if (days <= 0) { + engineerResult = "OK"; + } else { + engineerResult = "NG"; + } + }else{ + days = CommonUtil.getDaysBetween(ysr8_EnginePlanDate, today); + if (days <= 0) { + engineerResult = ""; + } else { + engineerResult = "NG"; + } + } + } else if (ysr8_PurchFinishDate.isEmpty()) { + engineerResult = ""; + } + }else if (!ysr8_TechPlanDate.isEmpty()) { + engineerResult = ""; + }else { + if(!ysr8_FinishDate.isEmpty()) { + days = CommonUtil.getDaysBetween(ysr8_EnginePlanDate, ysr8_FinishDate); + if (days <= 0) { + engineerResult = "OK"; + } else { + engineerResult = "NG"; + } + }else{ + days = CommonUtil.getDaysBetween(ysr8_EnginePlanDate, today); + if (days <= 0) { + engineerResult = ""; + } else { + engineerResult = "NG"; + } + } + } + } + vec.add(Integer.toString(engineerPlanDay));// ʵʩʱƻ + vec.add(engineerResult);// ʵʩǷ񰴼ƻ + vec.add(prRevisionForm.getProperty("ysr8_ImplementReason") + "" + prRevisionForm.getProperty("ysr8_ReasonAnalysis2"));// ʵʩԭ + + + + int dqPlanDate = 0; + if (!ysr8_ReplyDate.isEmpty() && !ysr8_ElecDebug2PlanDate.isEmpty()) { + dqPlanDate = CommonUtil.getDaysBetween(ysr8_ReplyDate, ysr8_ElecDebug2PlanDate); + } + vec.add(Integer.toString(dqPlanDate)); + + String dqResult = ""; + int dqDays = 0; + if (!ysr8_ElecDebug2PlanDate.isEmpty() && !ysr8_ElecDebug2FinishDate.isEmpty()) { + dqDays = CommonUtil.getDaysBetween(ysr8_ElecDebug2PlanDate, ysr8_ElecDebug2FinishDate); + if (dqDays > 0) { + dqResult = "NG"; + } else { + dqResult = "OK"; + } + }else if (!ysr8_ElecDebug2PlanDate.isEmpty() && ysr8_ElecDebug2FinishDate.isEmpty()) { + dqDays = CommonUtil.getDaysBetween(ysr8_ElecDebug2PlanDate, today); + if (dqDays > 0) { + dqResult = "NG"; + } else { + dqResult = ""; + } + } + vec.add(dqResult); + vec.add(prRevisionForm.getProperty("ysr8_ElecReason")); + + + + + int jszxPlanDate = 0; + if (!ysr8_ReplyDate.isEmpty() && !ysr8_TechCenterPlanDate.isEmpty()) { + jszxPlanDate = CommonUtil.getDaysBetween(ysr8_ReplyDate, ysr8_TechCenterPlanDate); + } + vec.add(Integer.toString(jszxPlanDate)); + + String jszxResult = ""; + int jszxDays = 0; + if (!ysr8_TechCenterPlanDate.isEmpty() && !ysr8_TechCenterFinishDate.isEmpty()) { + jszxDays = CommonUtil.getDaysBetween(ysr8_TechCenterPlanDate, ysr8_TechCenterFinishDate); + if (jszxDays > 0) { + jszxResult = "NG"; + } else { + jszxResult = "OK"; + } + }else if (!ysr8_TechCenterPlanDate.isEmpty() && ysr8_TechCenterFinishDate.isEmpty()) { + jszxDays = CommonUtil.getDaysBetween(ysr8_TechCenterPlanDate, today); + if (jszxDays > 0) { + jszxResult = "NG"; + } else { + jszxResult = ""; + } + } + vec.add(jszxResult); + vec.add(prRevisionForm.getProperty("ysr8_TechCenterReason")); + + + ////////////////////////////////// + { + String hasPic = ""; + TCComponent[] components = prRevision.getRelatedComponents("IMAN_specification"); + if (components != null && components.length > 0) { + for (int k = 0; k < components.length; k++) { + if(components[k] instanceof TCComponentDataset){ + TCComponentDataset dataset = (TCComponentDataset) components[k]; + String object_typeVal = dataset.getProperty("object_type"); + if (object_typeVal.equalsIgnoreCase("JPEG") || + // object_typeVal.equalsIgnoreCase("λͼ") || + object_typeVal.equalsIgnoreCase("GIF") || object_typeVal.equalsIgnoreCase("Image") || object_typeVal.equalsIgnoreCase("ͼ") + || object_typeVal.equalsIgnoreCase("Яʽͼͼ")) { + hasPic = ""; + break; + } + } + } + } + + + + + + + vec.add(hasPic);// ǷϴͼƬ + } + + for (int k = 0; k < vec.size(); k++) { + if (vec.get(k).isEmpty()) { + vec.set(k, "-"); + } + } + ci.dataTableModel.addRow(vec); +// System.out.println(vec.get(0) + "=======" + prId); + prRevisions.put(vec.get(0), prRevision); + } + } + } catch (TCException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } + } + + private void outputYSR8_PR() { + File tempFile = TCUtil.findTemplete(fu.session, "YSR8_ProblemBoardTemplete", "ۺϿ"); + if (tempFile == null) { + return; + } + File reportFile_Sub = null; + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + int returnVal = fileChooser.showOpenDialog(fileChooser); + if (returnVal == JFileChooser.APPROVE_OPTION) { + String dir = fileChooser.getSelectedFile().getAbsolutePath();// ѡļе· + Date date = new Date(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + String time = sdf.format(date); + reportFile_Sub = new File(dir + "\\" + "ۺϿ" + time + ".xlsx"); + reportFile_Sub.delete(); + tempFile.renameTo(reportFile_Sub); + } + if (reportFile_Sub == null) { + return; + } + final File reportFile = reportFile_Sub; + + final JTable table = (JTable) fu.allComponentMap.get("a.31.11.11"); + final JButton btn = (JButton) fu.allComponentMap.get("b.11.12.21"); + btn.setEnabled(false); + + final ProgressReporterDialog reporter = new ProgressReporterDialog(); + reporter.reportProgressMessage("ڵ,Ժ..."); + new Thread(reporter).start(); + new Thread() { + public void run() { + FileInputStream fileIn = null; + FileOutputStream fileOut = null; + try { + fileIn = new FileInputStream(reportFile); + XSSFWorkbook sworkbook = new XSSFWorkbook(fileIn); + //sworkbook = new SXSSFWorkbook(new XSSFWorkbook(fileIn), 100); + XSSFSheet sheet = sworkbook.getSheetAt(0); + // ʽ + CellStyle style = sworkbook.createCellStyle(); + // ʽ + style.setBorderBottom(CellStyle.BORDER_THIN); + style.setBorderLeft(CellStyle.BORDER_THIN); + style.setBorderRight(CellStyle.BORDER_THIN); + style.setBorderTop(CellStyle.BORDER_THIN); + + // һͼĶ + Drawing drawing = sheet.createDrawingPatriarch(); + + // д + int columnCount = table.getColumnCount(); // + int rowCount = table.getRowCount(); // + // if (rowCount > 0) { + // POIUtil.insertRow(sheet, 1, rowCount - 1); + // } + // + // int current_row = 0; // ʼǰΪʼ + Vector pngFile = new Vector(); + // д + if (rowCount > 0) + insertRow(sheet, 1, rowCount); + for (int i = 0; i < rowCount; i++) { +// Row row = sheet.createRow(i + 1); + Row row = sheet.getRow(i + 1); + row.setHeightInPoints(sheet.getDefaultRowHeightInPoints()); + TCComponentItemRevision prRevision = prRevisions.get(table.getValueAt(i, 0).toString()); + Vector prDatasets = new Vector(); + if (prRevision != null && table.getValueAt(i, 59).toString().equalsIgnoreCase("")) { + TCComponent[] components = prRevision.getRelatedComponents("IMAN_specification"); + if (components != null && components.length > 0) { + for (int k = 0; k < components.length; k++) { + TCComponentDataset dataset = (TCComponentDataset) components[k]; + String object_typeVal = dataset.getProperty("object_type"); +// System.out.println("object_typeVal===========" + object_typeVal); + if (object_typeVal.equalsIgnoreCase("JPEG") || + // object_typeVal.equalsIgnoreCase("λͼ") || + object_typeVal.equalsIgnoreCase("GIF") || object_typeVal.equalsIgnoreCase("Image") + || object_typeVal.equalsIgnoreCase("ͼ") + || object_typeVal.equalsIgnoreCase("Яʽͼͼ")) { + prDatasets.add(dataset); + System.out.println("prDatasets.add(dataset)=======" + prDatasets.size()); + } + } + } + } + + Cell cell = row.createCell(0); + cell.setCellStyle(style); + cell.setCellValue((i + 1) + ""); + int j = 1; + byte[] imageByte; + for (int c = 1; c < columnCount; c++) { + Object objValue = table.getValueAt(i, c); +// cell = row.createCell(j); + cell = row.getCell(j); + if(cell == null) { + cell = row.createCell(j); + } +// cell.setCellStyle(style); +// cell.setCellValue(objValue.toString()); + try { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + cell.setCellValue(sdf.parse(objValue.toString())); + }catch(ParseException e1) { + cell.setCellValue(objValue == null ? "":objValue.toString()); + } +// j++; +// if(c<7) +// continue; +// j--; + if (c == 8) {// Ŀ + j++; + cell = row.createCell(j); + cell.setCellStyle(style); + if (prDatasets.size() > 0) { + TCComponentDataset dataset = prDatasets.get(0); + TCComponentTcFile tcfiles[] = dataset.getTcFiles(); + if (tcfiles != null && tcfiles.length > 0) { + String name = dataset.getProperty("object_string"); + String fileExt = tcfiles[0].getProperty("file_ext"); + File file = new File(CommonUtil.tmpDir, name + "." + fileExt); + if (file.exists()) { + file.delete(); + } + file = tcfiles[0].getFile(CommonUtil.tmpDir, name + "." + fileExt); + // TCUtil.convert(CommonUtil.tmpDir + name + "." + fileExt, "png", + // CommonUtil.tmpDir + name + ".png"); + // file = new File(CommonUtil.tmpDir + name + ".png"); + if (file.exists()) { + FileInputStream tempInput = new FileInputStream(file); + imageByte = IOUtils.toByteArray(tempInput); + /* + * BufferedImage bufferImg = ImageIO.read(file); ByteArrayOutputStream + * byteArrayOut = new ByteArrayOutputStream(); ImageIO.write(bufferImg, "png", + * byteArrayOut); + */ + XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 255, 255, j, i + 1, j + 1, i + 1 + 1); + anchor.setAnchorType(XSSFClientAnchor.MOVE_DONT_RESIZE); + int pic = addPic(sworkbook, imageByte, fileExt); + if (pic >= 0) { + drawing.createPicture(anchor, pic); + } + // drawing.createPicture(anchor, sworkbook.addPicture(imageByte, + // XSSFWorkbook.PICTURE_TYPE_PNG)); + // WritableImage image = new WritableImage(j, i + current_row, 1, 1, file); + // //col rowͼƬʼʼ width heightǶͼƬԽ + // wsheet.addImage(image); + pngFile.add(file.getCanonicalPath()); + IOUtils.closeQuietly(tempInput); + } + } + } + } + j++; + } + if (prDatasets.size() > 1) { + for (int k = 1; k < prDatasets.size(); k++) { + TCComponentDataset dataset = prDatasets.get(k); + TCComponentTcFile tcfiles[] = dataset.getTcFiles(); + if (tcfiles != null && tcfiles.length > 0) { + cell = row.createCell(j); + // cell.setCellStyle(style); + String name = dataset.getProperty("object_string"); + String fileExt = tcfiles[0].getProperty("file_ext"); + fileExt = fileExt.toLowerCase(); + File file = new File(CommonUtil.tmpDir, name); + if (file.exists()) { + file.delete(); + } + file = tcfiles[0].getFile(CommonUtil.tmpDir, name); + /* + * if (!fileExt.equals("png")) { TCUtil.convert(CommonUtil.tmpDir + name, "png", + * CommonUtil.tmpDir + name + ".png"); file = new File(CommonUtil.tmpDir + name + * + ".png"); } + */ + if (file.exists()) { + FileInputStream tempInput = new FileInputStream(file); + imageByte = IOUtils.toByteArray(tempInput); + /* + * BufferedImage bufferImg = ImageIO.read(file); ByteArrayOutputStream + * byteArrayOut = new ByteArrayOutputStream(); ImageIO.write(bufferImg, "png", + * byteArrayOut); + */ + XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 255, 255, j, i + 1, j + 1, i + 1 + 1); + anchor.setAnchorType(XSSFClientAnchor.MOVE_DONT_RESIZE); + int pic = addPic(sworkbook, imageByte, fileExt); + if (pic >= 0) { + drawing.createPicture(anchor, pic); + } + // WritableImage image = new WritableImage(j, i + current_row, 1, 1, file); + // //col rowͼƬʼʼ width heightǶͼƬԽ + // wsheet.addImage(image); + pngFile.add(file.getCanonicalPath()); + IOUtils.closeQuietly(tempInput); + } + j++; + } + } + } + } + fileOut = new FileOutputStream(reportFile.getPath()); + sworkbook.write(fileOut); + fileOut.flush(); + + for (Iterator iterator = pngFile.iterator(); iterator.hasNext();) { + File file = new File((String) iterator.next()); + if (file.exists()) { + file.delete(); + } + } + + // 򿪵ıļ + Runtime.getRuntime().exec("cmd /c \"" + reportFile.getPath() + "\""); + + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (fileOut != null) { + try { + fileOut.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (fileIn != null) { + try { + fileIn.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + reporter.requestCanceling(); + btn.setEnabled(true); + } + }.start(); + } + + private int addPic(XSSFWorkbook sworkbook, byte[] imageByte, String ext) { + switch (ext.toLowerCase()) { + case "png": + return sworkbook.addPicture(imageByte, XSSFWorkbook.PICTURE_TYPE_PNG); + case "bmp": + return sworkbook.addPicture(imageByte, XSSFWorkbook.PICTURE_TYPE_BMP); + case "jpg": + return sworkbook.addPicture(imageByte, XSSFWorkbook.PICTURE_TYPE_JPEG); + case "jpeg": + return sworkbook.addPicture(imageByte, XSSFWorkbook.PICTURE_TYPE_JPEG); + case "eps": + return sworkbook.addPicture(imageByte, XSSFWorkbook.PICTURE_TYPE_EPS); + case "gif": + return sworkbook.addPicture(imageByte, XSSFWorkbook.PICTURE_TYPE_GIF); + case "tiff": + return sworkbook.addPicture(imageByte, XSSFWorkbook.PICTURE_TYPE_TIFF); + case "wpg": + return sworkbook.addPicture(imageByte, XSSFWorkbook.PICTURE_TYPE_WPG); + case "dib": + return sworkbook.addPicture(imageByte, XSSFWorkbook.PICTURE_TYPE_DIB); + case "emp": + return sworkbook.addPicture(imageByte, XSSFWorkbook.PICTURE_TYPE_EMF); + case "pict": + return sworkbook.addPicture(imageByte, XSSFWorkbook.PICTURE_TYPE_PICT); + case "wmf": + return sworkbook.addPicture(imageByte, XSSFWorkbook.PICTURE_TYPE_WMF); + default: + return -1; + } + } + + private void viewYSR8_PRPic() { + JTable table = (JTable) fu.allComponentMap.get("a.31.11.11"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪ鿴ͼƬУ", "ʾ", MessageBox.INFORMATION); + return; + } + + TCComponentItemRevision prRevision = prRevisions.get(table.getValueAt(rows[0], 0).toString()); + if (prRevision == null) { + return; + } + if (!table.getValueAt(rows[0], 59).toString().equalsIgnoreCase("")) { + System.out.println("table.getValueAt(rows[0], 59).toString()================="+table.getValueAt(rows[0], 59).toString()); + MessageBox.post("ѡͼƬУ", "ʾ", MessageBox.INFORMATION); + return; + } + ShowPicFrame spf = new ShowPicFrame(this, true); + // spf.init(fu.session, + // prRevisions.get(Integer.parseInt(table.getValueAt(rows[0], 0).toString()) - + // 1)); + try { + System.out.println("View:" + table.getValueAt(rows[0], 0).toString() + "=======" + + (prRevisions.get(table.getValueAt(rows[0], 0).toString()) == null ? "" : prRevisions.get(table.getValueAt(rows[0], 0).toString()).getProperty("item_id"))); + } catch (TCException e) { + // Auto-generated catch block + e.printStackTrace(); + } + spf.init(fu.session, prRevisions.get(table.getValueAt(rows[0], 0).toString())); + spf.setModal(true); + } + + private void ViewSelInfo() { + JTable table31 = (JTable) fu.allComponentMap.get("a.31.11.11"); + int[] rows = table31.getSelectedRows(); + if (rows == null || rows.length == 0) { + return; + } + + JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.21.11.11"); + int rowCount = ci.dataTableModel.getRowCount(); + for (int i = rowCount - 1; i >= 0; i--) { + ci.dataTableModel.removeRow(i); + } + ci.dataTableModel.getDataVector().clear(); + + Vector vec = new Vector<>(); + vec.add(table31.getValueAt(rows[0], 0).toString()); + vec.add(table31.getValueAt(rows[0], 1).toString()); + vec.add(table31.getValueAt(rows[0], 2).toString()); + vec.add(table31.getValueAt(rows[0], 3).toString()); + vec.add(table31.getValueAt(rows[0], 4).toString()); + vec.add(table31.getValueAt(rows[0], 5).toString()); + vec.add(table31.getValueAt(rows[0], 6).toString()); + vec.add(table31.getValueAt(rows[0], 7).toString()); + vec.add(table31.getValueAt(rows[0], 8).toString()); + vec.add(table31.getValueAt(rows[0], 9).toString()); + vec.add(table31.getValueAt(rows[0], 10).toString()); + vec.add(table31.getValueAt(rows[0], 11).toString()); + ci.dataTableModel.addRow(vec); + } + private void insertRow(Sheet sheet, int starRow, int rows) { + if(starRow 0) { + renderer.setBackground(Color.RED); + } + } else { + if (ysr8_TechPlanDateVal.equals("-")) { + //renderer.setBackground(Color.RED); + } else { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + String currDate = sdf.format(new Date()); + int nday = CommonUtil.getDaysBetween(ysr8_TechPlanDateVal, currDate); + System.out.println("currDate-ysr8_TechPlanDateVal====" + currDate + "====" + ysr8_TechPlanDateVal + + "====" + nday); + if (nday > 0) { + renderer.setBackground(Color.RED); + } + } + } + } else if (column == 18) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + String ysr8_TechPlanDateVal = table.getValueAt(row, 15).toString(); + String ysr8_TechFinishDateVal = table.getValueAt(row, 16).toString(); + String ysr8_PurchPlanDateVal = table.getValueAt(row, 18).toString(); + if(ysr8_PurchPlanDateVal.equals("-")) + return renderer; + String ysr8_PurchFinishDateVal = table.getValueAt(row, 19).toString(); + + //TODO ɹƻʱ˳ + Calendar c = Calendar.getInstance(); + if(!ysr8_PurchPlanDateVal.equals("-") && !ysr8_TechPlanDateVal.equals("-") && !ysr8_TechFinishDateVal.equals("-")) { + int techDay = CommonUtil.getDaysBetween(ysr8_TechPlanDateVal, ysr8_TechFinishDateVal); + if (techDay > 0) { + c.setTime(sdf.parse(ysr8_PurchPlanDateVal)); + c.add(Calendar.DAY_OF_MONTH, techDay); + ysr8_PurchPlanDateVal = sdf.format(c.getTime()); + } + } + + if (!ysr8_PurchPlanDateVal.equals("-") && !ysr8_PurchFinishDateVal.equals("-")) { + int nday = CommonUtil.getDaysBetween(ysr8_PurchPlanDateVal, ysr8_PurchFinishDateVal); + System.out.println("ysr8_PurchFinishDateVal-ysr8_PurchPlanDateVal====" + ysr8_PurchFinishDateVal + + "====" + ysr8_PurchPlanDateVal + "====" + nday); + if (nday > 0) { + renderer.setBackground(Color.RED); + } + } else { + if (ysr8_PurchPlanDateVal.equals("-") || ysr8_TechFinishDateVal.equals("-")&&!ysr8_TechPlanDateVal.equals("-")) { + //renderer.setBackground(Color.RED); + } else { + String currDate = sdf.format(new Date()); + int nday = CommonUtil.getDaysBetween(ysr8_PurchPlanDateVal, currDate); + System.out.println("currDate-ysr8_PurchPlanDateVal====" + currDate + "====" + ysr8_PurchPlanDateVal + + "====" + nday); + if (nday > 0) { + renderer.setBackground(Color.RED); + } + } + } + } else if (column == 21) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + String ysr8_TechPlanDateVal = table.getValueAt(row, 15).toString(); + String ysr8_TechFinishDateVal = table.getValueAt(row, 16).toString(); + String ysr8_MachinPlanDateVal = table.getValueAt(row, 21).toString(); + if(ysr8_MachinPlanDateVal.equals("-")) + return renderer; + String ysr8_MachinFinishDateVal = table.getValueAt(row, 22).toString(); + + //TODO ӹƻʱ˳ + Calendar c = Calendar.getInstance(); + if(!ysr8_MachinPlanDateVal.equals("-") && !ysr8_TechPlanDateVal.equals("-") && !ysr8_TechFinishDateVal.equals("-")) { + int techDay = CommonUtil.getDaysBetween(ysr8_TechPlanDateVal, ysr8_TechFinishDateVal); + if (techDay > 0) { + c.setTime(sdf.parse(ysr8_MachinPlanDateVal)); + c.add(Calendar.DAY_OF_MONTH, techDay); + ysr8_MachinPlanDateVal = sdf.format(c.getTime()); + } + } + + if (!ysr8_MachinPlanDateVal.equals("-") && !ysr8_MachinFinishDateVal.equals("-")) { + int nday = CommonUtil.getDaysBetween(ysr8_MachinPlanDateVal, ysr8_MachinFinishDateVal); + System.out.println("ysr8_PurchFinishDateVal-ysr8_MachinPlanDateVal====" + ysr8_MachinFinishDateVal + + "====" + ysr8_MachinPlanDateVal + "====" + nday); + if (nday > 0) { + renderer.setBackground(Color.RED); + } + } else { + if (ysr8_MachinPlanDateVal.equals("-") || ysr8_TechFinishDateVal.equals("-")&&!ysr8_TechPlanDateVal.equals("-")) { + //renderer.setBackground(Color.RED); + } else { + String currDate = sdf.format(new Date()); + int nday = CommonUtil.getDaysBetween(ysr8_MachinPlanDateVal, currDate); + System.out.println("currDate-ysr8_PurchPlanDateVal====" + currDate + "====" + ysr8_MachinPlanDateVal + + "====" + nday); + if (nday > 0) { + renderer.setBackground(Color.RED); + } + } + } + } else if (column == 25) { + String ysr8_EnginePlanDateVal = table.getValueAt(row, 25).toString(); + if(ysr8_EnginePlanDateVal.equals("-")) + return renderer; + String ysr8_FinishDateVal = table.getValueAt(row, 26).toString(); + String ysr8_TechPlanDateVal = table.getValueAt(row, 15).toString(); + String ysr8_PurchPlanDateVal = table.getValueAt(row, 18).toString(); + String ysr8_MachinPlanDateVal = table.getValueAt(row, 21).toString(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + //TODO + Calendar c = Calendar.getInstance(); + if(!ysr8_MachinPlanDateVal.equals("-")) { + String ysr8_MachinFinishDateVal = table.getValueAt(row, 22).toString(); + if(!ysr8_MachinFinishDateVal.equals("-")) { + int techDay = CommonUtil.getDaysBetween(ysr8_MachinPlanDateVal, ysr8_MachinFinishDateVal); + if (techDay > 0) { + c.setTime(sdf.parse(ysr8_EnginePlanDateVal)); + c.add(Calendar.DAY_OF_MONTH, techDay); + ysr8_EnginePlanDateVal = sdf.format(c.getTime()); + } + } + }else if(!ysr8_PurchPlanDateVal.equals("-")) { + String ysr8_PurchFinishDateVal = table.getValueAt(row, 19).toString(); + if(!ysr8_PurchFinishDateVal.equals("-")) { + int techDay = CommonUtil.getDaysBetween(ysr8_PurchPlanDateVal, ysr8_PurchFinishDateVal); + if (techDay > 0) { + c.setTime(sdf.parse(ysr8_EnginePlanDateVal)); + c.add(Calendar.DAY_OF_MONTH, techDay); + ysr8_EnginePlanDateVal = sdf.format(c.getTime()); + } + } + }else if(!ysr8_TechPlanDateVal.equals("-")) { + String ysr8_TechFinishDateVal = table.getValueAt(row, 16).toString(); + if(!ysr8_TechFinishDateVal.equals("-")) { + int techDay = CommonUtil.getDaysBetween(ysr8_TechPlanDateVal, ysr8_TechFinishDateVal); + if (techDay > 0) { + c.setTime(sdf.parse(ysr8_EnginePlanDateVal)); + c.add(Calendar.DAY_OF_MONTH, techDay); + ysr8_EnginePlanDateVal = sdf.format(c.getTime()); + } + } + } + + if (!ysr8_EnginePlanDateVal.equals("-") && !ysr8_FinishDateVal.equals("-")) { + int nday = CommonUtil.getDaysBetween(ysr8_EnginePlanDateVal, ysr8_FinishDateVal); + System.out.println("ysr8_PurchFinishDateVal-ysr8_EnginePlanDateVal====" + ysr8_FinishDateVal + + "====" + ysr8_EnginePlanDateVal + "====" + nday); + if (nday > 0) { + renderer.setBackground(Color.RED); + } + } else { + if (ysr8_EnginePlanDateVal.equals("-")) { + //renderer.setBackground(Color.RED); + } else { + String currDate = sdf.format(new Date()); + int nday = CommonUtil.getDaysBetween(ysr8_EnginePlanDateVal, currDate); + System.out.println("currDate-ysr8_PurchPlanDateVal====" + currDate + "====" + ysr8_EnginePlanDateVal + + "====" + nday); + if (nday > 0) { + renderer.setBackground(Color.RED); + } + } + } + }*/ + }catch(Exception e) { + e.printStackTrace(); + } + + return renderer; + } +} \ No newline at end of file diff --git a/src/cn/com/ebewin/ysr/dialog/ProgressReporterDialog.java b/src/cn/com/ebewin/ysr/dialog/ProgressReporterDialog.java new file mode 100644 index 0000000..5aacb72 --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/ProgressReporterDialog.java @@ -0,0 +1,126 @@ +package cn.com.ebewin.ysr.dialog; + +import java.awt.BorderLayout; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.Toolkit; + +import javax.swing.JLabel; +import javax.swing.JProgressBar; + +import com.teamcenter.rac.aif.AbstractAIFDialog; + +@SuppressWarnings("serial") +public class ProgressReporterDialog extends AbstractAIFDialog +{ + + private JLabel messageLabel; + + private JProgressBar progressBar; + + private boolean requestCanceling; + + private int percent; + + public ProgressReporterDialog() + { + super(false); + + setLayout(new BorderLayout()); + setAlwaysOnTop(true); + + initializeComponents(); + setTextPropertyForComponents(); + registerComponentsListeners(); + addComponents(); + + setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + } + + private void initializeComponents() + { + messageLabel = new JLabel(" ", JLabel.LEFT); + progressBar = new JProgressBar(); + } + + private void setTextPropertyForComponents() + { + setTitle(""); + } + + private void registerComponentsListeners() + { + } + + private void addComponents() + { + add(messageLabel, BorderLayout.NORTH); + add(progressBar, BorderLayout.SOUTH); + } + + private void centerToClientScreen() + { + Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); + + int x = screen.width - getWidth(); + int y = screen.height - getHeight(); + + setLocation(x / 2, y / 2); + } + + public void reportProgressMessage(String message) + { + messageLabel.setText(message); + } + + public void setProgressPercent(int percent) + { + this.percent = percent; + } + + public void requestCanceling() + { + requestCanceling = true; + } + + public void run() + { + pack(); + setSize(400, getHeight()); + centerToClientScreen(); + setVisible(true); + + while (!requestCanceling) + { + if(percent > progressBar.getMaximum()) + { + percent = 0; + } + + progressBar.setValue(percent); + + percent += 5; + + try + { + Thread.sleep(100); + } + catch (InterruptedException e) + { + continue; + } + } + + dispose(); + } + + public int getProgess() + { + return progressBar.getValue(); + } + + public boolean isRequestCanceling() + { + return requestCanceling; + } +} diff --git a/src/cn/com/ebewin/ysr/dialog/QualityManagementBoardDialog.java b/src/cn/com/ebewin/ysr/dialog/QualityManagementBoardDialog.java new file mode 100644 index 0000000..7624acd --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/QualityManagementBoardDialog.java @@ -0,0 +1,2014 @@ +package cn.com.ebewin.ysr.dialog; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.io.File; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Vector; + +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JTable; + +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentRole; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.iTextField; + +import cn.com.ebewin.ysr.util.CommonUtil; +import cn.com.ebewin.ysr.util.DialogUtil; +import cn.com.ebewin.ysr.util.FormUtil; +import cn.com.ebewin.ysr.util.KUtil; +import cn.com.ebewin.ysr.util.TCUtil; +import cn.com.ebewin.ysr.util.UIUtil.JComboBoxInfo; +import cn.com.ebewin.ysr.util.UIUtil.JTableInfo; +import jxl.Workbook; +import jxl.format.Alignment; +import jxl.format.Border; +import jxl.format.BorderLineStyle; +import jxl.format.VerticalAlignment; +import jxl.write.Label; +import jxl.write.WritableCellFormat; +import jxl.write.WritableFont; +import jxl.write.WritableSheet; +import jxl.write.WritableWorkbook; +import jxl.write.WriteException; + +@SuppressWarnings("deprecation") +public class QualityManagementBoardDialog extends JFrame { + private static final long serialVersionUID = 1L; + DialogUtil fu = new DialogUtil(this, "ʼ", "YSR8_QualityManagementBoardDialog"); + HashMap allObjectMap1 = new HashMap(); + HashMap allObjectMap1Idx = new HashMap(); + HashMap allObjectMap2 = new HashMap(); + HashMap allObjectMap2Idx = new HashMap(); + int currTable = 0; + + LinkedHashMap lovysr8_SubTaskManuState; + LinkedHashMap lovysr8_ysr8_SubQualityResult; + private JButton searBtn; + public TCSession session; + + private static final int SJ_STATE_INDEX = 7; + private static final int SJ_ARRIVED_INDEX = 8; + private static final int SJ_EXAMINED_INDEX = 10; + private static final int SJ_ID_INDEX = 1; + private static final int SJ_ZJWCSJ_INDEX=12; + private static final int SJ_ZJJL_INDEX=13; + private static final int SJ_JGC1_INDEX=14; + private static final int SJ_JGC2_INDEX=15; + + private static final int BJ_NAME_INDEX=2; + private static final int BJ_SJWCSJ_INDEX=12; + private static final int BJ_ZJJL_INDEX=14; + private static final int BJ_JGC1_INDEX=15; + private static final int BJ_JGC2_INDEX=16; + private Date date1 = null; + private Date date2 = null; + + + public QualityManagementBoardDialog(TCSession session) throws TCException { + // super(true); + + this.session = session; + lovysr8_SubTaskManuState = TCUtil.getlovValues(session, "YSR8_ScheduleTask02_LOV"); + lovysr8_ysr8_SubQualityResult = TCUtil.getlovValues(session, "YSR8_INSPR3_LOV"); + + fu.initializeUI(session); + JTable table = (JTable) fu.allComponentMap.get("a.41.11.11"); + table.setAutoCreateRowSorter(true); + table = (JTable) fu.allComponentMap.get("a.61.11.11"); + table.setAutoCreateRowSorter(true); + + // centerToScreen(); + this.setLocationRelativeTo(null); + this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); + + loadRendering(); + addActionListener(); + setVisible(true); + } + + private void loadRendering() throws TCException { + } + + private void setEnableBtns(boolean b) { + JButton btn; + btn = (JButton) fu.allComponentMap.get("b.11.16"); + btn.setEnabled(b); + btn = (JButton) fu.allComponentMap.get("b.11.17"); + btn.setEnabled(b); + btn = (JButton) fu.allComponentMap.get("b.21.14"); + btn.setEnabled(b); + btn = (JButton) fu.allComponentMap.get("b.21.15"); + btn.setEnabled(b); + } + + private void addActionListener() { + this.searBtn = (JButton) fu.allComponentMap.get("b.11.16"); + searBtn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + new Thread(new Runnable() { + @Override + public void run() { + searBtn.setText("ѯ..."); + setEnableBtns(false); + try { + searchQualityInfo(); + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post(QualityManagementBoardDialog.this, e.toString(), "ѯ", MessageBox.ERROR); + } + setEnableBtns(true); + searBtn.setText("ѯ"); + } + }).start(); + } + }); + JButton btn; + btn = (JButton) fu.allComponentMap.get("b.11.17"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + editQualityInfo(); + } + }); + + btn = (JButton) fu.allComponentMap.get("b.21.14"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + outputQualityInfo(); + } + }); + + btn = (JButton) fu.allComponentMap.get("b.21.15"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + createQualityInfo(); + } + }); + + final JTable table1 = (JTable) fu.allComponentMap.get("a.41.11.11"); + final JTable table2 = (JTable) fu.allComponentMap.get("a.61.11.11"); + table1.addMouseListener(new java.awt.event.MouseAdapter() { + public void mousePressed(MouseEvent e) {// 굥ʱӦ + currTable = 1; + table2.clearSelection(); + } + }); + + table2.addMouseListener(new java.awt.event.MouseAdapter() { + public void mousePressed(MouseEvent e) {// 굥ʱӦ + currTable = 2; + table1.clearSelection(); + } + }); + } + + @SuppressWarnings({ "unchecked" }) + private void searchQualityInfo() throws Exception { + allObjectMap1.clear(); + allObjectMap2.clear(); + allObjectMap2Idx.clear(); + + JTableInfo ci1 = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.41.11.11"); + int rowCount = ci1.dataTableModel.getRowCount(); + for (int i = rowCount - 1; i >= 0; i--) { + ci1.dataTableModel.removeRow(i); + } + ci1.dataTableModel.getDataVector().clear(); + + JTableInfo ci2 = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.61.11.11"); + rowCount = ci2.dataTableModel.getRowCount(); + for (int i = rowCount - 1; i >= 0; i--) { + ci2.dataTableModel.removeRow(i); + } + ci2.dataTableModel.getDataVector().clear(); + + iTextField textField = (iTextField) fu.allComponentMap.get("XMH"); + String XMH = textField.getText().toString(); + + JComboBox cbx = (JComboBox) fu.allComponentMap.get("JGC"); + JComboBoxInfo cii = (JComboBoxInfo) fu.allComponentInfos.get("JGC"); + String JGC = cbx.getSelectedItem().toString(); + if (cii.lovVal != null) { + Iterator iter = cii.lovVal.keySet().iterator(); + while (iter.hasNext()) { + String lovKey = iter.next(); + String lovValue = cii.lovVal.get(lovKey); + if (lovValue.equalsIgnoreCase(JGC)) { + JGC = lovKey; + break; + } + } + } + + date1 = null; + date2 = null; + DateButton db = (DateButton)fu.allComponentMap.get("c_ysr8_Date1"); + date1 = db.getDate(); + String ysr8_Date1 = ""; + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-d"); + if (date1 != null) { + ysr8_Date1 = sdf.format(date1) + " 00:00"; + } + db = (DateButton)fu.allComponentMap.get("c_ysr8_Date2"); + date2 = db.getDate(); + String ysr8_Date2 = ""; + if (date2 != null) { + ysr8_Date2 = sdf.format(date2) + " 23:59"; + } + + //textField = (iTextField) fu.allComponentMap.get("FZR"); + //String FZR = textField.getText().toString(); + + JCheckBox ckb1 = (JCheckBox) fu.allComponentMap.get("BJ"); + JCheckBox ckb2 = (JCheckBox) fu.allComponentMap.get("SJ"); + if (ckb1.isSelected()) { + { + Vector attrVec = new Vector(); + Vector valVec = new Vector(); + Vector attrVec2 = new Vector(); + Vector valVec2 = new Vector(); + + + attrVec.add(";"); + valVec.add("2;6"); + attrVec2.add(";"); + valVec2.add("2;6"); + attrVec.add("fnd0status1"); + valVec.add("aborted"); + attrVec2.add("fnd0status1"); + valVec2.add("aborted"); + + if (!XMH.equals("") && !XMH.equals("*")) { + attrVec.add("Ŀ ID"); + valVec.add(XMH); + attrVec2.add("Ŀ ID"); + valVec2.add(XMH); + attrVec.add("ӹ״̬"); + valVec.add("3;4;5"); + attrVec2.add("ӹ״̬"); + valVec2.add("3;4;5"); + } else { + attrVec.add("Ŀ ID"); + valVec.add("*"); + attrVec2.add("Ŀ ID"); + valVec2.add("*"); + attrVec.add("ӹ״̬"); + valVec.add("3;5"); + attrVec2.add("ӹ״̬"); + valVec2.add("3;5"); + } + if (!JGC.equals("")) { + attrVec.add("ӹ1"); + valVec.add(JGC); + attrVec2.add("ӹ2"); + valVec2.add(JGC); + } + if(!ysr8_Date1.equals("")) { + attrVec.add("ysr8_PurchFinishDate1"); + valVec.add(ysr8_Date1); + attrVec2.add("ysr8_PurchFinishDate1"); + valVec2.add(ysr8_Date1); + } + if(!ysr8_Date2.equals("")) { + attrVec.add("ysr8_PurchFinishDate2"); + valVec.add(ysr8_Date2); + attrVec2.add("ysr8_PurchFinishDate2"); + valVec2.add(ysr8_Date2); + } + /*if (!FZR.equals("")) { + attrVec.add("ӹ"); + valVec.add(FZR); + }*/ + + String[] attrs = (String[]) attrVec.toArray(new String[attrVec.size()]); + String[] vals = (String[]) valVec.toArray(new String[attrVec.size()]); + System.out.println(attrVec+"::"+valVec); + searchQualityInfo_SchedulTask(XMH, attrs, vals); + if(!JGC.isEmpty()) { + attrs = (String[]) attrVec2.toArray(new String[attrVec2.size()]); + vals = (String[]) valVec2.toArray(new String[attrVec2.size()]); + searchQualityInfo_SchedulTask(XMH, attrs, vals); + } + } + { + Vector attrVec = new Vector(); + Vector valVec = new Vector(); + Vector attrVec2 = new Vector(); + Vector valVec2 = new Vector(); + + attrVec.add("ysr8_Classfication"); + valVec.add("2"); + attrVec2.add("ysr8_Classfication"); + valVec2.add("2"); + attrVec.add("ysr8_TaskManuState"); + valVec.add("3;5"); + attrVec2.add("ysr8_TaskManuState"); + valVec2.add("3;5"); + + if (!XMH.equals("") && !XMH.equals("*")) { + attrVec.add("ysr8_ProjectCode"); + valVec.add(XMH); + attrVec2.add("ysr8_ProjectCode"); + valVec2.add(XMH); + } + if(!ysr8_Date1.equals("")) { + attrVec.add("ysr8_PurchFinishDate1"); + valVec.add(ysr8_Date1); + attrVec2.add("ysr8_PurchFinishDate1"); + valVec2.add(ysr8_Date1); + } + if(!ysr8_Date2.equals("")) { + attrVec.add("ysr8_PurchFinishDate2"); + valVec.add(ysr8_Date2); + attrVec2.add("ysr8_PurchFinishDate2"); + valVec2.add(ysr8_Date2); + } + if (!JGC.equals("")) { + attrVec.add("ysr8_ManuFactory1"); + valVec.add(JGC); + attrVec2.add("ysr8_ManuFactory2"); + valVec2.add(JGC); + } + /*if (!FZR.equals("")) { + attrVec.add("ysr8_ManuPerson"); + valVec.add(FZR); + }*/ + + String[] attrs = (String[]) attrVec.toArray(new String[attrVec.size()]); + String[] vals = (String[]) valVec.toArray(new String[attrVec.size()]); + System.out.println(attrVec+"::"+valVec); + searchQualityInfo_YSR8_DrawingList(XMH, attrs, vals); + if(!JGC.isEmpty()) { + attrs = (String[]) attrVec2.toArray(new String[attrVec2.size()]); + vals = (String[]) valVec2.toArray(new String[attrVec2.size()]); + searchQualityInfo_YSR8_DrawingList(XMH, attrs, vals); + } + } + } + if (ckb2.isSelected()) { + { + Vector attrVec = new Vector(); + Vector valVec = new Vector(); + Vector attrVec2 = new Vector(); + Vector valVec2 = new Vector(); + + if (!XMH.equals("") && !XMH.equals("*")) { + attrVec.add("ysr8_ProjectCode"); + valVec.add(XMH); + attrVec2.add("ysr8_ProjectCode"); + valVec2.add(XMH); + } else { + attrVec.add("ysr8_ProjectCode"); + valVec.add("*"); + attrVec2.add("ysr8_ProjectCode"); + valVec2.add("*"); + } + attrVec.add("ӹ״̬"); + valVec.add("3;5"); + attrVec2.add("ӹ״̬"); + valVec2.add("3;5"); + if (!JGC.equals("")) { + attrVec.add("ysr8_ManuFactory1"); + valVec.add(JGC); + attrVec2.add("ysr8_ManuFactory2"); + valVec2.add(JGC); + } + if(!ysr8_Date1.equals("")) { + attrVec.add("1"); + valVec.add(ysr8_Date1); + attrVec2.add("1"); + valVec2.add(ysr8_Date1); + } + if(!ysr8_Date2.equals("")) { + attrVec.add("2"); + valVec.add(ysr8_Date2); + attrVec2.add("2"); + valVec2.add(ysr8_Date2); + } + /*if (!FZR.equals("")) { + attrVec.add("ysr8_ManuPerson"); + valVec.add(FZR); + }*/ + + String[] attrs = (String[]) attrVec.toArray(new String[attrVec.size()]); + String[] vals = (String[]) valVec.toArray(new String[attrVec.size()]); + System.out.println(attrVec+"::"+valVec); + + searchQualityInfo_YSR8_ECN2(JGC, attrs, vals); + searchQualityInfo_YSR8_ECN4(JGC, attrs, vals); + if(!JGC.isEmpty()) { + attrs = (String[]) attrVec2.toArray(new String[attrVec2.size()]); + vals = (String[]) valVec2.toArray(new String[attrVec2.size()]); + searchQualityInfo_YSR8_ECN2(JGC, attrs, vals); + searchQualityInfo_YSR8_ECN4(JGC, attrs, vals); + } + } + { + Vector attrVec = new Vector(); + Vector valVec = new Vector(); + Vector attrVec2 = new Vector(); + Vector valVec2 = new Vector(); + +// attrVec1.add("ysr8_PartType"); +// valVec1.add("2"); +// attrVec2.add("ysr8_PartType"); +// valVec2.add("1"); + + if (!XMH.equals("") && !XMH.equals("*")) { + attrVec.add("ysr8_ProjectCode"); + valVec.add(XMH); + attrVec2.add("ysr8_ProjectCode"); + valVec2.add(XMH); + } else { + attrVec.add("ysr8_ProjectCode"); + valVec.add("*"); + attrVec2.add("ysr8_ProjectCode"); + valVec2.add("*"); + } + attrVec.add("ӹ״̬"); + valVec.add("3;5"); + attrVec2.add("ӹ״̬"); + valVec2.add("3;5"); + if (!JGC.equals("")) { + attrVec.add("ysr8_ManuFactory1"); + valVec.add(JGC); + attrVec2.add("ysr8_ManuFactory2"); + valVec2.add(JGC); + } + if(!ysr8_Date1.equals("")) { + attrVec.add("1"); + valVec.add(ysr8_Date1); + attrVec2.add("1"); + valVec2.add(ysr8_Date1); + } + if(!ysr8_Date2.equals("")) { + attrVec.add("2"); + valVec.add(ysr8_Date2); + attrVec2.add("2"); + valVec2.add(ysr8_Date2); + } + /*if (!FZR.equals("")) { + attrVec1.add("ysr8_ManuPerson"); + valVec1.add(FZR); + attrVec2.add("ysr8_ManuPerson"); + valVec2.add(FZR); + }*/ + + String[] attrs = (String[]) attrVec.toArray(new String[attrVec.size()]); + String[] vals = (String[]) valVec.toArray(new String[attrVec.size()]); + System.out.println(attrVec+"::"+valVec); + searchMachiningInfo_YSR8_SingleRepairBJ(attrs, vals); + if(!JGC.isEmpty()) { + String[] attrs2 = (String[]) attrVec2.toArray(new String[attrVec2.size()]); + String[] vals2 = (String[]) valVec2.toArray(new String[attrVec2.size()]); + searchMachiningInfo_YSR8_SingleRepairBJ(attrs2, vals2); + } + } + } + } + + private void searchQualityInfo_SchedulTask(String XMH, String[] attrs, String[] vals) throws Exception { + JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.41.11.11"); + TCComponent[] tcComponents = TCUtil.query(fu.session, "SearchSchedulTaskQM", attrs, vals); + Integer idx = ci.dataTableModel.getRowCount(); + for (int i = 0; i < tcComponents.length; i++) { + TCComponentScheduleTask scheduTask = (TCComponentScheduleTask) tcComponents[i]; + scheduTask.refresh(); + + String ysr8_TaskUse = scheduTask.getProperty("ysr8_TaskUse"); + String ysr8_ArrivedQuantity = "",ysr8_ExaminedQuantity = scheduTask.getProperty("ysr8_ExaminedQuantity"); + if(ysr8_TaskUse.equals("")) { + ysr8_ArrivedQuantity = scheduTask.getProperty("ysr8_WiredQuantity"); + } else { + ysr8_ArrivedQuantity = scheduTask.getProperty("ysr8_ArrivedQuantity"); + } + if("".equals(XMH) || "*".equals(XMH)) { + if(ysr8_ArrivedQuantity == null || ysr8_ArrivedQuantity.equals(ysr8_ExaminedQuantity)) + continue; + } + Vector vec = new Vector<>(); + vec.add((++idx) + "");// + vec.add(scheduTask.getProperty("ysr8_ProjectCode"));// Ŀ + String object_nameVal = scheduTask.getProperty("object_name"); + vec.add(object_nameVal);// + String itemID = ""; +// Vector itemIdPart = CommonUtil.split2Vector(object_nameVal, "_"); +// if (itemIdPart.size() > 1) { //kk bug Ұѭiijj +// for (int j = 0; j < itemIdPart.size() - 1; j++) { +// itemID += itemIdPart.get(j); +// if (j + 1 == itemIdPart.size() - 1) { +// +// } else { +// itemID += "_"; +// } +// } +// } + if(object_nameVal.indexOf("")>=0) { + object_nameVal = object_nameVal.substring(object_nameVal.indexOf("")+1, object_nameVal.length()); + } + Vector itemIdPart = CommonUtil.split2Vector(object_nameVal, "-"); + if (itemIdPart.size() > 1) { + itemID = itemIdPart.get(0) +"-"+ itemIdPart.get(1); + } + + String owning_userVal = "", date_releasedVal = ""; + if (!itemID.equals("")) { + TCComponentItem partItem = TCUtil.findItemByID(fu.session, itemID); + if (partItem != null) { + owning_userVal = partItem.getProperty("owning_user"); + date_releasedVal = fu.getDateString(partItem.getDateProperty("date_released")); + } + + } + vec.add(owning_userVal);// + vec.add(scheduTask.getProperty("ysr8_PartNumber"));// + vec.add(scheduTask.getProperty("ysr8_TaskManuState"));// ״̬ + + // kk 0911 + vec.add(ysr8_ArrivedQuantity); // ѵ + if(ysr8_TaskUse.equals("")) { +// vec.add(scheduTask.getProperty("ysr8_WiredQuantity")); // ѵ + vec.add(scheduTask.getProperty("ysr8_WiringQuantity")); // ε + } else { +// vec.add(scheduTask.getProperty("ysr8_ArrivedQuantity")); // ѵ + vec.add(scheduTask.getProperty("ysr8_ArrivingQuantity")); // ε + } + vec.add(ysr8_ExaminedQuantity); // Ѽ + vec.add(scheduTask.getProperty("ysr8_ExaminingQuantity")); // μ + vec.add(scheduTask.getProperty("ysr8_TaskUse"));// ; + + + vec.add(scheduTask.getProperty("ysr8_Factory"));// + vec.add(fu.getDateString(scheduTask.getDateProperty("ysr8_PurchFinishDate")));// ӹʵʱ + vec.add(fu.getDateString(scheduTask.getDateProperty("ysr8_SubQualityFinishDate")));// ʼʱ + vec.add(scheduTask.getProperty("ysr8_SubQualityResult"));// ʼ + vec.add(scheduTask.getProperty("ysr8_ManuFactory1"));// ӹ1 + vec.add(scheduTask.getProperty("ysr8_ManuFactory2"));// ӹ2 + vec.add(scheduTask.getProperty("ysr8_ManuPerson"));// ӹ + vec.add(date_releasedVal);// ͼ + vec.add(scheduTask.getProperty("start_date"));// ʼ + vec.add(scheduTask.getProperty("ysr8_PurchPlanDate"));// Ҫӹʱ + vec.add(scheduTask.getProperty("ysr8_DrawingReleaseDate"));// ͼ + + // vec.add(lovysr8_SubTaskManuState.get(scheduTask.getProperty("ysr8_TaskManuState")));//״̬ + + ci.dataTableModel.addRow(vec); + allObjectMap1.put(idx - 1, scheduTask); + allObjectMap1Idx.put(idx - 1, 0); + } + } + + private void searchQualityInfo_YSR8_DrawingList(String XMH, String[] attrs, String[] vals) throws Exception { + JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.41.11.11"); + TCComponent[] tcComponents = TCUtil.query(fu.session, "SearchDrawingListForQM", attrs, vals); + Integer idx = ci.dataTableModel.getRowCount(); + for (int i = 0; i < tcComponents.length; i++) { + TCComponentItemRevision dlRevision = (TCComponentItemRevision) tcComponents[i]; + TCComponentItem dlItem = dlRevision.getItem(); + TCComponentForm dlForm = TCUtil.getItemRevisionMasterForm(dlRevision); + dlForm.refresh(); + + String ysr8_ArrivedQuantity = dlForm.getProperty("ysr8_ArrivedQuantity"), + ysr8_ExaminedQuantity = dlForm.getProperty("ysr8_ExaminedQuantity"); + Date ysr8_SubQualityFinishDate = dlForm.getDateProperty("ysr8_SubQualityFinishDate"); + if(!"".equals(XMH) && !"*".equals(XMH)) { + if(ysr8_ArrivedQuantity == null || ysr8_ArrivedQuantity.equals(ysr8_ExaminedQuantity) && ysr8_SubQualityFinishDate!=null) + continue; + } else { + if(ysr8_ArrivedQuantity == null || ysr8_ArrivedQuantity.equals(ysr8_ExaminedQuantity)) + continue; + } + Vector vec = new Vector<>(); + vec.add((++idx) + "");// + vec.add(dlForm.getProperty("ysr8_ProjectCode"));// Ŀ +// String object_nameVal = "滻׷" + dlForm.getProperty("ysr8_AssemNo"); + String object_nameVal = "滻׷" + dlItem.getProperty("item_id"); + vec.add(object_nameVal);// + vec.add(dlForm.getProperty("owning_user"));// +// vec.add(dlForm.getProperty("ysr8_PartNumber"));// + vec.add(dlForm.getProperty("ysr8_AddOrReplaceQuantity"));// + vec.add(dlForm.getProperty("ysr8_TaskManuState"));// ״̬ + + // kk 0911 + vec.add(ysr8_ArrivedQuantity); // ѵ + vec.add(dlForm.getProperty("ysr8_ArrivingQuantity")); // ε + vec.add(ysr8_ExaminedQuantity); // Ѽ + vec.add(dlForm.getProperty("ysr8_ExaminingQuantity")); // μ + vec.add(dlForm.getProperty("ysr8_TaskUse"));// ; + + vec.add("");// + vec.add(fu.getDateString(dlForm.getDateProperty("ysr8_PurchFinishDate")));// ӹʵʱ + vec.add(fu.getDateString(dlForm.getDateProperty("ysr8_SubQualityFinishDate")));// ʼʱ + vec.add(dlForm.getProperty("ysr8_SubQualityResult"));// ʼ + vec.add(dlForm.getProperty("ysr8_ManuFactory1"));// ӹ1 + vec.add(dlForm.getProperty("ysr8_ManuFactory2"));// ӹ2 + vec.add(dlForm.getProperty("ysr8_ManuPerson"));// ӹ + vec.add(dlForm.getProperty("ysr8_ReleaseDate"));// ͼ + vec.add("");// ʼ + vec.add(dlForm.getProperty("ysr8_PurchPlanDate"));// Ҫӹʱ + vec.add(dlForm.getProperty("ysr8_DrawingReleaseDate"));// ͼ + + ci.dataTableModel.addRow(vec); + allObjectMap1.put(idx - 1, dlItem); + allObjectMap1Idx.put(idx - 1, 0); + } + } + + // kk 0911 ӵɢʱɸѡ + private boolean checkSJ(Vector data) { + if ("ѱ".equals(data.get(SJ_STATE_INDEX))) { + return true; + } + if ("".equals(data.get(SJ_STATE_INDEX))) { + String arrivedNumStr = data.get(SJ_ARRIVED_INDEX); + String examinedNumStr = data.get(SJ_EXAMINED_INDEX); + try { + double arrivedNum = KUtil.getDoubleFromString(arrivedNumStr, "ѵ"); + double examinedNum = KUtil.getDoubleFromString(examinedNumStr, "Ѽ"); + if (arrivedNum > examinedNum) { + return true; + } + } catch (Exception e) { + System.out.println("ɢ = " + data.get(SJ_ID_INDEX) + " " + e.getMessage());// תIJʾ + } + } + return false; + } + + private void searchQualityInfo_YSR8_ECN2(String jgc, String[] attrs, String[] vals) throws Exception { + JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.61.11.11"); + TCComponent[] tcComponents = TCUtil.query(fu.session, "SearchECN2ForMD", attrs, vals); + Integer idx = ci.dataTableModel.getRowCount()+1; + for (int i = 0; i < tcComponents.length; i++) { + TCComponentItemRevision ecn2Revision = (TCComponentItemRevision) tcComponents[i]; + System.out.println(">>ECN2: "+ecn2Revision); + TCComponentItem ecn2Item = ecn2Revision.getItem(); + TCComponentForm ecn2Form = TCUtil.getItemRevisionMasterForm(ecn2Revision); + ecn2Form.refresh(); + + TCProperty ysr8_SerialNo = ecn2Form.getFormTCProperty("ysr8_SerialNo"); + int[] ysr8_SerialNoVals = ysr8_SerialNo.getIntArrayValue(); + if(ysr8_SerialNoVals==null||ysr8_SerialNoVals.length==0) + continue; + int length = ysr8_SerialNoVals.length; + String[] nullArray = new String[length]; + Date[] nullDates = new Date[length]; + for(int j=0; j0) { + continue; + } + } + if (jgc!=null&&!jgc.isEmpty()&&!jgc.equals(ysr8_SubManuFactory1Vals[j])&&!jgc.equals(ysr8_SubManuFactory2Vals[j])) { + continue; + } + if(ysr8_ArrivedQuantityVals[j] == null || + ysr8_ArrivedQuantityVals[j].equals(ysr8_ExaminedQuantityVals[j]) && ysr8_SubQualityFinishDateVals[j]!=null) + continue; + Vector vec = new Vector<>(); + vec.add(idx + "");// + vec.add(ecn2Item.getProperty("item_id"));// /޵ + vec.add(ecn2Form.getProperty("ysr8_Factory"));// + vec.add(ecn2Form.getProperty("ysr8_ProjectCode"));// Ŀ + vec.add(ysr8_MaterialIDVals[j]);// + vec.add(ysr8_MaterialNameVals[j]);// + if(ysr8_QuantityVals==null||ysr8_QuantityVals.length==0) + vec.add(""); + else + vec.add(Double.toString(ysr8_QuantityVals[j]));// + vec.add(lovysr8_SubTaskManuState.get(ysr8_SubTaskManuStateVal));// ״̬ + + // kk 0911 + vec.add(ysr8_ArrivedQuantityVals[j]); // ѵ + vec.add(ysr8_ArrivingQuantityVals[j]); // ε + vec.add(ysr8_ExaminedQuantityVals[j]); // Ѽ + vec.add(ysr8_ExaminingQuantityVals[j]); // μ + + vec.add(fu.getDateString(ysr8_SubQualityFinishDateVals[j]));// ʼʱ + vec.add(ysr8_SubQualityResultVals[j]);// ʼ + vec.add(ysr8_SubManuFactory1Vals[j]);// ӹ1 + vec.add(ysr8_SubManuFactory2Vals[j]);// ӹ2 + vec.add(ecn2Form.getProperty("ysr8_ManuPerson"));// + vec.add("");// + vec.add(ysr8_OriginalDesignerVals[j]);// + vec.add(ecn2Form.getProperty("ysr8_TechFinishDate"));// ͼ + vec.add(fu.getDateString(ysr8_DrawingReleaseDateVals[j]));// ͼֽӹʱ + vec.add(fu.getDateString(ysr8_SubPurchPlanDateVals[j]));// ɹҪ + vec.add(ysr8_SubPurchFinishDateVal);// ӹʵʱ + + //kk 0913 ysr8_RepairECN + vec.add("");// ķ޵ + + // kk 0911 ɸѡɢ + if (!checkSJ(vec)) { + continue; + } + + ci.dataTableModel.addRow(vec); + allObjectMap2.put(idx - 1, ecn2Item); + allObjectMap2Idx.put(idx - 1, j); + idx++; + } + } + } + + private void searchQualityInfo_YSR8_ECN4(String jgc, String[] attrs, String[] vals) throws Exception { + JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.61.11.11"); + TCComponent[] tcComponents = TCUtil.query(fu.session, "SearchECN4ForMD", attrs, vals); + Integer idx = ci.dataTableModel.getRowCount()+1; + for (int i = 0; i < tcComponents.length; i++) { + TCComponentItemRevision ecn4Revision = (TCComponentItemRevision) tcComponents[i]; + System.out.println(">>ECN4: "+ecn4Revision); + TCComponentItem ecn4Item = ecn4Revision.getItem(); + TCComponentForm ecn4Form = TCUtil.getItemRevisionMasterForm(ecn4Revision); + ecn4Form.refresh(); + + TCProperty ysr8_SerialNo = ecn4Form.getFormTCProperty("ysr8_SerialNo"); + int[] ysr8_SerialNoVals = ysr8_SerialNo.getIntArrayValue(); + if(ysr8_SerialNoVals==null||ysr8_SerialNoVals.length==0) + continue; + int length = ysr8_SerialNoVals.length; + String[] nullArray = new String[length]; + Date[] nullDates = new Date[length]; + for(int j=0; j0) { + continue; + } + } + if(ysr8_ArrivedQuantityVals[j] == null || + ysr8_ArrivedQuantityVals[j].equals(ysr8_ExaminedQuantityVals[j]) && ysr8_SubQualityFinishDateVals[j]!=null) + continue; + Vector vec = new Vector<>(); + vec.add(idx + "");// + vec.add(ecn4Item.getProperty("item_id"));// /޵ + vec.add(ecn4Form.getProperty("ysr8_Factory"));// + vec.add(ecn4Form.getProperty("ysr8_ProjectCode"));// Ŀ + vec.add(ysr8_MaterialIDVals[j]);// + vec.add(ysr8_MaterialNameVals[j]);// + if(ysr8_QuantityVals==null||ysr8_QuantityVals.length==0) + vec.add(""); + else + vec.add(Double.toString(ysr8_QuantityVals[j]));// + vec.add(lovysr8_SubTaskManuState.get(ysr8_SubTaskManuStateVals[j]));// ״̬ + + // kk 0911 + vec.add(ysr8_ArrivedQuantityVals[j]); // ѵ + vec.add(ysr8_ArrivingQuantityVals[j]); // ε + vec.add(ysr8_ExaminedQuantityVals[j]); // Ѽ + vec.add(ysr8_ExaminingQuantityVals[j]); // μ + + vec.add(fu.getDateString(ysr8_SubQualityFinishDateVals[j]));// ʼʱ + vec.add(ysr8_SubQualityResultVals[j]);// ʼ + vec.add(ysr8_SubManuFactory1Vals[j]);// ӹ1 + vec.add(ysr8_SubManuFactory2Vals[j]);// ӹ2 + vec.add(ecn4Form.getProperty("ysr8_ManuPerson"));// + vec.add("");// + vec.add(ysr8_OriginalDesignerVals[j]);// + vec.add(ecn4Form.getProperty("ysr8_TechFinishDate"));// ͼ + vec.add(fu.getDateString(ysr8_DrawingReleaseDateVals[j]));// ͼֽӹʱ + vec.add(fu.getDateString(ysr8_SubPurchPlanDateVals[j]));// ɹҪ + vec.add(ysr8_SubPurchFinishDateVal);// ӹʵʱ + + //kk 0913 ysr8_RepairECN + vec.add("");// ķ޵ + + // kk 0911 ɸѡɢ + if (!checkSJ(vec)) { + continue; + } + + ci.dataTableModel.addRow(vec); + allObjectMap2.put(idx - 1, ecn4Item); + allObjectMap2Idx.put(idx - 1, j); + idx++; + } + } + } + + private void searchMachiningInfo_YSR8_SingleRepairBJ(String[] attrs, String[] vals) throws Exception { + JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.61.11.11"); + TCComponent[] tcComponents = TCUtil.query(fu.session, "SearchINSPRecordRevision", attrs, vals); + Integer idx = ci.dataTableModel.getRowCount()+1; + for (int i = 0; i < tcComponents.length; i++) { + TCComponentItemRevision ipRevision = (TCComponentItemRevision) tcComponents[i]; + TCComponentItem ipItem = ipRevision.getItem(); + TCComponentForm ipForm = TCUtil.getItemRevisionMasterForm(ipRevision); + ipForm.refresh(); + + TCProperty ysr8_PartCode = ipForm.getFormTCProperty("ysr8_PartCode"); + String[] ysr8_PartCodeVals = ysr8_PartCode.getStringArrayValue(); + if(ysr8_PartCodeVals==null||ysr8_PartCodeVals.length==0) + continue; + int length = ysr8_PartCodeVals.length; + String[] nullArray = new String[length]; + Date[] nullDates = new Date[length]; + for(int j=0; j0) { + continue; + } + } + if(ysr8_ArrivedQuantityVals[j] == null || + ysr8_ArrivedQuantityVals[j].equals(ysr8_ExaminedQuantityVals[j]) && ysr8_SubQualityFinishDateVals[j]!=null) + continue; + Vector vec = new Vector<>(); + vec.add(idx + "");// +// vec.add(ipForm.getProperty("ysr8_ReworkOrderNo"));// ĵ + vec.add(ipItem.getProperty("item_id"));// ķ޵ + vec.add("");// + vec.add(ipForm.getProperty("ysr8_ProjectCode"));// Ŀ + vec.add(ysr8_PartCodeVals[j]);// + vec.add(ysr8_PartNameVals[j]);// + vec.add(ysr8_SubUnqualifiedQuantityVals[j]);// + vec.add(lovysr8_SubTaskManuState.get(ysr8_SubTaskManuStateVals[j]));// ״̬ + + // kk 0911 + vec.add(ysr8_ArrivedQuantityVals[j]); // ѵ + vec.add(ysr8_ArrivingQuantityVals[j]); // ε + vec.add(ysr8_ExaminedQuantityVals[j]); // Ѽ + vec.add(ysr8_ExaminingQuantityVals[j]); // μ + + vec.add(fu.getDateString(ysr8_SubQualityFinishDateVals[j]));// ʼʱ +// vec.add(qualityResultLOV.getDisplayableValue(ysr8_SubQualityResultVals[j]));// ʼ + vec.add(ysr8_SubQualityResultVals[j]);// ʼ + vec.add(ipForm.getProperty("ysr8_ManuFactory1"));// ӹ1 + vec.add(ipForm.getProperty("ysr8_ManuFactory2"));// ӹ2 + vec.add(ipForm.getProperty("ysr8_ManuPerson"));// ӹ + vec.add(ipForm.getProperty("ysr8_PartType"));// + vec.add("");// + vec.add("");// ͼ + vec.add(fu.getDateString(ysr8_DrawingReleaseDateVals[j]));// ͼֽӹʱ + vec.add(fu.getDateString(ysr8_PurchPlanDate1Vals[j]));// ɹҪ + vec.add(ysr8_SubPurchFinishDateVal);// ӹʵʱ + + //kk 0913 ysr8_RepairECN + if(ysr8_RepairECNVals.length>0) { + vec.add(ysr8_RepairECNVals[j]);// ķ޵ + }else + vec.add(""); + + // kk 0911 ɸѡɢ + if (!checkSJ(vec)) { + continue; + } + + ci.dataTableModel.addRow(vec); + allObjectMap2.put(idx - 1, ipItem); + allObjectMap2Idx.put(idx - 1, j); + idx++; + } + } + } + + /*private void searchMachiningInfo_YSR8_SingleRepairSJ(String[] attrs, String[] vals) throws Exception { + JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.61.11.11"); + TCComponent[] tcComponents = TCUtil.query(fu.session, "SearchINSPRecordRevision", attrs, vals); + Integer idx = ci.dataTableModel.getRowCount()+1; + for (int i = 0; i < tcComponents.length; i++) { + TCComponentItemRevision ipRevision = (TCComponentItemRevision) tcComponents[i]; + TCComponentItem ipItem = ipRevision.getItem(); + TCComponentForm ipForm = TCUtil.getItemRevisionMasterForm(ipRevision); + ipForm.refresh(); + + TCProperty ysr8_PartCode = ipForm.getFormTCProperty("ysr8_PartCode"); + String[] ysr8_PartCodeVals = ysr8_PartCode.getStringArrayValue(); + if(ysr8_PartCodeVals==null||ysr8_PartCodeVals.length==0) + continue; + int length = ysr8_PartCodeVals.length; + String[] nullArray = new String[length]; + Date[] nullDates = new Date[length]; + for(int j=0; j vec = new Vector<>(); + vec.add(idx + "");// +// vec.add(ipForm.getProperty("ysr8_ReworkOrderNo"));// ĵ + vec.add(ipItem.getProperty("item_id")); + vec.add("");// + vec.add(ipForm.getProperty("ysr8_ProjectCode"));// Ŀ + vec.add(ysr8_PartCodeVals[j]);// + vec.add(ysr8_PartNameVals[j]);// + vec.add(ysr8_SubUnqualifiedQuantityVals[j]);// + vec.add(lovysr8_SubTaskManuState.get(ysr8_SubTaskManuStateVals[j]));// ״̬ + + // kk 0911 + vec.add(ysr8_ArrivedQuantityVals[j]); // ѵ + vec.add(ysr8_ArrivingQuantityVals[j]); // ε + vec.add(ysr8_ExaminedQuantityVals[j]); // Ѽ + vec.add(ysr8_ExaminingQuantityVals[j]); // μ + + vec.add(fu.getDateString(ysr8_SubQualityFinishDateVals[j]));// ʼʱ + vec.add(ysr8_SubQualityResultVals[j]);// ʼ + vec.add(ipForm.getProperty("ysr8_ManuFactory1"));// ӹ1 + vec.add(ipForm.getProperty("ysr8_ManuFactory2"));// ӹ2 + vec.add(ipForm.getProperty("ysr8_ManuPerson"));// ӹ + vec.add(ipForm.getProperty("ysr8_PartType"));// + vec.add("");// + vec.add("");// ͼ + vec.add(fu.getDateString(ysr8_DrawingReleaseDateVals[j]));// ͼֽӹʱ + vec.add(fu.getDateString(ysr8_PurchPlanDate1Vals[j]));// ɹҪ + vec.add(fu.getDateString(ysr8_SubPurchFinishDateVals[j]));// ӹʵʱ + + //kk 0913 ysr8_RepairECN +// vec.add(ipItem.getProperty("item_id"));// ķ޵ + if(ysr8_RepairECNVals.length>0) { + vec.add(ysr8_RepairECNVals[j]);// ķ޵ + }else + vec.add(""); + + // kk 0911 ɸѡɢ + if (!checkSJ(vec)) { + continue; + } + + ci.dataTableModel.addRow(vec); + allObjectMap2.put(idx - 1, ipItem); + allObjectMap2Idx.put(idx - 1, j); + idx++; + } + } + }*/ + + private void editQualityInfo() { + try { + TCComponentUser user = fu.session.getUser(); + Map> groupMap = user.getGroupRolesTable(); + Iterator>> iter = groupMap.entrySet().iterator(); + Boolean find = false; + while (iter.hasNext()) { + Map.Entry> entry = (Map.Entry>) iter.next(); + // TCComponentGroup group = entry.getKey(); + List roleList = entry.getValue(); + for (TCComponentRole role : roleList) { + if (role.getStringProperty("role_name").equals("QualitySurvey")) { + find = true; + break; + } + } + if (find) { + break; + } + } + if (!find) { + MessageBox.post(this,"ֻ[]ɫûܹ༭ݣ", "ʾ", MessageBox.INFORMATION); + return; + } + + if (currTable == 1) { + JTable table = (JTable) fu.allComponentMap.get("a.41.11.11"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post(this,"ѡҪ༭ݣ", "ʾ", MessageBox.INFORMATION); + return; + } + //б༭ʱ鲿 +// Map nameAndTime=new HashMap<>(); + for (int rowIdx : rows) { + Object name=table.getValueAt(rowIdx, BJ_NAME_INDEX); + String ysr8_ArrivedQuantityVal = table.getValueAt(rowIdx, 6).toString(); +// int ysr8_ArrivedQuantity = Integer.parseInt(ysr8_ArrivedQuantityVal.isEmpty()?"0":ysr8_ArrivedQuantityVal); + String ysr8_ExaminedQuantityVal = table.getValueAt(rowIdx, 8).toString(); +// int ysr8_ExaminedQuantity = Integer.parseInt(ysr8_ExaminedQuantityVal.isEmpty()?"0":ysr8_ExaminedQuantityVal); + if(ysr8_ArrivedQuantityVal.equals(ysr8_ExaminedQuantityVal)) { + MessageBox.post(this,""+name+"Ѽѵ˲ٱ༭", "ʾ", MessageBox.INFORMATION); + return; + }// lidy20190108 + +// Object time=table.getValueAt(rowIdx, BJ_SJWCSJ_INDEX);//lidy20190528 ȥ߼ +// if(name!=null&&!"".equals(name)) { +// if(name.toString().startsWith("滻׷")) { +// name=name.toString().substring(4); +// } +// if(nameAndTime.containsKey(name)) { +// if(time==null) { +// if(nameAndTime.get(name)!=null) { +// MessageBox.post(this,""+name+"жʵ", "ʾ", MessageBox.INFORMATION); +// return; +// } +// }else { +// if(nameAndTime.get(name)==null||!time.equals(nameAndTime.get(name))) { +// MessageBox.post(this,""+name+"жʵ", "ʾ", MessageBox.INFORMATION); +// return; +// } +// } +// }else { +// nameAndTime.put(name, time); +// } +// } + } + ArrayList editObjectList = new ArrayList(); + ArrayList editObjectListIdx = new ArrayList(); + ArrayList editRows = new ArrayList(); + for (int rowIdx : rows) { + int idx = Integer.parseInt(table.getValueAt(rowIdx, 0).toString()); + // lidy20190606༭ǩ + if(allObjectMap1.get(idx - 1) instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem) allObjectMap1.get(idx - 1); + TCComponentItemRevision revision = item.getLatestItemRevision(); + TCComponentForm form = TCUtil.getItemRevisionMasterForm(revision); + if(form.isCheckedOut()) { + MessageBox.post("汾" + form + "ѱǩ޷༭", "ʾ", MessageBox.INFORMATION); + return; + } + } + editObjectList.add(allObjectMap1.get(idx - 1)); + editObjectListIdx.add(allObjectMap1Idx.get(idx - 1)); + editRows.add(rowIdx); + } + new QualityManagementBoardEditDialog(session, this, currTable, editObjectList, editObjectListIdx, editRows); + } else if (currTable == 2) { + JTable table = (JTable) fu.allComponentMap.get("a.61.11.11"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪ༭ݣ", "ʾ", MessageBox.INFORMATION); + return; + } + for (int rowIdx : rows) { + Object name=table.getValueAt(rowIdx, BJ_NAME_INDEX); + String ysr8_ArrivedQuantityVal = ""; + if(table.getValueAt(rowIdx, 8)!=null) + ysr8_ArrivedQuantityVal = table.getValueAt(rowIdx, 8).toString(); +// int ysr8_ArrivedQuantity = Integer.parseInt(ysr8_ArrivedQuantityVal.isEmpty()?"0":ysr8_ArrivedQuantityVal); + String ysr8_ExaminedQuantityVal = ""; + if(table.getValueAt(rowIdx, 10)!=null) + ysr8_ExaminedQuantityVal = table.getValueAt(rowIdx, 10).toString(); +// int ysr8_ExaminedQuantity = Integer.parseInt(ysr8_ExaminedQuantityVal.isEmpty()?"0":ysr8_ExaminedQuantityVal); + if(ysr8_ArrivedQuantityVal.equals(ysr8_ExaminedQuantityVal)) { + MessageBox.post(this,""+name+"Ѽѵ˲ٱ༭", "ʾ", MessageBox.INFORMATION); + return; + }// lidy20190108 + +// Object state = table.getValueAt(rows[rowIdx], SJ_STATE_INDEX);//lidy20181220 + Object state = table.getValueAt(rowIdx, SJ_STATE_INDEX); + if (state==null||(!state.equals("ѱ")&&!state.equals(""))) { + MessageBox.post("״̬Ϊ[ѱ][]ݲܽб༭", "ʾ", MessageBox.INFORMATION); + return; + } + } + ArrayList editObjectList = new ArrayList(); + ArrayList editObjectListIdx = new ArrayList(); + ArrayList editRows = new ArrayList(); + for (int rowIdx : rows) { + int idx = Integer.parseInt(table.getValueAt(rowIdx, 0).toString()); + // lidy20190606༭ǩ + if(allObjectMap2.get(idx - 1) instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem) allObjectMap2.get(idx - 1); + TCComponentItemRevision revision = item.getLatestItemRevision(); + TCComponentForm form = TCUtil.getItemRevisionMasterForm(revision); + if(form.isCheckedOut()) { + MessageBox.post("汾" + form + "ѱǩ޷༭", "ʾ", MessageBox.INFORMATION); + return; + } + } + editObjectList.add(allObjectMap2.get(idx - 1)); + editObjectListIdx.add(allObjectMap2Idx.get(idx - 1)); + editRows.add(rowIdx); + } + new QualityManagementBoardEditDialog(session, this, currTable, editObjectList, editObjectListIdx, editRows); + } + } catch (TCException e) { + e.printStackTrace(); + } +// searBtn.doClick(); + } + + private void outputQualityInfo() { + final JButton btn = (JButton) fu.allComponentMap.get("b.21.14"); + btn.setEnabled(false); + final JTable table1 = (JTable) fu.allComponentMap.get("a.41.11.11"); + final JTable table2 = (JTable) fu.allComponentMap.get("a.61.11.11"); + + final ProgressReporterDialog reporter = new ProgressReporterDialog(); + reporter.reportProgressMessage("ڵ,Ժ..."); + new Thread(reporter).start(); + new Thread() { + public void run() { + try { + Date date = new Date(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + String time = sdf.format(date); + String toPath = System.getProperty("java.io.tmpdir") + "ӹ̬" + time + ".xls"; + // һдWorkbook + WritableWorkbook writeWorkBook = Workbook.createWorkbook(new File(toPath)); + // + WritableSheet wsheet = writeWorkBook.createSheet("ӹ̬", 0); + + // д + int columnCount = table1.getColumnCount(); // + int rowCount = table1.getRowCount(); // + String[] titles = new String[columnCount]; // ͷ + + // ȡͷ + for (int i = 0; i < columnCount; i++) { + titles[i] = table1.getColumnName(i); + } + + int current_row = 0; // ʼǰΪʼ + + try { + // ʽ + WritableFont titleFont = new WritableFont(WritableFont.createFont(""), 13, WritableFont.BOLD); + WritableCellFormat titleCellFormat = new WritableCellFormat(titleFont); + titleCellFormat.setBorder(Border.ALL, BorderLineStyle.MEDIUM); + titleCellFormat.setAlignment(Alignment.CENTRE); + titleCellFormat.setVerticalAlignment(VerticalAlignment.CENTRE); + titleCellFormat.setWrap(true); + + // ʽ + WritableFont contentFont = new WritableFont(WritableFont.createFont(""), 12); + WritableCellFormat contentCellFormat = new WritableCellFormat(contentFont); + contentCellFormat.setBorder(Border.ALL, BorderLineStyle.THIN); + contentCellFormat.setAlignment(Alignment.CENTRE); + contentCellFormat.setVerticalAlignment(VerticalAlignment.CENTRE); + contentCellFormat.setWrap(true); + + // дб + for (int i = 0; i < columnCount; i++) { + Label labelTitle = new Label(i, current_row, titles[i], titleCellFormat); + wsheet.addCell(labelTitle); + } + + current_row = current_row + 1; + // д + for (int i = 0; i < rowCount; i++) { + for (int j = 0; j < columnCount; j++) { + Object objValue = table1.getValueAt(i, j); + Label labelContent = new Label(j, i + current_row, String.valueOf(objValue), contentCellFormat); + wsheet.addCell(labelContent); + } + } + + // øʽ + wsheet.getSettings().setDefaultColumnWidth(20); + /* + * writeWorkBook.write(); writeWorkBook.close(); + */ + } catch (WriteException e) { + e.printStackTrace(); + } + // + wsheet = writeWorkBook.createSheet("ɢӹ̬", 1); + + // д + columnCount = table2.getColumnCount(); // + rowCount = table2.getRowCount(); // + titles = new String[columnCount]; // ͷ + + // ȡͷ + for (int i = 0; i < columnCount; i++) { + titles[i] = table2.getColumnName(i); + } + + current_row = 0; // ʼǰΪʼ + + try { + // ʽ + WritableFont titleFont = new WritableFont(WritableFont.createFont(""), 13, WritableFont.BOLD); + WritableCellFormat titleCellFormat = new WritableCellFormat(titleFont); + titleCellFormat.setBorder(Border.ALL, BorderLineStyle.MEDIUM); + titleCellFormat.setAlignment(Alignment.CENTRE); + titleCellFormat.setVerticalAlignment(VerticalAlignment.CENTRE); + titleCellFormat.setWrap(true); + + // ʽ + WritableFont contentFont = new WritableFont(WritableFont.createFont(""), 12); + WritableCellFormat contentCellFormat = new WritableCellFormat(contentFont); + contentCellFormat.setBorder(Border.ALL, BorderLineStyle.THIN); + contentCellFormat.setAlignment(Alignment.CENTRE); + contentCellFormat.setVerticalAlignment(VerticalAlignment.CENTRE); + contentCellFormat.setWrap(true); + + // дб + for (int i = 0; i < columnCount; i++) { + Label labelTitle = new Label(i, current_row, titles[i], titleCellFormat); + wsheet.addCell(labelTitle); + } + + current_row = current_row + 1; + // д + for (int i = 0; i < rowCount; i++) { + for (int j = 0; j < columnCount; j++) { + Object objValue = table2.getValueAt(i, j); + Label labelContent = new Label(j, i + current_row, String.valueOf(objValue), contentCellFormat); + wsheet.addCell(labelContent); + } + } + + // øʽ + wsheet.getSettings().setDefaultColumnWidth(20); + } catch (WriteException e) { + e.printStackTrace(); + } + + try { + writeWorkBook.write(); + writeWorkBook.close(); + } catch (WriteException e) { + e.printStackTrace(); + } + // 򿪵ıļ + Runtime.getRuntime().exec("cmd /c \"" + toPath + "\""); + + } catch (IOException e) { + e.printStackTrace(); + } + reporter.requestCanceling(); + btn.setEnabled(true); + } + }.start(); + } + + private void createQualityInfo() { + try { + TCComponentUser user = fu.session.getUser(); + Map> groupMap = user.getGroupRolesTable(); + Iterator>> iter = groupMap.entrySet().iterator(); + Boolean find = false; + while (iter.hasNext()) { + Map.Entry> entry = (Map.Entry>) iter.next(); + // TCComponentGroup group = entry.getKey(); + List roleList = entry.getValue(); + for (TCComponentRole role : roleList) { + if (role.getStringProperty("role_name").equals("QualitySurvey")) { + find = true; + break; + } + } + if (find) { + break; + } + } + if (!find) { + MessageBox.post("ֻ[]ɫûܹз޵", "ʾ", MessageBox.INFORMATION); + return; + } + + if (currTable == 1) { + JTable table = (JTable) fu.allComponentMap.get("a.41.11.11"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length <1 ) { + MessageBox.post("ѡһз޵", "ʾ", MessageBox.INFORMATION); + return; + } + // if (allObjectMap1.get(rows[0]) instanceof TCComponentScheduleTask) { + // } else if (allObjectMap1.get(rows[0]) instanceof TCComponentItem) { + // TCComponentItem item = (TCComponentItem)allObjectMap1.get(rows[0]); + // + // String object_typeVal = item.getProperty("object_type"); + // if (object_typeVal.equals("ɢ¼")) { + // MessageBox.post("ɷ޵з޵", "ʾ", MessageBox.INFORMATION); + // return; + // } + // } + //int idx = Integer.parseInt(table.getValueAt(rows[0], 0).toString()); + List parentObjs=new ArrayList<>(); + List parentIdxs=new ArrayList<>(); + List checkData=new ArrayList<>(); //ƣʵʱ䣬ʼ +// String ysr8_ManuFactory1 = "", ysr8_ManuFactory2 = ""; + for (int row : rows) { +// if(ysr8_ManuFactory1.isEmpty()) { +// ysr8_ManuFactory1 = table.getValueAt(row, 15).toString(); +// } else if(!ysr8_ManuFactory1.equals(table.getValueAt(row, 15).toString())) { +// MessageBox.post("ѡһз޵", "ʾ", MessageBox.INFORMATION); +// return; +// } +// if(ysr8_ManuFactory2.isEmpty()) { +// ysr8_ManuFactory2 = table.getValueAt(row, 16).toString(); +// } else if(!ysr8_ManuFactory2.equals(table.getValueAt(row, 16).toString())) { +// MessageBox.post("ѡһз޵", "ʾ", MessageBox.INFORMATION); +// return; +// } + int idx = Integer.parseInt(table.getValueAt(row, 0).toString()); + // lidy20190606༭ǩ + if(allObjectMap1.get(idx - 1) instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem) allObjectMap1.get(idx - 1); + TCComponentItemRevision revision = item.getLatestItemRevision(); + TCComponentForm form = TCUtil.getItemRevisionMasterForm(revision); + if(form.isCheckedOut()) { + MessageBox.post("汾" + form + "ѱǩ޷༭", "ʾ", MessageBox.INFORMATION); + return; + } + } + parentObjs.add(allObjectMap1.get(idx - 1)); + parentIdxs.add(allObjectMap1Idx.get(idx - 1)); + Object[] data=new Object[5]; + data[0]=table.getValueAt(row, BJ_NAME_INDEX); + data[1]=table.getValueAt(row, BJ_SJWCSJ_INDEX); + data[2]=table.getValueAt(row, BJ_ZJJL_INDEX); + data[3]=table.getValueAt(row, BJ_JGC1_INDEX); + data[4]=table.getValueAt(row, BJ_JGC2_INDEX); + checkData.add(data); + } + if(!checkBJData(checkData)) { + return; + } + new YSR8_INSPRecordCreateDialog(this, 2, parentObjs, parentIdxs); + } else if (currTable == 2) { + JTable table = (JTable) fu.allComponentMap.get("a.61.11.11"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length <1) { + MessageBox.post("ѡһз޵", "ʾ", MessageBox.INFORMATION); + return; + } + //kk 0912 Ϊв + List parentObjs=new ArrayList<>(); + List parentIdxs=new ArrayList<>(); + List checkData=new ArrayList<>(); //ʼʱ䣬ʼۣӹ1ӹ2 + for (int row : rows) { + int idx = Integer.parseInt(table.getValueAt(row, 0).toString()); + // lidy20190606༭ǩ + if(allObjectMap2.get(idx - 1) instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem) allObjectMap2.get(idx - 1); + TCComponentItemRevision revision = item.getLatestItemRevision(); + TCComponentForm form = TCUtil.getItemRevisionMasterForm(revision); + if(form.isCheckedOut()) { + MessageBox.post("汾" + form + "ѱǩ޷༭", "ʾ", MessageBox.INFORMATION); + return; + } + } + parentObjs.add(allObjectMap2.get(idx - 1)); + parentIdxs.add(allObjectMap2Idx.get(idx - 1)); + Object[] data=new Object[4]; + data[0]=table.getValueAt(row, SJ_ZJWCSJ_INDEX); + data[1]=table.getValueAt(row, SJ_ZJJL_INDEX); + data[2]=table.getValueAt(row, SJ_JGC1_INDEX); + data[3]=table.getValueAt(row, SJ_JGC2_INDEX); + checkData.add(data); + } + if(!checkSJData(checkData)) { + return; + } + new YSR8_INSPRecordCreateDialog(this, 1, parentObjs, parentIdxs); + } + } catch (TCException e) { + e.printStackTrace(); + } +// searBtn.doClick(); + } + + /** + * ƣʵʱ䣬ʼ + * @param checkData + * @return + */ + private boolean checkBJData(List checkData) { + final int NAME_ID=0; + final int SJWCSJ_ID=1; + final int ZJJL_ID=2; + final int JGC1_ID=3; + final int JGC2_ID=4; + if(checkData.size()==0) { + return true; + } + //&ʵ + Map nameAndTime=new HashMap<>(); + //ʼ + boolean isQualified=false; + Object temp=checkData.get(0)[ZJJL_ID]; + if(temp!=null&&"ϸ".equals(temp)){ + isQualified=true; + } + String subProject = checkData.get(0)[NAME_ID].toString(); + if(subProject.startsWith("滻׷")) { + subProject = subProject.substring(4, subProject.indexOf("_")); + }else { + subProject = subProject.substring(0, subProject.indexOf("-", 12)); + } + for (Object[] data : checkData) { + Object name=data[NAME_ID]; + Object time=data[SJWCSJ_ID]; + String taskName = name.toString(); + if(name!=null&&!"".equals(name)) { + if(name.toString().startsWith("滻׷")) {// + taskName=taskName.substring(4, taskName.indexOf("_")); + name=name.toString().substring(4); + } + if(!taskName.startsWith(subProject)) { +// if(!subProject.equals(taskName)) { + MessageBox.post("ѡевͬһĿ༭", "ʾ", MessageBox.INFORMATION); + return false; + } + if(nameAndTime.containsKey(name)) { + if(time==null) { + if(nameAndTime.get(name)!=null) { + MessageBox.post(this,""+name+"жʵ", "ʾ", MessageBox.INFORMATION); + return false; + } + }else { + if(nameAndTime.get(name)==null||!time.equals(nameAndTime.get(name))) { + MessageBox.post(this,""+name+"жʵ", "ʾ", MessageBox.INFORMATION); + return false; + } + } + }else { + nameAndTime.put(name, time); + } + } + Object zjjl=data[ZJJL_ID]; + // lidy20190327ʼΪյв + if(zjjl==null || "".equals(zjjl)) { + MessageBox.post(this,"ʼΪյв", "ʾ", MessageBox.INFORMATION); + return false; + } + if(isQualified) { + if(zjjl==null||!"ϸ".equals(zjjl)) { + MessageBox.post(this,"ʼ۲ѡͬʱڡϸ񡱼", "ʾ", MessageBox.INFORMATION); + return false; + } + }else { + if(zjjl!=null&&"ϸ".equals(zjjl)) { + MessageBox.post(this,"ʼ۲ѡͬʱڡϸ񡱼", "ʾ", MessageBox.INFORMATION); + return false; + } + } + } +// for (Object[] data : checkData) { +// Object zjjl=data[ZJJL_ID]; +// if(isQualified) { +// if(zjjl==null||!"ϸ".equals(zjjl)) { +// MessageBox.post(this,"ʼ۲ѡͬʱڡϸ񡱼", "ʾ", MessageBox.INFORMATION); +// return false; +// } +// }else { +// if(zjjl!=null&&"ϸ".equals(zjjl)) { +// MessageBox.post(this,"ʼ۲ѡͬʱڡϸ񡱼", "ʾ", MessageBox.INFORMATION); +// return false; +// } +// } +// } + //ӹ + if(!isQualified) { + Object jgc1temp=checkData.get(0)[JGC1_ID]; + if(jgc1temp==null) { + jgc1temp=""; + } + Object jgc2temp=checkData.get(0)[JGC2_ID]; + if(jgc2temp==null) { + jgc2temp=""; + } + for (Object[] data : checkData) { + Object jgc1=data[JGC1_ID]; + if(jgc1==null) { + jgc1=""; + } + Object jgc2=data[JGC2_ID]; + if(jgc2==null) { + jgc2=""; + } + if(!jgc1temp.equals(jgc1)) { + MessageBox.post(this,"ѡеġʼۡڡϸ£ӹ1͡ӹ2Աͬ", "ʾ", MessageBox.INFORMATION); + return false; + } + if(!jgc2temp.equals(jgc2)) { + MessageBox.post(this,"ѡеġʼۡڡϸ£ӹ1͡ӹ2Աͬ", "ʾ", MessageBox.INFORMATION); + return false; + } + } + } + return true; + } + + /** + * ʼʱ䣬ʼۣӹ1ӹ2 + * @param checkData + * @return + */ + private boolean checkSJData(List checkData) { + if(checkData.size()==0) { + return true; + } + final int ZJWCSJ_ID=0; + final int ZJJL_ID=1; + final int JGC1_ID=2; + final int JGC2_ID=3; + //ʼ + boolean isQualified=false; + Object temp=checkData.get(0)[ZJJL_ID]; + if(temp!=null&&"ϸ".equals(temp)){ + isQualified=true; + } + //ʼʱ + for (Object[] data : checkData) { + //TODO lidy20190214⴦ + if(data[ZJWCSJ_ID]!=null&&!"".equals(data[ZJWCSJ_ID])) { + MessageBox.post(this,"ʼʱΪ", "ʾ", MessageBox.INFORMATION); + return false; + } + Object zjjl=data[ZJJL_ID]; + //TODO lidy20190321ʼΪյв + if(zjjl==null || "".equals(zjjl)) { + MessageBox.post(this,"ʼΪյв", "ʾ", MessageBox.INFORMATION); + return false; + } + if(isQualified) { + if(!"ϸ".equals(zjjl)) { + MessageBox.post(this,"ʼ۲ѡͬʱڡϸ񡱼", "ʾ", MessageBox.INFORMATION); + return false; + } + }else { + if("ϸ".equals(zjjl)) { + MessageBox.post(this,"ʼ۲ѡͬʱڡϸ񡱼", "ʾ", MessageBox.INFORMATION); + return false; + } + } + } +// for (Object[] data : checkData) { +// Object zjjl=data[ZJJL_ID]; +// if(isQualified) { +// if(zjjl==null||!"ϸ".equals(zjjl)) { +// MessageBox.post(this,"ʼ۲ѡͬʱڡϸ񡱼", "ʾ", MessageBox.INFORMATION); +// return false; +// } +// }else { +// if(zjjl!=null&&"ϸ".equals(zjjl)) { +// MessageBox.post(this,"ʼ۲ѡͬʱڡϸ񡱼", "ʾ", MessageBox.INFORMATION); +// return false; +// } +// } +// } + //ӹ + if(!isQualified) { + Object jgc1temp=checkData.get(0)[JGC1_ID]; + if(jgc1temp==null) { + jgc1temp=""; + } + Object jgc2temp=checkData.get(0)[JGC2_ID]; + if(jgc2temp==null) { + jgc2temp=""; + } + for (Object[] data : checkData) { + Object jgc1=data[JGC1_ID]; + if(jgc1==null) { + jgc1=""; + } + Object jgc2=data[JGC2_ID]; + if(jgc2==null) { + jgc2=""; + } + if(!jgc1temp.equals(jgc1)) { + MessageBox.post(this,"ѡеġʼۡڡϸ£ӹ1͡ӹ2Աͬ", "ʾ", MessageBox.INFORMATION); + return false; + } + if(!jgc2temp.equals(jgc2)) { + MessageBox.post(this,"ѡеġʼۡڡϸ£ӹ1͡ӹ2Աͬ", "ʾ", MessageBox.INFORMATION); + return false; + } + } + } + return true; + } + + protected void updateValues(HashMap tableMap) { + JTable table; + int rows[]; + if(currTable==1) { + table = (JTable) fu.allComponentMap.get("a.41.11.11"); + } else { + table = (JTable) fu.allComponentMap.get("a.61.11.11"); + } + rows = table.getSelectedRows(); + for(int i : rows) { + for(String s : tableMap.keySet()) { + if(currTable==1) { + if(s.equals("ZJJLVal")) { + table.setValueAt(tableMap.get(s), i, 14); + } else if(s.equals("ysr8_SubQualityFinishDate")) { +// table.setValueAt(tableMap.get(s).substring(0, 10), i, 13); + if(tableMap.get(s).length()>10) + table.setValueAt(tableMap.get(s).substring(0, 10), i, 13); + else + table.setValueAt(tableMap.get(s), i, 13); + } else if(s.equals("ysr8_ExaminedQuantity")) { + if(table.getValueAt(i, 8)==null || table.getValueAt(i, 8).toString().isEmpty()) + table.setValueAt(tableMap.get(s), i, 8); + } else if(s.equals("ysr8_ExaminingQuantity")) { + if(table.getValueAt(i, 9)==null || table.getValueAt(i, 9).toString().isEmpty()) + table.setValueAt(tableMap.get(s), i, 9); + } else if(s.equals("ysr8_TaskManuState")) { +// table.setValueAt(tableMap.get(s), i, 5); + if(tableMap.get(s).equals("1")) { + table.setValueAt("δ", i, 5); + } else if(tableMap.get(s).equals("2")) { + table.setValueAt("ѵ", i, 5); + } else if(tableMap.get(s).equals("3")) { + table.setValueAt("ѱ", i, 5); + } else if(tableMap.get(s).equals("4")) { + table.setValueAt("Ѽ", i, 5); + } else if(tableMap.get(s).equals("5")) { + table.setValueAt("", i, 5); + } + } + } else { + if(s.equals("ZJJLVal")) { + table.setValueAt(tableMap.get(s), i, 13); + } else if(s.equals("ysr8_SubQualityFinishDate")) { +// table.setValueAt(tableMap.get(s).substring(0, 10), i, 12); + if(tableMap.get(s).length()>10) + table.setValueAt(tableMap.get(s).substring(0, 10), i, 12); + else + table.setValueAt(tableMap.get(s), i, 12); + } else if(s.equals("ysr8_ExaminedQuantity")) { + if(table.getValueAt(i, 10)==null || table.getValueAt(i, 10).toString().isEmpty()) + table.setValueAt(tableMap.get(s), i, 10); + } else if(s.equals("ysr8_ExaminingQuantity")) { + if(table.getValueAt(i, 11)==null || table.getValueAt(i, 11).toString().isEmpty()) + table.setValueAt(tableMap.get(s), i, 11); + } else if(s.equals("ysr8_TaskManuState")) { +// table.setValueAt(tableMap.get(s), i, 7); + if(tableMap.get(s).equals("1")) { + table.setValueAt("δ", i, 7); + } else if(tableMap.get(s).equals("2")) { + table.setValueAt("ѵ", i, 7); + } else if(tableMap.get(s).equals("3")) { + table.setValueAt("ѱ", i, 7); + } else if(tableMap.get(s).equals("4")) { + table.setValueAt("Ѽ", i, 7); + } else if(tableMap.get(s).equals("5")) { + table.setValueAt("", i, 7); + } + } + } + } + } + } + + protected void updateValue(String ing, String ed, int idx) { + System.out.println(currTable+"==="+ing+"==="+ed+"==="+idx); + if(currTable==1) { + JTable table = (JTable) fu.allComponentMap.get("a.41.11.11"); + table.setValueAt(ing, idx, 9); + table.setValueAt(ed, idx, 8); + } else if(currTable==2) { + JTable table = (JTable) fu.allComponentMap.get("a.61.11.11"); + table.setValueAt(ing, idx, 11); + table.setValueAt(ed, idx, 10); + } + } +} diff --git a/src/cn/com/ebewin/ysr/dialog/QualityManagementBoardEditDialog.java b/src/cn/com/ebewin/ysr/dialog/QualityManagementBoardEditDialog.java new file mode 100644 index 0000000..0a2128f --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/QualityManagementBoardEditDialog.java @@ -0,0 +1,710 @@ +package cn.com.ebewin.ysr.dialog; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JTextField; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.iTextField; + +import cn.com.ebewin.ysr.util.DialogUtil; +import cn.com.ebewin.ysr.util.KUtil; +import cn.com.ebewin.ysr.util.TCUtil; + +@SuppressWarnings("deprecation") +public class QualityManagementBoardEditDialog extends AbstractAIFDialog { + private static final long serialVersionUID = 1L; + private DialogUtil fu = new DialogUtil(this, "ʼ", "YSR8_QualityManagementBoardEditDialog"); + + private TCSession session; + private int currTable = 0; + private ArrayList editObjectList = null; + private ArrayList editObjectListIdx = null; + private ArrayList editRows = null; + private boolean isSingleEdit = true; + private int examingNum; + private int arrivedNum; + private int examinedNum; + private QualityManagementBoardDialog qmb; + + public QualityManagementBoardEditDialog(TCSession session, QualityManagementBoardDialog qmb, int currTable, ArrayList editObjectList, ArrayList editObjectListIdx, ArrayList editRows) throws TCException { + super(true); + + this.session = session; + this.qmb = qmb; + this.currTable = currTable; + this.editObjectList = editObjectList; + this.editObjectListIdx = editObjectListIdx; + this.editRows = editRows; + if (editObjectList.size() > 1) { + this.isSingleEdit = false; + } + + fu.initializeUI(qmb.fu.session); + centerToScreen(); + loadRendering(); + addActionListener(); + getDefVal(); + setVisible(true); + } + + @SuppressWarnings("unchecked") + private void loadRendering() throws TCException { + JComboBox ZJJL = (JComboBox) fu.allComponentMap.get("ZJJL");//TODO lidy20190331ϲLOV YSR8_INSPR3_LOV + TCComponentListOfValuesType lovType = (TCComponentListOfValuesType)session.getTypeComponent("ListOfValues"); + TCComponentListOfValues[] lov = lovType.find("YSR8_INSPR3_LOV"); + if(lov.length>0) { + ListOfValuesInfo lovInfo = lov[0].getListOfValues(); + Map lovValue = lovInfo.getValueTable(); + for(Map.Entry me : lovValue.entrySet()) { + ZJJL.addItem(me.getValue()); + } + } +// if (currTable == 1) { +// ZJJL.addItem("ϸ"); +// ZJJL.addItem("ϸ"); +// ZJJL.addItem("ɵ"); +// } else if (currTable == 2) { +// ZJJL.addItem("ϸ"); +// ZJJL.addItem("ϸ"); +// ZJJL.addItem("ֺϸ"); +// } + + if (!isSingleEdit) { // kk 0911 б༭ʱ + iTextField examingQuantityField = (iTextField) fu.allComponentMap.get("BCJYSL"); + examingQuantityField.setEditable(false); + } + + } + + private void addActionListener() { + JButton btn = (JButton) fu.allComponentMap.get("b.41.12"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + saveRendering(); + } + }); + + btn = (JButton) fu.allComponentMap.get("b.41.14"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + } + + @SuppressWarnings("unchecked") + private void saveRendering() { + try { + if (!checkCanSave()) { + return; + } + } catch (Exception e1) { + MessageBox.post(this, "ʱ\n" + e1.toString(), "ʾ", MessageBox.ERROR); + e1.printStackTrace(); + return; + } + + HashMap tableMap = new HashMap(); + // DateButton ZJWCRQ = (DateButton)fu.allComponentMap.get("ZJWCRQ"); + JComboBox ZJJL = (JComboBox) fu.allComponentMap.get("ZJJL"); + // JCheckBox TSWCRW = (JCheckBox)fu.allComponentMap.get("TSWCRW"); + + // Date ZJWCRQVal = ZJWCRQ.getDate(); +// String ZJJLVal = ((JTextField) ZJJL.getEditor().getEditorComponent()).getText(); + String ZJJLVal = ZJJL.getSelectedItem().toString(); + tableMap.put("ZJJLVal", ZJJLVal); + tableMap.put("ysr8_SubQualityFinishDate", ""); + double newExaminedNum = 0; + double newExamingNum = 0; +// String ysr8_TaskManuState = "3"; + // Boolean TSWCRWVal = TSWCRW.isSelected(); + + try { + HashMap valMap = new HashMap(); + if (currTable == 1) { + for (int i = 0; i < editObjectList.size(); i++) { + Object object = editObjectList.get(i); + if (object instanceof TCComponentScheduleTask) { + TCComponentScheduleTask scheduTask = (TCComponentScheduleTask) object; + + valMap.put("ysr8_SubQualityResult", ZJJLVal); + /* + * if (TSWCRWVal) { valMap.put("ysr8_TaskManuState", "4"); } + */ + + // kk ޸Ѽʼʱ + //TODO lidy20190310⴦ + valMap.put("ysr8_SubQualityFinishDate", ""); + if (isSingleEdit) { + newExaminedNum=this.examinedNum + this.examingNum; + newExamingNum=this.examingNum; + }else { + getNums(object, i); + newExaminedNum=this.examinedNum; + newExamingNum=this.examingNum; +// ysr8_TaskManuState = "4"; + } + valMap.put("ysr8_ExaminedQuantity", fu.getDoubleString(newExaminedNum)); + valMap.put("ysr8_ExaminingQuantity", fu.getDoubleString(newExamingNum)); +// valMap.put("ysr8_TaskManuState", ysr8_TaskManuState); + qmb.updateValue(fu.getDoubleString(newExamingNum), fu.getDoubleString(newExaminedNum), editRows.get(i)); + + for (Entry entry : valMap.entrySet()) { + String key1 = entry.getKey(); + String key2 = entry.getValue(); + TCProperty property = (TCProperty) scheduTask.getTCProperty(key1); + switch (property.getPropertyType()) { + case TCProperty.PROP_string: + case TCProperty.PROP_long_string: + scheduTask.setStringProperty(key1, key2); + break; + case TCProperty.PROP_short: + case TCProperty.PROP_int: + scheduTask.setIntProperty(key1, Integer.parseInt(key2)); + break; + case TCProperty.PROP_double: + case TCProperty.PROP_float: + scheduTask.setDoubleProperty(key1, Double.parseDouble(key2)); + break; + case TCProperty.PROP_date: + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + if (!key2.equals("")) { + Date date = sdf.parse(key2); + if (date != null) { + scheduTask.setDateProperty(key1, date); + } + } else { + Date date = sdf.parse("0001-01-01"); + scheduTask.setDateProperty(key1, date); + } + break; + default: + scheduTask.setStringProperty(key1, key2); + break; + } + } + } else if (object instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem) object; + TCComponentItemRevision revision = item.getLatestItemRevision(); + TCComponentForm form = TCUtil.getItemRevisionMasterForm(revision); + + String params = "", proName = "###", proVal = "###"; + + String object_typeVal = item.getProperty("object_type"); + if (object_typeVal.equals("ͼĿ¼")) { + // kk ޸Ѽʼʱ + { + //TODO lidy20190310⴦ + String key1 = "ysr8_SubQualityFinishDate"; +// String key2 = Integer.toString(editObjectListIdx.get(i)) + "$$$$" + ""; + String key2 = ""; + + if (proName.equals("###")) { + proName = key1; + } else { + proName += "@@@@" + key1; + } + if (proVal.equals("###")) { + proVal = key2; + } else { + proVal += "@@@@" + key2; + } + } + if (isSingleEdit) { + newExaminedNum=this.examinedNum + this.examingNum; + newExamingNum=this.examingNum; + }else { + getNums(object, i); + newExamingNum=this.examinedNum; + newExaminedNum=this.examingNum; + qmb.updateValue(""+newExamingNum, ""+newExaminedNum, editRows.get(i)); +// ysr8_TaskManuState = "4"; + } + { + String key1 = "ysr8_ExaminedQuantity"; +// String key2 = Integer.toString(editObjectListIdx.get(i)) + "$$$$" + fu.getDoubleString(newExaminedNum); + String key2 = fu.getDoubleString(newExaminedNum); + + if (proName.equals("###")) { + proName = key1; + } else { + proName += "@@@@" + key1; + } + if (proVal.equals("###")) { + proVal = key2; + } else { + proVal += "@@@@" + key2; + } + } + { + String key1 = "ysr8_ExaminingQuantity"; +// String key2 = Integer.toString(editObjectListIdx.get(i)) + "$$$$" + fu.getDoubleString(newExamingNum); + String key2 = fu.getDoubleString(newExamingNum); + + if (proName.equals("###")) { + proName = key1; + } else { + proName += "@@@@" + key1; + } + if (proVal.equals("###")) { + proVal = key2; + } else { + proVal += "@@@@" + key2; + } + } + + + { + String key1 = "ysr8_SubQualityResult"; +// String key2 = Integer.toString(editObjectListIdx.get(i)) + "$$$$" + ZJJLVal; + String key2 = ZJJLVal; + + if (proName.equals("###")) { + proName = key1; + } else { + proName += "@@@@" + key1; + } + if (proVal.equals("###")) { + proVal = key2; + } else { + proVal += "@@@@" + key2; + } + } + } + params = item.getProperty("item_id") + "^^^^" + proName + "^^^^" + proVal; + + TCUserService userService = fu.session.getUserService(); + Object[] objParams = new Object[2]; + String cmd = "Update_ItemRevForm_TCProperty"; + objParams[0] = cmd; + objParams[1] = params; + long startime = System.currentTimeMillis(); + String result = (String) userService.call("YSR8UserService", objParams); + long endtime = System.currentTimeMillis(); + System.out.println("Cʱ" + (endtime - startime) + ""); + System.out.println(result); + form.refresh(); + } + } + } else if (currTable == 2) { + for (int i = 0; i < editObjectList.size(); i++) { + Object object = editObjectList.get(i); + if (object instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem) object; + TCComponentItemRevision revision = item.getLatestItemRevision(); + TCComponentForm form = TCUtil.getItemRevisionMasterForm(revision); + + String params = "", proName = "", proVal = ""; + String object_typeVal = item.getProperty("object_type"); + if (object_typeVal.equals("ͼֽĵ")) { + // kk ޸Ѽʼʱ + { + //TODO lidy20190310⴦ + String key1 = "ysr8_SubQualityFinishDate"; + String key2 = Integer.toString(editObjectListIdx.get(i)) + "$$$$" + ""; + + if (proName.equals("")) { + proName = key1; + } else { + proName += "@@@@" + key1; + } + if (proVal.equals("")) { + proVal = key2; + } else { + proVal += "@@@@" + key2; + } + } + if (isSingleEdit) { + newExaminedNum=this.examinedNum + this.examingNum; + newExamingNum=this.examingNum; + }else { + getNums(object, i); + newExamingNum=this.examingNum; + newExaminedNum=this.examinedNum; + System.out.println("ECN2:"+i+"editRow:"+editRows.get(i)); + qmb.updateValue(""+newExamingNum, ""+newExaminedNum, editRows.get(i)); +// ysr8_TaskManuState = "4"; + } + { + String key1 = "ysr8_ExaminedQuantity"; + String key2 = Integer.toString(editObjectListIdx.get(i)) + "$$$$" + fu.getDoubleString(newExaminedNum); + + if (proName.equals("")) { + proName = key1; + } else { + proName += "@@@@" + key1; + } + if (proVal.equals("")) { + proVal = key2; + } else { + proVal += "@@@@" + key2; + } + } + { + String key1 = "ysr8_ExaminingQuantity"; + String key2 = Integer.toString(editObjectListIdx.get(i)) + "$$$$" + fu.getDoubleString(newExamingNum); + + if (proName.equals("")) { + proName = key1; + } else { + proName += "@@@@" + key1; + } + if (proVal.equals("")) { + proVal = key2; + } else { + proVal += "@@@@" + key2; + } + } + + + { + String key1 = "ysr8_SubQualityResult"; + String key2 = Integer.toString(editObjectListIdx.get(i)) + "$$$$" + ZJJLVal; + + if (proName.equals("")) { + proName = key1; + } else { + proName += "@@@@" + key1; + } + if (proVal.equals("")) { + proVal = key2; + } else { + proVal += "@@@@" + key2; + } + } + } else if (object_typeVal.equals("ļӹ")) { + // kk ޸Ѽʼʱ + { + //TODO lidy20190310⴦ + String key1 = "ysr8_SubQualityFinishDate"; + String key2 = Integer.toString(editObjectListIdx.get(i)) + "$$$$" + ""; + + if (proName.equals("")) { + proName = key1; + } else { + proName += "@@@@" + key1; + } + if (proVal.equals("")) { + proVal = key2; + } else { + proVal += "@@@@" + key2; + } + } + if (isSingleEdit) { + newExaminedNum=this.examinedNum + this.examingNum; + newExamingNum=this.examingNum; + }else { + getNums(object, i); + newExamingNum=this.examingNum; + newExaminedNum=this.examinedNum; + System.out.println("ECN4:"+i+"editRow:"+editRows.get(i)); + qmb.updateValue(""+newExamingNum, ""+newExaminedNum, editRows.get(i)); +// ysr8_TaskManuState = "4"; + } + { + String key1 = "ysr8_ExaminedQuantity"; + String key2 = Integer.toString(editObjectListIdx.get(i)) + "$$$$" + fu.getDoubleString(newExaminedNum); + + if (proName.equals("")) { + proName = key1; + } else { + proName += "@@@@" + key1; + } + if (proVal.equals("")) { + proVal = key2; + } else { + proVal += "@@@@" + key2; + } + } + { + String key1 = "ysr8_ExaminingQuantity"; + String key2 = Integer.toString(editObjectListIdx.get(i)) + "$$$$" + fu.getDoubleString(newExamingNum); + + if (proName.equals("")) { + proName = key1; + } else { + proName += "@@@@" + key1; + } + if (proVal.equals("")) { + proVal = key2; + } else { + proVal += "@@@@" + key2; + } + } + + { + String key1 = "ysr8_SubQualityResult"; + String key2 = Integer.toString(editObjectListIdx.get(i)) + "$$$$" + ZJJLVal; + + if (proName.equals("")) { + proName = key1; + } else { + proName += "@@@@" + key1; + } + if (proVal.equals("")) { + proVal = key2; + } else { + proVal += "@@@@" + key2; + } + } + } else if (object_typeVal.equals("ɢ¼")) { + // kk ޸Ѽʼʱ + { + //TODO lidy20190310⴦ + String key1 = "ysr8_SubQualityFinishDate"; + String key2 = Integer.toString(editObjectListIdx.get(i)) + "$$$$" + ""; + + if (proName.equals("")) { + proName = key1; + } else { + proName += "@@@@" + key1; + } + if (proVal.equals("")) { + proVal = key2; + } else { + proVal += "@@@@" + key2; + } + } + if (isSingleEdit) { + newExaminedNum=this.examinedNum + this.examingNum; + newExamingNum=this.examingNum; + }else { + getNums(object, i); + newExamingNum=this.examingNum; + newExaminedNum=this.examinedNum; + System.out.println("INSP:"+i+"editRow:"+editRows.get(i)); + qmb.updateValue(""+newExamingNum, ""+newExaminedNum, editRows.get(i)); +// ysr8_TaskManuState = "4"; + } + { + String key1 = "ysr8_ExaminedQuantity"; + String key2 = Integer.toString(editObjectListIdx.get(i)) + "$$$$" + fu.getDoubleString(newExaminedNum); + + if (proName.equals("")) { + proName = key1; + } else { + proName += "@@@@" + key1; + } + if (proVal.equals("")) { + proVal = key2; + } else { + proVal += "@@@@" + key2; + } + } + { + String key1 = "ysr8_ExaminingQuantity"; + String key2 = Integer.toString(editObjectListIdx.get(i)) + "$$$$" + fu.getDoubleString(newExamingNum); + + if (proName.equals("")) { + proName = key1; + } else { + proName += "@@@@" + key1; + } + if (proVal.equals("")) { + proVal = key2; + } else { + proVal += "@@@@" + key2; + } + } + + { + String key1 = "ysr8_SubQualityResult"; + String key2 = Integer.toString(editObjectListIdx.get(i)) + "$$$$" + ZJJLVal; + + if (proName.equals("")) { + proName = key1; + } else { + proName += "@@@@" + key1; + } + if (proVal.equals("")) { + proVal = key2; + } else { + proVal += "@@@@" + key2; + } + } + } + params = item.getProperty("item_id") + "^^^^" + proName + "^^^^" + proVal; + + TCUserService userService = fu.session.getUserService(); + Object[] objParams = new Object[2]; + String cmd = "Update_ItemRevForm_TCProperty"; + objParams[0] = cmd; + objParams[1] = params; + long startime = System.currentTimeMillis(); + String result = (String) userService.call("YSR8UserService", objParams); + long endtime = System.currentTimeMillis(); + System.out.println("Cʱ" + (endtime - startime) + ""); + System.out.println(result); + form.refresh(); + } + } + } + tableMap.put("ysr8_ExaminedQuantity", fu.getDoubleString(newExaminedNum)); + tableMap.put("ysr8_ExaminingQuantity", fu.getDoubleString(newExamingNum)); +// tableMap.put("ysr8_TaskManuState", ysr8_TaskManuState); + + qmb.updateValues(tableMap); + disposeDialog(); + } catch (TCException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } catch (ParseException e) { + e.printStackTrace(); + MessageBox.post(e); + return; + } + } + + private void getDefVal() { + fu.getDefVal(); + } + + public boolean checkCanSave() throws Exception { + @SuppressWarnings("unchecked") + JComboBox ZJJL = (JComboBox) fu.allComponentMap.get("ZJJL"); + String ZJJLVal = ((JTextField) ZJJL.getEditor().getEditorComponent()).getText(); + if (ZJJLVal == null || "".equals(ZJJLVal)) { + MessageBox.post(this, "ʼ۲Ϊ", "ʾ", MessageBox.INFORMATION); + return false; + } + if (isSingleEdit) { // kk 0911 б༭ʱ + iTextField examingQuantityField = (iTextField) fu.allComponentMap.get("BCJYSL"); + String examingNumStr = examingQuantityField.getText(); + if ("".equals(examingNumStr)) { + MessageBox.post(this, "μΪ", "ʾ", MessageBox.INFORMATION); + return false; + } + this.examingNum = KUtil.getIntFromString(examingNumStr, "μ"); + if (examingNum <= 0) { + MessageBox.post(this, "μ", "ʾ", MessageBox.INFORMATION); + return false; + } + String arrivedNumStr = ""; + String examinedNumStr = ""; + Object object = editObjectList.get(0); + if (currTable == 1) { + if (object instanceof TCComponentScheduleTask) { + TCComponentScheduleTask scheduTask = (TCComponentScheduleTask) object; + String ysr8_TaskUse = scheduTask.getProperty("ysr8_TaskUse"); + if(ysr8_TaskUse.equals("")) { + arrivedNumStr = scheduTask.getProperty("ysr8_WiredQuantity"); + }else { + arrivedNumStr = scheduTask.getProperty("ysr8_ArrivedQuantity"); + } + examinedNumStr = scheduTask.getProperty("ysr8_ExaminedQuantity"); + } else if (object instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem) object; + TCComponentItemRevision revision = item.getLatestItemRevision(); + TCComponentForm form = TCUtil.getItemRevisionMasterForm(revision); + arrivedNumStr = form.getProperty("ysr8_ArrivedQuantity"); + examinedNumStr = form.getProperty("ysr8_ExaminedQuantity"); + } + } else if (currTable == 2) { + if (object instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem) object; + TCComponentItemRevision revision = item.getLatestItemRevision(); + TCComponentForm form = TCUtil.getItemRevisionMasterForm(revision); + TCProperty ysr8_ArrivedQuantity = form.getFormTCProperty("ysr8_ArrivedQuantity"); + String[] ysr8_ArrivedQuantityVals = ysr8_ArrivedQuantity.getStringArrayValue(); + if (ysr8_ArrivedQuantityVals != null && ysr8_ArrivedQuantityVals.length > editObjectListIdx.get(0)) { + arrivedNumStr = ysr8_ArrivedQuantityVals[editObjectListIdx.get(0)]; + } + TCProperty ysr8_ExaminedQuantity = form.getFormTCProperty("ysr8_ExaminedQuantity"); + String[] ysr8_ExaminedQuantityVals = ysr8_ExaminedQuantity.getStringArrayValue(); + if (ysr8_ExaminedQuantityVals != null && ysr8_ExaminedQuantityVals.length > editObjectListIdx.get(0)) { + examinedNumStr = ysr8_ExaminedQuantityVals[editObjectListIdx.get(0)]; + } + } + } + this.arrivedNum = KUtil.getIntFromString(arrivedNumStr, "ѵ"); + this.examinedNum = KUtil.getIntFromString(examinedNumStr, "Ѽ"); + if (examingNum > (arrivedNum - examinedNum)) { + System.out.println(""+examingNum+" : "+arrivedNum+" - "+examinedNum); + MessageBox.post(this, "㣺μ <= ѵ-Ѽ", "ʾ", MessageBox.INFORMATION); + return false; + } + } else {//lidy20181223 + } + return true; + } + + private void getNums(Object object, int i) throws TCException {//lidy20190107 + String arrivedNumStr = ""; + String examinedNumStr = ""; + if (currTable == 1) { + if (object instanceof TCComponentScheduleTask) { + TCComponentScheduleTask scheduTask = (TCComponentScheduleTask) object; + String ysr8_TaskUse = scheduTask.getProperty("ysr8_TaskUse"); + if(ysr8_TaskUse.equals("")) { + arrivedNumStr = scheduTask.getProperty("ysr8_WiredQuantity"); + }else { + arrivedNumStr = scheduTask.getProperty("ysr8_ArrivedQuantity"); + } + examinedNumStr = scheduTask.getProperty("ysr8_ExaminedQuantity"); + } else if (object instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem) object; + TCComponentItemRevision revision = item.getLatestItemRevision(); + TCComponentForm form = TCUtil.getItemRevisionMasterForm(revision); + arrivedNumStr = form.getProperty("ysr8_ArrivedQuantity"); + examinedNumStr = form.getProperty("ysr8_ExaminedQuantity"); + } + } else if (currTable == 2) { + if (object instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem) object; + TCComponentItemRevision revision = item.getLatestItemRevision(); + TCComponentForm form = TCUtil.getItemRevisionMasterForm(revision); + TCProperty ysr8_ArrivedQuantity = form.getFormTCProperty("ysr8_ArrivedQuantity"); + String[] ysr8_ArrivedQuantityVals = ysr8_ArrivedQuantity.getStringArrayValue(); + if (ysr8_ArrivedQuantityVals != null && ysr8_ArrivedQuantityVals.length > editObjectListIdx.get(i)) { + arrivedNumStr = ysr8_ArrivedQuantityVals[editObjectListIdx.get(i)]; + } + TCProperty ysr8_ExaminedQuantity = form.getFormTCProperty("ysr8_ExaminedQuantity"); + String[] ysr8_ExaminedQuantityVals = ysr8_ExaminedQuantity.getStringArrayValue(); + if (ysr8_ExaminedQuantityVals != null && ysr8_ExaminedQuantityVals.length > editObjectListIdx.get(i)) { + examinedNumStr = ysr8_ExaminedQuantityVals[editObjectListIdx.get(i)]; + } + } + } + int arrivedNum = 0; + int examinedNum = 0; + try { + if(arrivedNumStr!=null && !arrivedNumStr.isEmpty()) { + arrivedNum = Integer.parseInt(arrivedNumStr); + } + if(examinedNumStr!=null && !examinedNumStr.isEmpty()) { + examinedNum = Integer.parseInt(examinedNumStr); + } + } catch (NumberFormatException e) { + e.printStackTrace(); + MessageBox.post(this, "ѵ" + arrivedNumStr + "Ѽ" + examinedNumStr + "", "ʾ", MessageBox.INFORMATION); + throw new TCException("ѵ" + arrivedNumStr + "Ѽ" + examinedNumStr + ""); + } + + examingNum = arrivedNum - examinedNum; + this.examinedNum = arrivedNum; + } +} diff --git a/src/cn/com/ebewin/ysr/dialog/RectificationPurchasingImportDialog.java b/src/cn/com/ebewin/ysr/dialog/RectificationPurchasingImportDialog.java new file mode 100644 index 0000000..c457729 --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/RectificationPurchasingImportDialog.java @@ -0,0 +1,410 @@ +package cn.com.ebewin.ysr.dialog; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Vector; + +import javax.swing.JButton; +import javax.swing.JFrame; + +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.iTextField; + +import cn.com.ebewin.ysr.util.CommonUtil; +import cn.com.ebewin.ysr.util.DialogUtil; +import cn.com.ebewin.ysr.util.FileUtil; +import cn.com.ebewin.ysr.util.FormUtil; +import cn.com.ebewin.ysr.util.TCUtil; +import cn.com.ebewin.ysr.util.UIUtil; + +public class RectificationPurchasingImportDialog extends JFrame { + private static final long serialVersionUID = 1L; + DialogUtil fu = new DialogUtil(this, "IJɹݵ", "YSR8_RectificationPurchasingImportDialog"); + HashMap allECN = new HashMap(); + HashMap allECNType = new HashMap(); + private int c = 0; + + public RectificationPurchasingImportDialog(TCSession session) throws TCException { + //super(true); + + fu.initializeUI(session); + //centerToScreen(); + this.setLocationRelativeTo(null); + this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); + + loadRendering(); + addActionListener(); + setVisible(true); + } + + private void loadRendering() throws TCException { + JButton btn = (JButton)fu.allComponentMap.get("b.11.16"); + btn.setEnabled(false); + btn = (JButton)fu.allComponentMap.get("b.11.17"); + btn.setEnabled(false); + } + + private void addActionListener() { + JButton btn = (JButton)fu.allComponentMap.get("b.11.14"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + try { + loadExcel(); + } catch (Exception e1) { + MessageBox.post(RectificationPurchasingImportDialog.this,"ˣ\n"+e1.getMessage(),"ʾ",MessageBox.ERROR); + e1.printStackTrace(); + } + } + }); + + btn = (JButton)fu.allComponentMap.get("b.11.16"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + checkData(); + } + }); + + btn = (JButton)fu.allComponentMap.get("b.11.17"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + importData(); + } + }); + } + + private void loadExcel() throws Exception { + String[][] fileENames = { { ".xlsx", "MS-Excelļ(*.xlsx)" },{ ".xls", "MS-Excelļ(*.xls)" } };//lidy20190419֧xlsʽ + File file = FileUtil.openFileChooser(fileENames); + if (file == null) { + return; + } + iTextField textField = (iTextField)fu.allComponentMap.get("SJWJ"); + textField.setText(file.getName()); + + UIUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a.21.11.11"); + int rowCount = ci.dataTableModel.getRowCount(); + for(int i = rowCount - 1; i >= 0; i--){ + ci.dataTableModel.removeRow(i); + } + ci.dataTableModel.getDataVector().clear(); + + ci.dataTableModel.setRowCount(0); + //ɹID ƷID + // ɹID ƷID ѵ Ҫ IJɹ ɹ У ʾϢ + List> listData = FileUtil.readExcel(file); + + allECN.clear(); allECNType.clear(); + + //Integer idx = 0; + for (ArrayList arrayList : listData) { + Vector vec = new Vector<>(); + String purchID = arrayList.get(1).toString(); + Vector purchIDPart = CommonUtil.split2Vector(purchID, "-"); + if (purchIDPart.size() < 2) { + continue; + } + /*String ecnID = ""; + for (int i = 0; i < purchIDPart.size() - 1; i++) { + ecnID += purchIDPart.get(i); + if (i + 1 == purchIDPart.size() - 1) { + + } else { + ecnID += "-"; + } + }*/ + String ecnIdx = purchIDPart.get(purchIDPart.size() - 1); + //int ecnIdxint = Integer.parseInt(ecnIdx); + //kk TODO 0822 + int ecnIdxint=getDigit(ecnIdx); + vec.add(arrayList.get(0));// + vec.add(purchID);//ɹID + vec.add(arrayList.get(3).toString());//ƷID + //vec.add(new DecimalFormat("#.00").format(arrayList.get(2)));// + vec.add(arrayList.get(4));// + vec.add(arrayList.get(5).toString());// + vec.add("");//ѵ + vec.add("");//Ҫ + vec.add(arrayList.get(2));//IJɹ + vec.add(Integer.toString(ecnIdxint));//ɹ + vec.add("");//У + vec.add("");//ʾϢ + + ci.dataTableModel.addRow(vec); + } + + JButton btn = (JButton)fu.allComponentMap.get("b.11.16"); + btn.setEnabled(ci.dataTableModel.getRowCount() > 0); + } + + //kk TOOD 0822 ȡַ + private int getDigit(String str) throws Exception { + int len=str.length(); + String resStr=""; + for(int i=len-1;i>=0;i--) { + char c=str.charAt(i); + if(Character.isDigit(c)) { + resStr=c+resStr; + }else { + break; + } + } + int res=0; +// if(!"".equals(resStr)) { +// throw new Exception("޷ַȡĩβ֣"+str); +// } + if("".equals(resStr)) { + throw new Exception("޷ַȡĩβ֣"+str); + } + res = new Integer(resStr); + return res; + } + + private void checkData() { + UIUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a.21.11.11"); + try { + // ɹID ƷID ѵ Ҫ IJɹ ɹ У ʾϢ + for (int i = 0; i < ci.dataTableModel.getRowCount(); i++) { + String currFinishQuantity = ci.dataTableModel.getValueAt(i, 3).toString(); + String ecnID = ci.dataTableModel.getValueAt(i, 7).toString(); + String ecnIdx = ci.dataTableModel.getValueAt(i, 8).toString(); + + TCComponentForm ecnRevisionForm = allECN.get(ecnID); + System.out.println(ecnID); + if (ecnRevisionForm == null) { + TCComponentItem ecnItem = TCUtil.findItemByID(fu.session, ecnID); + if(ecnItem == null) { + ci.dataTableModel.setValueAt("", i, 9); + ci.dataTableModel.setValueAt("ҲƥIJɹ", i, 10); + continue; + } + String objectType; + objectType = ecnItem.getProperty("object_type"); + if(!objectType.equalsIgnoreCase("IJɹ") && !objectType.equalsIgnoreCase("IJɹ")) { + ci.dataTableModel.setValueAt("", i, 9); + ci.dataTableModel.setValueAt("ҲƥIJɹ", i, 10); + continue; + } + allECNType.put(ecnID, objectType); + + TCComponentItemRevision ecnRevision = ecnItem.getLatestItemRevision(); + ecnRevisionForm = TCUtil.getItemRevisionMasterForm(ecnRevision); + allECN.put(ecnID, ecnRevisionForm); + } + if (ecnRevisionForm == null) { + ci.dataTableModel.setValueAt("", i, 9); + ci.dataTableModel.setValueAt("ҲƥIJɹ", i, 10); + continue; + } + + String objectType = allECNType.get(ecnID); + + TCProperty ysr8_SerialNo = null, ysr8_FinishQuantity = null, ysr8_Quantity = null; + if (objectType.equalsIgnoreCase("IJɹ")) { + ysr8_SerialNo = (TCProperty)ecnRevisionForm.getFormTCProperty("ysr8_SerialNo"); + ysr8_FinishQuantity = (TCProperty)ecnRevisionForm.getFormTCProperty("ysr8_FinishQuantity"); + ysr8_Quantity = (TCProperty)ecnRevisionForm.getFormTCProperty("ysr8_Quantity"); + + } else if (objectType.equalsIgnoreCase("IJɹ")) { + ysr8_SerialNo = (TCProperty)ecnRevisionForm.getFormTCProperty("ysr8_SerialNo"); + ysr8_FinishQuantity = (TCProperty)ecnRevisionForm.getFormTCProperty("ysr8_FinishQuantity"); + ysr8_Quantity = (TCProperty)ecnRevisionForm.getFormTCProperty("ysr8_Quantity"); + } + int[] ysr8_SerialNoVals; + double[] ysr8_FinishQuantityVals, ysr8_QuantityVals; + ysr8_SerialNoVals = ysr8_SerialNo.getIntArrayValue(); + ysr8_FinishQuantityVals = ysr8_FinishQuantity.getDoubleArrayValue(); + ysr8_QuantityVals = ysr8_Quantity.getDoubleArrayValue(); + double ysr8_FinishQuantityVal = 0.0, ysr8_QuantityVal = 0.0; + boolean find = false; + for(int m = 0; m < ysr8_SerialNoVals.length; m++){ + if (ysr8_SerialNoVals[m] == Integer.parseInt(ecnIdx)) { + ysr8_FinishQuantityVal = ysr8_FinishQuantityVals[m]; + ysr8_QuantityVal = ysr8_QuantityVals[m]; + find = true; + break; + } + } + if (!find) { + ci.dataTableModel.setValueAt("", i, 9); + ci.dataTableModel.setValueAt("ҲƥɹIDĻƷϢ", i, 10); + continue; + } + + ysr8_FinishQuantityVal += Double.parseDouble(currFinishQuantity); + ci.dataTableModel.setValueAt(fu.getDoubleString(ysr8_FinishQuantityVal), i, 5);//ѵ + ci.dataTableModel.setValueAt(fu.getDoubleString(ysr8_QuantityVal), i, 6);//Ҫ + + if (ysr8_FinishQuantityVal > ysr8_QuantityVal) { + ci.dataTableModel.setValueAt("", i, 9); + ci.dataTableModel.setValueAt("֮ͳҪȷϣ", i, 10); + continue; + } else if (ysr8_FinishQuantityVal < ysr8_QuantityVal) { + ci.dataTableModel.setValueAt("", i, 9); + ci.dataTableModel.setValueAt("֮СҪ...", i, 10); + } else { + ci.dataTableModel.setValueAt("", i, 9); + } + } + } catch (TCException e) { + e.printStackTrace(); + return; + } + + JButton btn = (JButton)fu.allComponentMap.get("b.11.17"); + btn.setEnabled(true); + } + + private void importData() { + final ProgressReporterDialog reporter = new ProgressReporterDialog(); + reporter.reportProgressMessage("ڵ,Ժ..."); + new Thread(reporter).start(); + new Thread() { + public void run() { + fu.session.setStatus("ڵ..."); + c = 0; + importData_Sub(); + fu.session.setStatus(""); + reporter.requestCanceling(); + MessageBox.post(","+c+"", "", MessageBox.WARNING); + } + }.start(); +// Display.getDefault().syncExec(new Runnable() { +// @Override +// public void run() { +// try { +// new ProgressMonitorDialog(null).run(true, false, new IRunnableWithProgress() { +// @Override +// public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { +// fu.session.setStatus("ڵ..."); +// importData_Sub(); +// fu.session.setStatus(""); +// MessageBox.post("ɹ!", "", MessageBox.WARNING); +// } +// }); +// } catch (InvocationTargetException | InterruptedException ex) { +// ex.printStackTrace(); +// MessageBox.post("ʧ!\n" + ex.getMessage(), "", MessageBox.WARNING); +// } +// } +// }); + + //MessageBox.post(this, "ɹ", "", MessageBox.INFORMATION);//TODO lidy20190408ʧ + } + + private void importData_Sub() { + JButton btn = (JButton)fu.allComponentMap.get("b.11.17"); + btn.setEnabled(false); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + try { + UIUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a.21.11.11"); +// monitor.beginTask("ڵ룺", ci.dataTableModel.getRowCount()); + + // ɹID ƷID ѵ Ҫ IJɹ ɹ У ʾϢ + for (int i = 0; i < ci.dataTableModel.getRowCount(); i++) { + String check = ci.dataTableModel.getValueAt(i, 9).toString(); + String ecnID = ci.dataTableModel.getValueAt(i, 7).toString(); + String ecnIdx = ci.dataTableModel.getValueAt(i, 8).toString(); + if (!check.equals("")) { +// monitor.worked(1); + System.out.println(ecnID + "----" + ecnIdx + " δͨ"); + continue; + } + + System.out.println("ڵ룺" + ecnID + "----" + ecnIdx); + String finishDate = ci.dataTableModel.getValueAt(i, 4).toString(); + String finishQuantity = ci.dataTableModel.getValueAt(i, 5).toString(); + String quantity = ci.dataTableModel.getValueAt(i, 6).toString(); + + double finishQuantityDouble = Double.parseDouble(finishQuantity); + double quantityDouble = Double.parseDouble(quantity); + + TCComponentForm ecnRevisionForm = allECN.get(ecnID); + String objectType = allECNType.get(ecnID); + TCProperty ysr8_SerialNo = null, ysr8_FinishQuantity = null, ysr8_SubPurchFinishDate = null; + if (objectType.equalsIgnoreCase("IJɹ")) { + ysr8_SerialNo = (TCProperty)ecnRevisionForm.getFormTCProperty("ysr8_SerialNo"); + ysr8_FinishQuantity = (TCProperty)ecnRevisionForm.getFormTCProperty("ysr8_FinishQuantity"); + ysr8_SubPurchFinishDate = (TCProperty)ecnRevisionForm.getFormTCProperty("ysr8_SubPurchFinishDate"); + + } else if (objectType.equalsIgnoreCase("IJɹ")) { + ysr8_SerialNo = (TCProperty)ecnRevisionForm.getFormTCProperty("ysr8_SerialNo"); + ysr8_FinishQuantity = (TCProperty)ecnRevisionForm.getFormTCProperty("ysr8_FinishQuantity"); + ysr8_SubPurchFinishDate = (TCProperty)ecnRevisionForm.getFormTCProperty("ysr8_SubPurchFinishDate"); + } + int[] ysr8_SerialNoVals; + double[] ysr8_FinishQuantityVals; + Date[] ysr8_SubPurchFinishDateVals; + ysr8_SerialNoVals = ysr8_SerialNo.getIntArrayValue(); + ysr8_FinishQuantityVals = ysr8_FinishQuantity.getDoubleArrayValue(); + ysr8_SubPurchFinishDateVals = ysr8_SubPurchFinishDate.getDateValueArray(); + + CommonUtil.setByPass(true); + for(int m = 0; m < ysr8_SerialNoVals.length; m++){ + if (ysr8_SerialNoVals[m] == Integer.parseInt(ecnIdx)) { + if (finishQuantityDouble == quantityDouble) { + ysr8_FinishQuantityVals[m] = finishQuantityDouble; + ysr8_FinishQuantity.setDoubleValueArray(ysr8_FinishQuantityVals); + ysr8_SubPurchFinishDateVals[m] = sdf.parse(finishDate); + ysr8_SubPurchFinishDate.setDateValueArray(ysr8_SubPurchFinishDateVals); + + TCProperty[] formPropertyArray = new TCProperty[2]; + formPropertyArray[0] = ysr8_FinishQuantity; + formPropertyArray[1] = ysr8_SubPurchFinishDate; + ecnRevisionForm.setTCProperties(formPropertyArray); + //TODO + String oldEnd = "0000-01-01"; + + int count = 0; + for(Date date : ysr8_SubPurchFinishDateVals) { + if(date!=null) { + count++; + } + if(date==null) + continue; + String dateTime = sdf.format(date); + if (oldEnd.compareTo(dateTime) < 0) { + oldEnd = dateTime; + } + } + Date ysr8_PurchFinishDate = ecnRevisionForm.getDateProperty("ysr8_PurchFinishDate"); + if(ysr8_PurchFinishDate==null || !sdf.format(ysr8_PurchFinishDate).equals(oldEnd)) { + //޸ + if(count == ysr8_SubPurchFinishDateVals.length) { + ecnRevisionForm.setDateProperty("ysr8_PurchFinishDate", sdf.parse(oldEnd)); + } + } + } else { + ysr8_FinishQuantityVals[m] = finishQuantityDouble; + ysr8_FinishQuantity.setDoubleValueArray(ysr8_FinishQuantityVals); + + TCProperty[] formPropertyArray = new TCProperty[1]; + formPropertyArray[0] = ysr8_FinishQuantity; + ecnRevisionForm.setTCProperties(formPropertyArray); + } + break; + } + } + CommonUtil.setByPass(false); + c++; +// monitor.worked(1); + } +// monitor.done(); + + } catch (Exception ex) { + ex.printStackTrace(); + } + } + +} diff --git a/src/cn/com/ebewin/ysr/dialog/ScheduleTaskEditDialog.java b/src/cn/com/ebewin/ysr/dialog/ScheduleTaskEditDialog.java new file mode 100644 index 0000000..c3cdf52 --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/ScheduleTaskEditDialog.java @@ -0,0 +1,319 @@ +package cn.com.ebewin.ysr.dialog; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Date; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.schedule.commands.properties.WorkflowTemplateComboBox; +import com.teamcenter.rac.schedule.scheduler.componentutils.TaskHelper; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; + +import cn.com.ebewin.ysr.util.CommonUtil; + +@SuppressWarnings({ "serial", "deprecation" }) +public class ScheduleTaskEditDialog extends AbstractAIFDialog{ + + private TCSession session; + private AbstractAIFUIApplication app; + private ListOfValuesInfo taskUseLov; + private ListOfValuesInfo statusLov; + private JTextField countField; + private JComboBox taskUseComboBox; + private WorkflowTemplateComboBox workflowBox; + private DateButton planDate; + private JComboBox taskStatusBox; + private JTextField taskName; + private JButton okBtn; + private InterfaceAIFComponent[] targets; + private static final String PROP_COUNT="ysr8_PartNumber"; + private static final String PROP_TASKUSE="ysr8_TaskUse"; + private static final String PROP_PLANDATE="finish_date"; + private static final String PROP_TASKSTATUS="fnd0status"; + private static final String PROP_TASKNAME="object_name"; + private static final String PROP_WORKFLOW="workflow_template"; + + public ScheduleTaskEditDialog(AbstractAIFUIApplication app, TCSession session) { + super(true); + this.app=app; + this.session=session; + } + + @Override + public void run() { + //ȡĿ + this.targets = app.getTargetComponents(); + if(targets==null||targets.length==0) { + return; + } + //ȡLOV + this.taskUseLov = CommonUtil.getLov("YSR8_ScheduleTask01_LOV", session); + if(this.taskUseLov==null) { + MessageBox.post("ûҵLOVYSR8_ScheduleTask01_LOV","ʾ",MessageBox.WARNING); + return; + } + this.statusLov = CommonUtil.getLov("Fnd0state_status", session); + if(this.statusLov==null) { + MessageBox.post("ûҵLOVYSR8_SFnd0state_status","ʾ",MessageBox.WARNING); + return; + } + //ʼ + initUI(); + } + + private void initUI() { + if(this.targets.length==1) { + this.setTitle("ʱԱ༭--"+this.targets[0]); + }else { + this.setTitle("ʱԱ༭ѡ"+this.targets.length+""); + } + this.setLayout(new BorderLayout()); + this.setPreferredSize(new Dimension(500, 200)); + this.setMinimumSize(new Dimension(300, 150)); + JPanel mainPanel=new JPanel(new GridBagLayout()); + GridBagConstraints s = new GridBagConstraints(); + s.fill = GridBagConstraints.BOTH; + s.gridwidth = 1; + s.gridheight=1; + s.weightx = 0; + s.weighty = 0; + s.gridx=0; + s.gridy=0; + s.insets=new Insets(3, 10, 3, 10); + + mainPanel.add(new JLabel(""),s); + this.countField=new JTextField(); + s.gridx++; + s.weightx=1; + mainPanel.add(this.countField,s); + s.weightx=0; + s.gridx++; + mainPanel.add(new JLabel(";"),s); + this.taskUseComboBox=new JComboBox<>(); + s.gridx++; + s.weightx=0.6; + mainPanel.add(this.taskUseComboBox,s); + + s.gridx=0; + s.gridy++; + mainPanel.add(new JLabel("ƻʱ"),s); + this.planDate=new DateButton(null, "yyyy-MM-dd", false, false, false); + s.gridx++; + s.weightx=1; + mainPanel.add(this.planDate,s); + s.weightx=0; + s.gridx++; + mainPanel.add(new JLabel("״̬"),s); + this.taskStatusBox=new JComboBox(); +// taskStatus.addItem("δʼ"); +// taskStatus.addItem(""); +// taskStatus.addItem("Ҫע"); +// taskStatus.addItem("ٵ"); +// taskStatus.addItem(""); +// taskStatus.addItem("ѷ"); +// taskStatus.addItem("ֹ"); + s.gridx++; + s.weightx=0.6; + mainPanel.add(this.taskStatusBox,s); + s.gridx=0; + s.gridy++; + mainPanel.add(new JLabel(""),s); + this.taskName=new JTextField(); + s.gridx++; + s.weightx=1; + s.gridwidth = 4; + mainPanel.add(this.taskName,s); + s.gridwidth = 1; + s.weightx=0; + s.gridx=0; + s.gridy++; + mainPanel.add(new JLabel("ģ"),s); +// this.workflowBox=new JComboBox<>(); + this.workflowBox = new WorkflowTemplateComboBox(); + s.gridx++; + s.weightx=0.6; + s.gridwidth = 4; + mainPanel.add(this.workflowBox,s); + + s.weightx=0; + JPanel btnPanel=new JPanel(new FlowLayout(FlowLayout.CENTER,15,5)); + this.okBtn=new JButton("ȷϱ"); + btnPanel.add(okBtn); + //ʼ + try { + initData(); + } catch (Exception e) { + MessageBox.post("ʼʧܣ"+e.getMessage(),"ʾ",MessageBox.WARNING); + e.printStackTrace(); + return; + } + //ü + addListeners(); + this.add(BorderLayout.CENTER,mainPanel); + this.add(BorderLayout.SOUTH,btnPanel); + this.showDialog(); + } + + private void initData() throws Exception { + String[] lovVals = this.taskUseLov.getLOVDisplayValues(); + this.taskUseComboBox.addItem(null); + for (String v : lovVals) { + this.taskUseComboBox.addItem(v); + } + lovVals = this.statusLov.getLOVDisplayValues(); + this.taskStatusBox.addItem(null); + for (String v : lovVals) { + this.taskStatusBox.addItem(v); + } +// Object[] lovValues = TaskHelper.getWFTemplatesList(session); +// this.workflowBox.addItem(null); +// for (Object v : lovValues) { +// this.workflowBox.addItem(v); +// } + TCComponentScheduleTask targetTask = (TCComponentScheduleTask)this.targets[0]; +// workflowBox.load(targetTask); + workflowBox.addItems(TaskHelper.getWFTemplatesList(session)); +// addItems(TaskHelper.getWFTemplatesList(session)); + if(this.targets.length==1) { + String taskUseReal=targetTask.getTCProperty(PROP_TASKUSE).getStringValue(); + String taskStatusReal=targetTask.getTCProperty(PROP_TASKSTATUS).getStringValue(); + String count=targetTask.getProperty(PROP_COUNT); + String taskUse=this.taskUseLov.getDisplayableValue(taskUseReal); + String taskStatus=this.statusLov.getDisplayableValue(taskStatusReal); + Object workflow=targetTask.getReferenceProperty(PROP_WORKFLOW);//.getProperty(PROP_WORKFLOW); + System.out.println("workflow:"+workflow); + this.taskUseComboBox.setSelectedItem(taskUse); + this.workflowBox.setSelectedItem(workflow); + this.countField.setText(count); + + Date date=targetTask.getDateProperty(PROP_PLANDATE); +// String state=targetTask.getProperty(PROP_TASKSTATUS); + String name=targetTask.getProperty(PROP_TASKNAME); + this.planDate.setDate(date); + this.taskStatusBox.setSelectedItem(taskStatus); + this.taskName.setText(name); + } + } + + private void addListeners() { + this.okBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent arg0) { + try { + okEvent(); + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post("ʱ"+e.getMessage(),"ʾ",MessageBox.ERROR); + } + } + }); + + } + + private boolean checkInput() { + String count=this.countField.getText(); + try { + if(!"".equals(count)) { + Integer.parseInt(count); + } + return true; + } catch (NumberFormatException e) { + MessageBox.post("","ʾ",MessageBox.INFORMATION); + } catch (Exception e) { + MessageBox.post("ûʱ쳣"+e.getMessage(),"ʾ",MessageBox.WARNING); + } + return false; + } + + private void okEvent() throws Exception { + if(checkInput()) { + String countStr=this.countField.getText(); + Object taskUse=this.taskUseComboBox.getSelectedItem(); + + Date date=this.planDate.getDate(); + Object status=this.taskStatusBox.getSelectedItem(); + Object workflow=this.workflowBox.getSelectedItem(); + String name=this.taskName.getText(); + //״̬ + if(status!=null) { + String taskStatusReal=(String) this.statusLov.getRealValue(status.toString()); + System.out.println("statusReal:"+taskStatusReal); + if(taskStatusReal!=null) { + for (InterfaceAIFComponent comp : targets) { + String statused = ((TCComponentScheduleTask)comp).getStringProperty(PROP_TASKSTATUS); + if(!statused.equals(taskStatusReal)) + ((TCComponentScheduleTask)comp).setProperty(PROP_TASKSTATUS, taskStatusReal); + } + } + } +// else { +// for (InterfaceAIFComponent comp : targets) { +// ((TCComponentScheduleTask)comp).getTCProperty(PROP_TASKSTATUS).setValueFromString(""); +// } +// } + //ģ + if(workflow!=null) { +// String taskStatusReal=(String) this.statusLov.getRealValue(status.toString()); + System.out.println("workflow:"+workflow); + for (InterfaceAIFComponent comp : targets) { + TCComponentScheduleTask task = (TCComponentScheduleTask)comp; + System.out.println("PROP_TASKSTATUS:"+task.getStringProperty(PROP_TASKSTATUS)); + if(task.getStringProperty(PROP_TASKSTATUS).equals("not_started")) { + if(workflow instanceof TCComponent) + task.setReferenceProperty(PROP_WORKFLOW, (TCComponent) workflow); + else if("ûйģ".equals(workflow) || "".equals(workflow)) { + task.getTCProperty(PROP_WORKFLOW).setReferenceValue(null); + } + } + } + } + // + int count=0; + if(!"".equals(countStr)) { + count = Integer.parseInt(countStr); + } + for (InterfaceAIFComponent comp : targets) { + ((TCComponentScheduleTask)comp).setIntProperty(PROP_COUNT,count); + + ((TCComponentScheduleTask)comp).setDateProperty(PROP_PLANDATE,date); +// ((TCComponentScheduleTask)comp).setProperty(PROP_TASKSTATUS,state); + ((TCComponentScheduleTask)comp).setProperty(PROP_TASKNAME,name); + } + //; + if(taskUse!=null) { + String taskUseReal=(String) this.taskUseLov.getRealValue(taskUse.toString()); + if(taskUseReal!=null) { + for (InterfaceAIFComponent comp : targets) { + ((TCComponentScheduleTask)comp).setStringProperty(PROP_TASKUSE, taskUseReal); + } + } + }else { + for (InterfaceAIFComponent comp : targets) { + ((TCComponentScheduleTask)comp).getTCProperty(PROP_TASKUSE).setValueFromString(""); + } + } + disposeDialog(); + MessageBox.post("ݱɣ","ʾ",MessageBox.INFORMATION); + } + } + +} diff --git a/src/cn/com/ebewin/ysr/dialog/SelectMotomanModleDialog.java b/src/cn/com/ebewin/ysr/dialog/SelectMotomanModleDialog.java new file mode 100644 index 0000000..c8356d1 --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/SelectMotomanModleDialog.java @@ -0,0 +1,305 @@ +package cn.com.ebewin.ysr.dialog; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.Vector; + +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.border.TitledBorder; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableColumn; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.iTextField; + +import cn.com.ebewin.ysr.util.TCUtil; + +public class SelectMotomanModleDialog extends AbstractAIFDialog { + private static final long serialVersionUID = 1L; + private TCSession session; + + public String retJQRXH = ""; + public String retBTXH = ""; + public String retBZ = ""; + public String retKZGXH = ""; + + private iTextField txtJQRXH; + private iTextField txtBTXH; + private iTextField txtYT; + private iTextField txtKDBJC; + private iTextField txtKDBJZ; + private iTextField txtFZC; + private iTextField txtFZZ; + private iTextField txtCFDWJDC; + private iTextField txtCFDWJDZ; + + private JButton btnSearch; + private JButton btnOK; + private JButton btnCancel; + + private JTable table; + String names[] = ("ƹ,ͺ,ͺ,;,ע,(kg),Pˮƽɴ(mm),ظλ(mm),ɫ,IPȼ:/").split(","); + private SearchResultTableModel dtm; + + public class SearchResultTableModel extends DefaultTableModel { + + private static final long serialVersionUID = 1L; + + public SearchResultTableModel(String[] names, int index) { + super(new Object[0][], names); + } + + @Override + public boolean isCellEditable(int row, int column) { + return false; + } + + public Class getColumnClass(int column) { + return getValueAt(0, column).getClass(); + } + + // п + public void FitTableColumns(JTable myTable) { + JTableHeader header = myTable.getTableHeader(); + int rowCount = myTable.getRowCount(); + Enumeration columns = myTable.getColumnModel().getColumns(); + while (columns.hasMoreElements()) { + TableColumn column = (TableColumn) columns.nextElement(); + int col = header.getColumnModel().getColumnIndex(column.getIdentifier()); + int width = (int) myTable.getTableHeader().getDefaultRenderer().getTableCellRendererComponent(myTable, column.getIdentifier(), false, false, -1, col).getPreferredSize().getWidth(); + for (int row = 0; row < rowCount; row++) { + int preferedWidth = (int) myTable.getCellRenderer(row, col).getTableCellRendererComponent(myTable, myTable.getValueAt(row, col), false, false, row, col).getPreferredSize().getWidth(); + width = Math.max(width, preferedWidth); + } + header.setResizingColumn(column); + column.setWidth(width + myTable.getIntercellSpacing().width + 10); + } + } + } + + public SelectMotomanModleDialog(TCSession session) { + super(true); + this.session = session; + + setTitle("ͺŲѯ"); + initializeUI(); + addActionListener(); + setVisible(true); + } + + private void initializeUI() { + txtJQRXH = new iTextField("*", 25); + txtBTXH = new iTextField(25); + txtYT = new iTextField(25); + txtKDBJC = new iTextField(25); + txtKDBJZ = new iTextField(25); + txtFZC = new iTextField(25); + txtFZZ = new iTextField(25); + txtCFDWJDC = new iTextField(25); + txtCFDWJDZ = new iTextField(25); + + btnSearch = new JButton(" ѯ"); + btnOK = new JButton("ȷ"); + btnCancel = new JButton("ȡ"); + + JPanel paneTop = new JPanel(new PropertyLayout()); + paneTop.add("1.1.left.center", new JLabel("ͺţ")); + paneTop.add("1.2.left.center", txtJQRXH); + paneTop.add("1.3.left.center", new JLabel("")); + paneTop.add("1.4.right.center", btnSearch); + paneTop.add("2.1.left.center", new JLabel("ͺţ")); + paneTop.add("2.2.left.center", txtBTXH); + paneTop.add("2.3.left.center", new JLabel(";")); + paneTop.add("2.4.left.center", txtYT); + paneTop.add("3.1.left.center", new JLabel("Pˮƽɴ")); + paneTop.add("3.2.left.center", txtKDBJC); + paneTop.add("3.3.left.center", new JLabel("")); + paneTop.add("3.4.left.center", txtKDBJZ); + paneTop.add("4.1.left.center", new JLabel("أ")); + paneTop.add("4.2.left.center", txtFZC); + paneTop.add("4.3.left.center", new JLabel("")); + paneTop.add("4.4.left.center", txtFZZ); + paneTop.add("5.1.left.center", new JLabel("ظλȣ")); + paneTop.add("5.2.left.center", txtCFDWJDC); + paneTop.add("5.3.left.center", new JLabel("")); + paneTop.add("5.4.left.center", txtCFDWJDZ); + + JPanel paneMid = new JPanel(new BorderLayout()); + paneMid.setBorder(new TitledBorder("")); + dtm = new SearchResultTableModel(names, 0); + table = new JTable(dtm); + table.getTableHeader().setReorderingAllowed(false); + table.setRowHeight(22); + table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + table.setAutoscrolls(true); + table.setShowGrid(true); + JScrollPane scrollPane = new JScrollPane(table);; + scrollPane.setPreferredSize(new Dimension(800, 450)); + paneMid.add(scrollPane); + + JPanel paneBotton = new JPanel(new PropertyLayout()); + paneBotton.add("1.1.left.center", new JLabel("")); + paneBotton.add("1.2.left.center", btnOK); + paneBotton.add("1.3.left.center", new JLabel("")); + paneBotton.add("1.4.left.center", btnCancel); + + JPanel paneMain = new JPanel(new PropertyLayout()); + paneMain.add("1.1.left.center", new JLabel(" ")); + paneMain.add("2.1.left.center", new JLabel(" ")); + paneMain.add("2.2.center.center", paneTop); + paneMain.add("3.1.left.center", new JLabel(" ")); + paneMain.add("3.2.center.center", paneMid); + paneMain.add("4.1.left.center", new JLabel(" ")); + paneMain.add("4.2.center.center", paneBotton); + getContentPane().add(paneMain); + + pack(); + centerToScreen(); + setResizable(false); + } + + private void addActionListener() { + + btnSearch.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + loadPane(); + } + }); + + btnOK.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡһݣ", "ʾ", MessageBox.INFORMATION); + return; + } + retJQRXH = dtm.getValueAt(rows[0], 1).toString(); + retBTXH = dtm.getValueAt(rows[0], 2).toString(); + retBZ = dtm.getValueAt(rows[0], 4).toString(); + retKZGXH = dtm.getValueAt(rows[0], 0).toString(); + + dialogResultId = ID_OK; + disposeDialog(); + } + }); + + btnCancel.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + dialogResultId = ID_CANCEL; + disposeDialog(); + } + }); + } + + public String getSearchCondition() { + HashMap hmkey = new HashMap(); + String JQRXH = txtJQRXH.getText(); + String BTXH = txtBTXH.getText(); + String YT = txtYT.getText(); + String KDBJC = txtKDBJC.getText(); + String KDBJZ = txtKDBJZ.getText(); + String FZC = txtFZC.getText(); + String FZZ = txtFZZ.getText(); + String CFDWJDC = txtCFDWJDC.getText(); + String CFDWJDZ = txtCFDWJDZ.getText(); + + if (!JQRXH.equals("") && !JQRXH.equals("*")) { + hmkey.put("JQRXH", JQRXH); + } + if (!BTXH.equals("") && !BTXH.equals("*")) { + hmkey.put("BTXH", BTXH); + } + if (!YT.equals("") && !YT.equals("*")) { + hmkey.put("YT", YT); + } + if (!KDBJC.equals("") && !KDBJC.equals("*")) { + hmkey.put("KDBJC", KDBJC); + } + if (!KDBJZ.equals("") && !KDBJZ.equals("*")) { + hmkey.put("KDBJZ", KDBJZ); + } + if (!FZC.equals("") && !FZC.equals("*")) { + hmkey.put("FZC", FZC); + } + if (!FZZ.equals("") && !FZZ.equals("*")) { + hmkey.put("FZZ", FZZ); + } + if (!CFDWJDC.equals("") && !CFDWJDC.equals("*")) { + hmkey.put("CFDWJDC", CFDWJDC); + } + if (!CFDWJDZ.equals("") && !CFDWJDZ.equals("*")) { + hmkey.put("CFDWJDZ", CFDWJDZ); + } + + String sql = "SELECT PSM01, PSM02, PSM03, PSM04, PSM08, PSM05, PSM06, PSM07, PSM12, PSM13 FROM PICM0 WHERE PCID = 'Motoman'"; + if (hmkey.get("JQRXH") != null) { + sql += " AND PSM02 Like '%" + hmkey.get("JQRXH") + "%'"; + } + if (hmkey.get("BTXH") != null) { + sql += " AND PSM03 Like '%" + hmkey.get("BTXH") + "%'"; + } + if (hmkey.get("YT") != null) { + sql += " AND PSM04 Like '%" + hmkey.get("YT") + "%'"; + } + if (hmkey.get("KDBJC") != null) { + sql += " AND PSM06 >= " + hmkey.get("KDBJC") + ""; + } + if (hmkey.get("KDBJZ") != null) { + sql += " AND PSM06 <= " + hmkey.get("KDBJZ") + ""; + } + if (hmkey.get("FZC") != null) { + sql += " AND PSM05 >= " + hmkey.get("FZC") + ""; + } + if (hmkey.get("FZZ") != null) { + sql += " AND PSM05 <= " + hmkey.get("FZZ") + ""; + } + if (hmkey.get("CFDWJDC") != null) { + sql += " AND PSM07 >= " + hmkey.get("CFDWJDC") + ""; + } + if (hmkey.get("CFDWJDZ") != null) { + sql += " AND PSM07 <= " + hmkey.get("CFDWJDZ") + ""; + } + sql += " ORDER BY PSM02, PSM03"; +System.out.println(sql); + return sql; + } + + private void loadPane(){ + String sql = getSearchCondition(); + + Vector> vecData = TCUtil.GetCls_InstanceInfo(session, sql); + dtm.getDataVector().clear(); + if (vecData != null) { + for (Iterator> iterator = vecData.iterator(); iterator.hasNext();) { + Hashtable hashtable = (Hashtable) iterator.next(); + String[] rowData = new String[10]; + rowData[0] = hashtable.get("PSM01").toString(); + rowData[1] = hashtable.get("PSM02").toString(); + rowData[2] = hashtable.get("PSM03").toString(); + rowData[3] = hashtable.get("PSM04").toString(); + rowData[4] = hashtable.get("PSM08").toString(); + rowData[5] = hashtable.get("PSM05").toString(); + rowData[6] = hashtable.get("PSM06").toString(); + rowData[7] = hashtable.get("PSM07").toString(); + rowData[8] = hashtable.get("PSM12").toString(); + rowData[9] = hashtable.get("PSM13").toString(); + dtm.addRow(rowData); + } + } + dtm.FitTableColumns(table); + } +} \ No newline at end of file diff --git a/src/cn/com/ebewin/ysr/dialog/SelectUserDialog.java b/src/cn/com/ebewin/ysr/dialog/SelectUserDialog.java new file mode 100644 index 0000000..16094a7 --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/SelectUserDialog.java @@ -0,0 +1,191 @@ +package cn.com.ebewin.ysr.dialog; + +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.Vector; + +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.tree.TreeNode; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.common.AIFTreeNode; +import com.teamcenter.rac.common.organization.OrgNodeInfo; +import com.teamcenter.rac.common.organization.OrgTreePanel; +import com.teamcenter.rac.common.organization.OrganizationTree; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.ui.common.RACUIUtil; +import com.teamcenter.rac.util.PropertyLayout; + +import cn.com.ebewin.ysr.util.CommonUtil; + +public class SelectUserDialog extends AbstractAIFDialog { + private static final long serialVersionUID = 1L; + //private TCSession session = null; + String type; + + private String value = ""; + private String Dep = ""; + + JButton buttonSelect = new JButton("ѡ"); + JButton buttonConcel = new JButton("ȡ"); + + public SelectUserDialog(TCSession session, String type) { + super(true); + //this.session = session; + this.type = type; + } + + public String getUserOfDep() { + return Dep; + } + + public String getValue() { + setTitle("ѡԱ"); + + JPanel paneMain = new JPanel(new PropertyLayout()); + + OrgTreePanel org = new OrgTreePanel(RACUIUtil.getTCSession()); + final OrganizationTree orgTree = org.getOrgTree(); + orgTree.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent mouseevent) { + if(mouseevent.getClickCount() == 2){ + if (type.equals("user") || type.equals("userid")) { + if(orgTree.getSelectedNode() != null && orgTree.getSelectedNode().isLeaf()){ + AIFTreeNode node = orgTree.getSelectedNode(); + if (node == null) { + return; + } + String userInfo = orgTree.getSelectedNode().getUserObject().toString(); + System.out.println("userInfo1=====" + userInfo); + userInfo = userInfo.substring(userInfo.lastIndexOf("/") + 1); + System.out.println("userInfo2=====" + userInfo); + String userName = userInfo; + String userID = userInfo; + if(userInfo.contains("(")){ + userName = userInfo.substring(0, userInfo.indexOf("(")).trim(); + userID = userInfo.substring(userInfo.indexOf("(") + 1).trim(); + userID = userID.substring(0, userID.length() - 1); + } + System.out.println("userID=====" + userID); + System.out.println("userName=====" + userName); + if (type.equals("user")) { + value = userName; + } else if (type.equals("userid")) { + value = userID; + } + + TreeNode parent = node.getParent(); + if (parent != null) { + parent = parent.getParent(); + String groupInfo = parent.toString(); + Dep = groupInfo.substring(userInfo.lastIndexOf("/") + 1); + Vector Deps = CommonUtil.split2Vector(Dep, "."); + Dep = Deps.get(0); + } + } + }else if (type.equals("organization")){ + if(orgTree.getSelectedNode() != null){ + String organization; + OrgNodeInfo orgNodeInfo = (OrgNodeInfo)orgTree.getSelectedNode().getUserObject(); + if (orgNodeInfo.getType()==0) { + organization=orgTree.getSelectedNode().toString(); + value=organization; + } + } + } + disposeDialog(); + } + } + }); + + JPanel paneButton = new JPanel(new PropertyLayout()); + buttonSelect.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if (type.equals("user") || type.equals("userid")) { + if(orgTree.getSelectedNode() != null){ + if(orgTree.getSelectedNode() != null && orgTree.getSelectedNode().isLeaf()){ + AIFTreeNode node = orgTree.getSelectedNode(); + if (node == null) { + return; + } + String userInfo = orgTree.getSelectedNode().getUserObject().toString(); + userInfo = userInfo.substring(userInfo.lastIndexOf("/") + 1); + String userName = userInfo; + String userID = userInfo; + if(userInfo.contains("(")){ + userName = userInfo.substring(0, userInfo.indexOf("(")).trim(); + userID = userInfo.substring(userInfo.indexOf("(") + 1).trim(); + userID = userID.substring(0, userID.length() - 1); + } + System.out.println("userID=====" + userID); + System.out.println("userName=====" + userName); + if (type.equals("user")) { + value = userName; + } else if (type.equals("userid")) { + value = userID; + } + + TreeNode parent = node.getParent(); + if (parent != null) { + parent = parent.getParent(); + String groupInfo = parent.toString(); + Dep = groupInfo.substring(userInfo.lastIndexOf("/") + 1); + Vector Deps = CommonUtil.split2Vector(Dep, "."); + Dep = Deps.get(0); + } + } + /* + String user; + OrgNodeInfo orgNodeInfo=(OrgNodeInfo)orgTree.getSelectedNode().getUserObject(); + if(orgNodeInfo.getType()==3){ + user = orgTree.getSelectedNode().getUserObject().toString() ; + user = user.substring(user.lastIndexOf("/") + 1); + if(user.contains("(")){ + user = user.substring(0,user.indexOf("(")).trim(); + } + value=user; + } + */ + } + }else if (type.equals("organization")){ + if(orgTree.getSelectedNode() != null){ + String organization; + OrgNodeInfo orgNodeInfo=(OrgNodeInfo)orgTree.getSelectedNode().getUserObject(); + if (orgNodeInfo.getType()==0) { + organization=orgTree.getSelectedNode().toString(); + value=organization; + } + } + } + disposeDialog(); + } + }); + + buttonConcel.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + paneButton.add("1.1.left.center",buttonSelect); + paneButton.add("1.2.left.center",new JLabel(" ")); + paneButton.add("1.3.left.center",buttonConcel); + + org.setPreferredSize(new Dimension(300, 350)); + paneMain.add("1.1.center.center",org); + paneMain.add("2.1.center.center",paneButton); + + getContentPane().add(paneMain); + pack(); + centerToScreen(); + setResizable(false); + setVisible(true); + return value; + } + + +} diff --git a/src/cn/com/ebewin/ysr/dialog/ShowPicFrame.java b/src/cn/com/ebewin/ysr/dialog/ShowPicFrame.java new file mode 100644 index 0000000..4daf08f --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/ShowPicFrame.java @@ -0,0 +1,1411 @@ +package cn.com.ebewin.ysr.dialog; + +import java.awt.Color; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseWheelEvent; +import java.awt.event.MouseWheelListener; +import java.io.File; +import java.util.Vector; + +import javax.swing.ImageIcon; +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.JPanel; +import javax.swing.JScrollPane; + +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + +import cn.com.ebewin.ysr.util.CommonUtil; +import cn.com.ebewin.ysr.util.TCUtil; + +public class ShowPicFrame extends JDialog implements ActionListener, MouseListener, MouseWheelListener{ + private static final long serialVersionUID = 1L; + + JMenuBar jmb; + JMenuItem jm1, jm2, jm3, jm4, jm5; + JLabel jl, jl1; + JPanel jp; + JScrollPane jsp; + ImageIcon imgIco, showii; + Vector fs = new Vector(); + File f; + int currIdx; + float width; + float height; + + TCSession session; + TCComponentItemRevision prRevision; + Vector prDatasets = new Vector(); + + public ShowPicFrame(JFrame owner, boolean modaln) { + super(owner, modaln); + } + public ShowPicFrame(JDialog owner, boolean modaln) { + super(owner, modaln); + } + + void init(TCSession session, TCComponentItemRevision prRevision) { + //˵ + jmb = new JMenuBar(); + jm1 = new JMenuItem("һ"); + jm1.addActionListener(this); + jm2 = new JMenuItem("һ"); + jm2.addActionListener(this); + jm3 = new JMenuItem("Ŵ"); + jm3.addActionListener(this); + jm4 = new JMenuItem("С"); + jm4.addActionListener(this); + jm5 = new JMenuItem("ԭͼ"); + jm5.addActionListener(this); + jmb.add(jm1); + jmb.add(jm2); + jmb.add(jm3); + jmb.add(jm4); + jmb.add(jm5); + + //ʾ + jl = new JLabel("ѡͼƬ", JLabel.CENTER); + jl.setForeground(Color.gray); + jl.addMouseWheelListener(this); + jl.addMouseListener(this); + jsp = new JScrollPane(jl); + + //ײϢ + jl1 = new JLabel("ͼƬϢ"); + //ô + this.setJMenuBar(jmb); + this.add(jsp); + this.add(jl1, "South"); + + this.setSize(700, 500); + this.setLocation(300, 200); + this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); + + this.session = session; + this.prRevision = prRevision; + TCComponentDataset dataset = null; + try { + TCComponent[] components = prRevision.getRelatedComponents("IMAN_specification"); + if (components != null && components.length > 0) { + for (int i = 0; i < components.length; i++) { + dataset = (TCComponentDataset) components[i]; + String object_typeVal = dataset.getProperty("object_type"); + System.out.println("object_typeVal===========" + object_typeVal); + if (object_typeVal.equalsIgnoreCase("JPEG") || + //object_typeVal.equalsIgnoreCase("λͼ") || + object_typeVal.equalsIgnoreCase("GIF") || + object_typeVal.equalsIgnoreCase("Image") || + object_typeVal.equalsIgnoreCase("ͼ") || + object_typeVal.equalsIgnoreCase("Яʽͼͼ")) { + prDatasets.add(dataset); + System.out.println("prDatasets.add(dataset)=======" + prDatasets.size()); + } + } + } + } catch (TCException e1) { + e1.printStackTrace(); + } + currIdx = 0; + f = downloadPic(currIdx); + imgIco = new ImageIcon(f.getPath()); + ShowImg(); + + pack(); + setResizable(true); + setVisible(true); + } + + public void ShowImg() { + if(imgIco.getIconWidth() > 695 || imgIco.getIconHeight() > 465){ + width = 695; + height = 675 * (float)imgIco.getIconHeight() / imgIco.getIconWidth(); + //System.out.println((float)ii.getIconHeight()/ii.getIconWidth()); + }else { + width = imgIco.getIconWidth(); + height = imgIco.getIconHeight(); + } + showii = new ImageIcon(imgIco.getImage().getScaledInstance((int)width, (int)height, 0)); + this.jl.setText(""); + this.jl.setIcon(showii); + ShowMsg(); + } + + public void Zoom(int flag) { + if ((width < 5000 && height < 4000) && (width > 5 && height > 4)) { + if (flag == 0) { + //Ŵ + width *= 1.3; height *= 1.3; + } else if (flag == 1) { + //С + width *= 0.7; height *= 0.7; + } else if (flag == 2) { + //ԭͼ + width = imgIco.getIconWidth(); height = imgIco.getIconHeight(); + } + showii = new ImageIcon(imgIco.getImage().getScaledInstance((int) width, (int) height, 0)); + this.jl.setIcon(showii); + ShowMsg(); + } else if (width > 5000 || height > 4000) { + width *= 0.8; + height *= 0.8; + //JOptionPane.showMessageDialog(this, "ٷŴʧ棡"); + } else if (width < 5 || height < 3) { + width *= 1.2; + height *= 1.2; + //JOptionPane.showMessageDialog(this, "СͿˣ"); + } + } + + public void ShowMsg() { + //õײϢ + String[] n = f.getName().split("\\."); + float per = (float)showii.getIconWidth() / imgIco.getIconWidth(); + String msg = "ԭͼ" + imgIco.getIconWidth() + "x" + imgIco.getIconHeight() + "" + + " ʾ" + showii.getIconWidth() + "x" + showii.getIconHeight() + "" + + " Ŷȣ" + (int)(per*100) + "%" + + " ʽ:" + (n.length == 1 ? "δ֪" : n[1]); + this.jl1.setText(msg); + this.setTitle(f.toString()); + this.jl1.setForeground(Color.gray); + } + + @Override + public void actionPerformed(ActionEvent e) { + if(e.getSource() == jm1) { + if (currIdx == 0) { + return; + } + currIdx--; + f = downloadPic(currIdx); + imgIco = new ImageIcon(f.getPath()); + ShowImg(); + } else if(e.getSource() == jm2) { + if (currIdx == prDatasets.size() - 1) { + return; + } + currIdx++; + f = downloadPic(currIdx); + imgIco = new ImageIcon(f.getPath()); + ShowImg(); + } else if(f != null && e.getSource() == jm3) { + //Ŵ + Zoom(0); + } else if(f != null && e.getSource() == jm4) { + //С + Zoom(1); + } else if(f != null && e.getSource() == jm5) { + //ԭͼ + Zoom(2); + } + } + + @Override + public void mouseWheelMoved(MouseWheelEvent e) { + //System.out.println(e.getWheelRotation()+" "+e.getScrollAmount()); + if(f != null) { + if (e.getWheelRotation() == 1) { + Zoom(0); + } else if (e.getWheelRotation() == -1) { + Zoom(1); + } + } + } + + @Override + public void mouseClicked(MouseEvent e) { + } + + @Override + public void mousePressed(MouseEvent e) { + } + + @Override + public void mouseReleased(MouseEvent e) { + } + + @Override + public void mouseEntered(MouseEvent e) { + } + + @Override + public void mouseExited(MouseEvent e) { + } + + public File downloadPic(int idx) { + if (fs.size() > idx) { + return fs.get(idx); + } + try { + if (prDatasets.size() > idx) { + TCComponentDataset dataset = prDatasets.get(idx); + String name = dataset.getProperty("object_string"); + File file = TCUtil.exportFileToDir(dataset, CommonUtil.tmpDir, name); + fs.add(file); + return file; + } + } catch (TCException e1) { + e1.printStackTrace(); + } + return null; + } +} + + +//-------------------------------------------------------- +//// +////This code was taken and cleaned up from a +////Javaworld tips and tricks column +//// +// +//importjava.awt.Image; +//importjava.awt.Toolkit; +//importjava.awt.image.MemoryImageSource; +//importjava.io.FileInputStream; +//importjava.io.IOException; +// +//importjavax.swing.ImageIcon; +//importjavax.swing.JFrame; +//importjavax.swing.JLabel; +//importjavax.swing.JScrollPane; +// +//// +////really just a collection of methods to read a BMP file +//// +// +//publicclass BMPLoader +// +//{ +// +//// build an int from a byte array - convert little to big endian +//publicstaticint constructInt(byte[] in, int offset) { +// +//int ret = ((int) in[offset + 3] & 0xff); +// +// ret = (ret << 8) | ((int) in[offset + 2] & 0xff); +// +// ret = (ret << 8) | ((int) in[offset + 1] & 0xff); +// +// ret = (ret << 8) | ((int) in[offset + 0] & 0xff); +// +//return (ret); +// +// } +// +//// build an int from a byte array - convert little to big endian +//// set high order bytes to 0xfff +//publicstaticint constructInt3(byte[] in, int offset) { +// +//int ret = 0xff; +// +// ret = (ret << 8) | ((int) in[offset + 2] & 0xff); +// +// ret = (ret << 8) | ((int) in[offset + 1] & 0xff); +// +// ret = (ret << 8) | ((int) in[offset + 0] & 0xff); +// +//return (ret); +// +// } +// +//// build an int from a byte array - convert little to big endian +//publicstaticlong constructLong(byte[] in, int offset) { +// +//long ret = ((long) in[offset + 7] & 0xff); +// +// ret |= (ret << 8) | ((long) in[offset + 6] & 0xff); +// +// ret |= (ret << 8) | ((long) in[offset + 5] & 0xff); +// +// ret |= (ret << 8) | ((long) in[offset + 4] & 0xff); +// +// ret |= (ret << 8) | ((long) in[offset + 3] & 0xff); +// +// ret |= (ret << 8) | ((long) in[offset + 2] & 0xff); +// +// ret |= (ret << 8) | ((long) in[offset + 1] & 0xff); +// +// ret |= (ret << 8) | ((long) in[offset + 0] & 0xff); +// +//return (ret); +// +// } +// +//// build an double from a byte array - convert little to big endian +//publicstaticdouble constructDouble(byte[] in, int offset) { +// +//long ret = constructLong(in, offset); +// +//return (Double.longBitsToDouble(ret)); +// +// } +// +//// build an short from a byte array - convert little to big endian +//publicstaticshort constructShort(byte[] in, int offset) { +// +//short ret = (short) ((short) in[offset + 1] & 0xff); +// +// ret = (short) ((ret << 8) | (short) ((short) in[offset + 0] & 0xff)); +// +//return (ret); +// +// } +// +//// internal class representing a bitmap header structure +//// with code to read it from a file +//staticclass BitmapHeader { +// +//publicint nsize; +// +//publicint nbisize; +// +//publicint nwidth; +// +//publicint nheight; +// +//publicint nplanes; +// +//publicint nbitcount; +// +//publicint ncompression; +// +//publicint nsizeimage; +// +//publicint nxpm; +// +//publicint nypm; +// +//publicint nclrused; +// +//publicint nclrimp; +// +//// read in the bitmap header +//publicvoid read(FileInputStream fs) throwsIOException +// +// { +// +//finalint bflen = 14; // 14 byte BITMAPFILEHEADER +// +//byte bf[] = newbyte[bflen]; +// +// fs.read(bf, 0, bflen); +// +//finalint bilen = 40; // 40-byte BITMAPINFOHEADER +// +//byte bi[] = newbyte[bilen]; +// +// fs.read(bi, 0, bilen); +// +//// Interperet data. +// nsize = constructInt(bf, 2); +// +//// System.out.println("File type is :"+(char)bf[0]+(char)bf[1]); +//// System.out.println("Size of file is :"+nsize); +// +// nbisize = constructInt(bi, 2); +// +//// System.out.println("Size of bitmapinfoheader is :"+nbisize); +// +// nwidth = constructInt(bi, 4); +// +//// System.out.println("Width is :"+nwidth); +// +// nheight = constructInt(bi, 8); +// +//// System.out.println("Height is :"+nheight); +// +// nplanes = constructShort(bi, 12); //(((int)bi[13]&0xff)<<8) | +//// (int)bi[12]&0xff; +// +//// System.out.println("Planes is :"+nplanes); +// +// nbitcount = constructShort(bi, 14); //(((int)bi[15]&0xff)<<8) | +//// (int)bi[14]&0xff; +// +//// System.out.println("BitCount is :"+nbitcount); +// +//// Look for non-zero values to indicate compression +// ncompression = constructInt(bi, 16); +// +//// System.out.println("Compression is :"+ncompression); +// +// nsizeimage = constructInt(bi, 20); +// +//// System.out.println("SizeImage is :"+nsizeimage); +// +// nxpm = constructInt(bi, 24); +// +//// System.out.println("X-Pixels per meter is :"+nxpm); +// +// nypm = constructInt(bi, 28); +// +//// System.out.println("Y-Pixels per meter is :"+nypm); +// +// nclrused = constructInt(bi, 32); +// +//// System.out.println("Colors used are :"+nclrused); +// +// nclrimp = constructInt(bi, 36); +// +//// System.out.println("Colors important are :"+nclrimp); +// +// } +// +// } +// +//publicstaticImage read(FileInputStream fs) +// +// { +// +//try { +// +// BitmapHeader bh = new BitmapHeader(); +// +// bh.read(fs); +// +//if (bh.nbitcount == 24) +// +//return (readMap24(fs, bh)); +// +//if (bh.nbitcount == 32) +// +//return (readMap32(fs, bh)); +// +//if (bh.nbitcount == 8) +// +//return (readMap8(fs, bh)); +// +// fs.close(); +// +// } catch (IOException e) { +// +//// System.out.println("Caught exception in loadbitmap!"); +// } +// +//return (null); +// +// } +// +///** +// * +// * readMap24 internal routine to read the bytes in a 24 bit bitmap +// * +// * +// * +// * Arguments: +// * +// * fs - file stream +// * +// * bh - header struct +// * +// * Returns: +// * +// * Image Object, be sure to check for (Image)null !!!! +// * +// * +// * +// */ +//protectedstaticImage readMap32(FileInputStream fs, BitmapHeader bh) +//throwsIOException +// +// { +// +//Image image; +// +//// No Palatte data for 24-bit format but scan lines are +// +//// padded out to even 4-byte boundaries. +// +//int xwidth = bh.nsizeimage / bh.nheight; +// +//int ndata[] = newint[bh.nheight * bh.nwidth]; +// +//byte brgb[] = newbyte[bh.nwidth * 4 * bh.nheight]; +// +// fs.read(brgb, 0, bh.nwidth * 4 * bh.nheight); +// +//int nindex = 0; +// +//for (int j = 0; j < bh.nheight; j++) +// +// { +// +//for (int i = 0; i < bh.nwidth; i++) +// +// { +// +// ndata[bh.nwidth * (bh.nheight - j - 1) + i] = constructInt3( +// brgb, nindex); +// +// nindex += 4; +// +// } +// +// } +// +// image = Toolkit.getDefaultToolkit().createImage +// +// (newMemoryImageSource(bh.nwidth, bh.nheight, +// +// ndata, 0, bh.nwidth)); +// +// fs.close(); +// +//return (image); +// +// } +// +///** +// * +// * readMap24 internal routine to read the bytes in a 24 bit bitmap +// * +// * +// * +// * Arguments: +// * +// * fs - file stream +// * +// * bh - header struct +// * +// * Returns: +// * +// * Image Object, be sure to check for (Image)null !!!! +// * +// * +// * +// */ +//protectedstaticImage readMap24(FileInputStream fs, BitmapHeader bh) +//throwsIOException +// +// { +// +//Image image; +// +//// No Palatte data for 24-bit format but scan lines are +// +//// padded out to even 4-byte boundaries. +// +//int npad = (bh.nsizeimage / bh.nheight) - bh.nwidth * 3; +// +//int ndata[] = newint[bh.nheight * bh.nwidth]; +// +//byte brgb[] = newbyte[(bh.nwidth + npad) * 3 * bh.nheight]; +// +// fs.read(brgb, 0, (bh.nwidth + npad) * 3 * bh.nheight); +// +//int nindex = 0; +// +//for (int j = 0; j < bh.nheight; j++) +// +// { +// +//for (int i = 0; i < bh.nwidth; i++) +// +// { +// +// ndata[bh.nwidth * (bh.nheight - j - 1) + i] = constructInt3( +// brgb, nindex); +// +// nindex += 3; +// +// } +// +// nindex += npad; +// +// } +// +// image = Toolkit.getDefaultToolkit().createImage +// +// (newMemoryImageSource(bh.nwidth, bh.nheight, +// +// ndata, 0, bh.nwidth)); +// +// fs.close(); +// +//return (image); +// +// } +// +///** +// * +// * readMap8 internal routine to read the bytes in a 8 bit bitmap +// * +// * +// * +// * Arguments: +// * +// * fs - file stream +// * +// * bh - header struct +// * +// * Returns: +// * +// * Image Object, be sure to check for (Image)null !!!! +// * +// * +// * +// */ +//protectedstaticImage readMap8(FileInputStream fs, BitmapHeader bh) +//throwsIOException +// +// { +// +//Image image; +// +//// Have to determine the number of colors, the clrsused +// +//// parameter is dominant if it is greater than zero. If +// +//// zero, calculate colors based on bitsperpixel. +// +//int nNumColors = 0; +// +//if (bh.nclrused > 0) +// +// { +// +// nNumColors = bh.nclrused; +// +// } +// +//else +// +// { +// +// nNumColors = (1 & 0xff) << bh.nbitcount; +// +// } +// +//// System.out.println("The number of Colors is"+nNumColors); +// +//// Some bitmaps do not have the sizeimage field calculated +// +//// Ferret out these cases and fix em. +// +//if (bh.nsizeimage == 0) +// +// { +// +// bh.nsizeimage = ((((bh.nwidth * bh.nbitcount) + 31) & ~31) >> 3); +// +// bh.nsizeimage *= bh.nheight; +// +//// System.out.println("nsizeimage (backup) is"+nsizeimage); +// +// } +// +//// Read the palatte colors. +// +//int npalette[] = newint[nNumColors]; +// +//byte bpalette[] = newbyte[nNumColors * 4]; +// +// fs.read(bpalette, 0, nNumColors * 4); +// +//int nindex8 = 0; +// +//for (int n = 0; n < nNumColors; n++) +// +// { +// +// npalette[n] = constructInt3(bpalette, nindex8); +// +// nindex8 += 4; +// +// } +// +//// Read the image data (actually indices into the palette) +// +//// Scan lines are still padded out to even 4-byte +// +//// boundaries. +// +//int npad8 = (bh.nsizeimage / bh.nheight) - bh.nwidth; +// +//// System.out.println("nPad is:"+npad8); +// +//int ndata8[] = newint[bh.nwidth * bh.nheight]; +// +//byte bdata[] = newbyte[(bh.nwidth + npad8) * bh.nheight]; +// +// fs.read(bdata, 0, (bh.nwidth + npad8) * bh.nheight); +// +// nindex8 = 0; +// +//for (int j8 = 0; j8 < bh.nheight; j8++) +// +// { +// +//for (int i8 = 0; i8 < bh.nwidth; i8++) +// +// { +// +// ndata8[bh.nwidth * (bh.nheight - j8 - 1) + i8] = +// +// npalette[((int) bdata[nindex8] & 0xff)]; +// +// nindex8++; +// +// } +// +// nindex8 += npad8; +// +// } +// +// image = Toolkit.getDefaultToolkit().createImage +// +// (newMemoryImageSource(bh.nwidth, bh.nheight, +// +// ndata8, 0, bh.nwidth)); +// +//return (image); +// +// } +// +///** +// * +// * load method - see read for details +// * +// * +// * +// * Arguments: +// * +// * sdir and sfile are the result of the FileDialog() +// * +// * getDirectory() and getFile() methods. +// * +// * +// * +// * Returns: +// * +// * Image Object, be sure to check for (Image)null !!!! +// * +// * +// * +// */ +//publicstaticImage load(String sdir, String sfile) { +// +//return (load(sdir + sfile)); +// +// } +// +///** +// * +// * load method - see read for details +// * +// * +// * +// * Arguments: +// * +// * sdir - full path name +// * +// * +// * +// * Returns: +// * +// * Image Object, be sure to check for (Image)null !!!! +// * +// * +// * +// */ +//publicstaticImage load(String sdir) +// +// { +// +//try +// +// { +// +//FileInputStream fs = newFileInputStream(sdir); +// +//return (read(fs)); +// +// } +// +//catch (IOException ex) { +// +//return (null); +// +// } +// +// } +// +//publicstaticvoid main(String[] args) throwsIOException +// +// { +// +//if (args.length == 0) { +// +// System.out.println("Usage >java BMPLoader ImageFile.bmp"); +// +// System.exit(0); +// +// } +// +//FileInputStream in = newFileInputStream(args[0]); +// +//Image TheImage = read(in); +// +//JFrame TheFrame = newJFrame(args[0]); +// +//JLabel TheLabel = newJLabel(newImageIcon(TheImage)); +// +// TheFrame.getContentPane().add(newJScrollPane(TheLabel)); +// +// TheFrame.setSize(300, 300); +// +// TheFrame.setVisible(true); +// +// } +////end class BMPLoader +//} + + +//package BMP; +// +//import java.awt.Image; +//import java.awt.Toolkit; +//import java.awt.Graphics2D; +//import java.awt.image.BufferedImage; +//import java.awt.image.MemoryImageSource; +// +//import java.io.File; +//import java.io.FileInputStream; +//import java.io.FileOutputStream; +// +////import com.sun.image.codec.jpeg.JPEGCodec; +////import com.sun.image.codec.jpeg.JPEGImageEncoder; +// +//public class BmpParse { +// +// private File srcImage; +// private Graphics2D graph; +// +// public BmpParse(String imagefile) { +// srcImage = new File(imagefile); +// } +// +// public BmpParse(File imagefile) { +// srcImage = imagefile; +// } +// +// public boolean Reader(Graphics2D graph) { +// Image image; //target image +// +// if (!srcImage.exists()) +// { +// System.out.println("bmp file is not exist!"); +// return false; +// } +// +// try { +// FileInputStream fs = new FileInputStream(srcImage); +// int bflen = 14; +// byte bf[] = new byte[bflen]; +// fs.read(bf, 0, bflen); //read 14 byte the head of bmp file +// int bilen = 40; +// byte bi[] = new byte[bilen]; +// fs.read(bi, 0, bilen); //read 40 byte the head of bmp info +// +// // /u83B7ȡһЩҪ +// int nwidth = ( ( (int) bi[7] & 0xff) << 24) //width of source file +// | ( ( (int) bi[6] & 0xff) << 16) +// | ( ( (int) bi[5] & 0xff) << 8) +// | (int) bi[4] & 0xff; +// System.out.println("Width:" + nwidth); +// int nheight = ( ( (int) bi[11] & 0xff) << 24) //heigth of source file +// | ( ( (int) bi[10] & 0xff) << 16) +// | ( ( (int) bi[9] & 0xff) << 8) +// | (int) bi[8] & 0xff; +// System.out.println("Heigth:" + nheight); +// //bits of source file +// int nbitcount = ( ( (int) bi[15] & 0xff) << 8) | (int) bi[14] & 0xff; +// System.out.println("Bits Count:" + nbitcount); +// //size of source file +// int nsizeimage = ( ( (int) bi[23] & 0xff) << 24) +// | ( ( (int) bi[22] & 0xff) << 16) +// | ( ( (int) bi[21] & 0xff) << 8) +// | (int) bi[20] & 0xff; +// System.out.println("Size:" + nsizeimage); +// +// //parse the 24 bit bmp file +// if (nbitcount == 24) { +// int npad = (nsizeimage / nheight) - nwidth * 3; +// int ndata[] = new int[nheight * nwidth]; +// byte brgb[] = new byte[ (nwidth + npad) * 3 * nheight]; +// fs.read(brgb, 0, (nwidth + npad) * 3 * nheight); +// int nindex = 0; +// for (int j = 0; j < nheight; j++) { +// for (int i = 0; i < nwidth; i++) { +// ndata[nwidth * (nheight - j - 1) + i] = +// (255 & 0xff) << 24 +// | ( ( (int) brgb[nindex + 2] & 0xff) << 16) +// | ( ( (int) brgb[nindex + 1] & 0xff) << 8) +// | (int) brgb[nindex] & 0xff; +// nindex += 3; +// } +// nindex += npad; +// } +// Toolkit kit = Toolkit.getDefaultToolkit(); +// image = kit.createImage(new MemoryImageSource(nwidth, nheight, +// ndata, 0, nwidth)); +// System.out.println("get image from bmp file"); +// } +// else { +// image = (Image)null; +// System.out.println("not 24 bit bitmap, failed!"); +// return false; +// } +// fs.close(); //close input stream +// +// // start extract image file +// int wideth = image.getWidth(null); +// int height = image.getHeight(null); +// BufferedImage tag = new BufferedImage(wideth, height, +// BufferedImage.TYPE_INT_RGB); +// +///* tag.getGraphics().drawImage(image, 0, 0, wideth / 2, height / 2, null); +// FileOutputStream out = new FileOutputStream("newfile.jpg"); +// JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out); +// encoder.encode(tag); +// out.close(); //close output stream +// */ +// graph.drawImage(image, 0, 0, wideth, height, null); +// } +// catch (Exception e) { +// e.printStackTrace(); +// return false; +// } +// +// return true; +// } +// +// /** +// loadbitmap() method converted from Windows C code. +// Reads only uncompressed 24- and 8-bit images. Tested with +// images saved using Microsoft Paint in Windows 95. If the image +// is not a 24- or 8-bit image, the program refuses to even try. +// I guess one could include 4-bit images by masking the byte +// by first 1100 and then 0011. I am not really +// interested in such images. If a compressed image is attempted, +// the routine will probably fail by generating an IOException. +// Look for variable ncompression to be different from 0 to indicate +// compression is present. +// +// Arguments: +// sdir and sfile are the result of the FileDialog() +// getDirectory() and getFile() methods. +// +// Returns: +// Image Object, be sure to check for (Image)null !!!! */ +// +// public Image loadbitmap(Graphics2D graph) { +// Image image; +// System.out.println("loading:" + srcImage.getName()); +// try { +// FileInputStream fs = new FileInputStream(srcImage); +// int bflen = 14; // 14 byte BITMAPFILEHEADER +// byte bf[] = new byte[bflen]; +// fs.read(bf, 0, bflen); +// int bilen = 40; // 40-byte BITMAPINFOHEADER +// byte bi[] = new byte[bilen]; +// fs.read(bi, 0, bilen); +// +// // Interperet data. +// int nsize = ( ( (int) bf[5] & 0xff) << 24) +// | ( ( (int) bf[4] & 0xff) << 16) +// | ( ( (int) bf[3] & 0xff) << 8) +// | (int) bf[2] & 0xff; +// System.out.println("File type is :" + (char) bf[0] + (char) bf[1]); +// System.out.println("Size of file is :" + nsize); +// +// // Head info data +// int nbisize = ( ( (int) bi[3] & 0xff) << 24) +// | ( ( (int) bi[2] & 0xff) << 16) +// | ( ( (int) bi[1] & 0xff) << 8) +// | (int) bi[0] & 0xff; +// System.out.println("Size of bitmapinfoheader is :" + nbisize); +// +// int nwidth = ( ( (int) bi[7] & 0xff) << 24) +// | ( ( (int) bi[6] & 0xff) << 16) +// | ( ( (int) bi[5] & 0xff) << 8) +// | (int) bi[4] & 0xff; +// System.out.println("Width is :" + nwidth); +// +// int nheight = ( ( (int) bi[11] & 0xff) << 24) +// | ( ( (int) bi[10] & 0xff) << 16) +// | ( ( (int) bi[9] & 0xff) << 8) +// | (int) bi[8] & 0xff; +// System.out.println("Height is :" + nheight); +// +// // number of planes in this bitmap +// int nplanes = ( ( (int) bi[13] & 0xff) << 8) | (int) bi[12] & 0xff; +// System.out.println("Planes is :" + nplanes); +// +// // bits per pixel used to store palette entry +// // information. this also identifies in an indirect way +// // the number of possible colors. possible values are: 1, 4, 8, 16, 24, 32 +// int nbitcount = ( ( (int) bi[15] & 0xff) << 8) | (int) bi[14] & 0xff; +// System.out.println("BitCount is :" + nbitcount); +// +// // Look for non-zero values to indicate compression +// int ncompression = ( ( (int) bi[19]) << 24) +// | ( ( (int) bi[18]) << 16) +// | ( ( (int) bi[17]) << 8) +// | (int) bi[16]; +// System.out.println("Compression is :" + ncompression); +// +// int nsizeimage = ( ( (int) bi[23] & 0xff) << 24) +// | ( ( (int) bi[22] & 0xff) << 16) +// | ( ( (int) bi[21] & 0xff) << 8) +// | (int) bi[20] & 0xff; +// System.out.println("SizeImage is :" + nsizeimage); +// +// int nxpm = ( ( (int) bi[27] & 0xff) << 24) +// | ( ( (int) bi[26] & 0xff) << 16) +// | ( ( (int) bi[25] & 0xff) << 8) +// | (int) bi[24] & 0xff; +// System.out.println("X-Pixels per meter is :" + nxpm); +// +// int nypm = ( ( (int) bi[31] & 0xff) << 24) +// | ( ( (int) bi[30] & 0xff) << 16) +// | ( ( (int) bi[29] & 0xff) << 8) +// | (int) bi[28] & 0xff; +// System.out.println("Y-Pixels per meter is :" + nypm); +// +// int nclrused = ( ( (int) bi[35] & 0xff) << 24) +// | ( ( (int) bi[34] & 0xff) << 16) +// | ( ( (int) bi[33] & 0xff) << 8) +// | (int) bi[32] & 0xff; +// System.out.println("Colors used are :" + nclrused); +// +// int nclrimp = ( ( (int) bi[39] & 0xff) << 24) +// | ( ( (int) bi[38] & 0xff) << 16) +// | ( ( (int) bi[37] & 0xff) << 8) +// | (int) bi[36] & 0xff; +// System.out.println("Colors important are :" + nclrimp); +// +// // Some bitmaps do not have the sizeimage field calculated +// // Ferret out these cases and fix 'em. +// if (nsizeimage == 0) { +// nsizeimage = ( ( ( (nwidth * nbitcount) + 31) & ~31) >> 3); +// nsizeimage *= nheight; +// System.out.println("nsizeimage (backup) is" + nsizeimage); +// } +// +// if (nbitcount == 32) +// { +// // No Palatte data for 32-bit format but scan lines are +// // padded out to even 4-byte boundaries. +// int npad = (nsizeimage / nheight) - nwidth * 4; +// int ndata[] = new int[nheight * nwidth]; +// byte brgb[] = new byte[ (nwidth + npad) * 4 * nheight]; +// fs.read(brgb, 0, (nwidth + npad) * 4 * nheight); +// int nindex = 0; +// for (int j = 0; j < nheight; j++) { +// for (int i = 0; i < nwidth; i++) { +// ndata[nwidth * (nheight - j - 1) + i] = +// (255 & 0xff) << 24 +// | ( ( (int) brgb[nindex + 2] & 0xff) << 16) +// | ( ( (int) brgb[nindex + 1] & 0xff) << 8) +// | (int) brgb[nindex] & 0xff; +///* System.out.println("Encoded Color at (" +// + i + "," + j + ")is:" + brgb + " (R,G,B)= (" +// + ( (int) (brgb[2]) & 0xff) + "," +// + ( (int) brgb[1] & 0xff) + "," +// + ( (int) brgb[0] & 0xff) + ")"); */ +// nindex += 4; +// } +// nindex += npad; +// } +// +// image = Toolkit.getDefaultToolkit().createImage +// (new MemoryImageSource(nwidth, nheight, +// ndata, 0, nwidth)); +// } +// else if (nbitcount == 24) { +// // No Palatte data for 24-bit format but scan lines are +// // padded out to even 4-byte boundaries. +// int npad = (nsizeimage / nheight) - nwidth * 3; +// int ndata[] = new int[nheight * nwidth]; +// byte brgb[] = new byte[ (nwidth + npad) * 3 * nheight]; +// fs.read(brgb, 0, (nwidth + npad) * 3 * nheight); +// int nindex = 0; +// for (int j = 0; j < nheight; j++) { +// for (int i = 0; i < nwidth; i++) { +// ndata[nwidth * (nheight - j - 1) + i] = +// (255 & 0xff) << 24 +// | ( ( (int) brgb[nindex + 2] & 0xff) << 16) +// | ( ( (int) brgb[nindex + 1] & 0xff) << 8) +// | (int) brgb[nindex] & 0xff; +///* System.out.println("Encoded Color at (" +// + i + "," + j + ")is:" + brgb + " (R,G,B)= (" +// + ( (int) (brgb[2]) & 0xff) + "," +// + ( (int) brgb[1] & 0xff) + "," +// + ( (int) brgb[0] & 0xff) + ")");*/ +// nindex += 3; +// } +// nindex += npad; +// } +// +// image = Toolkit.getDefaultToolkit().createImage +// (new MemoryImageSource(nwidth, nheight, +// ndata, 0, nwidth)); +// } +// else if (nbitcount == 16) { +// // No Palatte data for 16-bit format but scan lines are +// // padded out to even 4-byte boundaries. +// int npad = (nsizeimage / nheight) - nwidth * 2; +// int ndata[] = new int[nheight * nwidth]; +// byte brgb[] = new byte[ (nwidth + npad) * 2 * nheight]; +// fs.read(brgb, 0, (nwidth + npad) * 2 * nheight); +// int nindex = 0; +// for (int j = 0; j < nheight; j++) { +// for (int i = 0; i < nwidth; i++) { +// ndata[nwidth * (nheight - j - 1) + i] = +// (255 & 0xff) << 24 +// | ( ( ( ((int)brgb[nindex + 1] >>> 2) & 0x3f) | 0x60)<<3 << 16) +// | ( ( ( (int) (((brgb[nindex + 1]&0x3)<<3) | ((brgb[nindex]&0xe0)>>>5))) | 0x60)<<3 << 8) +// | ( ( ( (int) brgb[nindex] & 0x1f) | 0x60)<<3); +// +// nindex += 2; +// } +// nindex += npad; +// } +// +// image = Toolkit.getDefaultToolkit().createImage +// (new MemoryImageSource(nwidth, nheight, +// ndata, 0, nwidth)); +// } +// else if (nbitcount == 8) { +// // Have to determine the number of colors, the clrsused +// // parameter is dominant if it is greater than zero. If +// // zero1, calculate colors based on bitsperpixel. +// int nNumColors = 0; +// if (nclrused > 0) { +// nNumColors = nclrused; +// } +// else { +// nNumColors = (1 & 0xff) << nbitcount; +// } +// System.out.println("The number of Colors is" + nNumColors); +// +// // Read the palatte colors. +// int npalette[] = new int[nNumColors]; +// byte bpalette[] = new byte[nNumColors * 4]; +// fs.read(bpalette, 0, nNumColors * 4); +// int nindex8 = 0; +// for (int n = 0; n < nNumColors; n++) { +// npalette[n] = (255 & 0xff) << 24 +// | ( ( (int) bpalette[nindex8 + 2] & 0xff) << 16) +// | ( ( (int) bpalette[nindex8 + 1] & 0xff) << 8) +// | (int) bpalette[nindex8] & 0xff; +///* System.out.println("Palette Color " + n +// + " is:" + npalette[n] + " (res,R,G,B)= (" +// + ( (int) (bpalette[nindex8 + 3]) & 0xff) + "," +// + ( (int) (bpalette[nindex8 + 2]) & 0xff) + "," +// + ( (int) bpalette[nindex8 + 1] & 0xff) + "," +// + ( (int) bpalette[nindex8] & 0xff) + ")"); */ +// nindex8 += 4; +// } +// +// // Read the image data (actually indices into the palette) +// // Scan lines are still padded out to even 4-byte +// // boundaries. +// int npad8 = (nsizeimage / nheight) - nwidth; +// System.out.println("nPad is:" + npad8); +// +// int ndata8[] = new int[nwidth * nheight]; +// byte bdata[] = new byte[ (nwidth + npad8) * nheight]; +// fs.read(bdata, 0, (nwidth + npad8) * nheight); +// nindex8 = 0; +// for (int j8 = 0; j8 < nheight; j8++) { +// for (int i8 = 0; i8 < nwidth; i8++) { +// ndata8[nwidth * (nheight - j8 - 1) + i8] = +// npalette[ ( (int) bdata[nindex8] & 0xff)]; +// nindex8++; +// } +// nindex8 += npad8; +// } +// +// image = Toolkit.getDefaultToolkit().createImage +// (new MemoryImageSource(nwidth, nheight, +// ndata8, 0, nwidth)); +// } +// else if (nbitcount == 4) { +// // Have to determine the number of colors, the clrsused +// // parameter is dominant if it is greater than zero. If +// // zero1, calculate colors based on bitsperpixel. +// int nNumColors = 0; +// if (nclrused > 0) { +// nNumColors = nclrused; +// } +// else { +// nNumColors = (1 & 0xff) << nbitcount; +// } +// System.out.println("The number of Colors is" + nNumColors); +// +// // Read the palatte colors. +// int npalette[] = new int[nNumColors]; +// byte bpalette[] = new byte[nNumColors * 4]; +// fs.read(bpalette, 0, nNumColors * 4); +// int nindex4 = 0; +// for (int n = 0; n < nNumColors; n++) { +// npalette[n] = (255 & 0xff) << 24 +// | ( ( (int) bpalette[nindex4 + 2] & 0xff) << 16) +// | ( ( (int) bpalette[nindex4 + 1] & 0xff) << 8) +// | (int) bpalette[nindex4] & 0xff; +// /* System.out.println("Palette Color " + n +// + " is:" + npalette[n] + " (res,R,G,B)= (" +// + ( (int) (bpalette[nindex8 + 3]) & 0xff) + "," +// + ( (int) (bpalette[nindex8 + 2]) & 0xff) + "," +// + ( (int) bpalette[nindex8 + 1] & 0xff) + "," +// + ( (int) bpalette[nindex8] & 0xff) + ")"); */ +// nindex4 += 4; +// } +// +// // Scan line is padded with zeroes to be a multiple of four bytes +// int scanLineSize = ( ( (nwidth * nbitcount) + 31) & ~31) >> 3; +// +// // Read the image data (actually indices into the palette) +// // Scan lines are still padded out to even 4-byte +// // boundaries. +// //int npad4 = (nsizeimage / nheight) - nwidth / 2; +// /*int npad4 = 0; +// if ((nwidth%2) == 0) +// npad4 = scanLineSize - nwidth/2; +// else +// npad4 = scanLineSize - nwidth/2 - 1; +// System.out.println("nPad is:" + npad4);*/ +// +// int ndata4[] = new int[nwidth * nheight]; +// //byte bdata[] = new byte[ scanLineSize * nheight]; +// byte blinedata[] = new byte[scanLineSize]; +// //fs.read(bdata, 0, scanLineSize * nheight); +// nindex4 = 0; +// for (int j4 = 0; j4 < nheight; j4++) { +// fs.read(blinedata, 0, scanLineSize); +// nindex4 = 0; +// +// for (int i4 = 0; i4 < nwidth; i4++) { +// +// if (nwidth * (nheight - j4 - 1) + i4 > nwidth * nheight-1) +// break; +// if (nindex4 > scanLineSize * nheight - 1) +// break; +// +// for (int pixPerByte = 0; pixPerByte < 2; pixPerByte++) +// { +// if (pixPerByte == 0) +// { +// ndata4[nwidth * (nheight - j4 - 1) + i4] = +// npalette[ ( (int) (blinedata[nindex4]>>4) & 0xf)]; +// i4++; +// if (i4 >= nwidth) +// break; +// } +// else +// { +// ndata4[nwidth * (nheight - j4 - 1) + i4] = +// npalette[ ( (int) blinedata[nindex4] & 0xf)]; +// } +// } +// +// nindex4++; +// } +// } +// +// image = Toolkit.getDefaultToolkit().createImage +// (new MemoryImageSource(nwidth, nheight, +// ndata4, 0, nwidth)); +// } +// else if (nbitcount == 1) { +// // Have to determine the number of colors, the clrsused +// // parameter is dominant if it is greater than zero. If +// // zero1, calculate colors based on bitsperpixel. +// int nNumColors = 0; +// if (nclrused > 0) { +// nNumColors = nclrused; +// } +// else { +// nNumColors = (1 & 0xff) << nbitcount; +// } +// System.out.println("The number of Colors is" + nNumColors); +// +// // Read the palatte colors. +// int npalette[] = new int[nNumColors]; +// byte bpalette[] = new byte[nNumColors * 4]; +// fs.read(bpalette, 0, nNumColors * 4); +// int nindex1 = 0; +// for (int n = 0; n < nNumColors; n++) { +// npalette[n] = (255 & 0xff) << 24 +// | ( ( (int) bpalette[nindex1 + 2] & 0xff) << 16) +// | ( ( (int) bpalette[nindex1 + 1] & 0xff) << 8) +// | (int) bpalette[nindex1] & 0xff; +// nindex1 += 4; +// } +// +// // Scan line is padded with zeroes to be a multiple of four bytes +// int scanLineSize = ( ( (nwidth * nbitcount) + 31) & ~31) >> 3; +// +// int ndata1[] = new int[nwidth * nheight]; +// //byte bdata[] = new byte[ scanLineSize * nheight]; +// byte blinedata[] = new byte[scanLineSize]; +// //fs.read(bdata, 0, scanLineSize * nheight); +// nindex1 = 0; +// for (int j1 = 0; j1 < nheight; j1++) { +// fs.read(blinedata, 0, scanLineSize); +// nindex1 = 0; +// +// for (int i1 = 0; i1 < nwidth; i1++) { +// +// if (nwidth * (nheight - j1 - 1) + i1 > nwidth * nheight-1) +// break; +// if (nindex1 > scanLineSize * nheight - 1) +// break; +// +// for (int pixPerByte = 0; pixPerByte < 8; pixPerByte++) +// { +// int shift = 8 - pixPerByte - 1; +// ndata1[nwidth * (nheight - j1 - 1) + i1] = +// npalette[ ( (int) (blinedata[nindex1]>>shift) & 0x1)]; +// if (pixPerByte != 7) +// { +// i1++; +// if (i1 >= nwidth) +// break; +// } +// } +// +// nindex1++; +// } +// } +// +// image = Toolkit.getDefaultToolkit().createImage +// (new MemoryImageSource(nwidth, nheight, +// ndata1, 0, nwidth)); +// } +// else { +// System.out.println("Not a 32-bit, 24-bit, 16-bit, 8-bit, 4-bit and 1-bit Windows Bitmap, aborting..."); +// image = (Image)null; +// } +// +// fs.close(); +// return image; +// } +// catch (Exception e) { +// e.printStackTrace(System.out); +// System.out.println("Caught exception in loadbitmap!"); +// } +// return (Image)null; +// } +//} \ No newline at end of file diff --git a/src/cn/com/ebewin/ysr/dialog/Show_AddTaskStartDialog.java b/src/cn/com/ebewin/ysr/dialog/Show_AddTaskStartDialog.java new file mode 100644 index 0000000..a211610 --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/Show_AddTaskStartDialog.java @@ -0,0 +1,508 @@ +package cn.com.ebewin.ysr.dialog; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.util.List; + +import javax.swing.Action; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.event.PopupMenuEvent; +import javax.swing.event.PopupMenuListener; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.services.rac.core._2011_06.DataManagement.SaveAsOut; +import com.teamcenter.soa.client.model.LovValue; + +import cn.com.ebewin.ysr.util.CommonUtil; +import cn.com.ebewin.ysr.util.FormUtil; + +/** + * @copyRight 㽭տƼ޹˾ + * @author E-mail:hub@connor.net.cn + * @date ʱ䣺2018-6-19 3:13:59 + * @version v1.0 + * @parameter + * @since + * @return + */ + +@SuppressWarnings("serial") +public class Show_AddTaskStartDialog extends AbstractAIFDialog implements Action { + + public static final int O_ADD = 1; + public static final int O_DEL = 2; + public static final int O_EDIT = 3; + private TCSession session; + private AbstractAIFApplication app; + private FormUtil.JTableInfo table; + private String title; + private int OPERATE_CODE; + + private JComboBox subProjectCodeField; + private JTextField tskEquipName; + private JTextField count; + private JComboBox taskDesignType; + private JTextField taskReason; + private FuzzySearchComboBox recommendPlace1; + private FuzzySearchComboBox recommendPlace2; + private FuzzySearchComboBox recommendPlace3; + private JComboBox taskUnitRank; + private JComboBox projectFamiliarity; + private JComboBox manageRank; + private JComboBox choiceUnit; + + private JButton okBtn; + private JButton celBtn; + private JComboBox srcCodeCombo; + private Object choiceUnits = null; + + public Show_AddTaskStartDialog(FormUtil.JTableInfo table, String title, int code, JComboBox subCodeCombo) { + super(true); + this.app = AIFUtility.getCurrentApplication(); + this.session = (TCSession) app.getSession(); + this.table = table; + this.title = title; + this.OPERATE_CODE = code; + this.srcCodeCombo = subCodeCombo; + + } + + public void addTableInfo() { + + Object[] objData = { subProjectCodeField.getSelectedItem(), tskEquipName.getText(), count.getText(), getComBoxKeyByValue(taskDesignType, null), taskReason.getText(), (String)recommendPlace1.getSelectedItem(), + (String)recommendPlace2.getSelectedItem(), (String)recommendPlace3.getSelectedItem(), + + choiceUnit.getSelectedItem(), getComBoxKeyByValue(taskUnitRank, null), getComBoxKeyByValue(projectFamiliarity, null), getComBoxKeyByValue(manageRank, null) }; + if (OPERATE_CODE == O_ADD) { + table.dataTableModel.addRow(objData); + } else { + JTable jt = table.dataTable; + int rowIndex = jt.getSelectedRow(); + table.dataTableModel.removeRow(rowIndex); + table.dataTableModel.insertRow(rowIndex, objData); + } + } + + public void init() { + this.setTitle(this.title); + this.setLayout(new BorderLayout(15, 0)); + this.setPreferredSize(new Dimension(420, 570)); + this.setMinimumSize(new Dimension(400, 570)); + subProjectCodeField = new JComboBox<>(); + int cnt = srcCodeCombo.getItemCount(); + for (int i = 0; i < cnt; i++) { + subProjectCodeField.addItem(srcCodeCombo.getItemAt(i)); + } + subProjectCodeField.setSelectedIndex(srcCodeCombo.getSelectedIndex()); + + tskEquipName = new JTextField(32); + //kk 0724Ӽ ĺͬitem_name + subProjectCodeField.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + Object selectedItem=subProjectCodeField.getSelectedItem(); + if (!e.getItem().equals(selectedItem)||selectedItem==null||"".equals(selectedItem)) { + return; + } + String itemId=selectedItem.toString(); + try { + TCComponentItem item = CommonUtil.getSingleItem(itemId, session); + if(item!=null) { + tskEquipName.setText(item.getStringProperty("object_name")); + } + } catch (Exception e1) { + System.out.println("ѯ"); + e1.printStackTrace(); + } + } + }); + count = new JTextField(32); + taskDesignType = new JComboBox();// YSR8_TaskDesignType_LOV + + TCPreferenceService service = this.session.getPreferenceService(); + String[] values = service.getStringValues("YSR8_ManuFactory"); + System.out.println("values======="+values.length); + System.out.println("values======="+values); + // һµ飬ȱԭ1 + String[] newValues = new String[values.length + 1]; + + // ַ뵽ĵһλ + newValues[0] = ""; + + // ԭԪظƵʣλ + System.arraycopy(values, 0, newValues, 1, values.length); + taskReason = new JTextField(32); + recommendPlace1 = new FuzzySearchComboBox(newValues); + recommendPlace2 = new FuzzySearchComboBox(newValues); + recommendPlace3 = new FuzzySearchComboBox(newValues); + + choiceUnit = new JComboBox();// + + taskUnitRank = new JComboBox();// YSR8_TaskUnitRank_LOV + projectFamiliarity = new JComboBox();// YSR8_ProjectFamiliarity_LOV + + manageRank = new JComboBox();// YSR8_ManageRank_LOV + + choiceUnits = null; + int rowIndex = -1; + switch (OPERATE_CODE) { + case Show_AddTaskStartDialog.O_ADD: + setLovValue(taskDesignType, null, "YSR8_TaskDesignType_LOV"); + setLovValue(taskUnitRank, null, "YSR8_TaskUnitRank_LOV"); + setLovValue(projectFamiliarity, null, "YSR8_ProjectFamiliarity_LOV"); + setLovValue(manageRank, null, "YSR8_ManageRank_LOV"); + break; + case Show_AddTaskStartDialog.O_EDIT: + + JTable jt = table.dataTable; + rowIndex = jt.getSelectedRow(); + Object value1 = table.dataTableModel.getValueAt(rowIndex, 0); + subProjectCodeField.setSelectedItem(value1);//TODO + + Object value2 = table.dataTableModel.getValueAt(rowIndex, 1); + tskEquipName.setText(value2 == null ? "" : value2.toString()); + Object value3 = table.dataTableModel.getValueAt(rowIndex, 2); + count.setText(value3 == null ? "" : value3.toString()); + Object value4 = table.dataTableModel.getValueAt(rowIndex, 3); + setLovValue(taskDesignType, value4 == null ? null : value4.toString(), "YSR8_TaskDesignType_LOV"); + Object value40 = table.dataTableModel.getValueAt(rowIndex, 4); + taskReason.setText(value40 == null ? "" : value40.toString()); + Object value5 = table.dataTableModel.getValueAt(rowIndex, 5); + recommendPlace1.setSelectedItem(value5 == null ? "" : value5.toString()); + Object value6 = table.dataTableModel.getValueAt(rowIndex, 6); + recommendPlace2.setSelectedItem(value6 == null ? "" : value6.toString()); + Object value7 = table.dataTableModel.getValueAt(rowIndex, 7); + recommendPlace3.setSelectedItem(value7 == null ? "" : value7.toString()); + + choiceUnit.addItem(null); + if(value5 != null) + choiceUnit.addItem(value5.toString()); + if(value6 != null) + choiceUnit.addItem(value6.toString()); + if(value7 != null) + choiceUnit.addItem(value7.toString()); + Object value8 = table.dataTableModel.getValueAt(rowIndex, 8); + choiceUnit.setSelectedItem(value8); + choiceUnits = value8; + + Object value9 = table.dataTableModel.getValueAt(rowIndex, 9); + setLovValue(taskUnitRank, value9 == null ? null : value9.toString(), "YSR8_TaskUnitRank_LOV"); + Object value10 = table.dataTableModel.getValueAt(rowIndex, 10); + setLovValue(projectFamiliarity, value10 == null ? null : value10.toString(), "YSR8_ProjectFamiliarity_LOV"); + Object value11 = table.dataTableModel.getValueAt(rowIndex, 11); + setLovValue(manageRank, value11 == null ? null : value11.toString(), "YSR8_ManageRank_LOV"); + + break; + default: + break; + + } + + JPanel centerPanel = new JPanel(new GridBagLayout()); + GridBagConstraints s = new GridBagConstraints(); + s.fill = GridBagConstraints.BOTH; + s.gridwidth = 1; + s.gridheight = 1; + s.weightx = 0; + s.weighty = 0; + s.gridx = 0; + s.gridy = 0; + // init top panel + s.insets = new Insets(15, 5, 0, 5); + + centerPanel.add(new JLabel("Ŀ"), s); + s.gridx++; + s.weightx = 1; + centerPanel.add(subProjectCodeField, s); + s.weightx = 0; + s.gridx = 0; + s.gridy++; + centerPanel.add(new JLabel("ί豸"), s); + s.gridx++; + centerPanel.add(tskEquipName, s); + s.gridx = 0; + s.gridy++; + centerPanel.add(new JLabel(""), s); + s.gridx++; + centerPanel.add(count, s); + s.gridx = 0; + s.gridy++; + centerPanel.add(new JLabel("ί"), s); + s.gridx++; + centerPanel.add(taskDesignType, s); + s.gridx = 0; + s.gridy++; + // kk + s.gridx = 0; + s.gridy++; + centerPanel.add(new JLabel("ίԭ"), s); + s.gridx++; + centerPanel.add(taskReason, s); + s.gridx = 0; + s.gridy++; + + centerPanel.add(new JLabel("Ƽίλ1"), s); + s.gridx++; + centerPanel.add(recommendPlace1, s); + s.gridx = 0; + s.gridy++; + centerPanel.add(new JLabel("Ƽίλ2"), s); + s.gridx++; + centerPanel.add(recommendPlace2, s); + s.gridx = 0; + s.gridy++; + centerPanel.add(new JLabel("Ƽίλ3"), s); + s.gridx++; + centerPanel.add(recommendPlace3, s); + s.gridx = 0; + s.gridy++; + + centerPanel.add(new JLabel("ѡίλ"), s); + s.gridx++; + centerPanel.add(choiceUnit, s); + s.gridx = 0; + s.gridy++; + centerPanel.add(new JLabel("ίλȼ"), s); + s.gridx++; + centerPanel.add(taskUnitRank, s); + s.gridx = 0; + s.gridy++; + centerPanel.add(new JLabel("Ŀ/Ϥ"), s); + s.gridx++; + centerPanel.add(projectFamiliarity, s); + s.gridx = 0; + s.gridy++; + + centerPanel.add(new JLabel("ȼ"), s); + s.gridx++; + centerPanel.add(manageRank, s); + s.gridx = 0; + s.gridy++; + s.weighty = 1; + centerPanel.add(new JLabel(""), s); + + // choiceUnit add contents kk + choiceUnit.addPopupMenuListener(new PopupMenuListener() { + + @Override + public void popupMenuWillBecomeVisible(PopupMenuEvent e) { + initChoiceUnit(choiceUnit); + } + + @Override + public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { +// choiceUnit.setSelectedItem(choiceUnits); + } + + @Override + public void popupMenuCanceled(PopupMenuEvent e) { + + } + }); + + choiceUnit.setEnabled(isUserEiditable()); + System.out.println("choiceUnitS:"+choiceUnit.getSelectedItem()); + + okBtn = new JButton("ȷ"); + okBtn.addActionListener(this); + celBtn = new JButton("ȡ"); + celBtn.addActionListener(this); + JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 25, 7)); + southPanel.add(okBtn); + southPanel.add(celBtn); + this.add(new JLabel(" "), BorderLayout.WEST); + this.add(new JLabel(" "), BorderLayout.EAST); + this.add(new JLabel(" "), BorderLayout.NORTH); + this.add(centerPanel, BorderLayout.CENTER); + this.add(southPanel, BorderLayout.SOUTH); + this.pack(); + this.showDialog(); + } + + protected void initChoiceUnit(JComboBox choiceUnit) { + String text1 = (String)recommendPlace1.getSelectedItem(); + String text2 = (String)recommendPlace2.getSelectedItem(); + String text3 = (String)recommendPlace3.getSelectedItem(); + choiceUnit.removeAllItems(); + choiceUnit.addItem(null); + if (!"".equals(text1)) { + choiceUnit.addItem(text1); + } + if (!"".equals(text2)) { + choiceUnit.addItem(text2); + } + if (!"".equals(text3)) { + choiceUnit.addItem(text3); + } +// System.out.println("choiceUnit2:"+choiceUnits.toString()); + choiceUnit.setSelectedItem(choiceUnits); + + } + + @Override + public void run() { + init(); + } + + @Override + public void actionPerformed(ActionEvent arg0) { + Object source = arg0.getSource(); + if (source.equals(this.okBtn)) { + addTableInfo(); + this.disposeDialog(); + } else { + this.disposeDialog(); + } + } + + @Override + public Object getValue(String arg0) { + return null; + } + + @Override + public void putValue(String arg0, Object arg1) { + + } + + public boolean isUserEiditable() { + boolean can = false; + try { + TCPreferenceService service = this.session.getPreferenceService(); + String[] values = service.getStringValues("YSR_TaskStartMaster_ChoiceUnit"); + if (values == null || values.length < 1) { + return false; + } + String userID = this.session.getUser().getStringProperty("user_name"); + for (String value : values) { + if (value.equals(userID)) { + return true; + } + } + } catch (TCException e) { + e.printStackTrace(); + } + return can; + } + + /** + * תLOV + * + * @param tcsession + * @param s + * @return + */ + public TCComponentListOfValues findLOVByName(TCSession tcsession, String s) { + TCComponentListOfValues tccomponentlistofvalues = null; + try { + TCComponentListOfValuesType tccomponentlistofvaluestype = (TCComponentListOfValuesType) tcsession.getTypeComponent("ListOfValues"); + TCComponentListOfValues atccomponentlistofvalues[] = tccomponentlistofvaluestype.find(s); + if (atccomponentlistofvalues != null && atccomponentlistofvalues.length > 0) + tccomponentlistofvalues = atccomponentlistofvalues[0]; + else + tccomponentlistofvalues = null; + } catch (TCException tcexception) { + tccomponentlistofvalues = null; + } + return tccomponentlistofvalues; + } + + public void setLovValue(JComboBox combox, String value, String lovName) { + // String value = null; + + try { + TCComponentListOfValues lov = findLOVByName(session, lovName); + if (lov != null) { + ListOfValuesInfo lovinfo = lov.getListOfValues(); + List lovValueList = lovinfo.getValues(); + for (LovValue lv : lovValueList) { + LovBean lb = new LovBean(); + lb.value = lv.getDisplayValue(); + lb.key = lv.getValue().toString(); + combox.addItem(lb); + if (value != null && value.equals(lb.value)) { + combox.setSelectedItem(lb); + } + } + } + + } catch (TCException e) { + e.printStackTrace(); + } + + // return value; + } + + /** + * + * @param combox + * @param c + * @return + */ + public String getComBoxKeyByValue(JComboBox combox, String value) { + String key = ""; + if (value == null) { + LovBean lb = (LovBean) combox.getSelectedItem(); + key = lb.getValue(); + return key; + } + int count = combox.getItemCount(); + for (int i = 0; i < count; i++) { + LovBean lb = combox.getItemAt(i); + if (lb.getValue().equals(value)) { + key = lb.getKey(); + break; + } + } + return key; + } + + public class LovBean { + private String key; + private String value; + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + @Override + public String toString() { + return value; + } + + } + +} diff --git a/src/cn/com/ebewin/ysr/dialog/SysCatalogRevisionMasterBean.java b/src/cn/com/ebewin/ysr/dialog/SysCatalogRevisionMasterBean.java new file mode 100644 index 0000000..019711c --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/SysCatalogRevisionMasterBean.java @@ -0,0 +1,133 @@ +package cn.com.ebewin.ysr.dialog; + +public class SysCatalogRevisionMasterBean { + private String ysr8_ID;// + private String ysr8_object;// + private String ysr8_Quantity;// + private String ysr8_Category;// + private String ysr8_Electric;// ǷҪ + private String ysr8_Cost;// ƻɱ + private String ysr8_Cancel;// ȡ + + private String ysr8_Designer;// Ա + private String ysr8_SubProjectType;// + private String ysr8_CustomPartCode;// ûͼ + private String ysr8_PlanWorkTime;// ƻʱ + private String ysr8_qzsj;// ʱ + private String xmh;// Ŀ + + public String getYsr8_Designer() { + return ysr8_Designer; + } + + public void setYsr8_Designer(String ysr8_Designer) { + this.ysr8_Designer = ysr8_Designer; + } + + public String getYsr8_SubProjectType() { + return ysr8_SubProjectType; + } + + public void setYsr8_SubProjectType(String ysr8_SubProjectType) { + this.ysr8_SubProjectType = ysr8_SubProjectType; + } + + public String getYsr8_CustomPartCode() { + return ysr8_CustomPartCode; + } + + public void setYsr8_CustomPartCode(String ysr8_CustomPartCode) { + this.ysr8_CustomPartCode = ysr8_CustomPartCode; + } + + public String getYsr8_PlanWorkTime() { + return ysr8_PlanWorkTime; + } + + public void setYsr8_PlanWorkTime(String ysr8_PlanWorkTime) { + this.ysr8_PlanWorkTime = ysr8_PlanWorkTime; + } + + public String getYsr8_ID() { + return ysr8_ID; + } + + public void setYsr8_ID(String ysr8_ID) { + this.ysr8_ID = ysr8_ID; + } + + public String getYsr8_object() { + return ysr8_object; + } + + public void setYsr8_object(String ysr8_object) { + this.ysr8_object = ysr8_object; + } + + public String getYsr8_Quantity() { + return ysr8_Quantity; + } + + public void setYsr8_Quantity(String ysr8_Quantity) { + this.ysr8_Quantity = ysr8_Quantity; + } + + public String getYsr8_Category() { + return ysr8_Category; + } + + public void setYsr8_Category(String ysr8_Category) { + this.ysr8_Category = ysr8_Category; + } + + public String getYsr8_Electric() { + return ysr8_Electric; + } + + public void setYsr8_Electric(String ysr8_Electric) { + this.ysr8_Electric = ysr8_Electric; + } + + public String getYsr8_Cost() { + return ysr8_Cost; + } + + public void setYsr8_Cost(String ysr8_Cost) { + this.ysr8_Cost = ysr8_Cost; + } + + public String getYsr8_Cancel() { + return ysr8_Cancel; + } + + public void setYsr8_Cancel(String ysr8_Cancel) { + this.ysr8_Cancel = ysr8_Cancel; + } + + public String getYsr8_qzsj() { + return ysr8_qzsj; + } + + public void setYsr8_qzsj(String ysr8_qzsj) { + this.ysr8_qzsj = ysr8_qzsj; + } + + public String getXmh() { + return xmh; + } + + public void setXmh(String xmh) { + this.xmh = xmh; + } + + @Override + public String toString() { + return "SysCatalogRevisionMasterBean{" + "ysr8_ID='" + ysr8_ID + '\'' + ", ysr8_object='" + ysr8_object + '\'' + + ", ysr8_Quantity='" + ysr8_Quantity + '\'' + ", ysr8_Category='" + ysr8_Category + '\'' + + ", ysr8_Electric='" + ysr8_Electric + '\'' + ", ysr8_Cost='" + ysr8_Cost + '\'' + ", ysr8_Cancel='" + + ysr8_Cancel + '\'' + ", ysr8_Designer='" + ysr8_Designer + '\'' + ", ysr8_SubProjectType='" + + ysr8_SubProjectType + '\'' + ", ysr8_CustomPartCode='" + ysr8_CustomPartCode + '\'' + + ", ysr8_PlanWorkTime='" + ysr8_PlanWorkTime + '\'' + ", ysr8_qzsj='" + ysr8_qzsj + '\'' + ", xmh='" + + xmh + '\'' + '}'; + } +} diff --git a/src/cn/com/ebewin/ysr/dialog/TardinessEditDialog.java b/src/cn/com/ebewin/ysr/dialog/TardinessEditDialog.java new file mode 100644 index 0000000..a0c0b62 --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/TardinessEditDialog.java @@ -0,0 +1,266 @@ +package cn.com.ebewin.ysr.dialog; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.Map.Entry; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.om.OMNamespace; +import org.apache.axis2.addressing.EndpointReference; +import org.apache.axis2.client.Options; +import org.apache.axis2.client.ServiceClient; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.ServiceData; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +import com.teamcenter.rac.kernel.TCComponentTask; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.iTextField; +import com.teamcenter.services.rac.core.DataManagementService; +import cn.com.ebewin.ysr.dialog.MachiningDynamicsManageDialog.EditObjectInfo; +import cn.com.ebewin.ysr.util.CommonUtil; +import cn.com.ebewin.ysr.util.DialogUtil; +import cn.com.ebewin.ysr.util.KUtil; +import cn.com.ebewin.ysr.util.TCUtil; + +@SuppressWarnings("deprecation") +public class TardinessEditDialog extends AbstractAIFDialog { + private static final long serialVersionUID = 1L; + private DialogUtil fu; + + private int currTable = 0; + private Boolean isMachiningManager = false; + private Boolean isAllLeading = true; + private EditObjectInfo editObjectInfo = null; + + private Boolean setArrivalState = false; + private boolean isSingleEdit = true; + private MachiningDynamicsManageDialog mdm; + double arrivedNum; + + public TardinessEditDialog(MachiningDynamicsManageDialog mdm, int currTable, Boolean isMachiningManager, + EditObjectInfo editObjectInfo) throws Exception { + super(true); + + if(currTable == 1) { + fu = new DialogUtil(this, "ԭ", "YSR8_TardinessEditDialogUp"); + }else { + fu = new DialogUtil(this, "ԭ", "YSR8_TardinessEditDialog"); + } + this.mdm = mdm; + this.currTable = currTable; + this.editObjectInfo = editObjectInfo; + this.isMachiningManager = isMachiningManager; + if (this.editObjectInfo.editObjects.size() > 1) { + this.isSingleEdit = false; + } + System.out.println("888888888888888888888888888888"); + fu.initializeUI(mdm.fu.session); + centerToScreen(); + loadRendering(); + addActionListener(); + getDefVal(); + setVisible(true); + } + + @SuppressWarnings("unchecked") + private void loadRendering() throws Exception { + System.out.println("99999999999999999999999999999999999999"); + JComboBox ysr8_DelayReason = (JComboBox) fu.allComponentMap.get("ysr8_DelayReason"); + if (currTable == 1) { + System.out.println("޸" + editObjectInfo.editObjects.size()); + for (int i = 0; i < editObjectInfo.editObjects.size(); i++) { + if (editObjectInfo.editObjects.get(i) instanceof TCComponentScheduleTask) { + TCComponentScheduleTask scheduTask = (TCComponentScheduleTask) editObjectInfo.editObjects.get(i); + ysr8_DelayReason.setSelectedItem(scheduTask.getStringProperty("ysr8_DelayReason")); + } + } +// if(editObjectInfo.editObjects.size() > 1){ +// for (int i = 0; i < editObjectInfo.editObjects.size(); i++) { +// if (!editObjectInfo.isLeadings.get(i)) { +// JLabel lable = (JLabel) fu.allComponentMap.get("l.61.11"); +// lable.setText("вΪӹ˵ݣ޷趨ʱ..."); +// ysr8_PurchFinishDate.setEnabled(false); +//// fu.allComponentMap.get("b.51.14").setEnabled(false); +// isAllLeading = false; +// break; +// } +// } +// } + } + + } + + private void addActionListener() { + JButton btn1 = (JButton) fu.allComponentMap.get("b.51.12"); +// JButton btn2 = (JButton) fu.allComponentMap.get("b.51.14"); + JButton btn3 = (JButton) fu.allComponentMap.get("b.51.16"); + btn1.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + saveRendering(); + } + }); + +// btn2.addActionListener(new ActionListener() { +// public void actionPerformed(ActionEvent e) { +// setArrivalState = false; +// saveRendering(); +// } +// }); + + btn3.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + dialogResultId = ID_CANCEL; + disposeDialog(); + } + }); + } + + @SuppressWarnings("unchecked") + private void saveRendering() { + + JComboBox ysr8_DelayReason = (JComboBox) fu.allComponentMap.get("ysr8_DelayReason"); + String text = (String)ysr8_DelayReason.getSelectedItem(); + if(text == null || text.isEmpty()) { + MessageBox.post(this, "дԭ", "", MessageBox.WARNING); + return; + } + JButton btn1 = (JButton) fu.allComponentMap.get("b.51.12"); + JButton btn3 = (JButton) fu.allComponentMap.get("b.51.16"); + btn1.setText("ڱ"); + btn1.setEnabled(false); + btn3.setEnabled(false); + System.out.println("Save"); + + String ysr8_DelayReasonVal = ""; + HashMap tableMap = new HashMap(); + ysr8_DelayReasonVal = text; + + + tableMap.put("ysr8_DelayReason", ysr8_DelayReasonVal); + + + try { + HashMap valMap = new HashMap(); + if (currTable == 1) { + for (int i = 0; i < editObjectInfo.editObjects.size(); i++) { + if (editObjectInfo.editObjects.get(i) instanceof TCComponentScheduleTask) { + TCComponentScheduleTask scheduTask = (TCComponentScheduleTask) editObjectInfo.editObjects.get(i); + System.out.println("ysr8_DelayReasonVal->"+ysr8_DelayReasonVal); + valMap.put("ysr8_DelayReason", ysr8_DelayReasonVal); + + + CommonUtil.setByPass(true); + for (Entry entry : valMap.entrySet()) { + String key1 = entry.getKey(); + String key2 = entry.getValue(); + TCProperty property = (TCProperty) scheduTask.getTCProperty(key1); + switch (property.getPropertyType()) { + case TCProperty.PROP_string: + case TCProperty.PROP_long_string: + scheduTask.setStringProperty(key1, key2); + break; + case TCProperty.PROP_short: + case TCProperty.PROP_int: + scheduTask.setIntProperty(key1, Integer.parseInt(key2)); + break; + case TCProperty.PROP_double: + case TCProperty.PROP_float: + scheduTask.setDoubleProperty(key1, Double.parseDouble(key2)); + break; + case TCProperty.PROP_date: + if (!key2.equals("")) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss"); + Date date = sdf.parse(key2); + if (date != null) { + scheduTask.setDateProperty(key1, date); + } + } + break; + default: + scheduTask.setStringProperty(key1, key2); + break; + } + } + CommonUtil.setByPass(false); + + // kk +// resetScheduleTaskByArrivedNum(scheduTask); + + } + } + + }else if (currTable == 2) { + CommonUtil.setByPass(true); + for (int i = 0; i < editObjectInfo.editObjects.size(); i++) { + Object editObject = editObjectInfo.editObjects.get(i); + if (editObject instanceof TCComponentItem) { + + TCComponentItem item = (TCComponentItem) editObject; + String item_type = item.getStringProperty("object_type"); + System.out.println("item->"+item_type); + if(item_type.equals("YSR8_ECN4")) { + TCComponentItemRevision revision = item.getLatestItemRevision(); + TCComponentForm form = TCUtil.getItemRevisionMasterForm(revision); + // form.setStringProperty("ysr8_Ecn2DelayReason", ysr8_DelayReasonVal); + form.setProperty("ysr8_Ecn4DelayReason", ysr8_DelayReasonVal); + }else { + TCComponentItemRevision revision = item.getLatestItemRevision(); + TCComponentForm form = TCUtil.getItemRevisionMasterForm(revision); + // form.setStringProperty("ysr8_Ecn2DelayReason", ysr8_DelayReasonVal); + form.setProperty("ysr8_Ecn2DelayReason", ysr8_DelayReasonVal); + } + + + } + } + CommonUtil.setByPass(false); + } + dialogResultId = ID_OK; + mdm.updateValues(tableMap); + disposeDialog(); + } catch (Exception e) { + MessageBox.post(TardinessEditDialog.this, e); + e.printStackTrace(); + return; + } + } + + 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()); + } + } + + private void getDefVal() { + fu.getDefVal(); + } +} diff --git a/src/cn/com/ebewin/ysr/dialog/YSR8_DebugingInfoDlg.java b/src/cn/com/ebewin/ysr/dialog/YSR8_DebugingInfoDlg.java new file mode 100644 index 0000000..93840a9 --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/YSR8_DebugingInfoDlg.java @@ -0,0 +1,546 @@ +package cn.com.ebewin.ysr.dialog; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.io.File; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Vector; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JTable; +import javax.swing.JTextArea; + +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.iTextField; + +import cn.com.ebewin.ysr.util.DialogUtil; +import cn.com.ebewin.ysr.util.TCUtil; +import cn.com.ebewin.ysr.util.UIUtil.JComboBoxInfo; +import cn.com.ebewin.ysr.util.UIUtil.JTableInfo; +import jxl.Workbook; +import jxl.format.Alignment; +import jxl.format.Border; +import jxl.format.BorderLineStyle; +import jxl.format.VerticalAlignment; +import jxl.write.Label; +import jxl.write.WritableCellFormat; +import jxl.write.WritableFont; +import jxl.write.WritableSheet; +import jxl.write.WritableWorkbook; +import jxl.write.WriteException; + +@SuppressWarnings({"unchecked","deprecation"}) +public class YSR8_DebugingInfoDlg extends JFrame { + private static final long serialVersionUID = 1L; + DialogUtil fu = new DialogUtil(this, "ĿϢͳƱ", "YSR8_DebugingInfoDlg"); + Vector WorkingHourRevisions = new Vector(); + + LinkedHashMap lovysr8_TravelType; + LinkedHashMap lovysr8_WorkPlace; + LinkedHashMap lovysr8_DebugPhase; + LinkedHashMap lovysr8_Dept; + + public YSR8_DebugingInfoDlg(TCSession session) throws TCException { + //super(true); + + lovysr8_TravelType = TCUtil.getlovValues(session, "ysr8_TravelORDEN_LOV1"); + lovysr8_WorkPlace = TCUtil.getlovValues(session, "YSR8_WH02_LOV"); + lovysr8_DebugPhase = TCUtil.getlovValues(session, "YSR8_WH03_LOV"); + lovysr8_Dept = TCUtil.getlovValues(session, "YSR8_WH01_LOV"); + + fu.initializeUI(session); + //TODO centerToScreen(); + this.setLocationRelativeTo(null); + this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); + + loadRendering(); + addActionListener(); + setVisible(true); + } + + private void loadRendering() throws TCException { + } + + private void addActionListener() { + JButton btn = (JButton)fu.allComponentMap.get("b.11.12.12"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + searchYSR8_DebugingInfo(); + } + }); + + btn = (JButton)fu.allComponentMap.get("b.11.12.13"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + outputYSR8_DebugingInfo(); + } + }); + + btn = (JButton)fu.allComponentMap.get("b.11.12.14"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + viewYSR8_PRPic(); + } + }); + ////////////////////////////////////////////////////// + { + JTable table = (JTable)fu.allComponentMap.get("a.31.11.11"); + table.addMouseListener(new java.awt.event.MouseAdapter(){ + public void mouseClicked(MouseEvent e) {//굥ʱӦ + System.out.println("mouseClicked------------------------------- " ); + ViewSelDebugInfo(); + } + }); + + } + + } + + private void searchYSR8_DebugingInfo() { + WorkingHourRevisions.clear(); + JTableInfo ci = (JTableInfo)fu.allComponentInfos.get("a.31.11.11"); + int nRowCount = ci.dataTableModel.getRowCount(); + for(int i=nRowCount-1; i>=0; i--){ + ci.dataTableModel.removeRow(i); + } + ci.dataTableModel.getDataVector().clear(); + + { + iTextField textField = (iTextField)fu.allComponentMap.get("ysr8_ProjectManager"); + textField.setText(""); + + textField = (iTextField)fu.allComponentMap.get("ysr8_Planner"); + textField.setText(""); + + textField = (iTextField)fu.allComponentMap.get("ysr8_DesignDirector"); + textField.setText(""); + + textField = (iTextField)fu.allComponentMap.get("ysr8_ElectricDirector"); + textField.setText(""); + + textField = (iTextField)fu.allComponentMap.get("ysr8_EngineerDebug"); + textField.setText(""); + + textField = (iTextField)fu.allComponentMap.get("ysr8_Machiner"); + textField.setText(""); + + JTextArea textArea = (JTextArea)fu.allComponentMap.get("ysr8_WorkContent1"); + textArea.setText(""); + textArea = (JTextArea)fu.allComponentMap.get("ysr8_WorkContent"); + textArea.setText(""); + } + + iTextField textField = (iTextField)fu.allComponentMap.get("ysr8_ProjectCode"); + String ysr8_ProjectCodeVal = textField.getText().toString(); + + textField = (iTextField)fu.allComponentMap.get("ysr8_Applicant"); + String ysr8_ApplicantVal = textField.getText().toString(); + + textField = (iTextField)fu.allComponentMap.get("ysr8_Operators"); + String ysr8_OperatorsVal = textField.getText().toString(); + + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_DeptCondition"); + JComboBoxInfo cii = (JComboBoxInfo)fu.allComponentInfos.get("ysr8_DeptCondition"); + String ysr8_DeptConditionVal = cbx.getSelectedItem().toString(); + if (cii.lovVal != null) { + Iterator iter = cii.lovVal.keySet().iterator(); + while (iter.hasNext()) { + String lovKey = iter.next(); + String lovValue = cii.lovVal.get(lovKey); + if (lovValue.equalsIgnoreCase(ysr8_DeptConditionVal)) { + ysr8_DeptConditionVal = lovKey; + break; + } + } + } + + DateButton db = (DateButton)fu.allComponentMap.get("ysr8_DeclarationDate1"); + Date date = db.getDate(); + String ysr8_DeclarationDate1Val = ""; + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + if (date != null) { + ysr8_DeclarationDate1Val = sdf.format(date); + } + + cbx = (JComboBox)fu.allComponentMap.get("ysr8_Province"); + cii = (JComboBoxInfo)fu.allComponentInfos.get("ysr8_Province"); + String ysr8_ProvinceVal = cbx.getSelectedItem().toString(); + if (cii.lovVal != null) { + Iterator iter = cii.lovVal.keySet().iterator(); + while (iter.hasNext()) { + String lovKey = iter.next(); + String lovValue = cii.lovVal.get(lovKey); + if (lovValue.equalsIgnoreCase(ysr8_ProvinceVal)) { + ysr8_ProvinceVal = lovKey; + break; + } + } + } + + textField = (iTextField)fu.allComponentMap.get("ysr8_City"); + String ysr8_CityVal = textField.getText().toString(); + + cbx = (JComboBox)fu.allComponentMap.get("c_ysr8_TravelType"); + cii = (JComboBoxInfo)fu.allComponentInfos.get("c_ysr8_TravelType"); + String ysr8_TravelTypeVal = cbx.getSelectedItem().toString(); + if (cii.lovVal != null) { + Iterator iter = cii.lovVal.keySet().iterator(); + while (iter.hasNext()) { + String lovKey = iter.next(); + String lovValue = cii.lovVal.get(lovKey); + if (lovValue.equalsIgnoreCase(ysr8_TravelTypeVal)) { + ysr8_TravelTypeVal = lovKey; + break; + } + } + } + + cbx = (JComboBox)fu.allComponentMap.get("ysr8_Section"); + cii = (JComboBoxInfo)fu.allComponentInfos.get("ysr8_Section"); + String ysr8_SectionVal = cbx.getSelectedItem().toString(); + if (cii.lovVal != null) { + Iterator iter = cii.lovVal.keySet().iterator(); + while (iter.hasNext()) { + String lovKey = iter.next(); + String lovValue = cii.lovVal.get(lovKey); + if (lovValue.equalsIgnoreCase(ysr8_SectionVal)) { + ysr8_SectionVal = lovKey; + break; + } + } + } + + db = (DateButton)fu.allComponentMap.get("ysr8_DeclarationDate2"); + date = db.getDate(); + String ysr8_DeclarationDate2Val = ""; + if (date != null) { + ysr8_DeclarationDate2Val = sdf.format(date); + } + +System.out.println("ysr8_ProjectCode-----" + ysr8_ProjectCodeVal); + + String sql = "SELECT X_ITEM_PUID, X_ITEMREV_PUID, X_ITEM_ID, X_REVISION_ID, X_SEQUENCE_ID, YSR8_DECLARATIONDATE, YSR8_TRAVELORDCODE, " + + "YSR8_WORKPLACE, YSR8_DEBUGPHASE, YSR8_DEPT, YSR8_TOTALHOURS, YSR8_WORKDAYHOURS, YSR8_OVERTIMEHOURS, YSR8_HOVERTIMEHOURS, " + + "YSR8_DHOURS, YSR8_JHOURS, YSR8_MHOURS, YSR8_CHOURS, YSR8_THOURS, YSR8_RHOURS, YSR8_OPERATORS, YSR8_OPERATORSNUM, " + + "YSR8_APPLICANT, YSR8_REMARK, YSR8_PROJECTCODE, Y_ITEM_PUID, Y_ITEMREV_PUID, Y_ITEM_ID, Y_REVISION_ID, Y_SEQUENCE_ID, " + + "Y_YSR8_PROJECTCODE, YSR8_SECTION, Z_ITEM_PUID, Z_ITEMREV_PUID, Z_ITEM_ID, Z_REVISION_ID, Z_SEQUENCE_ID, YSR8_PROVINCE, " + + "YSR8_CITY, YSR8_TRAVELTYPE FROM VL30N_WH_PS_TORD"; + String where = ""; + if (!ysr8_ProjectCodeVal.equals("")) { + if (where.equals("")) { + where = " WHERE (YSR8_PROJECTCODE LIKE '%" + ysr8_ProjectCodeVal + "%')"; + } else { + where += " AND (YSR8_PROJECTCODE LIKE '%" + ysr8_ProjectCodeVal + "%')"; + } + } + + if (!ysr8_ApplicantVal.equals("")) { + if (where.equals("")) { + where = " WHERE (YSR8_APPLICANT LIKE '%" + ysr8_ApplicantVal + "%')"; + } else { + where += " AND (YSR8_APPLICANT LIKE '%" + ysr8_ApplicantVal + "%')"; + } + } + + if (!ysr8_OperatorsVal.equals("")) { + if (where.equals("")) { + where = " WHERE (YSR8_OPERATORS LIKE '%" + ysr8_OperatorsVal + "%')"; + } else { + where += " AND (YSR8_OPERATORS LIKE '%" + ysr8_OperatorsVal + "%')"; + } + } + + if (!ysr8_DeptConditionVal.equals("")) { + if (where.equals("")) { + where = " WHERE (YSR8_DEPT = '" + ysr8_DeptConditionVal + "')"; + } else { + where += " AND (YSR8_DEPT = '" + ysr8_DeptConditionVal + "')"; + } + } + + if (!ysr8_DeclarationDate1Val.equals("")) { + if (where.equals("")) { + where = " WHERE (YSR8_DECLARATIONDATE <= '" + ysr8_DeclarationDate1Val + "')"; + } else { + where += " AND (YSR8_DECLARATIONDATE <= '" + ysr8_DeclarationDate1Val + "')"; + } + } + + if (!ysr8_ProvinceVal.equals("")) { + if (where.equals("")) { + where = " WHERE (YSR8_PROVINCE = '" + ysr8_ProvinceVal + "')"; + } else { + where += " AND (YSR8_PROVINCE = '" + ysr8_ProvinceVal + "')"; + } + } + + if (!ysr8_CityVal.equals("")) { + if (where.equals("")) { + where = " WHERE (YSR8_CITY LIKE '%" + ysr8_CityVal + "%')"; + } else { + where += " AND (YSR8_CITY LIKE '%" + ysr8_CityVal + "%')"; + } + } + + if (!ysr8_TravelTypeVal.equals("")) { + if (where.equals("")) { + where = " WHERE (YSR8_TRAVELTYPE = '" + ysr8_TravelTypeVal + "')"; + } else { + where += " AND (YSR8_TRAVELTYPE = '" + ysr8_TravelTypeVal + "')"; + } + } + + if (!ysr8_SectionVal.equals("")) { + if (where.equals("")) { + where = " WHERE (YSR8_SECTION = '" + ysr8_SectionVal + "')"; + } else { + where += " AND (YSR8_SECTION = '" + ysr8_SectionVal + "')"; + } + } + + if (!ysr8_DeclarationDate2Val.equals("")) { + if (where.equals("")) { + where = " WHERE (YSR8_DECLARATIONDATE >= '" + ysr8_DeclarationDate2Val + "')"; + } else { + where += " AND (YSR8_DECLARATIONDATE >= '" + ysr8_DeclarationDate2Val + "')"; + } + } + sql += where; +System.out.println("sql-----" + sql); + Vector> datavec = TCUtil.getDBInfo3(fu.session, sql); + if (datavec == null) { + return; + } + Integer idx = 0; + //SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd"); + try { + for (Iterator> iterator = datavec.iterator(); iterator.hasNext();) { + Hashtable hashtable = (Hashtable) iterator.next(); + + Vector vec = new Vector<>(); + vec.add((++idx) + "");// + vec.add(hashtable.get("YSR8_DECLARATIONDATE").toString());//걨 + vec.add(hashtable.get("YSR8_TRAVELORDCODE").toString());//ίе + vec.add(lovysr8_TravelType.get(hashtable.get("YSR8_TRAVELTYPE").toString()));// + vec.add(lovysr8_WorkPlace.get(hashtable.get("YSR8_WORKPLACE").toString()));//ص + vec.add(lovysr8_DebugPhase.get(hashtable.get("YSR8_DEBUGPHASE").toString()));//Խ׶ + vec.add(lovysr8_Dept.get(hashtable.get("YSR8_DEPT").toString()));// + vec.add(hashtable.get("YSR8_TOTALHOURS").toString());//ʵʹʱ + vec.add(hashtable.get("YSR8_WORKDAYHOURS").toString());//չʱ + vec.add(hashtable.get("YSR8_OVERTIMEHOURS").toString());//ƽʱӰ๤ʱ + vec.add(hashtable.get("YSR8_HOVERTIMEHOURS").toString());//ڼռӰ๤ʱ + + vec.add(hashtable.get("YSR8_DHOURS").toString());//ʱ + vec.add(hashtable.get("YSR8_JHOURS").toString());//ʱе + vec.add(hashtable.get("YSR8_MHOURS").toString());//ʱӹ + vec.add(hashtable.get("YSR8_CHOURS").toString());//ʱͻ + vec.add(hashtable.get("YSR8_THOURS").toString());//ʱԣ + vec.add(hashtable.get("YSR8_RHOURS").toString());//ʱࣩ + + vec.add(hashtable.get("YSR8_OPERATORS").toString());//ҵԱ + vec.add(hashtable.get("YSR8_OPERATORSNUM").toString());//ҵ + vec.add(hashtable.get("YSR8_APPLICANT").toString());//걨 + vec.add(hashtable.get("YSR8_REMARK").toString());//ע + vec.add(hashtable.get("YSR8_PROJECTCODE").toString());//Ŀ + + ci.dataTableModel.addRow(vec); + + TCComponentItem item = TCUtil.findItemByID(fu.session, hashtable.get("X_ITEM_ID").toString()); + if (item == null) { + System.out.println("ûҵʱձItem...---" + hashtable.get("X_ITEM_ID").toString()); + return; + } + TCComponentItemRevision revision = TCUtil.getItemRevisionFromItem(item, hashtable.get("X_REVISION_ID").toString()); + if (revision == null) { + System.out.println("ûҵʱձItemRevision...---" + hashtable.get("X_ITEM_ID").toString() + "----" + hashtable.get("X_REVISION_ID").toString()); + return; + } + WorkingHourRevisions.add(revision); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private void outputYSR8_DebugingInfo() { + final JTable table = (JTable)fu.allComponentMap.get("a.31.11.11"); + final JButton btn = (JButton)fu.allComponentMap.get("b.11.12.13"); + btn.setEnabled(false); + final ProgressReporterDialog reporter = new ProgressReporterDialog(); + reporter.reportProgressMessage("ڵ,Ժ..."); + new Thread(reporter).start(); + new Thread() { + public void run() { + try { + Date date = new Date(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + String time = sdf.format(date); + String toPath = System.getProperty("java.io.tmpdir") + "ĿϢͳƱ" + time + ".xls"; + // һдWorkbook + WritableWorkbook writeWorkBook = Workbook.createWorkbook(new File(toPath)); + // + WritableSheet wsheet = writeWorkBook.createSheet("ĿϢͳƱ", 0); + + //д + int columnCount = table.getColumnCount(); // + int rowCount = table.getRowCount(); // + String[] titles = new String[columnCount]; // ͷ + + // ȡͷ + for (int i = 0; i < columnCount; i++) { + titles[i] = table.getColumnName(i); + } + + int current_row = 0; // ʼǰΪʼ + + try { + // ʽ + WritableFont titleFont = new WritableFont(WritableFont.createFont(""), 13,WritableFont.BOLD); + WritableCellFormat titleCellFormat = new WritableCellFormat(titleFont); + titleCellFormat.setBorder(Border.ALL, BorderLineStyle.MEDIUM); + titleCellFormat.setAlignment(Alignment.CENTRE); + titleCellFormat.setVerticalAlignment(VerticalAlignment.CENTRE); + titleCellFormat.setWrap(true); + + // ʽ + WritableFont contentFont = new WritableFont(WritableFont.createFont(""), 12); + WritableCellFormat contentCellFormat = new WritableCellFormat(contentFont); + contentCellFormat.setBorder(Border.ALL, BorderLineStyle.THIN); + contentCellFormat.setAlignment(Alignment.CENTRE); + contentCellFormat.setVerticalAlignment(VerticalAlignment.CENTRE); + contentCellFormat.setWrap(true); + + // дб + for (int i = 0; i < columnCount; i++) { + Label labelTitle = new Label(i, current_row, titles[i], titleCellFormat); + wsheet.addCell(labelTitle); + } + + current_row = current_row + 1; + // д + for (int i = 0; i < rowCount; i++) { + for (int j = 0; j < columnCount; j++) { + Object objValue = table.getValueAt(i, j); + Label labelContent = new Label(j, i + current_row, String.valueOf(objValue), contentCellFormat); + wsheet.addCell(labelContent); + } + } + + // øʽ + wsheet.getSettings().setDefaultColumnWidth(20); + writeWorkBook.write(); + writeWorkBook.close(); + } catch (WriteException e) { + e.printStackTrace(); + } + + // 򿪵ıļ + Runtime.getRuntime().exec("cmd /c \"" + toPath + "\""); + + } catch (IOException e) { + e.printStackTrace(); + } + reporter.requestCanceling(); + btn.setEnabled(true); + } + }.start(); + } + + private void viewYSR8_PRPic() { + JTable table = (JTable)fu.allComponentMap.get("a.31.11.11"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪ鿴ͼƬУ", "ʾ", MessageBox.INFORMATION); + return; + } + + ShowPicFrame spf = new ShowPicFrame(this, true); +System.out.println("rows[0]-----------------" + rows[0]); +System.out.println("prRevisions.size()-----------------" + WorkingHourRevisions.size()); + spf.init(fu.session, WorkingHourRevisions.get(rows[0])); + spf.setModal(true); + } + + private void ViewSelDebugInfo(){ + JTable table = (JTable)fu.allComponentMap.get("a.31.11.11"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + return; + } + try { + TCComponentItemRevision workingHourRevision = WorkingHourRevisions.get(rows[0]); + TCComponentForm workingHourRevisionForm = TCUtil.getItemRevisionMasterForm(workingHourRevision); + JTextArea textArea = (JTextArea)fu.allComponentMap.get("ysr8_WorkContent1"); + textArea.setText(workingHourRevisionForm.getProperty("ysr8_WorkContent1")); + textArea = (JTextArea)fu.allComponentMap.get("ysr8_WorkContent"); + textArea.setText(workingHourRevisionForm.getProperty("ysr8_WorkContent")); + + SetDebugPlanInfo(workingHourRevisionForm.getProperty("ysr8_ProjectCode")); + + }catch (TCException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } + + } + + private void SetDebugPlanInfo(String ysr8_ProjectCode){ + + try { + //ݱŻȡĶӦı + TCComponentItem tsghItem = TCUtil.findItemByID(fu.session, ysr8_ProjectCode + "-TSGH"); + if (tsghItem == null) { + return; + } + + TCComponentItemRevision tsghRevision = tsghItem.getLatestItemRevision(); + TCComponentForm tsghForm = TCUtil.getItemRevisionMasterForm(tsghRevision); + + iTextField textField = (iTextField)fu.allComponentMap.get("ysr8_ProjectManager"); + textField.setText(tsghForm.getProperty("ysr8_ProjectManager")); + + textField = (iTextField)fu.allComponentMap.get("ysr8_Planner"); + textField.setText(tsghForm.getProperty("ysr8_Planner")); + + textField = (iTextField)fu.allComponentMap.get("ysr8_DesignDirector"); + textField.setText(tsghForm.getProperty("ysr8_DesignDirector")); + + textField = (iTextField)fu.allComponentMap.get("ysr8_ElectricDirector"); + textField.setText(tsghForm.getProperty("ysr8_ElectricDirector")); + + textField = (iTextField)fu.allComponentMap.get("ysr8_EngineerDebug"); + textField.setText(tsghForm.getProperty("ysr8_EngineerDebug")); + + textField = (iTextField)fu.allComponentMap.get("ysr8_Machiner"); + textField.setText(tsghForm.getProperty("ysr8_Machiner")); + + DateButton db = (DateButton)fu.allComponentMap.get("ysr8_DebugStartT"); + db.setText(tsghForm.getProperty("ysr8_DebugStartT")); + + db = (DateButton)fu.allComponentMap.get("ysr8_DebugFinishT"); + db.setText(tsghForm.getProperty("ysr8_DebugFinishT")); + + }catch (TCException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } + } + +} diff --git a/src/cn/com/ebewin/ysr/dialog/YSR8_DrawingListCreateDialog.java b/src/cn/com/ebewin/ysr/dialog/YSR8_DrawingListCreateDialog.java new file mode 100644 index 0000000..56d0184 --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/YSR8_DrawingListCreateDialog.java @@ -0,0 +1,1309 @@ +package cn.com.ebewin.ysr.dialog; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.Vector; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +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.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentPseudoFolder; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCFormProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.iTextField; + +import cn.com.ebewin.ysr.util.CommonUtil; +import cn.com.ebewin.ysr.util.CreateDialogUtil; +import cn.com.ebewin.ysr.util.FormUtil; +import cn.com.ebewin.ysr.util.TCUtil; +import cn.com.ebewin.ysr.util.UIUtil.JComboBoxInfo; +@SuppressWarnings({"unchecked"}) +public class YSR8_DrawingListCreateDialog extends AbstractAIFDialog { + private static final long serialVersionUID = 1L; + private CreateDialogUtil fu = new CreateDialogUtil(this, "ͼĿ¼", "YSR8_DrawingListRevisionMasterDialog", "YSR8_DrawingList"); + private TCComponentBOMLine currentLine = null; + private TCComponentBOMLine preLine = null; + private static String Assembly = ""; + private TCComponentItem partItem = null; + private TCComponentItemRevision partItemRevision = null; + private String createItem_ID = ""; + private int selectType = 0; + private int selectTypeTemplate = 0; + private String excelPath = ""; + private Vector> dataVector = null; + private Map totalQuantityMap = new LinkedHashMap(); + + private Boolean isRewrite = false; + private TCComponentItem oldDLItem = null; + private Vector lineVector = new Vector(); + private int drawQuantity = 0; + private Set SDset = new HashSet(); + private Map> lineMap1 = null; + private Map preComps = null; + private Map currentComps = null; + + private double sumPartNum = 0.0; + private double sumCylindersNum = 0.0; + private String[] YSR8_DingZhiJian; + private Set DZJset = new LinkedHashSet(); + private FileWriter fos; + private SimpleDateFormat sdf; + private boolean dzjtq = false; + + public YSR8_DrawingListCreateDialog(TCSession session, TCComponentBOMLine bomline, TCComponentItemRevision partItemRevision) throws TCException { + super(true); + try { + String out = System.getProperty("java.io.tmpdir")+"\\ͼĿ¼־.txt"; + sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + File htmlfile = new File(out); + if(htmlfile.exists()) + htmlfile.delete(); + htmlfile.createNewFile(); + fos = new FileWriter(htmlfile); + }catch(Exception e) { + e.printStackTrace(); + } + System.out.println("YSR8_DrawingListCreateDialog"); + + this.currentLine = bomline; + this.partItemRevision = partItemRevision; + partItem = partItemRevision.getItem(); + YSR8_DingZhiJian = session.getPreferenceService().getStringValues("YSR8_DingZhiJian"); + TCComponentForm subform = TCUtil.getItemRevisionMasterForm(currentLine.getItemRevision()); + for(String s : YSR8_DingZhiJian) { + String[] ss = s.split("="); + logger(ss[0]+"=="+ss[1]+">>"+subform.getProperty(ss[0])); + if(subform.getProperty(ss[0]).equals(ss[1])) { + dzjtq = true;//TODO + break; + } + } + + fu.initializeUI(session); + centerToScreen(); + loadRendering(); + addActionListener(); + getDefVal(); + // +// JLabel label = (JLabel)fu.allComponentMap.get("l.091.17"); +// label.setVisible(false); +// iTextField ysr8_SDParts = (iTextField)fu.allComponentMap.get("ysr8_SDParts"); +// ysr8_SDParts.setVisible(false); + setVisible(true); + } + + private void loadRendering() throws TCException { + } + + private void addActionListener() { + JButton btn = (JButton)fu.allComponentMap.get("b.011.15"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + outputExcel(); + } + }); + + btn = (JButton)fu.allComponentMap.get("b.011.17"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + saveRendering(); + } + }); + + btn = (JButton)fu.allComponentMap.get("b.011.18"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + + { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_Use"); + cbx.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent itemevent) { + if (itemevent.getStateChange() == ItemEvent.SELECTED) { + ChangeComboBoxState_ysr8_Use(); + } + } + }); + } + } + + private void saveRendering() { + if (!checkCanSave()) { + return; + } + + File tempFile = null; + if (selectTypeTemplate == 1) { + tempFile = TCUtil.findTemplete(fu.session, "YSR8_DrawingListTemplete0", "ͼĿ¼"); + } else if (selectTypeTemplate == 2) { + tempFile = TCUtil.findTemplete(fu.session, "YSR8_DrawingListTemplete1", "ͼĿ¼"); + } + if (tempFile != null) { + excelPath = tempFile.getPath(); + writeToExcel(tempFile); + } + if (excelPath.equals("")) { + MessageBox.post(AIFUtility.getActiveDesktop(), "BOMȡʧܣ޷б棬...", "ʾ", MessageBox.WARNING); + return; + } + + try { + System.out.printf("isRewrite============" + isRewrite); + if (!isRewrite) { + fu.createItem(createItem_ID, "ͼĿ¼"); + partItemRevision.add("YSR8_FixtureDocument", new TCComponent[] { fu.newItem }); + fu.newForm.setProperty("ysr8_AssemNo", partItem.getProperty("item_id")); + //kk don't put dataset + /*if (!excelPath.equals("")) { + tempFile = new File(excelPath); + TCComponentDataset newDataset = TCUtil.createDataset(fu.session, tempFile, tempFile.getName()); + fu.newRevision.add("IMAN_specification", new TCComponent[] { newDataset }); + }*/ + } else { + TCComponentItemRevision oldDLRevision = oldDLItem.getLatestItemRevision(); + TCComponentForm oldDLForm = TCUtil.getItemRevisionMasterForm(oldDLRevision); + fu.formProperties = oldDLForm.getAllFormProperties(); + Vector formPropertys = fu.GetPropertiesValue(); + + TCComponentPseudoFolder folder = TCUtil.getRevisionPseudoFolder(oldDLRevision, "׷ӡ滻ͼֽ"); + AIFComponentContext[] context3 = folder.getChildren("YSR8_AddOrReplace"); + for(int i=0;i 0) { + TCComponentDataset dataset = null; + for (int i = 0; i < components.length; i++) { + dataset = (TCComponentDataset) components[i]; + String name = dataset.getProperty("object_name"); + if (name.equals(tempFile.getName())) { + TCUtil.updateFile(dataset, tempFile); + break; + } + } + } + } + } + +// if (!excelPath.equals("")) { +// File tempFile = new File(excelPath); +// TCComponentDataset newDataset = TCUtil.createDataset(fu.session, tempFile, tempFile.getName()); +// if (!isRewrite) { +// fu.newRevision.add("IMAN_specification", new TCComponent[] { newDataset }); +// } else { +// TCComponentItemRevision oldDLRevision = oldDLItem.getLatestItemRevision(); +// oldDLRevision.add("IMAN_specification", new TCComponent[] { newDataset }); +// } +// } + +// boolean find = false; +// TCComponentPseudoFolder folder = TCUtil.getRevisionPseudoFolder(partItemRevision, "оĵ"); +// if (folder != null) { +// AIFComponentContext[] context3 = folder.getChildren("YSR8_FixtureDocument"); +// if (context3 != null && context3.length > 0) { +// find = true; +// } +// } +// if (!find) { +// partItemRevision.add("YSR8_FixtureDocument", new TCComponent[] { fu.newItem }); +// } + + if (selectType == 2) { + Integer vecSize = dataVector.size(); + Map add = new HashMap<>(); + for (int i = 0; i < vecSize; i++) { + Map map = dataVector.get(i); +// String tydh = map.get("ͼ"); +// System.out.println(map.keySet()); +// if(map.get("仯").equals("׷")) +// if(!map.get("").equals("0")) + if(!map.get("").equals("")) + add.put(map.get("ͼ"), map.get("汾")); + } + for (String tydh : add.keySet()) { + if (!(tydh.startsWith("WG"))) { + TCComponentItem item = TCUtil.findItemByID(fu.session, tydh); + if (item != null) { + String bb = add.get(tydh); + TCComponentItemRevision itemRevision = TCUtil.getItemRevisionFromItem(item, bb); + if (itemRevision != null) { + if (!isRewrite) { + fu.newRevision.add("YSR8_AddOrReplace", new TCComponent[] { itemRevision }); + } else { + TCComponentItemRevision oldDLRevision = oldDLItem.getLatestItemRevision(); + oldDLRevision.add("YSR8_AddOrReplace", new TCComponent[] { itemRevision }); +// +// boolean find = false; +// TCComponentPseudoFolder folder = TCUtil.getRevisionPseudoFolder(oldDLRevision, "׷ӡ滻ͼֽ"); +// if (folder != null) { +// AIFComponentContext[] context3 = folder.getChildren("YSR8_AddOrReplace"); +// if (context3 != null && context3.length > 0) { +// find = true; +// } +// } +// if (!find) { +// oldDLRevision.add("YSR8_AddOrReplace", new TCComponent[] { itemRevision }); +// } + } + } + } + } + } + } + if(dzjtq) { + String[] vals = new String[DZJset.size()];//TODO + Object[] os = DZJset.toArray(); + for(int i=0; i cbx = (JComboBox)fu.allComponentMap.get("ysr8_Classfication"); + cbx.setSelectedIndex(1); + String item_idVal = partItem.getProperty("item_id"); + System.out.printf("item_idVal + _TM============" + item_idVal + "_TM"); + createItem_ID = item_idVal + "_TM" + TCUtil.getSerialNo(fu.session, item_idVal + "_TM", "");// createItem_ID + System.out.printf("createItem_ID============" + createItem_ID); + if (createItem_ID.endsWith("01")) { + cbx.setEnabled(false); + System.out.printf("cbx.setEnabled(false)"); + } else { + TCComponentPseudoFolder fixtureDocumentFolder = TCUtil.getRevisionPseudoFolder(partItemRevision, "оĵ"); + if (fixtureDocumentFolder != null) { + ArrayList oldDLItems = TCUtil.getAllChildComponent(fu.session, fixtureDocumentFolder, "YSR8_FixtureDocument", "ͼĿ¼"); + if (oldDLItems != null && oldDLItems.size() > 0) { + oldDLItem = (TCComponentItem) oldDLItems.get(0); + isRewrite = true; + System.out.printf("isRewrite = true"); + } + } + } + + cbx = (JComboBox)fu.allComponentMap.get("ysr8_Format"); + cbx.setSelectedIndex(1); + } catch (TCException e) { + e.printStackTrace(); + } + } + + public boolean checkCanSave() { + return true; + } + + private void ChangeComboBoxState_ysr8_Use() { + JComboBoxInfo ci = (JComboBoxInfo)fu.allComponentInfos.get("ysr8_Use"); + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_Use"); + String ysr8_UseVal = cbx.getSelectedItem().toString(); + if (ysr8_UseVal.equals("") || ci.lovVal == null) { + return; + } + Iterator iter = ci.lovVal.keySet().iterator(); + while (iter.hasNext()) { + String lovKey = iter.next(); + String lovValue = ci.lovVal.get(lovKey); + if (lovValue.equalsIgnoreCase(ysr8_UseVal)) { + + JComboBoxInfo ci1 = (JComboBoxInfo)fu.allComponentInfos.get("ysr8_StructureType"); + JComboBox cbx1 = (JComboBox)fu.allComponentMap.get("ysr8_StructureType"); + System.out.println("ci1.valueName = " + lovKey); + ci1.valueName = lovKey; + ci1.lovVal = null; + cbx1.removeAllItems(); + cbx1.addItem(""); + fu.getlovValues(ci1); + if (ci1.lovVal != null && ci1.lovVal.size() > 0) { + for(Entry entry: ci1.lovVal.entrySet()){ + cbx1.addItem(entry.getValue()); + } + } + cbx1.setSelectedIndex(0); + break; + } + } + } + + private void outputExcel() { +// try { +// new ProgressMonitorDialog(null).run(true, false, new IRunnableWithProgress() { +// @Override +// public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { +// fu.session.setStatus("ڵ..."); +// export(monitor); +// fu.session.setStatus(""); +// } +// }); +// } catch (InvocationTargetException | InterruptedException e) { +// e.printStackTrace(); +// } + final JButton btn = (JButton)fu.allComponentMap.get("b.011.15"); + final String text=btn.getText(); + btn.setText("ȡ..."); + btn.setEnabled(false); + new Thread(new Runnable() { + @Override + public void run() { + export(); + btn.setText(text); + btn.setEnabled(true); + } + }).start(); + } + + //protected void export(IProgressMonitor monitor) { + protected void export() { + //monitor.beginTask("ڵ,Ժ...", 4); + //monitor.subTask("..."); + dataVector = null; + totalQuantityMap = new LinkedHashMap(); + lineVector = new Vector(); + drawQuantity = 0; + sumPartNum = 0.0; + sumCylindersNum = 0.0; + lineMap1 = new HashMap>(); + + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_Classfication"); + selectType = cbx.getSelectedIndex(); + cbx = (JComboBox)fu.allComponentMap.get("ysr8_Format"); + selectTypeTemplate = cbx.getSelectedIndex(); + fillData(); + } + + private void fillData() { + sumPartNum = 0.0; + sumCylindersNum = 0.0; + dataVector = new Vector>(); + try { + TCComponentItem item = currentLine.getItem(); + TCComponent[] revlist = item.getRelatedComponents("revision_list"); + System.out.println("revlist:" + revlist.length); + if (selectType == 1) { + totalQuantityMap.clear(); + addToDataVector(currentLine); + //lidy20180921Ļԭ߼ +// Map currentMapItemId = new LinkedHashMap(); +// Map currentSet = new HashMap<>(); +// getBOMLineDL(currentLine, currentMapItemId, currentSet); +// +// List> list = new ArrayList>(currentMapItemId.entrySet()); +// Collections.sort(list, new Comparator>() { +// public int compare(Map.Entry mapping1, Map.Entry mapping2) { +// return mapping1.getValue().compareTo(mapping2.getValue()); +// } +// }); +// currentMapItemId.clear(); +// for(Map.Entry me : list) +// currentMapItemId.put(me.getKey(), me.getValue()); +// +// addToDataVector(currentMapItemId); + } else if (selectType == 2) { + Assembly = currentLine.getProperty("bl_item_item_id"); + TCComponentItemRevision preRev = (TCComponentItemRevision)revlist[revlist.length - 2]; + preLine = TCUtil.getBOMLine(fu.session, preRev); + +// Vector preComps = new Vector(); + preComps = new HashMap<>(); + Map preMap = new LinkedHashMap(); + Map preMapItemId = new LinkedHashMap(); + Map preSet = new HashMap<>(); + +// Vector currentComps = new Vector(); + currentComps = new HashMap<>(); + Map currentMap = new LinkedHashMap(); + Map currentMapItemId = new LinkedHashMap(); + Map currentSet = new HashMap<>(); + + getBOMLineDL(preLine, preComps, preMap, preMapItemId, preSet); + getBOMLineDL(currentLine, currentComps, currentMap, currentMapItemId, currentSet); + + System.out.println("preComps.len:" + preComps.size()); + System.out.println("currentComps.len:" + currentComps.size()); + + Map lineMap = new LinkedHashMap(); + for (Map.Entry currentEntry : currentMap.entrySet()) { + if (preMap.containsKey(currentEntry.getKey())) { +// System.out.println("currentEntry.getKey():" + currentEntry.getKey());// + if (TCUtil.compareBOMLineRevId(preMap.get(currentEntry.getKey()), currentMap.get(currentEntry.getKey()))) { + Object compResult = compareBOMLineQuantity(preLine, currentLine, currentSet.get(currentEntry.getKey())); + if (compResult instanceof double[]) { + double[] ds = (double[])compResult; +// System.out.println(preComps.get(currentEntry.getValue())+">>"+currentComps.get(currentEntry.getValue())); +// Object subCompResult = null; + Object subCompResult = compareBOMLineQuantity(preComps.get(preMap.get(currentEntry.getKey())), + currentComps.get(currentEntry.getValue()), currentSet.get(currentEntry.getKey())); +// System.out.println(currentEntry.getKey()+"===="+subCompResult); + if (subCompResult instanceof double[]) { + lineMap.put(currentMap.get(currentEntry.getKey()), currentMapItemId.get(currentMap.get(currentEntry.getKey())) + + "@@" + "" + fu.getDoubleString(ds[0]) + "->" + fu.getDoubleString(ds[1])); + }else { + Boolean subCompResult1 = comparePBOMLineQuantity(preComps.get(preMap.get(currentEntry.getKey())), + currentComps.get(currentEntry.getValue())); + // System.out.println(currentEntry.getValue()+">>"+subCompResult); + if (subCompResult1) { + lineMap.put(currentMap.get(currentEntry.getKey()), currentMapItemId.get(currentMap.get(currentEntry.getKey())) + + "@@" + "" + fu.getDoubleString(ds[0]) + "->" + fu.getDoubleString(ds[1])); + } + } + } else { // + Object subCompResult = compareBOMLineQuantity(preComps.get(preMap.get(currentEntry.getKey())), + currentComps.get(currentEntry.getValue()), currentSet.get(currentEntry.getKey())); + if (subCompResult instanceof double[]) { + lineMap.put(currentMap.get(currentEntry.getKey()), currentMapItemId.get(currentMap.get(currentEntry.getKey())) + + "@@"); + }else { + Boolean subCompResult1 = comparePBOMLineQuantity(preComps.get(preMap.get(currentEntry.getKey())), + currentComps.get(currentEntry.getValue())); + if (subCompResult1) { + lineMap.put(currentMap.get(currentEntry.getKey()), currentMapItemId.get(currentMap.get(currentEntry.getKey())) + + "@@"); + } + } + } + } else { + Object compResult = compareBOMLineQuantity(preLine, currentLine, currentSet.get(currentEntry.getKey())); + if (compResult instanceof double[]) { + double[] ds = (double[])compResult; + lineMap.put(currentMap.get(currentEntry.getKey()), currentMapItemId.get(currentMap.get(currentEntry.getKey())) + + "@@" + "滻ԭͼ," + fu.getDoubleString(ds[0]) + "->" + fu.getDoubleString(ds[1])); + } else + lineMap.put(currentMap.get(currentEntry.getKey()), currentMapItemId.get(currentMap.get(currentEntry.getKey())) + + "@@" + "滻ԭͼ"); + } + } else if (!preSet.containsValue(currentSet.get(currentEntry.getKey()))){ + lineMap.put(currentEntry.getValue(), currentMapItemId.get(currentEntry.getValue()) + "@@" + "׷ͼֽ"); + } else { + Object compResult = compareBOMLineQuantity(preLine, currentLine, currentSet.get(currentEntry.getKey())); + if (compResult instanceof double[]) { + double[] ds = (double[])compResult; + lineMap.put(currentMap.get(currentEntry.getKey()), currentMapItemId.get(currentMap.get(currentEntry.getKey())) + + "@@" + "" + fu.getDoubleString(ds[0]) + "->" + fu.getDoubleString(ds[1])); + }else { // + lineMap.put(currentMap.get(currentEntry.getKey()), currentMapItemId.get(currentMap.get(currentEntry.getKey())) + + "@@"); + } + } + } + for (Map.Entry preEntry : preSet.entrySet()) { + if (currentSet.containsKey(preEntry.getKey())) { + + } else if (currentSet.containsValue(preEntry.getValue())) { + Object compResult = compareBOMLineQuantity(preLine, currentLine, preEntry.getValue()); + if (compResult instanceof double[]) { + double[] ds = (double[])compResult; + lineMap.put(preMap.get(preEntry.getKey()), preMapItemId.get(preMap.get(preEntry.getKey())) + + "@@" + fu.getDoubleString(ds[0]) + "->" + fu.getDoubleString(ds[1]) + "@@0"); + } else { // + lineMap.put(preMap.get(preEntry.getKey()), preMapItemId.get(preMap.get(preEntry.getKey())) + + "@@@@0"); + } + } else { + lineMap.put(preMap.get(preEntry.getKey()), preMapItemId.get(preMap.get(preEntry.getKey())) + "@@" + "ȡͼֽ"); + } + } +// for (Map.Entry preEntry : preMap.entrySet()) { +// if (currentMap.containsKey(preEntry.getKey())) { +// System.out.println("preEntry.getKey():" + preEntry.getKey()); +// if (TCUtil.compareBOMLineRevId(preMap.get(preEntry.getKey()), currentMap.get(preEntry.getKey()))) { +// Object compResult = TCUtil.compareBOMLineQuantity(preMap.get(preEntry.getKey()), currentMap.get(preEntry.getKey())); +// if (compResult instanceof double[]) { +// double[] ds = (double[])compResult; +// lineMap.put(currentMap.get(preEntry.getKey()), currentMapItemId.get(currentMap.get(preEntry.getKey())) +// + "@@" + "" + fu.getDoubleString(ds[0]) + "->" + fu.getDoubleString(ds[1])); +// } +// } else { +// lineMap.put(currentMap.get(preEntry.getKey()), currentMapItemId.get(currentMap.get(preEntry.getKey())) + "@@" + "滻ԭͼ"); +// } +// } else { +// lineMap.put(preEntry.getValue(), preMapItemId.get(preEntry.getValue()) + "@@" + "ȡͼֽ"); +// } +// } +// for (Map.Entry currententry : currentMap.entrySet()) { +// if (preMap.containsKey(currententry.getKey())) { +// +// } else { +// lineMap.put(currententry.getValue(), currentMapItemId.get(currententry.getValue()) + "@@" + "׷ͼֽ"); +// } +// } + List> list = new ArrayList>(lineMap.entrySet()); + Collections.sort(list, new Comparator>() { + public int compare(Map.Entry mapping1, Map.Entry mapping2) { + return mapping1.getValue().replace("@@", "##").compareTo(mapping2.getValue().replace("@@", "##")); + } + }); + lineMap.clear(); + for(Map.Entry me : list) + lineMap.put(me.getKey(), me.getValue()); + for(String v : lineMap.values()) + System.out.println("------"+v); + addToDataVector(lineMap); + } + } catch (TCException e) { + e.printStackTrace(); + } + + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a.061.11.11"); + int rowCount = ci.dataTableModel.getRowCount(); + for(int i = rowCount - 1; i >= 0; i--){ + ci.dataTableModel.removeRow(i); + } + ci.dataTableModel.getDataVector().clear(); + + try { + + Map map = new HashMap<>(); + map.put("汾", partItemRevision.getProperty("item_revision_id")); + map.put("ͼ", partItemRevision.getProperty("item_id")); + TCComponentForm form = TCUtil.getItemRevisionMasterForm(partItemRevision); + map.put("ûͼ", form.getProperty("ysr8_CustomPartCode")); + map.put("", partItemRevision.getProperty("object_name")); + map.put("", "1"); + map.put("", "1"); + map.put("װ", ""); + map.put("仯", "׷"); + map.put("ע", selectType == 1 ? "" : "滻ԭͼ"); + dataVector.insertElementAt(map, 0); + + lineVector = new Vector(); + Integer idx = 0; + Map idxMap = new HashMap<>(); + Set draw = new HashSet<>(); + for (Iterator> iterator = dataVector.iterator(); iterator.hasNext();) { + map = (Map)iterator.next(); + String item_idVal = map.get("ͼ"); + + Vector vec = new Vector<>(); + if (!idxMap.containsKey(item_idVal)) { + idxMap.put(item_idVal, ""); + vec.add((++idx) + "");// + } else { + vec.add("");// + } + String id = map.get("ͼ"); + vec.add(map.get("汾")); + vec.add(map.get("ͼ")); + vec.add(map.get("ûͼ")); + vec.add(map.get("")); + vec.add(map.get("")); + vec.add(map.get("")); + vec.add(map.get("װ")); + vec.add(map.get("ע")); + logger(map.get("ͼ")+">>"+map.containsKey("Ƽ")); + if(dzjtq && map.containsKey("Ƽ") && map.get("Ƽ").equals("Y") && !DZJset.contains(id)) { + DZJset.add(id); + } + + ci.dataTableModel.addRow(vec); + if (selectType == 2) + draw.add(map.get("ͼ")); + + if (createItem_ID.endsWith("01") || (createItem_ID.endsWith("02") && isRewrite)) { + if (lineVector.contains(item_idVal)) { + continue; + } + if (map.get("Item") == null) { + continue; + } + if (map.get("Item").equals("㲿") && !map.get("").contains("Ƭ")) { + if (item_idVal.startsWith("SW")) { + if (!map.get("").equals("")) { + sumPartNum += Double.parseDouble(map.get("")); + lineVector.add(item_idVal); + } + } else if (item_idVal.startsWith("ST")) { + if (!map.get("").equals("")) { + sumPartNum += Double.parseDouble(map.get("")); + lineVector.add(item_idVal); + } + } + } else if (map.get("Item").equals("") && !map.get("").contains("Ƭ")) { + if (item_idVal.startsWith("SD")) { + sumPartNum += Double.parseDouble(map.get("")); + lineVector.add(item_idVal); + } else if (item_idVal.startsWith("SC")) { + sumPartNum += Double.parseDouble(map.get("")); + lineVector.add(item_idVal); + } + } + System.out.println("Item=" + map.get("Item") + "=" + item_idVal + "=" + map.get("") + "=======" + + sumPartNum + "=======" + sumCylindersNum); + } + } + drawQuantity = draw.size(); +// System.out.println("׷滻ͼֽ:"+drawQuantity); + iTextField ysr8_AddOrReplaceQuantity = (iTextField)fu.allComponentMap.get("ysr8_AddOrReplaceQuantity"); + ysr8_AddOrReplaceQuantity.setText(drawQuantity +""); + iTextField ysr8_SDParts = (iTextField)fu.allComponentMap.get("ysr8_SDParts"); + ysr8_SDParts.setText(""+SDset.size()); // lidy20190416ͳSD׼ͼֽ + +// if (selectType == 1 && (createItem_ID.endsWith("01") || (createItem_ID.endsWith("02") && isRewrite))) { + if (selectType == 1 && (createItem_ID.endsWith("01") || isRewrite && oldDLItem.getProperty("item_id").endsWith("01"))) { + iTextField textfieldForm; + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_PartQuantity"); + textfieldForm.setText(fu.getDoubleString(sumPartNum-1)); //20200718ȥоܵͼֽXĬϰ1㣩 + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_CylindersQuantity"); + System.out.println("ysr8_CylindersQuantity Val=" + fu.getDoubleString(sumCylindersNum)); + textfieldForm.setText(fu.getDoubleString(sumCylindersNum)); + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + private void addToDataVector(TCComponentBOMLine pbomLine) { + try { + TCComponentItemRevision pitemRev = pbomLine.getItemRevision(); + String pitemId = pitemRev.getProperty("item_id"); + + AIFComponentContext[] context = pbomLine.getChildren(); +// Vector lineVector = new Vector(); + for (int i = 0; i < context.length; i++) { + TCComponentBOMLine childBomLine = (TCComponentBOMLine) context[i].getComponent(); + TCComponentItemRevision itemRev = childBomLine.getItemRevision(); + TCComponentItem item = itemRev.getItem(); + String itemId = itemRev.getProperty("item_id"); + if (lineVector.contains(itemId)) { + Vector parent = lineMap1.get(itemId); + for (Map map : dataVector) { + if (map.get("ͼ").equals(itemId) && map.get("װ").equals(pitemId)) { + double totalQuantity = Double.parseDouble(map.get("")); + String quantity = childBomLine.getProperty("bl_quantity"); + quantity = quantity.isEmpty() ? "1" : quantity; + double currQuantity = Double.parseDouble(quantity); + totalQuantity += currQuantity; + //System.out.println(itemId+"£ +"+currQuantity+"="+totalQuantity); + map.put("", fu.getDoubleString(totalQuantity)); + break; + } + } + //lidy20180912װͬʾ + if(parent.contains(pitemId)) + continue; + } + + if (item.getProperty("object_type").equals("ɹ")) { + if (itemId.startsWith("A01")) { + if (!totalQuantityMap.containsKey(itemId)) { + String totalQuantity = totalQuantityMap.get(itemId); +// double totalQuantity1 = TCUtil.totalBOMLineQuantity(childBomLine); + double totalQuantity1 = totalBOMLineQuantity(childBomLine); + totalQuantity = fu.getDoubleString(totalQuantity1); + totalQuantityMap.put(itemId, totalQuantity); + sumCylindersNum += Double.parseDouble(totalQuantity); + } + } + } + + if (itemId.startsWith("SW") || itemId.startsWith("SC") || + itemId.startsWith("SD") || itemId.startsWith("ST")) { + if(itemId.startsWith("SD")) + SDset.add(itemId);//lidy20190416 + String remark = childBomLine.getProperty("YSR8_Remark_bom"); + + if(itemRev.getProperty("object_type").equals("Fac Std Part Revision")) {// + TCComponentForm revForm = TCUtil.getItemRevisionMasterForm(itemRev); + String ysr8_Remark = revForm.getProperty("ysr8_Remark"); + if(ysr8_Remark.indexOf("")!=-1) + remark = remark +" "; + } + //Ƽ + String[] keys = new String[] {" ID"}; + String[] values = new String[] {itemId}; + List comps = queryObject("...",keys,values); + if(comps!=null && comps.size()>0) { + TCComponentItem componentItem = null; + TCComponent tcComponent = comps.get(0); + if(tcComponent instanceof TCComponentItem) { + componentItem = (TCComponentItem)tcComponent; + TCComponentItemRevision latestItemRevision = componentItem.getLatestItemRevision(); + TCComponent[] referenceListProperty = latestItemRevision.getReferenceListProperty("IMAN_master_form_rev"); + TCComponentForm form; + if (referenceListProperty != null) { + try { + form = (TCComponentForm) referenceListProperty[0]; + } catch (Exception e) { + MessageBox.post("IDΪ"+latestItemRevision.getStringProperty("item_id")+"汾ȱٱ","ʾ",2); + return; + } + + if (form.getProperty("ysr8_isDzj") != null) { + String property = form.getProperty("ysr8_isDzj"); + if("yes".equalsIgnoreCase(property)||"".equals(property)) { + if("".equals(remark.trim()) || remark==null) { + remark = "Ƽ"; + }else { + remark = remark+"Ƽ"; + } + } + } + } + } + } + TCComponentForm form = TCUtil.getItemRevisionMasterForm(itemRev); + + Map map = new HashMap<>(); + map.put("汾", itemRev.getProperty("item_revision_id")); + map.put("ͼ", itemId); + map.put("ûͼ", form.getProperty("ysr8_CustomPartCode")); + map.put("", itemRev.getProperty("object_name")); + String quantity = childBomLine.getProperty("bl_quantity"); + quantity = quantity.isEmpty() ? "1" : quantity; + map.put("", quantity); + if (!totalQuantityMap.containsKey(itemId)) { + String totalQuantity = totalQuantityMap.get(itemId); +// double totalQuantity1 = TCUtil.totalBOMLineQuantity(childBomLine); + double totalQuantity1 = totalBOMLineQuantity(childBomLine); + totalQuantity = fu.getDoubleString(totalQuantity1); + totalQuantityMap.put(itemId, totalQuantity); + map.put("", totalQuantity); + } else { + map.put("", ""); + } + map.put("װ", pitemId); + map.put("ע", remark); + map.put("", form.getProperty("ysr8_Material")); + map.put("Item", item.getProperty("object_type")); + map.put("Ƿɹ", form.getProperty("ysr8_IsPurch")); + //map.put("Ƽ", "N"); + if(dzjtq && form.getProperty("ysr8_isDzj").equals("")) { + map.put("Ƽ", "Y");//TODO + } + dataVector.add(map); + + lineVector.add(itemId); + + Vector parents; + if(lineMap1.containsKey(itemId)) { + parents = lineMap1.get(itemId); + } else + parents = new Vector(); + parents.add(pitemId); + lineMap1.put(itemId, parents); + + } + addToDataVector(childBomLine); + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + private void addToDataVector(Map lineMap) { + try { + System.out.println("lineMap:" + lineMap.size()); + + for (Map.Entry entry : lineMap.entrySet()) { + TCComponentBOMLine bomline = entry.getKey(); + + TCComponentItemRevision itemRev = bomline.getItemRevision(); + String itemId = itemRev.getProperty("item_id"); +// System.out.println("itemId:" + itemId); +// TCComponentItem item = itemRev.getItem(); +// if (item.getProperty("object_type").equals("ɹ")) { +// if (itemId.startsWith("A01")) { +// if (!totalQuantityMap.containsKey(itemId)) { +// String totalQuantity = totalQuantityMap.get(itemId); +// double totalQuantity1 = totalBOMLineQuantity(this.bomline, itemId); +// totalQuantity = fu.getDoubleString(totalQuantity1); +// totalQuantityMap.put(itemId, totalQuantity); +// sumCylindersNum += Double.parseDouble(totalQuantity); +// } +// } +// } + if (itemId.startsWith("SW") || itemId.startsWith("SC") || + itemId.startsWith("SD") || itemId.startsWith("ST")) { + Vector vecMark = CommonUtil.split2Vector(entry.getValue(), "@@"); + String pitemId = vecMark.get(0); + String mark = ""; + if(vecMark.size()>1) + mark= vecMark.get(1); + if(itemId.startsWith("SD") && vecMark.size()>1 && !"".equals(mark))// lidy20190416ͳSD׼ͼֽ + SDset.add(itemId); + String remark = bomline.getProperty("YSR8_Remark_bom"); + TCComponentForm form = TCUtil.getItemRevisionMasterForm(itemRev); + + Map map = new HashMap<>(); + map.put("汾", itemRev.getProperty("item_revision_id")); + map.put("ͼ", itemId); + map.put("ûͼ", form.getProperty("ysr8_CustomPartCode")); + map.put("", itemRev.getProperty("object_name")); + //㵱ǰ㼶 + Double q=0.0; + TCComponentBOMLine pLine = bomline.parent(); + if(vecMark.size()>2) { + map.put("", "0"); + }else if(pLine!=null) { + for (AIFComponentContext cLineContext : pLine.getChildren()) { + TCComponentBOMLine cLine = (TCComponentBOMLine)cLineContext.getComponent(); + TCComponentItemRevision cRev = cLine.getItemRevision(); + if(itemId.equals(cRev.getProperty("item_id"))) { + String quantity = cLine.getProperty("bl_quantity"); + quantity = quantity.isEmpty() ? "1" : quantity; + double currQuantity = Double.parseDouble(quantity); + q += currQuantity; + } + } + map.put("", fu.getDoubleString(q)); + }else { + String quantity = bomline.getProperty("bl_quantity"); + quantity = quantity.isEmpty() ? "1" : quantity; + map.put("", quantity); + } + if (!totalQuantityMap.containsKey(itemId)) { + String totalQuantity = totalQuantityMap.get(itemId); +// double totalQuantity1 = TCUtil.totalBOMLineQuantity(bomline); +// double totalQuantity1 = totalBOMLineQuantity(bomline); + double totalQuantity1 = totalBOMLineQuantity(currentLine, itemId);// lidy20190320 + totalQuantity = fu.getDoubleString(totalQuantity1); + totalQuantityMap.put(itemId, totalQuantity); + map.put("", totalQuantity); + } else { + map.put("", ""); + } +// if(selectType == 1) { +// map.put("", form.getProperty("ysr8_Material")); +// map.put("Item", item.getProperty("object_type")); +// map.put("Ƿɹ", form.getProperty("ysr8_IsPurch")); +// } + map.put("װ", pitemId); + if(mark.equals("ȡͼֽ")) { + map.put("仯", "ȡ"); + } else + map.put("仯", "׷"); + if(!mark.equals("") && itemRev.getProperty("object_type").equals("Fac Std Part Revision")) { + String ysr8_Remark = form.getProperty("ysr8_Remark"); + if(ysr8_Remark.indexOf("")!=-1) + mark = mark +","; + } + map.put("ע", remark.equals("") ? mark : remark + "," + mark); + //map.put("Ƽ", "N"); + if(dzjtq && form.getProperty("ysr8_isDzj").equals("")) { + map.put("Ƽ", "Y");//TODO + } + + dataVector.add(map); + } + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + private void writeToExcel(File reportFile) { + try { + String itemId = partItemRevision.getProperty("item_id"); + String itemName = partItemRevision.getProperty("object_name"); + String topItemId = partItemRevision.getProperty("project_ids"); + + FileInputStream fileIn = new FileInputStream(reportFile); + String fileName = reportFile.getName().toLowerCase(); + Workbook workbook = fileName.endsWith("xls") ? new HSSFWorkbook(fileIn) : new XSSFWorkbook(fileIn); + + System.out.println("dataVector.len:" + dataVector.size()); + + Integer sheetIndex = 0, row = 3, maxrow = 22, index = 0, pageSize = 20, vecSize = dataVector.size(); + Integer sheetCount = 0; + if (vecSize <= pageSize) { + sheetCount = 1; + } else { + sheetCount = vecSize / pageSize + (vecSize % pageSize == 0 ? 0 : 1); + } + + System.out.println("Sheet count:" + sheetCount); + + for (int i = 1; i < sheetCount; i++) { + workbook.cloneSheet(0); + } + Sheet sheet = workbook.getSheetAt(sheetIndex); + workbook.setSheetName(sheetIndex, "" + (++sheetIndex) + "ҳ"); + + for (int i = 0; i < dataVector.size(); i++) { + Map map = dataVector.get(i); + + if (!(map.get("ͼ").startsWith("WG"))) { + sheet.getRow(row).getCell(0).setCellValue(++index); + sheet.getRow(row).getCell(1).setCellValue(map.get("汾")); + sheet.getRow(row).getCell(2).setCellValue(map.get("ͼ")); + if (selectTypeTemplate == 1) { + sheet.getRow(row).getCell(6).setCellValue(map.get("")); + sheet.getRow(row).getCell(10).setCellValue(map.get("")); + sheet.getRow(row).getCell(11).setCellValue(map.get("")); + sheet.getRow(row).getCell(12).setCellValue(map.get("װ")); + sheet.getRow(row).getCell(13).setCellValue(map.get("ע")); + } else if (selectTypeTemplate == 2) { + sheet.getRow(row).getCell(4).setCellValue(map.get("ûͼ")); + sheet.getRow(row).getCell(7).setCellValue(map.get("")); + sheet.getRow(row).getCell(10).setCellValue(map.get("")); + sheet.getRow(row).getCell(11).setCellValue(map.get("")); + sheet.getRow(row).getCell(12).setCellValue(map.get("װ")); + sheet.getRow(row).getCell(13).setCellValue(map.get("ע")); + } + row++; + } + if (row > maxrow && sheetIndex < sheetCount) { + row = 3; + sheet = workbook.getSheetAt(sheetIndex); + workbook.setSheetName(sheetIndex, "" + (++sheetIndex) + "ҳ"); + } + } + for (int i = 0; i < sheetCount; i++) { + sheet = workbook.getSheetAt(i); + sheet.getRow(23).getCell(3).setCellValue(itemName); + sheet.getRow(23).getCell(12).setCellValue(topItemId); + sheet.getRow(24).getCell(12).setCellValue(itemId); + sheet.getRow(26).getCell(12).setCellValue(" " + sheetCount + " ҳ " + (i + 1) + " ҳ"); + } + + sheet = workbook.createSheet(""); + Row dataRow = sheet.createRow(0); + dataRow.createCell(0); dataRow.createCell(1); + sheet.getRow(0).getCell(0).setCellValue(""); + sheet.getRow(0).getCell(1).setCellValue("ͼĿ¼"); + + dataRow = sheet.createRow(1); + dataRow.createCell(0); dataRow.createCell(1); + sheet.getRow(1).getCell(0).setCellValue("û"); + iTextField textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_CustomerName"); + sheet.getRow(1).getCell(1).setCellValue(textfieldForm.getText()); + + dataRow = sheet.createRow(2); + dataRow.createCell(0); dataRow.createCell(1); + sheet.getRow(2).getCell(0).setCellValue(";"); + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_Use"); + sheet.getRow(2).getCell(1).setCellValue(cbx.getSelectedItem().toString()); + + dataRow = sheet.createRow(3); + dataRow.createCell(0); dataRow.createCell(1); + sheet.getRow(3).getCell(0).setCellValue("ṹ"); + cbx = (JComboBox)fu.allComponentMap.get("ysr8_StructureType"); + System.out.println("ysr8_StructureTypeؼ=" + (cbx == null ? "" : cbx.getSelectedItem().toString())); + sheet.getRow(3).getCell(1).setCellValue(cbx.getSelectedItem().toString()); + + dataRow = sheet.createRow(4); + dataRow.createCell(0); dataRow.createCell(1); + sheet.getRow(4).getCell(0).setCellValue("ֶ/Զ"); + cbx = (JComboBox)fu.allComponentMap.get("ysr8_AutoMation"); + System.out.println("ysr8_AutoMationؼ=" + (cbx == null ? "" : cbx.getSelectedItem().toString())); + sheet.getRow(4).getCell(1).setCellValue(cbx.getSelectedItem().toString()); + + dataRow = sheet.createRow(5); + dataRow.createCell(0); dataRow.createCell(1); + sheet.getRow(5).getCell(0).setCellValue("㺸/"); + cbx = (JComboBox)fu.allComponentMap.get("ysr8_ProductType"); + System.out.println("ysr8_ProductTypeؼ=" + (cbx == null ? "" : cbx.getSelectedItem().toString())); + sheet.getRow(5).getCell(1).setCellValue(cbx.getSelectedItem().toString()); + + dataRow = sheet.createRow(6); + dataRow.createCell(0); dataRow.createCell(1); + sheet.getRow(6).getCell(0).setCellValue("װ峤(mm)"); + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_BoardLength"); + System.out.println("ysr8_BoardLengthؼ=" + (cbx == null ? "" : textfieldForm.getText())); + sheet.getRow(6).getCell(1).setCellValue(textfieldForm.getText()); + + dataRow = sheet.createRow(7); + dataRow.createCell(0); dataRow.createCell(1); + sheet.getRow(7).getCell(0).setCellValue("װbase(mm)"); + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_BoardWidth"); + System.out.println("ysr8_BoardWidthؼ=" + (cbx == null ? "" : textfieldForm.getText())); + sheet.getRow(7).getCell(1).setCellValue(textfieldForm.getText()); + + dataRow = sheet.createRow(8); + dataRow.createCell(0); dataRow.createCell(1); + sheet.getRow(8).getCell(0).setCellValue(""); + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_PartQuantity"); + sheet.getRow(8).getCell(1).setCellValue(textfieldForm.getText()); + + dataRow = sheet.createRow(9); + dataRow.createCell(0); dataRow.createCell(1); + sheet.getRow(9).getCell(0).setCellValue(""); + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_CylindersQuantity"); + System.out.println("ysr8_CylindersQuantityؼ=" + (cbx == null ? "" : textfieldForm.getText())); + sheet.getRow(9).getCell(1).setCellValue(textfieldForm.getText()); + + FileOutputStream fileOut = new FileOutputStream(reportFile.getPath()); + workbook.write(fileOut); + fileOut.flush(); + fileOut.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + //lidy20180906ͼĿ¼ + private void getBOMLineDL(TCComponentBOMLine pbomLine, Map comps, Map map, + Map mapItemId,Map 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"); + if (!set.containsKey(pitemId + ">>" + itemId)) { + comps.put(bomLine, pbomLine); + set.put(pitemId + ">>" + itemId, itemId); + map.put(pitemId + ">>" + itemId, bomLine); + mapItemId.put(bomLine, pitemId); + // System.out.println(itemId + install + "-----" + bomLine); + } + getBOMLineDL(bomLine, comps, map, mapItemId, set); + } + } catch (TCException e) { + e.printStackTrace(); + } + } +// private void getBOMLineDL(TCComponentBOMLine pbomLine, Map mapItemId, Map 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"); +// if (!set.containsKey(pitemId + ">>" + itemId)) { +// mapItemId.put(bomLine, pitemId); +// set.put(pitemId + ">>" + itemId, itemId); +// // System.out.println(itemId + install + "-----" + bomLine); +// } +// getBOMLineDL(bomLine, mapItemId, set); +// } +// } catch (TCException e) { +// e.printStackTrace(); +// } +// } + private static Object compareBOMLineQuantity(TCComponentBOMLine preBomLine, TCComponentBOMLine currentBomLine, String bomID) { + double currentQuantity = totalBOMLineQuantity(currentBomLine, bomID); + double preQuantity = totalBOMLineQuantity(preBomLine, bomID); + System.out.println(bomID + ":" + preQuantity + ":" + currentQuantity); + if (currentQuantity == preQuantity) { + return true; + } else { + return new double[] { preQuantity, currentQuantity }; + } + } + private Boolean comparePBOMLineQuantity(TCComponentBOMLine preBomLine, TCComponentBOMLine currentBomLine) { +// System.out.println(bomID + "===" + preBomLine + "===" + currentBomLine); + + try { + double currentQuantity = totalBOMLineQuantity(currentLine, currentBomLine.getProperty("bl_item_item_id")); + double preQuantity = totalBOMLineQuantity(preLine, currentBomLine.getProperty("bl_item_item_id")); + if (currentQuantity != preQuantity) { + return true; + } else if(preBomLine.getProperty("bl_item_item_id").equals(Assembly) || currentBomLine.getProperty("bl_item_item_id").equals(Assembly)) { + return false; + } else + return comparePBOMLineQuantity(preBomLine.parent(), currentBomLine.parent()); + } catch (TCException e) { + e.printStackTrace(); + } + return true; + } + + /** + * ItembomLineе + * + * @param bomLine + * @return + */ + private static double totalBOMLineQuantity(TCComponentBOMLine bomLine, String bomID) { + 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(bomLine, bomID, true); + // System.out.println("ҪItem" + itemID + " Ŀǰ" + count); + } catch (TCException e) { + e.printStackTrace(); + } + return count; + } + /** + * bomLineǰװλ + * + * @param bomLine + * @return + */ + private 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(); + } + System.out.println("totalBOMLineQuantity:"+bomLine+"->"+rootBomLine); + count += loop(rootBomLine, bomLine.getProperty("bl_item_item_id"), 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; + //ǰbomline¼Ӽ + for (int i = 0; i < context.length; i++) { + TCComponentBOMLine children = (TCComponentBOMLine) context[i].getComponent(); + String childrenID = children.getProperty("bl_item_item_id");//Ӽid + // System.out.println("ǰItem" + childrenID + install); + if (childrenID.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 List queryObject(String queryName, String[] keys, String[] values) { + TCComponent[] components = null; + try { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + MessageBox.post("ûҵѯ:" + queryName, "", MessageBox.ERROR); + return null; + } + components = query.execute(keys, values); + } catch (TCException e) { + e.printStackTrace(); + } + if (components != null && components.length > 0) { + List compList = Arrays.asList(components); + return compList; + } else { + MessageBox.post("ûвѯ", "", MessageBox.ERROR); + return null; + } + } + + private void logger(String msg){ + try { +// System.out.println(msg); + fos.write(sdf.format(new Date()) +" "+ msg +"\r\n\r\n"); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/cn/com/ebewin/ysr/dialog/YSR8_DrawingListSortUtil.java b/src/cn/com/ebewin/ysr/dialog/YSR8_DrawingListSortUtil.java new file mode 100644 index 0000000..cbfb7c4 --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/YSR8_DrawingListSortUtil.java @@ -0,0 +1,122 @@ +package cn.com.ebewin.ysr.dialog; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Vector; + +import com.teamcenter.rac.kernel.TCComponentBOMLine; + +public class YSR8_DrawingListSortUtil { + + private static String[] dc = { "SW", "SC", "SD", "ST" }; + + public static Vector> sortDC(Vector> dataVector) { + Set> linkSet = new LinkedHashSet<>(dataVector); +System.out.println("linkSet.size()-----" + linkSet.size()); + List> listSort = new ArrayList>(linkSet); +System.out.println("listSort.size()1-----" + listSort.size()); + + Collections.sort(listSort, new DCComparator()); +System.out.println("listSort.size()2-----" + listSort.size()); + + dataVector.clear(); + dataVector.addAll(listSort); +System.out.println("dataVector.size()-----" + dataVector.size()); + return dataVector; + } + + private static class DCComparator implements Comparator> { + + @Override + public int compare(Map o1, Map o2) { + String id1 = o1.get("ͼ"), id2 = o2.get("ͼ"); + String dc1 = id1.substring(0, 2), dc2 = id2.substring(0, 2); + String idn1 = id1.substring(2, id1.length()), idn2 = id2.substring(2, id2.length()); + Integer dci1 = 0, dci2 = 0; + for (int i = 0; i < dc.length; i++) { + if (dc1.equals(dc[i])) { + dci1 = i; + } + if (dc2.equals(dc[i])) { + dci2 = i; + } + } + if (dci1 == dci2) { + return idn1.compareTo(idn2); + } + return dci1.compareTo(dci2); + } + + } + + public static Vector> sortSD(Vector> dataVector) { + Set> linkSet = new LinkedHashSet<>(dataVector); + List> listSort = new ArrayList>(linkSet); + + Collections.sort(listSort, new SDComparator()); + + dataVector.clear(); + dataVector.addAll(listSort); + return dataVector; + } + + private static class SDComparator implements Comparator> { + + @Override + public int compare(Map o1, Map o2) { + String id1 = o1.get("ͼ"), id2 = o2.get("ͼ"); + return id1.compareTo(id2); + } + + } + + public static Vector> sortWP(Vector> dataVector) { + Set> linkSet = new LinkedHashSet<>(dataVector); + List> listSort = new ArrayList>(linkSet); + + Collections.sort(listSort, new WPComparator()); + + dataVector.clear(); + dataVector.addAll(listSort); + return dataVector; + } + + private static class WPComparator implements Comparator> { + + @Override + public int compare(Map o1, Map o2) { + String id1 = o1.get("ͼ"), id2 = o2.get("ͼ"); + return id1.compareTo(id2); + } + + } + + public static Vector> sortOS(Vector> dataVector) { + Set> linkSet = new LinkedHashSet<>(dataVector); + List> listSort = new ArrayList>(linkSet); + Collections.sort(listSort, new OSComparator()); + + dataVector.clear(); + dataVector.addAll(listSort); + return dataVector; + + } + + private static class OSComparator implements Comparator> { + + @Override + public int compare(Map o1, Map o2) { + String id1 = o1.get("ͼ"), id2 = o2.get("ͼ"); + String ins1 = o1.get("װ"), ins2 = o2.get("װ"); + if (ins1.equals(ins2)) { + return id1.compareTo(id2); + } + return ins1.compareTo(ins2); + } + } +} diff --git a/src/cn/com/ebewin/ysr/dialog/YSR8_ECN2RevisionMasterEditDialog.java b/src/cn/com/ebewin/ysr/dialog/YSR8_ECN2RevisionMasterEditDialog.java new file mode 100644 index 0000000..7318998 --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/YSR8_ECN2RevisionMasterEditDialog.java @@ -0,0 +1,109 @@ +package cn.com.ebewin.ysr.dialog; + +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.JTable; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; + +import cn.com.ebewin.ysr.util.DialogUtil; +import cn.com.ebewin.ysr.util.TCUtil; + +@SuppressWarnings("deprecation") +public class YSR8_ECN2RevisionMasterEditDialog extends AbstractAIFDialog { + private static final long serialVersionUID = 1L; + private DialogUtil fu = new DialogUtil(this, "Ԫ޸", "YSR8_ECN2RevisionMasterEditDialog"); + + private TCComponentForm ecn2Form = null; + private JTable table = null; + private int listIdx = -1; + public String return_ysr8_SubPurchFinishDateVal = ""; + + public YSR8_ECN2RevisionMasterEditDialog(TCSession session, JTable table, TCComponentForm ecn2Form, int listIdx) throws TCException { + super(true); + + this.table = table; + this.ecn2Form = ecn2Form; + this.listIdx = listIdx-1; + + fu.initializeUI(session); + centerToScreen(); + loadRendering(); + addActionListener(); + getDefVal(); + setVisible(true); + } + + private void loadRendering() throws TCException { + DateButton ysr8_SubPurchFinishDate = (DateButton)fu.allComponentMap.get("ysr8_SubPurchFinishDate"); + + TCProperty ysr8_SubPurchFinishDatePro = ecn2Form.getFormTCProperty("ysr8_SubPurchFinishDate"); + ysr8_SubPurchFinishDate.setDate(new Date()); + Date[] ysr8_SubPurchFinishDateVals = ysr8_SubPurchFinishDatePro.getDateValueArray(); + if (ysr8_SubPurchFinishDateVals != null && + ysr8_SubPurchFinishDateVals.length > listIdx && + ysr8_SubPurchFinishDateVals[listIdx] != null) { + ysr8_SubPurchFinishDate.setDate(ysr8_SubPurchFinishDateVals[listIdx]); + } + } + + private void addActionListener() { + JButton btn = (JButton)fu.allComponentMap.get("b.21.12"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + saveRendering(); + } + }); + + btn = (JButton)fu.allComponentMap.get("b.21.14"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + dialogResultId = ID_CANCEL; + disposeDialog(); + } + }); + } + + private void saveRendering() { + if (!checkCanSave()) { + return; + } + DateButton ysr8_SubPurchFinishDate = (DateButton)fu.allComponentMap.get("ysr8_SubPurchFinishDate"); +// String ysr8_SubPurchFinishDateVal = fu.getDateString(ysr8_SubPurchFinishDate.getDate()); + if (ysr8_SubPurchFinishDate.getDate() == null) { + MessageBox.post(AIFUtility.getActiveDesktop(), "ûѡʱ䣬޷", "ʾ", MessageBox.WARNING); + System.out.println("ûѡʱ䣬޷"); + return; + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String ysr8_SubPurchFinishDateVal = sdf.format(ysr8_SubPurchFinishDate.getDate()); + int Quantity = Integer.parseInt(TCUtil.getNumber(table.getValueAt(listIdx, 5).toString())); + table.setValueAt(Quantity+"", listIdx, 24); + table.setValueAt(Quantity+"", listIdx, 25); + table.setValueAt("ѱ", listIdx, 18); + + table.setValueAt(ysr8_SubPurchFinishDateVal, listIdx, 11); + return_ysr8_SubPurchFinishDateVal = ysr8_SubPurchFinishDateVal; + + dialogResultId = ID_OK; + disposeDialog(); + } + + private void getDefVal() { + fu.getDefVal(); + } + + public boolean checkCanSave() { + return true; + } + +} diff --git a/src/cn/com/ebewin/ysr/dialog/YSR8_INSPRecordCreateDialog.java b/src/cn/com/ebewin/ysr/dialog/YSR8_INSPRecordCreateDialog.java new file mode 100644 index 0000000..d129268 --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/YSR8_INSPRecordCreateDialog.java @@ -0,0 +1,1355 @@ +package cn.com.ebewin.ysr.dialog; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Vector; +import java.util.Map.Entry; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JOptionPane; +import javax.swing.JTable; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentProcessType; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +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.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.iTextField; + +import cn.com.ebewin.ysr.util.CommonUtil; +import cn.com.ebewin.ysr.util.CreateDialogUtil; +import cn.com.ebewin.ysr.util.DialogUtil; +import cn.com.ebewin.ysr.util.FormUtil; +import cn.com.ebewin.ysr.util.KUtil; +import cn.com.ebewin.ysr.util.TCUtil; + +@SuppressWarnings("deprecation") +public class YSR8_INSPRecordCreateDialog extends AbstractAIFDialog { + private static final long serialVersionUID = 1L; + private CreateDialogUtil fu = new CreateDialogUtil(this, "ɢ¼", "YSR8_INSPRecordCreateDialog", "YSR8_INSPRecord"); + private int partType = 2; + private List parentObjs = null; + private List parentObjIdxs = null; + private QualityManagementBoardDialog qmb; + private String ysr8_ProjectCodeVal = ""; + + private static final int PARTTYPE_BJ = 2; + private static final int PARTTYPE_SJ = 1; + + public YSR8_INSPRecordCreateDialog(QualityManagementBoardDialog qmb, int partType, List parentObjs, List parentObjIdxs) throws TCException { + super(true); + + this.qmb =qmb; + this.partType = partType; + this.parentObjs = parentObjs; + this.parentObjIdxs = parentObjIdxs; + +// if (partType == 1) {// ɢ +// } else if (partType == 2) {// +// CreateDialogUtil.JComboBoxInfo ci1 = (CreateDialogUtil.JComboBoxInfo) fu.allComponentInfos.get("ysr8_UnqualifiedType"); +// ci1.valueName = "YSR8_INSPR4_LOV"; +// CreateDialogUtil.JComboBoxInfo ci2 = (CreateDialogUtil.JComboBoxInfo) fu.allComponentInfos.get("ysr8_UnqualifiedType2"); +// ci2.valueName = "YSR8_INSPR4_LOV"; +// CreateDialogUtil.JComboBoxInfo ci3 = (CreateDialogUtil.JComboBoxInfo) fu.allComponentInfos.get("ysr8_UnqualifiedType3"); +// ci3.valueName = "YSR8_INSPR4_LOV"; +// CreateDialogUtil.JComboBoxInfo ci4 = (CreateDialogUtil.JComboBoxInfo) fu.allComponentInfos.get("ysr8_UnqualifiedType4"); +// ci4.valueName = "YSR8_INSPR4_LOV"; +// CreateDialogUtil.JComboBoxInfo ci5 = (CreateDialogUtil.JComboBoxInfo) fu.allComponentInfos.get("ysr8_UnqualifiedType5"); +// ci5.valueName = "YSR8_INSPR4_LOV"; +// +// CreateDialogUtil.JComboBoxInfo ci0 = (CreateDialogUtil.JComboBoxInfo) fu.allComponentInfos.get("ysr8_SubQualityResult"); +// ci0.valueName = "YSR8_INSPR3_LOV"; +// } + fu.initializeUI(qmb.fu.session); + centerToScreen(); + loadRendering(); + addActionListener(); + getDefVal(); + setVisible(true); + } + + private void loadRendering() throws TCException { + double examinNum = 0;// + if (partType == PARTTYPE_SJ) { // ɢ + // + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.41.12.11"); + DateButton ysr8_TestDate = (DateButton) fu.allComponentMap.get("ysr8_TestDate"); + ysr8_TestDate.setDate(new Date()); + for (int k = 0; k < parentObjs.size(); k++) { + Object parentObj = parentObjs.get(k); + Integer parentObjIdx = parentObjIdxs.get(k); + TCComponentForm form; + TCComponentItem item; + if (parentObj instanceof TCComponentItem) { + item = (TCComponentItem) parentObj; + TCComponentItemRevision revision = item.getLatestItemRevision(); + form = TCUtil.getItemRevisionMasterForm(revision); + } else { + continue; + } + // ͼ + TCProperty ysr8_MaterialID = form.getFormTCProperty("ysr8_MaterialID"); + if (ysr8_MaterialID == null) { + ysr8_MaterialID = form.getFormTCProperty("ysr8_PartCode"); + } + String[] ysr8_MaterialIDVal = ysr8_MaterialID.getStringArrayValue(); + String materialID = ysr8_MaterialIDVal[parentObjIdx]; + // 㲿 + TCProperty ysr8_MaterialName = form.getFormTCProperty("ysr8_MaterialName"); + if (ysr8_MaterialName == null) { + ysr8_MaterialName = form.getFormTCProperty("ysr8_PartName"); + } + String[] ysr8_MaterialNameVal = ysr8_MaterialName.getStringArrayValue(); + String materialName = ysr8_MaterialNameVal[parentObjIdx]; + // μ + TCProperty ysr8_ExaminingQuantity = form.getFormTCProperty("ysr8_ExaminingQuantity"); + String[] ysr8_ExaminingQuantityVal = ysr8_ExaminingQuantity.getStringArrayValue(); + String ysr8_ExaminingQuantityNum = ysr8_ExaminingQuantityVal[parentObjIdx]; + if(ysr8_ExaminingQuantityNum==null) { + ysr8_ExaminingQuantityNum=""; + } + + // + String partType = form.getProperty("ysr8_PartType"); + String fxdh = ""; + if ("".equals(partType)) { + String object_typeVal = item.getProperty("object_type"); + if(object_typeVal.equals("ͼֽĵ")||object_typeVal.equals("ļӹ")) { + fxdh = item.getProperty("item_id"); + }else if(object_typeVal.equals("ɢ¼")) { +// fxdh=form.getProperty("ysr8_ReworkOrderNo");//TODO lidy20190321 + TCProperty ysr8_RepairECN = form.getFormTCProperty("ysr8_RepairECN"); + if (ysr8_RepairECN != null) { + String[] ysr8_RepairECNVals = ysr8_RepairECN.getStringArrayValue(); + fxdh = ysr8_RepairECNVals[parentObjIdx]; + } + } + } else { + TCProperty ysr8_RepairECN = form.getFormTCProperty("ysr8_RepairECN"); + if (ysr8_RepairECN != null) { + String[] ysr8_RepairECNVals = ysr8_RepairECN.getStringArrayValue(); + fxdh = ysr8_RepairECNVals[parentObjIdx]; + } + } + Object[] objData = new Object[ci.childComponentInfos.size()]; + for (int i = 0; i < objData.length; i++) { + DialogUtil.ComponentInfo cci = ci.childComponentInfos.get(i); + switch (cci.name) { + case "ysr8_PartCode": + objData[i] = materialID; + break; + case "ysr8_PartName": + objData[i] = materialName; + break; + case "ysr8_Quantity": + objData[i] = ysr8_ExaminingQuantityNum; + break; + case "ysr8_RepairECN": + objData[i] = fxdh; + break; + case "ysr8_FactorySurvey"://lidy20190328 ӷѡΪĬֵ + objData[i] = ""; + break; + case "ysr8_SubTaskManuState": + objData[i] = "1"; + break; + default: + objData[i] = ""; + break; + } + } + ci.dataTableModel.addRow(objData); + try { + double rowExaminNum = KUtil.getDoubleFromString(ysr8_ExaminingQuantityNum, "μ"); + examinNum += rowExaminNum; + } catch (Exception e) { + System.out.println("ȡ" + materialID + "-" + materialName + "ıμ" + e.getMessage()); + e.printStackTrace(); + } + } + // kk ü + iTextField textfield = (iTextField) fu.allComponentMap.get("ysr8_TestNumber"); + textfield.setText(fu.getDoubleString(examinNum)); + } else if (partType == PARTTYPE_BJ) { // + for (int k = 0; k < parentObjs.size(); k++) { + Object parentObj = parentObjs.get(k); + if (parentObj instanceof TCComponentScheduleTask) { + TCComponentScheduleTask scheduTask = (TCComponentScheduleTask) parentObj; + String arrivingNum = scheduTask.getProperty("ysr8_ArrivingQuantity"); + try { + double rowExaminNum = KUtil.getDoubleFromString(arrivingNum, "μ"); + examinNum += rowExaminNum; + } catch (Exception e) { + System.out.println("ȡ" + scheduTask + "ıμ" + e.getMessage()); + e.printStackTrace(); + } + } else if (parentObj instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem) parentObj; + TCComponentItemRevision revision = item.getLatestItemRevision(); + TCComponentForm form = TCUtil.getItemRevisionMasterForm(revision); + String arrivingNum = form.getProperty("ysr8_ArrivingQuantity"); + try { + double rowExaminNum = KUtil.getDoubleFromString(arrivingNum, "μ"); + examinNum += rowExaminNum; + } catch (Exception e) { + System.out.println("ȡ" + item + "ıμ" + e.getMessage()); + e.printStackTrace(); + } + // + // String object_typeVal = item.getProperty("object_type"); + // if (object_typeVal.equals("ͼ滻Ŀ¼")) { + // } + } + } + } + // kk òϸ + iTextField textfield = (iTextField) fu.allComponentMap.get("ysr8_UnqualifiedQuantity"); + textfield.setText(fu.getDoubleString(0.0)); + + } + + private void copyRow() { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.41.12.11"); + int row = ci.dataTable.getSelectedRow(); + if (row < 0) { + System.out.println("ûѡ"); + return; + } + System.out.println("ѡ˵" + row + "ни"); + Object[] objData = new Object[ci.childComponentInfos.size()]; + for (int i = 0; i < objData.length; i++) { + objData[i] = ci.dataTableModel.getValueAt(row, i); + } + ci.dataTableModel.insertRow(row, objData); + } + + private void addActionListener() { + @SuppressWarnings("unchecked") + final JComboBox jcb = (JComboBox) fu.allComponentMap.get("ysr8_PartType"); + jcb.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + if (e.getStateChange() == ItemEvent.SELECTED) { + if("ɢ".equals(e.getItem())) { + partType = 1; + }else { + partType = 2; + } + } + } + + }); + JButton btn = (JButton) fu.allComponentMap.get("b.11.110"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + saveRendering(); + } + }); + + btn = (JButton) fu.allComponentMap.get("b.41.13.41"); // kk 0913 + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + copyRow(); + } + }); + + /*btn = (JButton) fu.allComponentMap.get("b.41.13.51"); // kk 0913 ɷ޵ + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + createFXD(); + } + });*/ + + /*btn = (JButton) fu.allComponentMap.get("b.11.111"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + });*/ + + btn = (JButton) fu.allComponentMap.get("b.41.13.11"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + iTextField textfield = (iTextField) fu.allComponentMap.get("ysr8_ManuPerson"); + String ysr8_ManuPersonVal = textfield.getText(); + + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.41.12.11"); + YSR8_INSPRecordDetailEditDialog dlg = new YSR8_INSPRecordDetailEditDialog(fu.session, partType, ysr8_ManuPersonVal, false); + dlg.showDlg(); + if (dlg.dialogResult() == AbstractAIFDialog.ID_OK) { + Object[] objData = new Object[ci.childComponentInfos.size()]; + for (int i = 0; i < objData.length; i++) { + DialogUtil.ComponentInfo cci = ci.childComponentInfos.get(i); + switch (cci.name) { + case "ysr8_PartCode": + objData[i] = dlg.ysr8_PartCodeVal; + break; + case "ysr8_PartName": + objData[i] = dlg.ysr8_PartNameVal; + break; + case "ysr8_UnqualifiedType": + objData[i] = dlg.ysr8_UnqualifiedTypeVal; + break; + case "ysr8_UnqualifiedType2": + objData[i] = dlg.ysr8_UnqualifiedType2Val; + break; + case "ysr8_UnqualifiedType3": + objData[i] = dlg.ysr8_UnqualifiedType3Val; + break; + case "ysr8_UnqualifiedType4": + objData[i] = dlg.ysr8_UnqualifiedType4Val; + break; + case "ysr8_UnqualifiedType5": + objData[i] = dlg.ysr8_UnqualifiedType5Val; + break; + case "ysr8_SubUnqualifiedQuantity": + objData[i] = dlg.ysr8_SubUnqualifiedQuantityVal; + break; + case "ysr8_PurchReasonDesc": + objData[i] = dlg.ysr8_PurchReasonDescVal; + break; + case "ysr8_Measures": + objData[i] = dlg.ysr8_MeasuresVal; + break; + case "ysr8_PurchPlanDate1": + objData[i] = dlg.ysr8_PurchPlanDate1Val; + break; + case "ysr8_DrawingReleaseDate": + objData[i] = dlg.ysr8_DrawingReleaseDateVal; + break; + case "ysr8_UnqualifiedDesc": + objData[i] = dlg.ysr8_UnqualifiedDescVal; + break; + case "ysr8_CompromiseAuthorizer": + objData[i] = dlg.ysr8_CompromiseAuthorizerVal; + break; + case "ysr8_FlowOutReason": + objData[i] = dlg.ysr8_FlowOutReasonVal; + break; + case "ysr8_ProduceReason": + objData[i] = dlg.ysr8_ProduceReasonVal; + break; + case "ysr8_YSRReason": + objData[i] = dlg.ysr8_YSRReasonVal; + break; + case "ysr8_FactorySurvey": + objData[i] = dlg.ysr8_FactorySurveyVal; + break; + case "ysr8_FactorySurveyQuantity": + objData[i] = dlg.ysr8_FactorySurveyQuantityVal; + break; + + // case "ysr8_SubQualityFinishDate": + // objData[i] = dlg.ysr8_SubQualityFinishDateVal; + // break; + // case "ysr8_SubQualityResult": + // objData[i] = dlg.ysr8_SubQualityResultVal; + // break; + case "ysr8_SubTaskManuState": + objData[i] = "1"; + break; + default: + objData[i] = ""; + break; + } + } + ci.dataTableModel.addRow(objData); + } + } + }); + + btn = (JButton) fu.allComponentMap.get("b.41.13.21"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + iTextField textfield = (iTextField) fu.allComponentMap.get("ysr8_ManuPerson"); + String ysr8_ManuPersonVal = textfield.getText(); + + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.41.12.11"); + JTable table = (JTable) fu.allComponentMap.get("a.41.12.11"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪ༭У", "ʾ", MessageBox.INFORMATION); + return; + } + YSR8_INSPRecordDetailEditDialog dlg = new YSR8_INSPRecordDetailEditDialog(fu.session, partType, ysr8_ManuPersonVal, false); + for (int i = 0; i < ci.childComponentInfos.size(); i++) { + DialogUtil.ComponentInfo cci = ci.childComponentInfos.get(i); + switch (cci.name) { + case "ysr8_PartCode": + dlg.ysr8_PartCodeVal = ci.dataTableModel.getValueAt(rows[0], i).toString(); + break; + case "ysr8_PartName": + dlg.ysr8_PartNameVal = ci.dataTableModel.getValueAt(rows[0], i).toString(); + break; + case "ysr8_UnqualifiedType": + dlg.ysr8_UnqualifiedTypeVal = ci.dataTableModel.getValueAt(rows[0], i).toString(); + break; + case "ysr8_UnqualifiedType2": + dlg.ysr8_UnqualifiedType2Val = ci.dataTableModel.getValueAt(rows[0], i).toString(); + break; + case "ysr8_UnqualifiedType3": + dlg.ysr8_UnqualifiedType3Val = ci.dataTableModel.getValueAt(rows[0], i).toString(); + break; + case "ysr8_UnqualifiedType4": + dlg.ysr8_UnqualifiedType4Val = ci.dataTableModel.getValueAt(rows[0], i).toString(); + break; + case "ysr8_UnqualifiedType5": + dlg.ysr8_UnqualifiedType5Val = ci.dataTableModel.getValueAt(rows[0], i).toString(); + break; + case "ysr8_SubUnqualifiedQuantity": + dlg.ysr8_SubUnqualifiedQuantityVal = ci.dataTableModel.getValueAt(rows[0], i).toString(); + break; + case "ysr8_PurchReasonDesc": + dlg.ysr8_PurchReasonDescVal = ci.dataTableModel.getValueAt(rows[0], i).toString(); + break; + case "ysr8_Measures": + dlg.ysr8_MeasuresVal = ci.dataTableModel.getValueAt(rows[0], i).toString(); + break; + case "ysr8_PurchPlanDate1": + dlg.ysr8_PurchPlanDate1Val = ci.dataTableModel.getValueAt(rows[0], i).toString(); + break; + case "ysr8_DrawingReleaseDate": + dlg.ysr8_DrawingReleaseDateVal = ci.dataTableModel.getValueAt(rows[0], i).toString(); + break; + case "ysr8_UnqualifiedDesc": + dlg.ysr8_UnqualifiedDescVal= ci.dataTableModel.getValueAt(rows[0], i).toString(); + break; + case "ysr8_CompromiseAuthorizer": + dlg.ysr8_CompromiseAuthorizerVal= ci.dataTableModel.getValueAt(rows[0], i).toString(); + break; + case "ysr8_ProduceReason": + dlg.ysr8_ProduceReasonVal= ci.dataTableModel.getValueAt(rows[0], i).toString(); + break; + case "ysr8_FlowOutReason": + dlg.ysr8_FlowOutReasonVal= ci.dataTableModel.getValueAt(rows[0], i).toString(); + break; + case "ysr8_YSRReason": + dlg.ysr8_YSRReasonVal= ci.dataTableModel.getValueAt(rows[0], i).toString(); + break; + case "ysr8_FactorySurvey": + dlg.ysr8_FactorySurveyVal= ci.dataTableModel.getValueAt(rows[0], i).toString(); + break; + case "ysr8_FactorySurveyQuantity": + dlg.ysr8_FactorySurveyQuantityVal= ci.dataTableModel.getValueAt(rows[0], i).toString(); + break; + // case "ysr8_SubQualityFinishDate": + // dlg.ysr8_SubQualityFinishDateVal = ci.dataTableModel.getValueAt(rows[0], i).toString(); + // break; + // case "ysr8_SubQualityResult": + // dlg.ysr8_SubQualityResultVal = ci.dataTableModel.getValueAt(rows[0], i).toString(); + // break; + default: + break; + } + } + dlg.showDlg(); + if (dlg.dialogResult() == AbstractAIFDialog.ID_OK) { + for (int i = 0; i < ci.childComponentInfos.size(); i++) { + DialogUtil.ComponentInfo cci = ci.childComponentInfos.get(i); + switch (cci.name) { + case "ysr8_PartCode": + ci.dataTableModel.setValueAt(dlg.ysr8_PartCodeVal, rows[0], i); + break; + case "ysr8_PartName": + ci.dataTableModel.setValueAt(dlg.ysr8_PartNameVal, rows[0], i); + break; + case "ysr8_UnqualifiedType": + ci.dataTableModel.setValueAt(dlg.ysr8_UnqualifiedTypeVal, rows[0], i); + break; + case "ysr8_UnqualifiedType2": + ci.dataTableModel.setValueAt(dlg.ysr8_UnqualifiedType2Val, rows[0], i); + break; + case "ysr8_UnqualifiedType3": + ci.dataTableModel.setValueAt(dlg.ysr8_UnqualifiedType3Val, rows[0], i); + break; + case "ysr8_UnqualifiedType4": + ci.dataTableModel.setValueAt(dlg.ysr8_UnqualifiedType4Val, rows[0], i); + break; + case "ysr8_UnqualifiedType5": + ci.dataTableModel.setValueAt(dlg.ysr8_UnqualifiedType5Val, rows[0], i); + break; + case "ysr8_SubUnqualifiedQuantity": + ci.dataTableModel.setValueAt(dlg.ysr8_SubUnqualifiedQuantityVal, rows[0], i); + break; + case "ysr8_PurchReasonDesc": + ci.dataTableModel.setValueAt(dlg.ysr8_PurchReasonDescVal, rows[0], i); + break; + case "ysr8_Measures": + ci.dataTableModel.setValueAt(dlg.ysr8_MeasuresVal, rows[0], i); + break; + case "ysr8_PurchPlanDate1": + ci.dataTableModel.setValueAt(dlg.ysr8_PurchPlanDate1Val, rows[0], i); + break; + case "ysr8_DrawingReleaseDate": + ci.dataTableModel.setValueAt(dlg.ysr8_DrawingReleaseDateVal, rows[0], i); + break; + case "ysr8_UnqualifiedDesc": + ci.dataTableModel.setValueAt(dlg.ysr8_UnqualifiedDescVal, rows[0], i); + break; + case "ysr8_CompromiseAuthorizer": + ci.dataTableModel.setValueAt(dlg.ysr8_CompromiseAuthorizerVal, rows[0], i); + break; + case "ysr8_ProduceReason": + ci.dataTableModel.setValueAt(dlg.ysr8_ProduceReasonVal, rows[0], i); + break; + case "ysr8_FlowOutReason": + ci.dataTableModel.setValueAt(dlg.ysr8_FlowOutReasonVal, rows[0], i); + break; + case "ysr8_YSRReason": + ci.dataTableModel.setValueAt(dlg.ysr8_YSRReasonVal, rows[0], i); + break; + case "ysr8_FactorySurvey": + ci.dataTableModel.setValueAt(dlg.ysr8_FactorySurveyVal, rows[0], i); + break; + case "ysr8_FactorySurveyQuantity": + ci.dataTableModel.setValueAt(dlg.ysr8_FactorySurveyQuantityVal, rows[0], i); + break; + // case "ysr8_SubQualityFinishDate": + // ci.dataTableModel.setValueAt(dlg.ysr8_SubQualityFinishDateVal, rows[0], i); + // break; + // case "ysr8_SubQualityResult": + // ci.dataTableModel.setValueAt(dlg.ysr8_SubQualityResultVal, rows[0], i); + // break; + default: + break; + } + } + } + } + }); + + btn = (JButton) fu.allComponentMap.get("b.41.13.31"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.41.12.11"); + JTable table = (JTable) fu.allComponentMap.get("a.41.12.11"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪƳУ", "ʾ", MessageBox.INFORMATION); + return; + } + for (int i = rows.length - 1; i >= 0; i--) { + ci.dataTableModel.removeRow(rows[i]); + } + } + }); + + /*btn = (JButton) fu.allComponentMap.get("b.51.13.11"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + addLocalPic(); + } + }); + + btn = (JButton) fu.allComponentMap.get("b.51.13.21"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + CreateDialogUtil.JTableInfo ci = (CreateDialogUtil.JTableInfo) fu.allComponentInfos.get("a.51.12.11"); + JTable table = (JTable) fu.allComponentMap.get("a.71.12.11"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪƳУ", "ʾ", MessageBox.INFORMATION); + return; + } + for (int i = rows.length - 1; i >= 0; i--) { + ci.dataTableModel.removeRow(rows[i]); + } + } + });*/ + iTextField component = (iTextField) fu.allComponentMap.get("ysr8_AssemNumber"); + component.addFocusListener(checkNumber); + } + private FocusListener checkNumber = new FocusListener(){ + + @Override + public void focusGained(FocusEvent arg0) { + + } + + @Override + public void focusLost(FocusEvent arg0) { + if(arg0.getComponent() instanceof iTextField){ + iTextField component = (iTextField)(arg0.getComponent()); + String text = component.getText(); + if(text!=null && !text.isEmpty()){ + if(text.startsWith(".")){ + text = "0" + text; + component.setText(text); + } + try { + new Double(text); + } catch(NumberFormatException e) { + MessageBox.post("Աд", "", 1); + component.setText(""); + } + } + } + } + + }; + + + private void saveRendering() { + if (!checkCanSave()) { + return; + } + try { + HashMap tableMap = new HashMap(); + iTextField textfield = (iTextField) fu.allComponentMap.get("Item_ID"); +// String itemId = textfield.getText(); + String prefix = ysr8_ProjectCodeVal + "-ZJ"; + String newIndex = KUtil.getNewINSPRecordNum(prefix, fu.session); + String itemId = prefix + newIndex; + textfield = (iTextField) fu.allComponentMap.get("ysr8_UnqualifiedQuantity"); + String unqualifiedStr = textfield.getText(); + double unqualifiedNum = KUtil.getDoubleFromString(unqualifiedStr, "ϸ"); + System.out.println("ϸ" + unqualifiedNum); + if (unqualifiedNum > 0) { + itemId = "FX-" + itemId; + } + fu.createItem(itemId, "ɢ¼"); + if (fu.newItem != null) { +// saveLocalPic(); + /////////////////////////////////////////////////// +// String ysr8_ProjectCodeVal = fu.newForm.getStringProperty("ysr8_ProjectCode"); + + // kk 0913 дע + /*JTextArea area = (JTextArea) fu.allComponentMap.get("ysr8_Remark"); + String remark=area.getText(); + fu.newForm.setStringProperty("ysr8_Remark", remark);*/ + + Vector attrVec = new Vector(); + Vector valVec = new Vector(); + + attrVec.add("Ŀ ID"); + valVec.add(ysr8_ProjectCodeVal); + attrVec.add(""); + if (partType == PARTTYPE_BJ) {// + String folderName = TCUtil.getPreference2(fu.session, TCPreferenceService.TC_preference_site, "YSR8_INSPRecordCreate_BJFolder"); + valVec.add(folderName); + } else if (partType == PARTTYPE_SJ) {// ɢ + String folderName = TCUtil.getPreference2(fu.session, TCPreferenceService.TC_preference_site, "YSR8_INSPRecordCreate_SJFolder"); + valVec.add(folderName); + } + String[] attrs = (String[]) attrVec.toArray(new String[attrVec.size()]); + String[] vals = (String[]) valVec.toArray(new String[attrVec.size()]); + + TCComponent[] tcComponents = TCUtil.query(fu.session, "SearchINSPFolder", attrs, vals); + if (tcComponents != null && tcComponents.length >= 1) { + TCComponentFolder parent = (TCComponentFolder) tcComponents[0]; + parent.add("contents", new TCComponent[] { fu.newItem }); + } + /////////////////////////////////////////////////// + if (JOptionPane.showConfirmDialog(this, "ɢ¼"+itemId+"ѴǷֱӷ̣", "ʾ", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { + String twName = TCUtil.getPreference2(fu.session, TCPreferenceService.TC_preference_site, "YSR8_INSPRecordCreate_AuditFW"); + TCComponentTaskTemplateType taskTemplateType = (TCComponentTaskTemplateType) fu.session.getTypeComponent("EPMTaskTemplate"); + TCComponentTaskTemplate taskTemplate = taskTemplateType.find(twName, 0); + TCComponentProcessType processType = (TCComponentProcessType) fu.session.getTypeComponent("EPMJob"); + processType.create(itemId, "", taskTemplate, new TCComponent[] { fu.newRevision }, new int[] { 1 }); + } + /////////////////////////////////////////////////// + + try { + // kk 0913 д + writeCreateResult(tableMap); + } catch (Exception e) { + MessageBox.post(this,"ɢ¼ɣдԵʼʱ\b"+e.toString(),"",MessageBox.ERROR); + e.printStackTrace(); + } + + qmb.updateValues(tableMap); + disposeDialog(); + } + } catch (Exception ex) { + ex.printStackTrace(); + MessageBox.post(this, ex); + return; + } + } + + // kk д + private void writeCreateResult(HashMap tableMap) throws Exception { + DateButton dateButton = (DateButton) fu.allComponentMap.get("ysr8_TestDate"); + // ʱдʼʱ + Date ysr8_TestDateVal = dateButton.getDate(); + HashMap valMap = new HashMap(); + if (partType == PARTTYPE_BJ) {// + for (int i = 0; i < parentObjs.size(); i++) { + Object object = parentObjs.get(i); + if (object instanceof TCComponentScheduleTask) { + TCComponentScheduleTask scheduTask = (TCComponentScheduleTask) object; + // lidy20190214⴦ + valMap.put("ysr8_SubQualityFinishDate", fu.getDateTimeString2(ysr8_TestDateVal)); + String partNumStr = scheduTask.getProperty("ysr8_PartNumber"); + String examinedStr = scheduTask.getProperty("ysr8_ExaminedQuantity"); + double partNum = 0; + double examined = 0; + try { + partNum = KUtil.getDoubleFromString(partNumStr, ""); + examined = KUtil.getDoubleFromString(examinedStr, "Ѽ"); + if (partNum == examined) { + valMap.put("ysr8_TaskManuState", KUtil.SCH_TASK_STATE_YIJIANYAN + ""); + } + } catch (Exception e) { + System.out.println(scheduTask + "" + e.getMessage()); + e.printStackTrace(); + } + + for (Entry entry : valMap.entrySet()) { + String key1 = entry.getKey(); + String key2 = entry.getValue(); + TCProperty property = (TCProperty) scheduTask.getTCProperty(key1); + switch (property.getPropertyType()) { + case TCProperty.PROP_string: + case TCProperty.PROP_long_string: + scheduTask.setStringProperty(key1, key2); + break; + case TCProperty.PROP_short: + case TCProperty.PROP_int: + scheduTask.setIntProperty(key1, Integer.parseInt(key2)); + break; + case TCProperty.PROP_double: + case TCProperty.PROP_float: + scheduTask.setDoubleProperty(key1, Double.parseDouble(key2)); + break; + case TCProperty.PROP_date: + if (!key2.equals("")) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date date = sdf.parse(key2); + if (date != null) { + scheduTask.setDateProperty(key1, date); + } + } + break; + default: + scheduTask.setStringProperty(key1, key2); + break; + } + } + tableMap = valMap; + } else if (object instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem) object; + TCComponentItemRevision revision = item.getLatestItemRevision(); + TCComponentForm form = TCUtil.getItemRevisionMasterForm(revision); + + String params = "", proName = "", proVal = ""; + + String object_typeVal = item.getProperty("object_type"); + if (object_typeVal.equals("ͼĿ¼")) { + { + //TODO lidy20190214⴦ + String key1 = "ysr8_SubQualityFinishDate"; + String key2 = Integer.toString(parentObjIdxs.get(i)) + "$$$$" + fu.getDateTimeString2(ysr8_TestDateVal); + tableMap.put("ysr8_SubQualityFinishDate", fu.getDateTimeString2(ysr8_TestDateVal)); + + if (proName.equals("")) { + proName = key1; + } else { + proName += "@@@@" + key1; + } + if (proVal.equals("")) { + proVal = key2; + } else { + proVal += "@@@@" + key2; + } + } + String partNumStr = form.getProperty("ysr8_PartNumber"); + String examinedStr = form.getProperty("ysr8_ExaminedQuantity"); + double partNum = 0; + double examined = 0; + try { + partNum = KUtil.getDoubleFromString(partNumStr, ""); + examined = KUtil.getDoubleFromString(examinedStr, "Ѽ"); + if (partNum == examined) { + // valMap.put("ysr8_TaskManuState", KUtil.SCH_TASK_STATE_YIJIANYAN+""); + { + String key1 = "ysr8_TaskManuState"; + String key2 = Integer.toString(parentObjIdxs.get(i)) + "$$$$" + KUtil.SCH_TASK_STATE_YIJIANYAN; + tableMap.put("ysr8_TaskManuState", ""+KUtil.SCH_TASK_STATE_YIJIANYAN); + + if (proName.equals("")) { + proName = key1; + } else { + proName += "@@@@" + key1; + } + if (proVal.equals("")) { + proVal = key2; + } else { + proVal += "@@@@" + key2; + } + } + } + } catch (Exception e) { + System.out.println(revision + "" + e.getMessage()); + e.printStackTrace(); + } + } + params = item.getProperty("item_id") + "^^^^" + proName + "^^^^" + proVal; + + TCUserService userService = fu.session.getUserService(); + Object[] objParams = new Object[2]; + String cmd = "Update_ItemRevForm_TCProperty"; + objParams[0] = cmd; + objParams[1] = params; + long startime = System.currentTimeMillis(); + String result = (String) userService.call("YSR8UserService", objParams); + long endtime = System.currentTimeMillis(); + System.out.println("Cʱ" + (endtime - startime) + ""); + System.out.println(result); + form.refresh(); + } + } + } else if (partType == PARTTYPE_SJ) {// ɢ + for (int i = 0; i < parentObjs.size(); i++) { + Object object = parentObjs.get(i); + if (object instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem) object; + TCComponentItemRevision revision = item.getLatestItemRevision(); + TCComponentForm form = TCUtil.getItemRevisionMasterForm(revision); + + String params = "", proName = "", proVal = ""; + String object_typeVal = item.getProperty("object_type"); + if (object_typeVal.equals("ͼֽĵ")) { + { + //TODO lidy20190214⴦ + String key1 = "ysr8_SubQualityFinishDate"; + String key2 = Integer.toString(parentObjIdxs.get(i)) + "$$$$" + fu.getDateTimeString2(ysr8_TestDateVal); + tableMap.put("ysr8_SubQualityFinishDate", fu.getDateTimeString2(ysr8_TestDateVal)); + + if (proName.equals("")) { + proName = key1; + } else { + proName += "@@@@" + key1; + } + if (proVal.equals("")) { + proVal = key2; + } else { + proVal += "@@@@" + key2; + } + } + TCProperty ysr8_Quantity = form.getFormTCProperty("ysr8_Quantity"); + double[] ysr8_QuantityVals = ysr8_Quantity.getDoubleArrayValue(); + double partNum = ysr8_QuantityVals[parentObjIdxs.get(i)]; + + TCProperty ysr8_ExaminedQuantity = form.getFormTCProperty("ysr8_ExaminedQuantity"); + String[] ysr8_ExaminedQuantityVals = ysr8_ExaminedQuantity.getStringArrayValue(); + String examinedStr = ysr8_ExaminedQuantityVals[parentObjIdxs.get(i)]; + double examined = 0; + try { + examined = KUtil.getDoubleFromString(examinedStr, "Ѽ"); + if (partNum == examined) { + // valMap.put("ysr8_TaskManuState", KUtil.SCH_TASK_STATE_YIJIANYAN+""); + { + String key1 = "ysr8_SubTaskManuState"; + String key2 = Integer.toString(parentObjIdxs.get(i)) + "$$$$" + KUtil.SCH_TASK_STATE_YIJIANYAN; + tableMap.put("ysr8_TaskManuState", ""+KUtil.SCH_TASK_STATE_YIJIANYAN); + + if (proName.equals("")) { + proName = key1; + } else { + proName += "@@@@" + key1; + } + if (proVal.equals("")) { + proVal = key2; + } else { + proVal += "@@@@" + key2; + } + } + } + } catch (Exception e) { + System.out.println(revision + "" + e.getMessage()); + e.printStackTrace(); + } + + } else if (object_typeVal.equals("ļӹ")) { + // kk ޸Ѽʼʱ + { + //TODO lidy20190214⴦ + String key1 = "ysr8_SubQualityFinishDate"; + String key2 = Integer.toString(parentObjIdxs.get(i)) + "$$$$" + fu.getDateTimeString2(ysr8_TestDateVal); + tableMap.put("ysr8_SubQualityFinishDate", fu.getDateTimeString2(ysr8_TestDateVal)); + + if (proName.equals("")) { + proName = key1; + } else { + proName += "@@@@" + key1; + } + if (proVal.equals("")) { + proVal = key2; + } else { + proVal += "@@@@" + key2; + } + } + TCProperty ysr8_Quantity = form.getFormTCProperty("ysr8_Quantity"); + double[] ysr8_QuantityVals = ysr8_Quantity.getDoubleArrayValue(); + double partNum = ysr8_QuantityVals[parentObjIdxs.get(i)]; + + TCProperty ysr8_ExaminedQuantity = form.getFormTCProperty("ysr8_ExaminedQuantity"); + String[] ysr8_ExaminedQuantityVals = ysr8_ExaminedQuantity.getStringArrayValue(); + String examinedStr = ysr8_ExaminedQuantityVals[parentObjIdxs.get(i)]; + double examined = 0; + try { + examined = KUtil.getDoubleFromString(examinedStr, "Ѽ"); + if (partNum == examined) { + // valMap.put("ysr8_TaskManuState", KUtil.SCH_TASK_STATE_YIJIANYAN+""); + { + String key1 = "ysr8_SubTaskManuState"; + String key2 = Integer.toString(parentObjIdxs.get(i)) + "$$$$" + KUtil.SCH_TASK_STATE_YIJIANYAN; + tableMap.put("ysr8_TaskManuState", ""+KUtil.SCH_TASK_STATE_YIJIANYAN); + + if (proName.equals("")) { + proName = key1; + } else { + proName += "@@@@" + key1; + } + if (proVal.equals("")) { + proVal = key2; + } else { + proVal += "@@@@" + key2; + } + } + } + } catch (Exception e) { + System.out.println(revision + "" + e.getMessage()); + e.printStackTrace(); + } + + } else if (object_typeVal.equals("ɢ¼")) { + // kk ޸Ѽʼʱ + { + //TODO lidy20190214⴦ + String key1 = "ysr8_SubQualityFinishDate"; + String key2 = Integer.toString(parentObjIdxs.get(i)) + "$$$$" + fu.getDateTimeString2(ysr8_TestDateVal); + tableMap.put("ysr8_SubQualityFinishDate", fu.getDateTimeString2(ysr8_TestDateVal)); + + if (proName.equals("")) { + proName = key1; + } else { + proName += "@@@@" + key1; + } + if (proVal.equals("")) { + proVal = key2; + } else { + proVal += "@@@@" + key2; + } + } + TCProperty ysr8_Quantity = form.getFormTCProperty("ysr8_SubUnqualifiedQuantity"); + String[] ysr8_QuantityVals = ysr8_Quantity.getStringArrayValue(); + String partNumStr = ysr8_QuantityVals[parentObjIdxs.get(i)]; + + TCProperty ysr8_ExaminedQuantity = form.getFormTCProperty("ysr8_ExaminedQuantity"); + String[] ysr8_ExaminedQuantityVals = ysr8_ExaminedQuantity.getStringArrayValue(); + String examinedStr = ysr8_ExaminedQuantityVals[parentObjIdxs.get(i)]; + double partNum=0; + double examined = 0; + try { + partNum=KUtil.getDoubleFromString(partNumStr, ""); + examined = KUtil.getDoubleFromString(examinedStr, "Ѽ"); + if (partNum == examined) { + // valMap.put("ysr8_TaskManuState", KUtil.SCH_TASK_STATE_YIJIANYAN+""); + { + String key1 = "ysr8_SubTaskManuState"; + String key2 = Integer.toString(parentObjIdxs.get(i)) + "$$$$" + KUtil.SCH_TASK_STATE_YIJIANYAN; + tableMap.put("ysr8_TaskManuState", ""+KUtil.SCH_TASK_STATE_YIJIANYAN); + + if (proName.equals("")) { + proName = key1; + } else { + proName += "@@@@" + key1; + } + if (proVal.equals("")) { + proVal = key2; + } else { + proVal += "@@@@" + key2; + } + } + } + } catch (Exception e) { + System.out.println(revision + "" + e.getMessage()); + e.printStackTrace(); + } + } + params = item.getProperty("item_id") + "^^^^" + proName + "^^^^" + proVal; + + TCUserService userService = fu.session.getUserService(); + Object[] objParams = new Object[2]; + String cmd = "Update_ItemRevForm_TCProperty"; + objParams[0] = cmd; + objParams[1] = params; + long startime = System.currentTimeMillis(); + String result = (String) userService.call("YSR8UserService", objParams); + long endtime = System.currentTimeMillis(); + System.out.println("Cʱ" + (endtime - startime) + ""); + System.out.println(result); + form.refresh(); + } + } + } + + } + + @SuppressWarnings("unchecked") + private void getDefVal() { + fu.getDefVal(); + + try { + iTextField textfield; +// String ysr8_ProjectCodeVal = ""; + String ysr8_ProjectManagerVal = ""; + if (partType == 2) {// + Object parentObj = parentObjs.get(0); + if (parentObj instanceof TCComponentScheduleTask) { + TCComponentScheduleTask scheduTask = (TCComponentScheduleTask) parentObj; + + ysr8_ProjectCodeVal = scheduTask.getProperty("ysr8_ProjectCode"); + textfield = (iTextField) fu.allComponentMap.get("ysr8_ProjectCode"); + textfield.setText(ysr8_ProjectCodeVal); + + ysr8_ProjectManagerVal = scheduTask.getProperty("ysr8_ProjectManager"); + textfield = (iTextField) fu.allComponentMap.get("ysr8_ProjectManager"); + textfield.setText(ysr8_ProjectManagerVal); + + JComboBox cbx = (JComboBox) fu.allComponentMap.get("ysr8_ManuFactory1"); + cbx.setSelectedItem(scheduTask.getProperty("ysr8_ManuFactory1")); + + cbx = (JComboBox) fu.allComponentMap.get("ysr8_ManuFactory2"); + cbx.setSelectedItem(scheduTask.getProperty("ysr8_ManuFactory2")); + + textfield = (iTextField) fu.allComponentMap.get("ysr8_ManuPerson"); + textfield.setText(scheduTask.getProperty("ysr8_ManuPerson")); + + String object_nameVal = scheduTask.getProperty("object_name"); + Vector object_nameVals = CommonUtil.split2Vector(object_nameVal, "-"); + if (object_nameVals.size() >= 2) { + textfield = (iTextField) fu.allComponentMap.get("ysr8_AssemCode"); + String code = ""; + for (int i = 0; i < object_nameVals.size() - 1; i++) { + code += object_nameVals.get(i); + } + textfield.setText(code); + textfield = (iTextField) fu.allComponentMap.get("ysr8_AssemName"); + textfield.setText(object_nameVals.get(object_nameVals.size() - 1)); + } + + // kk 0912 ;ѡ + String taskUse = scheduTask.getProperty("ysr8_TaskUse"); + cbx = (JComboBox) fu.allComponentMap.get("ysr8_PartType"); + if ("ӹ".equals(taskUse)) { + cbx.setSelectedItem(""); + } else if ("".equals(taskUse)) { + cbx.setSelectedItem(""); + } + + //kk 0914 װͼ汾 + textfield = (iTextField) fu.allComponentMap.get("ysr8_DrawingREV"); + textfield.setText(scheduTask.getProperty("ysr8_DrawingREV")); + + } else if (parentObj instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem)parentObj; + TCComponentItemRevision revision = item.getLatestItemRevision(); + TCComponentForm form = TCUtil.getItemRevisionMasterForm(revision); + + String object_typeVal = item.getProperty("object_type"); + if (object_typeVal.equals("ͼĿ¼")) { + ysr8_ProjectCodeVal = form.getProperty("ysr8_ProjectCode"); + textfield = (iTextField) fu.allComponentMap.get("ysr8_ProjectCode"); + textfield.setText(ysr8_ProjectCodeVal); + + ysr8_ProjectManagerVal = form.getProperty("ysr8_ProjectManager"); + textfield = (iTextField) fu.allComponentMap.get("ysr8_ProjectManager"); + textfield.setText(ysr8_ProjectManagerVal); + + TCProperty ysr8_SubManuFactory1 = form.getFormTCProperty("ysr8_ManuFactory1"); + String ysr8_SubManuFactory1Vals = ysr8_SubManuFactory1.getStringValue(); + JComboBox cbx = (JComboBox) fu.allComponentMap.get("ysr8_ManuFactory1"); + cbx.setSelectedItem(ysr8_SubManuFactory1Vals); + + TCProperty ysr8_SubManuFactory2 = form.getFormTCProperty("ysr8_ManuFactory2"); + String ysr8_SubManuFactory2Vals = ysr8_SubManuFactory2.getStringValue(); + cbx = (JComboBox) fu.allComponentMap.get("ysr8_ManuFactory2"); + cbx.setSelectedItem(ysr8_SubManuFactory2Vals); + + textfield = (iTextField) fu.allComponentMap.get("ysr8_ManuPerson"); + textfield.setText(form.getProperty("ysr8_ManuPerson")); + + cbx = (JComboBox) fu.allComponentMap.get("ysr8_PartType"); + cbx.setSelectedItem(""); + + //kk 0914 װͼ汾 + textfield = (iTextField) fu.allComponentMap.get("ysr8_DrawingREV"); + textfield.setText(form.getProperty("ysr8_DrawingREV")); + } + } + } else if (partType == 1) {// ɢ + Object parentObj = parentObjs.get(0); + Integer parentObjIdx = parentObjIdxs.get(0); + if (parentObj instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem) parentObj; + TCComponentItemRevision revision = item.getLatestItemRevision(); + TCComponentForm form = TCUtil.getItemRevisionMasterForm(revision); + + String object_typeVal = item.getProperty("object_type"); + if (object_typeVal.equals("ͼֽĵ")) { + ysr8_ProjectCodeVal = form.getProperty("ysr8_ProjectCode"); + textfield = (iTextField) fu.allComponentMap.get("ysr8_ProjectCode"); + textfield.setText(ysr8_ProjectCodeVal); + + ysr8_ProjectManagerVal = form.getProperty("ysr8_ProjectManager"); + textfield = (iTextField) fu.allComponentMap.get("ysr8_ProjectManager"); + textfield.setText(ysr8_ProjectManagerVal); + + TCProperty ysr8_SubManuFactory1 = form.getFormTCProperty("ysr8_SubManuFactory1"); + String[] ysr8_SubManuFactory1Vals = ysr8_SubManuFactory1.getStringArrayValue(); + JComboBox cbx = (JComboBox) fu.allComponentMap.get("ysr8_ManuFactory1"); + cbx.setSelectedItem(ysr8_SubManuFactory1Vals[parentObjIdx]); + + TCProperty ysr8_SubManuFactory2 = form.getFormTCProperty("ysr8_SubManuFactory2"); + String[] ysr8_SubManuFactory2Vals = ysr8_SubManuFactory2.getStringArrayValue(); + cbx = (JComboBox) fu.allComponentMap.get("ysr8_ManuFactory2"); + cbx.setSelectedItem(ysr8_SubManuFactory2Vals[parentObjIdx]); + + textfield = (iTextField) fu.allComponentMap.get("ysr8_ManuPerson"); + textfield.setText(form.getProperty("ysr8_ManuPerson")); + + cbx = (JComboBox) fu.allComponentMap.get("ysr8_PartType"); + cbx.setSelectedItem("ɢ"); + + //kk 0914 װͼ汾 + textfield = (iTextField) fu.allComponentMap.get("ysr8_DrawingREV"); + textfield.setText(form.getProperty("ysr8_DrawingREV")); + + } else if (object_typeVal.equals("ļӹ")) { + ysr8_ProjectCodeVal = form.getProperty("ysr8_ProjectCode"); + textfield = (iTextField) fu.allComponentMap.get("ysr8_ProjectCode"); + textfield.setText(ysr8_ProjectCodeVal); + + ysr8_ProjectManagerVal = form.getProperty("ysr8_ProjectManager"); + textfield = (iTextField) fu.allComponentMap.get("ysr8_ProjectManager"); + textfield.setText(ysr8_ProjectManagerVal); + + TCProperty ysr8_SubManuFactory1 = form.getFormTCProperty("ysr8_SubManuFactory1"); + String[] ysr8_SubManuFactory1Vals = ysr8_SubManuFactory1.getStringArrayValue(); + JComboBox cbx = (JComboBox) fu.allComponentMap.get("ysr8_ManuFactory1"); + cbx.setSelectedItem(ysr8_SubManuFactory1Vals[parentObjIdx]); + + TCProperty ysr8_SubManuFactory2 = form.getFormTCProperty("ysr8_SubManuFactory2"); + String[] ysr8_SubManuFactory2Vals = ysr8_SubManuFactory2.getStringArrayValue(); + cbx = (JComboBox) fu.allComponentMap.get("ysr8_ManuFactory2"); + cbx.setSelectedItem(ysr8_SubManuFactory2Vals[parentObjIdx]); + + textfield = (iTextField) fu.allComponentMap.get("ysr8_ManuPerson"); + textfield.setText(form.getProperty("ysr8_ManuPerson")); + + cbx = (JComboBox) fu.allComponentMap.get("ysr8_PartType"); + cbx.setSelectedItem("ɢ"); + + //kk 0914 װͼ汾 + textfield = (iTextField) fu.allComponentMap.get("ysr8_DrawingREV"); + textfield.setText(form.getProperty("ysr8_DrawingREV")); + + } else if (object_typeVal.equals("ɢ¼")) { + ysr8_ProjectCodeVal = form.getProperty("ysr8_ProjectCode"); + textfield = (iTextField) fu.allComponentMap.get("ysr8_ProjectCode"); + textfield.setText(ysr8_ProjectCodeVal); + + ysr8_ProjectManagerVal = form.getProperty("ysr8_ProjectManager"); + textfield = (iTextField) fu.allComponentMap.get("ysr8_ProjectManager"); + textfield.setText(ysr8_ProjectManagerVal); + + TCProperty ysr8_ManuFactory1 = form.getFormTCProperty("ysr8_ManuFactory1"); + String ysr8_ManuFactory1Val = ysr8_ManuFactory1.getStringValue(); + JComboBox cbx = (JComboBox) fu.allComponentMap.get("ysr8_ManuFactory1"); + cbx.setSelectedItem(ysr8_ManuFactory1Val); + + TCProperty ysr8_ManuFactory2 = form.getFormTCProperty("ysr8_ManuFactory2"); + String ysr8_ManuFactory2Val = ysr8_ManuFactory2.getStringValue(); + cbx = (JComboBox) fu.allComponentMap.get("ysr8_ManuFactory2"); + cbx.setSelectedItem(ysr8_ManuFactory2Val); + + textfield = (iTextField) fu.allComponentMap.get("ysr8_ManuPerson"); + textfield.setText(form.getProperty("ysr8_ManuPerson")); + + cbx = (JComboBox) fu.allComponentMap.get("ysr8_PartType"); + cbx.setSelectedItem("ɢ"); + + //kk 0914 װͼ汾 + textfield = (iTextField) fu.allComponentMap.get("ysr8_DrawingREV"); + textfield.setText(form.getProperty("ysr8_DrawingREV")); + + /* + * TCProperty ysr8_PartType = form.getFormTCProperty("ysr8_PartType"); String + * ysr8_PartTypeVal = ysr8_PartType.getStringValue(); if + * (ysr8_PartTypeVal.equals("2")) { cbx.setSelectedItem(""); } else if + * (ysr8_PartTypeVal.equals("1")) { cbx.setSelectedItem("ɢ"); } + */ + } + } + } + // kk 0913 ȡˮ +// String prefix = ysr8_ProjectCodeVal + "-ZJ"; +// String newIndex = KUtil.getNewINSPRecordNum(prefix, fu.session); +// String Item_ID = prefix + newIndex; +// textfield = (iTextField) fu.allComponentMap.get("Item_ID"); +// textfield.setText(Item_ID); + TCComponentUser user = fu.session.getUser(); + /* + * String user_id = user.getProperty("user_id").toString(); SimpleDateFormat sdf + * = new SimpleDateFormat("yyyyMMddHHmmss"); String curDate = sdf.format(new + * Date()); String Item_ID = ysr8_ProjectCodeVal + ("_") + user_id + ("_") + + * curDate; + */ + TCComponentItem xmqdItem = TCUtil.findItemByID(fu.session, ysr8_ProjectCodeVal + "_XMQD"); + if (xmqdItem == null) { + return; + } + TCComponentItemRevision xmqdRevision = xmqdItem.getLatestItemRevision(); + TCComponentForm xmqdForm = TCUtil.getItemRevisionMasterForm(xmqdRevision); + textfield = (iTextField) fu.allComponentMap.get("ysr8_Planner"); + textfield.setText(xmqdForm.getProperty("ysr8_Planner")); + + textfield = (iTextField) fu.allComponentMap.get("ysr8_Tester"); + textfield.setText(user.getProperty("user_name").toString()); + } catch (Exception e) { + MessageBox.post(this, e.toString(), "ݳ", MessageBox.ERROR); + e.printStackTrace(); + } + } + + public boolean checkCanSave() { + iTextField textfield = (iTextField) fu.allComponentMap.get("ysr8_TestNumber"); + String ysr8_TestNumberVal = TCUtil.getNumber(textfield.getText()); + textfield.setText(ysr8_TestNumberVal); + if (ysr8_TestNumberVal.equals("")) { + MessageBox.post("[]д...", "", MessageBox.ERROR); + return false; + } + try { + int numInt=Integer.parseInt(ysr8_TestNumberVal); + if(numInt<0) { + MessageBox.post(this,"[]Ϊ", "ʾ", MessageBox.INFORMATION); + return false; + } + } catch (NumberFormatException e) { + MessageBox.post(this,"[]д", "ʾ", MessageBox.INFORMATION); + e.printStackTrace(); + return false; + } + + textfield = (iTextField) fu.allComponentMap.get("ysr8_UnqualifiedQuantity"); + String ysr8_UnqualifiedQuantityVal = TCUtil.getNumber(textfield.getText()); + textfield.setText(ysr8_UnqualifiedQuantityVal); + if (ysr8_UnqualifiedQuantityVal.equals("")) { + MessageBox.post("[ϸ]д...", "", MessageBox.ERROR); + return false; + } + try { + int numInt=Integer.parseInt(ysr8_UnqualifiedQuantityVal); + if(numInt<0) { + MessageBox.post(this,"[ϸ]Ϊ", "ʾ", MessageBox.INFORMATION); + return false; + } + } catch (NumberFormatException e) { + MessageBox.post(this,"[ϸ]д", "ʾ", MessageBox.INFORMATION); + e.printStackTrace(); + return false; + } + + textfield = (iTextField) fu.allComponentMap.get("ysr8_Tester"); + String ysr8_TesterVal = textfield.getText(); + if (ysr8_TesterVal.equals("")) { + MessageBox.post("[Ա]д...", "", MessageBox.ERROR); + return false; + } + + DateButton dateButton = (DateButton) fu.allComponentMap.get("ysr8_TestDate"); + Date ysr8_TestDateVal = dateButton.getDate(); + if (ysr8_TestDateVal == null) { + MessageBox.post("[ʱ]д...", "", MessageBox.ERROR); + return false; + } + + textfield = (iTextField) fu.allComponentMap.get("ysr8_AssemNumber"); + String text = textfield.getText(); + if(text!=null && !text.isEmpty()){ + if(text.startsWith(".")){ + text = "0" + text; + textfield.setText(text); + } + try { + new Double(text); + } catch(NumberFormatException e) { + MessageBox.post("Աд", "", 1); + textfield.setText(""); + return false; + } + } + + return true; + } + + /*private void saveLocalPic() { + Vector addPic = new Vector(); + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.51.12.11"); + for (int l = 0; l < ci.dataTableModel.getRowCount(); l++) { + if (ci.dataTableModel.getValueAt(l, 0) == null || ci.dataTableModel.getValueAt(l, 1) == null) { + continue; + } else { + String sign = ci.dataTableModel.getValueAt(l, 0).toString(); + if (sign.equalsIgnoreCase("")) { + String fileName = ci.dataTableModel.getValueAt(l, 1).toString(); + addPic.add(fileName); + } + } + } + + TCComponentItemRevision itemRevision = fu.newRevision; + try { + for (String pic : addPic) { + File file = new File(pic); + TCComponentDataset newDataset = TCUtil.createDataset(fu.session, file, file.getName()); + itemRevision.add("IMAN_specification", new TCComponent[] { newDataset }); + } + } catch (TCException e1) { + e1.printStackTrace(); + } + }*/ + + /*private void setLov(JComboBox jcb, String lov) { + try { + TCComponentListOfValuesType lovType = (TCComponentListOfValuesType)qmb.session.getTypeComponent("ListOfValues"); + TCComponentListOfValues[] lovs = lovType.find(lov); + if(lovs.length>0) { + Map lovValue = lovs[0].getListOfValues().getValueTable(); + jcb.removeAllItems(); + jcb.addItem(""); + for(String s : lovValue.values()) { + jcb.addItem(s); + } + } + } catch (TCException e) { + e.printStackTrace(); + } + }*/ +} diff --git a/src/cn/com/ebewin/ysr/dialog/YSR8_INSPRecordDetailEditDialog.java b/src/cn/com/ebewin/ysr/dialog/YSR8_INSPRecordDetailEditDialog.java new file mode 100644 index 0000000..bd8f735 --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/YSR8_INSPRecordDetailEditDialog.java @@ -0,0 +1,467 @@ +package cn.com.ebewin.ysr.dialog; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JTextArea; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentRole; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.iTextField; + +import cn.com.ebewin.ysr.util.DialogUtil; +import cn.com.ebewin.ysr.util.TCUtil; + +@SuppressWarnings("deprecation") +public class YSR8_INSPRecordDetailEditDialog extends AbstractAIFDialog { + private static final long serialVersionUID = 1L; + private DialogUtil fu = new DialogUtil(this, "༭ϸ", "YSR8_INSPRecordDetailEditDialog"); + + // private int partType = 2; + // private String ysr8_ManuPersonVal = ""; + + private Boolean isInTask = false; + private Boolean isTaskMachiner = false; + private Boolean isQualitySurvey = false; + private Boolean isPurcher = false; + + public String ysr8_PartCodeVal = ""; + public String ysr8_PartNameVal = ""; + public String ysr8_UnqualifiedTypeVal = ""; + public String ysr8_UnqualifiedType2Val = ""; + public String ysr8_UnqualifiedType3Val = ""; + public String ysr8_UnqualifiedType4Val = ""; + public String ysr8_UnqualifiedType5Val = ""; + public String ysr8_SubUnqualifiedQuantityVal = ""; + public String ysr8_PurchReasonDescVal = ""; + public String ysr8_MeasuresVal = ""; + public String ysr8_PurchPlanDate1Val = ""; + public String ysr8_DrawingReleaseDateVal = ""; + + public String ysr8_UnqualifiedDescVal = ""; + public String ysr8_CompromiseAuthorizerVal=""; + public String ysr8_ProduceReasonVal=""; + public String ysr8_FlowOutReasonVal=""; + public String ysr8_YSRReasonVal=""; + public String ysr8_FactorySurveyVal=""; + public String ysr8_FactorySurveyQuantityVal=""; +// public String ysr8_ExaminingQuantity="0"; + //ysr8_CompromiseAuthorizerVal + //ysr8_ProduceReasonVal + //ysr8_FlowOutReasonVal + //ysr8_YSRReasonVal + + // public String ysr8_SubQualityFinishDateVal = ""; + // public String ysr8_SubQualityResultVal = ""; + + public YSR8_INSPRecordDetailEditDialog(TCSession session, int partType, String ysr8_ManuPersonVal, Boolean isInTask) { + super(true); + + this.isInTask = isInTask; +// this.ysr8_ExaminingQuantity = ysr8_ExaminingQuantity; + try { + TCComponentUser user = session.getUser(); + Map> groupMap = user.getGroupRolesTable(); + Iterator>> iter = groupMap.entrySet().iterator(); + while (iter.hasNext()) { + Map.Entry> entry = (Map.Entry>) iter.next(); + System.out.println(entry.getKey().getGroupName()); + if(entry.getKey().getGroupName().equals("ɹ")) { + isPurcher = true; + } + if (isInTask) { + List roleList = entry.getValue(); + for (TCComponentRole role : roleList) { + if (role.getStringProperty("role_name").equals("TaskMachiner")) { + isTaskMachiner = true; + } else if (role.getStringProperty("role_name").equals("QualitySurvey")) { + isQualitySurvey = true; + } + } + } + } + } catch (TCException e) { + e.printStackTrace(); + } + + // this.partType = partType; +// if (partType == 1) {// ɢ//TODO lidy20190328ϸLOVϲ +// } else if (partType == 2) {// +// CreateDialogUtil.JComboBoxInfo ci1 = (CreateDialogUtil.JComboBoxInfo) fu.allComponentInfos.get("ysr8_UnqualifiedType"); +// ci1.valueName = "YSR8_INSPR4_LOV"; +// CreateDialogUtil.JComboBoxInfo ci2 = (CreateDialogUtil.JComboBoxInfo) fu.allComponentInfos.get("ysr8_UnqualifiedType2"); +// ci2.valueName = "YSR8_INSPR4_LOV"; +// CreateDialogUtil.JComboBoxInfo ci3 = (CreateDialogUtil.JComboBoxInfo) fu.allComponentInfos.get("ysr8_UnqualifiedType3"); +// ci3.valueName = "YSR8_INSPR4_LOV"; +// CreateDialogUtil.JComboBoxInfo ci4 = (CreateDialogUtil.JComboBoxInfo) fu.allComponentInfos.get("ysr8_UnqualifiedType4"); +// ci4.valueName = "YSR8_INSPR4_LOV"; +// CreateDialogUtil.JComboBoxInfo ci5 = (CreateDialogUtil.JComboBoxInfo) fu.allComponentInfos.get("ysr8_UnqualifiedType5"); +// ci5.valueName = "YSR8_INSPR4_LOV"; +// +// // CreateDialogUtil.JComboBoxInfo ci2 = +// // (CreateDialogUtil.JComboBoxInfo)fu.allComponentInfos.get("ysr8_SubQualityResult"); +// // ci2.valueName = "YSR8_INSPR3_LOV"; +// } + + fu.initializeUI(session); + } + + public void showDlg() { + centerToScreen(); + loadRendering(); + addActionListener(); + getDefVal(); + setVisible(true); + } + + @SuppressWarnings("unchecked") + private void loadRendering() { + dialogResultId = ID_CANCEL; + iTextField ysr8_PartCode = (iTextField) fu.allComponentMap.get("ysr8_PartCode"); + ysr8_PartCode.setText(ysr8_PartCodeVal); + iTextField ysr8_PartName = (iTextField) fu.allComponentMap.get("ysr8_PartName"); + ysr8_PartName.setText(ysr8_PartNameVal); + JTextArea ysr8_UnqualifiedDesc = (JTextArea) fu.allComponentMap.get("ysr8_UnqualifiedDesc"); + ysr8_UnqualifiedDesc.setText(ysr8_UnqualifiedDescVal); + iTextField ysr8_CompromiseAuthorizer=(iTextField) fu.allComponentMap.get("ysr8_CompromiseAuthorizer"); + ysr8_CompromiseAuthorizer.setText(ysr8_CompromiseAuthorizerVal); + JComboBox ysr8_ProduceReason = (JComboBox) fu.allComponentMap.get("ysr8_ProduceReason"); + ysr8_ProduceReason.setSelectedItem(ysr8_ProduceReasonVal); + JComboBox ysr8_FlowOutReason = (JComboBox) fu.allComponentMap.get("ysr8_FlowOutReason"); + ysr8_FlowOutReason.setSelectedItem(ysr8_FlowOutReasonVal); + JComboBox ysr8_YSRReason = (JComboBox) fu.allComponentMap.get("ysr8_YSRReason"); + ysr8_YSRReason.setSelectedItem(ysr8_YSRReasonVal); + + JComboBox ysr8_UnqualifiedType = (JComboBox) fu.allComponentMap.get("ysr8_UnqualifiedType"); + ysr8_UnqualifiedType.setSelectedItem(ysr8_UnqualifiedTypeVal); + JComboBox ysr8_UnqualifiedType2 = (JComboBox) fu.allComponentMap.get("ysr8_UnqualifiedType2"); + ysr8_UnqualifiedType2.setSelectedItem(ysr8_UnqualifiedType2Val); + JComboBox ysr8_UnqualifiedType3 = (JComboBox) fu.allComponentMap.get("ysr8_UnqualifiedType3"); + ysr8_UnqualifiedType3.setSelectedItem(ysr8_UnqualifiedType3Val); + JComboBox ysr8_UnqualifiedType4 = (JComboBox) fu.allComponentMap.get("ysr8_UnqualifiedType4"); + ysr8_UnqualifiedType4.setSelectedItem(ysr8_UnqualifiedType4Val); + JComboBox ysr8_UnqualifiedType5 = (JComboBox) fu.allComponentMap.get("ysr8_UnqualifiedType5"); + ysr8_UnqualifiedType5.setSelectedItem(ysr8_UnqualifiedType5Val); + iTextField ysr8_SubUnqualifiedQuantity = (iTextField) fu.allComponentMap.get("ysr8_SubUnqualifiedQuantity"); + ysr8_SubUnqualifiedQuantity.setText(ysr8_SubUnqualifiedQuantityVal); + + iTextField ysr8_PurchReasonDesc = (iTextField) fu.allComponentMap.get("ysr8_PurchReasonDesc"); + ysr8_PurchReasonDesc.setText(ysr8_PurchReasonDescVal); + + + JComboBox ysr8_Measures = (JComboBox) fu.allComponentMap.get("ysr8_Measures"); + ysr8_Measures.setSelectedItem(ysr8_MeasuresVal); + + DateButton ysr8_PurchPlanDate1 = (DateButton) fu.allComponentMap.get("ysr8_PurchPlanDate1"); + ysr8_PurchPlanDate1.setDate(fu.getDateFromString(ysr8_PurchPlanDate1Val)); + DateButton ysr8_DrawingReleaseDate = (DateButton) fu.allComponentMap.get("ysr8_DrawingReleaseDate"); + ysr8_DrawingReleaseDate.setDate(fu.getDateFromString(ysr8_DrawingReleaseDateVal)); + + JComboBox ysr8_FactorySurvey = (JComboBox) fu.allComponentMap.get("ysr8_FactorySurvey"); +// ysr8_FactorySurvey.removeAll(); + ysr8_FactorySurvey.removeItem(""); + ysr8_FactorySurvey.addItem("");//lidy20190328 ӷѡΪĬֵ + ysr8_FactorySurvey.addItem(""); + ysr8_FactorySurvey.setSelectedItem(ysr8_FactorySurveyVal.equals("")?"":ysr8_FactorySurveyVal); + iTextField ysr8_FactorySurveyQuantity = (iTextField) fu.allComponentMap.get("ysr8_FactorySurveyQuantity"); + ysr8_FactorySurveyQuantity.setText(ysr8_FactorySurveyQuantityVal); + // DateButton ysr8_SubQualityFinishDate = + // (DateButton)fu.allComponentMap.get("ysr8_SubQualityFinishDate"); + // ysr8_SubQualityFinishDate.setDate(fu.getDateFromString(ysr8_SubQualityFinishDateVal)); + // JComboBox ysr8_SubQualityResult = + // (JComboBox)fu.allComponentMap.get("ysr8_SubQualityResult"); + // ysr8_SubQualityResult.setSelectedItem(ysr8_SubQualityResultVal); + + if (isInTask) { + if (isQualitySurvey) { + ysr8_PartCode.setEnabled(true); + ysr8_UnqualifiedType.setEnabled(true); + ysr8_UnqualifiedType2.setEnabled(true); + ysr8_UnqualifiedType3.setEnabled(true); + ysr8_UnqualifiedType4.setEnabled(true); + ysr8_UnqualifiedType5.setEnabled(true); + ysr8_SubUnqualifiedQuantity.setEnabled(true); + + ysr8_PurchReasonDesc.setEnabled(false); + ysr8_Measures.setEnabled(false); + ysr8_PurchPlanDate1.setEnabled(false); + ysr8_DrawingReleaseDate.setEnabled(false); + ysr8_PartName.setEnabled(false); + // ysr8_SubQualityFinishDate.setEnabled(false); + // ysr8_SubQualityResult.setEnabled(false); + } else if (isTaskMachiner) { + ysr8_PurchReasonDesc.setEnabled(true); + ysr8_Measures.setEnabled(true); + ysr8_PurchPlanDate1.setEnabled(true); + ysr8_DrawingReleaseDate.setEnabled(true); + + ysr8_PartCode.setEnabled(false); + ysr8_PartName.setEnabled(false); + ysr8_UnqualifiedType.setEnabled(false); + ysr8_UnqualifiedType2.setEnabled(false); + ysr8_UnqualifiedType3.setEnabled(false); + ysr8_UnqualifiedType4.setEnabled(false); + ysr8_UnqualifiedType5.setEnabled(false); + ysr8_SubUnqualifiedQuantity.setEnabled(false); + // ysr8_SubQualityFinishDate.setEnabled(false); + // ysr8_SubQualityResult.setEnabled(false); + } + + } else { + ysr8_PartCode.setEnabled(true); + ysr8_UnqualifiedType.setEnabled(true); + ysr8_UnqualifiedType2.setEnabled(true); + ysr8_UnqualifiedType3.setEnabled(true); + ysr8_UnqualifiedType4.setEnabled(true); + ysr8_UnqualifiedType5.setEnabled(true); + ysr8_SubUnqualifiedQuantity.setEnabled(true); + + //kk + + + // TCComponentUser user = fu.session.getUser(); + // if (ysr8_ManuPersonVal.equals(user.getProperty("user_name"))) { + // ysr8_PurchReasonDesc.setEnabled(true); + // ysr8_Measures.setEnabled(true); + // ysr8_PurchPlanDate1.setEnabled(true); + // } else { + // ysr8_PurchReasonDesc.setEnabled(false); + // ysr8_Measures.setEnabled(false); + // ysr8_PurchPlanDate1.setEnabled(false); + // } + } + + if(isPurcher) { + ysr8_PurchReasonDesc.setEnabled(true); + ysr8_PurchPlanDate1.setEnabled(true); + ysr8_DrawingReleaseDate.setEnabled(true); + ysr8_Measures.setEnabled(true); + ysr8_CompromiseAuthorizer.setEnabled(true); + + ysr8_PartCode.setEnabled(false); + ysr8_PartName.setEnabled(false); + ysr8_UnqualifiedType.setEnabled(false); + ysr8_UnqualifiedType2.setEnabled(false); + ysr8_UnqualifiedType3.setEnabled(false); + ysr8_UnqualifiedType4.setEnabled(false); + ysr8_UnqualifiedType5.setEnabled(false); + ysr8_SubUnqualifiedQuantity.setEnabled(false); + ysr8_ProduceReason.setEnabled(false); + ysr8_FlowOutReason.setEnabled(false); + ysr8_YSRReason.setEnabled(false); + ysr8_FactorySurvey.setEnabled(false); + ysr8_FactorySurveyQuantity.setEnabled(false); + ysr8_UnqualifiedDesc.setEnabled(false); + + } + } + + private void addActionListener() { + JButton btn = (JButton) fu.allComponentMap.get("b.61.12"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + saveRendering(); + } + }); + + btn = (JButton) fu.allComponentMap.get("b.61.14"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + dialogResultId = ID_CANCEL; + disposeDialog(); + } + }); + + } + + @SuppressWarnings("unchecked") + private void saveRendering() { + if (!checkCanSave()) { + return; + } + // ysr8_UnqualifiedDesc + // kk 0913 ϸ + JTextArea ysr8_UnqualifiedDesc = (JTextArea) fu.allComponentMap.get("ysr8_UnqualifiedDesc"); + ysr8_UnqualifiedDescVal = ysr8_UnqualifiedDesc.getText(); + iTextField ysr8_CompromiseAuthorizer = (iTextField) fu.allComponentMap.get("ysr8_CompromiseAuthorizer"); + ysr8_CompromiseAuthorizerVal = ysr8_CompromiseAuthorizer.getText(); + JComboBox ysr8_ProduceReason = (JComboBox) fu.allComponentMap.get("ysr8_ProduceReason"); + if (ysr8_ProduceReason.getSelectedItem() != null) { + ysr8_ProduceReasonVal = ysr8_ProduceReason.getSelectedItem().toString(); + } else { + ysr8_ProduceReasonVal = ""; + } + JComboBox ysr8_FlowOutReason = (JComboBox) fu.allComponentMap.get("ysr8_FlowOutReason"); + if (ysr8_FlowOutReason.getSelectedItem() != null) { + ysr8_FlowOutReasonVal = ysr8_FlowOutReason.getSelectedItem().toString(); + } else { + ysr8_FlowOutReasonVal = ""; + } + JComboBox ysr8_YSRReason = (JComboBox) fu.allComponentMap.get("ysr8_YSRReason"); + if (ysr8_YSRReason.getSelectedItem() != null) { + ysr8_YSRReasonVal = ysr8_YSRReason.getSelectedItem().toString(); + } else { + ysr8_YSRReasonVal = ""; + } + + iTextField ysr8_PartCode = (iTextField) fu.allComponentMap.get("ysr8_PartCode"); + ysr8_PartCodeVal = ysr8_PartCode.getText().toString(); + iTextField ysr8_PartName = (iTextField) fu.allComponentMap.get("ysr8_PartName"); + ysr8_PartNameVal = ysr8_PartName.getText().toString(); + + JComboBox ysr8_UnqualifiedType = (JComboBox) fu.allComponentMap.get("ysr8_UnqualifiedType"); + if (ysr8_UnqualifiedType.getSelectedItem() != null) { + ysr8_UnqualifiedTypeVal = ysr8_UnqualifiedType.getSelectedItem().toString(); + } else { + ysr8_UnqualifiedTypeVal = ""; + } + JComboBox ysr8_UnqualifiedType2 = (JComboBox) fu.allComponentMap.get("ysr8_UnqualifiedType2"); + if (ysr8_UnqualifiedType2.getSelectedItem() != null) { + ysr8_UnqualifiedType2Val = ysr8_UnqualifiedType2.getSelectedItem().toString(); + } else { + ysr8_UnqualifiedType2Val = ""; + } + JComboBox ysr8_UnqualifiedType3 = (JComboBox) fu.allComponentMap.get("ysr8_UnqualifiedType3"); + if (ysr8_UnqualifiedType3.getSelectedItem() != null) { + ysr8_UnqualifiedType3Val = ysr8_UnqualifiedType3.getSelectedItem().toString(); + } else { + ysr8_UnqualifiedType3Val = ""; + } + JComboBox ysr8_UnqualifiedType4 = (JComboBox) fu.allComponentMap.get("ysr8_UnqualifiedType4"); + if (ysr8_UnqualifiedType4.getSelectedItem() != null) { + ysr8_UnqualifiedType4Val = ysr8_UnqualifiedType4.getSelectedItem().toString(); + } else { + ysr8_UnqualifiedType4Val = ""; + } + JComboBox ysr8_UnqualifiedType5 = (JComboBox) fu.allComponentMap.get("ysr8_UnqualifiedType5"); + if (ysr8_UnqualifiedType5.getSelectedItem() != null) { + ysr8_UnqualifiedType5Val = ysr8_UnqualifiedType5.getSelectedItem().toString(); + } else { + ysr8_UnqualifiedType5Val = ""; + } + iTextField ysr8_SubUnqualifiedQuantity = (iTextField) fu.allComponentMap.get("ysr8_SubUnqualifiedQuantity"); + ysr8_SubUnqualifiedQuantityVal = ysr8_SubUnqualifiedQuantity.getText().toString(); + + iTextField ysr8_PurchReasonDesc = (iTextField) fu.allComponentMap.get("ysr8_PurchReasonDesc"); + ysr8_PurchReasonDescVal = ysr8_PurchReasonDesc.getText().toString(); + JComboBox ysr8_Measures = (JComboBox) fu.allComponentMap.get("ysr8_Measures"); + if (ysr8_Measures.getSelectedItem() != null) { + ysr8_MeasuresVal = ysr8_Measures.getSelectedItem().toString(); + } else { + ysr8_MeasuresVal = ""; + } + + DateButton ysr8_PurchPlanDate1 = (DateButton) fu.allComponentMap.get("ysr8_PurchPlanDate1"); + ysr8_PurchPlanDate1Val = fu.getDateTimeString(ysr8_PurchPlanDate1.getDate()); + DateButton ysr8_DrawingReleaseDate = (DateButton) fu.allComponentMap.get("ysr8_DrawingReleaseDate"); + ysr8_DrawingReleaseDateVal = fu.getDateTimeString(ysr8_DrawingReleaseDate.getDate()); + + JComboBox ysr8_FactorySurvey = (JComboBox) fu.allComponentMap.get("ysr8_FactorySurvey"); + if (ysr8_FactorySurvey.getSelectedItem() == null || ysr8_FactorySurvey.getSelectedItem().equals("")) { + ysr8_FactorySurveyVal = ""; + } else if(ysr8_FactorySurvey.getSelectedItem().equals("")){ + ysr8_FactorySurveyVal = ""; + } else { + ysr8_FactorySurveyVal = ""; + } +// System.out.println("ysr8_FactorySurveyVal:"+ysr8_FactorySurveyVal); + iTextField ysr8_FactorySurveyQuantity = (iTextField) fu.allComponentMap.get("ysr8_FactorySurveyQuantity"); + ysr8_FactorySurveyQuantityVal = ysr8_FactorySurveyQuantity.getText(); + // DateButton ysr8_SubQualityFinishDate = + // (DateButton)fu.allComponentMap.get("ysr8_SubQualityFinishDate"); + // ysr8_SubQualityFinishDateVal = + // fu.getDateString(ysr8_SubQualityFinishDate.getDate()); + // JComboBox ysr8_SubQualityResult = + // (JComboBox)fu.allComponentMap.get("ysr8_SubQualityResult"); + // if (ysr8_SubQualityResult.getSelectedItem() != null) { + // ysr8_SubQualityResultVal = + // ysr8_SubQualityResult.getSelectedItem().toString(); + // } else { + // ysr8_SubQualityResultVal = ""; + // } + + dialogResultId = ID_OK; + disposeDialog(); + } + + private void getDefVal() { + fu.getDefVal(); + } + + public boolean checkCanSave() { + try { + iTextField ysr8_PartCode = (iTextField) fu.allComponentMap.get("ysr8_PartCode"); + String _ysr8_PartCodeVal = ysr8_PartCode.getText().toString(); + if (_ysr8_PartCodeVal.isEmpty()) { + MessageBox.post(this,"д[㲿ͼ]", "ʾ", MessageBox.INFORMATION); + return false; + } + TCComponentItem partItem = TCUtil.findItemByID(fu.session, _ysr8_PartCodeVal); + if (partItem == null) { + MessageBox.post(this,"㲿ͼŲЧͼţ޸ijȷͼţ", "ʾ", MessageBox.INFORMATION); + return false; + } + iTextField ysr8_PartName = (iTextField) fu.allComponentMap.get("ysr8_PartName"); + String _ysr8_PartNameVal = partItem.getProperty("object_name"); + ysr8_PartName.setText(_ysr8_PartNameVal); + iTextField ysr8_SubUnqualifiedQuantity = (iTextField) fu.allComponentMap.get("ysr8_SubUnqualifiedQuantity"); + String num = TCUtil.getNumber(ysr8_SubUnqualifiedQuantity.getText()); + ysr8_SubUnqualifiedQuantity.setText(num); + if("".equals(num)) { + MessageBox.post(this,"ϸδд", "ʾ", MessageBox.INFORMATION); + return false; + } + try { + int numInt=Integer.parseInt(num); +// int ExaminingQuantity=Integer.parseInt(ysr8_ExaminingQuantity); + if(numInt<0) { + MessageBox.post(this,"ϸΪ", "ʾ", MessageBox.INFORMATION); + return false; + } +// if(numInt>ExaminingQuantity) { +// MessageBox.post(this,"ϸóμ", "ʾ", MessageBox.INFORMATION); +// return false; +// } + } catch (NumberFormatException e) { + MessageBox.post(this,"ϸд", "ʾ", MessageBox.INFORMATION); + e.printStackTrace(); + return false; + } + //lidy20190628ӹԼ + iTextField ysr8_FactorySurveyQuantity = (iTextField) fu.allComponentMap.get("ysr8_FactorySurveyQuantity"); + String FactorySurveyQuantity=TCUtil.getNumber(ysr8_FactorySurveyQuantity.getText()); + ysr8_FactorySurveyQuantity.setText(FactorySurveyQuantity); + try { + int numInt=Integer.parseInt(FactorySurveyQuantity); + if(numInt<0) { + MessageBox.post(this,"ӹԼΪ", "ʾ", MessageBox.INFORMATION); + return false; + } + } catch (NumberFormatException e) { + MessageBox.post(this,"ӹԼд", "ʾ", MessageBox.INFORMATION); + e.printStackTrace(); + return false; + } + } catch (TCException e) { + MessageBox.post(this,""+e.toString(), "ʾ", MessageBox.INFORMATION); + e.printStackTrace(); + return false; + } + + return true; + } + +} diff --git a/src/cn/com/ebewin/ysr/dialog/YSR8_PMSBRevisionEditDialog.java b/src/cn/com/ebewin/ysr/dialog/YSR8_PMSBRevisionEditDialog.java new file mode 100644 index 0000000..8203822 --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/YSR8_PMSBRevisionEditDialog.java @@ -0,0 +1,162 @@ +package cn.com.ebewin.ysr.dialog; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.JButton; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.iTextField; + +import cn.com.ebewin.ysr.util.DialogUtil; + +@SuppressWarnings("deprecation") +public class YSR8_PMSBRevisionEditDialog extends AbstractAIFDialog { + private static final long serialVersionUID = 1L; + private DialogUtil fu = new DialogUtil(this, "޸", "YSR8_PMSBRevisionEditDialog"); + + private TCComponentForm[] editObject = null; + private YSR8_PMSBRevisionSearchDialog search = null; + private int row = -1; + private String val0 = ""; + + public YSR8_PMSBRevisionEditDialog(TCSession session,YSR8_PMSBRevisionSearchDialog search, int row, TCComponentForm[] editObject, String val0) throws TCException { + super(true); + + this.editObject = editObject; + this.search = search; + this.row = row; + this.val0 = val0; + + fu.initializeUI(session); + centerToScreen(); + loadRendering(); + addActionListener(); + getDefVal(); + setVisible(true); + } + + private void loadRendering() throws TCException { + } + + private void addActionListener() { + JButton btn = (JButton)fu.allComponentMap.get("b.41.12"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + saveRendering(); + } + }); + + btn = (JButton)fu.allComponentMap.get("b.41.14"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + } + + private void saveRendering() { + if (!checkCanSave()) { + return; + } + + iTextField ysr8_Coefficient = (iTextField)fu.allComponentMap.get("ysr8_Coefficient"); + iTextField ysr8_PreAcceptanceRate = (iTextField)fu.allComponentMap.get("ysr8_PreAcceptanceRate"); + iTextField ysr8_AcceptanceRate = (iTextField)fu.allComponentMap.get("ysr8_AcceptanceRate"); + iTextField ysr8_ProjectSRemark = (iTextField)fu.allComponentMap.get("ysr8_ProjectSRemark"); + + String ysr8_CoefficientVal = ysr8_Coefficient.getText(); + String ysr8_PreAcceptanceRateVal = ysr8_PreAcceptanceRate.getText(); + String ysr8_AcceptanceRateVal = ysr8_AcceptanceRate.getText(); + String ysr8_ProjectSRemarkVal = ysr8_ProjectSRemark.getText(); + + DateButton db = (DateButton)fu.allComponentMap.get("ysr8_PlanDeliveryDate"); + String ysr8_PlanDeliveryDate = fu.getDateString(db.getDate()); + db = (DateButton)fu.allComponentMap.get("ysr8_ActualAcceptanceDate"); + String ysr8_ActualAcceptanceDate = fu.getDateString(db.getDate()); + + try { +// editObject.setProperty("ysr8_Coefficient", ysr8_CoefficientVal); +// editObject.setProperty("ysr8_PreAcceptanceRate", ysr8_PreAcceptanceRateVal); +// editObject.setProperty("ysr8_AcceptanceRate", ysr8_AcceptanceRateVal); +// editObject.refresh(); + + String params0 = "", proName0 = "", proVal0 = ""; +// proName0 = "ysr8_PlanDeliveryDate" + "@@@@" + "ysr8_Ratio" + "@@@@" + "ysr8_PreAcceptanceRate" + "@@@@" + "ysr8_AcceptanceRate"; +// proVal0 = ysr8_PlanDeliveryDate + "@@@@" + ysr8_CoefficientVal + "@@@@" + ysr8_PreAcceptanceRateVal + "@@@@" + ysr8_AcceptanceRateVal; + proName0 = "ysr8_PlanDeliveryDate" + "@@@@" + "ysr8_Ratio" + "@@@@" + "ysr8_PreAcceptanceRate" + "@@@@" + "ysr8_AcceptanceRate" + "@@@@" + "ysr8_ActualAcceptanceDate" + "@@@@" + "ysr8_ProjectSRemark"; + proVal0 = ysr8_PlanDeliveryDate + "@@@@" + ysr8_CoefficientVal + "@@@@" + ysr8_PreAcceptanceRateVal + "@@@@" + ysr8_AcceptanceRateVal + "@@@@" + ysr8_ActualAcceptanceDate + "@@@@" + ysr8_ProjectSRemarkVal; + params0 = editObject[0].getStringProperty("ysr8_ProjectCode") + "_XMQD" + "^^^^" + proName0 + "^^^^" + proVal0; + Object[] objParams0 = new Object[2]; + String cmd0 = "Update_ItemRevForm_TCProperty"; + objParams0[0] = cmd0; + objParams0[1] = params0; + System.out.println("cmd0" + cmd0); + System.out.println("params0" + params0); + + Object[] objParams = new Object[2]; + if(editObject[1]!=null) { + String params = "", proName = "", proVal = ""; + proName = "ysr8_Coefficient" + "@@@@" + "ysr8_PreAcceptanceRate" + "@@@@" + "ysr8_AcceptanceRate"; + proVal = ysr8_CoefficientVal + "@@@@" + ysr8_PreAcceptanceRateVal + "@@@@" + ysr8_AcceptanceRateVal; + params = editObject[1].getUid() + "^^^^" + proName + "^^^^" + proVal; + String cmd = "Update_Form_TCProperty"; + objParams[0] = cmd; + objParams[1] = params; + System.out.println("cmd" + cmd); + System.out.println("params" + params); + } + + TCUserService userService = fu.session.getUserService(); + String result = ""; + long startime = System.currentTimeMillis(); + String result0 = (String) userService.call("YSR8UserService", objParams0); + if(editObject[1]!=null) + result = (String) userService.call("YSR8UserService", objParams); + long endtime = System.currentTimeMillis(); + System.out.println("Cʱ" + (endtime - startime) + ""); + System.out.println("Ŀ֪ͨ"+result0+"\nµĿ壺"+result); + editObject[0].refresh(); + if(editObject[1]!=null) + editObject[1].refresh(); + search.setChengeValue(row, proVal0); + + disposeDialog(); + } catch (TCException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } + } + + private void getDefVal() { + fu.getDefVal(); + String[] vals = val0.split("@@@@", -1); + for(int i=0; i pfForms = new Vector(); + Vector psRevisionForms = new Vector(); + Map col = new HashMap(); + TCSession session; + + public YSR8_PMSBRevisionSearchDialog(TCSession session) throws TCException { + //super(true); + + this.session = session; + fu.initializeUI(session); + //centerToScreen(); + this.setLocationRelativeTo(null); + this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); + + col.put("ʱ()", 25); + col.put("ͬ", 33); + col.put("ɱ", 34); + col.put("ϵ", 35); + col.put("", 36); + col.put("ǰԤ", 38); + col.put("ǰ", 39); + col.put("ձ", 40); + col.put("ս", 41); + col.put("ʵʱ", 32); + col.put("ע", 44); + + JTable table = (JTable)fu.allComponentMap.get("a.21.11.11"); + DefaultTableCellRenderer right = new DefaultTableCellRenderer(); + right.setHorizontalAlignment(SwingConstants.RIGHT); + table.getColumnModel().getColumn(col.get("ͬ")).setCellRenderer(right); + table.getColumnModel().getColumn(col.get("ɱ")).setCellRenderer(right); + table.getColumnModel().getColumn(col.get("")).setCellRenderer(right); + table.getColumnModel().getColumn(col.get("ǰ")).setCellRenderer(right); + table.getColumnModel().getColumn(col.get("ս")).setCellRenderer(right); + + + loadRendering(); + addActionListener(); + setVisible(true); + } + + private void loadRendering() throws TCException { + } + + private void addActionListener() { + @SuppressWarnings({ "unchecked", "rawtypes" }) + JComboBox cb = (JComboBox)fu.allComponentMap.get("DateName"); + cb.setEditable(false); + cb.addItem("Ŀ"); + cb.addItem("һη"); + cb.addItem(""); + cb.addItem("߱"); + + JButton btnS = (JButton)fu.allComponentMap.get("b.11.12.11"); + btnS.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + searchYSR8_PMSBR(); + } + }); + + JButton btn = (JButton)fu.allComponentMap.get("b.11.12.12"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + editYSR8_ProjectForm(); + } + }); + + btn = (JButton)fu.allComponentMap.get("b.11.12.13"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + outputYSR8_PMSBR(); + } + }); + } + + private void searchYSR8_PMSBR() { + JButton btn = (JButton)fu.allComponentMap.get("b.11.12.11"); + btn.setText("ѯ..."); +// setEnable(false); + DecimalFormat df = new DecimalFormat(",###,###.00"); + pfForms.clear(); + psRevisionForms.clear(); + JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a.21.11.11"); + int nRowCount = ci.dataTableModel.getRowCount(); + for(int i=nRowCount-1; i>=0; i--){ + ci.dataTableModel.removeRow(i); + } + ci.dataTableModel.getDataVector().clear(); + + Map DateNames = new HashMap<>(); + DateNames.put("Ŀ", "StartDate"); + DateNames.put("һη", "ActualFactoryDate"); + DateNames.put("", "FinalDeliveryTime"); + DateNames.put("߱", "ActualAcceptanceDate"); + @SuppressWarnings({ "unchecked", "rawtypes" }) + JComboBox cb = (JComboBox)fu.allComponentMap.get("DateName"); + iTextField itf = (iTextField)fu.allComponentMap.get("c_ysr8_ProjectCode"); + String code = itf.getText(); + itf = (iTextField)fu.allComponentMap.get("c_ysr8_ProjectManager"); + String manager = itf.getText(); + itf = (iTextField)fu.allComponentMap.get("c_ysr8_Planner"); + String planner = itf.getText(); + + DateButton db = (DateButton)fu.allComponentMap.get("c_ysr8_Date1"); + Date date1 = db.getDate(); + String ysr8_Date1 = ""; + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-d"); + if (date1 != null) { + ysr8_Date1 = sdf.format(date1) + " 00:00"; + } + + db = (DateButton)fu.allComponentMap.get("c_ysr8_Date2"); + Date date2 = db.getDate(); + String ysr8_Date2 = ""; + if (date2 != null) { + ysr8_Date2 = sdf.format(date2) + " 23:59"; + } + if (code.isEmpty() && manager.isEmpty() && planner.isEmpty() && ysr8_Date1.isEmpty() && ysr8_Date2.isEmpty()) { + MessageBox.post("ѯ", "ʾ", MessageBox.INFORMATION); + btn.setText("ѯ"); + return; + } + if (((String) cb.getSelectedItem()).isEmpty() && (!ysr8_Date1.isEmpty() || !ysr8_Date2.isEmpty())) { + MessageBox.post("ѡͣ", "ʾ", MessageBox.INFORMATION); + btn.setText("ѯ"); + return; + } + String select = (String) cb.getSelectedItem(); + + Vector attrVec = new Vector(); + Vector valVec = new Vector(); + + if (!code.equals("")) { + attrVec.add("ProjectCode"); + valVec.add(code); + } + if (!manager.equals("")) { + attrVec.add("ProjectManager"); + valVec.add(manager); + } + if (!planner.equals("")) { + attrVec.add("Planner"); + valVec.add(planner); + } + if (!ysr8_Date1.equals("")) { + attrVec.add(DateNames.get(select) + "1"); + valVec.add(select.equals("")?String.format("%tF", date1):ysr8_Date1); + } + if (!ysr8_Date2.equals("")) { + attrVec.add(DateNames.get(select) + "2"); + valVec.add(select.equals("")?String.format("%tF", date2):ysr8_Date2); + } + String ysr8_ProjectCode = null; + + try { + + TCComponentUser user = fu.session.getUser(); + String group = fu.session.getGroup().toString(); + if(group.indexOf(".")>0) + group = group.substring(0, group.indexOf(".")); + Boolean inACL = false; + Boolean isManager = false; + TCComponentACLType type = (TCComponentACLType)fu.session.getTypeComponent("AM_ACL"); + TCComponentACL acl = type.find("YSR8_SaleOrder_acl"); + TCComponent[] accessors= acl.getAccessors(); + for(TCComponent c : accessors) { +// System.out.println(user.toString()+"("+group+"/"+fu.session.getRole()+")=="+c.toString()); + if(c.toString().indexOf(" (")>0) { + if(user.toString().equals(c.toString())) { + inACL = true; + break; + } + } +// else { +// if(group.equals(c.toString())) { +// inACL = true; +// break; +// } +// } + } + String[] Managers = TCUtil.getPreference(fu.session, TCPreferenceService.TC_preference_site, "YSR_PMSBManagers"); + for(String c : Managers) { +// System.out.println(user.toString()+"=="+c.toString()); + if(user.getProperty("user_name").equals(c)) { + isManager = true; + break; + } + } + + String[] attrs = (String[]) attrVec.toArray(new String[attrVec.size()]); + String[] vals = (String[]) valVec.toArray(new String[attrVec.size()]); + System.out.println("ѯSearchPMSBPSĿ="+ArrayUtil.toString(attrs)+"ֵ="+ArrayUtil.toString(vals)); + TCComponent[] tcComponents = TCUtil.query(fu.session, "SearchPMSBPS", attrs, vals); + Integer idx = 0; + for (int i = 0; i < tcComponents.length; i++) { + //lidy20181017ѯĿ֪ͨ + TCComponentItemRevision psRevision = (TCComponentItemRevision)tcComponents[i]; + TCComponentForm psRevisionForm = TCUtil.getItemRevisionMasterForm(psRevision); + ysr8_ProjectCode = psRevisionForm.getProperty("ysr8_ProjectCode"); + System.out.println("ȡysr8_ProjectCode="+ysr8_ProjectCode); + if (ysr8_ProjectCode.equals("")) { + continue; + } + psRevisionForms.add(psRevisionForm); + + TCComponentSchedule schedule = TCUtil.findScheduleByProjectID(session, ysr8_ProjectCode); + if(schedule!=null) { + TCComponent form = schedule.getRelatedComponent("IMAN_reference"); + if(form instanceof TCComponentForm) + pfForms.add((TCComponentForm)form); + else + pfForms.add(null); + } else + pfForms.add(null); + + Vector vec = new Vector<>(); + Double jqrsl = 0.0; + String jqrxhStr=""; + try { + jqrsl = fu.getDoubleFromString(psRevisionForm.getProperty("ysr8_MotomanQuantity")); + } catch(NumberFormatException e) { + System.out.println(""+psRevisionForm.getProperty("ysr8_MotomanQuantity")+"Сʽ"); + } + jqrxhStr = psRevisionForm.getFormTCProperty("ysr8_MotomanType").getStringValue(); + + vec.add((++idx) + "");// + vec.add(psRevisionForm.getStringProperty("ysr8_QuotationNo"));//ίе + vec.add(ysr8_ProjectCode);// + vec.add(psRevisionForm.getProperty("ysr8_ProjectCategory"));// + vec.add(psRevisionForm.getStringProperty("ysr8_OrderManufacturer"));//û + vec.add(psRevisionForm.getStringProperty("ysr8_CustomerName"));//û + vec.add(psRevisionForm.getStringProperty("ysr8_Sales"));// + vec.add(psRevisionForm.getStringProperty("ysr8_ProjectManager"));//Ŀ + vec.add(psRevisionForm.getStringProperty("ysr8_Planner"));//ƻԱ + vec.add(psRevisionForm.getStringProperty("ysr8_Factory"));// + vec.add(psRevisionForm.getStringProperty("ysr8_Section"));//Ʊ + vec.add(psRevisionForm.getProperty("ysr8_Use"));//; + vec.add(psRevisionForm.getProperty("ysr8_Product"));//Ʒ + vec.add(psRevisionForm.getStringProperty("ysr8_ProjectName"));//Ŀ + ///////////////////////////////////////////////////////////////////////////// + Double jjsl = 0.0, fjsl = 0.0, aql = 0.0, bwj = 0.0; + System.out.println("ѯ...Ŀ=ItemIDType"+"ֵ="+ysr8_ProjectCode+"YSR8_SystemParts"); + TCComponent[] comps = TCUtil.query(fu.session, "...", new String[] { "ItemID", "Type" }, new String[] { ysr8_ProjectCode, "YSR8_SystemParts" }); + if (comps != null && comps.length > 0) { + TCComponentItemRevision spRevision = ((TCComponentItem)comps[0]).getLatestItemRevision(); + TCComponentBOMLine pbomLine = TCUtil.getBOMLine(fu.session, spRevision); + if (pbomLine != null) { + AIFComponentContext[] context = pbomLine.getChildren(); + for (int j = 0; j < context.length; j++) { + TCComponentBOMLine bomLine = (TCComponentBOMLine) context[j].getComponent(); + TCComponentItemRevision cspRevision = bomLine.getItemRevision(); +// System.out.println(ysr8_ProjectCode+"===="+cspRevision.getProperty("object_type")); + if(cspRevision.getProperty("object_type").equals("Mach Parts Revision")) { + String quantity = bomLine.getProperty("bl_quantity"); + quantity = quantity.isEmpty() ? "1" : quantity; + TCComponentForm cspRevisionForm = TCUtil.getItemRevisionMasterForm(cspRevision); + String ysr8_SubProjectClassVal = cspRevisionForm.getProperty("ysr8_SubProjectClass"); + if (ysr8_SubProjectClassVal.equals("о")) { + jjsl += Double.parseDouble(quantity); + } else if (ysr8_SubProjectClassVal.equals("ȫ")) { + aql += Double.parseDouble(quantity); + } else if (ysr8_SubProjectClassVal.equals("λ")) { + bwj += Double.parseDouble(quantity); + } else { + fjsl += Double.parseDouble(quantity); + } + } + } + } + } + vec.add(fu.getDoubleString(jjsl));//о + vec.add(fu.getDoubleString(fjsl));// + vec.add(fu.getDoubleString(aql));//ȫ + vec.add(fu.getDoubleString(bwj));//λ + ///////////////////////////////////////////////////////////////////////////// + /*List jqrxh=new ArrayList<>(); + comps = TCUtil.query(fu.session, "...", new String[] { "ItemID", "Type" }, new String[] { ysr8_ProjectCode + "_JQR*", "YSR8_MotomanC" }); + if (comps != null && comps.length > 0) { + for (int j = 0; j < comps.length; j++) { + TCComponentItemRevision psRevision = ((TCComponentItem)comps[j]).getLatestItemRevision(); + TCComponentForm psRevisionForm = TCUtil.getItemRevisionMasterForm(mcRevision); + double doubleval = fu.getDoubleFromString(mcRevisionForm.getProperty("ysr8_OrderQuantity1")); + jqrsl += doubleval; + + String strval = psRevisionForm.getFormTCProperty("ysr8_MotomanType").getStringValue(); + if (!strval.equals("")) { + // 0803 kk ͺźϲͬ + if(!jqrxh.contains(strval)) { + jqrxh.add(strval); + } + } + } + }*/ + //kk 0803 ղŸĴˣλù仯 + /*for (String str : jqrxh) { + if("".equals(jqrxhStr)) { + jqrxhStr=str; + }else{ + jqrxhStr=jqrxhStr+","+str; + } + }*/ + vec.add(fu.getDoubleString(jqrsl));// + vec.add(jqrxhStr);//ͺ + ///////////////////////////////////////////////////////////////////////////// + TCComponentItemRevision soRevision = null; + TCComponentForm soRevisionForm = null; + TCComponentItemRevision spRevision = null; + TCComponentForm spRevisionForm = null; + + attrVec = new Vector(); + valVec = new Vector(); + attrVec.add("ysr8_ProjectCode"); valVec.add(ysr8_ProjectCode); + attrs = (String[]) attrVec.toArray(new String[attrVec.size()]); + vals = (String[]) valVec.toArray(new String[attrVec.size()]); + System.out.println("ѯSearchSaleOrderSearchSaleProjectĿysr8_ProjectCode="+ysr8_ProjectCode); + TCComponent[] tcdhtzComponents = TCUtil.query(fu.session, "SearchSaleOrder", attrs, vals); + if (tcdhtzComponents.length > 0) { + soRevision = (TCComponentItemRevision)tcdhtzComponents[0]; + soRevisionForm = TCUtil.getItemRevisionMasterForm(soRevision); + } +// System.out.println(ysr8_ProjectCode+"SearchSaleOrder:"+soRevision); + TCComponent[] tcqdtzComponents = TCUtil.query(fu.session, "SearchSaleProject", attrs, vals); + if (tcqdtzComponents.length > 0) { + if (tcqdtzComponents.length > 1) { + tcqdtzComponents = TCUtil.TCFormsort(tcqdtzComponents, "ysr8_ReleseDate", false); + } + spRevision = (TCComponentItemRevision)tcqdtzComponents[0]; + spRevisionForm = TCUtil.getItemRevisionMasterForm(spRevision); + } +// System.out.println(ysr8_ProjectCode+"SearchSaleProject:"+spRevision); + ///////////////////////////////////////////////////////////////////////////// + String ysr8_ApproverDateVal = ""; + if (soRevisionForm != null) { + ysr8_ApproverDateVal = soRevisionForm.getProperty("ysr8_ApproverDate").replace(".", "-"); + } + vec.add(ysr8_ApproverDateVal);//· + ysr8_ApproverDateVal = ""; + if (spRevisionForm != null) { + ysr8_ApproverDateVal = spRevisionForm.getProperty("ysr8_ApproverDate"); + } + vec.add(ysr8_ApproverDateVal.replace(".", "-"));//ʱ + vec.add(psRevisionForm.getDateProperty("ysr8_StartDate")==null?"":String.format("%tF", psRevisionForm.getDateProperty("ysr8_StartDate")));//ϵͳʱ + String ysr8_ReleseDateVal = ""; + if (soRevisionForm != null) { + ysr8_ReleseDateVal = String.format("%tF", soRevisionForm.getDateProperty("ysr8_ReleseDate")); + } + vec.add(ysr8_ReleseDateVal);//ǩͬ + ///////////////////////////////////////////////////////////////////////////// +// attrVec = new Vector(); +// valVec = new Vector(); +// attrVec.add(";"); valVec.add("12"); +// attrVec.add("Ŀ ID"); valVec.add(ysr8_ProjectCode); +// attrs = (String[]) attrVec.toArray(new String[attrVec.size()]); +// vals = (String[]) valVec.toArray(new String[attrVec.size()]); + // TODO lidy20181017ʱ䣨֪ͨԴ + /*TCComponent[] schedulTasks = TCUtil.query(fu.session, "SearchSchedulTask", attrs, vals); + if (schedulTasks != null) { + Date maxDate = new Date(2000, 1, 1); + Boolean find = false; + for (int l = 0; l < schedulTasks.length; l++) { + TCComponentScheduleTask scheduTask = (TCComponentScheduleTask)schedulTasks[l]; + scheduTask.refresh(); + Date currDate = scheduTask.getDateProperty("finish_date"); + if (currDate != null && currDate.after(maxDate)) { + maxDate = currDate; + find = true; + } + } + if (find) { +// vec.add(fu.getDateString(maxDate));//ʱ(֪ͨ) + vec.add(String.format("%tF", maxDate));//ʱ(֪ͨ) + } else { + vec.add("");//ʱ(֪ͨ) + } + } else { + vec.add("");//ʱ(֪ͨ) + }*/ + String ysr8_DeliveryDate = ""; + ysr8_DeliveryDate = (psRevisionForm.getDateProperty("ysr8_CriticalDate")==null?"":String.format("%tF", psRevisionForm.getDateProperty("ysr8_CriticalDate"))); + vec.add(ysr8_DeliveryDate);//ʱ(֪ͨ) + String ysr8_PlanDeliveryDate = ""; + ysr8_PlanDeliveryDate = (psRevisionForm.getDateProperty("ysr8_PlanDeliveryDate")==null?"":String.format("%tF", psRevisionForm.getDateProperty("ysr8_PlanDeliveryDate"))); + vec.add(ysr8_PlanDeliveryDate);//ʱ() + ///////////////////////////////////////////////////////////////////////////// + String ysr8_DeliveryDateVal = ""; + if (soRevisionForm != null) { + ysr8_DeliveryDateVal = String.format("%tF", soRevisionForm.getDateProperty("ysr8_DeliveryDate")); + } + if (ysr8_DeliveryDateVal == ""&&spRevisionForm != null) { + ysr8_DeliveryDateVal = String.format("%tF", spRevisionForm.getDateProperty("ysr8_DeliveryDate")); + } + vec.add(ysr8_DeliveryDateVal);//ʱ䣨ͬ + vec.add(psRevisionForm.getDateProperty("ysr8_ActualFactoryDate")==null ? + "":String.format("%tF", psRevisionForm.getDateProperty("ysr8_ActualFactoryDate")));//ηʱ + vec.add(psRevisionForm.getProperty("ysr8_FinalDeliveryTime"));//ȫʱ + ///////////////////////////////////////////////////////////////////////////// + String ysr8_aqccqk = ""; +// String ysr8_ActualFactoryDate = pfForm.getProperty("ysr8_ActualFactoryDate"); +// System.out.println(ysr8_ActualFactoryDate); +// String ysr8_PlanDeliveryDate = pfForm.getProperty("ysr8_PlanDeliveryDate"); + String ysr8_ActualFactoryDate = (psRevisionForm.getDateProperty("ysr8_ActualFactoryDate")==null ? + "":String.format("%tF", psRevisionForm.getDateProperty("ysr8_ActualFactoryDate"))); + // TODO lidy20181017ڳ + if (ysr8_ActualFactoryDate == null || ysr8_ActualFactoryDate.isEmpty()) { + ysr8_aqccqk = ""; + } else { + if (ysr8_PlanDeliveryDate == null || ysr8_PlanDeliveryDate.isEmpty()) { + if (ysr8_DeliveryDate == null || ysr8_DeliveryDate.isEmpty()) { + ysr8_aqccqk = ""; + } else { + int nn = CommonUtil.getDaysBetween(ysr8_DeliveryDate, ysr8_ActualFactoryDate); + if (nn <= 0) { + + ysr8_aqccqk = "OK"; + } + else{ + ysr8_aqccqk = "NG"; + } + } + } else { + int nn = CommonUtil.getDaysBetween(ysr8_PlanDeliveryDate, ysr8_ActualFactoryDate); + if (nn <= 0) { + + ysr8_aqccqk = "OK"; + } + else{ + ysr8_aqccqk = "NG"; + } + } + } + vec.add(ysr8_aqccqk);//ڳ + ///////////////////////////////////////////////////////////////////////////// + vec.add(psRevisionForm.getDateProperty("ysr8_ProductionDate")==null? + "":String.format("%tF", psRevisionForm.getDateProperty("ysr8_ProductionDate"))); //Ԥʱ + vec.add(psRevisionForm.getDateProperty("ysr8_FinalAcceptance")==null? + "":String.format("%tF", psRevisionForm.getDateProperty("ysr8_FinalAcceptance")));//ƻʱ + vec.add(psRevisionForm.getDateProperty("ysr8_ActualAcceptanceDate")==null? + "":String.format("%tF", psRevisionForm.getDateProperty("ysr8_ActualAcceptanceDate")));//ʵʱ + ///////////////////////////////////////////////////////////////////////////// + //ȡͬ ɱysr8_ContractAmount ysr8_Cost + String ysr8_ContractAmount = ""; + String ysr8_Cost = ""; + if (soRevisionForm != null) { + ysr8_ContractAmount = soRevisionForm.getProperty("ysr8_ContractAmount"); + ysr8_Cost = soRevisionForm.getProperty("ysr8_Cost"); + } else if (spRevisionForm != null) { + ysr8_ContractAmount = spRevisionForm.getProperty("ysr8_ContractAmount"); + ysr8_Cost = spRevisionForm.getProperty("ysr8_Cost"); + } +// vec.add(fu.getDoubleString(fu.getDoubleFromString(ysr8_ContractAmount))); //ͬ + vec.add(df.format(fu.getDoubleFromString(ysr8_ContractAmount))); //ͬ + if(inACL) { + vec.add(df.format(fu.getDoubleFromString(ysr8_Cost)));//ɱ + }else + vec.add("");//ɱ + // + ///////////////////////////////////////////////////////////////////////////// + //ϵ + String XS = "1"; + String ysr8_Coefficient = psRevisionForm.getProperty("ysr8_Ratio"); + if (ysr8_Coefficient == null || ysr8_Coefficient.isEmpty()) { + String ysr8_Use = psRevisionForm.getProperty("ysr8_Use"); + if (ysr8_Use.equals("") || ysr8_Use.equals("ĥ")) { + XS = "1.5"; + } + } else { + XS = ysr8_Coefficient; + } + if(isManager) { + vec.add(XS);//ϵ + }else + vec.add("");//ϵ + ///////////////////////////////////////////////////////////////////////////// + // + Double zsje = 0.0; + if (ysr8_ContractAmount != null && !ysr8_ContractAmount.isEmpty()) { + double dxs = Double.parseDouble(XS); + double dContractAmount = Double.parseDouble(ysr8_ContractAmount); + zsje = dContractAmount * dxs; + } + if(isManager) { + vec.add(df.format(zsje));// + }else + vec.add("");// + ///////////////////////////////////////////////////////////////////////////// + String FKTJ = ""; + if (soRevisionForm != null) { + FKTJ = soRevisionForm.getProperty("ysr8_PaymentMethod"); + } else if (spRevisionForm != null) { + FKTJ = spRevisionForm.getProperty("ysr8_PaymentMethod"); + } + vec.add(FKTJ);// + ///////////////////////////////////////////////////////////////////////////// + String ysr8_PreAcceptanceRate = psRevisionForm.getProperty("ysr8_PreAcceptanceRate"); + vec.add(ysr8_PreAcceptanceRate);//ǰ\Ԥ + ///////////////////////////////////////////////////////////////////////////// + Double fhqje = 0.0; + if (!ysr8_ContractAmount.isEmpty() && !ysr8_PreAcceptanceRate.isEmpty()) { + try { + double dysr8_ContractAmount = Double.parseDouble(ysr8_ContractAmount); + double dysr8_PreAcceptanceRate = Double.parseDouble(ysr8_PreAcceptanceRate); + fhqje = dysr8_ContractAmount * dysr8_PreAcceptanceRate; + } catch(NumberFormatException e) { + System.out.println("ǰԤ"+ysr8_PreAcceptanceRate+"Сʽ"); + } + + } + vec.add(df.format(fhqje));//ǰ + ///////////////////////////////////////////////////////////////////////////// + String ysr8_AcceptanceRate = psRevisionForm.getProperty("ysr8_AcceptanceRate"); + vec.add(psRevisionForm.getProperty("ysr8_AcceptanceRate"));//ձ + ///////////////////////////////////////////////////////////////////////////// + Double ysje = 0.0; + if (!ysr8_ContractAmount.isEmpty() && !ysr8_AcceptanceRate.isEmpty()) { + try { + double dysr8_ContractAmount = Double.parseDouble(ysr8_ContractAmount); + double dysr8_AcceptanceRate = Double.parseDouble(ysr8_AcceptanceRate); + ysje = dysr8_ContractAmount * dysr8_AcceptanceRate; + } catch(NumberFormatException e) { + System.out.println("ձ"+ysr8_AcceptanceRate+"Сʽ"); + } + } + vec.add(df.format(ysje));//ս + ///////////////////////////////////////////////////////////////////////////// + // TODO lidy20181017ί + Set ChoiceUnitSet = new LinkedHashSet<>(); + String ysr8_ChoiceUnit = ""; + String ysr8_SubProjectCode = ""; + Double ysr8_Count = 0.0; + if (!ysr8_ProjectCode.equals("")) { + Vector attrVecdhtz = new Vector(); + Vector valVecdhtz = new Vector(); + attrVecdhtz.add("ysr8_ProjectCode"); + valVecdhtz.add(ysr8_ProjectCode); + String[] attrsdhtz = (String[]) attrVecdhtz.toArray(new String[attrVecdhtz.size()]); + String[] valsdhtz = (String[]) valVecdhtz.toArray(new String[attrVecdhtz.size()]); + System.out.println("ѯSearchTaskStartItemIJѯĿysr8_ProjectCode="+ysr8_ProjectCode); + TCComponent[] TaskStarts = TCUtil.query(fu.session, "SearchTaskStartItem", attrsdhtz, valsdhtz); + if (TaskStarts!=null && TaskStarts.length > 0) { + for(TCComponent TaskStart : TaskStarts) { + TCComponentItemRevision[] tsRevisions = ((TCComponentItem)TaskStart).getReleasedItemRevisions(); + if(tsRevisions.length>0) { + TCComponentItemRevision tsRevision = tsRevisions[0]; + System.out.println(tsRevision+"----"+tsRevisions.length); + TCComponentForm tsRevisionForm = TCUtil.getItemRevisionMasterForm(tsRevision); +// ysr8_ChoiceUnit = ysr8_ChoiceUnit+";"+tsRevisionForm.getProperty("ysr8_ChoiceUnit"); + String[] ChoiceUnit = tsRevisionForm.getProperty("ysr8_ChoiceUnit").split(","); + if(ChoiceUnit.length>0) { + for(int j=0; j0) { + for(String s : ChoiceUnitSet) { + ysr8_ChoiceUnit += (","+s); + } + ysr8_ChoiceUnit = ysr8_ChoiceUnit.substring(0); + } + vec.add(ysr8_ChoiceUnit.length()>0?ysr8_ChoiceUnit.substring(1):"");//ί11 +// vec.add(ysr8_SubProjectCode.length()>0?ysr8_SubProjectCode.substring(1):"");// + vec.add(fu.getDoubleString(ysr8_Count));// + vec.add(psRevisionForm.getStringProperty("ysr8_ProjectSRemark"));//ע +// vec.add("");//ע + ///////////////////////////////////////////////////////////////////////////// + for (int k = 0; k < vec.size(); k++) { + if ("".equals(vec.get(k))) { + vec.set(k, "-"); + } + } + + ci.dataTableModel.addRow(vec); + } + + } catch (Exception ex) { + ex.printStackTrace(); +// MessageBox.post(ex);// + MessageBox.post(""+ysr8_ProjectCode+"ʱ"+ex, "ERROR", MessageBox.ERROR); + btn.setText("ѯ"); + return; + } +// setEnable(true); + btn.setText("ѯ"); + } + + private void editYSR8_ProjectForm() { + try { + JTable table = (JTable)fu.allComponentMap.get("a.21.11.11"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪ༭ݣ", "ʾ", MessageBox.INFORMATION); + return; + } + System.out.println("psRevisionForms:"+psRevisionForms.size()+"--pfForms:"+pfForms.size()); + + TCComponentUser user = fu.session.getUser(); + String[] YSR8_PMSB_Editors = TCUtil.getPreference(fu.session, TCPreferenceService.TC_preference_site, "YSR8_PMSB_Editor"); + Boolean isYSR8_PMSB_Editor = false; + for (int i = 0; i < YSR8_PMSB_Editors.length; i++) { + if (YSR8_PMSB_Editors[i].equals(user.getProperty("user_name"))) { + isYSR8_PMSB_Editor = true; + } + } + if (!isYSR8_PMSB_Editor) { + MessageBox.post("ָĿ̨˱༭Աܽб༭", "ʾ", MessageBox.INFORMATION); + return; + } + String Val0 = table.getValueAt(rows[0], col.get("ʱ()")) + "@@@@" + table.getValueAt(rows[0], col.get("ϵ")) + + "@@@@" + table.getValueAt(rows[0], col.get("ǰԤ")) + "@@@@" + table.getValueAt(rows[0], col.get("ձ")) + + "@@@@" + table.getValueAt(rows[0], col.get("ʵʱ")) + "@@@@" + table.getValueAt(rows[0], col.get("ע")); + TCComponentForm[] editForms = { psRevisionForms.get(rows[0]), pfForms.get(rows[0]) }; + new YSR8_PMSBRevisionEditDialog(fu.session, this, rows[0], editForms, Val0); + } catch (TCException e) { + e.printStackTrace(); + } +// searchYSR8_PMSBR(); + } + + private void outputYSR8_PMSBR() { + final JTable table = (JTable)fu.allComponentMap.get("a.21.11.11"); + final JButton btn = (JButton)fu.allComponentMap.get("b.11.12.12"); + btn.setEnabled(false); + final ProgressReporterDialog reporter = new ProgressReporterDialog(); + reporter.reportProgressMessage("ڵ,Ժ..."); + new Thread(reporter).start(); + new Thread() { + public void run() { + POIUtil.outputExcel(fu.session,table,"YSR8_PMSBRevisionTemplate","Ŀ̨ģ","Ŀ̨"); + reporter.requestCanceling(); + btn.setEnabled(true); + } + }.start(); + } + + + @SuppressWarnings("unused") + private void output_old(JTable table) { + try { + Date date = new Date(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + String time = sdf.format(date); + String toPath = System.getProperty("java.io.tmpdir") + "Ŀ̨" + time + ".xls"; + // һдWorkbook + WritableWorkbook writeWorkBook = Workbook.createWorkbook(new File(toPath)); + // + WritableSheet wsheet = writeWorkBook.createSheet("Ŀ̨", 0); + + //д + int columnCount = table.getColumnCount(); // + int rowCount = table.getRowCount(); // + String[] titles = new String[columnCount]; // ͷ + + // ȡͷ + for (int i = 0; i < columnCount; i++) { + titles[i] = table.getColumnName(i); + } + + int current_row = 0; // ʼǰΪʼ + + try { + // ʽ + WritableFont titleFont = new WritableFont(WritableFont.createFont(""), 13,WritableFont.BOLD); + WritableCellFormat titleCellFormat = new WritableCellFormat(titleFont); + titleCellFormat.setBorder(Border.ALL, BorderLineStyle.MEDIUM); + titleCellFormat.setAlignment(Alignment.CENTRE); + titleCellFormat.setVerticalAlignment(VerticalAlignment.CENTRE); + titleCellFormat.setWrap(true); + + // ʽ + WritableFont contentFont = new WritableFont(WritableFont.createFont(""), 12); + WritableCellFormat contentCellFormat = new WritableCellFormat(contentFont); + contentCellFormat.setBorder(Border.ALL, BorderLineStyle.THIN); + contentCellFormat.setAlignment(Alignment.CENTRE); + contentCellFormat.setVerticalAlignment(VerticalAlignment.CENTRE); + contentCellFormat.setWrap(true); + + // дб + for (int i = 0; i < columnCount; i++) { + Label labelTitle = new Label(i, current_row, titles[i], titleCellFormat); + wsheet.addCell(labelTitle); + } + + current_row = current_row + 1; + // д + for (int i = 0; i < rowCount; i++) { + for (int j = 0; j < columnCount; j++) { + Object objValue = table.getValueAt(i, j); + Label labelContent = new Label(j, i + current_row, String.valueOf(objValue), contentCellFormat); + wsheet.addCell(labelContent); + } + } + + // øʽ + wsheet.getSettings().setDefaultColumnWidth(20); + writeWorkBook.write(); + writeWorkBook.close(); + } catch (WriteException e) { + e.printStackTrace(); + } + + // 򿪵ıļ + Runtime.getRuntime().exec("cmd /c \"" + toPath + "\""); + + } catch (IOException e) { + e.printStackTrace(); + } + + } + //lidy20180919༭Ľͬ + protected void setChengeValue(int row, String value) { + DecimalFormat df = new DecimalFormat(",###,###.00"); + String[] values = value.split("@@@@",-1); +// System.out.println("size:"+values.length); + JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a.21.11.11"); + + ci.dataTableModel.setValueAt(values[0], row, col.get("ʱ()"));//ʱ() + ci.dataTableModel.setValueAt(values[1], row, col.get("ϵ"));//ϵ + try { + Double ysr8_ContractAmount = new Double(ci.dataTableModel.getValueAt(row, col.get("ͬ")).toString().replace(",", "")); + Double XS = new Double(values[1]); + ci.dataTableModel.setValueAt(df.format(ysr8_ContractAmount*XS), row, col.get(""));// + } catch(NumberFormatException e) { + ci.dataTableModel.setValueAt("0", row, col.get(""));// + } + ci.dataTableModel.setValueAt(values[2], row, col.get("ǰԤ"));//ǰ\Ԥ + try { + Double ysr8_ContractAmount = new Double(ci.dataTableModel.getValueAt(row, col.get("")).toString().replace(",", "")); + Double XS = new Double(values[2]); + ci.dataTableModel.setValueAt(df.format(ysr8_ContractAmount*XS), row, col.get("ǰ"));//ǰ + } catch(NumberFormatException e) { + ci.dataTableModel.setValueAt("0", row, col.get("ǰ"));//ǰ + } + ci.dataTableModel.setValueAt(values[3], row, col.get("ձ"));//ձ + try { + Double ysr8_ContractAmount = new Double(ci.dataTableModel.getValueAt(row, col.get("")).toString().replace(",", "")); + Double XS = new Double(values[3]); + ci.dataTableModel.setValueAt(df.format(ysr8_ContractAmount*XS), row, col.get("ս"));//ս + } catch(NumberFormatException e) { + ci.dataTableModel.setValueAt("0", row, col.get("ս"));//ս + } + ci.dataTableModel.setValueAt(values[4], row, col.get("ʵʱ"));//ʵʱ + if(values.length>5) + ci.dataTableModel.setValueAt(values[5], row, col.get("ע"));//ע + } + +// private void setEnable(Boolean enable) { +// JButton btn = (JButton)fu.allComponentMap.get("b.11.12.11"); +// btn.setEnabled(enable); +// btn = (JButton)fu.allComponentMap.get("b.11.12.12"); +// btn.setEnabled(enable); +// btn = (JButton)fu.allComponentMap.get("b.11.12.13"); +// btn.setEnabled(enable); +// +// } +} diff --git a/src/cn/com/ebewin/ysr/dialog/YSR8_ProjectFormSearchDialog.java b/src/cn/com/ebewin/ysr/dialog/YSR8_ProjectFormSearchDialog.java new file mode 100644 index 0000000..e85ec75 --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/YSR8_ProjectFormSearchDialog.java @@ -0,0 +1,849 @@ +package cn.com.ebewin.ysr.dialog; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.math.BigDecimal; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Vector; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableColumnModel; +import javax.swing.text.JTextComponent; + +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.DateUtil; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.commands.open.OpenCommand; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.Registry; + +import cn.com.ebewin.ysr.util.CommonUtil; +import cn.com.ebewin.ysr.util.FileUtil; +import cn.com.ebewin.ysr.util.POIUtil; +import cn.com.ebewin.ysr.util.TCUtil; + +@SuppressWarnings("deprecation") +public class YSR8_ProjectFormSearchDialog extends JFrame { + private static final long serialVersionUID = 1L; + private DateButton startDateBtn; + private DateButton endDateBtn; + private JTextField project; + private JButton searchBtn; + private JButton editBtn; + private JButton exportBtn; + private JButton importBtn; +// private String[] header=new String[] {"","Ŀ","û","Ŀ", +// "Ŀ","ƻԱ","","(AF)","(AN)","տ(AO)", +// "(AA)","ʱ","ƻ߱ʱ(AD)","ƻ߱ʱ(ǰ)", +// "ʵʾ߱ʱ","ע","ʱ","״̬","ǰ","տʱ"}; + private String[] header=new String[] {"", "Ŀ", "û", "Ŀ", "Ŀ", + "ƻԱ", "", "", "", "տ", + "ʱ", "", "ʱ", "Ŀռƻʱ", "ƻ߱ʱ", + "ƻ߱ʱ(ǰ)", "ʵʾ߱ʱ", "ע", "ʱ", "Ŀ״̬", + "ǰ", "տʱ", "ʱ£"}; + private int[] headerWidth=new int[] {50,100,180,180,80, + 80,80,150,80,150, + 150,150,180,180,180, + 100,150,100,100,150}; + private List tableRows=new ArrayList<>(); + private TCSession session; + private DefaultTableModel tableModel; + private JTable table; + private JButton openBtn; + + + public YSR8_ProjectFormSearchDialog(TCSession session) throws TCException { + // super(true); + this.session=session; + initUI(); + +// TableColumn column = table.getColumnModel().getColumn(7); +// System.out.println(column.getHeaderValue()); +// DefaultTableCellRenderer right = new DefaultTableCellRenderer(); +// right.setHorizontalAlignment(SwingConstants.RIGHT); +// column.setCellRenderer(right); + // centerToScreen(); + this.setLocationRelativeTo(null); + this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); + + this.pack(); + addActionListener(); + setVisible(true); + } + + private void initUI() { + this.setTitle("Ŀ̨"); + this.setLayout(new BorderLayout()); + this.setPreferredSize(new Dimension(1000, 600)); + this.setMinimumSize(new Dimension(800, 480)); + this.setSize(new Dimension(1000, 600)); + JPanel topPanel = new JPanel(new BorderLayout()); + JPanel cmpPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); + JPanel btnPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + + cmpPanel.add(new JLabel("ʼ")); + this.startDateBtn = new DateButton(null , "yyyy-MM-dd", false, false, false); + cmpPanel.add(startDateBtn); + cmpPanel.add(new JLabel("")); + this.endDateBtn = new DateButton(null , "yyyy-MM-dd", false, false, false); + cmpPanel.add(endDateBtn); + cmpPanel.add(new JLabel("Ŀɸѡ"));//TODO + this.project = new JTextField(20); + project.setPreferredSize(new Dimension(100, 23)); + cmpPanel.add(project); + + this.searchBtn = new JButton("ѯ"); + this.editBtn = new JButton("༭"); + this.editBtn.setEnabled(false); + this.exportBtn = new JButton(""); + this.importBtn = new JButton(""); + this.openBtn = new JButton(""); + this.openBtn.setEnabled(false); + btnPanel.add(this.searchBtn); + btnPanel.add(this.editBtn); + btnPanel.add(this.exportBtn); + btnPanel.add(this.importBtn); + topPanel.add(cmpPanel, BorderLayout.WEST); + topPanel.add(btnPanel, BorderLayout.EAST); + this.add(topPanel, BorderLayout.NORTH); + // init center panel + this.tableModel = new DefaultTableModel(); + this.table = new JTable(tableModel) { + private static final long serialVersionUID = 1L; + public boolean isCellEditable(int row, int col) { + return false; + } + }; + JTableHeader tableHeader = table.getTableHeader(); + tableHeader.setReorderingAllowed(false);// вƶ + DefaultTableCellRenderer hr = (DefaultTableCellRenderer) tableHeader.getDefaultRenderer(); + hr.setHorizontalAlignment(DefaultTableCellRenderer.CENTER);// + // table.getTableHeader().setReorderingAllowed(false); + table.setRowHeight(22); + table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + table.setAutoscrolls(true); + // table.setFillsViewportHeight(false); + table.setShowGrid(true); + tableModel.setDataVector(null, header); + JScrollPane centerPanel = new JScrollPane(table); + this.add(centerPanel, BorderLayout.CENTER); + + } + + private void addActionListener() { + final JFrame dialog = this; + this.searchBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + new Thread(new Runnable() { + @Override + public void run() { + searchBtn.setEnabled(false); + searchBtn.setText("ѯ..."); + searchYSR8_ProjectForm(); + searchBtn.setEnabled(true); + searchBtn.setText("ѯ"); + } + }).start(); + } + }); + this.openBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent arg0) { + new Thread(new Runnable() { + @Override + public void run() { + int row=table.getSelectedRow(); + if(row==-1) { + MessageBox.post(dialog, "ѡݣ", "ʾ", MessageBox.INFORMATION); + return; + } + Object val = table.getValueAt(row, 0); + ProjectFormBean bean=(ProjectFormBean) val; + try { + Registry localRegistry = Registry.getRegistry("com.teamcenter.rac.commands.open.open"); + OpenCommand localOpenCommand = (OpenCommand) localRegistry.newInstanceForEx("openCommand", + new Object[] { AIFUtility.getActiveDesktop(), bean.projectForm }); + localOpenCommand.executeModeless(); + } catch (Exception e) { + e.printStackTrace(); + } + } + }).start(); + } + }); + this.editBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + + TCComponentUser user = session.getUser(); + String manager = TCUtil.getPreference2(session, TCPreferenceService.TC_preference_site, "YSR8_ProjectForm_Manager"); + Boolean isManager = false; + System.out.println(manager); + try { + if (manager.equals(user.getProperty("user_name"))) { + isManager = true; + } + } catch (TCException e2) { + e2.printStackTrace(); + } + if(!isManager) { + MessageBox.post(dialog, "ָԱܽб༭", "ʾ", MessageBox.INFORMATION); + return; + } + int row=table.getSelectedRow(); + if(row==-1) { + MessageBox.post(dialog, "ѡݣ", "ʾ", MessageBox.INFORMATION); + return; + } + Object val = table.getValueAt(row, 0); + if(val!=null&&(val instanceof ProjectFormBean)) { + ProjectFormBean bean=(ProjectFormBean) val; + try { + bean.editProperty(); + } catch (Exception e1) { + MessageBox.post(dialog, ":\n"+e1.getMessage(), "ʾ", MessageBox.WARNING); + e1.printStackTrace(); + } + } + + } + }); + this.exportBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if(table.getRowCount()==0) { + MessageBox.post(dialog, "ûݿԵ", "ʾ", MessageBox.WARNING); + return; + } + exportToExcel(); + } + }); + this.importBtn.addActionListener(new ActionListener() {//TODO importBtn + @Override + public void actionPerformed(ActionEvent e) { + InputStream input = null; + try { + String[] prefs = TCUtil.getPreference(session, TCPreferenceService.TC_preference_site, "YSR_Import_FinishDate"); + String[] users = prefs[0].split(";"); + TCComponentUser user = session.getUser(); + if(!TCUtil.contains(users, user.getUserId())) { + MessageBox.post(dialog, "ǰûеȨ", "ERROR", MessageBox.ERROR); + return; + } + String[] nums = prefs[1].split(";"); + int projectCol = Integer.parseInt(nums[0])-1; + int dateCol = Integer.parseInt(nums[1])-1; + int startRow = Integer.parseInt(nums[2])-1; + String[][] fileENames = { { ".xlsx", "MS Excelļ(*.xlsx)" } }; + File file = FileUtil.openFileChooser(fileENames); + input = new FileInputStream(file); + XSSFWorkbook wb = new XSSFWorkbook(input); + XSSFSheet sheet = wb.getSheetAt(0); + + CommonUtil.setByPass(true); + for(int i=startRow; i<=sheet.getLastRowNum(); i++) { + XSSFRow row = sheet.getRow(i); + String project = row.getCell(projectCol).getStringCellValue(); + if(project.isEmpty()) + break; + XSSFCell cell = row.getCell(dateCol); + String date; + if(cell.getCellType()==Cell.CELL_TYPE_NUMERIC && DateUtil.isCellDateFormatted(cell)) { + date = String.format("%tF", cell.getDateCellValue()); + }else + date = cell.getStringCellValue(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + System.out.println("import:"+project+" -> "+date); + + TCComponentItemRevision xmqdRev = TCUtil.findItemByID(session, project+"_XMQD").getLatestItemRevision(); + TCUtil.getItemRevisionMasterForm(xmqdRev).setDateProperty("ysr8_ActualAcceptanceDate", sdf.parse(date)); + } + CommonUtil.setByPass(false); + }catch(Exception e1) { + MessageBox.post(dialog, ""+e1.getMessage(), "ERROR", MessageBox.ERROR); + }finally { + if(input != null) + try { + input.close(); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + } + }); + this.table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { + @Override + public void valueChanged(ListSelectionEvent e) { + if(table.getSelectedRow()!=-1) { + editBtn.setEnabled(true); + openBtn.setEnabled(true); + }else { + openBtn.setEnabled(false); + editBtn.setEnabled(false); + } + } + }); + /*JButton btn = (JButton) fu.allComponentMap.get("b.11.12.11"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + searchYSR8_ProjectForm(); + } + }); + + btn = (JButton) fu.allComponentMap.get("b.11.12.12"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + editYSR8_ProjectForm(); + } + }); + + btn = (JButton) fu.allComponentMap.get("b.11.12.13"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + outputYSR8_PMSBR(); + } + });*/ + + } + + private void searchYSR8_ProjectForm() { + System.out.println("search-----1"); + this.tableRows.clear(); + + Date date1 = this.startDateBtn.getDate(); + String startDate = ""; + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + if (date1 != null) { + startDate = sdf.format(date1) + " 00:00"; + } + + Date date2 = this.endDateBtn.getDate(); + String endDate = ""; + if (date2 != null) { + endDate = sdf.format(date2) + " 23:59"; + } + String project = this.project.getText(); + + if (startDate.isEmpty() && endDate.isEmpty() && project.replaceAll("\\*", "").isEmpty()) { + MessageBox.post(YSR8_ProjectFormSearchDialog.this, "ѯ", "ʾ", MessageBox.INFORMATION); + return; + } + + Vector attrVec = new Vector(); + Vector valVec = new Vector(); + + attrVec.add("ProjectCategory"); + valVec.add("2"); + if (!startDate.equals("")) { + attrVec.add("FinalDeliveryTime1"); + valVec.add(String.format("%tF", date1)); + } + if (!endDate.equals("")) { + attrVec.add("FinalDeliveryTime2"); + valVec.add(String.format("%tF", date2)); + } + if(!project.isEmpty()) { + attrVec.add("Ŀ ID"); + valVec.add(project); + } + attrVec.add("ProjectCode");//TODO + valVec.add("*-S*"); + + /*if (!startDate.equals("")) { + attrVec.add("ysr8_StartDate1"); + valVec.add(startDate); + } + if (!endDate.equals("")) { + attrVec.add("ysr8_StartDate2"); + valVec.add(endDate); + }*/ + + try { + String[] attrs = attrVec.toArray(new String[attrVec.size()]); + String[] vals = valVec.toArray(new String[attrVec.size()]); + + //TCComponent[] tcComponents = TCUtil.query(session, "SearchPMSBRevision", attrs, vals); +// TCComponent[] tcComponents = TCUtil.query(session, "SearchProjectBook", attrs, vals); + TCComponent[] tcComponents = TCUtil.query(session, "SearchPMSBPS", attrs, vals); + System.out.println("search-----2"); + if(tcComponents==null) { + System.out.println("null"); + return; + } + System.out.println("tcComponents:"+tcComponents.length); + Integer idx = 0; + for (int i = 0; i < tcComponents.length; i++) { + TCComponentItemRevision revision = (TCComponentItemRevision) tcComponents[i]; + TCComponentForm pfForm = TCUtil.getItemRevisionMasterForm(revision); + String ysr8_ProjectCode = pfForm.getProperty("ysr8_ProjectCode"); + if (ysr8_ProjectCode.equals("")) { + continue; + } + //ѯ֪ͨ + TCComponentForm saleForm=getSaleForm(ysr8_ProjectCode); + /*if(saleForm==null) { + continue; + }*/ + this.tableRows.add(new ProjectFormBean(++idx,pfForm, saleForm)); + } + refreshTable(); + System.out.println("search-----5"); + } catch (Exception ex) { + ex.printStackTrace(); + MessageBox.post(YSR8_ProjectFormSearchDialog.this,ex); + return; + } + } + + private void refreshTable() throws Exception { + int size=this.tableRows.size(); + Object[][] content=new Object[size][]; + for(int i=0;i1) { + TCComponentItemRevision tempRev = (TCComponentItemRevision) tcComponents[0]; + Date tempDate=tempRev.getDateProperty("creation_date"); + for (int i = 1; i < tcComponents.length; i++) { + TCComponentItemRevision rev = (TCComponentItemRevision) tcComponents[i]; + Date date=rev.getDateProperty("creation_date"); + if(date.after(tempDate)) { + tempRev=rev; + tempDate=date; + } + } + targetForm=(TCComponentForm) tempRev.getRelatedComponent("IMAN_master_form_rev"); + } + return targetForm; + } + + + private void exportToExcel() { + exportBtn.setEnabled(false); + final ProgressReporterDialog reporter = new ProgressReporterDialog(); + reporter.reportProgressMessage("ڵ,Ժ..."); + new Thread(reporter).start(); + new Thread() { + public void run() { + POIUtil.outputXlsx(session,table,"YSR8_ProjectFormTemplate","Ŀ̨ģ","Ŀ̨"); + /*try { + + Date date = new Date(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + String time = sdf.format(date); + String toPath = System.getProperty("java.io.tmpdir") + "Ŀ̨" + time + ".xls"; + // һдWorkbook + WritableWorkbook writeWorkBook = Workbook.createWorkbook(new File(toPath)); + // + WritableSheet wsheet = writeWorkBook.createSheet("Ŀ̨", 0); + + // д + int columnCount = table.getColumnCount(); // + int rowCount = table.getRowCount(); // + String[] titles = new String[columnCount]; // ͷ + + // ȡͷ + for (int i = 0; i < columnCount; i++) { + titles[i] = table.getColumnName(i); + } + int current_row = 0; // ʼǰΪʼ + + try { + // ʽ + WritableFont titleFont = new WritableFont(WritableFont.createFont(""), 13, WritableFont.BOLD); + WritableCellFormat titleCellFormat = new WritableCellFormat(titleFont); + titleCellFormat.setBorder(Border.ALL, BorderLineStyle.MEDIUM); + titleCellFormat.setAlignment(Alignment.CENTRE); + titleCellFormat.setVerticalAlignment(VerticalAlignment.CENTRE); + titleCellFormat.setWrap(true); + + // ʽ + WritableFont contentFont = new WritableFont(WritableFont.createFont(""), 12); + WritableCellFormat contentCellFormat = new WritableCellFormat(contentFont); + contentCellFormat.setBorder(Border.ALL, BorderLineStyle.THIN); + contentCellFormat.setAlignment(Alignment.CENTRE); + contentCellFormat.setVerticalAlignment(VerticalAlignment.CENTRE); + contentCellFormat.setWrap(true); + + // дб + for (int i = 0; i < columnCount; i++) { + Label labelTitle = new Label(i, current_row, titles[i], titleCellFormat); + wsheet.addCell(labelTitle); + } + + current_row = current_row + 1; + // д + for (int i = 0; i < rowCount; i++) { + for (int j = 0; j < columnCount; j++) { + Object objValue = table.getValueAt(i, j); + Label labelContent = new Label(j, i + current_row, String.valueOf(objValue), contentCellFormat); + wsheet.addCell(labelContent); + } + } + + // øʽ + wsheet.getSettings().setDefaultColumnWidth(20); + writeWorkBook.write(); + writeWorkBook.close(); + } catch (WriteException e) { + e.printStackTrace(); + } + + // 򿪵ıļ + Runtime.getRuntime().exec("cmd /c \"" + toPath + "\""); + + } catch (IOException e) { + e.printStackTrace(); + }*/ + reporter.requestCanceling(); + exportBtn.setEnabled(true); + } + }.start(); + } + + private class ProjectFormBean{ + TCComponentForm projectForm; + TCComponentForm saleForm; + private Integer index; + public ProjectFormBean(Integer idx, TCComponentForm projectForm, TCComponentForm saleForm) { + this.projectForm = projectForm; + this.saleForm = saleForm; + this.index=idx; + } + + public Object[] getTableRow() throws TCException { + DecimalFormat df = new DecimalFormat(",###,###");//lidy20181015ǧλָ + + Object[] rowData=new Object[23]; + rowData[0]=this;//index + rowData[1]=this.projectForm.getProperty("ysr8_ProjectCode");//ysr8_ProjectCodeĿ + rowData[2]=this.projectForm.getProperty("ysr8_CustomerName");//ysr8_CustomerNameû + rowData[3]=this.projectForm.getProperty("ysr8_ProjectName");//Ŀ + rowData[4]=this.projectForm.getProperty("ysr8_ProjectManager");//Ŀ + rowData[5]=this.projectForm.getProperty("ysr8_Planner");//ƻԱ + rowData[6]=this.projectForm.getProperty("ysr8_Sales");// + String amount="0"; + if(saleForm==null) { + rowData[7]="0";//(AF) + }else { + amount=this.saleForm.getProperty("ysr8_ContractAmount");// + String sales = "0"; + if(!"".equals(amount)) { + BigDecimal res=new BigDecimal(amount); +// sales=String.format("%.2f", res); + sales=df.format(res.doubleValue()); + } + rowData[7]=sales;//(AF) + } + rowData[8]=this.projectForm.getProperty("ysr8_AcceptanceRate");//(AN) + rowData[9]="";//տ(AO) + if(saleForm!=null&&rowData[7]!=null&&!"".equals(rowData[7])&&rowData[8]!=null&&!"".equals(rowData[8])) { + //lidy20181121ָʽ +// BigDecimal n1=new BigDecimal(rowData[7].toString()); + BigDecimal n1=new BigDecimal(amount); + BigDecimal n2=new BigDecimal(rowData[8].toString()); + BigDecimal res=n1.multiply(n2); +// rowData[9]=String.format("%.2f", res);//տ(AO) + rowData[9]=df.format(res.doubleValue());//տ(AO) + } + if(rowData[8]==null || rowData[8].toString().isEmpty()) + rowData[8] = "0"; + if(rowData[9]==null || rowData[9].toString().isEmpty()) + rowData[9] = "0"; + + rowData[10]=String.format("%tF", this.projectForm.getDateProperty("ysr8_StartDate"));//TODO ʱ + +// rowData[11]=String.format("%tF", this.projectForm.getDateProperty("ysr8_ActualFactoryDate"));// (AA) + rowData[11]=this.projectForm.getProperty("ysr8_FinalDeliveryTime"); +// if(rowData[11].toString().equals("null")) +// rowData[11] = ""; + rowData[12]=String.format("%tF", this.projectForm.getDateProperty("ysr8_EntryDate"));//ʱ? + if(rowData[12].toString().equals("null")) + rowData[12] = ""; + rowData[13] = "";//Ŀռƻʱ +// rowData[14]=String.format("%tF", this.projectForm.getDateProperty("ysr8_PlanAcceptance"));//ƻ߱ʱ(AD)? + rowData[14]=String.format("%tF", this.projectForm.getDateProperty("ysr8_FinalAcceptance"));//ƻ߱ʱ(AD)? + if(rowData[14].toString().equals("null")) + rowData[14] = ""; + rowData[15]=String.format("%tF", this.projectForm.getDateProperty("ysr8_ActualPlanAcceptance"));//ƻ߱ʱ(ǰ)? + if(rowData[15].toString().equals("null")) + rowData[15] = ""; +// rowData[16]=String.format("%tF", this.projectForm.getDateProperty("ysr8_ActualAcceptance"));//ʵʾ߱ʱ? + rowData[16]=String.format("%tF", this.projectForm.getDateProperty("ysr8_ActualAcceptanceDate"));//ʵʾ߱ʱ? + if(rowData[16].toString().equals("null")) + rowData[16] = ""; + rowData[17]=this.projectForm.getProperty("ysr8_Remark");//ע + rowData[18]=String.format("%tF", this.projectForm.getDateProperty("ysr8_ResidenceTime"));//ʱ? + if(rowData[18].toString().equals("null")) + rowData[18] = ""; + rowData[19]=this.projectForm.getProperty("ysr8_ProductionState");//Ŀ״̬? + rowData[20]=this.projectForm.getProperty("ysr8_ResponsibleParty");//ǰ? + rowData[21]=String.format("%tF", this.projectForm.getDateProperty("ysr8_AcceptanceArrivalDate"));//տʱ? + if(rowData[21].toString().equals("null")) + rowData[21] = ""; + rowData[22] = "";//ʱ£ + return rowData; + } + + @Override + public String toString() { + return this.index.toString(); + } + + public void editProperty() throws Exception { + /*boolean canWrite=session.getTCAccessControlService().checkUsersPrivilege(session.getUser(), projectForm, "WRITE"); + if(!canWrite) { + session.getTCAccessControlService().grantPrivilege(projectForm, session.getUser(), new String[] {"WRITE"}); + MessageBox.post("ǰûԱ"+projectForm+"ûдȨ","ʾ",MessageBox.WARNING); + return; + }*/ + ProjectFormEditDialog dialog = new ProjectFormEditDialog(this); + dialog.showEditDialog(); + } + + } + + private class ProjectFormEditDialog extends AbstractAIFDialog { + private static final long serialVersionUID = 1L; + private ProjectFormBean projectFormBean; + private Map datePropMap = new HashMap<>(); + private Map> comboPropMap = new HashMap<>(); + private Map textPropMap = new HashMap<>(); + private TCComponentForm projectForm; + + ProjectFormEditDialog(ProjectFormBean projectFormBean) { + super(true); + this.projectFormBean = projectFormBean; + this.projectForm = projectFormBean.projectForm; + } + + protected void refreshRowData() throws TCException { + Object[] rowData = this.projectFormBean.getTableRow(); + int index = this.projectFormBean.index-1; + for(int i=1; i comboBox = new JComboBox<>(); + String val = this.projectForm.getStringProperty(propName); + if(content != null) { + comboBox.addItem(null); + for (String str : content) { + comboBox.addItem(str); + } + comboBox.setSelectedItem(val); + } + comboPropMap.put(propName, comboBox); + parent.add(comboBox, s); + } + } + private void addTextProp(String propName, JPanel parent, GridBagConstraints s) throws TCException { + if(!textPropMap.containsKey(propName)) { + String val = this.projectForm.getStringProperty(propName); + JTextArea area = new JTextArea(val); + textPropMap.put(propName, area); + s.weightx = 1; + s.weighty = 1; + parent.add(new JScrollPane(area), s); + s.weightx = 0; + s.weighty = 0; + } + } + + public void showEditDialog() throws Exception{ + initEditDialog(); + this.showDialog(); + } + + private void initEditDialog() throws TCException { + this.setTitle("ĿϢά"); + this.setLayout(new BorderLayout()); + this.setMinimumSize(new Dimension(520, 350)); + JPanel centerPanel = new JPanel(new GridBagLayout()); + JPanel btnPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 15, 5)); + GridBagConstraints s = new GridBagConstraints(); + s.fill = GridBagConstraints.BOTH; + s.gridwidth = 1; + s.gridheight = 1; + s.weightx = 0; + s.weighty = 0; + s.gridx = 0; + s.gridy = 0; + // init center panel + s.insets = new Insets(10, 5, 0, 5); + centerPanel.add(new JLabel("ʱ"), s); + s.gridx++; + addDateProp("ysr8_EntryDate",centerPanel, s); + s.gridx++; + centerPanel.add(new JLabel("ƻ߱ʱ(ǰ)"), s); + s.gridx++; + addDateProp("ysr8_ActualPlanAcceptance", centerPanel, s); + s.gridy++; + s.gridx = 0; + centerPanel.add(new JLabel("ʱ"), s); + s.gridx++; + addDateProp("ysr8_ResidenceTime", centerPanel, s); + s.gridx++; + centerPanel.add(new JLabel("ʵʾ߱ʱ"), s); + s.gridx++; + addDateProp("ysr8_ActualAcceptanceDate", centerPanel, s); + s.gridy++; + s.gridx = 0; + centerPanel.add(new JLabel("״̬"), s); + s.gridx++; + TCPreferenceService service = session.getPreferenceService(); + //lov=YSR8_ProjectBook_ProductionState_LOV + String[] comboContent = service.getStringValues("YSR8_ProjectBook_ProductionState_LOV"); + addComboProp("ysr8_ProductionState", centerPanel, s, comboContent); + s.gridx++; + centerPanel.add(new JLabel("ǰ"),s); + s.gridx++; + //lov=YSR8_ProjectBook_ResponsibleParty_LOV + String[] comboContent2 = service.getStringValues("YSR8_ProjectBook_ResponsibleParty_LOV"); + addComboProp("ysr8_ResponsibleParty", centerPanel, s, comboContent2); + s.gridy++; + s.gridx = 0; + centerPanel.add(new JLabel("տʱ"), s); + s.gridx++; + addDateProp("ysr8_AcceptanceArrivalDate", centerPanel, s); + s.gridy++; + s.gridx = 0; + centerPanel.add(new JLabel("ע"), s); + s.gridx++; + s.gridwidth = 4; + s.gridheight = 3; + addTextProp("ysr8_Remark", centerPanel, s); + //init button panel + JButton okBtn = new JButton("ȷ"); + JButton celBtn = new JButton("ȡ"); + btnPanel.add(okBtn); + btnPanel.add(celBtn); + this.add(centerPanel, BorderLayout.CENTER); + this.add(btnPanel, BorderLayout.SOUTH); + //add listeners + celBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + okBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + try { + CommonUtil.setByPass(true); + okEvent(); + CommonUtil.setByPass(false); + } catch (Exception e1) { + MessageBox.post(ProjectFormEditDialog.this, "дԳ\n"+e1.getMessage(), "ʾ", MessageBox.WARNING); + e1.printStackTrace(); + } + try { + CommonUtil.setByPass(false); + } catch (Exception e2) { + e2.printStackTrace(); + } + try { + refreshRowData(); + } catch (Exception e1) { + e1.printStackTrace(); + } + disposeDialog(); + } + }); + } + } +} diff --git a/src/cn/com/ebewin/ysr/dialog/YSR8_QERevisionSearchDialog.java b/src/cn/com/ebewin/ysr/dialog/YSR8_QERevisionSearchDialog.java new file mode 100644 index 0000000..f17878f --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/YSR8_QERevisionSearchDialog.java @@ -0,0 +1,621 @@ +package cn.com.ebewin.ysr.dialog; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.Vector; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.RowSorter; +import javax.swing.SortOrder; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; + +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.iTextField; + +import cn.com.ebewin.ysr.util.CommonUtil; +import cn.com.ebewin.ysr.util.DialogUtil; +import cn.com.ebewin.ysr.util.FormUtil; +import cn.com.ebewin.ysr.util.POIUtil; +import cn.com.ebewin.ysr.util.TCUtil; + +@SuppressWarnings("deprecation") +public class YSR8_QERevisionSearchDialog extends JFrame { + private static final long serialVersionUID = 1L; + DialogUtil fu = new DialogUtil(this, "ί̨", "YSR8_QERevisionSearchDialog"); + Vector quotationRevisions = new Vector(); + TCSession session; +// JTable table; + Map itemMap = new HashMap<>(); + + public YSR8_QERevisionSearchDialog(TCSession session) throws Exception { + //super(true); + this.session = session; + + fu.initializeUI(session); + //lidy20181106ɵ + JTable table = (JTable) fu.allComponentMap.get("a.21.11.11"); + + Comparator comparator = new Comparator() { + public int compare(Object arg0, Object arg1) { + try{ + int a = Integer.parseInt(arg0.toString()); + int b = Integer.parseInt(arg1.toString()); + return a-b; + }catch(NumberFormatException e){ + return 0; + } + } + }; + + table.setAutoCreateRowSorter(true); + ArrayList sortKeys = new ArrayList(); + sortKeys.add(new RowSorter.SortKey(0, SortOrder.ASCENDING)); + TableRowSorter sorter = new TableRowSorter(table.getModel()); + sorter.setComparator(0, comparator); + sorter.setSortKeys(sortKeys); + table.setRowSorter(sorter); + //centerToScreen(); + this.setLocationRelativeTo(null); + this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); + + table = (JTable)fu.allComponentMap.get("a.21.11.11"); + addActionListener(); + setVisible(true); + } + + private void addActionListener() { + @SuppressWarnings({ "unchecked", "rawtypes" }) + JComboBox cb = (JComboBox)fu.allComponentMap.get("DateName"); + cb.setEditable(false); + cb.addItem("ʱ"); + cb.addItem("ʱ"); + cb.addItem("ʱ"); + cb.addItem("Ԥʱ"); + + @SuppressWarnings({ "unchecked", "rawtypes" }) + JComboBox qs = (JComboBox)fu.allComponentMap.get("QuotationStatus"); + String[] values = TCUtil.getPreference(session, TCPreferenceService.TC_preference_site, "ysr8_QuotationStatus_lov"); + for(int i=0; i0) { + TCComponentUser user = session.getUser(); + String[] YSR8_PMSB_Editors = TCUtil.getPreference(fu.session, TCPreferenceService.TC_preference_site, "YSR8_PMSB_Editor"); + Boolean isYSR8_PMSB_Editor = false; + try { + if (table.getValueAt(rows[0], 9).toString().equals(user.getProperty("user_name"))) { + isYSR8_PMSB_Editor = true; + } + if (!isYSR8_PMSB_Editor) { + for (int i = 0; i < YSR8_PMSB_Editors.length; i++) { + if (YSR8_PMSB_Editors[i].equals(user.getProperty("user_name"))) { + isYSR8_PMSB_Editor = true; + } + } + } + } catch (Exception e1) { + e1.printStackTrace(); + } + if (!isYSR8_PMSB_Editor) { + MessageBox.post("Ŀָ̨˱༭Աܽб༭", "ʾ", MessageBox.INFORMATION); + return; + } +// System.out.println(rows[0]); + editYSR8_QERevision(rows[0]); + } else { + MessageBox.post("ѡҪ༭ݣ", "ʾ", MessageBox.INFORMATION); + } + } + }); + + btn = (JButton)fu.allComponentMap.get("b.11.12.13"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + outputYSR8_QERevision(); + } + }); + + } + + private void searchYSR8_QERevision() { + quotationRevisions.clear(); + itemMap.clear(); + + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a.21.11.11"); + + int nRowCount = ci.dataTableModel.getRowCount(); + for(int i=nRowCount-1; i>=0; i--){ + ci.dataTableModel.removeRow(i); + } + ci.dataTableModel.getDataVector().clear(); + + Map DateNames = new HashMap<>(); + DateNames.put("ʱ", "ReceiveDate"); + DateNames.put("ʱ", "SysPlanDate"); + DateNames.put("ʱ", "FinishedDate"); + DateNames.put("Ԥʱ", "EstimatedDate"); + @SuppressWarnings({ "unchecked", "rawtypes" }) + JComboBox cb = (JComboBox)fu.allComponentMap.get("DateName");// + String DateName = ""; + DateName = cb.getSelectedItem().toString(); + @SuppressWarnings({ "unchecked", "rawtypes" }) + JComboBox qs = (JComboBox)fu.allComponentMap.get("QuotationStatus");//״̬ + String + QuotationStatus = qs.getSelectedItem().toString(); + iTextField itf = (iTextField)fu.allComponentMap.get("c_ysr8_ProjectManager");//Ŀ + String ProjectManager = ""; + ProjectManager = itf.getText(); + itf = (iTextField)fu.allComponentMap.get("c_ysr8_Sales");// + String Sales = ""; + Sales = itf.getText(); + itf = (iTextField)fu.allComponentMap.get("c_ysr8_OrderManufacturer");// + String OrderManufacturer = ""; + OrderManufacturer = itf.getText(); + itf = (iTextField)fu.allComponentMap.get("c_ysr8_CustomerName");//û + String CustomerName = ""; + CustomerName = itf.getText(); + + DateButton db = (DateButton)fu.allComponentMap.get("c_ysr8_Date1"); + Date date1 = new Date(); + date1 = db.getDate(); + String ysr8_Date1 = ""; + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-d"); + if (date1 != null) { + ysr8_Date1 = sdf.format(date1) + " 00:00"; + } + + db = (DateButton)fu.allComponentMap.get("c_ysr8_Date2"); + Date date2 = new Date(); + date2 = db.getDate(); + String ysr8_Date2 = ""; + if (date2 != null) { + ysr8_Date2 = sdf.format(date2) + " 23:59"; + } + if (QuotationStatus.equals("") && ProjectManager.isEmpty() && Sales.isEmpty() && OrderManufacturer.isEmpty() + && CustomerName.isEmpty() && ysr8_Date1.isEmpty() && ysr8_Date2.isEmpty()) { + MessageBox.post("ѯ", "ʾ", MessageBox.INFORMATION); + return; + } + if (DateName.isEmpty() && (!ysr8_Date1.isEmpty() || !ysr8_Date2.isEmpty())) { + MessageBox.post("ѡͣ", "ʾ", MessageBox.INFORMATION); + return; + } + + Vector attrVec = new Vector(); + Vector valVec = new Vector(); + +// attrVec.add("ysr8_ProjectManager"); +// valVec.add("*"); + + if(!DateName.equals("")) { + if (!ysr8_Date1.equals("")) { + attrVec.add(DateNames.get(DateName)+"1"); + valVec.add(ysr8_Date1); + } + if (!ysr8_Date2.equals("")) { + attrVec.add(DateNames.get(DateName)+"2"); + valVec.add(ysr8_Date2); + } + } + if (!ProjectManager.equals("")) { + attrVec.add("ProjectManager"); + valVec.add(ProjectManager); + } + if (!Sales.equals("")) { + attrVec.add("Sales"); + valVec.add(Sales); + } + if (!OrderManufacturer.equals("")) { + attrVec.add("OrderManufacturer"); + valVec.add(OrderManufacturer); + } + if (!CustomerName.equals("")) { + attrVec.add("CustomerName"); + valVec.add(CustomerName); + } + if (!QuotationStatus.equals("")) { + attrVec.add("QuotationStatus"); + valVec.add(QuotationStatus); + } + + try { + String[] attrs = (String[]) attrVec.toArray(new String[attrVec.size()]); + String[] vals = (String[]) valVec.toArray(new String[attrVec.size()]); + TCComponent[] tcComponents = TCUtil.query(fu.session, "SearchQuotationRevision", attrs, vals); + DecimalFormat df = new DecimalFormat(",###,###"); + + Integer idx = 0; + for (int i = 0; i < tcComponents.length; i++) { + TCComponentItemRevision quotationRevision = (TCComponentItemRevision)tcComponents[i]; + TCComponentItem quotationItem = quotationRevision.getItem(); + itemMap.put(idx, quotationItem); + quotationRevisions.add(quotationRevision); + TCComponentForm quotationRevisionForm = TCUtil.getItemRevisionMasterForm(quotationRevision); + + Vector vec = new Vector<>(); + vec.add((++idx) + "");// + +// String sItemId = quotationRevisionForm.getProperty("ItemID"); + String sItemId = quotationRevision.getProperty("item_id"); + vec.add(sItemId);//۱ + vec.add(quotationItem.getProperty("object_name"));// + + //ItemID + Vector itemInfos = CommonUtil.split2Vector(sItemId, "-"); + String sHY = ""; + String sGB = ""; + String sYT = ""; + if(itemInfos.size()>4) { + sHY = itemInfos.get(3); + sGB = itemInfos.get(1); + sYT = itemInfos.get(4); + } + vec.add(quotationRevisionForm.getProperty("ysr8_OrderManufacturer"));// lidy20190704 + vec.add(quotationRevisionForm.getProperty("ysr8_CustomerName"));//ʹ÷ + vec.add(sHY);//ҵ + vec.add(sGB);// + vec.add(sYT);//; + vec.add(quotationRevisionForm.getProperty("ysr8_use"));//;2 + vec.add(quotationRevisionForm.getProperty("ysr8_Product"));//Ʒ + vec.add(quotationRevisionForm.getProperty("ysr8_SytemName"));//ϵͳ + + + vec.add(quotationRevisionForm.getProperty("ysr8_Sales"));//۵ + vec.add(quotationRevisionForm.getProperty("ysr8_ProjectManager"));//۵ + vec.add(quotationRevisionForm.getDateProperty("ysr8_ReceiveDate")==null?"": + String.format("%tF", quotationRevisionForm.getDateProperty("ysr8_ReceiveDate")));//ʱ + vec.add(quotationRevisionForm.getDateProperty("ysr8_SysPlanDate")==null?"": + String.format("%tF", quotationRevisionForm.getDateProperty("ysr8_SysPlanDate")));// + vec.add(quotationRevisionForm.getDateProperty("ysr8_FinishedDate")==null?"": + String.format("%tF", quotationRevisionForm.getDateProperty("ysr8_FinishedDate")));//ʱ + + + String ysr8_sfas = ""; + String ysr8_FinishedDate = quotationRevisionForm.getProperty("ysr8_FinishedDate"); + if (ysr8_FinishedDate.isEmpty() || ysr8_FinishedDate == null) { + ysr8_sfas = ""; + } + else{ + int nn = CommonUtil.getDaysBetween(quotationRevisionForm.getProperty("ysr8_SysPlanDate"), ysr8_FinishedDate); + if (nn > 0) { + ysr8_sfas = "NG"; + } + else{ + ysr8_sfas = "OK"; + } + } + vec.add(ysr8_sfas);//Ƿʱ + vec.add(quotationRevisionForm.getProperty("ysr8_RobotModelAndNum"));//ͺ̨ + + vec.add(quotationRevisionForm.getProperty("ysr8_RobotCount"));//TODO + vec.add(quotationRevisionForm.getProperty("ysr8_Positioner"));//λ + vec.add(quotationRevisionForm.getProperty("ysr8_Fixture"));//Уץ + vec.add(quotationRevisionForm.getProperty("ysr8_Grid"));//ȫ + vec.add(quotationRevisionForm.getProperty("ysr8_Attachment"));// + + //ysr8_ActualDeliveryDate + + vec.add(quotationRevisionForm.getProperty("ysr8_ProjectLevel"));//۵ȼ + vec.add(quotationItem.getDateProperty("ysr8_EstimatedDate")==null?"": + String.format("%tF", quotationItem.getDateProperty("ysr8_EstimatedDate")));//Ԥʱ + vec.add(quotationItem.getProperty("ysr8_Possibility").isEmpty()?"":quotationItem.getProperty("ysr8_Possibility")+"%");// + String ysr8_QuotationStatus = quotationItem.getProperty("ysr8_QuotationStatus");//lidy20181112״̬ΪʱĿ + if(ysr8_QuotationStatus.isEmpty()) { + Vector attrVecxmkb = new Vector(); + Vector valVecxmkb = new Vector(); + if (!sItemId.equals("")) { + attrVecxmkb.add("ysr8_QuotationNo"); + valVecxmkb.add(sItemId); + } + + String[] attrsxmkb = (String[]) attrVecxmkb.toArray(new String[attrVecxmkb.size()]); + String[] valsxmkb = (String[]) valVecxmkb.toArray(new String[attrVecxmkb.size()]); + TCComponent[] tcxmkbComponents = null; + tcxmkbComponents = TCUtil.query(fu.session, "SearchProjectRevisionWithQuotationNo", attrsxmkb, valsxmkb); + + if (tcxmkbComponents.length > 0) { + TCComponentItemRevision psRevision = (TCComponentItemRevision)tcxmkbComponents[0]; + TCComponentForm psRevisionForm = TCUtil.getItemRevisionMasterForm(psRevision); + +// ysr8_ActualDeliveryDate = psRevisionForm.getProperty("ysr8_ActualDeliveryDate"); + ysr8_QuotationStatus = psRevisionForm.getProperty("ysr8_ProjectCode"); + } +// vec.add(ysr8_ActualDeliveryDate); //ͻҪ + } + vec.add(ysr8_QuotationStatus);//״̬ + + String ysr8_OfferAmount = ""; + ysr8_OfferAmount = quotationRevisionForm.getProperty("ysr8_OfferAmount"); + String ysr8_xs = ""; + ysr8_xs = quotationRevisionForm.getProperty("ysr8_Ratio"); +// String ysr8_SytemName = quotationRevisionForm.getProperty("ysr8_SytemName"); +// if (ysr8_SytemName.indexOf("ĥ") != -1 || sYT.equals("HL") || sYT.equals("CR")) { +// ysr8_xs = "1.5"; +// } + vec.add(quotationRevisionForm.getProperty("ysr8_NoRobotCost"));//˳ɱܽ + double dOfferAmount = 0d; + double dxs = 0d; + double dZSJE = 0d; + try { + dOfferAmount = Double.parseDouble(ysr8_OfferAmount); + vec.add(df.format(dOfferAmount));//۽ + } catch(NumberFormatException e) { + System.out.println("۵"+sItemId+"ı۽"+ysr8_OfferAmount+"ΪջСʽ"); + vec.add(ysr8_OfferAmount);//۽ + } + vec.add(ysr8_xs);//ϵ + try { + dxs = Double.parseDouble(ysr8_xs); + } catch(NumberFormatException e) { + System.out.println("۵"+sItemId+"ϵ"+ysr8_xs+"ΪջСʽ"); + } + dZSJE = dOfferAmount * dxs; +// String sZSJE = fu.getDoubleString(dZSJE); + vec.add(df.format(dZSJE));// + +// vec.add(ysr8_ProjectCode); + vec.add(quotationItem.getStringProperty("ysr8_HistoricRev"));//Ѵݰ汾 + vec.add(quotationItem.getProperty("ysr8_QuotationRemarks"));//ע + + ci.dataTableModel.addRow(vec); + + } + + } catch (Exception ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } + } + + private void outputYSR8_QERevision() { + final JTable table = (JTable)fu.allComponentMap.get("a.21.11.11"); + final JButton btn = (JButton)fu.allComponentMap.get("b.11.12.12"); + btn.setEnabled(false); + final ProgressReporterDialog reporter = new ProgressReporterDialog(); + reporter.reportProgressMessage("ڵ,Ժ..."); + new Thread(reporter).start(); + new Thread() { + public void run() { + for(int i=0; i t3 = new JComboBox(s2); + t3.setBounds(120, 70, 150, 22); + final JTextArea t4 = new JTextArea(); + t4.setBounds(70, 100, 200, 122); + t4.setBorder(BorderFactory.createLoweredBevelBorder()); + t4.setLineWrap(true); + t4.setWrapStyleWord(true); + +// TCComponentForm form = null; +// final String formUID = form.getUid(); + try { +// form = TCUtil.getItemRevisionMasterForm(quotationRevisions.get(row)); + t1.setDate(item.getDateProperty("ysr8_EstimatedDate")); + t2.setText(item.getProperty("ysr8_Possibility")); + t3.setSelectedItem(item.getProperty("ysr8_QuotationStatus")); + t4.setText(item.getProperty("ysr8_QuotationRemarks")); + } catch (Exception e1) { + e1.printStackTrace(); + } + JButton b1 = new JButton("ȷ"); + b1.setBounds(50, 230, 90, 22); + JButton b2 = new JButton("ȡ"); + b2.setBounds(150, 230, 90, 22); + + b1.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + try { + JTable table = (JTable) fu.allComponentMap.get("a.21.11.11"); +// CommonUtil.setByPass(true); +// item.lock(); +// item.setDateProperty("ysr8_EstimatedDate", t1.getDate()); +// item.setStringProperty("ysr8_Possibility", t2.getText()); +// item.setStringProperty("ysr8_QuotationStatus", t3.getSelectedItem().toString()); + String params = "", proName = ""; + StringBuilder proVal = new StringBuilder("");//TODO + proName = "ysr8_EstimatedDate@@@@ysr8_Possibility@@@@ysr8_QuotationStatus@@@@ysr8_QuotationRemarks"; + proVal.append(fu.getDateString(t1.getDate())).append("@@@@").append(t2.getText()).append("@@@@"); + proVal.append(t3.getSelectedItem().toString()).append("@@@@").append(t4.getText()); + params = item.getUid() + "^^^^" + proName + "^^^^" + proVal.toString(); +// System.out.println("params" + params); + String cmd = "Update_Item_TCProperty"; + Object[] objParams = new Object[2]; + objParams[0] = cmd; + objParams[1] = params; + TCUserService userService = fu.session.getUserService(); + String result = (String) userService.call("YSR8UserService", objParams); + System.out.println("±ίItemԣ"+result); +// item.save(); +// item.unlock(); +// CommonUtil.setByPass(false); +// params = formUID + "^^^^ysr8_Remark^^^^" + t4.getText(); +// cmd = "Update_Form_TCProperty"; +// objParams = new Object[2]; +// objParams[0] = cmd; +// objParams[1] = params; +// result = (String) userService.call("YSR8UserService", objParams); +// System.out.println("±ίбԣ"+result); + + table.setValueAt(t1.getDate()==null?"":String.format("%tF", t1.getDate()), row, 22); + table.setValueAt(t2.getText()+"%", row, 23); + table.setValueAt(t3.getSelectedItem().toString(), row, 24); + table.setValueAt(t4.getText(), row, 30); + } catch (Exception e1) { + e1.printStackTrace(); + } + dialog.dispose(); + } + }); + b2.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + dialog.dispose(); + } + }); + dialog.add(l1); + dialog.add(l2); + dialog.add(l3); + dialog.add(l4); + dialog.add(t1); + dialog.add(t2); + dialog.add(t3); + dialog.add(b1); + dialog.add(b2); + dialog.add(l5); + dialog.add(t4); + dialog.add(new JLabel("")); + dialog.setBounds(600, 200, 310, 295); + dialog.setVisible(true); + } +} diff --git a/src/cn/com/ebewin/ysr/dialog/YSR8_TotalContentDialog.java b/src/cn/com/ebewin/ysr/dialog/YSR8_TotalContentDialog.java new file mode 100644 index 0000000..deaf7eb --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/YSR8_TotalContentDialog.java @@ -0,0 +1,831 @@ +package cn.com.ebewin.ysr.dialog; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.io.File; +import java.io.IOException; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Vector; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.ListSelectionModel; +import javax.swing.RowSorter; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableColumnModel; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; + +import org.apache.poi.hssf.model.ConvertAnchor; + +import cn.com.ebewin.ysr.dialog.SysCatalogRevisionMasterBean; +import cn.hutool.json.JSONUtil; +import jxl.Workbook; +import jxl.format.Alignment; +import jxl.format.Border; +import jxl.format.BorderLineStyle; +import jxl.format.VerticalAlignment; +import jxl.write.Label; +import jxl.write.WritableCellFormat; +import jxl.write.WritableFont; +import jxl.write.WritableSheet; +import jxl.write.WritableWorkbook; +import jxl.write.WriteException; +import net.sf.json.JSON; + +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +public class YSR8_TotalContentDialog extends JFrame implements ActionListener{ + + private Map textMap = new HashMap<>(); + private TCSession session; + private JTable table; + private String[] header = new String[] {"","Ŀ",""}; + private String[] header2 = new String[] {"", "Ŀ","", "", "","Ա", "","", "ǷҪ", "ûͼ","","ƻɱ", "ȡ","ƻʱ"}; + protected DefaultTableModel tm_part; + private String[] condition; + private HashMap revMap = new HashMap (); + private List valueLists; + private List AllValueLists; + private TCProperty propertiesArray[]; + + public YSR8_TotalContentDialog(TCSession session) { + // TODO Auto-generated constructor stub + this.session = session; + initUI(); + } + private Map uomTags = new HashMap(); + public void initUI() { + // TODO Auto-generated method stub + + this.setTitle("ϵͳĿ¼̨"); + this.setLayout(new BorderLayout()); + + JPanel topPanel = getTopPanel(); + + JScrollPane pane = getTablePanel(); + pane.setBorder(BorderFactory.createTitledBorder("")); +// JPanel btnPanel = getRightPanel(); + + + this.add(topPanel,BorderLayout.NORTH); + this.add(pane,BorderLayout.CENTER); + JScrollPane tablePanelRight = getTablePanelRight(); + tablePanelRight.setBorder(BorderFactory.createTitledBorder("")); + comp = tablePanelRight; + this.add(tablePanelRight,BorderLayout.EAST); + this.createActionEvent(); + this.pack(); + this.setPreferredSize(new Dimension(1850,950)); + this.validate(); + this.setVisible(true); + this.setLocationRelativeTo(null); + } + + private JButton btnQry; + private JScrollPane comp; + private JButton btnExport; + + private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + private DateButton startButton; + private DateButton endButton; + private JTable table2; + private DefaultTableModel dtm2; + private DefaultTableModel dtm1; + + //ѯ + private JPanel getTopPanel() { + // TODO Auto-generated method stub + JPanel topPanel = new JPanel(); + startButton = new DateButton(null, "yyyy-MM-dd", false, false, false); + endButton = new DateButton(null, "yyyy-MM-dd", false, false, false); + startButton.setDate("δ"); + endButton.setDate("δ"); +// startButton.set + btnQry = new JButton("ѯ"); + btnExport = new JButton(""); + topPanel.add("1.1.left.center",new JLabel("ͣʱ")); + topPanel.add("1.2.left.center",new JLabel(" ʼʱ䣺")); + topPanel.add("1.3.left.center",endButton); + topPanel.add("1.4.left.center",new JLabel("ʱ䣺")); + topPanel.add("1.5.left.center",startButton); + topPanel.add("1.6.left.center",btnQry); + + topPanel.add("1.6.left.center",btnExport); + return topPanel; + } + + // Ӽ + public void createActionEvent() { + this.btnQry.addActionListener(this); + this.btnExport.addActionListener(this); + //˫bomͼ + this.table.addMouseListener(new MouseListener() { + + @Override + public void mouseReleased(MouseEvent var1) { + // TODO Auto-generated method stub + + } + + @Override + public void mousePressed(MouseEvent var1) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseExited(MouseEvent var1) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseEntered(MouseEvent var1) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseClicked(MouseEvent var1) { + // TODO Auto-generated method stub + if (var1.getClickCount() == 2) { + System.out.println("click 2"); + for(int t=dtm2.getRowCount()-1;t>=0;t--) { + dtm2.removeRow(t); + } + + String str = (String)table.getValueAt(table.getSelectedRow(), 1); + TCComponentForm form = null; + TCComponentItemRevision selectRev = revMap.get(str); + try { + valueLists = new ArrayList<>(); + form = (TCComponentForm)selectRev.getRelatedComponent("IMAN_master_form_rev"); + String[] args = { "ysr8_ID", "ysr8_object", "ysr8_Quantity","ysr8_Designer1", "ysr8_Category", "ysr8_SubProjectType1","ysr8_Electric", + "ysr8_CustomPartCode1","ysr8_Cost", "ysr8_Cancel","ysr8_PlanWorkTime" }; + propertiesArray = form.getTCProperties(args); + if(propertiesArray != null) + { + String valueStrs0[] = propertiesArray[0] != null ? propertiesArray[0].getStringArrayValue() : new String[0]; + String valueStrs1[] = propertiesArray[1] != null ? propertiesArray[1].getStringArrayValue() : new String[0]; + double valueStrs2[] = propertiesArray[2] != null ? propertiesArray[2].getDoubleArrayValue() : new double[0]; + String valueStrs3[] = propertiesArray[4] != null ? propertiesArray[4].getStringArrayValue() : new String[0]; + String valueStrs5[] = propertiesArray[6] != null ? propertiesArray[6].getStringArrayValue() : new String[0]; + double valueStrs7[] = propertiesArray[8] != null ? propertiesArray[8].getDoubleArrayValue() : new double[0]; + String valueStrs9[] = propertiesArray[9] != null ? propertiesArray[9].getStringArrayValue() : new String[0]; + + String valueStrs4[] = propertiesArray[3] != null ? propertiesArray[3].getStringArrayValue() : new String[0]; + String valueStrs6[] = propertiesArray[5] != null ? propertiesArray[5].getStringArrayValue() : new String[0]; + String valueStrs8[] = propertiesArray[7] != null ? propertiesArray[7].getStringArrayValue() : new String[0]; + double valueStrs11[] = propertiesArray[10] != null ? propertiesArray[10].getDoubleArrayValue() : new double[0]; + //ʱ + String[] split = str.split("_");//Ŀ + String qdsj = getQdsj(split[0]); + System.out.println("qdsj=="+qdsj); + + for(int i = 0; i < valueStrs0.length; i++) + { + SysCatalogRevisionMasterBean bean = new SysCatalogRevisionMasterBean(); + bean.setYsr8_ID(valueStrs0[i]); + bean.setYsr8_object(valueStrs1[i]); + bean.setYsr8_Quantity(valueStrs2[i]==0?"0.00":doubleTwoString(valueStrs2[i])); + bean.setYsr8_Category(valueStrs3[i]); + bean.setYsr8_Electric(valueStrs5[i]); + bean.setYsr8_Cost(valueStrs7[i]==0?"":doubleTwoString(valueStrs7[i])); + bean.setYsr8_Cancel(valueStrs9[i]); + + if(valueStrs4.length > i) {bean.setYsr8_Designer(valueStrs4[i]);} + else { + bean.setYsr8_Designer(""); + } + + if(valueStrs6.length > i) {bean.setYsr8_SubProjectType(valueStrs6[i]);} + else { + bean.setYsr8_SubProjectType(""); + } + + if(valueStrs8.length > i) { bean.setYsr8_CustomPartCode(valueStrs8[i]);} + else { + bean.setYsr8_CustomPartCode(""); + } + + if(valueStrs11.length > i) {bean.setYsr8_PlanWorkTime(doubleTwoString(valueStrs11[i]));} + else { + bean.setYsr8_PlanWorkTime(""); + } + bean.setYsr8_qzsj(qdsj); + bean.setXmh(split[0]);; + valueLists.add(bean); + } + System.out.println("valueList.lenth"+valueLists.size()); + setTable2Value(valueLists); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + }else if(var1.getClickCount() == 1) { + //ʾ + System.out.println("click 1"); + + for(int t=dtm2.getRowCount()-1;t>=0;t--) { + dtm2.removeRow(t); + } + + String str = (String)table.getValueAt(table.getSelectedRow(), 1); + TCComponentForm form = null; + TCComponentItemRevision selectRev = revMap.get(str); + try { + valueLists = new ArrayList<>(); + form = (TCComponentForm)selectRev.getRelatedComponent("IMAN_master_form_rev"); + String[] args = { "ysr8_ID", "ysr8_object", "ysr8_Quantity","ysr8_Designer1", "ysr8_Category", "ysr8_SubProjectType1","ysr8_Electric", + "ysr8_CustomPartCode1","ysr8_Cost", "ysr8_Cancel","ysr8_PlanWorkTime" }; + propertiesArray = form.getTCProperties(args); + if(propertiesArray != null) + { + String valueStrs0[] = propertiesArray[0] != null ? propertiesArray[0].getStringArrayValue() : new String[0]; + String valueStrs1[] = propertiesArray[1] != null ? propertiesArray[1].getStringArrayValue() : new String[0]; + double valueStrs2[] = propertiesArray[2] != null ? propertiesArray[2].getDoubleArrayValue() : new double[0]; + String valueStrs3[] = propertiesArray[4] != null ? propertiesArray[4].getStringArrayValue() : new String[0]; + String valueStrs5[] = propertiesArray[6] != null ? propertiesArray[6].getStringArrayValue() : new String[0]; + double valueStrs7[] = propertiesArray[8] != null ? propertiesArray[8].getDoubleArrayValue() : new double[0]; + String valueStrs9[] = propertiesArray[9] != null ? propertiesArray[9].getStringArrayValue() : new String[0]; + + String valueStrs4[] = propertiesArray[3] != null ? propertiesArray[3].getStringArrayValue() : new String[0]; + String valueStrs6[] = propertiesArray[5] != null ? propertiesArray[5].getStringArrayValue() : new String[0]; + String valueStrs8[] = propertiesArray[7] != null ? propertiesArray[7].getStringArrayValue() : new String[0]; + double valueStrs11[] = propertiesArray[10] != null ? propertiesArray[10].getDoubleArrayValue() : new double[0]; + //ʱ + String[] split = str.split("_");//Ŀ + String qdsj = getQdsj(split[0]); + System.out.println("qdsj=="+qdsj); + + for(int i = 0; i < valueStrs0.length; i++) + { + SysCatalogRevisionMasterBean bean = new SysCatalogRevisionMasterBean(); + bean.setYsr8_ID(valueStrs0[i]); + bean.setYsr8_object(valueStrs1[i]); + bean.setYsr8_Quantity(valueStrs2[i]==0?"0.00":doubleTwoString(valueStrs2[i])); + bean.setYsr8_Category(valueStrs3[i]); + bean.setYsr8_Electric(valueStrs5[i]); + if(valueStrs7.length > i) {bean.setYsr8_Cost(valueStrs7[i]==0?"":doubleTwoString(valueStrs7[i]));} + else { + bean.setYsr8_Cost(""); + } + + bean.setYsr8_Cancel(valueStrs9[i]); + //TODO ,˴жϴvalueStrs4.length=iʱΪ0ʱvalueStrs4[0]ΪnullԭĴbean.setYsr8_Designer(valueStrs4[i] == null)϶DzԵģ֪дδô + if(valueStrs4.length > i) { + bean.setYsr8_Designer(valueStrs4[i] == null ? "":valueStrs4[i]); + } + else { + bean.setYsr8_Designer(""); + } + + if(valueStrs6.length > i) {bean.setYsr8_SubProjectType(valueStrs6[i] == null ? "":valueStrs6[i]);} + else { + bean.setYsr8_SubProjectType(""); + } + + if(valueStrs8.length > i) { bean.setYsr8_CustomPartCode(valueStrs8[i] == null ? "":valueStrs8[i]);} + else { + bean.setYsr8_CustomPartCode(""); + } + + if(valueStrs11.length > i) {bean.setYsr8_PlanWorkTime(doubleTwoString(valueStrs11[i]));} + else { + bean.setYsr8_PlanWorkTime(""); + } + bean.setYsr8_qzsj(qdsj); + bean.setXmh(split[0]);; + valueLists.add(bean); + } + System.out.println("valueList.lenth="+valueLists.size()); + setTable2Value(valueLists); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + } + }); + } + + + protected String getQdsj(String string) { + // TODO Auto-generated method stub + TCComponent[] search = null; + try { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-hh"); + search = session.search("Ŀѯ", + new String[] {"Ŀ ID"}, + new String[] {string}); + if(search != null && search.length > 0) { + TCComponentItemRevision rev = (TCComponentItemRevision)search[0]; + TCComponentForm form = (TCComponentForm)rev.getRelatedComponent("IMAN_master_form_rev"); + Date date = form.getDateProperty("ysr8_StartDate"); + String dateStr = simpleDateFormat.format(date); + + return dateStr; + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + MessageBox.post("δҵʱ","ʾ",2); + } + + return ""; + } + + private JScrollPane getTablePanel() { + // TODO Auto-generated method stub + table = getjTable(null, null, header, null,false); + table.setRowHeight(30); + table.getColumnModel().getColumn(0).setPreferredWidth(50); + table.getColumnModel().getColumn(1).setPreferredWidth(150); + table.getColumnModel().getColumn(2).setPreferredWidth(300); +// table.setPreferredSize(new Dimension(1500,400)); + table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // ñԶģʽΪرԶ +// table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);//JTableпбݵĴСе +// table.setPreferredSize(new Dimension(1200,400)); + JScrollPane pane = new JScrollPane(table,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + pane.setPreferredSize(new Dimension(300,900)); + pane.setViewportView(table);//ΪscrollPaneָʾΪtable + return pane; + } + private JScrollPane getTablePanelRight() { + // TODO Auto-generated method stub + table2 = getjTable(null, null, header2, null,true); + table2.setRowHeight(30); + //ÿһп + TableColumnModel columnModel = table2.getColumnModel(); + columnModel.getColumn(0).setPreferredWidth(50); + columnModel.getColumn(1).setPreferredWidth(100); + columnModel.getColumn(2).setPreferredWidth(100); + columnModel.getColumn(3).setPreferredWidth(120); + columnModel.getColumn(4).setPreferredWidth(70); + columnModel.getColumn(5).setPreferredWidth(100); + columnModel.getColumn(6).setPreferredWidth(100); + columnModel.getColumn(7).setPreferredWidth(100); + columnModel.getColumn(8).setPreferredWidth(150); + columnModel.getColumn(9).setPreferredWidth(100); + columnModel.getColumn(10).setPreferredWidth(100); + columnModel.getColumn(11).setPreferredWidth(100); + columnModel.getColumn(12).setPreferredWidth(100); + columnModel.getColumn(13).setPreferredWidth(100); +// table.setPreferredSize(new Dimension(1500,400)); + table2.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // ñԶģʽΪرԶ +// table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);//JTableпбݵĴСе +// table.setPreferredSize(new Dimension(1200,400)); + JScrollPane pane = new JScrollPane(table2,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + pane.setPreferredSize(new Dimension(1400,900)); + pane.setViewportView(table2);//ΪscrollPaneָʾΪtable + return pane; + } + /*** + * Jtableͨ÷ + * + * @param partsTable + * @param dtm + * @param titleNames + * @param values + * @return + */ + public JTable getjTable(JTable partsTable, DefaultTableModel dtm, Object[] titleNames, Object[][] values,Boolean isTable2) { +// int simpleLen = 100; +// int totleLen = 1000; + if (partsTable == null) { + partsTable = new JTable(this.getTableModel(dtm, titleNames, values,isTable2)); + partsTable.setRowHeight(20); + partsTable.getTableHeader().setReorderingAllowed(false); + partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + RowSorter sorter = new TableRowSorter(partsTable.getModel()); + partsTable.setRowSorter(sorter); +// for (int i = 0; i < titleNames.length; i++) { +// if(i==2) { +// partsTable.getColumnModel().getColumn(i).setPreferredWidth(200); +// }else { +// partsTable.getColumnModel().getColumn(i).setPreferredWidth(120); +// } +// +// } + + } + return partsTable; + } + public DefaultTableModel getTableModel(DefaultTableModel dtm, Object[] titleNames, Object[][] values,Boolean isTable2) { + + if(isTable2) { + dtm2 = null; + if (dtm == null) { + dtm2 = new DefaultTableModel(values, titleNames) { + @Override + public boolean isCellEditable(int row, int column) { + return false; + } + }; + } + return dtm2; + }else { + dtm1 = null; + if (dtm == null) { + dtm1 = new DefaultTableModel(values, titleNames) { + @Override + public boolean isCellEditable(int row, int column) { + return false; + } + }; + } + return dtm1; + } + + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + System.out.println("source==>+"+source); + //ѯťֻѯĿźĿ + if(source.equals(this.btnQry)) { + + try { + Date starDate = startButton.getDate(); + Date endDate = endButton.getDate(); + if(starDate == null && endDate == null) { + MessageBox.post("ѡʱ䣡","ʾ",2); + return; + } + //ѯ-ɾ֮ǰѯļ¼ + for(int t=dtm1.getRowCount()-1;t>=0;t--) { + dtm1.removeRow(t); + } + for(int t=dtm2.getRowCount()-1;t>=0;t--) { + dtm2.removeRow(t); + } + //һֵIJѯɾһβѯʱmapеʷѯ + revMap.clear(); + + TCComponent[] search = getRev(starDate,endDate); + TCComponent[] searchName=null; + if(search != null) { + for (int i = 0; i < search.length; i++) { + TCComponentItemRevision rev = (TCComponentItemRevision)search[i]; + Vector vec = new Vector(); + vec.add(i+1+""); + + String strId = rev.getStringProperty("item_id"); + String[] split = strId.split("_");//Ŀ + vec.add(split[0]); + + //ϹĿĿ + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-hh"); + searchName = session.search("ĿŲѯĿ", + new String[] {"Ŀ ID"}, + new String[] {split[0]}); + if(searchName != null && searchName.length > 0) { + TCComponentProject project = (TCComponentProject)searchName[0]; + vec.add(project.getStringProperty("object_name")); + }else { + vec.add(""); + } + dtm1.addRow(vec); + revMap.put(split[0],rev); + } + } + } catch (Exception e2) { + // TODO: handle exception + e2.printStackTrace(); + } + }else if(source.equals(this.btnExport)){ + // + final ProgressReporterDialog reporter = new ProgressReporterDialog(); + reporter.reportProgressMessage("ڵ,Ժ..."); + new Thread(reporter).start(); + AllValueLists = new ArrayList(); + new Thread() { + public void run() { + try { + Date date = new Date(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + String time = sdf.format(date); + String toPath = System.getProperty("java.io.tmpdir") + "ϵͳĿ¼" + time + ".xls"; + // һдWorkbook + WritableWorkbook writeWorkBook = Workbook.createWorkbook(new File(toPath)); + // + WritableSheet wsheet = writeWorkBook.createSheet("ϵͳĿ¼", 0); + + //д + int columnCount = table2.getColumnCount(); // + String[] titles = new String[columnCount]; // ͷ + + // ȡͷ + for (int i = 0; i < columnCount; i++) { + titles[i] = table2.getColumnName(i); + } + + int current_row = 0; // ʼǰΪʼ + + try { + // ʽ + WritableFont titleFont = new WritableFont(WritableFont.createFont(""), 13,WritableFont.BOLD); + WritableCellFormat titleCellFormat = new WritableCellFormat(titleFont); + titleCellFormat.setBorder(Border.ALL, BorderLineStyle.MEDIUM); + titleCellFormat.setAlignment(Alignment.CENTRE); + titleCellFormat.setVerticalAlignment(VerticalAlignment.CENTRE); + titleCellFormat.setWrap(true); + + // ʽ + WritableFont contentFont = new WritableFont(WritableFont.createFont(""), 12); + WritableCellFormat contentCellFormat = new WritableCellFormat(contentFont); + contentCellFormat.setBorder(Border.ALL, BorderLineStyle.THIN); + contentCellFormat.setAlignment(Alignment.CENTRE); + contentCellFormat.setVerticalAlignment(VerticalAlignment.CENTRE); + contentCellFormat.setWrap(true); + + // дб + for (int i = 0; i < columnCount; i++) { + Label labelTitle = new Label(i, current_row, titles[i], titleCellFormat); + wsheet.addCell(labelTitle); + } + + current_row = current_row + 1; + // д + //ȡ + List values = null; + try { + values = getValues(revMap); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + for (int i = 0; i < values.size(); i++) { + SysCatalogRevisionMasterBean bean = values.get(i); + try { + Label labelContent0 = new Label(0, i + current_row, String.valueOf(i+1), contentCellFormat); + wsheet.addCell(labelContent0); + + Label labelContent1 = new Label(1, i + current_row, String.valueOf(bean.getXmh().equals("") ? "" : bean.getXmh()), contentCellFormat); + wsheet.addCell(labelContent1); + + Label labelContent2 = new Label(2, i + current_row, String.valueOf(bean.getYsr8_ID().equals("") ? "" : bean.getYsr8_ID()), contentCellFormat); + wsheet.addCell(labelContent2); + + Label labelContent3 = new Label(3, i + current_row, String.valueOf(bean.getYsr8_object().equals("") ? "" : bean.getYsr8_object()), contentCellFormat); + wsheet.addCell(labelContent3); + + Label labelContent4 = new Label(4, i + current_row, String.valueOf(bean.getYsr8_Quantity().equals("") ? "" : bean.getYsr8_Quantity()), contentCellFormat); + wsheet.addCell(labelContent4); + + Label labelContent5 = new Label(5, i + current_row, String.valueOf(bean.getYsr8_Designer().equals("") ? "" : bean.getYsr8_Designer()), contentCellFormat); + wsheet.addCell(labelContent5); + + Label labelContent6 = new Label(6, i + current_row, String.valueOf(bean.getYsr8_Category().equals("") ? "" : bean.getYsr8_Category()), contentCellFormat); + wsheet.addCell(labelContent6); + + Label labelContent7 = new Label(7, i + current_row, String.valueOf(bean.getYsr8_SubProjectType().equals("") ? "" : bean.getYsr8_SubProjectType()), contentCellFormat); + wsheet.addCell(labelContent7); + + Label labelContent8 = new Label(8, i + current_row, String.valueOf(bean.getYsr8_Electric().equals("") ? "" : bean.getYsr8_Electric()), contentCellFormat); + wsheet.addCell(labelContent8); + + Label labelContent9 = new Label(9, i + current_row, String.valueOf(bean.getYsr8_CustomPartCode().equals("") ? "" : bean.getYsr8_CustomPartCode()), contentCellFormat); + wsheet.addCell(labelContent9); + + Label labelContent10 = new Label(10, i + current_row, String.valueOf(bean.getYsr8_qzsj().equals("") ? "" : bean.getYsr8_qzsj()), contentCellFormat); + wsheet.addCell(labelContent10); + + Label labelContent11 = new Label(11, i + current_row, String.valueOf(bean.getYsr8_Cost().equals("") ? "" : bean.getYsr8_Cost()), contentCellFormat); + wsheet.addCell(labelContent11); + + Label labelContent12 = new Label(12, i + current_row, String.valueOf( bean.getYsr8_Cancel().equals("") ? "" : bean.getYsr8_Cancel()), contentCellFormat); + wsheet.addCell(labelContent12); + + Label labelContent13 = new Label(13, i + current_row, String.valueOf(bean.getYsr8_PlanWorkTime().equals("") ? "" : bean.getYsr8_PlanWorkTime()), contentCellFormat); + wsheet.addCell(labelContent13); + } catch (Exception e2) { + System.out.println("--------------------------------------------------------------------"); + e2.printStackTrace(); + System.out.println("쳣ĶϢ"+e2.getMessage()); + System.out.println(bean.toString()); + } + + } + + // øʽ + wsheet.getSettings().setDefaultColumnWidth(20); + writeWorkBook.write(); + writeWorkBook.close(); + } catch (WriteException e) { + e.printStackTrace(); + } + + // 򿪵ıļ + Runtime.getRuntime().exec("cmd /c \"" + toPath + "\""); + + } catch (IOException e) { + e.printStackTrace(); + } + reporter.requestCanceling(); + //btn.setEnabled(true); + } + }.start(); + } + } + + private TCComponent[] getRev(Date starDate, Date endDate) { + TCComponent[] search = null; + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-M-dd"); + try { + if(starDate == null && endDate != null){ + search = session.search("ͨĿʱѯϵͳĿ¼", + new String[] {"ʼ"}, + new String[] {simpleDateFormat.format(endDate).toString()+" 00:00"}); + System.out.println("1"); + + }else if(starDate != null && endDate == null){ + search = session.search("ͨĿʱѯϵͳĿ¼", + new String[] {"ʼ"}, + new String[] {simpleDateFormat.format(starDate).toString()+" 23:59"}); + System.out.println("2"); + }else if(starDate != null && endDate != null){ + search = session.search("ͨĿʱѯϵͳĿ¼", + new String[] {"ʼ","ʼ"}, + new String[] {simpleDateFormat.format(starDate).toString()+" 23:59",simpleDateFormat.format(endDate).toString()+" 00:00"}); + System.out.println("3"); + } + } catch (Exception e) { + e.printStackTrace(); + } + return search; + } + + /* + * ĿMapȡÿһĿ + * mapĿϢ:汾 + */ + public List getValues(HashMap map) throws TCException + { + System.out.println("getValuesstart"); + for (Entry m : map.entrySet()) { + String str = m.getKey(); + TCComponentItemRevision rev = m.getValue(); + TCComponentForm form = (TCComponentForm)rev.getRelatedComponent("IMAN_master_form_rev"); + String[] args = { "ysr8_ID", "ysr8_object", "ysr8_Quantity","ysr8_Designer1", "ysr8_Category", "ysr8_SubProjectType1","ysr8_Electric", + "ysr8_CustomPartCode1","ysr8_Cost", "ysr8_Cancel","ysr8_PlanWorkTime" }; + TCProperty[] propertiesArray = form.getTCProperties(args); + if(propertiesArray != null) + { + //ysr8_ID + String valueStrs0[] = propertiesArray[0] != null ? propertiesArray[0].getStringArrayValue() : new String[0]; + //ysr8_object + String valueStrs1[] = propertiesArray[1] != null ? propertiesArray[1].getStringArrayValue() : new String[0]; + //ysr8_Quantity + double valueStrs2[] = propertiesArray[2] != null ? propertiesArray[2].getDoubleArrayValue() : new double[0]; + //ysr8_Category + String valueStrs3[] = propertiesArray[4] != null ? propertiesArray[4].getStringArrayValue() : new String[0]; + //ysr8_Electric + String valueStrs5[] = propertiesArray[6] != null ? propertiesArray[6].getStringArrayValue() : new String[0]; + //ysr8_Cost + double valueStrs7[] = propertiesArray[8] != null ? propertiesArray[8].getDoubleArrayValue() : new double[0]; + //ysr8_Cancel + String valueStrs9[] = propertiesArray[9] != null ? propertiesArray[9].getStringArrayValue() : new String[0]; + //ysr8_Designer1 + String valueStrs4[] = propertiesArray[3] != null ? propertiesArray[3].getStringArrayValue() : new String[0]; + //ysr8_SubProjectType1 + String valueStrs6[] = propertiesArray[5] != null ? propertiesArray[5].getStringArrayValue() : new String[0]; + //ysr8_CustomPartCode1 + String valueStrs8[] = propertiesArray[7] != null ? propertiesArray[7].getStringArrayValue() : new String[0]; + //ysr8_PlanWorkTime + double valueStrs11[] = propertiesArray[10] != null ? propertiesArray[10].getDoubleArrayValue() : new double[0]; + //ʱ + String[] split = str.split("_");//Ŀ + String qdsj = getQdsj(split[0]);//split[0] - Ŀid + System.out.println("qdsj=="+qdsj); + + for(int i = 0; i < valueStrs0.length; i++) + { + System.out.println("================================================================"); + System.out.println("ʼbeanĿţ"+valueStrs1[i]+"ţ"+valueStrs0[i]); + System.out.println("i="+i); + SysCatalogRevisionMasterBean bean = new SysCatalogRevisionMasterBean(); + bean.setYsr8_ID(valueStrs0[i]); + bean.setYsr8_object(valueStrs1[i]); + bean.setYsr8_Quantity(valueStrs2[i]==0?"0.00":doubleTwoString(valueStrs2[i])); + bean.setYsr8_Category(valueStrs3[i]); + bean.setYsr8_Electric(valueStrs5[i]); + + if(valueStrs7.length > i) {bean.setYsr8_Cost(valueStrs7[i]==0?"":doubleTwoString(valueStrs7[i]));} + else { + bean.setYsr8_Cost(""); + } + bean.setYsr8_Cancel(valueStrs9[i]); + + if(valueStrs4.length > i) {//TODO ж + System.out.println("valueStrs4.length="+valueStrs4.length); + System.out.println("ΪԱֵ"+valueStrs4[i]); + bean.setYsr8_Designer(valueStrs4[i] == null ? "":valueStrs4[i]); + } + else { + System.out.println("valueStrs4.length="+valueStrs4.length); + System.out.println("valueStrs4Ϊ:Ysr8_Designer=''"); + bean.setYsr8_Designer(""); + } + + if(valueStrs6.length > i) {bean.setYsr8_SubProjectType(valueStrs6[i] == null ? "":valueStrs6[i]);} + else { + bean.setYsr8_SubProjectType(""); + } + + if(valueStrs8.length > i) { bean.setYsr8_CustomPartCode(valueStrs8[i] == null ? "":valueStrs8[i]);} + else { + bean.setYsr8_CustomPartCode(""); + } + + if(valueStrs11.length > i) {bean.setYsr8_PlanWorkTime(doubleTwoString(valueStrs11[i]));} + else { + bean.setYsr8_PlanWorkTime(""); + } + bean.setYsr8_qzsj(qdsj); + bean.setXmh(split[0]);; + AllValueLists.add(bean); + } + System.out.println("AllValueList.lenth="+AllValueLists.size()); + } + } + + return AllValueLists; + } + + public void setTable2Value(List beanList) { + System.out.println("setTable2Valuestart"); + for(int i = 0; i < beanList.size(); i++) + { + SysCatalogRevisionMasterBean bean = (SysCatalogRevisionMasterBean)beanList.get(i); + Vector vec = new Vector(); + try { + vec.add(i+1); + vec.add(bean.getXmh().equals("") ? "" : bean.getXmh()); + vec.add(bean.getYsr8_ID().equals("") ? "" : bean.getYsr8_ID()); + vec.add(bean.getYsr8_object().equals("") ? "" : bean.getYsr8_object()); + vec.add(bean.getYsr8_Quantity().equals("") ? "" : bean.getYsr8_Quantity()); + vec.add(bean.getYsr8_Designer().equals("") ? "" : bean.getYsr8_Designer()); + vec.add(bean.getYsr8_Category().equals("") ? "" : bean.getYsr8_Category()); + vec.add(bean.getYsr8_SubProjectType().equals("") ? "" : bean.getYsr8_SubProjectType()); + vec.add(bean.getYsr8_Electric().equals("") ? "" : bean.getYsr8_Electric()); + vec.add(bean.getYsr8_CustomPartCode().equals("") ? "" : bean.getYsr8_CustomPartCode()); + vec.add(bean.getYsr8_qzsj().equals("") ? "" : bean.getYsr8_qzsj()); + vec.add(bean.getYsr8_Cost().equals("") ? "" : bean.getYsr8_Cost()); + vec.add(bean.getYsr8_Cancel().equals("") ? "" : bean.getYsr8_Cancel()); + vec.add(bean.getYsr8_PlanWorkTime().equals("") ? "" : bean.getYsr8_PlanWorkTime()); + dtm2.addRow(vec); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + System.out.println(bean.toString()); + } + + } + } + + public String doubleTwoString(double o){ + DecimalFormat df = new DecimalFormat("0.00"); + String str = df.format(o); + if(str.equals("0.00")) { + return ""; + } + return str; + } +} \ No newline at end of file diff --git a/src/cn/com/ebewin/ysr/dialog/YSR8_TravelORDENCreateDialog.java b/src/cn/com/ebewin/ysr/dialog/YSR8_TravelORDENCreateDialog.java new file mode 100644 index 0000000..2f5b58a --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/YSR8_TravelORDENCreateDialog.java @@ -0,0 +1,351 @@ +package cn.com.ebewin.ysr.dialog; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.text.ParseException; +import java.util.Date; +import java.util.List; +import java.util.Vector; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JTable; +import javax.swing.event.TableModelEvent; +import javax.swing.event.TableModelListener; +import javax.swing.table.DefaultTableModel; + +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentGroupMember; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentProjectType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCFormProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.iTextField; + +import cn.com.ebewin.ysr.util.CreateDialogUtil; +import cn.com.ebewin.ysr.util.TCUtil; + +@SuppressWarnings("deprecation") +public class YSR8_TravelORDENCreateDialog extends JFrame { + private static final long serialVersionUID = 1L; + CreateDialogUtil fu = new CreateDialogUtil(this, "ίе", "YSR8_TravelORDENCreateDialog", "YSR8_TravelORDEN"); + TCComponentFolder parent = null; + String projectCode = ""; + TCComponentProject project = null; + public String itemType = "YSR8_TravelORDEN"; + public TCComponentItem newItem = null; + public TCComponentItemRevision newRevision = null; + public TCComponentForm newForm = null; + TCSession session = null; + String ProjectManager = ""; + String ElecDebug = ""; + String Purcher = ""; + String summary = ""; + + + public YSR8_TravelORDENCreateDialog(TCSession session, TCComponentFolder parent, String projectCode) throws Exception { + //super(true); + + this.parent = parent; + this.projectCode = projectCode; + this.session = session; + + //getysr8_TravelORDCode(session); + + fu.initializeUI(session); + // centerToScreen(); + this.setLocationRelativeTo(null); + this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); + + String[] attrs = {"ProjectID"}; + String[] vals = {projectCode}; + //TCComponent[] TCproject = TCUtil.query(fu.session, "Ŀ...", attrs, vals); + TCComponent[] TCproject = TCUtil.query(fu.session, "Projects...", attrs, vals); + if(TCproject.length>0) { + this.project = (TCComponentProject)TCproject[0]; + } + + JTable table = (JTable) fu.allComponentMap.get("t.041.41"); + DefaultTableModel model = (DefaultTableModel)table.getModel(); + + Object[] rowData1 = {false, "һ", false, false, "", "", ""}; + model.addRow(rowData1); + Object[] rowData2 = {false, "̶", false, false, "", "", ""}; + model.addRow(rowData2); + Object[] rowData3 = {false, "", false, false, "", "", ""}; + model.addRow(rowData3); + Object[] rowData4 = {false, "ɹ-ӹ", false, false, "", "", ""}; + model.addRow(rowData4); + Object[] rowData5 = {false, "ɹ-", false, false, "", "", ""}; + model.addRow(rowData5); + Object[] rowData6 = {false, "ʼ", false, false, "", "", ""}; + model.addRow(rowData6); + + loadRendering(); + addActionListener(); + getDefVal(); + setVisible(true); + } + + private void loadRendering() throws Exception { + } + + private void addActionListener() { + final JTable table = ((JTable) fu.allComponentMap.get("t.041.41")); + DefaultTableModel model = (DefaultTableModel)table.getModel(); + table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); + model.addTableModelListener(new TableModelListener() { //һƲͬʱѡ + @Override + public void tableChanged(TableModelEvent e) { + if (e.getLastRow()==0&&(Boolean)table.getValueAt(0, 0)) { + table.setValueAt(false, 1, 0); + } + if (e.getLastRow()==1&&(Boolean)table.getValueAt(1, 0)) { + table.setValueAt(false, 0, 0); + } + } + }); + JButton create = (JButton)fu.allComponentMap.get("b.41.51.11"); + create.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + saveRendering(); + } + }); + JButton cancel = (JButton)fu.allComponentMap.get("b.41.51.13"); + cancel.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + dispose(); + } + }); + } + + private void saveRendering() { + if (!checkCanSave()) { + return; + } + final JTable table = ((JTable) fu.allComponentMap.get("t.041.41")); + try { + iTextField textfield = (iTextField)fu.allComponentMap.get("ysr8_ProjectCode"); + Date now = new Date(); + String itemID; + String dateString = String.format("%tY", now)+String.format("%tm", now)+String.format("%td", now); + + itemID = textfield.getText()+"-"+dateString+"-";//ѯˮ + int count = 1; + String[] attrs = {"ItemID"}; + String[] vals = {itemID+"*"}; + TCComponent[] sameItem = TCUtil.query(fu.session, "Item ID", attrs, vals); + sameItem = TCUtil.TCsort(sameItem, "item_id"); + if (sameItem.length>0) { + String[] maxID = sameItem[sameItem.length-1].getProperty("item_id").split("-"); + count = new Integer(maxID[3])+1; + } + Boolean check = (Boolean)table.getValueAt(0, 0);//һ + if(check) { + createItem(itemID, "ί", 0, count); + parent.add("contents", new TCComponent[] { newItem }); + } + check = (Boolean)table.getValueAt(1, 0);//̶ + if(check) { + createItem(itemID, "ί", 1, count); + parent.add("contents", new TCComponent[] { newItem }); + } + check = (Boolean)table.getValueAt(2, 0);// + if(check) { + createItem(itemID, "ί", 2, count); + parent.add("contents", new TCComponent[] { newItem }); + } + check = (Boolean)table.getValueAt(3, 0);//ɹ-ӹ + if(check) { + createItem(itemID, "ί", 3, count); + parent.add("contents", new TCComponent[] { newItem }); + } + check = (Boolean)table.getValueAt(4, 0);//ɹ- + if(check) { + createItem(itemID, "ί", 4, count); + parent.add("contents", new TCComponent[] { newItem }); + } + check = (Boolean)table.getValueAt(5, 0);//ʼ + if(check) { + createItem(itemID, "ί", 5, count); + parent.add("contents", new TCComponent[] { newItem }); + } + if (newItem != null) { + dispose(); + } + } catch (Exception ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } + } + + private void getDefVal() { + fu.getDefVal(); + Date now = new Date(); + DateButton ysr8_DistribDate = (DateButton)fu.allComponentMap.get("ysr8_DistribDate"); + ysr8_DistribDate.setDate(String.format("%tF", now)); + iTextField textfield = (iTextField)fu.allComponentMap.get("ysr8_ProjectCode"); + textfield.setText(projectCode); + if(!projectCode.equals("")) { + try { + TCComponentItem dhtzItem = TCUtil.findItemByID(fu.session, projectCode + "_DHTZ"); + if (dhtzItem != null) { + TCComponentItemRevision dhtzRevision; + dhtzRevision = dhtzItem.getLatestItemRevision(); + TCComponentForm dhtzForm = TCUtil.getItemRevisionMasterForm(dhtzRevision); + + //String ysr8_ProjectName = dhtzForm.getProperty("ysr8_ProjectName"); + textfield = (iTextField)fu.allComponentMap.get("ysr8_ProjectName"); + textfield.setText(project.getProperty("object_name")); + String ysr8_CustomerName = dhtzForm.getProperty("ysr8_CustomerName"); + textfield = (iTextField)fu.allComponentMap.get("ysr8_CustomerName"); + textfield.setText(ysr8_CustomerName); + String ysr8_Contact = dhtzForm.getProperty("ysr8_Receiver"); + textfield = (iTextField)fu.allComponentMap.get("ysr8_Contact"); + textfield.setText(ysr8_Contact); + String ysr8_ReceiverPhone = dhtzForm.getProperty("ysr8_ReceiverPhone"); + textfield = (iTextField)fu.allComponentMap.get("ysr8_ReceiverPhone"); + textfield.setText(ysr8_ReceiverPhone); + String ysr8_Adress = dhtzForm.getProperty("ysr8_ReceiptAddress"); + textfield = (iTextField)fu.allComponentMap.get("ysr8_Adress"); + textfield.setText(ysr8_Adress); + } + } catch (Exception e) { + // Auto-generated catch block + e.printStackTrace(); + } + } + } + + public boolean checkCanSave() { + JTable table = ((JTable) fu.allComponentMap.get("t.041.41")); + Boolean check = false; + for(int i=0;i<6;i++) { + if(!((String)table.getValueAt(i, 6)).equalsIgnoreCase("")) { + if(i==0) { + summary = summary+ (((Boolean)table.getValueAt(0, 0))?"һƣ":"̶ƣ") +(String)table.getValueAt(i, 6)+"\n"; + } else + summary = summary+(String)table.getValueAt(i, 1)+""+(String)table.getValueAt(i, 6)+"\n"; + } + if((Boolean)table.getValueAt(i, 0)) + check = true; + } + if(!check) { + MessageBox.post("ѡ!","",MessageBox.WARNING); + return false; + } + try { + List team = project.getTeam(); + Object teamMembers = team.get(0); + TCComponent[] members = (TCComponent[])teamMembers; + TCComponentGroupMember member = null; + for(TCComponent mem : members) { + if(mem instanceof TCComponentGroupMember) { + //((TCComponentGroupMember)mem).getRole(); + member = (TCComponentGroupMember)mem; + //System.out.println(member.getRole()); + if(member.getRole().toString().equals("")) { + if(ElecDebug.equals("")) { + ElecDebug = member.getUser().getProperty("user_name"); + } else + ElecDebug = ElecDebug+";"+member.getUser().getProperty("user_name"); + } else if(member.getRole().toString().equals("ίӹ")) { + if(Purcher.equals("")) { + Purcher = member.getUser().getProperty("user_name"); + } else + Purcher = Purcher+";"+member.getUser().getProperty("user_name"); + } + } + } + TCComponentUser[] teamAdmin = (TCComponentUser[]) team.get(1); + for(TCComponentUser user : teamAdmin) { + if(ProjectManager.equals("")) { + ProjectManager = ProjectManager+user.getProperty("user_name"); + } else + ProjectManager = ProjectManager+";"+user.getProperty("user_name"); + } + } catch (Exception e) { + // Auto-generated catch block + e.printStackTrace(); + } + return true; + } + + public void createItem(String itemID, String name, int check, int count) throws Exception { + //int count = 1; + String[] part = {"-GCYK","-GCEK","-DQK","-CGJG","-CGPX","-ZJK"}; + JTable table = ((JTable) fu.allComponentMap.get("t.041.41")); + int row = 0; + if(check!=1) + row = check; + newItem = TCUtil.createItem(session, itemID+String.format("%02d", count)+part[check], name, itemType); + newRevision = newItem.getLatestItemRevision(); + newForm = TCUtil.getItemRevisionMasterForm(newRevision); + + TCComponentProjectType tccomponentprojecttype = (TCComponentProjectType) session.getTypeComponent("TC_Project"); + tccomponentprojecttype.assignToProject(project, newItem); + + try { + fu.formProperties = newForm.getAllFormProperties(); + Vector formPropertys = fu.GetPropertiesValue(); + + TCFormProperty ysr8_Part; + for(int i=0;i<6;i++) { + if((Boolean)table.getValueAt(i, 0)) { + ysr8_Part = (TCFormProperty)newForm.getFormTCProperty("ysr8_Part"+(i+1)); + ysr8_Part.setLogicalValue((Boolean)table.getValueAt(i, 0)); + formPropertys.add(ysr8_Part); + }; +// if(!((String)table.getValueAt(i, 6)).equalsIgnoreCase("")) +// summary = summary+(String)table.getValueAt(i, 6)+"\n"; + } + ysr8_Part = (TCFormProperty)newForm.getFormTCProperty("ysr8_Principal"); + ysr8_Part.setStringValue(session.getUser().getProperty("user_name")); + formPropertys.add(ysr8_Part); + ysr8_Part = (TCFormProperty)newForm.getFormTCProperty("ysr8_ElecDebug"); + ysr8_Part.setStringValue(ElecDebug); + formPropertys.add(ysr8_Part); + ysr8_Part = (TCFormProperty)newForm.getFormTCProperty("ysr8_Purcher"); + ysr8_Part.setStringValue(Purcher); + formPropertys.add(ysr8_Part); + ysr8_Part = (TCFormProperty)newForm.getFormTCProperty("ysr8_ProjectManager"); + ysr8_Part.setStringValue(ProjectManager); + formPropertys.add(ysr8_Part); + ysr8_Part = (TCFormProperty)newForm.getFormTCProperty("ysr8_Planner"); + ysr8_Part.setStringValue(project.getPAUser().getProperty("user_name")); + formPropertys.add(ysr8_Part); + TCFormProperty ysr8_Receipt = (TCFormProperty)newForm.getFormTCProperty("ysr8_Receipt"); + ysr8_Receipt.setLogicalValue((Boolean)table.getValueAt(row, 2)); + formPropertys.add(ysr8_Receipt); + TCFormProperty ysr8_Program = (TCFormProperty)newForm.getFormTCProperty("ysr8_Program"); + ysr8_Program.setLogicalValue((Boolean)table.getValueAt(row, 3)); + formPropertys.add(ysr8_Program); + TCFormProperty ysr8_TravelDate = (TCFormProperty)newForm.getFormTCProperty("ysr8_TravelDate"); + ysr8_TravelDate.setStringValue((String)table.getValueAt(row, 4)); + formPropertys.add(ysr8_TravelDate); + TCFormProperty ysr8_AskFinishDate = (TCFormProperty)newForm.getFormTCProperty("ysr8_AskFinishDate"); + ysr8_AskFinishDate.setStringValue((String)table.getValueAt(row, 5)); + formPropertys.add(ysr8_AskFinishDate); + TCFormProperty ysr8_Purpose = (TCFormProperty)newForm.getFormTCProperty("ysr8_Purpose"); + ysr8_Purpose.setStringValue((String)table.getValueAt(row, 6)); + formPropertys.add(ysr8_Purpose); + TCFormProperty ysr8_WorkSummary = (TCFormProperty)newForm.getFormTCProperty("ysr8_WorkSummary"); + ysr8_WorkSummary.setStringValue(summary); + formPropertys.add(ysr8_WorkSummary); + + TCFormProperty[] formPropertyArray = new TCFormProperty[formPropertys.size()]; + formPropertys.toArray(formPropertyArray); + newForm.setTCProperties(formPropertyArray); + } catch (ParseException e) { + e.printStackTrace(); + } + } +} diff --git a/src/cn/com/ebewin/ysr/dialog/YSR8_WorkHoursCreateDialog.java b/src/cn/com/ebewin/ysr/dialog/YSR8_WorkHoursCreateDialog.java new file mode 100644 index 0000000..6203b8d --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/YSR8_WorkHoursCreateDialog.java @@ -0,0 +1,293 @@ +package cn.com.ebewin.ysr.dialog; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Vector; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JTable; + +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +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.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.iTextField; + +import cn.com.ebewin.ysr.util.CreateDialogUtil; +import cn.com.ebewin.ysr.util.DialogUtil; +import cn.com.ebewin.ysr.util.FileUtil; +import cn.com.ebewin.ysr.util.TCUtil; + +@SuppressWarnings("deprecation") +public class YSR8_WorkHoursCreateDialog extends JFrame { + private static final long serialVersionUID = 1L; + CreateDialogUtil fu = new CreateDialogUtil(this, "ձ", "YSR8_WorkHoursCreateDialog", "YSR8_WorkHours"); + TCComponentFolder parent = null; + String projectCode = ""; + + public YSR8_WorkHoursCreateDialog(TCSession session, TCComponentFolder parent, String projectCode) throws TCException { + //super(true); + + this.parent = parent; + this.projectCode = projectCode; + + getysr8_TravelORDCode(session); + + fu.initializeUI(session); + //TODO centerToScreen(); + this.setLocationRelativeTo(null); + this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); + + loadRendering(); + addActionListener(); + getDefVal(); + setVisible(true); + } + + private void loadRendering() throws TCException { + } + + private void addActionListener() { + JButton btn = (JButton)fu.allComponentMap.get("b.11.15"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + saveRendering(); + } + }); + + btn = (JButton)fu.allComponentMap.get("b.21.15"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + dispose(); + } + }); + + btn = (JButton)fu.allComponentMap.get("b.61.12"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + addLocalPic(); + } + }); + + btn = (JButton)fu.allComponentMap.get("b.61.13"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + CreateDialogUtil.JTableInfo ci = (CreateDialogUtil.JTableInfo)fu.allComponentInfos.get("a.71.12.11"); + JTable table = (JTable)fu.allComponentMap.get("a.71.12.11"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪƳУ", "ʾ", MessageBox.INFORMATION); + return; + } + for (int i = rows.length - 1; i >= 0; i--) { + ci.dataTableModel.removeRow(rows[i]); + } + } + }); + } + + private void saveRendering() { + if (!checkCanSave()) { + return; + } + try { + CountTotalHours(); + iTextField textfield = (iTextField)fu.allComponentMap.get("Item_ID"); + fu.createItem(textfield.getText(), "ձ"); + if (fu.newItem != null) { + parent.add("contents", new TCComponent[] { fu.newItem }); + saveLocalPic(); + dispose(); + } + } catch (TCException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } + } + + private void addLocalPic() { + String[][] fileTypes = { { ".gif", "gif ļ(*.gif)" }, + { ".bmp", "λͼ ļ(*.bmp)" }, + { ".jpg", "JPGE ļ(*.jpg)" } + }; + File[] files = FileUtil.openFileChoosers(fileTypes); + if (files == null) { + return; + } + CreateDialogUtil.JTableInfo ci = (CreateDialogUtil.JTableInfo)fu.allComponentInfos.get("a.71.12.11"); + int cols = ci.childComponentInfos.size(); + for (int f = 0; f < files.length; f++) { + Object[] objData = new Object[cols]; + objData[0] = ""; + objData[1] = files[f].getAbsolutePath(); + ci.dataTableModel.addRow(objData); + } + } + + private void getDefVal() { + fu.getDefVal(); + //lidy20180827걨˲Զȡ + iTextField textfield = (iTextField)fu.allComponentMap.get("ysr8_Applicant"); + textfield.setText(""); + + TCComponentUser user = fu.session.getUser(); + String user_id = ""; + try { + user_id = user.getProperty("user_id").toString(); + } catch (TCException e) { + e.printStackTrace(); + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + String curDate = sdf.format(new Date()); + String Item_ID = projectCode + ("-") + user_id + ("-") + curDate; + textfield = (iTextField)fu.allComponentMap.get("Item_ID"); + textfield.setText(Item_ID); + + textfield = (iTextField)fu.allComponentMap.get("ysr8_ProjectCode"); + textfield.setText(projectCode); + } + + @SuppressWarnings("unchecked") + public boolean checkCanSave() { + iTextField textfield = (iTextField)fu.allComponentMap.get("ysr8_Applicant"); + String ysr8_ApplicantVal = textfield.getText(); + if (ysr8_ApplicantVal.equals("")) { + MessageBox.post("д[걨]޷棡", "ʾ", MessageBox.INFORMATION); + return false; + } + + DateButton btn = (DateButton)fu.allComponentMap.get("ysr8_DeclarationDate"); + Date dt = btn.getDate(); + if (dt == null) { + MessageBox.post("д[걨]޷棡", "ʾ", MessageBox.INFORMATION); + return false; + } + + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_WorkPlace"); + String val = cbx.getSelectedItem().toString(); + try { + if (val.equals("")) { + String Item_ID = projectCode + "-TSGH"; + TCComponentItem dbpItem = TCUtil.findItemByID(fu.session, Item_ID); + if (dbpItem == null) { + MessageBox.post("δҵӦĿϢύ⹤ձ!", "ʾ", MessageBox.INFORMATION); + return false; + } + TCComponentItemRevision dbpRevision = dbpItem.getLatestItemRevision(); + TCComponentForm dbpForm = TCUtil.getItemRevisionMasterForm(dbpRevision); + if (!dbpForm.getStringProperty("ysr8_Check1").equals("1")) { + MessageBox.post("δͨˣύ⹤ձ!", "ʾ", MessageBox.INFORMATION); + return false; + } + + cbx = (JComboBox)fu.allComponentMap.get("ysr8_DebugPhase"); + val = cbx.getSelectedItem().toString(); + if (val.equals("豸")) { + if (!dbpForm.getStringProperty("ysr8_Check2").equals("1")) { + MessageBox.post("ʩȷϵδͨˣύ豸Թձ!", "ʾ", MessageBox.INFORMATION); + return false; + } + } + } + } catch (TCException e) { + e.printStackTrace(); + return false; + } + + return true; + } + + private void CountTotalHours(){ + iTextField textfield = (iTextField)fu.allComponentMap.get("ysr8_WorkdayHours"); + String ysr8_WorkdayHours = textfield.getText().toString(); + double ysr8_WorkdayHoursDoubleVal = 0.0; + if (!ysr8_WorkdayHours.equals("")) { + ysr8_WorkdayHoursDoubleVal = Double.parseDouble(ysr8_WorkdayHours); + } + + textfield = (iTextField)fu.allComponentMap.get("ysr8_OvertimeHours"); + String ysr8_OvertimeHours = textfield.getText().toString(); + double ysr8_OvertimeHoursDoubleVal = 0.0; + if (!ysr8_OvertimeHours.equals("")) { + ysr8_OvertimeHoursDoubleVal = Double.parseDouble(ysr8_OvertimeHours); + } + + textfield = (iTextField)fu.allComponentMap.get("ysr8_HOvertimeHours"); + String ysr8_HOvertimeHours = textfield.getText().toString(); + double ysr8_HOvertimeHoursDoubleVal = 0.0; + if (!ysr8_HOvertimeHours.equals("")) { + ysr8_HOvertimeHoursDoubleVal = Double.parseDouble(ysr8_HOvertimeHours); + } + + double ysr8_TotalHoursDoubleVal = ysr8_WorkdayHoursDoubleVal + ysr8_OvertimeHoursDoubleVal + ysr8_HOvertimeHoursDoubleVal; + textfield = (iTextField)fu.allComponentMap.get("ysr8_TotalHours"); + textfield.setText(new DecimalFormat("#.00").format(ysr8_TotalHoursDoubleVal)); + } + + private void saveLocalPic() { + Vector addPic = new Vector(); + CreateDialogUtil.JTableInfo ci = (CreateDialogUtil.JTableInfo)fu.allComponentInfos.get("a.71.12.11"); + for (int l = 0; l < ci.dataTableModel.getRowCount(); l++) { + if (ci.dataTableModel.getValueAt(l, 0) == null || + ci.dataTableModel.getValueAt(l, 1) == null) { + continue; + } else { + String sign = ci.dataTableModel.getValueAt(l, 0).toString(); + if (sign.equalsIgnoreCase("")) { + String fileName = ci.dataTableModel.getValueAt(l, 1).toString(); + addPic.add(fileName); + } + } + } + + TCComponentItemRevision itemRevision = fu.newRevision; + try { + for (String pic : addPic) { + File file = new File(pic); + TCComponentDataset newDataset = TCUtil.createDataset(fu.session, file, file.getName()); + itemRevision.add("IMAN_specification", new TCComponent[] { newDataset }); + } + } catch (TCException e1) { + e1.printStackTrace(); + } + } + + private void getysr8_TravelORDCode(TCSession session) { + try { + String ysr8_ProjectCodeVal = projectCode; + String[] attrs = new String[1]; + String[] vals = new String[1]; + attrs[0] = "ysr8_ProjectCode"; + vals[0] = ysr8_ProjectCodeVal; + TCComponent[] tcComponents = TCUtil.query(session, "SearchTravelORDEN", attrs, vals); + if (tcComponents != null) { + DialogUtil.JComboBoxInfo ci = (CreateDialogUtil.JComboBoxInfo)fu.allComponentInfos.get("ysr8_TravelORDCode"); + ci.valueType = "list"; + ci.values = new Vector(); + for (int i = 0; i < tcComponents.length; i++) { + TCComponentItemRevision TravelORDENItemRevision = (TCComponentItemRevision)tcComponents[i]; + TCComponentItem TravelORDENItem = TravelORDENItemRevision.getItem(); + //TCComponentForm TravelORDENForm = TCUtil.getItemRevisionMasterForm(TravelORDENItemRevision); + + ci.values.add(TravelORDENItem.getProperty("item_id")); + } + } + } catch (TCException e) { + e.printStackTrace(); + } + } +} diff --git a/src/cn/com/ebewin/ysr/dialog/YSR8_wysjTimeDialog.java b/src/cn/com/ebewin/ysr/dialog/YSR8_wysjTimeDialog.java new file mode 100644 index 0000000..bf173a5 --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/YSR8_wysjTimeDialog.java @@ -0,0 +1,908 @@ +package cn.com.ebewin.ysr.dialog; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.Vector; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.ListSelectionModel; +import javax.swing.RowSorter; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableColumnModel; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; + +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 cn.com.ebewin.ysr.dialog.SysCatalogRevisionMasterBean; +import cn.com.ebewin.ysr.util.CommonUtil; +import jxl.Workbook; +import jxl.format.Alignment; +import jxl.format.Border; +import jxl.format.BorderLineStyle; +import jxl.format.VerticalAlignment; +import jxl.write.Label; +import jxl.write.WritableCellFormat; +import jxl.write.WritableFont; +import jxl.write.WritableSheet; +import jxl.write.WritableWorkbook; +import jxl.write.WriteException; + +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.schemas.core._2011_06.datamanagement.SaveAsOut; +import com.teamcenter.soa.client.model.LovValue; + +public class YSR8_wysjTimeDialog extends JFrame implements ActionListener { + + private Map textMap = new HashMap<>(); + private TCSession session; + private JTable table; + private String[] header = new String[] { "", "Ŀ", "", "Ŀ", "Ŀ", "Ʒ", "Ŀ", "Ŀ", "Ŀ", + "Ƽƻʼʱ", "Ƽƻʱ", "ƻʱ죩", "ʵʿʼʱ", "ʵʱ", "ʵʱ죩", "ƿʼǷ", "ʱ䣨죩", "Ƿ", + "ʱ䣨죩" }; + public static final int[] HEADERWIDTH = new int[] { 50, 100, 200, 200, 100, 100, 80, 80, 100, 150, 150, 150, 150, + 150, 150, 150, 150, 150, 150 }; + protected DefaultTableModel tm_part; + private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + private HashMap cplxMap = new HashMap(); + private JTextField xmh = new JTextField(); + private JTextField xmjl = new JTextField(); + private JTextField xmgl = new JTextField(); + private JTextField dhcj = new JTextField(); + private JComboBox cplx = new JComboBox(); + private DateButton projectStartButton; + private DateButton projectEndButton; + + private DateButton wwxfjhksStartButton; + private DateButton wwxfjhksEndButton; + private DateButton wwswjhwcStartButton; + private DateButton wwswjhwcEndButton; + + private DateButton wwxfsjksStartButton; + private DateButton wwxfsjksEndButton; + private DateButton wwswsjwcStartButton; + private DateButton wwswsjwcEndButton; + + private String today; + + public YSR8_wysjTimeDialog(TCSession session) { + // TODO Auto-generated constructor stub + this.session = session; + initUI(); + } + + public void initUI() { + // TODO Auto-generated method stub + today = dateFormat.format(new Date()); + this.setTitle("ίʱͳƿ"); + this.setLayout(new BorderLayout()); + + JPanel topPanel = getTopPanel(); + + JScrollPane pane = getTablePanel(); + pane.setBorder(BorderFactory.createTitledBorder("")); +// JPanel btnPanel = getRightPanel(); + + this.add(topPanel, BorderLayout.NORTH); + this.add(pane, BorderLayout.CENTER); + this.createActionEvent(); + this.pack(); + this.setPreferredSize(new Dimension(1850, 1000)); + this.validate(); + this.setVisible(true); + // ôĻ +// Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize(); +// int x = (int) screensize.getWidth() / 2 - window.getWidth() / 2; +// int y = (int) screensize.getHeight() / 2 - window.getHeight() / 2; + this.setLocationRelativeTo(null); + + TCComponentListOfValues lov = TCComponentListOfValuesType.findLOVByName("YSR8_Product_LOV"); + ArrayList lovValueList = new ArrayList(); + ArrayList lovDisplayValueList = new ArrayList(); + + if(lov != null) { + ListOfValuesInfo info; + try { + info = lov.getListOfValues(); + info.getLOVDisplayValues(); + List lovValueList2 = info.getValues(); + for (LovValue lovV : lovValueList2) { + lovDisplayValueList.add(lovV.getDisplayValue()); + lovValueList.add(lovV.getStringValue()); + System.out.println("key==="+lovV.getStringValue()+"-----value======="+lovV.getDisplayValue()); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + + // ȡѡ +// String[] cplx = session.getPreferenceService().getStringValues("connor_wysj_cplx"); +// if (cplx == null || cplx.length <= 0) { +// MessageBox.post("ѡconnor_wysj_cplx", "ʾ ", MessageBox.INFORMATION); +// return; +// } + this.cplx.addItem(""); + for (int i = 0; i < lovValueList.size(); i++) { + cplxMap.put(lovDisplayValueList.get(i), lovValueList.get(i)); + this.cplx.addItem(lovDisplayValueList.get(i)); + } + + + + + + xmh.setPreferredSize(new Dimension(125, 25)); + xmjl.setPreferredSize(new Dimension(125, 25)); + xmgl.setPreferredSize(new Dimension(125, 25)); + dhcj.setPreferredSize(new Dimension(125, 25)); + this.cplx.setPreferredSize(new Dimension(125, 25)); + + TableColumnModel colModel = table.getColumnModel(); + int colCnt = HEADERWIDTH.length; + for (int i = 0; i < colCnt; i++) { + colModel.getColumn(i).setPreferredWidth(HEADERWIDTH[i]); + } + } + + private JButton btnQry; + private JScrollPane comp; + private JButton btnExport; + + private DefaultTableModel dtm1; + + public void createActionEvent() { + this.btnQry.addActionListener(this); + this.btnExport.addActionListener(this); + } + + // ѯ + private JPanel getTopPanel() { + // TODO Auto-generated method stub + JPanel topPanel = new JPanel(); + topPanel.setLayout(new PropertyLayout()); + projectStartButton = new DateButton(null, "yyyy-MM-dd", false, false, false); + projectEndButton = new DateButton(null, "yyyy-MM-dd", false, false, false); + projectStartButton.setDate("δ"); + projectEndButton.setDate("δ"); + wwxfjhksStartButton = new DateButton(null, "yyyy-MM-dd", false, false, false); + wwxfjhksEndButton = new DateButton(null, "yyyy-MM-dd", false, false, false); + wwxfjhksStartButton.setDate("δ"); + wwxfjhksEndButton.setDate("δ"); + wwswjhwcStartButton = new DateButton(null, "yyyy-MM-dd", false, false, false); + wwswjhwcEndButton = new DateButton(null, "yyyy-MM-dd", false, false, false); + wwswjhwcStartButton.setDate("δ"); + wwswjhwcEndButton.setDate("δ"); + + wwxfsjksStartButton = new DateButton(null, "yyyy-MM-dd", false, false, false); + wwxfsjksEndButton = new DateButton(null, "yyyy-MM-dd", false, false, false); + wwxfsjksStartButton.setDate("δ"); + wwxfsjksEndButton.setDate("δ"); + wwswsjwcStartButton = new DateButton(null, "yyyy-MM-dd", false, false, false); + wwswsjwcEndButton = new DateButton(null, "yyyy-MM-dd", false, false, false); + wwswsjwcStartButton.setDate("δ"); + wwswsjwcEndButton.setDate("δ"); +// startButton.set + btnQry = new JButton("ѯ"); + btnExport = new JButton(""); + topPanel.add("1.1.center.center", new JLabel(" Ŀţ")); + topPanel.add("1.2.center.center", xmh); + topPanel.add("1.3.center.center", new JLabel(" Ŀ")); + topPanel.add("1.4.center.center", xmjl); + topPanel.add("1.5.center.center", new JLabel(" Ŀ")); + topPanel.add("1.6.center.center", xmgl); + topPanel.add("1.7.center.center", new JLabel(" Ʒͣ")); + topPanel.add("1.8.center.center", cplx); + topPanel.add("1.9.center.center", new JLabel(" ң")); + topPanel.add("1.10.center.center", dhcj); + topPanel.add("1.11.center.center", new JLabel(" Ŀʼʱ䣺")); + topPanel.add("1.12.center.center", projectStartButton); + topPanel.add("1.13.center.center", new JLabel(" Ŀʱ䣺")); + topPanel.add("1.14.center.center", projectEndButton); + + topPanel.add("2.1.center.center", new JLabel(" άƼƻʼʱ䣺")); + topPanel.add("2.2.center.center", wwswjhwcStartButton); + topPanel.add("2.3.center.center", new JLabel(" άƼƻʱ䣺")); + topPanel.add("2.4.center.center", wwswjhwcEndButton); + + topPanel.add("2.5.center.center", new JLabel(" άʵʿʼʱ䣺")); + topPanel.add("2.6.center.center", wwswsjwcStartButton); + topPanel.add("2.7.center.center", new JLabel(" άʵʽʱ䣺")); + topPanel.add("2.8.center.center", wwswsjwcEndButton); + topPanel.add("2.9.center.center", new JLabel(" ")); + topPanel.add("3.1.center.center", new JLabel(" ·ͼֽƻʼʱ䣺")); + topPanel.add("3.2.center.center", wwxfjhksStartButton); + topPanel.add("3.3.center.center", new JLabel(" ·ͼֽƻʱ䣺")); + topPanel.add("3.4.center.center", wwxfjhksEndButton); + + topPanel.add("3.5.center.center", new JLabel(" ·ͼֽʵʿʼʱ䣺")); + topPanel.add("3.6.center.center", wwxfsjksStartButton); + topPanel.add("3.7.center.center", new JLabel(" ·ͼֽʵʽʱ䣺")); + topPanel.add("3.8.center.center", wwxfsjksEndButton); + + topPanel.add("2.10.center.center", btnQry); + topPanel.add("2.11.center.center", btnExport); + + // topPanel.add("1.6.left.center",btnExport); + topPanel.setPreferredSize(new Dimension(1850, 100)); + +// wwxfjhksStartButton.addActionListener(new ActionListener() { +// +// @Override +// public void actionPerformed(ActionEvent e) { +// // TODO Auto-generated method stub +//// if(wwswjhwcEndButton.getDate() != null || wwswjhwcStartButton.getDate() != null) { +//// MessageBox.post("ѡίάʱ䣡", "ʾ ", MessageBox.INFORMATION); +//// wwxfjhksStartButton.setDate("δ"); +//// return; +//// } +// wwswjhwcEndButton.setEnabled(false); +// wwswjhwcStartButton.setEnabled(false); +// wwswsjwcEndButton.setEnabled(false); +// wwswsjwcStartButton.setEnabled(false); +// } +// }); +// +// wwxfjhksEndButton.addActionListener(new ActionListener() { +// +// @Override +// public void actionPerformed(ActionEvent e) { +// // TODO Auto-generated method stub +// wwswjhwcEndButton.setEnabled(false); +// wwswjhwcStartButton.setEnabled(false); +// wwswsjwcEndButton.setEnabled(false); +// wwswsjwcStartButton.setEnabled(false); +// } +// }); +// +// wwxfsjksEndButton.addActionListener(new ActionListener() { +// +// @Override +// public void actionPerformed(ActionEvent e) { +// // TODO Auto-generated method stub +// wwswjhwcEndButton.setEnabled(false); +// wwswjhwcStartButton.setEnabled(false); +// wwswsjwcEndButton.setEnabled(false); +// wwswsjwcStartButton.setEnabled(false); +// } +// }); +// +// wwxfsjksStartButton.addActionListener(new ActionListener() { +// +// @Override +// public void actionPerformed(ActionEvent e) { +// // TODO Auto-generated method stub +// +// +// wwswjhwcEndButton.setEnabled(false); +// wwswjhwcStartButton.setEnabled(false); +// wwswsjwcEndButton.setEnabled(false); +// wwswsjwcStartButton.setEnabled(false); +// } +// }); +// +// wwswjhwcEndButton.addActionListener(new ActionListener() { +// +// @Override +// public void actionPerformed(ActionEvent e) { +// // TODO Auto-generated method stub +// wwxfjhksEndButton.setEnabled(false); +// wwxfjhksStartButton.setEnabled(false); +// wwxfsjksEndButton.setEnabled(false); +// wwxfsjksStartButton.setEnabled(false); +// } +// }); +// +// wwswjhwcStartButton.addActionListener(new ActionListener() { +// +// @Override +// public void actionPerformed(ActionEvent e) { +// // TODO Auto-generated method stub +// wwxfjhksEndButton.setEnabled(false); +// wwxfjhksStartButton.setEnabled(false); +// wwxfsjksEndButton.setEnabled(false); +// wwxfsjksStartButton.setEnabled(false); +// } +// }); +// +// wwswsjwcEndButton.addActionListener(new ActionListener() { +// +// @Override +// public void actionPerformed(ActionEvent e) { +// // TODO Auto-generated method stub +// wwxfjhksEndButton.setEnabled(false); +// wwxfjhksStartButton.setEnabled(false); +// wwxfsjksEndButton.setEnabled(false); +// wwxfsjksStartButton.setEnabled(false); +// } +// }); +// +// wwswsjwcStartButton.addActionListener(new ActionListener() { +// +// @Override +// public void actionPerformed(ActionEvent e) { +// // TODO Auto-generated method stub +// wwxfjhksEndButton.setEnabled(false); +// wwxfjhksStartButton.setEnabled(false); +// wwxfsjksEndButton.setEnabled(false); +// wwxfsjksStartButton.setEnabled(false); +// } +// }); + + return topPanel; + } + + private JScrollPane getTablePanel() { + // TODO Auto-generated method stub + table = getjTable(null, null, header, null, false); + table.setRowHeight(30); + table.getColumnModel().getColumn(0).setPreferredWidth(50); + table.getColumnModel().getColumn(1).setPreferredWidth(150); + table.getColumnModel().getColumn(2).setPreferredWidth(300); +// table.setPreferredSize(new Dimension(1500,400)); + table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // ñԶģʽΪرԶ +// table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);//JTableпбݵĴСе +// table.setPreferredSize(new Dimension(1200,400)); + JScrollPane pane = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, + JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + pane.setPreferredSize(new Dimension(1800, 850)); + pane.setViewportView(table);// ΪscrollPaneָʾΪtable + return pane; + } + + /*** + * Jtableͨ÷ + * + * @param partsTable + * @param dtm + * @param titleNames + * @param values + * @return + */ + public JTable getjTable(JTable partsTable, DefaultTableModel dtm, Object[] titleNames, Object[][] values, + Boolean isTable2) { +// int simpleLen = 100; +// int totleLen = 1000; + if (partsTable == null) { + partsTable = new JTable(this.getTableModel(dtm, titleNames, values)); + partsTable.setRowHeight(20); + partsTable.getTableHeader().setReorderingAllowed(false); + partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + RowSorter sorter = new TableRowSorter(partsTable.getModel()); + partsTable.setRowSorter(sorter); +// for (int i = 0; i < titleNames.length; i++) { +// if(i==2) { +// partsTable.getColumnModel().getColumn(i).setPreferredWidth(200); +// }else { +// partsTable.getColumnModel().getColumn(i).setPreferredWidth(120); +// } +// +// } + + } + return partsTable; + } + + public DefaultTableModel getTableModel(DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + + dtm1 = null; + if (dtm == null) { + dtm1 = new DefaultTableModel(values, titleNames) { + @Override + public boolean isCellEditable(int row, int column) { + return false; + } + }; + } + return dtm1; + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + System.out.println("source==>+" + source); + + if (source.equals(this.btnQry)) { + final ProgressReporterDialog reporter = new ProgressReporterDialog(); + reporter.reportProgressMessage("ڲѯ,Ժ..."); + new Thread(reporter).start(); + // ѯɾ֮ǰѯļ¼ + for (int t = dtm1.getRowCount() - 1; t >= 0; t--) { + dtm1.removeRow(t); + } + + HashMap seachField = new HashMap(); + HashMap timeSeachField = new HashMap(); + try { + Date starDate = projectStartButton.getDate(); + Date endDate = projectEndButton.getDate(); + + if (xmh.getText() != null && !(xmh.getText().isEmpty())) { + seachField.put("ysr8_ProjectCode", xmh.getText()); + } + + if (xmjl.getText() != null && !(xmjl.getText().isEmpty())) { + seachField.put("ysr8_ProjectManager", xmjl.getText()); + } + + if (xmgl.getText() != null && !(xmgl.getText().isEmpty())) { + seachField.put("ysr8_Planner", xmgl.getText()); + } + + String selectedItem = (String) cplx.getSelectedItem(); + if (selectedItem != null) { + String value = cplxMap.get(selectedItem); + if (value != null) { + seachField.put("ysr8_Product", value); + } + + } + if (dhcj.getText() != null && !(dhcj.getText().isEmpty())) { + seachField.put("ysr8_OrderManufacturer", "*" + dhcj.getText() + "*");// ģѯ + } + + // ʱ + Date projectStartDate = projectStartButton.getDate(); + Date projectEndDate = projectEndButton.getDate(); + if (projectStartDate != null) { + + // ȥ·ݵǰ + seachField.put("ysr8_StartDate>", + dateFormat.format(projectStartDate).replaceAll("(\\d{4})-0(\\d)-", "$1-$2-") + " 00:00"); + } + + if (projectEndDate != null) { + seachField.put("ysr8_StartDate<", + dateFormat.format(projectEndDate).replaceAll("(\\d{4})-0(\\d)-", "$1-$2-") + " 23:59"); + } + + // ίά + Date wwswjhwcStartDate = wwswjhwcStartButton.getDate(); + Date wwswjhwcDate = wwswjhwcEndButton.getDate(); + Date wwswsjwcEndDate = wwswsjwcEndButton.getDate(); + Date wwswsjwcStartDate = wwswsjwcStartButton.getDate(); + + if (wwswjhwcStartDate != null) { + + // ȥ·ݵǰ + timeSeachField.put("start_date>", + dateFormat.format(wwswjhwcStartDate).replaceAll("(\\d{4})-0(\\d)-", "$1-$2-") + " 00:00"); + } + + if (wwswjhwcDate != null) { + timeSeachField.put("start_date<", + dateFormat.format(wwswjhwcDate).replaceAll("(\\d{4})-0(\\d)-", "$1-$2-") + " 23:59"); + } + + if (wwswsjwcStartDate != null) { + + // ȥ·ݵǰ + timeSeachField.put("actual_start_date>", + dateFormat.format(wwswsjwcStartDate).replaceAll("(\\d{4})-0(\\d)-", "$1-$2-") + " 00:00"); + } + + if (wwswsjwcEndDate != null) { + timeSeachField.put("actual_start_date<", + dateFormat.format(wwswsjwcEndDate).replaceAll("(\\d{4})-0(\\d)-", "$1-$2-") + " 23:59"); + } + + if(wwswjhwcStartDate != null || wwswjhwcDate != null || wwswsjwcEndDate != null || wwswsjwcStartDate != null) { + timeSeachField.put("", "*ίά*"); + } + + + // ί· + Date wwxfjhksStartDate = wwxfjhksStartButton.getDate(); + + System.out.println(wwxfjhksStartDate+"============wwxfjhksStartDate"); + + Date wwxfjhksEndDate = wwxfjhksEndButton.getDate(); + + System.out.println(wwxfjhksEndDate+"============wwxfjhksEndDate"); + Date wwxfsjksStartDate = wwxfsjksStartButton.getDate(); + Date wwxfsjksEndStartDate = wwxfsjksEndButton.getDate(); + + if (wwxfjhksStartDate != null) { + + // ȥ·ݵǰ + timeSeachField.put("finish_date>", + dateFormat.format(wwxfjhksStartDate).replaceAll("(\\d{4})-0(\\d)-", "$1-$2-") + " 00:00"); + } + + if (wwxfjhksEndDate != null) { + timeSeachField.put("finish_date<", + dateFormat.format(wwxfjhksEndDate).replaceAll("(\\d{4})-0(\\d)-", "$1-$2-") + " 23:59"); + } + + if (wwxfsjksStartDate != null) { + + // ȥ·ݵǰ + timeSeachField.put("actual_finish_date>", + dateFormat.format(wwxfsjksStartDate).replaceAll("(\\d{4})-0(\\d)-", "$1-$2-") + " 00:00"); + } + + if (wwxfsjksEndStartDate != null) { + timeSeachField.put("actual_finish_date<", + dateFormat.format(wwxfsjksEndStartDate).replaceAll("(\\d{4})-0(\\d)-", "$1-$2-") + " 23:59"); + } + + if(wwxfjhksStartDate != null || wwxfjhksEndDate != null || wwxfsjksStartDate != null || wwxfsjksEndStartDate != null) { + timeSeachField.put("", "*ί·ͼֽ*"); + } + + + System.out.println("111111====="+(wwxfjhksStartDate != null || wwxfjhksEndDate != null || wwxfsjksStartDate != null || wwxfsjksEndStartDate != null)); + System.out.println("222222====="+(wwswjhwcStartDate != null || wwswjhwcDate != null || wwswsjwcEndDate != null || wwswsjwcStartDate != null)); + if((wwxfjhksStartDate != null || wwxfjhksEndDate != null || wwxfsjksStartDate != null || wwxfsjksEndStartDate != null) && (wwswjhwcStartDate != null || wwswjhwcDate != null || wwswsjwcEndDate != null || wwswsjwcStartDate != null)) { + reporter.requestCanceling(); + MessageBox.post("ֻܸάƼƻʱ·ͼֽƻʱһѯ", "ʾ ", MessageBox.INFORMATION); + + return; + } + + + + + ArrayList forms = new ArrayList(); + // òѯ + if (seachField.size() <= 0 && timeSeachField.size() <= 0) { + reporter.requestCanceling(); + MessageBox.post("ѡѯ", "ʾ ", MessageBox.INFORMATION); + + return; + } else { + if(seachField.size() > 0 && timeSeachField.size() <= 0) { + System.out.println("seachField=======" + seachField); + + Set keySet = seachField.keySet(); + String[] keys = keySet.toArray(new String[0]); + + // ȡе value תΪ + String[] values = seachField.values().toArray(new String[0]); + + TCComponent[] search = session.search("Ŀ֪ͨѯ", keys, values); + for (int i = 0; i < search.length; i++) { + forms.add((TCComponentForm)search[i].getReferenceListProperty("IMAN_master_form_rev")[0]); + } + }else if(seachField.size() <= 0 && timeSeachField.size() > 0) { + System.out.println("timeSeachField=======" + timeSeachField); + + Set keySet = timeSeachField.keySet(); + String[] keys = keySet.toArray(new String[0]); + + // ȡе value תΪ + String[] values = timeSeachField.values().toArray(new String[0]); + + TCComponent[] search = session.search("ίʱѯ", keys, values); + for (int i = 0; i < search.length; i++) { + String projectCode = search[i].getStringProperty("ysr8_ProjectCode"); + TCComponent[] projectSearch = session.search("Ŀ֪ͨѯ", new String[]{"ysr8_ProjectCode"}, new String[]{projectCode}); + for (int j = 0; j < projectSearch.length; j++) { + forms.add((TCComponentForm)projectSearch[j].getReferenceListProperty("IMAN_master_form_rev")[0]); + } + } + }else if(seachField.size() > 0 && timeSeachField.size() > 0) { + System.out.println("seachField=======" + seachField); + + Set keySet = seachField.keySet(); + String[] keys = keySet.toArray(new String[0]); + + // ȡе value תΪ + String[] values = seachField.values().toArray(new String[0]); + + TCComponent[] search = session.search("Ŀ֪ͨѯ", keys, values); + + + System.out.println("timeSeachField=======" + timeSeachField); + + Set timeKeySet = timeSeachField.keySet(); + String[] timeKeys = timeKeySet.toArray(new String[0]); + + // ȡе value תΪ + String[] timeValues = timeSeachField.values().toArray(new String[0]); + + TCComponent[] timeSearch = session.search("ίʱѯ", timeKeys, timeValues); + for (int i = 0; i < timeSearch.length; i++) { + String projectCode = timeSearch[i].getStringProperty("ysr8_ProjectCode"); + TCComponent[] projectSearch = session.search("Ŀ֪ͨѯ", new String[]{"ysr8_ProjectCode"}, new String[]{projectCode}); + for (int j = 0; j < projectSearch.length; j++) { + for (int k = 0; k < search.length; k++) { + System.out.println("projectSearch[j].getUid()========"+projectSearch[j].getUid()); + System.out.println("search[k].getUid()========"+search[k].getUid()); + + if(projectSearch[j].getUid().equals(search[k].getUid())) { + forms.add((TCComponentForm)search[j].getReferenceListProperty("IMAN_master_form_rev")[0]); + } + } + + } + } + } + } + System.out.println("forms===================="+forms.size()); + + for (int i = 0; i < forms.size(); i++) { + + TCComponentForm form = forms.get(i); + TCProperty[] formFields = form.getTCProperties( + new String[] { "ysr8_ProjectCode", "ysr8_OrderManufacturer", "ysr8_ProjectName", + "ysr8_Product", "ysr8_ProjectManager", "ysr8_Planner", "ysr8_StartDate" }); + + String projectCode = formFields[0].getStringValue(); + System.out.println("projectCode=============" + projectCode); + String dhcj = formFields[1].getStringValue(); + String xmmcStr = formFields[2].getStringValue(); + String cplxStr = formFields[3].getStringValue(); + String xmjlStr = formFields[4].getStringValue(); + String xmglStr = formFields[5].getStringValue(); + Date xmqdDate = formFields[6].getDateValue(); + String xmqdDateStr = ""; + + String swObjectName = ""; + String sw_start_date_str = ""; + String sw_actual_start_date_str = ""; + + String xf_finish_date_str = ""; + String xf_actual_finish_date_str = ""; + if (xmqdDate != null) { + xmqdDateStr = dateFormat.format(xmqdDate); + } + // ȡĿ ȥʱ + TCComponent[] wySearch = session.search("ίʱѯ", new String[] { "", "Ŀ ID" }, + new String[] { "*ίά*", projectCode }); + System.out.println("wySearch====" + wySearch.length); + if (wySearch.length > 0) { + TCComponent tcComponent = wySearch[0]; + TCProperty[] sWProperties = tcComponent + .getTCProperties(new String[] { "object_name", "start_date", "actual_start_date" }); + swObjectName = sWProperties[0].getStringValue(); + Date sw_start_date = sWProperties[1].getDateValue(); + if (sw_start_date != null) { + sw_start_date_str = dateFormat.format(sw_start_date); + } + + Date sw_actual_start_date = sWProperties[2].getDateValue(); + if (sw_actual_start_date != null) { + sw_actual_start_date_str = dateFormat.format(sw_actual_start_date); + } + } + + TCComponent[] xfSearch = session.search("ίʱѯ", new String[] { "", "Ŀ ID" }, + new String[] { "*ί·ͼֽ*", projectCode }); + System.out.println("xfSearch=======" + xfSearch.length); + if (xfSearch.length > 0) { + TCComponent tcComponent = xfSearch[0]; + TCProperty[] xfProperties = tcComponent + .getTCProperties(new String[] { "finish_date", "actual_finish_date" }); + Date xf_finish_date = xfProperties[0].getDateValue(); + if (xf_finish_date != null) { + xf_finish_date_str = dateFormat.format(xf_finish_date); + } + Date xf_actual_finish_date = xfProperties[1].getDateValue(); + if (xf_actual_finish_date != null) { + xf_actual_finish_date_str = dateFormat.format(xf_actual_finish_date); + } + } + + Vector vec = new Vector(); + vec.add(i + 1); + vec.add(projectCode); + vec.add(dhcj); + vec.add(xmmcStr); + if (swObjectName != null && !swObjectName.isEmpty()) { + int lastIndexOf = swObjectName.lastIndexOf("-"); + swObjectName = swObjectName.substring(0, lastIndexOf); + } + vec.add(swObjectName);// ָһ- + vec.add(cplxMap.get(cplxStr) == null || cplxMap.get(cplxStr).isEmpty() ? cplxStr + : cplxMap.get(cplxStr)); + vec.add(xmjlStr); + vec.add(xmglStr); + vec.add(xmqdDateStr); + vec.add(sw_start_date_str); + vec.add(xf_finish_date_str); + + int jhDate = 0; + if (!sw_start_date_str.isEmpty() && !xf_finish_date_str.isEmpty()) { + jhDate = CommonUtil.getDaysBetween(sw_start_date_str, xf_finish_date_str); + } + + vec.add(Integer.toString(jhDate)); + + vec.add(sw_actual_start_date_str); + vec.add(xf_actual_finish_date_str); + int sjDate = 0; + if (!sw_actual_start_date_str.isEmpty() && !xf_actual_finish_date_str.isEmpty()) { + sjDate = CommonUtil.getDaysBetween(sw_actual_start_date_str, xf_actual_finish_date_str); + } + + vec.add(Integer.toString(sjDate)); + + String sqksResult = ""; + int sqksDays = 0; + if (!sw_actual_start_date_str.isEmpty() && !sw_start_date_str.isEmpty()) { + sqksDays = CommonUtil.getDaysBetween(sw_start_date_str, sw_actual_start_date_str); + if (sqksDays > 0) { + sqksResult = "NG"; + } else { + sqksResult = "OK"; + } + } else if (!sw_start_date_str.isEmpty() && sw_actual_start_date_str.isEmpty()) { + sqksDays = CommonUtil.getDaysBetween(sw_start_date_str, today); + if (sqksDays > 0) { + sqksResult = "NG"; + } else { + sqksResult = ""; + } + } + + vec.add(sqksResult); + if (sqksDays > 0) { + vec.add(sqksDays + ""); + } else { + vec.add(""); + } + + String jhwcResult = ""; + int jhwcDays = 0; + if (!xf_finish_date_str.isEmpty() && !xf_actual_finish_date_str.isEmpty()) { + jhwcDays = CommonUtil.getDaysBetween(xf_finish_date_str, xf_actual_finish_date_str); + if (jhwcDays > 0) { + jhwcResult = "NG"; + } else { + jhwcResult = "OK"; + } + } else if (!xf_finish_date_str.isEmpty() && xf_actual_finish_date_str.isEmpty()) { + jhwcDays = CommonUtil.getDaysBetween(xf_finish_date_str, today); + if (jhwcDays > 0) { + jhwcResult = "NG"; + } else { + jhwcResult = ""; + } + } + vec.add(jhwcResult); + if (jhwcDays > 0) { + vec.add(jhwcDays + ""); + } else { + vec.add(""); + } + dtm1.addRow(vec); + + } + reporter.requestCanceling(); + } catch (Exception e2) { + // TODO: handle exception + reporter.requestCanceling(); + e2.printStackTrace(); + } + + } + else if(source.equals(this.btnExport)){ + // + final ProgressReporterDialog reporter = new ProgressReporterDialog(); + reporter.reportProgressMessage("ڵ,Ժ..."); + new Thread(reporter).start(); + + new Thread() { + public void run() { + try { + Date date = new Date(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + String time = sdf.format(date); + String toPath = System.getProperty("java.io.tmpdir") + "ίʱͳ" + time + ".xls"; + + int columnCount = table.getColumnCount(); // + + XSSFWorkbook wb = new XSSFWorkbook(); + XSSFSheet sheet = wb.createSheet("ϵͳĿ¼"); + + + + for(int i = 0; i < table.getRowCount(); i++){ + + XSSFRow excelRow = sheet.createRow(i+1); + for(int j = 0; j < table.getColumnCount(); j++){ + + XSSFCell excelCell = excelRow.createCell(j); + excelCell.setCellValue(table.getValueAt(i, j).toString()); + } + } + + // ȡͷ + XSSFRow row1 = sheet.createRow(0); + + for (int i = 0; i < columnCount; i++) { + + XSSFCell excelCell = row1.createCell(i); + excelCell.setCellValue(table.getColumnName(i)); + } + + File file = new File(toPath); + FileOutputStream out = null; + try { + if (file.exists()) { + file.delete(); + } + file.createNewFile(); + out = new FileOutputStream(file); + wb.write(out); + } catch (FileNotFoundException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + }catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + }finally { + if(out != null) { + try { + out.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + MessageBox.post("ɹ", "ʾ", MessageBox.INFORMATION); + // øʽ + + // 򿪵ıļ + Runtime.getRuntime().exec("cmd /c \"" + toPath + "\""); + + } catch (IOException e) { + e.printStackTrace(); + } + reporter.requestCanceling(); + //btn.setEnabled(true); + } + }.start(); + } + } + +} \ No newline at end of file diff --git a/src/cn/com/ebewin/ysr/dialog/systemdatadistribution/MultiComboBox.java b/src/cn/com/ebewin/ysr/dialog/systemdatadistribution/MultiComboBox.java new file mode 100644 index 0000000..ff91a78 --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/systemdatadistribution/MultiComboBox.java @@ -0,0 +1,217 @@ +package cn.com.ebewin.ysr.dialog.systemdatadistribution; +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Graphics; +import java.awt.GridLayout; +import java.awt.Insets; +import java.awt.LayoutManager; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JScrollPane; +import javax.swing.JTextField; +import javax.swing.UIManager; +import javax.swing.plaf.basic.BasicArrowButton; + +import com.teamcenter.rac.util.PropertyLayout; + + + +public class MultiComboBox extends JComponent { + + private Object[] values; + + public Object[] defaultValues; + + private List listeners = new ArrayList(); + + public MultiPopup popup; + + public JTextField editor; + + protected JButton arrowButton; + + private String valueSperator; + + private static final String DEFAULT_VALUE_SPERATOR = ","; + + public MultiComboBox(Object[] value, Object[] defaultValue){ + this(value,defaultValue,DEFAULT_VALUE_SPERATOR); + } + + public MultiComboBox(Object[] value, Object[] defaultValue , String valueSperator) { + values = value; + defaultValues = defaultValue; + this.valueSperator = valueSperator; + initComponent(); + } + + private void initComponent() { + //ʱʹøò,Լд + this.setLayout(new PropertyLayout()); + //this.set + popup =new MultiPopup(values,defaultValues); + popup.addActionListener(new PopupAction()); + + editor = new JTextField(); + editor.setBackground(Color.WHITE); + editor.setEditable(false); + editor.setPreferredSize(new Dimension(350, 25)); +// 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/com/ebewin/ysr/dialog/systemdatadistribution/MultiPopup.java b/src/cn/com/ebewin/ysr/dialog/systemdatadistribution/MultiPopup.java new file mode 100644 index 0000000..9d0fafd --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/systemdatadistribution/MultiPopup.java @@ -0,0 +1,210 @@ +package cn.com.ebewin.ysr.dialog.systemdatadistribution; +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("ѡ"); + + commitButton.addActionListener(new ActionListener(){ + + public void actionPerformed(ActionEvent e) { + commit(); + } + + }); + + cancelButton = new JButton("ȫѡ/ȫѡ"); + + cancelButton.addActionListener(new ActionListener(){ + + public void actionPerformed(ActionEvent e) { +// cancel(); + chooseAll(); + } + + }); + + 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)); + } + + public void chooseAll() { + // жǷиѡ򶼱ѡ + boolean allSelected = true; + for (JCheckBox checkBox : checkBoxList) { + if (!checkBox.isSelected()) { + allSelected = false; + break; + } + } + + // ݵǰ״̬ȫѡȫѡ + for (JCheckBox checkBox : checkBoxList) { + checkBox.setSelected(!allSelected); // ȫѡУȡѡУȫѡ + } + + // ѡҪ¼Աԭ߼ +// fireActionPerformed(new ActionEvent(this, 0, COMMIT_EVENT)); + } + +} diff --git a/src/cn/com/ebewin/ysr/dialog/systemdatadistribution/SystemDataDistributionDialog.java b/src/cn/com/ebewin/ysr/dialog/systemdatadistribution/SystemDataDistributionDialog.java new file mode 100644 index 0000000..3912f52 --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/systemdatadistribution/SystemDataDistributionDialog.java @@ -0,0 +1,2327 @@ +package cn.com.ebewin.ysr.dialog.systemdatadistribution; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.GridLayout; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.List; + +import javax.swing.*; +import javax.swing.filechooser.FileSystemView; +import javax.swing.table.DefaultTableModel; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentTask; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.UIUtilities; + +import cn.hutool.core.util.ArrayUtil; +import cn.hutool.core.util.StrUtil; +import java.util.regex.Pattern; +import java.util.regex.Matcher; + +public class SystemDataDistributionDialog extends JFrame implements ActionListener{ + private TCSession session; + private DefaultTableModel model; + private JTable table; + private int columnNum; + private List data = new ArrayList();//ѯ + private List finalData = new ArrayList();//Ⱦ + + private JLabel projectNumJLabel;//Ŀ + private JLabel projectManagerJLabel;//Ŀ + private JLabel projectManagementJLabel;//Ŀ + private JLabel projectNameJLabel;//ļ + private JLabel tcpodiJLabel;//ļ + + //ƻʱ1 + private String jhTime1 = null; + //ƻʱ2 + private String jhTime2 = null; + //ʵʱ1 + private String sjTime1 = null; + //ʵʱ2 + private String sjTime2 = null; + + + private JTextField projectNumField; + private JTextField projectManagerField; + private JTextField tcpodiField;//ܰٷֱ + private JTextField projectManagementField; + private JComboBox timeTypeComboBox; + private JComboBox fileNameComboBox; + private String[] fileNameValues = new String[]{ + "Ŀ", + "ͼ", + "հ沼ͼ", + "Ŀ¼", + "õ", + "Ŀ", + "ʩʽ", + "豸ɫ֪ͨ", + "ί", + "", + "׻", + "ɹ", + "Э", + "Ԥձ", + "յ", + "Ŀ֪ͨʱ", + "Ŀȼƻ񴥷ʱ", + }; + //53 + private String[] columnNames = { + "Ŀ", + "", + "Ŀ", + "Ŀ", + "Ŀ", + "ʱ", + "ʱ", + "Ч", + "ͼƻ",//8 + "ͼʵ",//=9 + "ֵ", + "հ沼ͼƻ",//11 + "հ沼ͼʵ",//=12 + "ֵ", + "Ŀ¼ƻ",//14 + "Ŀ¼ʵ",//=15 + "ֵ", + "õƻ",//17 + "õʵ",//=18 + "ֵ", + "Ŀϼƻ",//20 + "Ŀʵ",//=21 + "ֵ", + "ʩʽƻ",//23 + "ʩʽʵ",//=24 + "ֵ", + "豸ɫ֪ͨƻ",//26 + "豸ɫ֪ͨʵ",//=27 + "ֵ", + "ίƻ",//29 + "ίʵ",//=30 + "ֵ", + "ƻ",//32 + "ʵ",//=33 + "ֵ", + "׻ƻ",//35 + "׻ʵ",//=36 + "ֵ", + "ɹƻ",//38 + "ɹʵ",//=39 + "ֵ", + "Эʵ",//=41 + "Ԥձʵ",//=42 + "յʵ",//=43 + "Ŀ֪ͨʱʵ",//=44 + "Ŀȼƻ񴥷ʱʵ",//=45 + "ʱƻ",//46 + "ʱʵ",//=47 + "άʱƻ",//48 + "άʱʵ",//=49 + "Ԥ±ʱƻ",//50 + "Ԥ±ʱʵ",//=51 + "ÿĿϵͳɰٷֱ" + };//53 + + //ƻʵʵ + private int[] columnJH_SY = {8,11,14,17,20,23,26,29,32,35,38,46,48,50}; + private int[] columnSJ_SY = {9,12,15,18,21,24,27,30,33,36,39,41,42,43,44,45,47,49,51}; + + private JButton queryButton; + private JButton exportButton; + private DateButton startButton; + private DateButton endButton; + private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + private MultiComboBox combox; + private int fz = 0;//ÿĿϵͳɰٷֱ- + private int fm = 0;//ÿĿϵͳɰٷֱ-ĸ + private int tcpodi_fz = 0;//ѯϵɰٷֱ- + private int tcpodi_fm = 0;//ѯϵɰٷֱ-ĸ + //ͼٷֱ + private int bzt_total_fz = 0; + private int bzt_total_fm = 0; + //ͼٷֱ + private int bjt_total_fz = 0; + private int bjt_total_fm = 0; + //Ŀ¼ٷֱ + private int zml_total_fz = 0; + private int zml_total_fm = 0; + //õٷֱ + private int jqr_total_fz = 0; + private int jqr_total_fm = 0; + //Ŀϵٷֱ + private int qdh_total_fz = 0; + private int qdh_total_fm = 0; + //ʩʽ鵥ٷֱ + private int sjsg_total_fz = 0; + private int sjsg_total_fm = 0; + //豸ɫ֪ͨٷֱ + private int sbys_total_fz = 0; + private int sbys_total_fm = 0; + //ίٷֱ + private int wwsp_total_fz = 0; + private int wwsp_total_fm = 0; + //ٷֱ + private int elec_total_fz = 0; + private int elec_total_fm = 0; + //׻ᵥٷֱ + private int jdh_total_fz = 0; + private int jdh_total_fm = 0; + //ɹٷֱ + private int cg_total_fz = 0; + private int cg_total_fm = 0; + + + + public SystemDataDistributionDialog(TCSession session) throws Exception { + System.out.println("SystemDataDistributionDialog~"); + this.session = session; + initUi(); + } + + /** + * м㵥ٷֱصķӷĸ + */ + public void blankIndividualPercentage() { + //ͼٷֱ + this.bzt_total_fz = 0; + this.bzt_total_fm = 0; + //ͼٷֱ + this.bjt_total_fz = 0; + this.bjt_total_fm = 0; + //Ŀ¼ٷֱ + this.zml_total_fz = 0; + this.zml_total_fm = 0; + //õٷֱ + this.jqr_total_fz = 0; + this.jqr_total_fm = 0; + //Ŀϵٷֱ + this.qdh_total_fz = 0; + this.qdh_total_fm = 0; + //ʩʽ鵥ٷֱ + this.sjsg_total_fz = 0; + this.sjsg_total_fm = 0; + //豸ɫ֪ͨٷֱ + this.sbys_total_fz = 0; + this.sbys_total_fm = 0; + //ίٷֱ + this.wwsp_total_fz = 0; + this.wwsp_total_fm = 0; + //ٷֱ + this.elec_total_fz = 0; + this.elec_total_fm = 0; + //׻ᵥٷֱ + this.jdh_total_fz = 0; + this.jdh_total_fm = 0; + //ɹٷֱ + this.cg_total_fz = 0; + this.cg_total_fm = 0; + } + + /** + * п + */ + public void setColumnWidth() { + int[] czdxwcbfb = {10,13,16,19,22,25,28,31,34,37,40};//ֵٷֱȵ +// for (int i = 0; i < this.columnNum; i++){ +// int headNum = this.columnNames[i].length();//ȡͷ +// if (headNum <= 4){ +// this.table.getColumnModel().getColumn(i).setPreferredWidth(50);//2,3 +// } +// } + this.table.getColumnModel().getColumn(0).setPreferredWidth(100);//Ŀ + this.table.getColumnModel().getColumn(1).setPreferredWidth(250);// + this.table.getColumnModel().getColumn(2).setPreferredWidth(70);//Ŀ + this.table.getColumnModel().getColumn(3).setPreferredWidth(70);//Ŀ + this.table.getColumnModel().getColumn(4).setPreferredWidth(250);//Ŀ + for (int i = 5; i < this.columnNum; i++){ + this.table.getColumnModel().getColumn(i).setPreferredWidth(130);//ʱ->>> + } + for (int i = 0; i < czdxwcbfb.length; i++){ + this.table.getColumnModel().getColumn(czdxwcbfb[i]).setPreferredWidth(230);//ֵ + } + } + + /** + * ʼ + */ + private void initUi() throws Exception { + System.out.println("initUi~"); + // TODO Զɵķ + this.setTitle("ϵͳ·ͳƿ"); + this.setSize(800, 600); + this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + this.setResizable(true); + this.setLayout(new BorderLayout()); + // ȷװοɼ + this.setUndecorated(false); // ĬѾfalseʡ + + //1.ģ + this.columnNum = this.columnNames.length; + this.model = new DefaultTableModel(this.columnNames,0); + this.table = new JTable(this.model); + this.table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);// ԶģʽԱ֧ˮƽ + + setColumnWidth(); + + JScrollPane scrollPane = new JScrollPane(this.table,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);//ôֱ + scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);//ˮƽ + + //2. ѯ + JPanel queryPanel = topPanel();//ʱѯ + + // 3. + this.add(queryPanel, BorderLayout.NORTH); + this.add(scrollPane,BorderLayout.CENTER); +// this.add(minButton); + + // ȷڲö + this.setAlwaysOnTop(false); + + //ŵĻ + UIUtilities.centerToScreen(this); + this.pack(); // ԶڴСӦڲ + this.setPreferredSize(new Dimension(1850,950)); + this.setVisible(true); + } + + private JPanel topPanel() throws Exception { + JPanel panel = new JPanel(new GridBagLayout()); + GridBagConstraints gbc = new GridBagConstraints(); + gbc.insets = new Insets(5, 5, 5, 5); // ֮ļ + + this.timeTypeComboBox = new JComboBox<>(new String[]{"ʱ", "ƻʱ", "ʵʱ"}); + startButton = new DateButton(null, "yyyy-MM-dd", false, false, false); + endButton = new DateButton(null, "yyyy-MM-dd", false, false, false); + + this.projectNumJLabel = new JLabel("Ŀ"); // Ŀ + this.projectNumField = new JTextField(9); + this.projectManagerJLabel = new JLabel("Ŀ"); // Ŀ + this.projectManagerField = new JTextField(9); + this.tcpodiJLabel = new JLabel("ѯϵɰٷֱȣ"); + this.tcpodiField = new JTextField(9); + this.tcpodiField.setEditable(false); + + this.projectManagementJLabel = new JLabel("Ŀ"); // Ŀ + this.projectManagementField = new JTextField(9); + this.projectNameJLabel = new JLabel("ļ"); // ļ + this.combox = new MultiComboBox(fileNameValues, new String[]{""}); + + // ʱ + gbc.gridx = 0; + gbc.gridy = 0; + gbc.gridwidth = 1; + gbc.weightx = 0.0; + gbc.anchor = GridBagConstraints.WEST; + panel.add(new JLabel("ʱ:"), gbc); + + gbc.gridx = 1; + gbc.gridy = 0; + gbc.gridwidth = 1; + gbc.weightx = 0.0; + panel.add(this.timeTypeComboBox, gbc); + + gbc.gridx = 2; + gbc.gridy = 0; + gbc.gridwidth = 1; + gbc.weightx = 0.0; + panel.add(startButton, gbc); + + gbc.gridx = 3; + gbc.gridy = 0; + gbc.gridwidth = 1; + gbc.weightx = 0.0; + panel.add(new JLabel("-"), gbc); + + gbc.gridx = 4; + gbc.gridy = 0; + gbc.gridwidth = 1; + gbc.weightx = 0.0; + panel.add(endButton, gbc); + + // Ŀ + gbc.gridx = 0; + gbc.gridy = 1; + gbc.gridwidth = 1; + gbc.weightx = 0.0; + panel.add(projectNumJLabel, gbc); + + gbc.gridx = 1; + gbc.gridy = 1; + gbc.gridwidth = 1; + gbc.weightx = 0.0; + panel.add(projectNumField, gbc); + + // Ŀ + gbc.gridx = 0; + gbc.gridy = 2; + gbc.gridwidth = 1; + gbc.weightx = 0.0; + panel.add(projectManagerJLabel, gbc); + + gbc.gridx = 1; + gbc.gridy = 2; + gbc.gridwidth = 1; + gbc.weightx = 0.0; + panel.add(projectManagerField, gbc); + + //ѯܰٷֱ Total completion percentage of data inquiries + gbc.gridx = 2; + gbc.gridy = 2; + gbc.gridwidth = 1; + gbc.weightx = 0.0; + panel.add(this.tcpodiJLabel, gbc); + + gbc.gridx = 3; + gbc.gridy = 2; + gbc.gridwidth = 1; + gbc.weightx = 0.0; + panel.add(this.tcpodiField, gbc); + + // Ŀ + gbc.gridx = 0; + gbc.gridy = 3; + gbc.gridwidth = 1; + gbc.weightx = 0.0; + panel.add(projectManagementJLabel, gbc); + + gbc.gridx = 1; + gbc.gridy = 3; + gbc.gridwidth = 1; + gbc.weightx = 0.0; + panel.add(projectManagementField, gbc); + + // ļ + gbc.gridx = 0; + gbc.gridy = 4; + gbc.gridwidth = 1; + gbc.weightx = 0.0; + panel.add(projectNameJLabel, gbc); + + gbc.gridx = 1; + gbc.gridy = 4; + gbc.gridwidth = 1; + gbc.weightx = 0.0; + panel.add(this.combox, gbc); + + // ѯ͵ť + this.queryButton = new JButton("ѯ"); + this.exportButton = new JButton(""); + + JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + buttonPanel.add(this.queryButton); + buttonPanel.add(this.exportButton); + + gbc.gridx = 3; + gbc.gridy = 4; + gbc.gridwidth = 2; + gbc.weightx = 0.0; + gbc.anchor = GridBagConstraints.EAST; + panel.add(buttonPanel, gbc); + + this.queryButton.addActionListener(this); + this.exportButton.addActionListener(this); + + return panel; + } + + + /** + * ƳfileNameValuesаfileNamesԪ + * @param fileNameValues еļ + * @param fileNames ѡҪչʾļ + * @return չʾڿϵ + */ + public static String[] removeElements(String[] fileNameValues, Object[] fileNames) { + System.out.println("removeElements~"); + System.out.println("fileNameValues="+Arrays.toString(fileNameValues)); + System.out.println("fileNames="+Arrays.toString(fileNames)); + // fileNameValues תΪ ArrayList + List fileNameList = new ArrayList<>(Arrays.asList(fileNameValues)); + + // fileNames Ƴ fileNameList дڵԪ + for (Object fileName : fileNames) { + fileNameList.remove(fileName.toString()); + } + + // ArrayList ת + return fileNameList.toArray(new String[0]); + } + + /** + * ɸѡݣ± + * @param data + * @param timeType + * @param startTime + * @param endTime + * @param fileNames + */ + private void updataTable(List data, String timeType, String startTime, String endTime, Object[] fileNames) { + resetHeader(); + System.out.println("data_num0 = "+data.size()); + this.finalData.clear(); + System.out.println("updataTable~ΣtimeType="+timeType+"\n startTime="+startTime+"\n endTime="+endTime+"\n fileNames="+ArrayUtil.toString(fileNames)); + System.out.println("data_num1 = "+data.size()); + + if (timeType!=null){ + System.out.println("ʱɸѡ~"); + if (timeType.equals("ƻʱ")){ + for (int i = 0; i < data.size(); i++){// + String[] strings = data.get(i);// + if (timeType.equals("ƻʱ")){ + System.out.println("ݼƻʱɸѡ~"); + for (int j : columnJH_SY){//ǰемƻʱ + String jh = strings[j];//ǰУƻʱ + if (jh != null && !jh.isEmpty() && isTimeInRange(startTime, endTime, jh)){//jhΪnull򡰡ȻжǷʱ䷶Χ + this.finalData.add(strings); + break; + } + } + } + } + }else if (timeType.equals("ʵʱ")){ + System.out.println("ʵʱɸѡ~"); + for (int i = 0; i < data.size(); i++){ + String[] strings = data.get(i); + for (int j : columnSJ_SY){ + String sj = strings[j]; + if (sj != null && !sj.isEmpty() && isTimeInRange(startTime, endTime, sj)){//sjΪnull򡰡ȻжǷʱ䷶Χ + + finalData.add(strings); + break;//жһ + } + } + } + }else if (timeType.equals("ʱ")){ + finalData.addAll(data); + } + } + + if (fileNames.length>0){ + System.out.println("ļɸѡ~"); + String[] noShowfileName = removeElements(fileNameValues, fileNames);//õչʾڿϵļ + List noShowColum_SY = new ArrayList<>(); + for (String noShowName : noShowfileName){ + if (noShowName.equals("Ŀ")){//6-7 + noShowColum_SY.add(6); + noShowColum_SY.add(7); + } + if (noShowName.equals("ͼ")){//8-10 + noShowColum_SY.add(8); + noShowColum_SY.add(9); + noShowColum_SY.add(10); + } + if (noShowName.equals("հ沼ͼ")){ + noShowColum_SY.add(11); + noShowColum_SY.add(12); + noShowColum_SY.add(13); + } + if (noShowName.equals("Ŀ¼")){ + noShowColum_SY.add(14); + noShowColum_SY.add(15); + noShowColum_SY.add(16); + } + if (noShowName.equals("õ")){ + noShowColum_SY.add(17); + noShowColum_SY.add(18); + noShowColum_SY.add(19); + } + if (noShowName.equals("Ŀ")){ + noShowColum_SY.add(20); + noShowColum_SY.add(21); + noShowColum_SY.add(22); + } + if (noShowName.equals("ʩʽ")){ + noShowColum_SY.add(23); + noShowColum_SY.add(24); + noShowColum_SY.add(25); + } + if (noShowName.equals("豸ɫ֪ͨ")){ + noShowColum_SY.add(26); + noShowColum_SY.add(27); + noShowColum_SY.add(28); + } + if (noShowName.equals("ί")){ + noShowColum_SY.add(29); + noShowColum_SY.add(30); + noShowColum_SY.add(31); + } + if (noShowName.equals("")){ + noShowColum_SY.add(32); + noShowColum_SY.add(33); + noShowColum_SY.add(34); + } + if (noShowName.equals("׻")){ + noShowColum_SY.add(35); + noShowColum_SY.add(36); + noShowColum_SY.add(37); + } + if (noShowName.equals("ɹ")){ + noShowColum_SY.add(38); + noShowColum_SY.add(39); + noShowColum_SY.add(40); + } + if (noShowName.equals("Э")){ + noShowColum_SY.add(41); + } + if (noShowName.equals("Ԥձ")){ + noShowColum_SY.add(42); + } + if (noShowName.equals("յ")){ + noShowColum_SY.add(43); + } + if (noShowName.equals("Ŀ֪ͨʱ")){ + noShowColum_SY.add(44); + } + if (noShowName.equals("Ŀȼƻ񴥷ʱ")){ + noShowColum_SY.add(45); + } + } + if (noShowColum_SY.size()>0){ + for (int nosy : noShowColum_SY){//Ҫյ + for (String[] row : finalData){ + row[nosy] = ""; + } + } + } + } +//----------------------------------------------------------------------------------------------- + if (this.model.getRowCount() > 0) { + // ձݣб + System.out.println("ʼձݣб"); + for (int i = this.model.getRowCount() - 1; i >= 0; i--) { + this.model.removeRow(i); + } + } + System.out.println("Ⱦ"+finalData.size()); + for (int i = 0; i < finalData.size(); i++) { + this.model.addRow(finalData.get(i)); + } + } + + /* + * ѯ + * @param queryName ѯ + * @param entryNames ѯ + * @param entryValues ѯֵ + */ + public InterfaceAIFComponent[] queryBuilder(String queryName,List entryNames, List entryValues){ + System.out.println("òѯΣ"); + for (int i = 0; i < entryNames.size(); i++){ + System.out.println("entryNames:" + entryNames.get(i) + " entryValues:" + entryValues.get(i)); + } + InterfaceAIFComponent[] resultComponents = null; + try { + resultComponents = session.search(queryName, + entryNames.toArray(new String[entryNames.size()]), + entryValues.toArray(new String[entryNames.size()])); + } catch (Exception e) { + // TODO Զɵ catch + e.printStackTrace(); + } + return resultComponents; + } + + /** + * ȽʱǷָʱ䷶Χ + * @param startTime + * @param endTime + * @param currentTime + * @return + */ + public static boolean isTimeInRange(String startTime, String endTime, String currentTime) { + + System.out.println("isTimeInRange~startTime:"+startTime+" endTime:"+endTime+" currentTime:"+currentTime); + // ʱʽ + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-M-dd HH:mm"); + LocalDateTime startDateTime=null; + LocalDateTime endDateTime=null; + LocalDateTime currentDateTime=null; + // ַΪ LocalDateTime + if (startTime != null){ + startDateTime = LocalDateTime.parse(startTime, formatter); + } + if (endTime != null){ + endDateTime = LocalDateTime.parse(endTime, formatter); + } + if (currentTime != null){ + currentDateTime = LocalDateTime.parse(currentTime, formatter); + } + + // ж currentDateTime Ƿ startDateTime endDateTime ֮ + if (startDateTime != null && endDateTime != null) { + return !currentDateTime.isBefore(startDateTime) && !currentDateTime.isAfter(endDateTime); + } else if (startDateTime != null) { + return !currentDateTime.isBefore(startDateTime); + } else if (endDateTime != null) { + return !currentDateTime.isAfter(endDateTime); + } else { + // startTime endTime Ϊ nullɸѡΪգ򷵻 true + return true; + } + } + + /* + * ֵֻСʱͷӣһΪnull""ֱӷnull + * @param startDate ƻڣyyyy-M-dd hh:mm + * @param endDate ʵڣyyyy-M-dd hh:mm + * @return ڲֵλΪ + */ + public String caculateDifference(String startDate, String endDate) { + // ǷΪջַ + if (startDate == null || startDate.isEmpty() || endDate == null || endDate.isEmpty()) { + return "-"; + } + + // ڸʽ + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-M-dd HH:mm"); + + // + LocalDateTime startDateTime = LocalDateTime.parse(startDate, formatter); + LocalDateTime endDateTime = LocalDateTime.parse(endDate, formatter); + + // ֻڲ + LocalDate startDay = startDateTime.toLocalDate(); + LocalDate endDay = endDateTime.toLocalDate(); + + // ڲ + long daysBetween = ChronoUnit.DAYS.between(startDay, endDay); + + // ؽ + return String.valueOf(daysBetween); + + } + + /* + * + */ + @Override + public void actionPerformed(ActionEvent e) { + // TODO Զɵķ + Object s = e.getSource(); + try { + if (s.equals(this.queryButton)) { + System.out.println("ѯ¼"); + this.tcpodiField.setText(""); + data.clear(); + //1.ȡѯ + String timeType = (String) this.timeTypeComboBox.getSelectedItem(); + Date startDate = null; + Date endDate = null; + String projectNum = null; + String projectManager = null; + String projectManagement = null; + Object[] fileNames = null; + + startDate = startButton.getDate(); + endDate = endButton.getDate(); + projectNum = this.projectNumField.getText(); + projectManager = this.projectManagerField.getText(); + projectManagement = this.projectManagementField.getText(); + fileNames = this.combox.getSelectedValues(); + + //2.òѯysr8_ProjectSRevisionMaster + //ŸòѯеIJѯĿentryNamesĶӦֵentryValues + List entryNames = new ArrayList(); + List entryValues = new ArrayList(); + if (fileNames.length>0) {//ļ + System.out.println("ѡļƣ["+ArrayUtil.toString(fileNames)+"]="+fileNames.length); + if (startDate == null && endDate == null && projectNum.isEmpty() && projectManager.isEmpty() && projectManagement.isEmpty()) { + MessageBox.post("ļ⣬Ҫѡһ","ʾ",MessageBox.INFORMATION); + return; + } + } + //֯ʱתʽ + String startDateInput = null; + String endDateInput = null; + if (startDate != null){ + startDateInput = dateFormat.format(startDate).replaceAll("(\\d{4})-0(\\d)-", "$1-$2-") + " 00:00"; + + } + if (endDate != null){ + endDateInput = dateFormat.format(endDate).replaceAll("(\\d{4})-0(\\d)-", "$1-$2-") + " 23:59"; + } + + // + if (timeType.equals("ƻʱ")){ + jhTime1 = startDateInput; + jhTime2 = endDateInput; + } else if (timeType.equals("ʵʱ")) { + sjTime1 = startDateInput; + sjTime2 = endDateInput; + } + + if (startDate != null) {//ʼʱ + entryNames.add("ysr8_StartDate>"); + entryValues.add(startDateInput); + System.out.println("Σʱ=["+startDateInput+"]"); + } + if (endDate != null) {//ʱ + entryNames.add("ysr8_StartDate<"); + entryValues.add(endDateInput); + System.out.println("Σʱ=["+endDateInput+"]"); + } + if (projectNum != null && !projectNum.isEmpty()) {//Ŀ + entryNames.add("ysr8_ProjectCode"); + entryValues.add(projectNum); + System.out.println("ΣĿ=["+projectNum+"]="+projectNum.length()); + } + if (projectManager != null && !projectManager.isEmpty()) {//Ŀ + entryNames.add("ysr8_ProjectManager"); + entryValues.add(projectManager); + System.out.println("ΣĿ=["+projectManager+"]="+projectNum.length()); + } + if (projectManagement != null && !projectManagement.isEmpty()) {//Ŀ + entryNames.add("ysr8_Planner"); + entryValues.add(projectManagement); + System.out.println("ΣĿ=["+projectManagement+"]="+projectNum.length()); + } + System.out.println("ѯ="+entryNames.size()); + for (int i = 0; i < entryValues.size(); i++) { + System.out.println("["+entryNames.get(i)+"]<=:=>["+entryValues.get(i)+"]"); + } + InterfaceAIFComponent[] resultComponents = null; + if (entryValues.size()>0) { + resultComponents = queryBuilder("Ŀ֪ͨѯ", entryNames, entryValues); + + }else { + MessageBox.post("һѯ","ʾ",MessageBox.INFORMATION); + return; + } + + if(resultComponents != null) { + if (resultComponents.length>0) { + System.out.println("ѯĿϢɹ:"+resultComponents.length); + this.tcpodi_fz = 0; + this.tcpodi_fm = 0; + blankIndividualPercentage(); + for (int i = 0; i < resultComponents.length; i++) {//ѯ + String[] ss = new String[this.columnNum];//ݵ飨һĿϢӦһݣ + this.fz = 0; + this.fm = 0; + InterfaceAIFComponent interfaceAIFComponent = resultComponents[i]; + TCComponentItemRevision revision = (TCComponentItemRevision)interfaceAIFComponent; + TCComponent[] referenceListProperty = revision.getReferenceListProperty("IMAN_master_form_rev");//ȡ汾µı + if (referenceListProperty.length>0) { + System.out.println("ȡ汾µıɹȡĿϢɹ0-5"); + TCComponentForm form = (TCComponentForm)referenceListProperty[0]; + //ȡѯУĿ֪ͨĿϢ + String projectCodeString = form.getProperty("ysr8_ProjectCode");//Ŀ + String managerString = form.getProperty("ysr8_ProjectManager");//Ŀ + String orderManufacturer = form.getProperty("ysr8_OrderManufacturer");// + String planner = form.getProperty("ysr8_Planner");//Ŀ + String projectContent = form.getProperty("ysr8_ProjectContent");//Ŀ + String startDateString = form.getProperty("ysr8_StartDate");//ʱ + System.out.println("ѯĽ\n "+projectCodeString+"\n"+managerString+"\\n"+orderManufacturer+"\\n"+planner+"\\n"+projectContent+"\\n"+startDateString); + + //дĿϢ(0-5) + ss[0] = projectCodeString == null ? "" : projectCodeString; + ss[1] = orderManufacturer == null ? "" : orderManufacturer; + ss[2] = managerString == null ? "" : managerString; + ss[3] = planner == null ? "" : planner; + ss[4] = projectContent == null ? "" : projectContent; + ss[5] = startDateString == null ? "" : startDateString; + + //TODO ֯ĿϢϢ + if (projectCodeString != null) { + //ȡϢ + System.out.println("0ȡϢǰĻĿϢ"+ArrayUtil.toString(ss)); + ss = getAllAttribute(ss,projectCodeString); + + }else { + System.out.println("δѯĿϢ"); + } + } + data.add(ss); + } + //ɰٷֱȣȾ + String s1 = caculateTcpodi(this.tcpodi_fz, this.tcpodi_fm); + this.tcpodiField.setText(s1); + updataTable(data,timeType,startDateInput,endDateInput,fileNames); + + }else { + MessageBox.post("ѯδѯҪĽ","ѯ",MessageBox.INFORMATION); + } + }else { + MessageBox.post("'Ŀ֪ͨѯ'ʧ","ѯ",MessageBox.INFORMATION); + } + }else if (s.equals(this.exportButton)) { + if (this.finalData.size()>0) { + System.out.println("ť~"); + JFileChooser fileChooser = new JFileChooser(FileSystemView.getFileSystemView().getHomeDirectory()); + fileChooser.setDialogTitle("Select a folder"); + fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + int returnValue = fileChooser.showOpenDialog(null); + String chooserPathString = null; + if (returnValue == JFileChooser.APPROVE_OPTION) { + File selectedFile = fileChooser.getSelectedFile(); + chooserPathString = selectedFile.getAbsolutePath(); + System.out.println("Selected directory: " + chooserPathString); + } + if (this.finalData.size()>0) { + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); + String timestamp = dateFormat.format(new Date()); + String fileName = chooserPathString+"\\ϵͳ·ͳƱ_" + timestamp + ".xls"; + exportExcel(fileName, this.finalData); + } + }else { + MessageBox.post("ڵݣȲѯ","",MessageBox.INFORMATION); + } + + } + } catch (Exception e2) { + // TODO: handle exception + e2.printStackTrace(); + } + + } + + public void incremeFZ(String attributeValue) { + if (attributeValue != null && !attributeValue.isEmpty()){ + this.fz ++; + } + } + + public void incremeFM(String attributeValue) { + if (attributeValue != null && !attributeValue.isEmpty()){ + this.fm ++; + } + } + + /** + * ȡϢ + * @param ss Ϣ飬ʱֻĿϢ + * @param projectCodeString + * @return + * @throws Exception + */ + private String[] getAllAttribute(String[] ss,String projectCodeString) throws Exception { + System.out.println("getAllAttribute~"); + //֯ѯΣĿ_****** + String XMFXPGD_id = projectCodeString +"_XMFXPGD";//Ŀ + String BZT_id = projectCodeString +"_BZT";//ͼհ沼ͼ + String rev1 = "A";//ͼΣ汾 + String rev2 = "B";//հ沼ͼ汾 + String XTZML = projectCodeString + "_XTZML"; + String JQR01 = projectCodeString + "_JQR01"; + String QDHZL01 = projectCodeString + "_QDHZL01"; + String SJSY01 = projectCodeString + "_SJSY01"; + String YSTZ = projectCodeString + "_YSTZ"; + String WWQD01 = projectCodeString + "_WWQD*";//ί + // + String JDHZL01 = projectCodeString + "_JDHZL01"; + //ɹ +//---------------------------ʱ&Ч--------------------------------------------------------------- + if (XMFXPGD_id != null) {//Ŀ + System.out.println("ʱѯ"); + List entryNamesJK = new ArrayList(); + List entryValuesJK = new ArrayList(); + entryNamesJK.add(""); + entryValuesJK.add(XMFXPGD_id+"*"); + if (jhTime1 != null) { + entryNamesJK.add("ʱ"); + entryValuesJK.add(jhTime1); + } + if (jhTime2 != null) { + entryNamesJK.add("ʱС"); + entryValuesJK.add(jhTime2); + } + + TCComponent[] xmfxpgdRsJK = (TCComponent[]) queryBuilder("ʱѯ", entryNamesJK, entryValuesJK); + if (xmfxpgdRsJK.length > 0){ + System.out.println("ʱѯɹѯ"+xmfxpgdRsJK.length); + TCComponentTask task = (TCComponentTask)xmfxpgdRsJK[0]; + String jkspsj = task.getProperty("fnd0EndDate"); + incremeFM(jkspsj); + ss[6] = jkspsj == null ? "" : jkspsj;//ʱ + + }else { + System.out.println("ǰ汾δ̣ȡʱʧܣ"); + } + + System.out.println("Ŀѯ"); + List entryNames1 = new ArrayList(); + List entryValues1 = new ArrayList(); + entryNames1.add("ID"); + entryValues1.add(XMFXPGD_id); + if (sjTime1 != null){ + entryNames1.add("ʱ"); + entryValues1.add(sjTime1); + } + if(sjTime2 != null){ + entryNames1.add("ʱС"); + entryValues1.add(sjTime2); + } + + TCComponent[] xmfxpgdRs = (TCComponent[]) queryBuilder("Ŀĵѯ", entryNames1, entryValues1); + if (xmfxpgdRs.length > 0) { + System.out.println("Ŀĵѯɹѯ"+xmfxpgdRs.length); + TCComponentItemRevision rev = (TCComponentItemRevision)xmfxpgdRs[0]; + String ecxgpj = rev.getProperty("date_released"); + incremeFZ(ecxgpj); + incremeFM(ecxgpj); + ss[7] = ecxgpj == null ? "" : ecxgpj;//Чۣʵʣ + + }else { + System.out.println("Ŀ-δѯκϢ"); + } + + } +//-------------------------------------------------------------------------------------------------------------------------------- + + if (BZT_id != null){//ͼ + System.out.println("ͼѯ"); + InterfaceAIFComponent[] sjbrw = null; + //ѯͼļƻԪ-8 + InterfaceAIFComponent[] sjbrw1 = scheduleTaskQuery1(""+projectCodeString+"ͼ"); + InterfaceAIFComponent[] sjbrw2 = scheduleTaskQuery1(projectCodeString+"ͼ"); + if (sjbrw1.length>0) { + sjbrw = sjbrw1.clone(); + }else if (sjbrw2.length>0){ + sjbrw = sjbrw2.clone(); + }else { + System.out.println("ʱ δѯ ͼ ļƻϢ"); + } + if (sjbrw != null && sjbrw.length>0) { + String bztjh = sjbrw[0].getProperty("finish_date"); + incremeFM(bztjh); + if (bztjh != null && !bztjh.isEmpty()){ + this.bzt_total_fm ++; + } + ss[8] = bztjh == null ? "" : bztjh; + } + //ѯͼʵʣԪ-9 + List entryNames2 = new ArrayList(); + List entryValues2 = new ArrayList(); + entryNames2.add("ID"); + entryNames2.add("汾"); + entryValues2.add(BZT_id); + entryValues2.add(rev1); + if (sjTime1 != null){ + entryNames2.add("ʱ"); + entryValues2.add(sjTime1); + } + if (sjTime2 != null){ + entryNames2.add("ʱС"); + entryValues2.add(sjTime2); + } + + InterfaceAIFComponent[] bztsjs = queryBuilder("Ŀĵѯ", entryNames2, entryValues2); + if (bztsjs.length>0){ + String bztsj = bztsjs[0].getProperty("date_released"); + incremeFZ(bztsj); + incremeFM(bztsj); + + if (bztsj != null && !bztsj.isEmpty()){ + this.bzt_total_fz ++; + this.bzt_total_fm ++; + } + ss[9] = bztsj == null ? "" : bztsj; + }else { + System.out.println("Ŀĵѯ δѯ ͼ ʵϢ"); + } + //ֵ-10 + ss[10] = caculateDifference(ss[8], ss[9]); + + +//-------------------------------------------------------------------------------------------------------------------------------- + System.out.println("հ沼ͼѯ"); + //ѯհ沼ͼļƻԪ-11 + InterfaceAIFComponent[] zbbjtjhs = null; + InterfaceAIFComponent[] zbbjtjhs1 = scheduleTaskQuery1(""+projectCodeString+"ṩղͼ(н)"); + InterfaceAIFComponent[] zbbjtjhs2 = scheduleTaskQuery1(projectCodeString+"ṩղͼ(н)"); + if (zbbjtjhs1.length>0){ + zbbjtjhs = zbbjtjhs1.clone(); + }else if (zbbjtjhs2.length>0){ + zbbjtjhs = zbbjtjhs2.clone(); + }else { + System.out.println("ʱ δѯ հ沼ͼ ļƻϢ"); + } + if (zbbjtjhs != null && zbbjtjhs.length>0) { + String zbbjtjh = zbbjtjhs[0].getProperty("finish_date"); + incremeFM(zbbjtjh); + if (zbbjtjh != null && !zbbjtjh.isEmpty()){ + this.bjt_total_fm ++; + } + + ss[11] = zbbjtjh == null ? "" : zbbjtjh; + } + //ѯհ沼ͼʵʣԪ-12 + List entryNames4 = new ArrayList(); + List entryValues4 = new ArrayList(); + entryNames4.add("ID"); + entryNames4.add("汾"); + entryValues4.add(BZT_id); + entryValues4.add(rev2); + if (sjTime1 != null){ + entryNames4.add("ʱ"); + entryValues4.add(sjTime1); + } + if(sjTime2 != null){ + entryNames4.add("ʱС"); + entryValues4.add(sjTime2); + } + + InterfaceAIFComponent[] zbbjtsjs = queryBuilder("Ŀĵѯ", entryNames4, entryValues4); + if (zbbjtsjs.length>0){ + String zbbjtsj = zbbjtsjs[0].getProperty("date_released"); + incremeFZ(zbbjtsj); + incremeFM(zbbjtsj); + + if (zbbjtsj != null && !zbbjtsj.isEmpty()){ + this.bjt_total_fz ++; + this.bjt_total_fm ++; + } + ss[12] = zbbjtsj == null ? "" : zbbjtsj; + }else { + System.out.println("Ŀĵѯ δѯ հ沼ͼ ʵϢ"); + } + //ֵ-13 + ss[13] = caculateDifference(ss[11], ss[12]); + + } +//-------------------------------------------------------------------------------------------------------------------------------- + if (XTZML != null){//Ŀ¼ + System.out.println("ϵͳĿ¼ѯ"); + //Ŀ¼-ƻԪ-14 + InterfaceAIFComponent[] zmljhs = null; + InterfaceAIFComponent[] zmljhs1 = scheduleTaskQuery1("" + projectCodeString + "·Ŀ¼"); + InterfaceAIFComponent[] zmljhs2 = scheduleTaskQuery1(projectCodeString + "·Ŀ¼"); + if (zmljhs1.length>0){ + zmljhs = zmljhs1.clone(); + }else if (zmljhs2.length>0){ + zmljhs = zmljhs2.clone(); + }else { + System.out.println("ʱ δѯ Ŀ¼ ļƻϢ"); + } + + if (zmljhs != null && zmljhs.length>0) { + String zmljh = zmljhs[0].getProperty("finish_date"); + incremeFM(zmljh); + + if (zmljh != null && !zmljh.isEmpty()){ + this.zml_total_fm ++; + } + + ss[14] = zmljh == null ? "" : zmljh; + }else { + System.out.println("ʱ δѯ Ŀ¼ ļƻϢ"); + } + //Ŀ¼-ʵʣԪ-15 + List entryNames2 = new ArrayList(); + List entryValues2 = new ArrayList(); + entryNames2.add("ID"); + entryNames2.add("汾"); + entryValues2.add(XTZML); + entryValues2.add(rev1); + if (sjTime1 != null){ + entryNames2.add("ʱ"); + entryValues2.add(sjTime1); + } + if (sjTime2 != null){ + entryNames2.add("ʱС"); + entryValues2.add(sjTime2); + } + + InterfaceAIFComponent[] zmlsjs = queryBuilder("Ŀĵѯ", entryNames2, entryValues2); + if (zmlsjs.length>0){ + String zmlsj = zmlsjs[0].getProperty("date_released"); + incremeFZ(zmlsj); + incremeFM(zmlsj); + + if (zmlsj != null && !zmlsj.isEmpty()){ + this.zml_total_fz ++; + this.zml_total_fm ++; + } + + ss[15] = zmlsj == null ? "" : zmlsj; + }else { + System.out.println("Ŀĵѯ δѯ հ沼ͼ ʵϢ"); + } + //ֵ-16 + ss[16] = caculateDifference(ss[14], ss[15]); + } +//------------------------------------------------------------------------------------------------------------------------------- + if (JQR01 != null){//õ + System.out.println("õѯ"); + //õ-ƻԪ-17 + InterfaceAIFComponent[] jqrpzds = null; + InterfaceAIFComponent[] jqrpzds1 = scheduleTaskQuery1("" + projectCodeString + "˲ɹ"); + InterfaceAIFComponent[] jqrpzds2 = scheduleTaskQuery1(projectCodeString + "˲ɹ"); + if (jqrpzds1.length>0){ + jqrpzds = jqrpzds1.clone(); + }else if (jqrpzds2.length>0){ + jqrpzds = jqrpzds2.clone(); + }else { + System.out.println("ʱ δѯ õ ļƻϢ"); + } + + if (jqrpzds != null && jqrpzds.length>0){ + String jqrpzd = jqrpzds[0].getProperty("finish_date"); + incremeFM(jqrpzd); + + if (jqrpzd != null && !jqrpzd.isEmpty()){ + this.jqr_total_fm ++; + } + + ss[17] = jqrpzd == null ? "" : jqrpzd; + }else { + System.out.println("ʱ δѯ õ ļƻϢ"); + } + //õ-ʵʣԪ-18 + List entryNames2 = new ArrayList(); + List entryValues2 = new ArrayList(); + entryNames2.add("ID"); + entryNames2.add("汾"); + entryValues2.add(JQR01); + entryValues2.add(rev1); + if (sjTime1 != null){ + entryNames2.add("ʱ"); + entryValues2.add(sjTime1); + } + if (sjTime2 != null){ + entryNames2.add("ʱС"); + entryValues2.add(sjTime2); + } + + InterfaceAIFComponent[] jqrpzjs = queryBuilder("Ŀĵѯ", entryNames2, entryValues2); + if (jqrpzjs.length>0){ + String jqrpzj = jqrpzjs[0].getProperty("date_released"); + incremeFZ(jqrpzj); + incremeFM(jqrpzj); + //ٷֱۼӼ + if (jqrpzj != null && !jqrpzj.isEmpty()){ + this.jqr_total_fz ++; + this.jqr_total_fm ++; + } + + ss[18] = jqrpzj == null ? "" : jqrpzj; + }else { + System.out.println("Ŀĵѯ δѯ õ ʵϢ"); + } + //ֵ-19 + ss[19] = caculateDifference(ss[17], ss[18]); + } +//-------------------------------------------------------------------------------------------------------------------------------- + if (QDHZL01 != null){ + System.out.println("Ŀϡ"); + //Ŀ-ƻԪ-20 + InterfaceAIFComponent[] qdhjhs = null; + InterfaceAIFComponent[] qdhjhs1 = scheduleTaskQuery1("" + projectCodeString + "(н)"); + InterfaceAIFComponent[] qdhjhs2 = scheduleTaskQuery1(projectCodeString + "(н)"); + if (qdhjhs1.length>0){ + qdhjhs = qdhjhs1.clone(); + }else if (qdhjhs2.length>0){ + qdhjhs = qdhjhs2.clone(); + }else { + System.out.println("ʱ δѯ Ŀ ļƻϢ"); + } + + if (qdhjhs != null && qdhjhs.length>0){ + String qdhjh = qdhjhs[0].getProperty("finish_date"); + incremeFM(qdhjh); + + if (qdhjh != null && !qdhjh.isEmpty()){ + this.qdh_total_fm ++; + } + + ss[20] = qdhjh == null ? "" : qdhjh; + }else { + System.out.println("ʱ δѯ Ŀ ļƻϢ"); + } + //Ŀ-ʵʣԪ-21 + List entryNames2 = new ArrayList(); + List entryValues2 = new ArrayList(); + entryNames2.add("ID"); + entryNames2.add("汾"); + entryValues2.add(QDHZL01); + entryValues2.add(rev1); + if (sjTime1 != null){ + entryNames2.add("ʱ"); + entryValues2.add(sjTime1); + } + if (sjTime2 != null){ + entryNames2.add("ʱС"); + entryValues2.add(sjTime2); + } + + InterfaceAIFComponent[] qdhsjs = queryBuilder("Ŀĵѯ", entryNames2, entryValues2); + if (qdhsjs.length>0){ + String qdhsj = qdhsjs[0].getProperty("date_released"); + incremeFZ(qdhsj); + incremeFM(qdhsj); + + if (qdhsj != null && !qdhsj.isEmpty()){ + this.qdh_total_fz ++; + this.qdh_total_fm ++; + } + + ss[21] = qdhsj == null ? "" : qdhsj; + }else { + System.out.println("Ŀĵѯ δѯ Ŀ ʵϢ"); + } + //ֵ-22 + ss[22] = caculateDifference(ss[20], ss[21]); + } +//--------------------------------------------------------------------------------------------------------------------------------- + if (SJSY01 != null){ + System.out.println("ʩʽ顤"); + //ʩʽ-ƻԪ-23 + InterfaceAIFComponent[] sjsgyss = null; + InterfaceAIFComponent[] sjsgyss1 = scheduleTaskQuery1("" + projectCodeString + "·"); + InterfaceAIFComponent[] sjsgyss2 = scheduleTaskQuery1(projectCodeString + "·"); + if (sjsgyss1.length>0){ + sjsgyss = sjsgyss1.clone(); + }else if (sjsgyss2.length>0){ + sjsgyss = sjsgyss2.clone(); + }else { + System.out.println("ʱ δѯ ʩʽ ļƻϢ"); + } + + if (sjsgyss!=null&&sjsgyss.length>0){ + String sjsgys = sjsgyss[0].getProperty("finish_date"); + incremeFM(sjsgys); + + if (sjsgys != null && !sjsgys.isEmpty()){ + this.sjsg_total_fm ++; + } + + ss[23] = sjsgys == null ? "" : sjsgys; + }else { + System.out.println("ʱ δѯ ʩʽ ļƻϢ"); + } + //ʩʽ-ʵʣԪ-24 + List entryNames2 = new ArrayList(); + List entryValues2 = new ArrayList(); + entryNames2.add("ID"); + entryNames2.add("汾"); + entryValues2.add(SJSY01); + entryValues2.add(rev1); + if (sjTime1 != null){ + entryNames2.add("ʱ"); + entryValues2.add(sjTime1); + } + if (sjTime2 != null){ + entryNames2.add("ʱС"); + entryValues2.add(sjTime2); + } + + InterfaceAIFComponent[] sjsgysjs = queryBuilder("Ŀĵѯ", entryNames2, entryValues2); + if (sjsgysjs.length>0){ + String sjsgysj = sjsgysjs[0].getProperty("date_released"); + incremeFZ(sjsgysj); + incremeFM(sjsgysj); + + if (sjsgysj != null && !sjsgysj.isEmpty()){ + this.sjsg_total_fz ++; + this.sjsg_total_fm ++; + } + + ss[24] = sjsgysj == null ? "" : sjsgysj; + }else { + System.out.println("Ŀĵѯ δѯ ʩʽ ʵϢ"); + } + //ֵ-25 + ss[25] = caculateDifference(ss[23], ss[24]); + } +//--------------------------------------------------------------------------------------------------------------------------------- + if (YSTZ != null){ + System.out.println("豸ɫ֪ͨ"); + //豸ɫ֪ͨ-ƻԪ-26 + InterfaceAIFComponent[] ystzjhs = null; + InterfaceAIFComponent[] ystzjhs1 = scheduleTaskQuery1(""+projectCodeString + "豸ɫ֪ͨ"); + InterfaceAIFComponent[] ystzjhs2 = scheduleTaskQuery1(projectCodeString + "豸ɫ֪ͨ"); + if (ystzjhs1.length>0){ + ystzjhs = ystzjhs1.clone(); + }else if (ystzjhs2.length>0){ + ystzjhs = ystzjhs2.clone(); + }else { + System.out.println("ʱ δѯ 豸ɫ֪ͨ ļƻϢ"); + } + + if (ystzjhs!=null&&ystzjhs.length>0){ + String ystzjh = ystzjhs[0].getProperty("finish_date"); + incremeFM(ystzjh); + + if (ystzjh != null && !ystzjh.isEmpty()){ + this.sbys_total_fm ++; + } + + ss[26] = ystzjh == null ? "" : ystzjh; + }else { + System.out.println("ʱ δѯ 豸ɫ֪ͨ ļƻϢ"); + } + //豸ɫ֪ͨ-ʵʣԪ-27 + List entryNames2 = new ArrayList(); + List entryValues2 = new ArrayList(); + entryNames2.add("ID"); + entryNames2.add("汾"); + entryValues2.add(YSTZ); + entryValues2.add(rev1); + if (sjTime1 != null){ + entryNames2.add("ʱ"); + entryValues2.add(sjTime1); + } + if (sjTime2 != null){ + entryNames2.add("ʱС"); + entryValues2.add(sjTime2); + } + + InterfaceAIFComponent[] ystzsjs = queryBuilder("Ŀĵѯ", entryNames2, entryValues2); + if (ystzsjs.length>0){ + String ystzsj = ystzsjs[0].getProperty("date_released"); + incremeFZ(ystzsj); + incremeFM(ystzsj); + + if (ystzsj != null && !ystzsj.isEmpty()){ + this.sbys_total_fz ++; + this.sbys_total_fm ++; + } + + ss[27] = ystzsj == null ? "" : ystzsj; + }else { + System.out.println("Ŀĵѯ δѯ 豸ɫ֪ͨ ʵϢ"); + } + //ֵ-28 + ss[28] = caculateDifference(ss[26], ss[27]); + } +//--------------------------------------------------------------------------------------------------------------------------------- + if (WWQD01 != null){ + System.out.println("ί"); + String wwqdjh = ""; + String wwqdsj = ""; + int jhNum = 0; + int sjNum = 0; + String earliestDate = null; + + //ί-ƻԪ-29 + InterfaceAIFComponent[] wwqdjhs = null; + InterfaceAIFComponent[] wwqdjhs1 = scheduleTaskQuery1("" + projectCodeString + "ί*"); + InterfaceAIFComponent[] wwqdjhs2 = scheduleTaskQuery1(projectCodeString + "ί*"); + if (wwqdjhs1.length>0){ + wwqdjhs = wwqdjhs1.clone(); + } else if (wwqdjhs2.length > 0) { + wwqdjhs = wwqdjhs2.clone(); + }else { + System.out.println("ʱ δѯ ί ļƻϢ"); + } + + if (wwqdjhs != null && wwqdjhs.length>0){ + System.out.println("ѯί-ƻ" + wwqdjhs.length); + //񳡾-ȡĸ + for (int i = 0 ; i < wwqdjhs.length ; i++){ + jhNum ++; + String wwqdjh0 = wwqdjhs[i].getProperty("finish_date"); + wwqdjh += wwqdjh0 + ";"; + incremeFM(wwqdjh0); + + if (wwqdjh0 != null && !wwqdjh0.isEmpty()){ + this.wwsp_total_fm ++; + } + } + + ss[29] = wwqdjh == null ? "" : wwqdjh; + }else { + System.out.println("ʱ δѯ ί ļƻϢ"); + } + //ί-ʵʣԪ-30 + List entryNames2 = new ArrayList(); + List entryValues2 = new ArrayList(); + entryNames2.add("ID"); + entryNames2.add("汾"); + entryValues2.add(WWQD01); + entryValues2.add(rev1); + if (sjTime1 != null){ + entryNames2.add("ʱ"); + entryValues2.add(sjTime1); + } + if (sjTime2 != null){ + entryNames2.add("ʱС"); + entryValues2.add(sjTime2); + } + + InterfaceAIFComponent[] wwqdsjs = queryBuilder("Ŀĵѯ", entryNames2, entryValues2); + if (wwqdsjs.length>0){ + //ƴΧʵʣʱ䣩 + for (int i = 0; i < wwqdsjs.length; i++) { + sjNum ++; + String wwqds0= wwqdsjs[i].getProperty("date_released"); + wwqdsj += wwqds0 + ";"; + incremeFZ(wwqds0); + incremeFM(wwqds0); + + if (wwqds0 != null && !wwqds0.isEmpty()){ + this.wwsp_total_fz ++; + this.wwsp_total_fm ++; + // Ƚϲʱ + if (earliestDate == null || isTimeEarlier(wwqds0, earliestDate)) { + earliestDate = wwqds0; + } + } + } +// String wwqdsj = wwqdsjs[0].getProperty("date_released"); + ss[30] = earliestDate == null ? "" : earliestDate; + }else { + System.out.println("Ŀĵѯ δѯ ί ʵϢ"); + } + if (jhNum != 0 && sjNum != 0 ) { + //ֵ-31 + System.out.println("ΧֵУƻʱ="+wwqdjhs[0].getProperty("finish_date")+"ʵʱ="+earliestDate); + ss[31] = caculateDifference(wwqdjhs[0].getProperty("finish_date"), earliestDate); + }else { + ss[31] = "-"; + } + + } +//--------------------------------------------------------------------------------------------------------------------------------- + System.out.println("ѯ"); + //-ƻandʵʣԪ-32and33 + InterfaceAIFComponent[] dqcxs = null; + InterfaceAIFComponent[] dqcxs1 = scheduleTaskQuery1("" + projectCodeString + "д"); + InterfaceAIFComponent[] dqcxs2 = scheduleTaskQuery1(projectCodeString + "д"); + if (dqcxs1.length>0){ + dqcxs = dqcxs1.clone(); + } else if (dqcxs2.length > 0) { + dqcxs = dqcxs2.clone(); + }else { + System.out.println("ʱ δѯ д ļƻϢ"); + } + + if (dqcxs!=null&&dqcxs.length>0){ + String dqcxjh = dqcxs[0].getProperty("finish_date"); + incremeFM(dqcxjh); + + if (dqcxjh != null && !dqcxjh.isEmpty()){ + this.elec_total_fm ++; + } + ss[32] = dqcxjh == null ? "" : dqcxjh; + + String dqcxsj = dqcxs[0].getProperty("actual_finish_date"); + incremeFZ(dqcxsj); + incremeFM(dqcxsj); + + if (dqcxsj != null && !dqcxsj.isEmpty()){ + this.elec_total_fz ++; + this.elec_total_fm ++; + } + + ss[33] = dqcxsj == null ? "" : dqcxsj; + } + //ֵ-34 + ss[34] = caculateDifference(ss[32], ss[33]); +//--------------------------------------------------------------------------------------------------------------------------------- + if (JDHZL01 != null){ + System.out.println("׻ѯ"); + //׻-ƻԪ-35 + InterfaceAIFComponent[] jdhjhs = null; + InterfaceAIFComponent[] jdhjhs1 = scheduleTaskQuery1("" + projectCodeString + "׻(н)"); + InterfaceAIFComponent[] jdhjhs2 = scheduleTaskQuery1(projectCodeString + "׻(н)"); + if (jdhjhs1.length>0){ + jdhjhs = jdhjhs1.clone(); + } else if (jdhjhs2.length > 0) { + jdhjhs = jdhjhs2.clone(); + }else { + System.out.println("ʱ δѯ ׻ ļƻϢ"); + } + + if (jdhjhs!=null&&jdhjhs.length>0){ + String jdhjh = jdhjhs[0].getProperty("finish_date"); + incremeFM(jdhjh); + + if (jdhjh != null && !jdhjh.isEmpty()){ + this.jdh_total_fm ++; + } + + ss[35] = jdhjh == null ? "" : jdhjh; + }else { + System.out.println("ʱ δѯ ׻ ļƻϢ"); + } + //׻-ʵʣԪ-36 + List entryNames2 = new ArrayList(); + List entryValues2 = new ArrayList(); + entryNames2.add("ID"); + entryNames2.add("汾"); + entryValues2.add(JDHZL01); + entryValues2.add(rev1); + if (sjTime1 != null){ + entryNames2.add("ʱ"); + entryValues2.add(sjTime1); + } + if (sjTime2 != null){ + entryNames2.add("ʱС"); + entryValues2.add(sjTime2); + } + + InterfaceAIFComponent[] jdhsjs = queryBuilder("Ŀĵѯ", entryNames2, entryValues2); + if (jdhsjs.length>0){ + String jdhsj = jdhsjs[0].getProperty("date_released"); + incremeFZ(jdhsj); + incremeFM(jdhsj); + + if (jdhsj != null && !jdhsj.isEmpty()){ + this.jdh_total_fz ++; + this.jdh_total_fm ++; + } + + ss[36] = jdhsj == null ? "" : jdhsj; + }else { + System.out.println("Ŀĵѯ δѯ ׻ ʵϢ"); + } + //ֵ-37 + ss[37] = caculateDifference(ss[35], ss[36]); + } +//--------------------------------------------------------------------------------------------------------------------------------- + System.out.println("ɹѯ"); + String cgdjh = ""; + String cgdsj = ""; + String earliestDate1 = null; + //ɹ-ƻԪ-38 + InterfaceAIFComponent[] cgdjhs = null; + InterfaceAIFComponent[] cgdjhs1 = scheduleTaskQuery1("" + projectCodeString + "ϵͳɹ*"); + InterfaceAIFComponent[] cgdjhs2 = scheduleTaskQuery1(projectCodeString + "ϵͳɹ*"); + if (cgdjhs1.length>0){ + cgdjhs = cgdjhs1.clone(); + } else if (cgdjhs2.length > 0) { + cgdjhs = cgdjhs2.clone(); + }else { + System.out.println("ʱ δѯ ϵͳɹ ļƻϢ"); + } + + if (cgdjhs!=null&&cgdjhs.length>0){ + for (int i = 0; i < cgdjhs.length; i++) { + String cgdjh0= cgdjhs[i].getProperty("finish_date"); + cgdjh += cgdjh0 + ";"; + incremeFM(cgdjh0); + + if (cgdjh0 != null && !cgdjh0.isEmpty()){ + this.cg_total_fm ++; + } + } +// String cgdjh = cgdjhs[0].getProperty("finish_date"); + ss[38] = cgdjh == null ? "" : cgdjh; + }else { + System.out.println("ʱ δѯ ɹ ļƻϢ"); + } + //ɹ-ʵʣԪ-39 + List entryNamesCGD2 = new ArrayList(); + List entryValuesCGD2 = new ArrayList(); + entryNamesCGD2.add("ID"); + entryNamesCGD2.add("汾"); + entryNamesCGD2.add(""); + entryValuesCGD2.add(extractAndFormatNumber(projectCodeString)+"-S*"); + entryValuesCGD2.add("A"); + entryValuesCGD2.add("Ysr8_SystemPRevision"); + if (sjTime1 != null){ + entryNamesCGD2.add("ʱ"); + entryValuesCGD2.add(sjTime1); + } + if (sjTime2 != null){ + entryNamesCGD2.add("ʱС"); + entryValuesCGD2.add(sjTime2); + } + + InterfaceAIFComponent[] cgdsjs = queryBuilder("Ŀĵѯ", entryNamesCGD2, entryValuesCGD2); + if (cgdsjs.length>0){ + for (int i = 0; i < cgdsjs.length; i++){ + String cgdsj0= cgdsjs[i].getProperty("date_released"); + cgdsj += cgdsj0 + ";"; + incremeFZ(cgdsj0); + incremeFM(cgdsj0); + + if (cgdsj0 != null && !cgdsj0.isEmpty()){ + this.cg_total_fz ++; + this.cg_total_fm ++; + // Ƚϲʱ + if (earliestDate1 == null || isTimeEarlier(cgdsj0, earliestDate1)) { + earliestDate1 = cgdsj0; + } + } + } + + ss[39] = earliestDate1 == null ? "" : earliestDate1; + }else { + System.out.println("Ŀĵѯ δѯ ɹ ʵϢ"); + } + //ֵ-40 + if (cgdjhs != null && cgdjhs.length > 0 && cgdsjs != null && cgdsjs.length > 0 ) { + System.out.println("ɹֵļƻʱ="+cgdjhs[0].getProperty("finish_date")+"ʵʱ="+earliestDate1); + ss[40] = caculateDifference(cgdjhs[0].getProperty("finish_date"), earliestDate1); + }else { + ss[40] = "-"; + } + +//--------------------------------------------------------------------------------------------------------------------------------- + System.out.println("Эѯ"); + List entryNamesJSXY = new ArrayList(); + List entryValuesJSXY = new ArrayList(); + entryNamesJSXY.add("ID"); + entryNamesJSXY.add("汾"); + entryNamesJSXY.add(""); + entryValuesJSXY.add(projectCodeString+"_JSXYJYO1"); + entryValuesJSXY.add(rev1); + entryValuesJSXY.add("Ysr8_TechAandSRevision"); + if (sjTime1 != null){ + entryNamesJSXY.add("ʱ"); + entryValuesJSXY.add(sjTime1); + } + if (sjTime2 != null){ + entryNamesJSXY.add("ʱС"); + entryValuesJSXY.add(sjTime2); + } + + InterfaceAIFComponent[] jsxys = queryBuilder("Ŀĵѯ", entryNamesJSXY, entryValuesJSXY); + if (jsxys.length>0){ + String jsxy = jsxys[0].getProperty("date_released"); + incremeFZ(jsxy); + incremeFM(jsxy); + this.fm ++; + ss[41] = jsxy == null ? "" : jsxy; + }else { + System.out.println("Ŀĵѯ δѯ Э Ϣ"); + } +//--------------------------------------------------------------------------------------------------------------------------------- + System.out.println("Ԥձѯ"); + List entryNamesYYSBG = new ArrayList(); + List entryValuesYYSBG = new ArrayList(); + entryNamesYYSBG.add("ID"); + entryNamesYYSBG.add("汾"); + entryNamesYYSBG.add(""); + entryValuesYYSBG.add(projectCodeString+"_YYSBG01"); + entryValuesYYSBG.add(rev1); + entryValuesYYSBG.add("Ysr8_ProjectDocRevision"); + if (sjTime1 != null){ + entryNamesYYSBG.add("ʱ"); + entryValuesYYSBG.add(sjTime1); + } + if (sjTime2 != null){ + entryNamesYYSBG.add("ʱС"); + entryValuesYYSBG.add(sjTime2); + } + + InterfaceAIFComponent[] yysbgs = queryBuilder("Ŀĵѯ", entryNamesYYSBG, entryValuesYYSBG); + if (yysbgs.length>0){ + String yysbg = yysbgs[0].getProperty("date_released"); + incremeFZ(yysbg); + incremeFM(yysbg); + this.fm ++; + ss[42] = yysbg == null ? "" : yysbg; + }else { + System.out.println("Ŀĵѯ δѯ Ԥձ Ϣ"); + } +//---------------------------------------------------------------------------------------------------------------------------------- + System.out.println("յѯ"); + List entryNamesZYSD = new ArrayList(); + List entryValuesZYSD = new ArrayList(); + entryNamesZYSD.add("ID"); + entryNamesZYSD.add("汾"); + entryNamesZYSD.add(""); + entryValuesZYSD.add(projectCodeString+"_YSWT"); + entryValuesZYSD.add(rev1); + entryValuesZYSD.add("Ysr8_AccepComRevision"); + if (sjTime1 != null){ + entryNamesZYSD.add("ʱ"); + entryValuesZYSD.add(sjTime1); + } + if (sjTime2 != null){ + entryNamesZYSD.add("ʱС"); + entryValuesZYSD.add(sjTime2); + } + + InterfaceAIFComponent[] zysds = queryBuilder("Ŀĵѯ", entryNamesZYSD, entryValuesZYSD); + if (zysds.length>0){ + String zysd = zysds[0].getProperty("date_released"); + incremeFZ(zysd); + incremeFM(zysd); + this.fm ++; + ss[43] = zysd == null ? "" : zysd; + }else { + System.out.println("Ŀĵѯ δѯ յ Ϣ"); + } +//---------------------------------------------------------------------------------------------------------------------------------- + System.out.println("Ŀ֪ͨѯ"); + List entryNamesXMQDTZ = new ArrayList(); + List entryValuesXMQDTZ = new ArrayList(); + entryNamesXMQDTZ.add("ID"); + entryNamesXMQDTZ.add("汾"); + entryNamesXMQDTZ.add(""); + entryValuesXMQDTZ.add(projectCodeString+"_XMQD"); + entryValuesXMQDTZ.add(rev1); + entryValuesXMQDTZ.add("Ysr8_ProjectSRevision"); + if (sjTime1 != null){ + entryNamesXMQDTZ.add("ʱ"); + entryValuesXMQDTZ.add(sjTime1); + } + if (sjTime2 != null){ + entryNamesXMQDTZ.add("ʱС"); + entryValuesXMQDTZ.add(sjTime2); + } + + InterfaceAIFComponent[] xmqdtzs = queryBuilder("Ŀĵѯ", entryNamesXMQDTZ, entryValuesXMQDTZ); + if (xmqdtzs.length>0){ + String xmqdtz = xmqdtzs[0].getProperty("date_released"); + incremeFZ(xmqdtz); + incremeFM(xmqdtz); + ss[44] = xmqdtz == null ? "" : xmqdtz; + }else { + System.out.println("Ŀĵѯ δѯ Ŀ֪ͨ Ϣ"); + } +//---------------------------------------------------------------------------------------------------------------------------------- + System.out.println("Ŀȼƻѯ"); + InterfaceAIFComponent[] xmjdjhs = null; + List entryNamesXMJDJH = new ArrayList(); + List entryValuesXMJDJH = new ArrayList(); + entryNamesXMJDJH.add(""); + entryNamesXMJDJH.add(""); + entryValuesXMJDJH.add(projectCodeString + "*"); + entryValuesXMJDJH.add("6"); + if (sjTime1 != null){ + entryNamesXMJDJH.add("ʵʿʼʱ"); + entryValuesXMJDJH.add(sjTime1); + } + if (sjTime2 != null){ + entryNamesXMJDJH.add("ʵʿʼʱС"); + entryValuesXMJDJH.add(sjTime2); + } + + InterfaceAIFComponent[] xmjdjhs1 = queryBuilder("ʱѯ", entryNamesXMJDJH, entryValuesXMJDJH); + +// List entryNamesXMJDJH1 = new ArrayList(); +// List entryValuesXMJDJH1 = new ArrayList(); +// entryNamesXMJDJH1.add(""); +// entryNamesXMJDJH1.add(""); +// entryValuesXMJDJH1.add(projectCodeString + "*"); +// entryValuesXMJDJH1.add("6"); +// InterfaceAIFComponent[] xmjdjhs2 = queryBuilder("ʱѯ", entryNamesXMJDJH1, entryValuesXMJDJH1); + +// if (xmjdjhs1.length>0){ + xmjdjhs = xmjdjhs1.clone(); +// } else if (xmjdjhs2.length > 0) { +// xmjdjhs = xmjdjhs2.clone(); +// } else { +// System.out.println("ʱѯ δѯ Ŀȼƻ Ϣ"); +// } + + + if (xmjdjhs != null && xmjdjhs.length>0){ + String xmjdjh = xmjdjhs[0].getProperty("actual_finish_date"); + incremeFZ(xmjdjh); + incremeFM(xmjdjh); + ss[45] = xmjdjh == null ? "" : xmjdjh; + }else { + System.out.println("ʱѯ δѯ Ŀȼƻ Ϣ"); + } +//---------------------------------------------------------------------------------------------------------------------------------- + System.out.println("ʱѯ"); + InterfaceAIFComponent[] vmdtjh = null; + // ʱ-ƻandʵʣԪ45and46 + List entryNamesVMDT1 = new ArrayList(); + List entryValuesVMDT1 = new ArrayList(); + entryNamesVMDT1.add(""); + entryValuesVMDT1.add("" + projectCodeString + ""); + if (sjTime1 != null){ + entryNamesVMDT1.add("ʱ"); + entryValuesVMDT1.add(sjTime1); + } + if (sjTime2 != null){ + entryNamesVMDT1.add("ʱС"); + entryValuesVMDT1.add(sjTime2); + } + + InterfaceAIFComponent[] vmdts1 = queryBuilder("ʱѯ", entryNamesVMDT1, entryValuesVMDT1); + List entryNamesVMDT2 = new ArrayList(); + List entryValuesVMDT2 = new ArrayList(); + entryNamesVMDT2.add(""); + entryValuesVMDT2.add("" + projectCodeString + ""); + if (sjTime1 != null){ + entryNamesVMDT2.add("ʱ"); + entryValuesVMDT2.add(sjTime1); + } + if (sjTime2 != null){ + entryNamesVMDT2.add("ʱС"); + entryValuesVMDT2.add(sjTime2); + } + + InterfaceAIFComponent[] vmdts2 = queryBuilder("ʱѯ", entryNamesVMDT2, entryValuesVMDT2); + + if (vmdts1.length>0){ + vmdtjh = vmdts1.clone(); + } else if (vmdts2.length > 0) { + vmdtjh = vmdts2.clone(); + } else { + System.out.println("ʱѯ δѯ ʱ Ϣ"); + } + if (vmdtjh!=null&&vmdtjh.length>0){ + String vmdtjhs = vmdtjh[0].getProperty("finish_date"); + incremeFM(vmdtjhs); + ss[46] = vmdtjhs == null ? "" : vmdtjhs;//ʱ-ƻ + +// String vmdtsjString = vmdts[0].getProperty("actual_finish_date"); +// incremeFZ(vmdtsjString); +// incremeFM(vmdtsjString); +// ss[47] = vmdtsjString == null ? "" : vmdtsjString;//ʱ-ʵ + }else { + System.out.println("ʱѯ δѯ ʱ ļƻandʵϢ"); + } + + //ԡʵ + InterfaceAIFComponent[] xnsjs = null; + InterfaceAIFComponent[] xnsj1 = scheduleTaskQuery2(projectCodeString + ""); + InterfaceAIFComponent[] xnsj2 = scheduleTaskQuery2(""+projectCodeString + ""); + if (xnsj1.length>0){ + xnsjs = xnsj1.clone(); + } else if (xnsj2.length > 0) { + xnsjs = xnsj2.clone(); + }else { + System.out.println("ʱѯ δѯ ʱ Ϣ"); + } + if (xnsjs!=null&&xnsjs.length>0){ + String vmdtsjString = xnsjs[0].getProperty("actual_finish_date"); + incremeFZ(vmdtsjString); + incremeFM(vmdtsjString); + ss[47] = vmdtsjString == null ? "" : vmdtsjString;//ʱ-ʵ + } + +//---------------------------------------------------------------------------------------------------------------------------------- + System.out.println("άʱѯ"); + // άʱ-ƻandʵʣԪ47and48 + InterfaceAIFComponent[] ths = null; + InterfaceAIFComponent[] ths1 = scheduleTaskQuery3("" + projectCodeString + "ά"); + InterfaceAIFComponent[] ths2 = scheduleTaskQuery3(projectCodeString + "ά"); + if (ths1.length>0){ + ths = ths1.clone(); + } else if (ths2.length > 0) { + ths = ths2.clone(); + }else { + System.out.println("ʱѯ δѯ άʱ Ϣ"); + } + + if (ths!=null&&ths.length>0){ + String thjh = ths[0].getProperty("finish_date"); + incremeFM(thjh); + ss[48] = thjh == null ? "" : thjh;//άʱ-ƻ + +// String thsj = ths[0].getProperty("actual_finish_date"); +// incremeFZ(thsj); +// incremeFM(thsj); +// ss[49] = thsj == null ? "" : thsj; + }else { + System.out.println("ʱѯ δѯ άʱ ļƻandʵϢ"); + } + InterfaceAIFComponent[] thsj = null; + InterfaceAIFComponent[] thsj1 = scheduleTaskQuery2(projectCodeString + "ά"); + InterfaceAIFComponent[] thsj2 = scheduleTaskQuery2(""+projectCodeString + "ά"); + if (thsj1.length>0){ + thsj = thsj1.clone(); + } else if (thsj2.length > 0) { + thsj = thsj2.clone(); + }else { + System.out.println("ʱѯ δѯ άʱ Ϣ"); + } + if (thsj!=null&&thsj.length>0){ + String thsjs = thsj[0].getProperty("actual_finish_date"); + incremeFZ(thsjs); + incremeFM(thsjs); + ss[49] = thsjs == null ? "" : thsjs;//άʱ-ʵ + } + +//---------------------------------------------------------------------------------------------------------------------------------- + System.out.println("Ԥ±ѯ"); + InterfaceAIFComponent[] yzsComponents = null; + InterfaceAIFComponent[] yzs1 = scheduleTaskQuery3("" + projectCodeString + "Ԥ±"); + InterfaceAIFComponent[] yzs2 = scheduleTaskQuery3(projectCodeString + "Ԥ±"); + if (yzs1.length>0){ + yzsComponents = yzs1.clone(); + } else if (yzs2.length > 0) { + yzsComponents = yzs2.clone(); + }else { + System.out.println("ʱѯ δѯ Ԥ± Ϣ"); + } + + if (yzsComponents!=null&&yzsComponents.length>0){ + String yzjh = yzsComponents[0].getProperty("finish_date"); + incremeFM(yzjh); + ss[50] = yzjh == null ? "" : yzjh;//Ԥ±-ƻ + + }else { + System.out.println("ʱѯ δѯ Ԥ± ļƻandʵϢ"); + } + InterfaceAIFComponent[] yzxsjComponents = null; + InterfaceAIFComponent[] yzxsj1 = scheduleTaskQuery2(projectCodeString + "Ԥ±"); + InterfaceAIFComponent[] yzxsj2 = scheduleTaskQuery2(""+projectCodeString + "Ԥ±"); + if (yzxsj1.length>0){ + yzxsjComponents = yzxsj1.clone(); + } else if (yzxsj2.length > 0) { + yzxsjComponents = yzxsj2.clone(); + }else { + System.out.println("ʱѯ δѯ Ԥ± Ϣ"); + } + if (yzxsjComponents!=null&&yzxsjComponents.length>0){ + String yzsj = yzxsjComponents[0].getProperty("actual_finish_date"); + incremeFZ(yzsj); + incremeFM(yzsj); + ss[51] = yzsj == null ? "" : yzsj; + } + +//---------------------------------------------------------------------------------------------------------------------------------- + System.out.println("ÿĿϵͳɰٷֱȲѯ="+this.fz+"ĸ="+this.fm); + double percentage = (double) this.fz / this.fm * 100; + System.out.println("ÿĿϵͳɰٷֱȲѯ="+percentage); + String fb = String.format("%.2f", percentage); + ss[52] = fb + "%"; + + //ÿĿϵͳɰٷֱȵķӷĸЧֵۼӱ棬ڼ㡰ѯϵɰٷֱȡ + this.tcpodi_fz += this.fz; + this.tcpodi_fm += this.fm; + + + return ss; + } + + /** + * ȽʱַжϵһʱǷȵڶʱ + * @param time1 һʱַ + * @param time2 ڶʱַ + * @return time1time2磬true򷵻false + */ + private boolean isTimeEarlier(String time1, String time2) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-M-d HH:mm"); + LocalDateTime dateTime1 = LocalDateTime.parse(time1, formatter); + LocalDateTime dateTime2 = LocalDateTime.parse(time2, formatter); + return dateTime1.isBefore(dateTime2); + } + + /** + * תʱʽ + * @param input yyyy-MM-dd HH:mm + * @return yyyy-M-dd HH:mm + */ + public String transData(String input) { + String format = dateFormat.format(input); + System.out.println("ʽDQ="+format); + // ʽ + DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); + DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy-M-dd HH:mm"); + // ʽ + LocalDateTime dateTime = LocalDateTime.parse(input, inputFormatter); + String output = dateTime.format(outputFormatter); + return output; + } + + /** + * Excel.xlsxļ + * @param finalDataList + * @param outputPath + * @throws TCException + * @throws Exception + * + */ + public boolean exportExcel(String outputPath, List finalDataList) throws TCException { + File fmsFile = null; + //1.ȡģļ + TCComponent stringToComponent = session.stringToComponent("wHkdr3SyY$uSgD"); + + TCComponentDataset dataset = (TCComponentDataset)stringToComponent; + com.teamcenter.rac.kernel.TCComponentTcFile[] tcFile = dataset.getTcFiles(); + if(tcFile != null && tcFile.length == 0) + { + System.out.println("δҵļ"); + return false; + } + else + { + fmsFile = tcFile[0].getFmsFile(); + } + //2. + if (fmsFile != null){ + FileInputStream fis = null; + Workbook workbook = null; + FileOutputStream fos = null; + try { + fis = new FileInputStream(fmsFile); + workbook = new XSSFWorkbook(fis); + fos = new FileOutputStream(outputPath); + + // ȡһ + Sheet sheet = workbook.getSheetAt(0); + //ȡ + Row titleRow = sheet.getRow(0); +// String stringCellValue = titleRow.getCell(???).getStringCellValue(); + + // ӵڼпʼдݣӵ 2 пʼ + int startRowIndex = 1; + + // Listд Excel + for (String[] rowData : finalDataList) { + Row row = sheet.getRow(startRowIndex); + if (row == null) { + row = sheet.createRow(startRowIndex); // вڣ򴴽 + } + + // ÿһУд + for (int colIndex = 0; colIndex < rowData.length; colIndex++) { + Cell cell = row.getCell(colIndex); + if (cell == null) { + cell = row.createCell(colIndex); // Ԫ񲻴ڣ򴴽 + } + cell.setCellValue(rowData[colIndex]); // д + } + + startRowIndex++; // ƶһ + } + + // 湤ļ + workbook.write(fos); + + System.out.println("дɹ"); + + } catch (IOException e) { + e.printStackTrace(); + } finally { +// try { +// if (fis != null) fis.close(); +// if (workbook != null) workbook.close(); // ֶر Workbook +// if (fos != null) fos.close(); +// } catch (IOException e) { +// e.printStackTrace(); +// } + } + } + return true; + } + + + +// public boolean exportExcel(String outputPath, List finalDataList) { +// System.out.println("exportExcel~outputPath="+outputPath+"="+(finalDataList.size()-1)); +// // УļǷѾڣɾ +// File file = new File(outputPath); +// if (file.exists()) { +// if (file.delete()) { +// System.out.println("ļѳɹɾ"); +// } else { +// System.out.println("޷ɾļ"); +// return false; +// } +// } +// // һµĹ͹ +// Workbook workbook = new HSSFWorkbook(); +// try { +// Sheet sheet = workbook.createSheet("SheetName"); +// // д +// Row headerRow = sheet.createRow(0); +// String[] header = columnNames; +// for (int i = 0; i < columnNum; i++) { +// Cell cell = headerRow.createCell(i); +// cell.setCellValue(header[i]); +// } +// // д +//// int rowNum = 1; +// for (int i = 0; i < finalDataList.size(); i++) { +// Row row = sheet.createRow(i+1);//ΪѾΪˣԴʱҪ+1 +// String[] rowdata = finalDataList.get(i);//ȡ鵽ÿ +// for (int i1 = 0; i1 < columnNum; i1++) { +// Cell cell = row.createCell(i1); +// cell.setCellValue(rowdata[i1]); +// } +// } +// // Զп +// for (int i = 0; i < finalDataList.get(0).length; i++) { +// sheet.autoSizeColumn(i); +// } +// // дļ +// try (FileOutputStream fileOut = new FileOutputStream(outputPath)) { +// workbook.write(fileOut); +// } catch (IOException e) { +// e.printStackTrace(); +// MessageBox.post("ļʧܣ","",MessageBox.INFORMATION); +// return false; +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// return false; +// } finally { +// if (workbook != null) { +// } +// } +// +// MessageBox.post("Excel ļɹ","ʾ",MessageBox.INFORMATION); +// System.out.println("Excel ļѳɹ"); +// return true; +// } + + + /** + * ɶȰٷֱȣȾĶӦλϡ + */ + public String caculateTcpodi(int fz1,int fm1){ + System.out.println("caculateTcpodi~η="+fz1+"ηĸ="+fm1); + double percentage = (double) fz1 / fm1 * 100; + String fb = String.format("%.2f", percentage); + String s = fb + "%"; + return s; + } + + /** + * 㵥ٷֱ + * ͷֵΪֵ/'ɰٷֱ=%' + */ + public void resetHeader() { + //TODO 1.㵥ٷֱ + String bzt_dxbfb = caculateTcpodi(this.bzt_total_fz,this.bzt_total_fm); + String zbbjt_dxbfb = caculateTcpodi(this.bjt_total_fz,this.bjt_total_fm); + String zml_dxbfb = caculateTcpodi(this.zml_total_fz,this.zml_total_fm); + String jqr_dxbfb = caculateTcpodi(this.jqr_total_fz,this.jqr_total_fm); + String qdh_dxbfb = caculateTcpodi(this.qdh_total_fz,this.qdh_total_fm); + String sjsg_dxbfb = caculateTcpodi(this.sjsg_total_fz,this.sjsg_total_fm); + String sbys_dxbfb = caculateTcpodi(this.sbys_total_fz,this.sbys_total_fm); + String wwqd_dxbfb = caculateTcpodi(this.wwsp_total_fz,this.wwsp_total_fm); + String dqcx_dxbfb = caculateTcpodi(this.elec_total_fz,this.elec_total_fm); + String jdh_dxbfb = caculateTcpodi(this.jdh_total_fz,this.jdh_total_fm); + String cgd_dxbfb = caculateTcpodi(this.cg_total_fz,this.cg_total_fm); + + //TODO 2.ƴӱͷ=ֵ + System.out.println("resetHeader~"); + String[] newColumnNames = columnNames.clone(); + newColumnNames[10] = "ֵ/ɰٷֱ="+bzt_dxbfb;//ͼ + newColumnNames[13] = "ֵ/ɰٷֱ="+zbbjt_dxbfb;//հ沼ͼ + newColumnNames[16] = "ֵ/ɰٷֱ="+zml_dxbfb;//Ŀ¼ + newColumnNames[19] = "ֵ/ɰٷֱ="+jqr_dxbfb;//õ + newColumnNames[22] = "ֵ/ɰٷֱ="+qdh_dxbfb;//Ŀ + newColumnNames[25] = "ֵ/ɰٷֱ="+sjsg_dxbfb;//ʩʽ + newColumnNames[28] = "ֵ/ɰٷֱ="+sbys_dxbfb;//豸ɫ֪ͨ + newColumnNames[31] = "ֵ/ɰٷֱ="+wwqd_dxbfb;//ί + newColumnNames[34] = "ֵ/ɰٷֱ="+dqcx_dxbfb;// + newColumnNames[37] = "ֵ/ɰٷֱ="+jdh_dxbfb;//׻ + newColumnNames[40] = "ֵ/ɰٷֱ="+cgd_dxbfb;//ɹ + this.model.setColumnIdentifiers(newColumnNames);//±ͷӡɰٷֱȡ + setColumnWidth(); + } + + /** + * ʱѯ(ơʱjhʱСjh) + * @param projectCodeString Ŀֵ + * @return + */ + public InterfaceAIFComponent[] scheduleTaskQuery1(String inputValue){ + System.out.println("ʱѯscheduleTaskQuery1~="+inputValue); + List entryNames = new ArrayList(); + List entryValues = new ArrayList(); + entryNames.add(""); + entryValues.add(inputValue); + if (jhTime1 != null){ + entryNames.add("ʱ"); + entryValues.add(this.jhTime1); + } + if (jhTime2 != null){ + entryNames.add("ʱС"); + entryValues.add(this.jhTime2); + } + + return queryBuilder("ʱѯ", entryNames, entryValues); + } + + /** + * ʱѯ(ơʵʱsjʵʱСsj) + * @param projectCodeString Ŀֵ + * @return + */ + public InterfaceAIFComponent[] scheduleTaskQuery2(String inputValue){ + List entryNames = new ArrayList(); + List entryValues = new ArrayList(); + entryNames.add(""); + entryValues.add(inputValue); + if (sjTime1 != null){ + entryNames.add("ʵʱ"); + entryValues.add(this.sjTime1); + } + if (sjTime2 != null){ + entryNames.add("ʵʱС"); + entryValues.add(this.sjTime2); + } + + return queryBuilder("ʱѯ", entryNames, entryValues); + } + + /** + * ʱѯ(ơʱsjʱСsj) + * @param projectCodeString Ŀֵ + * @return + */ + public InterfaceAIFComponent[] scheduleTaskQuery3(String inputValue){ + List entryNames = new ArrayList(); + List entryValues = new ArrayList(); + entryNames.add(""); + entryValues.add(inputValue); + if (sjTime1 != null){ + entryNames.add("ʱ"); + entryValues.add(this.sjTime1); + } + if (sjTime2 != null){ + entryNames.add("ʱС"); + entryValues.add(this.sjTime2); + } + + return queryBuilder("ʱѯ", entryNames, entryValues); + } + + /** + * ȡַе + * @param input + * @return + */ + public static String extractAndFormatNumber(String input) { + // ʹʽƥеַ + Pattern pattern = Pattern.compile("\\d+"); + Matcher matcher = pattern.matcher(input); + + StringBuilder numberBuilder = new StringBuilder(); + while (matcher.find()) { + numberBuilder.append(matcher.group()); + } + + // ȡƥ䵽ַ + String numberString = numberBuilder.toString(); + + return numberString; + } + +} diff --git a/src/cn/com/ebewin/ysr/dialog/systemdatadistribution/SystemDataDistributionHandler.java b/src/cn/com/ebewin/ysr/dialog/systemdatadistribution/SystemDataDistributionHandler.java new file mode 100644 index 0000000..1696b94 --- /dev/null +++ b/src/cn/com/ebewin/ysr/dialog/systemdatadistribution/SystemDataDistributionHandler.java @@ -0,0 +1,30 @@ +package cn.com.ebewin.ysr.dialog.systemdatadistribution; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AbstractAIFSession; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class SystemDataDistributionHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Զɵķ + AbstractAIFApplication application = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession)application.getSession(); + try { + SystemDataDistributionDialog dialog = new SystemDataDistributionDialog(session); + } catch (Exception e) { + // TODO Զɵ catch + e.printStackTrace(); + } +// new Thread(dialog).start(); + + return null; + } + +} diff --git a/src/cn/com/ebewin/ysr/form/YSR8_AccepComRevisionMasterForm.java b/src/cn/com/ebewin/ysr/form/YSR8_AccepComRevisionMasterForm.java new file mode 100644 index 0000000..515f22c --- /dev/null +++ b/src/cn/com/ebewin/ysr/form/YSR8_AccepComRevisionMasterForm.java @@ -0,0 +1,359 @@ +package cn.com.ebewin.ysr.form; + +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Vector; + +import javax.swing.JComboBox; + +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCFormProperty; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.iTextField; + +import cn.com.ebewin.ysr.util.CommonUtil; +import cn.com.ebewin.ysr.util.FormUtil; +import cn.com.ebewin.ysr.util.TCUtil; + +public class YSR8_AccepComRevisionMasterForm extends AbstractRendering { + private static final long serialVersionUID = 1L; + private static Date refreshDate = null; + + String projectCode = ""; + FormUtil fu = new FormUtil(this); + + public YSR8_AccepComRevisionMasterForm(TCComponentForm arg0) throws Exception { + super(arg0); + + Date currDate = new Date(); + if (refreshDate == null) { + arg0.refresh(); + refreshDate = currDate; + } else { + long diff = currDate.getTime() - refreshDate.getTime(); + long minutes = diff / 1000 / 60; + if ( minutes >= 1 ) { + arg0.refresh(); + refreshDate = currDate; + } + } + + fu.readRenderingXML("YSR8_AccepComRevisionMasterForm"); + fu.initializeUI(arg0); + addActionListener(); + loadRendering(); + getDefVal(); + } + + @Override + public void loadRendering() throws TCException { + fu.loadRendering(); + } + + public void setRenderingReadOnly() + { + setModifiableComponents(this, false); + + if(getController() != null) + getController().setFormReadOnly(); + } + + public void setRenderingReadWrite() + { + setModifiableComponents(this, true); + ChangeComboBoxState(); + + } + + private void setModifiableComponents(java.awt.Component currcomponent, boolean flag) + { + fu.setModifiableComponents(currcomponent, flag); + } + + private void ChangeComboBoxState() + { + ChangeComboBoxState_ysr8_ProductionState(); + + ChangeComboBoxState_ysr8_ProjectState(); + + ChangeComboBoxState_ysr8_DocumentState(); + + ChangeComboBoxState_ysr8_SpareParts(); + + ChangeComboBoxState_ysr8_CustomerState(); + + ChangeComboBoxState_ysr8_ConfirmContent(); + } + + @Override + public void saveRendering() { + if (!checkCanSave()) { + return; + } + + try { + fu.saveRendering(); + } catch (TCException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } catch (ParseException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } + } + + public boolean isRenderingModified() { + return fu.isRenderingModified(); + } + + @SuppressWarnings("unchecked") + private void addActionListener() { + { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_ProductionState"); + cbx.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent itemevent) { + if (itemevent.getStateChange() == ItemEvent.SELECTED) { + ChangeComboBoxState_ysr8_ProductionState(); + } + } + }); + } + { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_ProjectState"); + cbx.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent itemevent) { + if (itemevent.getStateChange() == ItemEvent.SELECTED) { + ChangeComboBoxState_ysr8_ProjectState(); + } + } + }); + } + + { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_DocumentState"); + cbx.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent itemevent) { + if (itemevent.getStateChange() == ItemEvent.SELECTED) { + ChangeComboBoxState_ysr8_DocumentState(); + } + } + }); + } + + { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_SpareParts"); + cbx.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent itemevent) { + if (itemevent.getStateChange() == ItemEvent.SELECTED) { + ChangeComboBoxState_ysr8_SpareParts(); + } + } + }); + } + + { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_CustomerState"); + cbx.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent itemevent) { + if (itemevent.getStateChange() == ItemEvent.SELECTED) { + ChangeComboBoxState_ysr8_CustomerState(); + } + } + }); + } + + { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_ConfirmContent"); + cbx.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent itemevent) { + if (itemevent.getStateChange() == ItemEvent.SELECTED) { + ChangeComboBoxState_ysr8_ConfirmContent(); + } + } + }); + } + } + + public void getDefVal() { + + iTextField textfield = (iTextField)fu.allComponentMap.get("ysr8_ProjectCode"); + this.projectCode = textfield.getText().toString(); +System.out.println(CommonUtil.debug(new Throwable().getStackTrace()[0]) + "projectCode====" + projectCode); + if (!projectCode.equals("")) { + return; + } + + try { + AIFComponentContext[] context = fu.tcForm.whereReferencedByTypeRelation(new String[] {"YSR8_AccepComRevision"}, new String[] {"IMAN_master_form"}); + if (context != null && context.length > 0) { + TCComponentItemRevision acrRevision = (TCComponentItemRevision)context[0].getComponent(); + TCComponentItem acrItem = acrRevision.getItem(); + String itemId = acrItem.getProperty("item_id"); +System.out.println(CommonUtil.debug(new Throwable().getStackTrace()[0]) + "itemId====" + itemId); + Vector itemIdPart = CommonUtil.split2Vector(itemId, "_"); + projectCode = itemIdPart.get(0); + for (int i = 1; i < itemIdPart.size() - 1; i++) { + projectCode += "_" + itemIdPart.get(i); + } + textfield = (iTextField)fu.allComponentMap.get("ysr8_ProjectCode"); + textfield.setText(projectCode); + } + + if (projectCode.equals("")) { + return; + } + + List propList = new ArrayList(); + propList.add("ysr8_CustomerName"); + propList.add("ysr8_ProjectManager"); + propList.add("ysr8_Planner"); + propList.add("ysr8_ProjectName"); + HashMap propValueMap = new HashMap(); + + TCComponentItem xmqdItem = TCUtil.findItemByID(fu.session, projectCode + "_XMQD"); + if (xmqdItem == null) { + return; + } + TCComponentItemRevision xmqdRevision = xmqdItem.getLatestItemRevision(); + TCComponentForm xmqdForm = TCUtil.getItemRevisionMasterForm(xmqdRevision); + + for (String prop : propList) { + String propValue = ""; + TCFormProperty property1 = (TCFormProperty)xmqdForm.getFormTCProperty(prop); + switch (property1.getPropertyType()) { + case TCProperty.PROP_string: + case TCProperty.PROP_long_string: + propValue = xmqdForm.getStringProperty(prop); + break; + case TCProperty.PROP_short: + case TCProperty.PROP_int: + propValue = Integer.toString(xmqdForm.getIntProperty(prop)); + break; + case TCProperty.PROP_double: + case TCProperty.PROP_float: + propValue = fu.getDoubleString(xmqdForm.getDoubleProperty(prop)); + break; + case TCProperty.PROP_date: + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date date = xmqdForm.getDateProperty(prop); + if (date != null) { + propValue = sdf.format(date); + } + break; + default: + propValue = xmqdForm.getStringProperty(prop); + break; + } + propValueMap.put(prop, propValue); + } + + iTextField textfieldForm; + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_CustomerName"); + textfieldForm.setText(propValueMap.get("ysr8_CustomerName")); + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_ProjectManager"); + textfieldForm.setText(propValueMap.get("ysr8_ProjectManager")); + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_Planner"); + textfieldForm.setText(propValueMap.get("ysr8_Planner")); + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_ProjectName"); + textfieldForm.setText(propValueMap.get("ysr8_ProjectName")); + } catch (TCException e) { + e.printStackTrace(); + } + } + + @SuppressWarnings("unchecked") + private void ChangeComboBoxState_ysr8_ProductionState() { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_ProductionState"); + if (cbx.getSelectedItem().toString().equals("") || + cbx.getSelectedItem().toString().equals("С")) { + fu.allComponentMap.get("ysr8_ProductionDate").setEnabled(false); + + } else { + fu.allComponentMap.get("ysr8_ProductionDate").setEnabled(true); + } + } + + @SuppressWarnings("unchecked") + private void ChangeComboBoxState_ysr8_ProjectState() { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_ProjectState"); + if (cbx.getSelectedItem().toString().equals("޼")) { + fu.allComponentMap.get("ysr8_PlanFinishDate").setEnabled(false); + + } else { + fu.allComponentMap.get("ysr8_PlanFinishDate").setEnabled(true); + } + } + + @SuppressWarnings("unchecked") + private void ChangeComboBoxState_ysr8_DocumentState() { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_DocumentState"); + if (cbx.getSelectedItem().toString().equals("ѷ")|| + cbx.getSelectedItem().toString().equals("")) { + fu.allComponentMap.get("ysr8_PlanSendtDate1").setEnabled(false); + + } else { + fu.allComponentMap.get("ysr8_PlanSendtDate1").setEnabled(true); + } + } + + @SuppressWarnings("unchecked") + private void ChangeComboBoxState_ysr8_SpareParts() { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_SpareParts"); + if (cbx.getSelectedItem().toString().equals("ѷ")|| + cbx.getSelectedItem().toString().equals("ޱ")) { + fu.allComponentMap.get("ysr8_PlanSendtDate2").setEnabled(false); + + } else { + fu.allComponentMap.get("ysr8_PlanSendtDate2").setEnabled(true); + } + } + + @SuppressWarnings("unchecked") + private void ChangeComboBoxState_ysr8_CustomerState() { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_CustomerState"); + if (cbx.getSelectedItem().toString().equals("ͬ")|| + cbx.getSelectedItem().toString().equals("ͬ")) { + fu.allComponentMap.get("ysr8_Reason1").setEnabled(false); + + } else { + fu.allComponentMap.get("ysr8_Reason1").setEnabled(true); + } + } + + @SuppressWarnings("unchecked") + private void ChangeComboBoxState_ysr8_ConfirmContent() { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_ConfirmContent"); + if (cbx.getSelectedItem().toString().equals("Ƿ")|| + cbx.getSelectedItem().toString().equals("Ƿм")) { + fu.allComponentMap.get("ysr8_Others").setEnabled(false); + + } else { + fu.allComponentMap.get("ysr8_Others").setEnabled(true); + } + } + + + public boolean checkCanSave() { + return true; + } +} diff --git a/src/cn/com/ebewin/ysr/form/YSR8_DGPlanningRevisionMasterForm.java b/src/cn/com/ebewin/ysr/form/YSR8_DGPlanningRevisionMasterForm.java new file mode 100644 index 0000000..fc00cd5 --- /dev/null +++ b/src/cn/com/ebewin/ysr/form/YSR8_DGPlanningRevisionMasterForm.java @@ -0,0 +1,244 @@ +package cn.com.ebewin.ysr.form; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Vector; + +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentSchedule; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCFormProperty; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.iTextField; + +import cn.com.ebewin.ysr.util.CommonUtil; +import cn.com.ebewin.ysr.util.FormUtil; +import cn.com.ebewin.ysr.util.TCUtil; + +public class YSR8_DGPlanningRevisionMasterForm extends AbstractRendering { + private static final long serialVersionUID = 1L; + private static Date refreshDate = null; + + FormUtil fu = new FormUtil(this); + + public YSR8_DGPlanningRevisionMasterForm(TCComponentForm arg0) throws Exception { + super(arg0); + + Date currDate = new Date(); + if (refreshDate == null) { + arg0.refresh(); + refreshDate = currDate; + } else { + long diff = currDate.getTime() - refreshDate.getTime(); + long minutes = diff / 1000 / 60; + if ( minutes >= 1 ) { + arg0.refresh(); + refreshDate = currDate; + } + } + + fu.readRenderingXML("YSR8_DGPlanningRevisionMasterForm"); + fu.initializeUI(arg0); + addActionListener(); + getDefVal(); + loadRendering(); + } + + @Override + public void loadRendering() throws TCException { + fu.loadRendering(); + } + + /** + * (non-Javadoc) + * @see com.teamcenter.rac.form.AbstractTCForm#saveForm() + */ + @Override + public void saveRendering() { + if (!checkCanSave()) { + return; + } + countysr8_TotalHours(); + try { + fu.saveRendering(); + } catch (TCException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } catch (ParseException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } + } + + public boolean isRenderingModified() { + return fu.isRenderingModified(); + } + + private void addActionListener() { + } + + private void getDefVal() { + iTextField textfield = (iTextField)fu.allComponentMap.get("ysr8_ProjectCode"); + String projectCode = textfield.getText().toString(); + if (!projectCode.equals("")) { + return; + } + + try { + AIFComponentContext[] context = fu.tcForm.whereReferencedByTypeRelation(new String[] {"YSR8_DGPlanningRevision"}, new String[] {"IMAN_master_form"}); + if (context != null && context.length > 0) { + TCComponentItemRevision itemRevision = (TCComponentItemRevision)context[0].getComponent(); + String itemId = itemRevision.getProperty("item_id"); + Vector itemIdPart = CommonUtil.split2Vector(itemId, "-"); + if (itemIdPart.size() > 1) { + for (int i = 0; i < itemIdPart.size() - 1; i++) { + projectCode += itemIdPart.get(i); + if (i + 1 == itemIdPart.size() - 1) { + } else { + projectCode += "-"; + } + } + } + } + if (projectCode.equals("")) { + return; + } + + //HashMap valMap = new HashMap(); + //TCComponentForm sourceForm = null; + TCComponentSchedule schedule = TCUtil.findScheduleByProjectID(fu.session, projectCode);//lidy20180907ΪĿʱ + if (schedule == null) { + return; + } + TCComponentForm projectForm = (TCComponentForm)schedule.getRelatedComponent("IMAN_reference"); + if (projectForm == null) { + return; + } + + List propList = new ArrayList(); + propList.add("ysr8_ProjectName"); + propList.add("ysr8_ProjectManager"); + propList.add("ysr8_Planner"); + propList.add("ysr8_DesignDirector"); + propList.add("ysr8_ElectricDirector"); + propList.add("ysr8_EngineerDebug"); + propList.add("ysr8_ElecDebug"); + propList.add("ysr8_Machiner"); + HashMap propValueMap = new HashMap(); + propValueMap.put("ysr8_ProjectCode", projectCode); + for (String prop : propList) { + String propValue = ""; + TCFormProperty property1 = (TCFormProperty)projectForm.getFormTCProperty(prop); + switch (property1.getPropertyType()) { + case TCProperty.PROP_string: + case TCProperty.PROP_long_string: + propValue = projectForm.getStringProperty(prop); + break; + case TCProperty.PROP_short: + case TCProperty.PROP_int: + propValue = Integer.toString(projectForm.getIntProperty(prop)); + break; + case TCProperty.PROP_double: + case TCProperty.PROP_float: + propValue = fu.getDoubleString(projectForm.getDoubleProperty(prop)); + break; + case TCProperty.PROP_date: + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date date = projectForm.getDateProperty(prop); + if (date != null) { + propValue = sdf.format(date); + } + break; + default: + propValue = projectForm.getStringProperty(prop); + break; + } + propValueMap.put(prop, propValue); + } + + iTextField textfieldForm; + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_ProjectCode"); + textfieldForm.setText(propValueMap.get("ysr8_ProjectCode")); + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_ProjectName"); + textfieldForm.setText(propValueMap.get("ysr8_ProjectName")); + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_ProjectManager"); + textfieldForm.setText(propValueMap.get("ysr8_ProjectManager")); + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_Planner"); + textfieldForm.setText(propValueMap.get("ysr8_Planner")); + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_DesignDirector"); + textfieldForm.setText(propValueMap.get("ysr8_DesignDirector")); + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_ElectricDirector"); + textfieldForm.setText(propValueMap.get("ysr8_ElectricDirector")); + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_EngineerDebug"); + textfieldForm.setText(propValueMap.get("ysr8_EngineerDebug")); + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_ElecDebug"); + textfieldForm.setText(propValueMap.get("ysr8_ElecDebug")); + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_Machiner"); + textfieldForm.setText(propValueMap.get("ysr8_Machiner")); + } catch (TCException ex) { + ex.printStackTrace(); + } + } + + public boolean checkCanSave() { + return true; + } + + + private void countysr8_TotalHours() { + double ysr8_TotalHoursVal = 0.0; + iTextField textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_PhaseIn1"); + String val = textfieldForm.getText(); + ysr8_TotalHoursVal += fu.getDoubleFromString(val); + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_PhaseIn2"); + val = textfieldForm.getText(); + ysr8_TotalHoursVal += fu.getDoubleFromString(val); + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_PhaseIn3"); + val = textfieldForm.getText(); + ysr8_TotalHoursVal += fu.getDoubleFromString(val); + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_PhaseIn4"); + val = textfieldForm.getText(); + ysr8_TotalHoursVal += fu.getDoubleFromString(val); + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_PhaseIn5"); + val = textfieldForm.getText(); + ysr8_TotalHoursVal += fu.getDoubleFromString(val); + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_PhaseIn6"); + val = textfieldForm.getText(); + ysr8_TotalHoursVal += fu.getDoubleFromString(val); + + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_PhaseOut1"); + val = textfieldForm.getText(); + ysr8_TotalHoursVal += fu.getDoubleFromString(val); + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_PhaseOut2"); + val = textfieldForm.getText(); + ysr8_TotalHoursVal += fu.getDoubleFromString(val); + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_PhaseOut3"); + val = textfieldForm.getText(); + ysr8_TotalHoursVal += fu.getDoubleFromString(val); + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_PhaseOut4"); + val = textfieldForm.getText(); + ysr8_TotalHoursVal += fu.getDoubleFromString(val); + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_PhaseOut5"); + val = textfieldForm.getText(); + ysr8_TotalHoursVal += fu.getDoubleFromString(val); + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_PhaseOut6"); + val = textfieldForm.getText(); + ysr8_TotalHoursVal += fu.getDoubleFromString(val); + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_PhaseOut7"); + val = textfieldForm.getText(); + ysr8_TotalHoursVal += fu.getDoubleFromString(val); + + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_TotalHours"); + textfieldForm.setText(fu.getDoubleString(ysr8_TotalHoursVal)); + } +} diff --git a/src/cn/com/ebewin/ysr/form/YSR8_DeliveryRevisionMasterForm.java b/src/cn/com/ebewin/ysr/form/YSR8_DeliveryRevisionMasterForm.java new file mode 100644 index 0000000..c02a193 --- /dev/null +++ b/src/cn/com/ebewin/ysr/form/YSR8_DeliveryRevisionMasterForm.java @@ -0,0 +1,233 @@ +package cn.com.ebewin.ysr.form; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Vector; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.iTextField; + +import cn.com.ebewin.ysr.util.CommonUtil; +import cn.com.ebewin.ysr.util.FormUtil; +import cn.com.ebewin.ysr.util.TCUtil; + +public class YSR8_DeliveryRevisionMasterForm extends AbstractRendering { + private static final long serialVersionUID = 1L; + private static Date refreshDate = null; + + String projectCode = ""; + FormUtil fu = new FormUtil(this); + + public YSR8_DeliveryRevisionMasterForm(TCComponentForm arg0) throws Exception { + super(arg0); + + Date currDate = new Date(); + if (refreshDate == null) { + arg0.refresh(); + refreshDate = currDate; + } else { + long diff = currDate.getTime() - refreshDate.getTime(); + long minutes = diff / 1000 / 60; + if ( minutes >= 1 ) { + arg0.refresh(); + refreshDate = currDate; + } + } + + fu.readRenderingXML("YSR8_DeliveryRevisionMasterForm"); + fu.initializeUI(arg0); + addActionListener(); + loadRendering(); + getDefVal(); + } + + @Override + public void loadRendering() throws TCException { + fu.loadRendering(); + } + + public void setRenderingReadOnly() + { + setModifiableComponents(this, false); + + if(getController() != null) + getController().setFormReadOnly(); + } + + public void setRenderingReadWrite() + { + setModifiableComponents(this, true); + } + + private void setModifiableComponents(java.awt.Component currcomponent, boolean flag) + { + fu.setModifiableComponents(currcomponent, flag); + } + + @Override + public void saveRendering() { + if (!checkCanSave()) { + return; + } + + try { + fu.saveRendering(); + } catch (TCException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } catch (ParseException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } + } + + public boolean isRenderingModified() { + return fu.isRenderingModified(); + } + + private void addActionListener() { + //lidy20180824ͬ԰ť + JButton btn = (JButton)fu.allComponentMap.get("b.11.14"); + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + dhtzMessage(); + } + }); + } + + public void getDefVal() { + iTextField textfield = (iTextField)fu.allComponentMap.get("ysr8_ProjectCode"); + //Ŀ + textfield.setBorder(BorderFactory.createEmptyBorder()); + textfield.setColumns(textfield.getText().length()); + //ť + + this.projectCode = textfield.getText().toString(); + if (!projectCode.equals("")) { + return; + } + + projectCode = ""; + try { + AIFComponentContext[] context = fu.tcForm.whereReferencedByTypeRelation(new String[] {"YSR8_DeliveryRevision"}, new String[] {"IMAN_master_form"}); + if (context != null && context.length > 0) { + TCComponentItemRevision drRevision = (TCComponentItemRevision)context[0].getComponent(); + TCComponentItem drItem = drRevision.getItem(); + String itemId = drItem.getProperty("item_id"); + Vector itemIdPart = CommonUtil.split2Vector(itemId, "_"); + projectCode = itemIdPart.get(0); + for (int i = 1; i < itemIdPart.size() - 1; i++) { + projectCode += "_" + itemIdPart.get(i); + } + textfield = (iTextField)fu.allComponentMap.get("ysr8_ProjectCode"); + textfield.setText(projectCode); + //Ŀ + textfield.setColumns(projectCode.length()); + } + + if (projectCode.equals("")) { + return; + } + textfield = (iTextField)fu.allComponentMap.get("ysr8_ProjectName"); + String projectName = textfield.getText().toString(); + if (!projectName.equals("")) { + return; + } + + { + TCComponentItem xmqdItem = TCUtil.findItemByID(fu.session, projectCode + "_XMQD"); + if (xmqdItem != null) { + TCComponentItemRevision xmqdRevision = xmqdItem.getLatestItemRevision(); + TCComponentForm xmqdForm = TCUtil.getItemRevisionMasterForm(xmqdRevision); + + String ysr8_ProjectName = xmqdForm.getProperty("ysr8_ProjectName"); + textfield = (iTextField)fu.allComponentMap.get("ysr8_ProjectName"); + textfield.setText(ysr8_ProjectName); + + String ysr8_CustomerName = xmqdForm.getProperty("ysr8_CustomerName"); + textfield = (iTextField)fu.allComponentMap.get("ysr8_CustomerName"); + textfield.setText(ysr8_CustomerName); + } + } + + { + textfield = (iTextField)fu.allComponentMap.get("ysr8_Applicant"); + TCComponentUser user = fu.session.getUser(); + String user_id = user.getProperty("user_id").toString(); + textfield.setText(user_id); + + textfield = (iTextField)fu.allComponentMap.get("ysr8_ApplicantDate"); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + String curDate = sdf.format(new Date()); + textfield.setText(curDate); + } + + { + TCComponentItem dhtzItem = TCUtil.findItemByID(fu.session, projectCode + "_DHTZ"); + if (dhtzItem != null) { + TCComponentItemRevision dhtzRevision = dhtzItem.getLatestItemRevision(); + TCComponentForm dhtzForm = TCUtil.getItemRevisionMasterForm(dhtzRevision); + + String ysr8_ReceiverVal = dhtzForm.getProperty("ysr8_Receiver"); + textfield = (iTextField)fu.allComponentMap.get("ysr8_Receiver"); + textfield.setText(ysr8_ReceiverVal); + + String ysr8_ReceiverPhoneVal = dhtzForm.getProperty("ysr8_ReceiverPhone"); + textfield = (iTextField)fu.allComponentMap.get("ysr8_ReceiverPhone"); + textfield.setText(ysr8_ReceiverPhoneVal); + + String ysr8_ReceiptAddressVal = dhtzForm.getProperty("ysr8_ReceiptAddress"); + textfield = (iTextField)fu.allComponentMap.get("ysr8_ReceiptAddress"); + textfield.setText(ysr8_ReceiptAddressVal); + } + } + + } catch (TCException e) { + e.printStackTrace(); + } + } + + public boolean checkCanSave() { + return true; + } + void dhtzMessage() { + try { + iTextField textfield = null; + TCComponentItem dhtzItem = TCUtil.findItemByID(fu.session, projectCode + "_DHTZ"); + if (dhtzItem != null) { + TCComponentItemRevision dhtzRevision = dhtzItem.getLatestItemRevision(); + TCComponentForm dhtzForm = TCUtil.getItemRevisionMasterForm(dhtzRevision); + + String ysr8_ReceiverVal = dhtzForm.getProperty("ysr8_Receiver"); + textfield = (iTextField)fu.allComponentMap.get("ysr8_Receiver"); + textfield.setText(ysr8_ReceiverVal); + + String ysr8_ReceiverPhoneVal = dhtzForm.getProperty("ysr8_ReceiverPhone"); + textfield = (iTextField)fu.allComponentMap.get("ysr8_ReceiverPhone"); + textfield.setText(ysr8_ReceiverPhoneVal); + + String ysr8_ReceiptAddressVal = dhtzForm.getProperty("ysr8_ReceiptAddress"); + textfield = (iTextField)fu.allComponentMap.get("ysr8_ReceiptAddress"); + textfield.setText(ysr8_ReceiptAddressVal); + } else { + MessageBox.post("δѯĿĶ֪ͨ!","",MessageBox.WARNING); + } + } catch (TCException e) { + e.printStackTrace(); + } + } +} diff --git a/src/cn/com/ebewin/ysr/form/YSR8_DesignTaskRevisionMasterForm.java b/src/cn/com/ebewin/ysr/form/YSR8_DesignTaskRevisionMasterForm.java new file mode 100644 index 0000000..b184b4d --- /dev/null +++ b/src/cn/com/ebewin/ysr/form/YSR8_DesignTaskRevisionMasterForm.java @@ -0,0 +1,1105 @@ +package cn.com.ebewin.ysr.form; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.text.ParseException; +import java.util.Date; +import java.util.Iterator; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JTable; +import javax.swing.JTextField; + +import org.apache.poi.ss.util.AreaReference; +import org.apache.poi.ss.util.CellReference; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.commands.open.OpenFormDialog; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCFormProperty; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.util.MessageBox; + +import cn.com.ebewin.ysr.util.CommonUtil; +import cn.com.ebewin.ysr.util.UIUtil.JComboBoxInfo; +import cn.com.ebewin.ysr.util.FormUtil; +import cn.com.ebewin.ysr.util.TCUtil; +import cn.com.ebewin.ysr.dialog.SelectMotomanModleDialog; + +public class YSR8_DesignTaskRevisionMasterForm extends AbstractRendering { + private static final long serialVersionUID = 1L; + private static Date refreshDate = null; + + FormUtil fu = new FormUtil(this); + int beforeSelect_a111311111 = -1; + + public YSR8_DesignTaskRevisionMasterForm(TCComponentForm arg0) throws Exception { + super(arg0); + + Date currDate = new Date(); + if (refreshDate == null) { + arg0.refresh(); + refreshDate = currDate; + } else { + long diff = currDate.getTime() - refreshDate.getTime(); + long minutes = diff / 1000 / 60; + if ( minutes >= 1 ) { + arg0.refresh(); + refreshDate = currDate; + } + } + + fu.readRenderingXML("YSR8_DesignTaskRevisionMasterForm"); + fu.initializeUI(arg0); + addActionListener(); + loadRendering(); + + ChangeComboBoxState_ysr8_WelderBrand(); + loadYsr8_WelderType(); + ChangeComboBoxState_ysr8_TorchBrand(); + loadYsr8_TorchType(); + ChangeComboBoxState_ysr8_WireFeederBrand(); + loadYsr8_WireFeederTypeVal(); + ChangeComboBoxState_ysr8_ClearGunBrand(); + loadYsr8_ClearGunType(); + ChangeComboBoxState_ysr8_AntiCollisionBrand(); + loadYsr8_AntiCollisionType(); + ChangeComboBoxState_ysr8_WaterTankBrand(); + loadYsr8_WaterTankType(); + ChangeComboBoxState_ysr8_HolderBrand(); + loadYsr8_HolderModel(); + ChangeComboBoxState_ysr8_ControllerBrand(); + loadYsr8_ControllerType(); + ChangeComboBoxState_ysr8_WeldingTongBrand(); + loadYsr8_WeldingTongType(); + ChangeComboBoxState_ysr8_WeldingTongBrand2(); + loadYsr8_WeldingTongType2(); + ChangeComboBoxState_ysr8_WaterCoolerBrand(); + loadYsr8_WaterCoolerType(); + ChangeComboBoxState_ysr8_MachineBrand(); + loadYsr8_MachineType(); + } + + @Override + public void loadRendering() throws TCException { + fu.loadRendering(); + } + + @Override + public void saveRendering() { + try { + fu.saveRendering(); + } catch (TCException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } catch (ParseException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } + writeDatasetExcelInfo(); + } + + + + @Override + public void displayDialog(AbstractAIFDialog arg0, boolean arg1) { + fu.fitToScreen(arg0); + super.displayDialog(arg0, arg1); + } + + @Override + public void displayDialog(OpenFormDialog arg0, boolean arg1) { + fu.fitToScreen(arg0); + super.displayDialog(arg0, arg1); + } + + public boolean isRenderingModified() { + return fu.isRenderingModified(); + } + + ///////////////////////////////////////////////////////////////// + @SuppressWarnings("unchecked") + void addActionListener() { + ////////////////////////////////////////////////////// +// FormUtil.TableButtonEvent e = new FormUtil.TableButtonEvent() { +// @Override +// public void invoke(ActionEvent e) { +// FormUtil.TableButton button = (FormUtil.TableButton)e.getSource(); +// //ӡк +// System.out.println("row:" + button.row + "column :" + button.column); +// } +// +// }; + { + JButton btn = (JButton)fu.allComponentMap.get("b111311211"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a111311111"); + Object[] objData = new Object[ci.childComponentInfos.size()]; + for (int i = 0; i < objData.length; i++) { + objData[i] = ""; + } + ci.dataTableModel.addRow(objData); + } + }); + + btn = (JButton)fu.allComponentMap.get("b111311221"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a111311111"); + JTable table = (JTable)fu.allComponentMap.get("a111311111"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪƳУ", "ʾ", MessageBox.INFORMATION); + return; + } + for (int i = rows.length - 1; i >= 0; i--) { + ci.dataTableModel.removeRow(rows[i]); + } + } + }); + + btn = (JButton)fu.allComponentMap.get("b111311231"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + //FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a111311111"); + JTable table = (JTable)fu.allComponentMap.get("a111311111"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪƵУ", "ʾ", MessageBox.INFORMATION); + return; + } + beforeSelect_a111311111 = rows[0]; + } + }); + + btn = (JButton)fu.allComponentMap.get("b111311241"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a111311111"); + JTable table = (JTable)fu.allComponentMap.get("a111311111"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪճУ", "ʾ", MessageBox.INFORMATION); + return; + } + if (beforeSelect_a111311111 < 0) { + MessageBox.post("ѡҪƵУ", "ʾ", MessageBox.INFORMATION); + return; + } + //Object[] objData = new Object[ci.childComponentInfos.size()]; + for (int i = 0; i < ci.childComponentInfos.size(); i++) { + table.setValueAt(table.getValueAt(beforeSelect_a111311111, i), rows[0], i); + } + } + }); + + btn = (JButton)fu.allComponentMap.get("b111311261"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + JTable table = (JTable)fu.allComponentMap.get("a111311111"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪУ", "ʾ", MessageBox.INFORMATION); + return; + } + + SelectMotomanModleDialog dlg = new SelectMotomanModleDialog(fu.session); + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a111311111"); + ci.dataTableModel.setValueAt(dlg.retBTXH, rows[0], 0); + } + }); + } + ////////////////////////////////////////////////////// + { + JButton btn = (JButton)fu.allComponentMap.get("b11141111211"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a11141111111"); + Object[] objData = new Object[ci.childComponentInfos.size()]; + for (int i = 0; i < objData.length; i++) { + objData[i] = ""; + } + ci.dataTableModel.addRow(objData); + } + }); + + btn = (JButton)fu.allComponentMap.get("b11141111212"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a11141111111"); + JTable table = (JTable)fu.allComponentMap.get("a11141111111"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪƳУ", "ʾ", MessageBox.INFORMATION); + return; + } + for (int i = rows.length - 1; i >= 0; i--) { + ci.dataTableModel.removeRow(rows[i]); + } + } + }); + } + ////////////////////////////////////////////////////// + { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_WelderBrand"); + cbx.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent itemevent) { + if (itemevent.getStateChange() == ItemEvent.SELECTED) { + ChangeComboBoxState_ysr8_WelderBrand(); + } + } + }); + } + { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_TorchBrand"); + cbx.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent itemevent) { + if (itemevent.getStateChange() == ItemEvent.SELECTED) { + ChangeComboBoxState_ysr8_TorchBrand(); + } + } + }); + } + { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_WireFeederBrand"); + cbx.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent itemevent) { + if (itemevent.getStateChange() == ItemEvent.SELECTED) { + ChangeComboBoxState_ysr8_WireFeederBrand(); + } + } + }); + } + { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_ClearGunBrand"); + cbx.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent itemevent) { + if (itemevent.getStateChange() == ItemEvent.SELECTED) { + ChangeComboBoxState_ysr8_ClearGunBrand(); + } + } + }); + } + { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_AntiCollisionBrand"); + cbx.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent itemevent) { + if (itemevent.getStateChange() == ItemEvent.SELECTED) { + ChangeComboBoxState_ysr8_AntiCollisionBrand(); + } + } + }); + } + { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_WaterTankBrand"); + cbx.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent itemevent) { + if (itemevent.getStateChange() == ItemEvent.SELECTED) { + ChangeComboBoxState_ysr8_WaterTankBrand(); + } + } + }); + } + { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_HolderBrand"); + cbx.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent itemevent) { + if (itemevent.getStateChange() == ItemEvent.SELECTED) { + ChangeComboBoxState_ysr8_HolderBrand(); + } + } + }); + } + { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_ControllerBrand"); + cbx.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent itemevent) { + if (itemevent.getStateChange() == ItemEvent.SELECTED) { + ChangeComboBoxState_ysr8_ControllerBrand(); + } + } + }); + } + { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_WeldingTongBrand"); + cbx.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent itemevent) { + if (itemevent.getStateChange() == ItemEvent.SELECTED) { + ChangeComboBoxState_ysr8_WeldingTongBrand(); + } + } + }); + } + { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_WeldingTongBrand2"); + cbx.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent itemevent) { + if (itemevent.getStateChange() == ItemEvent.SELECTED) { + ChangeComboBoxState_ysr8_WeldingTongBrand2(); + } + } + }); + } + { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_WaterCoolerBrand"); + cbx.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent itemevent) { + if (itemevent.getStateChange() == ItemEvent.SELECTED) { + ChangeComboBoxState_ysr8_WaterCoolerBrand(); + } + } + }); + } + { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_MachineBrand"); + cbx.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent itemevent) { + if (itemevent.getStateChange() == ItemEvent.SELECTED) { + ChangeComboBoxState_ysr8_MachineBrand(); + } + } + }); + } + + } + ////////////////////////////////////////////////////// + @SuppressWarnings("unchecked") + void ChangeComboBoxState_ysr8_WelderBrand() { + JComboBox cbx1 = (JComboBox)fu.allComponentMap.get("ysr8_WelderBrand"); + String val = cbx1.getSelectedItem().toString(); + FormUtil.JComboBoxInfo ci = (FormUtil.JComboBoxInfo)fu.allComponentInfos.get("ysr8_WelderBrand"); + if (ci.key_values != null) { + for (int i = 0; i < ci.key_values.size(); i++) { + if (ci.key_values.get(i).get("PNAME").toString().equalsIgnoreCase(val)) { + val = ci.key_values.get(i).get("PCID").toString(); + break; + } + } + } + ci = (FormUtil.JComboBoxInfo)fu.allComponentInfos.get("ysr8_WelderType"); + ci.objvalues = TCUtil.GetCls_Instance(fu.session, val); + JComboBox cbx2 = (JComboBox)fu.allComponentMap.get("ysr8_WelderType"); + cbx2.removeAllItems(); + cbx2.addItem(""); + cbx2.addItem(""); + for (Iterator iterator = ci.objvalues.iterator(); iterator.hasNext();) { + cbx2.addItem(iterator.next().toString()); + } + } + @SuppressWarnings("unchecked") + void loadYsr8_WelderType() { + try { + TCFormProperty property = (TCFormProperty)fu.tcForm.getFormTCProperty("ysr8_WelderType"); + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_WelderType"); + cbx.setSelectedItem(property.getStringValue()); + } catch (TCException e) { + e.printStackTrace(); + } + } + + @SuppressWarnings("unchecked") + void ChangeComboBoxState_ysr8_TorchBrand() { + JComboBox cbx1 = (JComboBox)fu.allComponentMap.get("ysr8_TorchBrand"); + String val = cbx1.getSelectedItem().toString(); + FormUtil.JComboBoxInfo ci = (FormUtil.JComboBoxInfo)fu.allComponentInfos.get("ysr8_TorchBrand"); + if (ci.key_values != null) { + for (int i = 0; i < ci.key_values.size(); i++) { + if (ci.key_values.get(i).get("PNAME").toString().equalsIgnoreCase(val)) { + val = ci.key_values.get(i).get("PCID").toString(); + break; + } + } + } + ci = (FormUtil.JComboBoxInfo)fu.allComponentInfos.get("ysr8_TorchType"); + ci.objvalues = TCUtil.GetCls_Instance(fu.session, val); + JComboBox cbx2 = (JComboBox)fu.allComponentMap.get("ysr8_TorchType"); + cbx2.removeAllItems(); + cbx2.addItem(""); + cbx2.addItem(""); + for (Iterator iterator = ci.objvalues.iterator(); iterator.hasNext();) { + cbx2.addItem(iterator.next().toString()); + } + } + @SuppressWarnings("unchecked") + void loadYsr8_TorchType() { + try { + TCFormProperty property = (TCFormProperty)fu.tcForm.getFormTCProperty("ysr8_TorchType"); + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_TorchType"); + cbx.setSelectedItem(property.getStringValue()); + } catch (TCException e) { + e.printStackTrace(); + } + } + + @SuppressWarnings("unchecked") + void ChangeComboBoxState_ysr8_WireFeederBrand() { + JComboBox cbx1 = (JComboBox)fu.allComponentMap.get("ysr8_WireFeederBrand"); + String val = cbx1.getSelectedItem().toString(); + FormUtil.JComboBoxInfo ci = (FormUtil.JComboBoxInfo)fu.allComponentInfos.get("ysr8_WireFeederBrand"); + if (ci.key_values != null) { + for (int i = 0; i < ci.key_values.size(); i++) { + if (ci.key_values.get(i).get("PNAME").toString().equalsIgnoreCase(val)) { + val = ci.key_values.get(i).get("PCID").toString(); + break; + } + } + } + ci = (FormUtil.JComboBoxInfo)fu.allComponentInfos.get("ysr8_WireFeederType"); + ci.objvalues = TCUtil.GetCls_Instance(fu.session, val); + JComboBox cbx2 = (JComboBox)fu.allComponentMap.get("ysr8_WireFeederType"); + cbx2.removeAllItems(); + cbx2.addItem(""); + cbx2.addItem(""); + for (Iterator iterator = ci.objvalues.iterator(); iterator.hasNext();) { + cbx2.addItem(iterator.next().toString()); + } + } + @SuppressWarnings("unchecked") + void loadYsr8_WireFeederTypeVal() { + try { + TCFormProperty property = (TCFormProperty)fu.tcForm.getFormTCProperty("ysr8_WireFeederType"); + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_WireFeederType"); + cbx.setSelectedItem(property.getStringValue()); + } catch (TCException e) { + e.printStackTrace(); + } + } + + @SuppressWarnings("unchecked") + void ChangeComboBoxState_ysr8_ClearGunBrand() { + JComboBox cbx1 = (JComboBox)fu.allComponentMap.get("ysr8_ClearGunBrand"); + String val = cbx1.getSelectedItem().toString(); + FormUtil.JComboBoxInfo ci = (FormUtil.JComboBoxInfo)fu.allComponentInfos.get("ysr8_ClearGunBrand"); + if (ci.key_values != null) { + for (int i = 0; i < ci.key_values.size(); i++) { + if (ci.key_values.get(i).get("PNAME").toString().equalsIgnoreCase(val)) { + val = ci.key_values.get(i).get("PCID").toString(); + break; + } + } + } + ci = (FormUtil.JComboBoxInfo)fu.allComponentInfos.get("ysr8_ClearGunType"); + ci.objvalues = TCUtil.GetCls_Instance(fu.session, val); + JComboBox cbx2 = (JComboBox)fu.allComponentMap.get("ysr8_ClearGunType"); + cbx2.removeAllItems(); + cbx2.addItem(""); + cbx2.addItem(""); + for (Iterator iterator = ci.objvalues.iterator(); iterator.hasNext();) { + cbx2.addItem(iterator.next().toString()); + } + } + @SuppressWarnings("unchecked") + void loadYsr8_ClearGunType() { + try { + TCFormProperty property = (TCFormProperty)fu.tcForm.getFormTCProperty("ysr8_ClearGunType"); + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_ClearGunType"); + cbx.setSelectedItem(property.getStringValue()); + } catch (TCException e) { + e.printStackTrace(); + } + } + + @SuppressWarnings("unchecked") + void ChangeComboBoxState_ysr8_AntiCollisionBrand() { + JComboBox cbx1 = (JComboBox)fu.allComponentMap.get("ysr8_AntiCollisionBrand"); + String val = cbx1.getSelectedItem().toString(); + FormUtil.JComboBoxInfo ci = (FormUtil.JComboBoxInfo)fu.allComponentInfos.get("ysr8_AntiCollisionBrand"); + if (ci.key_values != null) { + for (int i = 0; i < ci.key_values.size(); i++) { + if (ci.key_values.get(i).get("PNAME").toString().equalsIgnoreCase(val)) { + val = ci.key_values.get(i).get("PCID").toString(); + break; + } + } + } + ci = (FormUtil.JComboBoxInfo)fu.allComponentInfos.get("ysr8_AntiCollisionType"); + ci.objvalues = TCUtil.GetCls_Instance(fu.session, val); + JComboBox cbx2 = (JComboBox)fu.allComponentMap.get("ysr8_AntiCollisionType"); + cbx2.removeAllItems(); + cbx2.addItem(""); + cbx2.addItem(""); + for (Iterator iterator = ci.objvalues.iterator(); iterator.hasNext();) { + cbx2.addItem(iterator.next().toString()); + } + } + @SuppressWarnings("unchecked") + void loadYsr8_AntiCollisionType() { + try { + TCFormProperty property = (TCFormProperty)fu.tcForm.getFormTCProperty("ysr8_AntiCollisionType"); + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_AntiCollisionType"); + cbx.setSelectedItem(property.getStringValue()); + } catch (TCException e) { + e.printStackTrace(); + } + } + + @SuppressWarnings("unchecked") + void ChangeComboBoxState_ysr8_WaterTankBrand() { + JComboBox cbx1 = (JComboBox)fu.allComponentMap.get("ysr8_WaterTankBrand"); + String val = cbx1.getSelectedItem().toString(); + FormUtil.JComboBoxInfo ci = (FormUtil.JComboBoxInfo)fu.allComponentInfos.get("ysr8_WaterTankBrand"); + if (ci.key_values != null) { + for (int i = 0; i < ci.key_values.size(); i++) { + if (ci.key_values.get(i).get("PNAME").toString().equalsIgnoreCase(val)) { + val = ci.key_values.get(i).get("PCID").toString(); + break; + } + } + } + ci = (FormUtil.JComboBoxInfo)fu.allComponentInfos.get("ysr8_WaterTankType"); + ci.objvalues = TCUtil.GetCls_Instance(fu.session, val); + JComboBox cbx2 = (JComboBox)fu.allComponentMap.get("ysr8_WaterTankType"); + cbx2.removeAllItems(); + cbx2.addItem(""); + cbx2.addItem(""); + for (Iterator iterator = ci.objvalues.iterator(); iterator.hasNext();) { + cbx2.addItem(iterator.next().toString()); + } + } + @SuppressWarnings("unchecked") + void loadYsr8_WaterTankType() { + try { + TCFormProperty property = (TCFormProperty)fu.tcForm.getFormTCProperty("ysr8_WaterTankType"); + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_WaterTankType"); + cbx.setSelectedItem(property.getStringValue()); + } catch (TCException e) { + e.printStackTrace(); + } + } + + @SuppressWarnings("unchecked") + void ChangeComboBoxState_ysr8_HolderBrand() { + JComboBox cbx1 = (JComboBox)fu.allComponentMap.get("ysr8_HolderBrand"); + String val = cbx1.getSelectedItem().toString(); + FormUtil.JComboBoxInfo ci = (FormUtil.JComboBoxInfo)fu.allComponentInfos.get("ysr8_HolderBrand"); + if (ci.key_values != null) { + for (int i = 0; i < ci.key_values.size(); i++) { + if (ci.key_values.get(i).get("PNAME").toString().equalsIgnoreCase(val)) { + val = ci.key_values.get(i).get("PCID").toString(); + break; + } + } + } + ci = (FormUtil.JComboBoxInfo)fu.allComponentInfos.get("ysr8_HolderModel"); + ci.objvalues = TCUtil.GetCls_Instance(fu.session, val); + JComboBox cbx2 = (JComboBox)fu.allComponentMap.get("ysr8_HolderModel"); + cbx2.removeAllItems(); + cbx2.addItem(""); + cbx2.addItem(""); + for (Iterator iterator = ci.objvalues.iterator(); iterator.hasNext();) { + cbx2.addItem(iterator.next().toString()); + } + } + @SuppressWarnings("unchecked") + void loadYsr8_HolderModel() { + try { + TCFormProperty property = (TCFormProperty)fu.tcForm.getFormTCProperty("ysr8_HolderModel"); + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_HolderModel"); + cbx.setSelectedItem(property.getStringValue()); + } catch (TCException e) { + e.printStackTrace(); + } + } + + @SuppressWarnings("unchecked") + void ChangeComboBoxState_ysr8_ControllerBrand() { + JComboBox cbx1 = (JComboBox)fu.allComponentMap.get("ysr8_ControllerBrand"); + String val = cbx1.getSelectedItem().toString(); + FormUtil.JComboBoxInfo ci = (FormUtil.JComboBoxInfo)fu.allComponentInfos.get("ysr8_ControllerBrand"); + if (ci.key_values != null) { + for (int i = 0; i < ci.key_values.size(); i++) { + if (ci.key_values.get(i).get("PNAME").toString().equalsIgnoreCase(val)) { + val = ci.key_values.get(i).get("PCID").toString(); + break; + } + } + } + ci = (FormUtil.JComboBoxInfo)fu.allComponentInfos.get("ysr8_ControllerType"); + ci.objvalues = TCUtil.GetCls_Instance(fu.session, val); + JComboBox cbx2 = (JComboBox)fu.allComponentMap.get("ysr8_ControllerType"); + cbx2.removeAllItems(); + cbx2.addItem(""); + cbx2.addItem(""); + for (Iterator iterator = ci.objvalues.iterator(); iterator.hasNext();) { + cbx2.addItem(iterator.next().toString()); + } + } + @SuppressWarnings("unchecked") + void loadYsr8_ControllerType() { + try { + TCFormProperty property = (TCFormProperty)fu.tcForm.getFormTCProperty("ysr8_ControllerType"); + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_ControllerType"); + cbx.setSelectedItem(property.getStringValue()); + } catch (TCException e) { + e.printStackTrace(); + } + } + + @SuppressWarnings("unchecked") + void ChangeComboBoxState_ysr8_WeldingTongBrand() { + JComboBox cbx1 = (JComboBox)fu.allComponentMap.get("ysr8_WeldingTongBrand"); + String val = cbx1.getSelectedItem().toString(); + FormUtil.JComboBoxInfo ci = (FormUtil.JComboBoxInfo)fu.allComponentInfos.get("ysr8_WeldingTongBrand"); + if (ci.key_values != null) { + for (int i = 0; i < ci.key_values.size(); i++) { + if (ci.key_values.get(i).get("PNAME").toString().equalsIgnoreCase(val)) { + val = ci.key_values.get(i).get("PCID").toString(); + break; + } + } + } + ci = (FormUtil.JComboBoxInfo)fu.allComponentInfos.get("ysr8_WeldingTongType"); + ci.objvalues = TCUtil.GetCls_Instance(fu.session, val); + JComboBox cbx2 = (JComboBox)fu.allComponentMap.get("ysr8_WeldingTongType"); + cbx2.removeAllItems(); + cbx2.addItem(""); + cbx2.addItem(""); + for (Iterator iterator = ci.objvalues.iterator(); iterator.hasNext();) { + cbx2.addItem(iterator.next().toString()); + } + } + @SuppressWarnings("unchecked") + void loadYsr8_WeldingTongType() { + try { + TCFormProperty property = (TCFormProperty)fu.tcForm.getFormTCProperty("ysr8_WeldingTongType"); + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_WeldingTongType"); + cbx.setSelectedItem(property.getStringValue()); + } catch (TCException e) { + e.printStackTrace(); + } + } + + @SuppressWarnings("unchecked") + void ChangeComboBoxState_ysr8_WeldingTongBrand2() { + JComboBox cbx1 = (JComboBox)fu.allComponentMap.get("ysr8_WeldingTongBrand2"); + String val = cbx1.getSelectedItem().toString(); + FormUtil.JComboBoxInfo ci = (FormUtil.JComboBoxInfo)fu.allComponentInfos.get("ysr8_WeldingTongBrand2"); + if (ci.key_values != null) { + for (int i = 0; i < ci.key_values.size(); i++) { + if (ci.key_values.get(i).get("PNAME").toString().equalsIgnoreCase(val)) { + val = ci.key_values.get(i).get("PCID").toString(); + break; + } + } + } + ci = (FormUtil.JComboBoxInfo)fu.allComponentInfos.get("ysr8_WeldingTongType2"); + ci.objvalues = TCUtil.GetCls_Instance(fu.session, val); + JComboBox cbx2 = (JComboBox)fu.allComponentMap.get("ysr8_WeldingTongType2"); + cbx2.removeAllItems(); + cbx2.addItem(""); + cbx2.addItem(""); + for (Iterator iterator = ci.objvalues.iterator(); iterator.hasNext();) { + cbx2.addItem(iterator.next().toString()); + } + } + @SuppressWarnings("unchecked") + void loadYsr8_WeldingTongType2() { + try { + TCFormProperty property = (TCFormProperty)fu.tcForm.getFormTCProperty("ysr8_WeldingTongType2"); + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_WeldingTongType2"); + cbx.setSelectedItem(property.getStringValue()); + } catch (TCException e) { + e.printStackTrace(); + } + } + + @SuppressWarnings("unchecked") + void ChangeComboBoxState_ysr8_WaterCoolerBrand() { + JComboBox cbx1 = (JComboBox)fu.allComponentMap.get("ysr8_WaterCoolerBrand"); + String val = cbx1.getSelectedItem().toString(); + FormUtil.JComboBoxInfo ci = (FormUtil.JComboBoxInfo)fu.allComponentInfos.get("ysr8_WaterCoolerBrand"); + if (ci.key_values != null) { + for (int i = 0; i < ci.key_values.size(); i++) { + if (ci.key_values.get(i).get("PNAME").toString().equalsIgnoreCase(val)) { + val = ci.key_values.get(i).get("PCID").toString(); + break; + } + } + } + ci = (FormUtil.JComboBoxInfo)fu.allComponentInfos.get("ysr8_WaterCoolerType"); + ci.objvalues = TCUtil.GetCls_Instance(fu.session, val); + JComboBox cbx2 = (JComboBox)fu.allComponentMap.get("ysr8_WaterCoolerType"); + cbx2.removeAllItems(); + cbx2.addItem(""); + cbx2.addItem(""); + for (Iterator iterator = ci.objvalues.iterator(); iterator.hasNext();) { + cbx2.addItem(iterator.next().toString()); + } + } + @SuppressWarnings("unchecked") + void loadYsr8_WaterCoolerType() { + try { + TCFormProperty property = (TCFormProperty)fu.tcForm.getFormTCProperty("ysr8_WaterCoolerType"); + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_WaterCoolerType"); + cbx.setSelectedItem(property.getStringValue()); + } catch (TCException e) { + e.printStackTrace(); + } + } + + @SuppressWarnings("unchecked") + void ChangeComboBoxState_ysr8_MachineBrand() { + JComboBox cbx1 = (JComboBox)fu.allComponentMap.get("ysr8_MachineBrand"); + String val = cbx1.getSelectedItem().toString(); + FormUtil.JComboBoxInfo ci = (FormUtil.JComboBoxInfo)fu.allComponentInfos.get("ysr8_MachineBrand"); + if (ci.key_values != null) { + for (int i = 0; i < ci.key_values.size(); i++) { + if (ci.key_values.get(i).get("PNAME").toString().equalsIgnoreCase(val)) { + val = ci.key_values.get(i).get("PCID").toString(); + break; + } + } + } + ci = (FormUtil.JComboBoxInfo)fu.allComponentInfos.get("ysr8_MachineType"); + ci.objvalues = TCUtil.GetCls_Instance(fu.session, val); + JComboBox cbx2 = (JComboBox)fu.allComponentMap.get("ysr8_MachineType"); + cbx2.removeAllItems(); + cbx2.addItem(""); + cbx2.addItem(""); + for (Iterator iterator = ci.objvalues.iterator(); iterator.hasNext();) { + cbx2.addItem(iterator.next().toString()); + } + } + @SuppressWarnings("unchecked") + void loadYsr8_MachineType() { + try { + TCFormProperty property = (TCFormProperty)fu.tcForm.getFormTCProperty("ysr8_MachineType"); + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_MachineType"); + cbx.setSelectedItem(property.getStringValue()); + } catch (TCException e) { + e.printStackTrace(); + } + } + ////////////////////////////////////////////////////// + void writeDatasetExcelInfo() { + TCComponentItemRevision itemRevision = null; + TCComponentDataset dataset = null; + String itemId = null; + try { + AIFComponentContext[] context = fu.tcForm.whereReferencedByTypeRelation(new String[] {"YSR8_DesignTaskRevision"}, new String[] {"IMAN_master_form"}); + if (context != null && context.length > 0) { + itemRevision = (TCComponentItemRevision)context[0].getComponent(); + TCComponent[] components = itemRevision.getRelatedComponents("IMAN_specification"); + if (components != null && components.length > 0) { + for (int i = 0; i < components.length; i++) { + dataset = (TCComponentDataset) components[i]; + String type = dataset.getProperty("object_type"); + if (!type.equals("MSExcelX")) { + continue; + } + String name = dataset.getProperty("object_string"); + if (!name.equals("ʩ_SJSY")) { + continue; + } + } + } + } + else { + //MessageBox.post("޷ҵʩϢ!", "ʾ", MessageBox.INFORMATION); + return; + } + itemId = itemRevision.getProperty("item_id"); + + if (dataset == null) { + //MessageBox.post("޷ҵʩݼϢ!", "ʾ", MessageBox.INFORMATION); + return; + } + } catch (TCException e1) { + e1.printStackTrace(); + } + + File excelFile = TCUtil.exportFileToDir(dataset, CommonUtil.tmpDir, itemId); + if (excelFile == null) { + //MessageBox.post("ȡʩݼExcelļʧ!", "ʾ", MessageBox.INFORMATION); + return; + } + writeDatasetExcelInfo_sub(itemRevision, excelFile); + + TCUtil.saveFileToDataset(dataset, excelFile); + } + @SuppressWarnings("unchecked") + void writeDatasetExcelInfo_sub(TCComponentItemRevision itemRevision, File excelFile) { + try { + FileInputStream fileIn = new FileInputStream(excelFile); + XSSFWorkbook workbook = new XSSFWorkbook(fileIn); + + String ZLTG = "", BWJ = ""; + String[] ysr8_PositionerModel = null; + int[] ysr8_PositionerNumber = null; + int length = fu.formProperties.length; + for (int k = 0; k < length; ++k) { + String propName = fu.formProperties[k].getPropertyName().trim(); +System.out.println("fu.formProperties[k].getPropertyName()-----" + propName); + if (!fu.formProperties[k].isNotArray()) { + if (propName.equalsIgnoreCase("ysr8_MotomanModel") || + propName.equalsIgnoreCase("ysr8_MotomanNumber") || + propName.equalsIgnoreCase("ysr8_Use") || + propName.equalsIgnoreCase("ysr8_Coordination") || + propName.equalsIgnoreCase("ysr8_CableLength") || + propName.equalsIgnoreCase("ysr8_Transformer") || + propName.equalsIgnoreCase("ysr8_ControlModel") || + propName.equalsIgnoreCase("ysr8_ControlNumber") || + propName.equalsIgnoreCase("ysr8_IO") || + propName.equalsIgnoreCase("ysr8_BusSubstrate") || + propName.equalsIgnoreCase("ysr8_RandomPlug") || + propName.equalsIgnoreCase("ysr8_Specification") || + propName.equalsIgnoreCase("ysr8_OtherInstruction")) { + switch (fu.formProperties[k].getPropertyType()) { + case TCProperty.PROP_string: + case TCProperty.PROP_long_string: + String[] strvals = fu.formProperties[k].getStringArrayValue(); + for (int l = 0; l < strvals.length; l++) { + setNameValue(workbook, propName + (l + 1), strvals[l]); + } + break; + case TCProperty.PROP_short: + case TCProperty.PROP_int: + int[] ivals = fu.formProperties[k].getIntArrayValue(); + for (int l = 0; l < ivals.length; l++) { + setNameValue(workbook, propName + (l + 1), ivals[l]); + } + break; + case TCProperty.PROP_double: + case TCProperty.PROP_float: + double[] doublevals = fu.formProperties[k].getDoubleArrayValue(); + for (int l = 0; l < doublevals.length; l++) { + setNameValue(workbook, propName + (l + 1), doublevals[l]); + } + break; + } + } else if (propName.equalsIgnoreCase("ysr8_PositionerModel")) { + ysr8_PositionerModel = fu.formProperties[k].getStringArrayValue(); + } else if (propName.equalsIgnoreCase("ysr8_PositionerNumber")) { + ysr8_PositionerNumber = fu.formProperties[k].getIntArrayValue(); + } + } else { + if (propName.equalsIgnoreCase("ysr8_WelderBrand") || + propName.equalsIgnoreCase("ysr8_TorchBrand") || + propName.equalsIgnoreCase("ysr8_WireFeederBrand") || + propName.equalsIgnoreCase("ysr8_ClearGunBrand") || + propName.equalsIgnoreCase("ysr8_AntiCollisionBrand") || + propName.equalsIgnoreCase("ysr8_WaterTankBrand") || + propName.equalsIgnoreCase("ysr8_HolderBrand") || + propName.equalsIgnoreCase("ysr8_ControllerBrand") || + propName.equalsIgnoreCase("ysr8_WeldingTongBrand") || + propName.equalsIgnoreCase("ysr8_WeldingTongBrand2") || + propName.equalsIgnoreCase("ysr8_WaterCoolerBrand") || + propName.equalsIgnoreCase("ysr8_MachineBrand")) { + String value = ""; + JComboBoxInfo ci = (JComboBoxInfo)fu.allComponentInfos.get(propName); + JComboBox cbx = (JComboBox)fu.allComponentMap.get(propName); + if (!ci.canWrite) { + value = cbx.getSelectedItem().toString(); + } else { + value = ((JTextField)cbx.getEditor().getEditorComponent()).getText(); + } + setNameValue(workbook, propName, value); + continue; + } else if (propName.equalsIgnoreCase("ysr8_2DAssemblyDiagram")) { + JCheckBox cbx = (JCheckBox)fu.allComponentMap.get(propName); + if (cbx.isSelected()) { + ZLTG += "άװͼ "; + } + continue; + } else if (propName.equalsIgnoreCase("ysr8_2DPartDrawing")) { + JCheckBox cbx = (JCheckBox)fu.allComponentMap.get(propName); + if (cbx.isSelected()) { + ZLTG += "άͼ "; + } + continue; + } else if (propName.equalsIgnoreCase("ysr8_3DDrawing")) { + JCheckBox cbx = (JCheckBox)fu.allComponentMap.get(propName); + if (cbx.isSelected()) { + ZLTG += "άͼ "; + } + continue; + } else if (propName.equalsIgnoreCase("ysr8_ProcessCard")) { + JCheckBox cbx = (JCheckBox)fu.allComponentMap.get(propName); + if (cbx.isSelected()) { + ZLTG += "տ "; + } + continue; + } else if (propName.equalsIgnoreCase("ysr8_UserRequirement")) { + JCheckBox cbx = (JCheckBox)fu.allComponentMap.get(propName); + if (cbx.isSelected()) { + ZLTG += "ûƱ׼Ҫ "; + } + continue; + } else if (propName.equalsIgnoreCase("ysr8_SimResults")) { + JCheckBox cbx = (JCheckBox)fu.allComponentMap.get(propName); + if (cbx.isSelected()) { + ZLTG += "׶η "; + } + continue; + } else if (propName.equalsIgnoreCase("ysr8_FixtureClamping")) { + JCheckBox cbx = (JCheckBox)fu.allComponentMap.get(propName); + if (cbx.isSelected()) { + ZLTG += "о߶λн "; + } + continue; + } else if (propName.equalsIgnoreCase("ysr8_TechnologyAgreement")) { + JCheckBox cbx = (JCheckBox)fu.allComponentMap.get(propName); + if (cbx.isSelected()) { + ZLTG += "Э "; + } + continue; + } else if (propName.equalsIgnoreCase("ysr8_Layout")) { + JCheckBox cbx = (JCheckBox)fu.allComponentMap.get(propName); + if (cbx.isSelected()) { + ZLTG += "ͼ "; + } + continue; + } else if (propName.equalsIgnoreCase("ysr8_SystemCatalog")) { + JCheckBox cbx = (JCheckBox)fu.allComponentMap.get(propName); + if (cbx.isSelected()) { + ZLTG += "ϵͳĿ¼ "; + } + continue; + } else if (propName.equalsIgnoreCase("ysr8_SystemPurchase")) { + JCheckBox cbx = (JCheckBox)fu.allComponentMap.get(propName); + if (cbx.isSelected()) { + ZLTG += "ϵͳɹ "; + } + continue; + } + + switch (fu.formProperties[k].getPropertyType()) { + case TCProperty.PROP_string: + case TCProperty.PROP_long_string: + setNameValue(workbook, propName, fu.formProperties[k].getStringValue()); + break; + case TCProperty.PROP_short: + case TCProperty.PROP_int: + setNameValue(workbook, propName, fu.formProperties[k].getIntValue()); + break; + case TCProperty.PROP_double: + case TCProperty.PROP_float: + setNameValue(workbook, propName, fu.formProperties[k].getDoubleValue()); + break; + } + } + } + setNameValue(workbook, "ZLTG", ZLTG); + for (int i = 0; i < ysr8_PositionerModel.length; i++) { + BWJ += ysr8_PositionerModel[i] + ":" + Integer.toString(ysr8_PositionerNumber[i]) + " "; + } + setNameValue(workbook, "BWJ", BWJ); + + FileOutputStream fileOut = new FileOutputStream(excelFile.getPath()); + workbook.write(fileOut); + fileOut.flush(); + fileOut.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + void setNameValue(XSSFWorkbook workbook, String nameName, String val) { + org.apache.poi.ss.usermodel.Name name = workbook.getName(nameName); + if (name != null) { + String refers = name.getRefersToFormula(); + System.out.println("refers======" + refers); + AreaReference[] arefs = AreaReference.generateContiguous(refers); + System.out.println("arefs.length======" + arefs.length); + for (int i = 0; i < arefs.length; i++) { + // Only get the corners of the Area + // (use arefs[i].getAllReferencedCells() to get all cells) + AreaReference aref = arefs[i]; + System.out.println("aref.formatAsString()======" + aref.formatAsString()); + CellReference[] crefs = aref.getAllReferencedCells(); + System.out.println("crefs.length======" + crefs.length); + for (int j = 0; j < crefs.length; j++) { + // Check it turns into real stuff + CellReference cref = crefs[j]; + System.out.println("cref.formatAsString()======" + cref.formatAsString()); + System.out.println("cref.getSheetName()======" + cref.getSheetName()); + XSSFSheet s = workbook.getSheet(cref.getSheetName()); + XSSFRow r = s.getRow(cref.getRow()); + System.out.println("r.toString()======" + r.toString()); + XSSFCell c = r.getCell(cref.getCol()); + System.out.println("c.toString()======" + c.toString()); + c.setCellValue(val); + } + } + } + } + void setNameValue(XSSFWorkbook workbook, String nameName, int val) { + org.apache.poi.ss.usermodel.Name name = workbook.getName(nameName); + if (name != null) { + String refers = name.getRefersToFormula(); + AreaReference[] arefs = AreaReference.generateContiguous(refers); + for (int i = 0; i < arefs.length; i++) { + // Only get the corners of the Area + // (use arefs[i].getAllReferencedCells() to get all cells) + AreaReference aref = arefs[i]; + CellReference[] crefs = aref.getAllReferencedCells(); + for (int j = 0; j < crefs.length; j++) { + // Check it turns into real stuff + CellReference cref = crefs[j]; + XSSFSheet s = workbook.getSheet(cref.getSheetName()); + XSSFRow r = s.getRow(cref.getRow()); + XSSFCell c = r.getCell(cref.getCol()); + c.setCellValue(val); + } + } + } + } + void setNameValue(XSSFWorkbook workbook, String nameName, double val) { + org.apache.poi.ss.usermodel.Name name = workbook.getName(nameName); + if (name != null) { + String refers = name.getRefersToFormula(); + AreaReference[] arefs = AreaReference.generateContiguous(refers); + for (int i = 0; i < arefs.length; i++) { + // Only get the corners of the Area + // (use arefs[i].getAllReferencedCells() to get all cells) + AreaReference aref = arefs[i]; + CellReference[] crefs = aref.getAllReferencedCells(); + for (int j = 0; j < crefs.length; j++) { + // Check it turns into real stuff + CellReference cref = crefs[j]; + XSSFSheet s = workbook.getSheet(cref.getSheetName()); + XSSFRow r = s.getRow(cref.getRow()); + XSSFCell c = r.getCell(cref.getCol()); + c.setCellValue(val); + } + } + } + } +} diff --git a/src/cn/com/ebewin/ysr/form/YSR8_DrawingListRevisionMasterForm.java b/src/cn/com/ebewin/ysr/form/YSR8_DrawingListRevisionMasterForm.java new file mode 100644 index 0000000..dd73c93 --- /dev/null +++ b/src/cn/com/ebewin/ysr/form/YSR8_DrawingListRevisionMasterForm.java @@ -0,0 +1,590 @@ +package cn.com.ebewin.ysr.form; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map.Entry; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFileChooser; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.filechooser.FileSystemView; +import javax.swing.table.DefaultTableModel; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +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.XSSFPrintSetup; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.commands.open.OpenFormDialog; +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.stylesheet.AbstractRendering; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.iTextField; + +import cn.com.ebewin.ysr.util.FormCheckUtil; +import cn.com.ebewin.ysr.util.FormUtil; +import cn.com.ebewin.ysr.util.TCUtil; +import cn.com.ebewin.ysr.util.UIUtil.JComboBoxInfo; +import cn.com.ebewin.ysr.util.UIUtil.JTableInfo; + +public class YSR8_DrawingListRevisionMasterForm extends AbstractRendering { + private static final long serialVersionUID = 1L; + private static Date refreshDate = null; + private TCComponentForm currentForm; + + FormUtil fu = new FormUtil(this); + FormCheckUtil fcu = null; + + public YSR8_DrawingListRevisionMasterForm(TCComponentForm arg0) throws Exception { + super(arg0); + this.currentForm = arg0; + Date currDate = new Date(); + if (refreshDate == null) { + arg0.refresh(); + refreshDate = currDate; + } else { + long diff = currDate.getTime() - refreshDate.getTime(); + long minutes = diff / 1000 / 60; + if (minutes >= 1) { + arg0.refresh(); + refreshDate = currDate; + } + } + + fu.readRenderingXML("YSR8_DrawingListRevisionMasterForm"); + fu.initializeUI(arg0); + addActionListener(); + loadRendering(); + getDefVal(); + // +// JLabel label = (JLabel)fu.allComponentMap.get("l.091.17"); +// label.setVisible(false); +// iTextField ysr8_SDParts = (iTextField)fu.allComponentMap.get("ysr8_SDParts"); +// ysr8_SDParts.setVisible(false); + + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.061.11.11"); + int rowCount = ci.dataTableModel.getRowCount(); + for(int i=0; i cbx = (JComboBox) fu.allComponentMap.get("ysr8_Use"); + cbx.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent itemevent) { + if (itemevent.getStateChange() == ItemEvent.SELECTED) { + ChangeComboBoxState_ysr8_Use(); + } + } + }); + } + + public void getDefVal() { + ChangeComboBoxState_ysr8_Use(); + } + + public boolean checkCanSave() { + return true; + } + + /** + * + */ + public void exportExcel(boolean main) { + String excelPath = null; + File tempFile = null; + @SuppressWarnings("unchecked") + JComboBox cbx = (JComboBox) fu.allComponentMap.get("ysr8_Format"); + int selectTypeTemplate = cbx.getSelectedIndex(); + // JButton btn = (JButton) fu.allComponentMap.get("hb.061.12.11"); + if (selectTypeTemplate == 1) { + tempFile = TCUtil.findTemplete(fu.session, "YSR8_DrawingListTemplete0", "ͼĿ¼"); + } else if (selectTypeTemplate == 2) { + tempFile = TCUtil.findTemplete(fu.session, "YSR8_DrawingListTemplete1", "ͼĿ¼"); + } + if (tempFile != null) { + excelPath = tempFile.getPath(); + writeToExcel(tempFile, selectTypeTemplate, main); + } + if (excelPath == null || excelPath.equals("")) { + MessageBox.post(AIFUtility.getActiveDesktop(), "BOMȡʧܣ޷б棬...", "ʾ", MessageBox.WARNING); + return; + } + } + + // TODO writeToExcel + @SuppressWarnings("unchecked") + private void writeToExcel(File reportFile, int selectTypeTemplate, boolean main) { + 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(this); + if (state == 1) { + return; + } + // kk +// Date date = new Date(); +// SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); +// String time = sdf.format(date); +// String toPath = fileChooser.getSelectedFile().getAbsolutePath() + "\\ƼĿ¼" + time + ".xlsx"; +// String toPath = null; +// try { +// if(main) { +// toPath = fileChooser.getSelectedFile().getAbsolutePath() + "\\"+currentForm.getProperty("object_name")+"ͼĿ¼" + ".xlsx"; +// }else { +// toPath = fileChooser.getSelectedFile().getAbsolutePath() + "\\"+currentForm.getProperty("object_name") + "ƼĿ¼"+".xlsx"; +// } +// +// } catch (TCException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } +// System.out.println("ļ·" + toPath); + FileInputStream fileIn = null; + try { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get(main ? "a.061.11.11":"a.131.11.11"); + TCComponentItemRevision tempRev = (TCComponentItemRevision) currentForm.getReferenceProperty("item_revision");// õǰݼڰ汾 + TCComponent component2 = this.getComponent(); + String property = component2.getProperty("object_string"); + String itemId = "", itemName = "", topItemId = ""; + if (tempRev != null) { + TCComponentItemRevision partItemRevision = null; + AIFComponentContext[] contexts = tempRev.getItem(). + whereReferencedByTypeRelation(new String[] { "YSR8_MachPartsRevision" }, new String[] { "YSR8_FixtureDocument" }); + if (contexts != null && contexts.length > 0) { + + partItemRevision = (TCComponentItemRevision) contexts[0].getComponent(); + itemId = partItemRevision.getProperty("item_id"); + itemName = partItemRevision.getProperty("object_name"); + topItemId = partItemRevision.getProperty("project_ids"); + } + + // YSR8_FixtureDocument + + } + //path + String toPath = null; + String[] split = property.split("\\/"); + if(main) { + toPath = fileChooser.getSelectedFile().getAbsolutePath() + "\\"+split[0]+"ͼĿ¼" + ".xlsx"; + }else { + toPath = fileChooser.getSelectedFile().getAbsolutePath() + "\\"+split[0] + "ƼĿ¼"+".xlsx"; + } + + System.out.println("ļ·" + toPath); + fileIn = new FileInputStream(reportFile); + String fileName = reportFile.getName().toLowerCase(); + Workbook workbook = fileName.endsWith("xls") ? new HSSFWorkbook(fileIn) : new XSSFWorkbook(fileIn); + + int rowCount = ci.dataTableModel.getRowCount(); + System.out.println("dataVector.len:" + rowCount);// dataVector.size()); + + Integer sheetIndex = 0, row = 3, maxrow = 22, pageSize = 20, vecSize = rowCount;// dataVector.size(); + Integer sheetCount = 0; + if (vecSize <= pageSize) { + sheetCount = 1; + } else { + sheetCount = vecSize / pageSize + (vecSize % pageSize == 0 ? 0 : 1); + } + + System.out.println("Sheet count:" + sheetCount); + + XSSFPrintSetup srcPrintSetup = null; + if (workbook instanceof XSSFWorkbook) { + srcPrintSetup = (XSSFPrintSetup) workbook.getSheetAt(0).getPrintSetup(); + } + for (int i = 1; i < sheetCount; i++) { + Sheet s = workbook.cloneSheet(0); + if (srcPrintSetup != null) { + XSSFPrintSetup printSetup = (XSSFPrintSetup) s.getPrintSetup(); + printSetup.setOrientation(srcPrintSetup.getOrientation()); + printSetup.setPaperSize(srcPrintSetup.getPaperSize()); + } + } + Sheet sheet = workbook.getSheetAt(sheetIndex); + workbook.setSheetName(sheetIndex, "" + (++sheetIndex) + "ҳ"); + writeSignoff(sheet); + for (int i = 0; i < rowCount; i++) { + // Map map = dataVector.get(i); + // ci.dataTableModel.getValueAt(i, arg1).toString(); + if (!(ci.dataTableModel.getValueAt(i, 2).toString().startsWith("WG"))) { +// sheet.getRow(row).getCell(0).setCellValue(++index); + sheet.getRow(row).getCell(0).setCellValue(ci.dataTableModel.getValueAt(i, 0) == null ? "" : ci.dataTableModel.getValueAt(i, 0).toString()); + // nullpointer kk + sheet.getRow(row).getCell(1).setCellValue(ci.dataTableModel.getValueAt(i, 1) == null ? "" : ci.dataTableModel.getValueAt(i, 1).toString()); + sheet.getRow(row).getCell(2).setCellValue(ci.dataTableModel.getValueAt(i, 2) == null ? "" : ci.dataTableModel.getValueAt(i, 2).toString()); + if (selectTypeTemplate == 1) { + sheet.getRow(row).getCell(6).setCellValue(ci.dataTableModel.getValueAt(i, 4) == null ? "" : ci.dataTableModel.getValueAt(i, 4).toString()); + sheet.getRow(row).getCell(10).setCellValue(ci.dataTableModel.getValueAt(i, 5) == null ? "" : ci.dataTableModel.getValueAt(i, 5).toString()); + sheet.getRow(row).getCell(11).setCellValue(ci.dataTableModel.getValueAt(i, 6) == null ? "" : ci.dataTableModel.getValueAt(i, 6).toString()); + sheet.getRow(row).getCell(12).setCellValue(ci.dataTableModel.getValueAt(i, 7) == null ? "" : ci.dataTableModel.getValueAt(i, 7).toString()); + sheet.getRow(row).getCell(13).setCellValue(ci.dataTableModel.getValueAt(i, 8) == null ? "" : ci.dataTableModel.getValueAt(i, 8).toString()); + } else if (selectTypeTemplate == 2) { + sheet.getRow(row).getCell(4).setCellValue(ci.dataTableModel.getValueAt(i, 3) == null ? "" : ci.dataTableModel.getValueAt(i, 3).toString()); + sheet.getRow(row).getCell(7).setCellValue(ci.dataTableModel.getValueAt(i, 4) == null ? "" : ci.dataTableModel.getValueAt(i, 4).toString()); + sheet.getRow(row).getCell(10).setCellValue(ci.dataTableModel.getValueAt(i, 5) == null ? "" : ci.dataTableModel.getValueAt(i, 5).toString()); + sheet.getRow(row).getCell(11).setCellValue(ci.dataTableModel.getValueAt(i, 6) == null ? "" : ci.dataTableModel.getValueAt(i, 6).toString()); + sheet.getRow(row).getCell(12).setCellValue(ci.dataTableModel.getValueAt(i, 7) == null ? "" : ci.dataTableModel.getValueAt(i, 7).toString()); + sheet.getRow(row).getCell(13).setCellValue(ci.dataTableModel.getValueAt(i, 8) == null ? "" : ci.dataTableModel.getValueAt(i, 8).toString()); + } + row++; + } + if (row > maxrow && sheetIndex < sheetCount) { + row = 3; + sheet = workbook.getSheetAt(sheetIndex); + workbook.setSheetName(sheetIndex, "" + (++sheetIndex) + "ҳ"); + writeSignoff(sheet); + } + } + for (int i = 0; i < sheetCount; i++) { + sheet = workbook.getSheetAt(i); + sheet.getRow(23).getCell(3).setCellValue(itemName); + sheet.getRow(23).getCell(12).setCellValue(topItemId); + sheet.getRow(24).getCell(12).setCellValue(itemId); + sheet.getRow(26).getCell(12).setCellValue(" " + sheetCount + " ҳ " + (i + 1) + " ҳ"); + } + + sheet = workbook.createSheet(""); + Row dataRow = sheet.createRow(0); + dataRow.createCell(0); + dataRow.createCell(1); + sheet.getRow(0).getCell(0).setCellValue(""); + sheet.getRow(0).getCell(1).setCellValue("ͼĿ¼"); + + dataRow = sheet.createRow(1); + dataRow.createCell(0); + dataRow.createCell(1); + sheet.getRow(1).getCell(0).setCellValue("û"); + iTextField textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_CustomerName"); + sheet.getRow(1).getCell(1).setCellValue(textfieldForm.getText()); + + dataRow = sheet.createRow(2); + dataRow.createCell(0); + dataRow.createCell(1); + sheet.getRow(2).getCell(0).setCellValue(";"); + JComboBox cbx = (JComboBox) fu.allComponentMap.get("ysr8_Use"); + sheet.getRow(2).getCell(1).setCellValue(cbx.getSelectedItem().toString()); + + dataRow = sheet.createRow(3); + dataRow.createCell(0); + dataRow.createCell(1); + sheet.getRow(3).getCell(0).setCellValue("ṹ"); + cbx = (JComboBox) fu.allComponentMap.get("ysr8_StructureType"); + System.out.println("ysr8_StructureTypeؼ=" + (cbx == null ? "" : cbx.getSelectedItem().toString())); + sheet.getRow(3).getCell(1).setCellValue(cbx.getSelectedItem().toString()); + + dataRow = sheet.createRow(4); + dataRow.createCell(0); + dataRow.createCell(1); + sheet.getRow(4).getCell(0).setCellValue("ֶ/Զ"); + cbx = (JComboBox) fu.allComponentMap.get("ysr8_AutoMation"); + System.out.println("ysr8_AutoMationؼ=" + (cbx == null ? "" : cbx.getSelectedItem().toString())); + sheet.getRow(4).getCell(1).setCellValue(cbx.getSelectedItem().toString()); + + dataRow = sheet.createRow(5); + dataRow.createCell(0); + dataRow.createCell(1); + sheet.getRow(5).getCell(0).setCellValue("㺸/"); + cbx = (JComboBox) fu.allComponentMap.get("ysr8_ProductType"); + System.out.println("ysr8_ProductTypeؼ=" + (cbx == null ? "" : cbx.getSelectedItem().toString())); + sheet.getRow(5).getCell(1).setCellValue(cbx.getSelectedItem().toString()); + + dataRow = sheet.createRow(6); + dataRow.createCell(0); + dataRow.createCell(1); + sheet.getRow(6).getCell(0).setCellValue("װ峤(mm)"); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_BoardLength"); + System.out.println("ysr8_BoardLengthؼ=" + (cbx == null ? "" : textfieldForm.getText())); + sheet.getRow(6).getCell(1).setCellValue(textfieldForm.getText()); + + dataRow = sheet.createRow(7); + dataRow.createCell(0); + dataRow.createCell(1); + sheet.getRow(7).getCell(0).setCellValue("װbase(mm)"); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_BoardWidth"); + System.out.println("ysr8_BoardWidthؼ=" + (cbx == null ? "" : textfieldForm.getText())); + sheet.getRow(7).getCell(1).setCellValue(textfieldForm.getText()); + + dataRow = sheet.createRow(8); + dataRow.createCell(0); + dataRow.createCell(1); + sheet.getRow(8).getCell(0).setCellValue(""); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_PartQuantity"); + sheet.getRow(8).getCell(1).setCellValue(textfieldForm.getText()); + + dataRow = sheet.createRow(9); + dataRow.createCell(0); + dataRow.createCell(1); + sheet.getRow(9).getCell(0).setCellValue(""); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_CylindersQuantity"); + System.out.println("ysr8_CylindersQuantityؼ=" + (cbx == null ? "" : textfieldForm.getText())); + sheet.getRow(9).getCell(1).setCellValue(textfieldForm.getText()); + + dataRow = sheet.createRow(10); + dataRow.createCell(0); + dataRow.createCell(1); + sheet.getRow(10).getCell(0).setCellValue("׷滻ͼֽ"); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_AddOrReplaceQuantity"); + System.out.println("ysr8_CylindersQuantityؼ=" + (cbx == null ? "" : textfieldForm.getText())); + sheet.getRow(10).getCell(1).setCellValue(textfieldForm.getText()); + // kk + dataRow = sheet.createRow(11); + dataRow.createCell(0); + dataRow.createCell(1); + sheet.getRow(11).getCell(0).setCellValue("ע"); + JTextArea textArea = (JTextArea) fu.allComponentMap.get("ysr8_Remark"); + System.out.println("ysr8_Remarkؼ=" + (cbx == null ? "" : textArea.getText())); + sheet.getRow(11).getCell(1).setCellValue(textArea.getText()); + //TODO + if(!main) { + dataRow = sheet.createRow(12); + dataRow.createCell(0); + dataRow.createCell(1); + sheet.getRow(12).getCell(0).setCellValue("Ƽ"); + textfieldForm = (iTextField) fu.allComponentMap.get("dzjCount"); + System.out.println("dzjCountؼ=" + (cbx == null ? "" : textfieldForm.getText())); + sheet.getRow(12).getCell(1).setCellValue(textfieldForm.getText()); + } + + FileOutputStream fileOut = new FileOutputStream(toPath); + workbook.write(fileOut); + fileOut.flush(); + fileOut.close(); + // MessageBox.post("ɹ!","ʾ",MessageBox.INFORMATION); + // 򿪵ıļ + Runtime.getRuntime().exec("cmd /c \"" + toPath + "\""); + + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (fileIn != null) { + try { + fileIn.close(); + } catch (Exception e) { + // Auto-generated catch block + e.printStackTrace(); + } + } + } + } + + // kk + private void writeSignoff(Sheet sheet) { + try { + String[] data = this.currentForm.getProperties(new String[] { "owning_user", "ysr8_DesignDirector", "ysr8_DesignChief", "ysr8_ChiefDate" }); + sheet.getRow(23).getCell(1).setCellValue(data[0]); + sheet.getRow(24).getCell(1).setCellValue(data[1]); + sheet.getRow(25).getCell(1).setCellValue(data[2]); + sheet.getRow(26).getCell(1).setCellValue(data[3]); + } catch (TCException e) { + System.out.println("дǩ"); + e.printStackTrace(); + } + + } + + @SuppressWarnings("unchecked") + private void ChangeComboBoxState_ysr8_Use() { + JComboBoxInfo ci = (JComboBoxInfo) fu.allComponentInfos.get("ysr8_Use"); + JComboBox cbx = (JComboBox) fu.allComponentMap.get("ysr8_Use"); + String ysr8_UseVal = cbx.getSelectedItem().toString(); + String ysr8_StructureType = ""; + try { + System.out.println("ysr8_CustomerName = " + fu.tcForm.getProperty("ysr8_CustomerName")); + System.out.println("ysr8_UseVal = " + ysr8_UseVal); + ysr8_StructureType = fu.tcForm.getProperty("ysr8_StructureType"); + System.out.println("ysr8_StructureType = " + ysr8_StructureType); + } catch (TCException e) { + e.printStackTrace(); + } + if (ysr8_UseVal.equals("") || ci.lovVal == null) { + return; + } + Iterator iter = ci.lovVal.keySet().iterator(); + while (iter.hasNext()) { + String lovKey = iter.next(); + String lovValue = ci.lovVal.get(lovKey); + if (lovValue.equalsIgnoreCase(ysr8_UseVal)) { + + JComboBoxInfo ci1 = (JComboBoxInfo) fu.allComponentInfos.get("ysr8_StructureType"); + JComboBox cbx1 = (JComboBox) fu.allComponentMap.get("ysr8_StructureType"); + System.out.println("ci1.valueName = " + lovKey); + ci1.valueName = lovKey; + ci1.lovVal = null; + cbx1.removeAllItems(); + cbx1.addItem(""); + fu.getlovValues(ci1); + ci1.lovVal = TCUtil.getlovValues(fu.session, lovKey); + if (ci1.lovVal != null && ci1.lovVal.size() > 0) { + for (Entry entry : ci1.lovVal.entrySet()) { + cbx1.addItem(entry.getValue()); + } + } + cbx1.setSelectedIndex(0); + if (ci1.lovVal.get(ysr8_StructureType) == null || ci1.lovVal.get(ysr8_StructureType).equals("")) { + cbx1.setSelectedItem(ysr8_StructureType); + } else { + cbx1.setSelectedItem(ci1.lovVal.get(ysr8_StructureType)); + } + break; + } + } + } + + private void loadDZJ(JTableInfo mi) throws Exception { + JTable table = mi.dataTable; + JTableInfo ci = (JTableInfo) fu.allComponentInfos.get("a.131.11.11"); + DefaultTableModel model = ci.dataTableModel; + String[] dzj = currentForm.getTCProperty("ysr8_dzjIds").getStringArrayValue(); + int dzjCount = 0; + HashSet idset = new HashSet<>(); + for(int i=0; i table2Map; + + public YSR8_ECN1RevisionMasterForm(TCComponentForm arg0) throws Exception { + super(arg0); + form = arg0; + AIFComponentContext[] context1 = form.whereReferencedByTypeRelation + (new String[] { "YSR8_ECN1Revision" }, new String[] { "IMAN_master_form" }); + if (!(context1 != null && context1.length > 0)) { + return; + } + ecn1Rev = (TCComponentItemRevision) context1[0].getComponent(); + ecn1Item = ecn1Rev.getItem(); + table2Map = new HashMap<>(); + table2Map.put("", 1);// + table2Map.put("ID", 4); + table2Map.put("Ƿ", 9); + + Date currDate = new Date(); + if (refreshDate == null) { + arg0.refresh(); + refreshDate = currDate; + } else { + long diff = currDate.getTime() - refreshDate.getTime(); + long minutes = diff / 1000 / 60; + if (minutes >= 1) { + arg0.refresh(); + refreshDate = currDate; + } + } + + fu.readRenderingXML("YSR8_ECN1RevisionMasterForm"); + fu.initializeUI(arg0); + + JTable table = (JTable) fu.allComponentMap.get("ecn1.141.11.11"); + // table.setAutoCreateRowSorter(true); + TableRowSorter sorter = new TableRowSorter(table.getModel()); + /* + * ArrayList sortKeys = new ArrayList(); + * sortKeys.add(new RowSorter.SortKey(1, SortOrder.ASCENDING)); + * sorter.setSortKeys(sortKeys); + */ + table.setRowSorter(sorter); + table.setFocusable(true); + table.setRowSelectionAllowed(true); + table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); +// System.out.println("table.setRowSorter(sorter)"); + + addActionListener(); + loadRendering(); + getDefVal(); + + int count = ((JTable) fu.allComponentMap.get("a.151.11.11")).getRowCount(); + if(count>0) { + int[] rows = new int[count]; + for(int i=0; i 0) { + TCComponentItemRevision ecn1Revision = (TCComponentItemRevision) context1[0].getComponent(); + TCComponentItem ecn1Item = ecn1Revision.getItem(); + + iTextField textfieldForm; + textfieldForm = (iTextField) fu.allComponentMap.get("Item_ID"); + textfieldForm.setText(ecn1Item.getProperty("item_id")); + } + + fu.loadRendering(); + + fcu = new FormCheckUtil(fu.tcForm, fu.allComponentMap); + fcu.checkHandler(); + JTable table = (JTable) fu.allComponentMap.get("ecn1.141.11.11"); +// table.setEnabled(true); + table.setRowSelectionAllowed(true); + } + + public void setRenderingReadOnly() { + setModifiableComponents(this, false); + if (getController() != null) + getController().setFormReadOnly(); + + JButton btn = (JButton) fu.allComponentMap.get("b.141.12.51"); + if (btn != null) { + btn.setEnabled(true); + if (btn.getParent() != null) + btn.getParent().setEnabled(true); + if (btn.getParent().getParent() != null) + btn.getParent().getParent().setEnabled(true); + } + btn = (JButton) fu.allComponentMap.get("b.141.12.61"); + if (btn != null) { + btn.setEnabled(true); + if (btn.getParent() != null) + btn.getParent().setEnabled(true); + if (btn.getParent().getParent() != null) + btn.getParent().getParent().setEnabled(true); + } + JTable table = (JTable) fu.allComponentMap.get("ecn1.141.11.11"); + table.setEnabled(true); + table = (JTable)fu.allComponentMap.get("a.151.11.11"); + table.setEnabled(true); + + } + + public void setRenderingReadWrite() { + if (fcu != null && fcu.isNeedCheck()) { + fcu.setEnable(); + fu.isCheckOut = true; + return; + } + setModifiableComponents(this, true); + + fu.allComponentMap.get("ysr8_TechFinishDate").setEnabled(false); + fu.allComponentMap.get("ysr8_PurchFinishDate").setEnabled(false); + fu.allComponentMap.get("ysr8_ChangeReason").setEnabled(false); + fu.allComponentMap.get("ysr8_ChangeReason1").setEnabled(false); + + JTable table = (JTable) fu.allComponentMap.get("ecn1.141.11.11"); + table.setEnabled(true); +// table.setCellEditor(anEditor); + table.setRowSelectionAllowed(true); + + ChangeComboBoxState_ysr8_ChangeReason(); + } + + private void setModifiableComponents(java.awt.Component currcomponent, boolean flag) { + if (fcu != null && flag) { + if (fcu.isNeedCheck()) { + return; + } + } + fu.setModifiableComponents(currcomponent, flag); + } + + /** + * (non-Javadoc) + * + * @see com.teamcenter.rac.form.AbstractTCForm#saveForm() + */ + @Override + public void saveRendering() { + if (!checkCanSave()) { + return; + } + countYsr8_SubTotalExpense(); + // try { + // if (fu.tcForm.getDoubleProperty("ysr8_TotalExpense") == 0.0) { + // countYsr8_TotalExpense(); + // } + // } catch (TCException e) { + // e.printStackTrace(); + // return; + // } + countYsr8_TotalExpense(); + + Integer idx = 0; + JTable table = (JTable) fu.allComponentMap.get("ecn1.141.11.11"); + for (int i = 0; i < table.getRowCount(); i++) { + table.setValueAt((++idx), i, 0);// + } + + try { + fu.saveRendering(); + } catch (TCException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } catch (ParseException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } + + linkPR(); + } + + public boolean isRenderingModified() { + return fu.isRenderingModified(); + } + + @SuppressWarnings("unchecked") + private void addActionListener() { + { + JComboBox cbx = (JComboBox) fu.allComponentMap.get("ysr8_ChangeReason"); + cbx.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent itemevent) { + if (itemevent.getStateChange() == ItemEvent.SELECTED) { + ChangeComboBoxState_ysr8_ChangeReason(); + } + } + }); + } + ////////////////////////////////////////////////////// + { + JButton btn = (JButton) fu.allComponentMap.get("b.061.16"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + countYsr8_TotalExpense(); + } + }); + } + ////////////////////////////////////////////////////// + { + JButton btn = (JButton) fu.allComponentMap.get("b.141.12.11"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + extractBom(); + } + }); + } + ////////////////////////////////////////////////////// + { + JButton btn = (JButton) fu.allComponentMap.get("b.141.12.21"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("ecn1.141.11.11"); + Object[] objData = new Object[ci.childComponentInfos.size()]; + for (int i = 0; i < objData.length; i++) { + objData[i] = ""; + } + ci.dataTableModel.addRow(objData); + } + }); + + btn = (JButton) fu.allComponentMap.get("b.141.12.31"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("ecn1.141.11.11"); + JTable table = (JTable) fu.allComponentMap.get("ecn1.141.11.11"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪƳУ", "ʾ", MessageBox.INFORMATION); + return; + } + for (int i = rows.length - 1; i >= 0; i--) { + ci.dataTableModel.removeRow(table.convertRowIndexToModel(rows[i])); + } + } + }); + + btn = (JButton) fu.allComponentMap.get("b.141.12.41"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("ecn1.141.11.11"); + try { + for (int i = 0; i < ci.dataTableModel.getRowCount(); i++) { + ci.dataTableModel.setValueAt(Integer.toString(i + 1), i, 0); + + String ysr8_MaterialID = ""; + if (ci.dataTableModel.getValueAt(i, 1) != null) { + ysr8_MaterialID = ci.dataTableModel.getValueAt(i, 1).toString(); + } + if (ysr8_MaterialID.equals("")) { + continue; + } + + // String ysr8_MaterialName = ""; + // if (ci.dataTableModel.getValueAt(i, 2) != null) { + // ysr8_MaterialName = ci.dataTableModel.getValueAt(i, 2).toString(); + // } + // if (!ysr8_MaterialName.equals("")) { + // continue; + // } + + TCComponentItem materialItem = TCUtil.findItemByID(fu.session, ysr8_MaterialID); + if (materialItem == null) { + continue; + } + TCComponentItemRevision materialRevision = materialItem.getLatestItemRevision(); + TCComponentForm materialForm = TCUtil.getItemRevisionMasterForm(materialRevision); + String object_name = materialRevision.getStringProperty("object_name"); + String ysr8_summary1 = materialForm.getStringProperty("ysr8_summary1"); + String uom_tag = materialItem.getProperty("uom_tag"); + String ysr8_Brand1 = materialForm.getStringProperty("ysr8_Brand1"); + + ci.dataTableModel.setValueAt(object_name, i, 2); + ci.dataTableModel.setValueAt(ysr8_summary1, i, 3); + ci.dataTableModel.setValueAt(uom_tag, i, 5); + ci.dataTableModel.setValueAt(ysr8_Brand1, i, 6); + } + } catch (TCException ex) { + ex.printStackTrace(); + } + } + }); + + btn = (JButton) fu.allComponentMap.get("b.141.12.51"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + updatePartItemECN(); + } + }); + + btn = (JButton) fu.allComponentMap.get("b.141.12.61"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + outputExcel(); + } + }); + + btn = (JButton) fu.allComponentMap.get("b.151.12.11");//TODO Ӱť + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + int option=JOptionPane.showOptionDialog(null, "ȷͬ񣬱ݻ", "ʾ", + JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE, null, new String[] {"ȷ","ȡ"}, ""); +// System.out.println("value:"+option); + if(option == 0) { + FormUtil.JTableInfo t2 = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.151.11.11");// + if(t2.dataTableModel.getRowCount()>0) + for(int i=t2.dataTableModel.getRowCount(); i>0; i--) + t2.dataTableModel.removeRow(i-1); + + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("ecn1.141.11.11"); + if(ci.dataTableModel.getRowCount()>0) { + JTable table = (JTable) fu.allComponentMap.get("ecn1.141.11.11"); + for(int i=0; i temp2 = new Vector<>(); + temp2.add(getTableValue(table, i, 0));// + temp2.add(getTableValue(table, i, 1));//ƷID + temp2.add(getTableValue(table, i, 3));//ͺ/ͼ + temp2.add(getTableValue(table, i, 2));// + temp2.add("");//ID + temp2.add("");//ɹʼƻʱ + temp2.add("");//ɹҪʱ + temp2.add("");//ɹʵʱ + temp2.add("");//ɹԭ + temp2.add("");//Ƿ + temp2.add("");//ļƻʱ + t2.dataTableModel.addRow(temp2); + } + } + } + } + }); + + btn = (JButton) fu.allComponentMap.get("b.151.12.21"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + JTable table = (JTable) fu.allComponentMap.get("a.151.11.11"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪƳУ", "ʾ", MessageBox.INFORMATION); + return; + } + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.151.11.11"); + for (int i = rows.length - 1; i >= 0; i--) { + boolean only = true; + for(int j=0; j temp2 = new Vector<>(); + temp2.add("");// + temp2.add(getTableValue(table, rows[0], 1));//ƷID + temp2.add(getTableValue(table, rows[0], 2));//ͺ/ͼ + temp2.add(getTableValue(table, rows[0], 3));// + temp2.add("");//ID + temp2.add("");//ɹʼƻʱ + temp2.add("");//ɹҪʱ + temp2.add("");//ɹʵʱ + temp2.add("");//ɹԭ + temp2.add("");//Ƿ + temp2.add("");//ļƻʱ + ci.dataTableModel.insertRow(rows[0]+1, temp2); + for(int i=0; i1) { + for(int i : rows) { + if(!getTableValue(table, rows[0], table2Map.get("ID")) + .equals(getTableValue(table, i, table2Map.get("ID")))) { + MessageBox.post("ѡаͬ޷༭", "ʾ", MessageBox.INFORMATION); + return; + } + if(!getTableValue(table, i, table2Map.get("Ƿ")).equals("")) { + MessageBox.post("ѡаδУ޷༭", "ʾ", MessageBox.INFORMATION); + return; + } + } + } + String[] lovs = TCUtil.getPreference(form.getSession(), TCPreferenceService.TC_preference_site, "YSR8_Ecn13DelayReason_LOV"); + final JDialog dialog = new JDialog(AIFUtility.getActiveDesktop().getFrame(), true); + dialog.setTitle("༭"); + JLabel label = new JLabel("ɹԭ"); + dialog.add(label); + label.setBounds(20, 20, 80, 24); +// final JTextArea area = new JTextArea(); +// area.setLineWrap(true); + final JComboBox area = new JComboBox<>(); + area.addItem(""); + if(lovs!=null && lovs.length>0) + for(String s : lovs) + area.addItem(s); + area.setEditable(true); + area.setBounds(100, 20, 200, 24); + dialog.add(area); + JButton btn1 = new JButton("ȷ"); + btn1.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent arg0) { + if(area.getSelectedItem().toString().isEmpty()) { + MessageBox.post("дɹԭ", "ʾ", MessageBox.WARNING); + return; + } + for(int i : rows) { + table.setValueAt(area.getSelectedItem().toString(), i, 8); + } + dialog.dispose(); + } + }); + dialog.add(btn1); + btn1.setBounds(20, 100, 80, 24); + JButton btn2 = new JButton("ȡ"); + btn2.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent arg0) { + dialog.dispose(); + } + }); + dialog.add(btn2); + btn2.setBounds(220, 100, 80, 24); + dialog.add(new JLabel("")); + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + dialog.setBounds((screenSize.width - 350)/2, (screenSize.height - 200)/2, 350, 200); + dialog.setVisible(true); + + } + }); + + btn = (JButton) fu.allComponentMap.get("b.151.12.61"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { +// FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.151.11.11"); + JTable table = (JTable) fu.allComponentMap.get("a.151.11.11"); + final int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪУ", "ʾ", MessageBox.INFORMATION); + return; + } + if(rows.length>1) { + Set set = new HashSet<>(); + for(int i : rows) { + if(set.contains(getTableValue(table, i, table2Map.get("")))) { + MessageBox.post("ͬһIJͬвͬ", "ʾ", MessageBox.INFORMATION); + return; + }else + set.add(getTableValue(table, i, table2Map.get(""))); + } + } + final JDialog dialog = new JDialog(AIFUtility.getActiveDesktop().getFrame(), true); + dialog.setTitle(""); + final JComboBox combo = new JComboBox<>(); + final Map techMap = new HashMap<>(); + final Map purchMap = new HashMap<>(); + try { + AIFComponentContext[] context2 = ecn1Item.whereReferencedByTypeRelation(new String[] { "YSR8_PRRevision" }, new String[] { "YSR8_ChangeForm" }); + if (context2 != null && context2.length > 0) { + for(int i=0; i cbx1 = (JComboBox) fu.allComponentMap.get("ysr8_ChangeReason"); + if (cbx1.getSelectedItem().toString().equals("G")) { + // fu.allComponentMap.get("ysr8_ChangeReasonDesc").setEnabled(true); + } else { + // fu.allComponentMap.get("ysr8_ChangeReasonDesc").setEnabled(false); + + if (cbx1.getSelectedItem().toString().equals("F")) { + fu.allComponentMap.get("ysr8_NeedSaleConfirm").setEnabled(true); + fu.allComponentMap.get("ysr8_Description").setEnabled(true); + } else { + fu.allComponentMap.get("ysr8_NeedSaleConfirm").setEnabled(false); + fu.allComponentMap.get("ysr8_Description").setEnabled(false); + } + } + } + + public void getDefVal() { + try { + if (!fu.tcForm.getStringProperty("ysr8_ProjectCode").equals("")) { + return; + } + + AIFComponentContext[] context1 = fu.tcForm.whereReferencedByTypeRelation(new String[] { "YSR8_ECN1Revision" }, new String[] { "IMAN_master_form" }); + if (!(context1 != null && context1.length > 0)) { + return; + } + TCComponentItemRevision ecn1Revision = (TCComponentItemRevision) context1[0].getComponent(); + TCComponentItem ecn1Item = ecn1Revision.getItem(); + + AIFComponentContext[] context2 = ecn1Item.whereReferencedByTypeRelation(new String[] { "YSR8_PRRevision" }, new String[] { "YSR8_ChangeForm" }); + if (context2 != null && context2.length > 0) {// ⱨ + TCComponentItemRevision prRevision = (TCComponentItemRevision) context2[0].getComponent(); + setPropsInPR(prRevision); + return; + } + // kk ͨļ + AIFComponentContext[] context4 = ecn1Item.whereReferencedByTypeRelation(new String[] { "Folder" }, null); + TCComponentFolder folder = null; + List projIds = new ArrayList<>(); + if (context4 != null && context4.length > 0) { + for (AIFComponentContext c : context4) { + folder = (TCComponentFolder) c.getComponent(); + String projId = folder.getStringProperty("project_ids"); + if (projId != null && !"".equals(projId)) { + for (String id : projId.split(",")) { + if (!projIds.contains(id)) { + projIds.add(id); + } + } + } + } + if (projIds.size() == 0) { + return; + } + if (projIds.size() > 1) { + System.out.println("***********************ͬʱҵĿļ************************"); + for (String string : projIds) { + System.out.println("ҵļָĿ" + string); + } + return; + } + setPropsInNormalFolder(projIds.get(0)); + return; + } + // еĿ汾Ŀ汾 + AIFComponentContext[] context3 = ecn1Item.whereReferencedByTypeRelation(new String[] { "YSR8_MachPartsRevision" }, new String[] { "YSR8_ChangeRecord" }); + if (context3 == null || context3.length <= 0) { + context3 = ecn1Item.whereReferencedByTypeRelation(new String[] { "YSR8_ElecPartsRevision" }, new String[] { "YSR8_ChangeRecord" }); + if (context3 == null || context3.length <= 0) { + return; + } + } + String projectId = ""; + TCComponentItemRevision partItemRevision = null; + TCComponentItem partItem = null; + for (int i = 0; i < context3.length; i++) { + if (context3[i].getComponent() instanceof TCComponentItemRevision) { + partItemRevision = (TCComponentItemRevision) context3[i].getComponent(); + String type = partItemRevision.getType(); + if (type.equals("YSR8_MachPartsRevision") || type.equals("YSR8_ElecPartsRevision")) { + partItem = partItemRevision.getItem(); + projectId = partItem.getProperty("project_ids"); + } + break; + } + } + if (projectId.equals("")) { + return; + } + + HashMap propValueMap = new HashMap(); + propValueMap.put("ysr8_ProjectCode", projectId); + + TCComponentItem xmqdItem = TCUtil.findItemByID(fu.session, projectId + "_XMQD"); + if (xmqdItem != null) { + TCComponentItemRevision xmqdRevision = xmqdItem.getLatestItemRevision(); + TCComponentForm xmqdForm = TCUtil.getItemRevisionMasterForm(xmqdRevision); + + List propList = new ArrayList(); + propList.add("ysr8_ProjectName"); + propList.add("ysr8_CustomerName"); + propList.add("ysr8_ProjectManager"); + propList.add("ysr8_DesignDirector"); + propList.add("ysr8_ElectricDirector"); + for (String prop : propList) { + String propValue = ""; + TCFormProperty property1 = (TCFormProperty) xmqdForm.getFormTCProperty(prop); + switch (property1.getPropertyType()) { + case TCProperty.PROP_string: + case TCProperty.PROP_long_string: + propValue = xmqdForm.getStringProperty(prop); + break; + case TCProperty.PROP_short: + case TCProperty.PROP_int: + propValue = Integer.toString(xmqdForm.getIntProperty(prop)); + break; + case TCProperty.PROP_double: + case TCProperty.PROP_float: + propValue = fu.getDoubleString(xmqdForm.getDoubleProperty(prop)); + break; + case TCProperty.PROP_date: + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date date = xmqdForm.getDateProperty(prop); + if (date != null) { + propValue = sdf.format(date); + } + break; + default: + propValue = xmqdForm.getStringProperty(prop); + break; + } + propValueMap.put(prop, propValue); + } + } + + propValueMap.put("ysr8_SubProjectCode", partItem.getProperty("item_id")); + propValueMap.put("ysr8_SubProjectName", partItem.getProperty("object_name")); + String object_type = partItem.getProperty("object_type"); + + iTextField textfieldForm; + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ProjectCode"); + textfieldForm.setText(propValueMap.get("ysr8_ProjectCode")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ProjectName"); + textfieldForm.setText(propValueMap.get("ysr8_ProjectName")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_CustomerName"); + textfieldForm.setText(propValueMap.get("ysr8_CustomerName")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ProjectManager"); + textfieldForm.setText(propValueMap.get("ysr8_ProjectManager")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_SubProjectCode"); + textfieldForm.setText(propValueMap.get("ysr8_SubProjectCode")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_SubProjectName"); + textfieldForm.setText(propValueMap.get("ysr8_SubProjectName")); + + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_DesignDirector"); + if (object_type.equals("еĿ")) { + textfieldForm.setText(propValueMap.get("ysr8_DesignDirector")); + } else if (object_type.equals("Ŀ")) { + textfieldForm.setText(propValueMap.get("ysr8_ElectricDirector")); + } + } catch (TCException ex) { + ex.printStackTrace(); + } + } + + // kk YSR8_ProjectFormеԴͼֽĵ + private void setPropsInNormalFolder(String projectId) throws TCException { + System.out.println("ʼͬYSR8_ProjectForm project id = " + projectId); + HashMap propValueMap = new HashMap(); + propValueMap.put("ysr8_ProjectCode", projectId); + + // TCComponentSchedule schedule = TCUtil.findScheduleByID(fu.session, projectId + // + "-00"); + // if (schedule != null) { + // TCComponentForm projectForm = + // (TCComponentForm)schedule.getRelatedComponent("IMAN_reference"); + // if (projectForm != null) { + // } + TCComponentItem xmqdItem = TCUtil.findItemByID(fu.session, projectId + "_XMQD"); + if (xmqdItem != null) { + TCComponentItemRevision xmqdRevision = xmqdItem.getLatestItemRevision(); + TCComponentForm xmqdForm = TCUtil.getItemRevisionMasterForm(xmqdRevision); + + List propList = new ArrayList(); + propList.add("ysr8_ProjectName"); + propList.add("ysr8_CustomerName"); + propList.add("ysr8_ProjectManager"); + propList.add("ysr8_DesignDirector"); + for (String prop : propList) { + String propValue = ""; + TCFormProperty property1 = (TCFormProperty) xmqdForm.getFormTCProperty(prop); + switch (property1.getPropertyType()) { + case TCProperty.PROP_string: + case TCProperty.PROP_long_string: + propValue = xmqdForm.getStringProperty(prop); + break; + case TCProperty.PROP_short: + case TCProperty.PROP_int: + propValue = Integer.toString(xmqdForm.getIntProperty(prop)); + break; + case TCProperty.PROP_double: + case TCProperty.PROP_float: + propValue = fu.getDoubleString(xmqdForm.getDoubleProperty(prop)); + break; + case TCProperty.PROP_date: + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date date = xmqdForm.getDateProperty(prop); + if (date != null) { + propValue = sdf.format(date); + } + break; + default: + propValue = xmqdForm.getStringProperty(prop); + break; + } + propValueMap.put(prop, propValue); + } + } + iTextField textfieldForm; + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ProjectCode"); + textfieldForm.setText(propValueMap.get("ysr8_ProjectCode")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ProjectName"); + textfieldForm.setText(propValueMap.get("ysr8_ProjectName")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_CustomerName"); + textfieldForm.setText(propValueMap.get("ysr8_CustomerName")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ProjectManager"); + textfieldForm.setText(propValueMap.get("ysr8_ProjectManager")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_DesignDirector"); + textfieldForm.setText(propValueMap.get("ysr8_DesignDirector")); + + } + + // kk ȡ + private void setPropsInPR(TCComponentItemRevision prRevision) throws TCException { + TCComponentForm prForm = (TCComponentForm) prRevision.getRelatedComponent("IMAN_master_form_rev"); + if (prForm == null) { + return; + } + + List propList = new ArrayList(); + propList.add("ysr8_ProjectCode"); + propList.add("ysr8_ProjectName"); + propList.add("ysr8_ProjectManager"); + propList.add("ysr8_StationNo"); + propList.add("ysr8_DesignDirector"); + propList.add("ysr8_ElectricDirector"); + propList.add("ysr8_TechPlanDate"); + propList.add("ysr8_PurchPlanDate"); + HashMap propValueMap = new HashMap(); + for (String prop : propList) { + String propValue = ""; + TCFormProperty property1 = (TCFormProperty) prForm.getFormTCProperty(prop); + switch (property1.getPropertyType()) { + case TCProperty.PROP_string: + case TCProperty.PROP_long_string: + propValue = prForm.getStringProperty(prop); + break; + case TCProperty.PROP_short: + case TCProperty.PROP_int: + propValue = Integer.toString(prForm.getIntProperty(prop)); + break; + case TCProperty.PROP_double: + case TCProperty.PROP_float: + propValue = fu.getDoubleString(prForm.getDoubleProperty(prop)); + break; + case TCProperty.PROP_date: + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date date = prForm.getDateProperty(prop); + if (date != null) { + propValue = sdf.format(date); + } + break; + default: + propValue = prForm.getStringProperty(prop); + break; + } + propValueMap.put(prop, propValue); + } + + propValueMap.put("ysr8_CustomerName", ""); + String ysr8_ProjectCodeVal = propValueMap.get("ysr8_ProjectCode"); + if (!ysr8_ProjectCodeVal.equals("")) { + TCComponentItem xmqdItem = TCUtil.findItemByID(fu.session, ysr8_ProjectCodeVal + "_XMQD"); + if (xmqdItem != null) { + TCComponentItemRevision xmqdRevision = xmqdItem.getLatestItemRevision(); + TCComponentForm xmqdForm = TCUtil.getItemRevisionMasterForm(xmqdRevision); + propValueMap.put("ysr8_CustomerName", xmqdForm.getStringProperty("ysr8_CustomerName")); + } + } + + propValueMap.put("ysr8_SubProjectName", ""); + String ysr8_SubProjectCodeVal = propValueMap.get("ysr8_StationNo"); + if (!ysr8_SubProjectCodeVal.equals("")) { + TCComponentItem item = TCUtil.findItemByID(fu.session, ysr8_SubProjectCodeVal); + if (item != null) { + String object_name = item.getProperty("object_name"); + propValueMap.put("ysr8_SubProjectName", object_name); + } + } + + iTextField textfieldForm; + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ProjectCode"); + textfieldForm.setText(propValueMap.get("ysr8_ProjectCode")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ProjectName"); + textfieldForm.setText(propValueMap.get("ysr8_ProjectName")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_CustomerName"); + textfieldForm.setText(propValueMap.get("ysr8_CustomerName")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ProjectManager"); + textfieldForm.setText(propValueMap.get("ysr8_ProjectManager")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_SubProjectCode"); + textfieldForm.setText(propValueMap.get("ysr8_StationNo")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_SubProjectName"); + textfieldForm.setText(propValueMap.get("ysr8_SubProjectName")); + + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_DesignDirector"); + if (ysr8_SubProjectCodeVal.startsWith("SW")) { + textfieldForm.setText(propValueMap.get("ysr8_DesignDirector")); + } else if (ysr8_SubProjectCodeVal.startsWith("SE")) { + textfieldForm.setText(propValueMap.get("ysr8_ElectricDirector")); + } + + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_TechPlanDate"); + textfieldForm.setText(propValueMap.get("ysr8_TechPlanDate")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_PurchPlanDate"); + textfieldForm.setText(propValueMap.get("ysr8_PurchPlanDate")); + } + + public boolean checkCanSave() { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + { + // DateButton datebtn = + // (DateButton)fu.allComponentMap.get("ysr8_TechFinishDate"); + // Date date1 = datebtn.getDate(); + // iTextField textfield = + // (iTextField)fu.allComponentMap.get("ysr8_TechPlanDate"); + // Date date2 = null; + // try { + // if (!textfield.getText().equals("")) { + // date2 = sdf.parse(textfield.getText()); + // } + // } catch (ParseException e) { + // e.printStackTrace(); + // } + // if (date1 != null && date2 != null) { + // iTextField text = (iTextField)fu.allComponentMap.get("ysr8_TechReasonDesc"); + // String string = text.getText(); + // if (date1.getTime() < date2.getTime() && string.equals("")) { + // MessageBox.post("ڡʵʱ䡱ڡƻʱ䡱Աдԭ...", "ʾ", + // MessageBox.INFORMATION); + // return false; + // } + // } + } + { + DateButton datebtn = (DateButton) fu.allComponentMap.get("ysr8_PurchFinishDate"); + Date date1 = datebtn.getDate(); + iTextField textfield = (iTextField) fu.allComponentMap.get("ysr8_PurchPlanDate"); + Date date2 = null; + try { + if (!textfield.getText().equals("")) { + date2 = sdf.parse(textfield.getText()); + } + } catch (ParseException e) { + e.printStackTrace(); + } + if (date1 != null && date2 != null) { + iTextField text = (iTextField) fu.allComponentMap.get("ysr8_PurchReasonDesc"); + String string = text.getText(); + if (date1.getTime() > date2.getTime() && string.equals("")) { + MessageBox.post("ڡɹʵʱ䡱ڡҪɹʱ䡱Աдԭ...", "ʾ", MessageBox.INFORMATION); + return false; + } + } + } + JTable table = (JTable) fu.allComponentMap.get("ecn1.141.11.11"); + JTable table2 = (JTable) fu.allComponentMap.get("a.151.11.11"); + Set idSet = new HashSet<>(); + for(int i=0; i 0) { + MessageBox.post("ϸݣȡBOMݣ", "ʾ", MessageBox.INFORMATION); + return; + } + + iTextField textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_SubProjectCode"); + String ysr8_SubProjectCodeVal = textfieldForm.getText(); + if (ysr8_SubProjectCodeVal.equals("")) { + MessageBox.post("ĿΪգ޷ȡBOMݣ", "ʾ", MessageBox.INFORMATION); + return; + } + + TCComponentItemRevision ecn1Revision = null; + + TCComponentItemRevision beforeBomRevision, afterBomRevision; + TCComponentBOMLine beforeBomLine, afterBomLine; + Vector beforeComps, afterComps; + Set beforeSet, afterSet; + Map beforeMap, afterMap; + + Map resultMap; + + try { + AIFComponentContext[] context1 = fu.tcForm.whereReferencedByTypeRelation(new String[] { "YSR8_ECN1Revision" }, new String[] { "IMAN_master_form" }); + if (context1 == null || context1.length <= 0) { + return; + } + ecn1Revision = (TCComponentItemRevision) context1[0].getComponent(); + + TCComponentPseudoFolder folder1 = TCUtil.getRevisionPseudoFolder(ecn1Revision, "ǰ㲿"); + beforeBomRevision = TCUtil.getPseudoItem2(folder1, ysr8_SubProjectCodeVal); + if (beforeBomRevision == null) { + MessageBox.post("ǰûҵĿ޷ȡBOMݣ", "ʾ", MessageBox.INFORMATION); + return; + } + beforeBomLine = TCUtil.getBOMLine(fu.session, beforeBomRevision); + if (beforeBomLine == null) { + MessageBox.post("ǰĿͼΪգ޷ȡBOMݣ", "ʾ", MessageBox.INFORMATION); + return; + } + TCComponentPseudoFolder folder2 = TCUtil.getRevisionPseudoFolder(ecn1Revision, "ĺ㲿"); + afterBomRevision = TCUtil.getPseudoItem2(folder2, ysr8_SubProjectCodeVal); + if (afterBomRevision == null) { + MessageBox.post("ĺûҵĿ޷ȡBOMݣ", "ʾ", MessageBox.INFORMATION); + return; + } + afterBomLine = TCUtil.getBOMLine(fu.session, afterBomRevision); + if (afterBomLine == null) { + MessageBox.post("ĺĿͼΪգ޷ȡBOMݣ", "ʾ", MessageBox.INFORMATION); + return; + } + + beforeComps = new Vector(); + beforeMap = new LinkedHashMap<>(); + Map beforeMapItemId = new LinkedHashMap(); + beforeSet = new HashSet(); + + afterComps = new Vector(); + afterMap = new LinkedHashMap<>(); + Map afterMapItemId = new LinkedHashMap(); + afterSet = new HashSet(); + + TCUtil.getBOMLineChildComps(beforeBomLine, beforeComps, beforeMap, beforeMapItemId, beforeSet); + TCUtil.getBOMLineChildComps(afterBomLine, afterComps, afterMap, afterMapItemId, afterSet); + + System.out.println("beforeBomLine.len:" + beforeComps.size()); + System.out.println("afterBomLine.len:" + afterComps.size()); + + resultMap = new HashMap(); + + + System.out.println("ǰ㲿BOMLineChild="+beforeMap.size()); + System.out.println("ĺ㲿BOMLineChild="+afterMap.size()); + + + for (Map.Entry beforeEntry : beforeMap.entrySet()) { + String key = beforeEntry.getKey(); + System.out.println("1_beforeMap ["+key+"] : ["+beforeMap.get(key)+"]"); + System.out.println("1_afterMap ["+key+"] : ["+afterMap.get(key)+"]"); + if (afterMap.containsKey(key)) { + System.out.println("1"); + Object compResult = TCUtil.compareBOMLineQuantity(beforeMap.get(key), afterMap.get(key)); + if (compResult instanceof double[]) { + System.out.println("2"); + double[] ds = (double[]) compResult; + resultMap.put(afterMap.get(key), ds[1] - ds[0]); + } + } + } + for (Map.Entry afterEntry : afterMap.entrySet()) { + String key = afterEntry.getKey(); + System.out.println("afterMap "+key+":"+afterMap.get(key)); + if (beforeMap.containsKey(key)) { + System.out.println("3"); + } else { + System.out.println("4"); + resultMap.put(afterMap.get(key), TCUtil.totalBOMLineQuantity(afterMap.get(key))); + } + } + + String ysr8_ReasonAnalysisVal = ""; + TCComponentItem ecn1Item = ecn1Revision.getItem(); + AIFComponentContext[] context2 = ecn1Item.whereReferencedByTypeRelation(new String[] { "YSR8_PRRevision" }, new String[] { "YSR8_ChangeForm" }); + if (context2 != null && context2.length > 0) {// ⱨ + TCComponentItemRevision prRevision = (TCComponentItemRevision) context2[0].getComponent(); + TCComponentForm prForm = (TCComponentForm) prRevision.getRelatedComponent("IMAN_master_form_rev"); + if (prForm != null) { + ysr8_ReasonAnalysisVal = prForm.getProperty("ysr8_ReasonAnalysis"); + } + } + + Integer idx = 0; + List> dataList = new ArrayList<>();// kk + Map prodIdMap = new HashMap<>(); + + System.out.println("resultMap.size="+resultMap.size()); + + for (Map.Entry entry : resultMap.entrySet()) { + TCComponentBOMLine bomline = entry.getKey(); + TCComponentItemRevision itemRevision = bomline.getItemRevision(); + TCComponentForm form = TCUtil.getItemRevisionMasterForm(itemRevision); + String bl_item_item_id = bomline.getProperty("bl_item_item_id"); + String changeToPurch = bomline.getProperty("YSR8_ChangeToPurch"); + String isPurch = form.getProperty("ysr8_IsPurch"); + String objectType = bomline.getItem().getProperty("object_type"); + boolean isAdd = false; + if (objectType.equals("ɹ") && isPurch.equals("")) { + isAdd = true; + } else if (objectType.equals("׼") && changeToPurch.equals("")) { + isAdd = true; + } else if (objectType.equals("Ԫ") && isPurch.equals("")) { + isAdd = true; + } + if (isAdd && bl_item_item_id.startsWith("WG")) { + isAdd = false; + } + if (isAdd) { + Vector vec = new Vector<>(); + vec.add((++idx) + "");// + String prodId = bomline.getProperty("bl_item_item_id"); + if (prodId != null && !"".equals(prodId)) { + prodId = prodId.split("_P")[0]; // ȡ_P֮ǰ + if (!prodIdMap.containsKey(prodId)) { // ¼ + prodIdMap.put(prodId, entry.getValue()); + } else { + prodIdMap.put(prodId, prodIdMap.get(prodId) + entry.getValue()); + } + } + vec.add(prodId);// ƷID + vec.add(bomline.getProperty("bl_item_object_name"));// + vec.add(form.getProperty("ysr8_summary1"));// ͺ/ͼ + vec.add(fu.getDoubleString(entry.getValue()));// + vec.add(bomline.getProperty("bl_uom"));// λ + vec.add(form.getProperty("ysr8_Brand1"));// Ʒ + vec.add(ysr8_ReasonAnalysisVal);// ԭ + vec.add("");// + vec.add("");// + vec.add("");// ãԪ + vec.add("");// Ƿ񷢼ӹ + vec.add("");// ԭ + vec.add("");// + vec.add("");// Ʒɹʱ + // kk ci.dataTableModel.addRow(vec); + dataList.add(vec); + } + } + + // kk ʼ + int n = dataList.size(); + Vector temp; + for (int i = 0; i < n; i++) { + for (int j = 0; j < n - i - 1; j++) { + if (dataList.get(j).get(1).compareTo(dataList.get(j + 1).get(1)) > 0) { + temp = dataList.get(j); + dataList.set(j, dataList.get(j + 1)); + dataList.set(j + 1, temp); + } + } + } + FormUtil.JTableInfo t2 = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.151.11.11");//ձ2 + if(t2.dataTableModel.getRowCount()>0) + for(int i=t2.dataTableModel.getRowCount(); i>0; i--) + t2.dataTableModel.removeRow(i-1); + + // ±д + int newIndex = 1; + DecimalFormat df = new DecimalFormat("#"); + for (int i = 0; i < n; i++) { + temp = dataList.get(i); + String prodId = temp.get(1); + if (prodIdMap.containsKey(prodId) && prodIdMap.get(prodId) != null) {// ± + temp.set(0, (newIndex++) + ""); + temp.set(4, df.format(prodIdMap.get(prodId))); + ci.dataTableModel.addRow(temp); + prodIdMap.put(prodId, null);// ñǡnull + + Vector temp2 = new Vector<>();//TODO д2 + temp2.add(temp.get(0));// + temp2.add(temp.get(1));//ƷID + temp2.add(temp.get(3));//ͺ/ͼ + temp2.add(temp.get(2));// + temp2.add("");//ID + temp2.add("");//ɹʼƻʱ + temp2.add("");//ɹҪʱ + temp2.add("");//ɹʵʱ + temp2.add("");//ɹԭ + temp2.add("");//Ƿ + temp2.add("");//ļƻʱ + t2.dataTableModel.addRow(temp2); + } + } + + } catch (TCException ex) { + ex.printStackTrace(); + } + } + + public void countYsr8_SubTotalExpense() { + double ysr8_SubTotalExpense = 0.0; + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("ecn1.141.11.11"); + for (int i = 0; i < ci.dataTableModel.getRowCount(); i++) { + // kk 0803 TODO к˰ Զ㷢 + Object numStr = ci.dataTableModel.getValueAt(i, 4); + Object priceStr = ci.dataTableModel.getValueAt(i, 9); + if (numStr != null && priceStr != null && !"".equals(numStr) && !"".equals(priceStr)) { + double num = Double.parseDouble(numStr.toString()); + double price = Double.parseDouble(priceStr.toString()); + double expense = num * price; + String propValue = fu.getDoubleString(expense); + if (propValue.startsWith(".")) { + propValue = "0" + propValue; + } + ci.dataTableModel.setValueAt(propValue, i, 10); + ysr8_SubTotalExpense += expense; + } + /* + * if (ci.dataTableModel.getValueAt(i, 9) != null) { String expense = + * ci.dataTableModel.getValueAt(i, 9).toString(); if (!expense.equals("")) { + * ysr8_SubTotalExpense += Double.parseDouble(expense); } } + */ + } + String propValue = fu.getDoubleString(ysr8_SubTotalExpense); + /* + * if (propValue.startsWith(".")) { propValue = "0" + propValue; } + */ + iTextField textField = (iTextField) fu.allComponentMap.get("ysr8_SubTotalExpense"); + textField.setText(propValue); + } + + public void countYsr8_TotalExpense() { + JButton btn = (JButton) fu.allComponentMap.get("b.061.16"); + btn.setEnabled(false); + + countYsr8_SubTotalExpense(); + iTextField textField = (iTextField) fu.allComponentMap.get("ysr8_SubTotalExpense"); + String ysr8_SubTotalExpense = textField.getText(); + double ysr8_SubTotalExpenseVal = 0.0; + if (!ysr8_SubTotalExpense.equals("")) { + ysr8_SubTotalExpenseVal = Double.parseDouble(ysr8_SubTotalExpense); + } + + double ysr8_TotalExpense = ysr8_SubTotalExpenseVal; + String projectCode = ""; + try { + iTextField ysr8_ProjectCode = (iTextField) fu.allComponentMap.get("ysr8_ProjectCode"); + projectCode = ysr8_ProjectCode.getText(); + if (projectCode.equals("")) { + btn.setEnabled(true); + return; + } + + String[] attrs = new String[1]; + String[] vals = new String[1]; + attrs[0] = "ysr8_ProjectCode"; + vals[0] = projectCode; + TCComponent[] tcComponents = TCUtil.query(fu.session, "SearchECN1", attrs, vals); + if (tcComponents != null) { + for (int i = 0; i < tcComponents.length; i++) { + TCComponentItemRevision ecn1ItemRevision = (TCComponentItemRevision) tcComponents[i]; + TCComponentForm ecn1Form = TCUtil.getItemRevisionMasterForm(ecn1ItemRevision); + ysr8_TotalExpense += ecn1Form.getDoubleProperty("ysr8_SubTotalExpense"); + } + } + + tcComponents = TCUtil.query(fu.session, "SearchECN2", attrs, vals); + if (tcComponents != null) { + for (int i = 0; i < tcComponents.length; i++) { + TCComponentItemRevision ecn2ItemRevision = (TCComponentItemRevision) tcComponents[i]; + TCComponentForm ecn2Form = TCUtil.getItemRevisionMasterForm(ecn2ItemRevision); + ysr8_TotalExpense += ecn2Form.getDoubleProperty("ysr8_SubTotalExpense"); + } + } + } catch (TCException e) { + e.printStackTrace(); + btn.setEnabled(true); + return; + } + + String propValue = fu.getDoubleString(ysr8_TotalExpense); + textField = (iTextField) fu.allComponentMap.get("ysr8_TotalExpense"); + textField.setText(propValue); + btn.setEnabled(true); + } + + public void linkPR() { + try { + AIFComponentContext[] context1 = fu.tcForm.whereReferencedByTypeRelation(new String[] { "YSR8_ECN1Revision" }, new String[] { "IMAN_master_form" }); + if (context1 != null && context1.length > 0) { + TCComponentItemRevision ecn1Revision = (TCComponentItemRevision) context1[0].getComponent(); + TCComponentItem ecn1Item = ecn1Revision.getItem(); + + AIFComponentContext[] context2 = ecn1Item.whereReferencedByTypeRelation(new String[] { "YSR8_PRRevision" }, new String[] { "YSR8_ChangeForm" }); + if (context2 != null && context2.length > 0) {// ĵ + for(int i=0; i 0) { + for(int j=0; j0) { + Date date = tasks[0].getDateProperty("fnd0finish_date"); + Calendar calendar = new GregorianCalendar(); + calendar.setTime(date); + calendar.add(Calendar.DATE, 1); + date = calendar.getTime(); + sheet.getRow(8).getCell(2).setCellValue(date); + } + + + TCComponentProject project = null; + try { + project = (TCComponentProject) ecn1Rev.getReferenceListProperty("project_list")[0]; + } catch (Exception e) { + // TODO: handle exception + MessageBox.post("IDΪ"+ecn1Rev.getStringProperty("item_id")+"δָĿ","ʾ",2); + return; + } + + List team = project.getTeam(); + TCComponent[] members = (TCComponent[])team.get(0); + System.out.println("members" + members.length); + for(TCComponent c : members) { + if(c instanceof TCComponentGroupMember) { + TCComponentGroupMember member = (TCComponentGroupMember)c; + String role = member.getRole().getStringProperty("role_name"); +// System.out.println("role" + role); + if(role.equals("Purcher")) {//ɹ + sheet.getRow(8).getCell(4).setCellValue(member.getUser().getProperty("user_name"));// ɹԱ + break; + } + } + } + + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("ecn1.141.11.11"); + if (ci.dataTableModel.getRowCount() > 0) { + if (ci.dataTableModel.getRowCount() > 1) { + POIUtil.insertRow(sheet, 10, ci.dataTableModel.getRowCount() - 1); + } + String cl = new StringBuilder("CL").append(ysr8_ProjectCodeVal.substring(0, 2)).append(ysr8_ProjectCodeVal.substring(ysr8_ProjectCodeVal.length()-4)) + .append(id.substring(id.lastIndexOf("-"))).append("-").toString(); + int currRowIdx = 10; + for (int i = 0; i < ci.dataTableModel.getRowCount(); i++) { + XSSFRow row = sheet.getRow(currRowIdx); + row.getCell(0).setCellValue(ci.dataTableModel.getValueAt(i, 0) == null ? "" : ci.dataTableModel.getValueAt(i, 0).toString()); + row.getCell(1).setCellValue(ci.dataTableModel.getValueAt(i, 1) == null ? "" : ci.dataTableModel.getValueAt(i, 1).toString()); + row.getCell(2).setCellValue(ci.dataTableModel.getValueAt(i, 2) == null ? "" : ci.dataTableModel.getValueAt(i, 2).toString()); + row.getCell(3).setCellValue(ci.dataTableModel.getValueAt(i, 3) == null ? "" : ci.dataTableModel.getValueAt(i, 3).toString()); + row.getCell(4).setCellValue(ci.dataTableModel.getValueAt(i, 4) == null ? "" : ci.dataTableModel.getValueAt(i, 4).toString()); + row.getCell(5).setCellValue(ci.dataTableModel.getValueAt(i, 5) == null ? "" : ci.dataTableModel.getValueAt(i, 5).toString()); + row.getCell(6).setCellValue(ci.dataTableModel.getValueAt(i, 6) == null ? "" : ci.dataTableModel.getValueAt(i, 6).toString()); + row.getCell(7).setCellValue(ci.dataTableModel.getValueAt(i, 11) == null ? "" : ci.dataTableModel.getValueAt(i, 11).toString()); + //20230928 6 Ӧ 006 + + row.getCell(9).setCellValue(cl + new DecimalFormat("000").format(ci.dataTableModel.getValueAt(i, 0) == null ? i+1 : Integer.parseInt(ci.dataTableModel.getValueAt(i, 0).toString())));// CL + currRowIdx++; + } + } + + fileOut = new FileOutputStream(reportFile.getPath()); + workbook.write(fileOut); + fileOut.flush(); + + Runtime.getRuntime().exec("cmd /c \"" + reportFile.getPath() + "\""); + } catch (Exception e) { + e.printStackTrace(); + }finally { + if(fileOut!=null) { + try { + fileOut.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + private void refrashTable2(int[] rows, boolean update) {// 2ʾ + JTable table = (JTable) fu.allComponentMap.get("ecn1.141.11.11"); + Map map2 = new HashMap<>(); + for(int i=0; i0"); + c.setTime(getDate(machPlan)); + c.add(Calendar.DAY_OF_MONTH, day); + table2.setValueAt(fu.getDateString(c.getTime()), i, 6); + } + Date machAsk = c.getTime(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date ask = sdf.parse(fu.getDateString(machAsk)+" 23:59:59"); + if(machFinish.isEmpty()) { + if(!ask.after(new Date())) + table2.setValueAt("", i, table2Map.get("Ƿ")); + else + table2.setValueAt("", i, table2Map.get("Ƿ")); + }else { + if(!ask.after(getDate(machFinish.substring(0, 10)))) + table2.setValueAt("", i, table2Map.get("Ƿ")); + else + table2.setValueAt("", i, table2Map.get("Ƿ")); + System.out.println(machAsk+"=="+machFinish+"=="+table2.getValueAt(i, table2Map.get("Ƿ"))); + } + } + } + }catch(Exception e) { + e.printStackTrace(); + } + } + private Date getDate(String s) throws ParseException { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + if(s==null || s.isEmpty()) + return null; + if(s.length()>10) + sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + return sdf.parse(s); + } + private String getTableValue(JTable table, int r, int c) { + if(table.getValueAt(r, c)==null) + return ""; + else + return table.getValueAt(r, c).toString(); + } +} diff --git a/src/cn/com/ebewin/ysr/form/YSR8_ECN2RevisionMasterForm.java b/src/cn/com/ebewin/ysr/form/YSR8_ECN2RevisionMasterForm.java new file mode 100644 index 0000000..487ab68 --- /dev/null +++ b/src/cn/com/ebewin/ysr/form/YSR8_ECN2RevisionMasterForm.java @@ -0,0 +1,1905 @@ +package cn.com.ebewin.ysr.form; + +import java.awt.Dimension; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.MouseEvent; +import java.io.File; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Comparator; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Vector; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JDialog; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.commands.open.OpenFormDialog; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentPseudoFolder; +import com.teamcenter.rac.kernel.TCException;// +import com.teamcenter.rac.kernel.TCFormProperty; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.iTextField; + +import cn.com.ebewin.ysr.dialog.ProgressReporterDialog; +import cn.com.ebewin.ysr.dialog.YSR8_ECN2RevisionMasterEditDialog; +import cn.com.ebewin.ysr.util.CommonUtil; +import cn.com.ebewin.ysr.util.FormCheckUtil; +import cn.com.ebewin.ysr.util.FormUtil; +import cn.com.ebewin.ysr.util.TCUtil; +import jxl.Workbook; +import jxl.format.Alignment; +import jxl.format.Border; +import jxl.format.BorderLineStyle; +import jxl.format.VerticalAlignment; +import jxl.write.Label; +import jxl.write.WritableCellFormat; +import jxl.write.WritableFont; +import jxl.write.WritableSheet; +import jxl.write.WritableWorkbook; + +@SuppressWarnings("deprecation") +public class YSR8_ECN2RevisionMasterForm extends AbstractRendering { + private static final long serialVersionUID = 1L; + private static Date refreshDate = null; + + FormUtil fu = new FormUtil(this); + FormCheckUtil fcu = null; + TCComponentForm form = null; + TCComponentItem ecn2Item = null; + + private Map table2Map; + + public YSR8_ECN2RevisionMasterForm(TCComponentForm arg0) throws Exception { + super(arg0); + form = arg0; + + AIFComponentContext[] context1 = form.whereReferencedByTypeRelation + (new String[] { "YSR8_ECN2Revision" }, new String[] { "IMAN_master_form" }); + if (!(context1 != null && context1.length > 0)) { + return; + } + ecn2Item = ((TCComponentItemRevision) context1[0].getComponent()).getItem(); + table2Map = new HashMap<>(); + table2Map.put("", 2);// + table2Map.put("ID", 4); + table2Map.put("Ƿ", 10); + + Date currDate = new Date(); + if (refreshDate == null) { + arg0.refresh(); + refreshDate = currDate; + } else { + long diff = currDate.getTime() - refreshDate.getTime(); + long minutes = diff / 1000 / 60; + if (minutes >= 1) { + arg0.refresh(); + refreshDate = currDate; + } + } + + fu.readRenderingXML("YSR8_ECN2RevisionMasterForm"); + fu.initializeUI(arg0); + + JTable table = (JTable) fu.allComponentMap.get("a.141.11.11"); + table.setAutoCreateRowSorter(true); + TableRowSorter sorter = new TableRowSorter(table.getModel()); +// ArrayList sortKeys = new ArrayList(); +// sortKeys.add(new RowSorter.SortKey(2, SortOrder.ASCENDING)); +// sorter.setSortKeys(sortKeys); + sorter.setComparator(2, new Comparator() { + public int compare(Object object1, Object object2) { +// System.out.println(mapping1.getValue()+"=="+mapping2.getValue()+"--"+mapping1.getValue().compareTo(mapping2.getValue())); + String s1="", s2="", c1="", c2=""; + if(object1 != null) + s1 = object1.toString(); + if(object2 != null) + s2 = object2.toString(); +// System.out.println(s1+":"+s2); + if(s1.length()>1) + c1 = s1.substring(0, 2); + if(s2.length()>1) + c2 = s2.substring(0, 2); + if(c1.equals("SW") && !c2.equals("SW")) { +// System.out.println(s1+":"+s2+"==-1"); + return -1; + }else if(!c1.equals("SW") && c2.equals("SW")) { +// System.out.println(s1+":"+s2+"==1"); + return 1; + }else { +// System.out.println(s1+":"+s2+"=="+s1.compareTo(s2)); + return s1.compareTo(s2); + } + } + }); + table.setRowSorter(sorter); + + addActionListener(); + loadRendering(); + getDefVal(); + + int count = ((JTable) fu.allComponentMap.get("a.151.11.11")).getRowCount(); + if(count>0) { + int[] rows = new int[count]; + for(int i=0; i 0) { + TCComponentItemRevision ecn2Revision = (TCComponentItemRevision) context1[0].getComponent(); + TCComponentItem ecn2Item = ecn2Revision.getItem(); + + iTextField textfieldForm; + textfieldForm = (iTextField) fu.allComponentMap.get("Item_ID"); + textfieldForm.setText(ecn2Item.getProperty("item_id")); + } + + fu.loadRendering(); + + fcu = new FormCheckUtil(fu.tcForm, fu.allComponentMap); + fcu.checkHandler(); + } + + public void setRenderingReadOnly() { + setModifiableComponents(this, false); + if (getController() != null) + getController().setFormReadOnly(); + + JButton btn = (JButton) fu.allComponentMap.get("b.141.12.41"); + if (btn != null) { + btn.setEnabled(true); + if (btn.getParent() != null) + btn.getParent().setEnabled(true); + if (btn.getParent().getParent() != null) + btn.getParent().getParent().setEnabled(true); + } + btn = (JButton) fu.allComponentMap.get("b.141.12.51"); + if (btn != null) { + btn.setEnabled(true); + if (btn.getParent() != null) + btn.getParent().setEnabled(true); + if (btn.getParent().getParent() != null) + btn.getParent().getParent().setEnabled(true); + } + + JTable table = (JTable)fu.allComponentMap.get("a.141.11.11"); + table.setEnabled(true); + table = (JTable)fu.allComponentMap.get("a.151.11.11"); + table.setEnabled(true); + } + + public void setRenderingReadWrite() { + if (fcu != null && fcu.isNeedCheck()) { + fcu.setEnable(); + fu.isCheckOut = true; + return; + } + setModifiableComponents(this, true); + + fu.allComponentMap.get("ysr8_TechFinishDate").setEnabled(false); + fu.allComponentMap.get("ysr8_PurchFinishDate").setEnabled(false); + fu.allComponentMap.get("ysr8_ChangeReason").setEnabled(false); + fu.allComponentMap.get("ysr8_ChangeReason1").setEnabled(false); + fu.allComponentMap.get("b.061.16").setEnabled(false); + //kk 0809 Ԫ޸İťijǩִ + //fu.allComponentMap.get("b.141.12.61").setEnabled(false); + + ChangeComboBoxState_ysr8_ChangeReason(); + } + + private void setModifiableComponents(java.awt.Component currcomponent, boolean flag) { + if (fcu != null && flag) { + if (fcu.isNeedCheck()) { + return; + } + } + fu.setModifiableComponents(currcomponent, flag); + } + + @Override + public void saveRendering() { + if (!checkCanSave()) { + return; + } + countYsr8_SubTotalExpense(); + + countYsr8_TotalExpense(); + + Integer idx = 0; + JTable table = (JTable) fu.allComponentMap.get("a.141.11.11"); + for (int i = 0; i < table.getRowCount(); i++) { + table.setValueAt((++idx), i, 0);// + } + + try { + fu.saveRendering(); + + } catch (Exception ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } + + linkPR(); + + } + + public boolean isRenderingModified() { + return fu.isRenderingModified(); + } + + @SuppressWarnings("unchecked") + private void addActionListener() { + { + JComboBox cbx = (JComboBox) fu.allComponentMap.get("ysr8_ChangeReason"); + cbx.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent itemevent) { + if (itemevent.getStateChange() == ItemEvent.SELECTED) { + ChangeComboBoxState_ysr8_ChangeReason(); + } + } + }); + } + ////////////////////////////////////////////////////// + { + JButton btn = (JButton) fu.allComponentMap.get("b.061.16"); + btn.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + countYsr8_TotalExpense(); + } + }); + } + ////////////////////////////////////////////////////// + { + JButton btn = (JButton) fu.allComponentMap.get("b.141.12.11"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + extractBom(); + } + }); + } + ////////////////////////////////////////////////////// + { + JButton btn = (JButton) fu.allComponentMap.get("b.141.12.21"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.141.11.11"); + Object[] objData = new Object[ci.childComponentInfos.size()]; + for (int i = 0; i < objData.length; i++) { + if (i == 18) { // kk һ + objData[i] = "δ"; + } else { + objData[i] = ""; + } + } + ci.dataTableModel.addRow(objData); + } + }); + + btn = (JButton) fu.allComponentMap.get("b.141.12.31"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.141.11.11"); + JTable table = (JTable) fu.allComponentMap.get("a.141.11.11"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪƳУ", "ʾ", MessageBox.INFORMATION); + return; + } + for (int i = rows.length - 1; i >= 0; i--) { + ci.dataTableModel.removeRow(table.convertRowIndexToModel(rows[i])); + } + } + }); + + btn = (JButton) fu.allComponentMap.get("b.141.12.41"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + updatePartItemECN(); + } + }); + + btn = (JButton) fu.allComponentMap.get("b.141.12.51"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + OutputExcel(); + } + }); + + btn = (JButton) fu.allComponentMap.get("b.141.12.61"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + PartModify(); + } + }); + + btn = (JButton) fu.allComponentMap.get("b.151.12.11");//TODO Ӱť + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + int option=JOptionPane.showOptionDialog(null, "ȷͬ񣬱ݻ", "ʾ", + JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE, null, new String[] {"ȷ","ȡ"}, ""); +// System.out.println("value:"+option); + if(option == 0) { + FormUtil.JTableInfo t2 = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.151.11.11");// + if(t2.dataTableModel.getRowCount()>0) + for(int i=t2.dataTableModel.getRowCount(); i>0; i--) + t2.dataTableModel.removeRow(i-1); + + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.141.11.11"); + if(ci.dataTableModel.getRowCount()>0) { + JTable table = (JTable) fu.allComponentMap.get("a.141.11.11"); + for(int i=0; i temp2 = new Vector<>(); + temp2.add(getTableValue(table, i, 0));// + temp2.add(getTableValue(table, i, 1));//汾 + temp2.add(getTableValue(table, i, 2));// + temp2.add(getTableValue(table, i, 4));// + temp2.add("");//ID + temp2.add("");//ӹʼƻʱ + temp2.add("");//ӹҪʱ + temp2.add("");//ӹʵʱ + temp2.add("");//ӹԭ + temp2.add("");//ļƻʱ + temp2.add("");//Ƿ + t2.dataTableModel.addRow(temp2); + } + } + } + } + }); + + btn = (JButton) fu.allComponentMap.get("b.151.12.21"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + JTable table = (JTable) fu.allComponentMap.get("a.151.11.11"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪƳУ", "ʾ", MessageBox.INFORMATION); + return; + } + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.151.11.11"); + for (int i = rows.length - 1; i >= 0; i--) { + boolean only = true; + for(int j=0; j temp2 = new Vector<>(); + temp2.add("");// + temp2.add(getTableValue(table, rows[0], 1));//汾 + temp2.add(getTableValue(table, rows[0], 2));// + temp2.add(getTableValue(table, rows[0], 3));// + temp2.add("");//ID + temp2.add("");//ӹʼƻʱ + temp2.add("");//ӹҪʱ + temp2.add("");//ӹʵʱ + temp2.add("");//ӹԭ + temp2.add("");//ļƻʱ + temp2.add("");//Ƿ + ci.dataTableModel.insertRow(rows[0]+1, temp2); + for(int i=0; i1) { + for(int i : rows) { + if(!getTableValue(table, rows[0], table2Map.get("ID")) + .equals(getTableValue(table, i, table2Map.get("ID")))) { + MessageBox.post("ѡаͬ޷༭", "ʾ", MessageBox.INFORMATION); + return; + } + if(!getTableValue(table, i, table2Map.get("Ƿ")).equals("")) { + MessageBox.post("ѡаδУ޷༭", "ʾ", MessageBox.INFORMATION); + return; + } + } + } + String[] lovs = TCUtil.getPreference(form.getSession(), TCPreferenceService.TC_preference_site, "YSR8_Ecn24DelayReason_LOV"); + final JDialog dialog = new JDialog(AIFUtility.getActiveDesktop().getFrame(), true); + dialog.setTitle("༭"); + JLabel label = new JLabel("ӹԭ"); + dialog.add(label); + label.setBounds(20, 20, 80, 24); +// final JTextArea area = new JTextArea(); +// area.setLineWrap(true); + final JComboBox area = new JComboBox<>(); + area.addItem(""); + if(lovs!=null && lovs.length>0) + for(String s : lovs) + area.addItem(s); + area.setEditable(true); + area.setBounds(100, 20, 200, 24); + dialog.add(area); + JButton btn1 = new JButton("ȷ"); + btn1.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent arg0) { + if(area.getSelectedItem().toString().isEmpty()) { + MessageBox.post("дӹԭ", "ʾ", MessageBox.WARNING); + return; + } + for(int i : rows) { + table.setValueAt(area.getSelectedItem().toString(), i, 8); + } + dialog.dispose(); + } + }); + dialog.add(btn1); + btn1.setBounds(20, 100, 80, 24); + JButton btn2 = new JButton("ȡ"); + btn2.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent arg0) { + dialog.dispose(); + } + }); + dialog.add(btn2); + btn2.setBounds(220, 100, 80, 24); + dialog.add(new JLabel("")); + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + dialog.setBounds((screenSize.width - 350)/2, (screenSize.height - 200)/2, 350, 200); + dialog.setVisible(true); + + } + }); + + btn = (JButton) fu.allComponentMap.get("b.151.12.61"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { +// FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.151.11.11"); + JTable table = (JTable) fu.allComponentMap.get("a.151.11.11"); + final int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪУ", "ʾ", MessageBox.INFORMATION); + return; + } + if(rows.length>1) { + Set set = new HashSet<>(); + for(int i : rows) { + if(set.contains(getTableValue(table, i, table2Map.get("")))) { + MessageBox.post("ͬһIJͬвͬ", "ʾ", MessageBox.INFORMATION); + return; + }else + set.add(getTableValue(table, i, table2Map.get(""))); + } + } + final JDialog dialog = new JDialog(AIFUtility.getActiveDesktop().getFrame(), true); + dialog.setTitle(""); + final JComboBox combo = new JComboBox<>(); + final Map techMap = new HashMap<>(); + final Map machMap = new HashMap<>(); + try { + AIFComponentContext[] context2 = + ecn2Item.whereReferencedByTypeRelation(new String[] { "YSR8_PRRevision" }, new String[] { "YSR8_ChangeForm" }); + if (context2 != null && context2.length > 0) { + for(int i=0; i cbx1 = (JComboBox) fu.allComponentMap.get("ysr8_ChangeReason"); + if (cbx1.getSelectedItem().toString().equals("G")) { + // fu.allComponentMap.get("ysr8_ChangeReasonDesc").setEnabled(true); + } else { + // fu.allComponentMap.get("ysr8_ChangeReasonDesc").setEnabled(false); + + if (cbx1.getSelectedItem().toString().equals("F")) { + fu.allComponentMap.get("ysr8_NeedSaleConfirm").setEnabled(true); + fu.allComponentMap.get("ysr8_Description").setEnabled(true); + } else { + fu.allComponentMap.get("ysr8_NeedSaleConfirm").setEnabled(false); + fu.allComponentMap.get("ysr8_Description").setEnabled(false); + } + } + } + + private void setPropsInPR(TCComponentItemRevision prRevision) throws Exception { + // TCComponentItemRevision prRevision = (TCComponentItemRevision) + // context2[0].getComponent(); + TCComponentForm prForm = (TCComponentForm) prRevision.getRelatedComponent("IMAN_master_form_rev"); + if (prForm == null) { + return; + } + + List propList = new ArrayList(); + propList.add("ysr8_ProjectCode"); + propList.add("ysr8_ProjectName"); + propList.add("ysr8_ProjectManager"); + propList.add("ysr8_StationNo"); + propList.add("ysr8_DesignDirector"); + propList.add("ysr8_ElectricDirector"); + propList.add("ysr8_TechPlanDate"); + propList.add("ysr8_MachinPlanDate"); + HashMap propValueMap = new HashMap(); + for (String prop : propList) { + String propValue = ""; + TCFormProperty property1 = (TCFormProperty) prForm.getFormTCProperty(prop); + switch (property1.getPropertyType()) { + case TCProperty.PROP_string: + case TCProperty.PROP_long_string: + propValue = prForm.getStringProperty(prop); + break; + case TCProperty.PROP_short: + case TCProperty.PROP_int: + propValue = Integer.toString(prForm.getIntProperty(prop)); + break; + case TCProperty.PROP_double: + case TCProperty.PROP_float: + propValue = fu.getDoubleString(prForm.getDoubleProperty(prop)); + break; + case TCProperty.PROP_date: + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date date = prForm.getDateProperty(prop); + if (date != null) { + propValue = sdf.format(date); + } + break; + default: + propValue = prForm.getStringProperty(prop); + break; + } + propValueMap.put(prop, propValue); + } + + propValueMap.put("ysr8_CustomerName", ""); + String ysr8_ProjectCodeVal = propValueMap.get("ysr8_ProjectCode"); + if (!ysr8_ProjectCodeVal.equals("")) { + TCComponentItem xmqdItem = TCUtil.findItemByID(fu.session, ysr8_ProjectCodeVal + "_XMQD"); + if (xmqdItem != null) { + TCComponentItemRevision xmqdRevision = xmqdItem.getLatestItemRevision(); + TCComponentForm xmqdForm = TCUtil.getItemRevisionMasterForm(xmqdRevision); + propValueMap.put("ysr8_CustomerName", xmqdForm.getStringProperty("ysr8_CustomerName")); + } + } + + propValueMap.put("ysr8_SubProjectName", ""); + String ysr8_SubProjectCodeVal = propValueMap.get("ysr8_StationNo"); + if (!ysr8_SubProjectCodeVal.equals("")) { + TCComponentItem item = TCUtil.findItemByID(fu.session, ysr8_SubProjectCodeVal); + if (item != null) { + String object_name = item.getProperty("object_name"); + propValueMap.put("ysr8_SubProjectName", object_name); + } + } + + iTextField textfieldForm; + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ProjectCode"); + textfieldForm.setText(propValueMap.get("ysr8_ProjectCode")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ProjectName"); + textfieldForm.setText(propValueMap.get("ysr8_ProjectName")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_CustomerName"); + textfieldForm.setText(propValueMap.get("ysr8_CustomerName")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ProjectManager"); + textfieldForm.setText(propValueMap.get("ysr8_ProjectManager")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_SubProjectCode"); + textfieldForm.setText(propValueMap.get("ysr8_StationNo")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_SubProjectName"); + textfieldForm.setText(propValueMap.get("ysr8_SubProjectName")); + + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_DesignDirector"); + if (ysr8_SubProjectCodeVal.startsWith("SW")) { + textfieldForm.setText(propValueMap.get("ysr8_DesignDirector")); + } else if (ysr8_SubProjectCodeVal.startsWith("SE")) { + textfieldForm.setText(propValueMap.get("ysr8_ElectricDirector")); + } + + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_TechPlanDate"); + textfieldForm.setText(propValueMap.get("ysr8_TechPlanDate")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_PurchPlanDate"); + textfieldForm.setText(propValueMap.get("ysr8_MachinPlanDate")); + } + + // kk YSR8_ProjectFormеԴͼֽĵ + private void setPropsInNormalFolder(String projectId) throws Exception { + System.out.println("ʼͬYSR8_ProjectForm project id = " + projectId); + HashMap propValueMap = new HashMap(); + propValueMap.put("ysr8_ProjectCode", projectId); + + TCComponentItem xmqdItem = TCUtil.findItemByID(fu.session, projectId + "_XMQD"); + if (xmqdItem != null) { + TCComponentItemRevision xmqdRevision = xmqdItem.getLatestItemRevision(); + TCComponentForm xmqdForm = TCUtil.getItemRevisionMasterForm(xmqdRevision); + + List propList = new ArrayList(); + propList.add("ysr8_ProjectName"); + propList.add("ysr8_CustomerName"); + propList.add("ysr8_ProjectManager"); + propList.add("ysr8_DesignDirector"); + for (String prop : propList) { + String propValue = ""; + TCFormProperty property1 = (TCFormProperty) xmqdForm.getFormTCProperty(prop); + switch (property1.getPropertyType()) { + case TCProperty.PROP_string: + case TCProperty.PROP_long_string: + propValue = xmqdForm.getStringProperty(prop); + break; + case TCProperty.PROP_short: + case TCProperty.PROP_int: + propValue = Integer.toString(xmqdForm.getIntProperty(prop)); + break; + case TCProperty.PROP_double: + case TCProperty.PROP_float: + propValue = fu.getDoubleString(xmqdForm.getDoubleProperty(prop)); + break; + case TCProperty.PROP_date: + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date date = xmqdForm.getDateProperty(prop); + if (date != null) { + propValue = sdf.format(date); + } + break; + default: + propValue = xmqdForm.getStringProperty(prop); + break; + } + propValueMap.put(prop, propValue); + } + } + iTextField textfieldForm; + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ProjectCode"); + textfieldForm.setText(propValueMap.get("ysr8_ProjectCode")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ProjectName"); + textfieldForm.setText(propValueMap.get("ysr8_ProjectName")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_CustomerName"); + textfieldForm.setText(propValueMap.get("ysr8_CustomerName")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ProjectManager"); + textfieldForm.setText(propValueMap.get("ysr8_ProjectManager")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_DesignDirector"); + textfieldForm.setText(propValueMap.get("ysr8_DesignDirector")); + + } + + public void getDefVal() { + try { + if (!fu.tcForm.getStringProperty("ysr8_ProjectCode").equals("") && !fu.tcForm.getStringProperty("ysr8_ProjectName").equals("")) { + return; + } + AIFComponentContext[] context2 = + ecn2Item.whereReferencedByTypeRelation(new String[] { "YSR8_PRRevision" }, new String[] { "YSR8_ChangeForm" }); + if (context2 != null && context2.length > 0) {// ⱨ + TCComponentItemRevision prRevision = (TCComponentItemRevision) context2[0].getComponent(); + setPropsInPR(prRevision); + return; + } + // kk ͨļ + AIFComponentContext[] context4 = ecn2Item.whereReferencedByTypeRelation(new String[] { "Folder" }, null); + TCComponentFolder folder = null; + List projIds = new ArrayList<>(); + if (context4 != null && context4.length > 0) { + for (AIFComponentContext c : context4) { + folder = (TCComponentFolder) c.getComponent(); + String projId = folder.getStringProperty("project_ids"); + if (projId != null && !"".equals(projId)) { + for (String id : projId.split(",")) { + if (!projIds.contains(id)) { + projIds.add(id); + } + } + } + } + if (projIds.size() == 0) { + return; + } + if (projIds.size() > 1) { + System.out.println("***********************ͬʱҵĿļ************************"); + for (String string : projIds) { + System.out.println("ҵļָĿ" + string); + } + return; + } + setPropsInNormalFolder(projIds.get(0)); + return; + } + + AIFComponentContext[] context3 = + ecn2Item.whereReferencedByTypeRelation(new String[] { "YSR8_MachPartsRevision" }, new String[] { "YSR8_ChangeRecord" }); + if (context3 == null || context3.length <= 0) { + context3 = ecn2Item.whereReferencedByTypeRelation(new String[] { "YSR8_ElecPartsRevision" }, new String[] { "YSR8_ChangeRecord" }); + if (context3 == null || context3.length <= 0) { + return; + } + } + // Ŀļ + String projectId = ""; + TCComponentItemRevision partItemRevision = null; + TCComponentItem partItem = null; + for (int i = 0; i < context3.length; i++) { + if (context3[i].getComponent() instanceof TCComponentItemRevision) { + partItemRevision = (TCComponentItemRevision) context3[i].getComponent(); + String type = partItemRevision.getType(); + if (type.equals("YSR8_MachPartsRevision") || type.equals("YSR8_ElecPartsRevision")) { + partItem = partItemRevision.getItem(); + projectId = partItem.getProperty("project_ids"); + } + break; + } + } + System.out.println("projectId=============" + projectId); + if (projectId.equals("")) { + return; + } + + HashMap propValueMap = new HashMap(); + propValueMap.put("ysr8_ProjectCode", projectId); + + TCComponentItem xmqdItem = TCUtil.findItemByID(fu.session, projectId + "_XMQD"); + if (xmqdItem != null) { + TCComponentItemRevision xmqdRevision = xmqdItem.getLatestItemRevision(); + TCComponentForm xmqdForm = TCUtil.getItemRevisionMasterForm(xmqdRevision); + + List propList = new ArrayList(); + propList.add("ysr8_ProjectName"); + propList.add("ysr8_CustomerName"); + propList.add("ysr8_ProjectManager"); + propList.add("ysr8_DesignDirector"); + propList.add("ysr8_ElectricDirector"); + for (String prop : propList) { + String propValue = ""; + TCFormProperty property1 = (TCFormProperty) xmqdForm.getFormTCProperty(prop); + switch (property1.getPropertyType()) { + case TCProperty.PROP_string: + case TCProperty.PROP_long_string: + propValue = xmqdForm.getStringProperty(prop); + break; + case TCProperty.PROP_short: + case TCProperty.PROP_int: + propValue = Integer.toString(xmqdForm.getIntProperty(prop)); + break; + case TCProperty.PROP_double: + case TCProperty.PROP_float: + propValue = fu.getDoubleString(xmqdForm.getDoubleProperty(prop)); + break; + case TCProperty.PROP_date: + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date date = xmqdForm.getDateProperty(prop); + if (date != null) { + propValue = sdf.format(date); + } + break; + default: + propValue = xmqdForm.getStringProperty(prop); + break; + } + propValueMap.put(prop, propValue); + } + } + + propValueMap.put("ysr8_SubProjectCode", partItem.getProperty("item_id")); + propValueMap.put("ysr8_SubProjectName", partItem.getProperty("object_name")); + String object_type = partItem.getProperty("object_type"); + + iTextField textfieldForm; + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ProjectCode"); + textfieldForm.setText(propValueMap.get("ysr8_ProjectCode")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ProjectName"); + textfieldForm.setText(propValueMap.get("ysr8_ProjectName")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_CustomerName"); + textfieldForm.setText(propValueMap.get("ysr8_CustomerName")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ProjectManager"); + textfieldForm.setText(propValueMap.get("ysr8_ProjectManager")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_SubProjectCode"); + textfieldForm.setText(propValueMap.get("ysr8_SubProjectCode")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_SubProjectName"); + textfieldForm.setText(propValueMap.get("ysr8_SubProjectName")); + + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_DesignDirector"); + if (object_type.equals("еĿ")) { + textfieldForm.setText(propValueMap.get("ysr8_DesignDirector")); + } else if (object_type.equals("Ŀ")) { + textfieldForm.setText(propValueMap.get("ysr8_ElectricDirector")); + } + // } + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + public boolean checkCanSave() { + DateButton datebtn1 = (DateButton) fu.allComponentMap.get("ysr8_PurchFinishDate"); + Date date1 = datebtn1.getDate(); + iTextField textfield = (iTextField) fu.allComponentMap.get("ysr8_PurchPlanDate"); + Date date2 = null; + try { + if (!textfield.getText().equals("")) { + date2 = getDate(textfield.getText()); + } + } catch (Exception e) { + e.printStackTrace(); + } + if (date1 != null && date2 != null) { + iTextField text = (iTextField) fu.allComponentMap.get("ysr8_PurchReasonDesc"); + String string = text.getText(); + if (date1.getTime() < date2.getTime() && string.equals("")) { + MessageBox.post("ڡɹʵʱ䡱ڡҪɹʱ䡱Աдԭ...", "ʾ", MessageBox.INFORMATION); + return false; + } + } + JTable table = (JTable) fu.allComponentMap.get("a.141.11.11"); + JTable table2 = (JTable) fu.allComponentMap.get("a.151.11.11"); + Set idSet = new HashSet<>(); + for(int i=0; i 0) { + MessageBox.post("ϸݣȡBOMݣ", "ʾ", MessageBox.INFORMATION); + return; + } + + iTextField textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_SubProjectCode"); + String ysr8_SubProjectCodeVal = textfieldForm.getText(); + if (ysr8_SubProjectCodeVal.equals("")) { + MessageBox.post("ĿΪգ޷ȡBOMݣ", "ʾ", MessageBox.INFORMATION); + return; + } + + TCComponentItemRevision ecn2Revision = null; + + TCComponentItemRevision beforeBomRevision, afterBomRevision; + TCComponentBOMLine beforeBomLine, afterBomLine; + Vector beforeComps, afterComps; + Set beforeSet, afterSet; + Map beforeMap, afterMap; + + Map resultMap; + + try { + AIFComponentContext[] context1 = + fu.tcForm.whereReferencedByTypeRelation(new String[] { "YSR8_ECN2Revision" }, new String[] { "IMAN_master_form" }); + if (context1 == null || context1.length <= 0) { + return; + } + + ecn2Revision = (TCComponentItemRevision) context1[0].getComponent(); + + TCComponentPseudoFolder folder1 = TCUtil.getRevisionPseudoFolder(ecn2Revision, "ǰ㲿"); + beforeBomRevision = TCUtil.getPseudoItem2(folder1, ysr8_SubProjectCodeVal); + if (beforeBomRevision == null) { + MessageBox.post("ǰûҵĿ޷ȡBOMݣ", "ʾ", MessageBox.INFORMATION); + return; + } + beforeBomLine = TCUtil.getBOMLine(fu.session, beforeBomRevision); + if (beforeBomLine == null) { + MessageBox.post("ǰĿͼΪգ޷ȡBOMݣ", "ʾ", MessageBox.INFORMATION); + return; + } + TCComponentPseudoFolder folder2 = TCUtil.getRevisionPseudoFolder(ecn2Revision, "ĺ㲿"); + afterBomRevision = TCUtil.getPseudoItem2(folder2, ysr8_SubProjectCodeVal); + if (afterBomRevision == null) { + MessageBox.post("ĺûҵĿ޷ȡBOMݣ", "ʾ", MessageBox.INFORMATION); + return; + } + TCComponentItem afterBomItem = afterBomRevision.getItem(); + afterBomLine = TCUtil.getBOMLine(fu.session, afterBomRevision); + if (afterBomLine == null) { + MessageBox.post("ĺĿͼΪգ޷ȡBOMݣ", "ʾ", MessageBox.INFORMATION); + return; + } + + beforeComps = new Vector(); + beforeMap = new LinkedHashMap<>(); + Map beforeMapItemId = new LinkedHashMap(); + beforeSet = new HashSet(); + + afterComps = new Vector(); + afterMap = new LinkedHashMap<>(); + Map afterMapItemId = new LinkedHashMap(); + afterSet = new HashSet(); + + TCUtil.getBOMLineChildComps(beforeBomLine, beforeComps, beforeMap, beforeMapItemId, beforeSet); + TCUtil.getBOMLineChildComps(afterBomLine, afterComps, afterMap, afterMapItemId, afterSet); + + System.out.println("beforeBomLine.len:" + beforeComps.size()); + System.out.println("afterBomLine.len:" + afterComps.size()); + + resultMap = new LinkedHashMap(); + + for (Map.Entry beforeEntry : beforeMap.entrySet()) { + String key = beforeEntry.getKey(); + System.out.println("beforekey:"+key); + if (afterMap.containsKey(key)) { + if (TCUtil.compareBOMLineRevId(beforeMap.get(key), afterMap.get(key))) { + Object compResult = TCUtil.compareBOMLineQuantity(beforeMap.get(key), afterMap.get(key)); + if (compResult instanceof double[]) { + double[] ds = (double[]) compResult; + //lidy20180827ٵ㲿ʾ + if(ds[1]>ds[0]) { + resultMap.put(afterMap.get(key), ds[1] - ds[0]); + } + } + } else { + resultMap.put(afterMap.get(key), TCUtil.totalBOMLineQuantity(afterMap.get(key))); + } + } + } + for (Map.Entry afterEntry : afterMap.entrySet()) { + String key = afterEntry.getKey(); + System.out.println("afterkey:"+key); + if (beforeMap.containsKey(key)) { + } else { + resultMap.put(afterMap.get(key), TCUtil.totalBOMLineQuantity(afterMap.get(key))); + } + } + + String ysr8_ReasonAnalysisVal = ""; + TCComponentItem ecn1Item = ecn2Revision.getItem(); + AIFComponentContext[] context2 = + ecn1Item.whereReferencedByTypeRelation(new String[] { "YSR8_PRRevision" }, new String[] { "YSR8_ChangeForm" }); + if (context2 != null && context2.length > 0) {// ⱨ + TCComponentItemRevision prRevision = (TCComponentItemRevision) context2[0].getComponent(); + TCComponentForm prForm = (TCComponentForm) prRevision.getRelatedComponent("IMAN_master_form_rev"); + if (prForm != null) { + ysr8_ReasonAnalysisVal = prForm.getProperty("ysr8_ReasonAnalysis"); + } + } + + List> dataList = new ArrayList<>();// kk + Map prodIdMap=new HashMap<>(); + + { + Vector vec = new Vector<>(); + vec.add(("1") + "");// + vec.add(afterBomRevision.getProperty("item_revision_id"));// 汾 + String prodId=afterBomItem.getProperty("item_id"); + if(prodId!=null&&!"".equals(prodId)) { + prodId=prodId.split("_P")[0]; //ȡ_P֮ǰ + if(!prodIdMap.containsKey(prodId)) { //¼ + prodIdMap.put(prodId, 1.0); + }else { + prodIdMap.put(prodId, prodIdMap.get(prodId)+1); + } + } + vec.add(prodId);// ƷID + vec.add("");// + vec.add(afterBomItem.getProperty("object_name"));// + vec.add("1");// + vec.add(ysr8_ReasonAnalysisVal);// ԭ + vec.add("");// ķ + vec.add("");// kk һ + vec.add("");// ãԪ + vec.add("");// ԭ + vec.add("");// ӹʱ + vec.add("");// ʼʱ + vec.add("");// ʼ + vec.add("");// ӹ1 + vec.add("");// ӹ2 + vec.add("");// ͼ + vec.add("");// ɹҪ + vec.add("1");// ״̬ + // kk ci.dataTableModel.addRow(vec); + dataList.add(vec); + } + + Integer idx = 1; + for (Map.Entry entry : resultMap.entrySet()) { + TCComponentBOMLine bomline = entry.getKey(); + TCComponentItemRevision itemRevision = bomline.getItemRevision(); + // TCComponentItem item = itemRevision.getItem(); + TCComponentForm form = TCUtil.getItemRevisionMasterForm(itemRevision); + String bl_item_item_id = bomline.getProperty("bl_item_item_id"); + String changeToPurch = bomline.getProperty("YSR8_ChangeToPurch"); + // String isPurch = form.getProperty("ysr8_IsPurch"); + String objectType = bomline.getItem().getProperty("object_type"); + boolean isAdd = false; + if (objectType.equals("׼") && (changeToPurch.equals("") || changeToPurch.equals(""))) { + isAdd = true; + } else if (objectType.equals("㲿") || objectType.equals("еĿ") || objectType.equals("")) { + isAdd = true; + } + if (isAdd && bl_item_item_id.startsWith("WG")) { + isAdd = false; + } + if (isAdd) { + Vector vec = new Vector<>(); + vec.add((++idx) + "");// + vec.add(itemRevision.getProperty("item_revision_id"));// 汾 + String prodId=bomline.getProperty("bl_item_item_id"); + if(prodId!=null&&!"".equals(prodId)) { + prodId=prodId.split("_P")[0]; //ȡ_P֮ǰ + if(!prodIdMap.containsKey(prodId)) { //¼ + prodIdMap.put(prodId, entry.getValue()); + }else { + prodIdMap.put(prodId, prodIdMap.get(prodId)+entry.getValue()); + } + } + vec.add(prodId);// ƷID + //vec.add(bomline.getProperty("bl_item_item_id"));// ƷID + if (objectType.equals("׼")) { + vec.add(form.getProperty("ysr8_summary1"));// + } else { + vec.add("");// + } + vec.add(bomline.getProperty("bl_item_object_name"));// + vec.add(fu.getDoubleString(entry.getValue()));// + vec.add(ysr8_ReasonAnalysisVal);// ԭ + vec.add("");// ķ + vec.add("");// kk һ + vec.add("");// ãԪ + vec.add("");// ԭ + vec.add("");// ӹʱ + vec.add("");// ʼʱ + vec.add("");// ʼ + vec.add("");// ӹ1 + vec.add("");// ӹ2 + vec.add("");// ͼ + vec.add("");// ɹҪ + vec.add("1");// ״̬ + // kk ci.dataTableModel.addRow(vec); + dataList.add(vec); + } + } + + // kk ʼ + int n = dataList.size(); + Vector temp; + for (int i = 0; i < n; i++) { + for (int j = 0; j < n - i - 1; j++) { + if (dataList.get(j).get(2).compareTo(dataList.get(j + 1).get(2)) > 0) { + temp = dataList.get(j); + dataList.set(j, dataList.get(j + 1)); + dataList.set(j + 1, temp); + } + } + } + + FormUtil.JTableInfo t2 = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.151.11.11");//ձ2 + if(t2.dataTableModel.getRowCount()>0) + for(int i=t2.dataTableModel.getRowCount(); i>0; i--) + t2.dataTableModel.removeRow(i-1); + // ±д + int newIndex=1; + DecimalFormat df=new DecimalFormat("#"); + for (int i = 0; i < n; i++) { + temp=dataList.get(i); + String prodId=temp.get(2); + System.out.println(prodId); + if(prodIdMap.containsKey(prodId)&&prodIdMap.get(prodId)!=null) {//± + temp.set(0, (newIndex++) + ""); + temp.set(5, df.format(prodIdMap.get(prodId))); + ci.dataTableModel.addRow(temp); + prodIdMap.put(prodId, null);//ñǡnull + + Vector temp2 = new Vector<>();//TODO д2 + temp2.add(temp.get(0));// + temp2.add(temp.get(1));//汾 + temp2.add(temp.get(2));// + temp2.add(temp.get(4));// + temp2.add("");//ID + temp2.add("");//ӹʼƻʱ + temp2.add("");//ӹҪʱ + temp2.add("");//ӹʵʱ + temp2.add("");//ӹԭ + temp2.add("");//ļƻʱ + temp2.add("");//Ƿ + t2.dataTableModel.addRow(temp2); + } + } + + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + public void countYsr8_SubTotalExpense() { + double ysr8_SubTotalExpense = 0.0; + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.141.11.11"); + for (int i = 0; i < ci.dataTableModel.getRowCount(); i++) { + // kk 0803 к˰ Զ㷢 + Object numStr = ci.dataTableModel.getValueAt(i, 5) ; + Object priceStr = ci.dataTableModel.getValueAt(i, 8); + if (numStr != null&&priceStr != null&&!"".equals(numStr)&&!"".equals(priceStr)) { + double num= Double.parseDouble(numStr.toString()); + double price= Double.parseDouble(priceStr.toString()); + double expense=num*price; + String propValue = fu.getDoubleString(expense); + if (propValue.startsWith(".")) { + propValue = "0" + propValue; + } + ci.dataTableModel.setValueAt(propValue,i,9); + ysr8_SubTotalExpense += expense; + } + } + String propValue = fu.getDoubleString(ysr8_SubTotalExpense); + if (propValue.startsWith(".")) { + propValue = "0" + propValue; + } + iTextField textField = (iTextField) fu.allComponentMap.get("ysr8_SubTotalExpense"); + textField.setText(propValue); + } + + public void countYsr8_TotalExpense() { + JButton btn = (JButton) fu.allComponentMap.get("b.061.16"); + btn.setEnabled(false); + + countYsr8_SubTotalExpense(); + iTextField textField = (iTextField) fu.allComponentMap.get("ysr8_SubTotalExpense"); + String ysr8_SubTotalExpense = textField.getText(); + double ysr8_SubTotalExpenseVal = 0.0; + if (!ysr8_SubTotalExpense.equals("")) { + ysr8_SubTotalExpenseVal = Double.parseDouble(ysr8_SubTotalExpense); + } + + double ysr8_TotalExpense = ysr8_SubTotalExpenseVal; + String projectCode = ""; + try { + iTextField ysr8_ProjectCode = (iTextField) fu.allComponentMap.get("ysr8_ProjectCode"); + projectCode = ysr8_ProjectCode.getText(); + if (projectCode.equals("")) { + btn.setEnabled(true); + return; + } + + String[] attrs = new String[1]; + String[] vals = new String[1]; + attrs[0] = "ysr8_ProjectCode"; + vals[0] = projectCode; + TCComponent[] tcComponents = TCUtil.query(fu.session, "SearchECN1", attrs, vals); + if (tcComponents != null) { + for (int i = 0; i < tcComponents.length; i++) { + TCComponentItemRevision ecn1ItemRevision = (TCComponentItemRevision) tcComponents[i]; + TCComponentForm ecn1Form = TCUtil.getItemRevisionMasterForm(ecn1ItemRevision); + ysr8_TotalExpense += ecn1Form.getDoubleProperty("ysr8_SubTotalExpense"); + } + } + + tcComponents = TCUtil.query(fu.session, "SearchECN2", attrs, vals); + if (tcComponents != null) { + for (int i = 0; i < tcComponents.length; i++) { + TCComponentItemRevision ecn2ItemRevision = (TCComponentItemRevision) tcComponents[i]; + TCComponentForm ecn2Form = TCUtil.getItemRevisionMasterForm(ecn2ItemRevision); + ysr8_TotalExpense += ecn2Form.getDoubleProperty("ysr8_SubTotalExpense"); + } + } + } catch (Exception e) { + e.printStackTrace(); + btn.setEnabled(true); + return; + } + + String propValue = fu.getDoubleString(ysr8_TotalExpense); + textField = (iTextField) fu.allComponentMap.get("ysr8_TotalExpense"); + textField.setText(propValue); + btn.setEnabled(true); + } + + public void linkPR() { + try { + AIFComponentContext[] context1 = + fu.tcForm.whereReferencedByTypeRelation(new String[] { "YSR8_ECN2Revision" }, new String[] { "IMAN_master_form" }); + if (context1 != null && context1.length > 0) { + TCComponentItemRevision ecn2Revision = (TCComponentItemRevision) context1[0].getComponent(); +// TCComponentItem ecn2Item = ecn2Revision.getItem(); + + AIFComponentContext[] context2 = + ecn2Item.whereReferencedByTypeRelation(new String[] { "YSR8_PRRevision" }, new String[] { "YSR8_ChangeForm" }); + if (context2 != null && context2.length > 0) {// ĵ + for(int i=0; i 0) { + for(int j=0; j changePictures = new HashMap<>(); + for(int s=0;s e : changePictures.entrySet()) { + if(!e.getValue()) + ChangePictureFolder.remove("YSR8_ChangePicture", e.getKey()); + } + } + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + public void updatePartItemECN() { + iTextField textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_SubProjectCode"); + String ysr8_SubProjectCodeVal = textfieldForm.getText(); + if (ysr8_SubProjectCodeVal.equals("")) { + MessageBox.post("ĿΪգ޷ͬĿ", "ʾ", MessageBox.INFORMATION); + return; + } + + try { + AIFComponentContext[] context1 = + fu.tcForm.whereReferencedByTypeRelation(new String[] { "YSR8_ECN2Revision" }, new String[] { "IMAN_master_form" }); + if (context1 == null || context1.length <= 0) { + return; + } + TCComponentItemRevision ecn2Revision = (TCComponentItemRevision) context1[0].getComponent(); + TCComponentItem ecn2Item = ecn2Revision.getItem(); + + TCComponentPseudoFolder folder2 = TCUtil.getRevisionPseudoFolder(ecn2Revision, "ĺ㲿"); + TCComponentItemRevision afterBomRevision = TCUtil.getPseudoItem2(folder2, ysr8_SubProjectCodeVal); + if (afterBomRevision == null) { + MessageBox.post("ĺûҵĿ޷ͬĿ", "ʾ", MessageBox.INFORMATION); + return; + } + afterBomRevision.add("YSR8_ChangeRecord", new TCComponent[] { ecn2Item }); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void OutputExcel() { + final JButton btn = (JButton) fu.allComponentMap.get("b.141.12.51"); + btn.setEnabled(false); + + iTextField textfieldForm; + textfieldForm = (iTextField) fu.allComponentMap.get("Item_ID"); + String item_IDVal = textfieldForm.getText(); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ProjectCode"); + final String[] ysr8_ProjectCodeVal = { textfieldForm.getText() }; + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ProjectName"); + final String[] ysr8_ProjectNameVal = { textfieldForm.getText() }; + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_SubProjectCode"); + final String[] ysr8_SubProjectCodeVal = { textfieldForm.getText() }; + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_SubProjectName"); + final String[] ysr8_SubProjectNameVal = { textfieldForm.getText() }; + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_DesignDirector"); + final String[] ysr8_DesignDirectorVal = { textfieldForm.getText() }; + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_Changer"); + final String[] ysr8_ChangerVal = { textfieldForm.getText() }; + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ApplicationDate"); + final String[] ysr8_ApplicationDateVal = { textfieldForm.getText() }; + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_PurchPlanDate"); + final String[] ysr8_PurchPlanDateVal = { textfieldForm.getText() }; + + final String[] reportFileName = { "" }; + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + int returnVal = fileChooser.showOpenDialog(fileChooser); + if (returnVal == JFileChooser.APPROVE_OPTION) { + String dir = fileChooser.getSelectedFile().getAbsolutePath();// ѡļе· + reportFileName[0] = dir + "\\" + item_IDVal + ".xls"; + } + if (reportFileName[0].equals("")) { + btn.setEnabled(true); + return; + } + + final JTable table1 = (JTable) fu.allComponentMap.get("a.141.11.11"); + + final ProgressReporterDialog reporter = new ProgressReporterDialog(); + reporter.reportProgressMessage("ڵ,Ժ..."); + new Thread(reporter).start(); + new Thread() { + public void run() { + try { + File reportFile = new File(reportFileName[0]); + reportFile.delete(); + // һдWorkbook + WritableWorkbook writeWorkBook = Workbook.createWorkbook(reportFile); + // + WritableSheet wsheet = writeWorkBook.createSheet("ͼֽĵ", 0); + + // д + int[] columnCount = { 0, 1, 2, 4, 7, 5 }; // // lidy20190423ӵ汾 + int rowCount = table1.getRowCount(); // + String[] titles = new String[columnCount.length]; // ͷ + + // ȡͷ + for (int i = 0; i < columnCount.length; i++) { + titles[i] = table1.getColumnName(columnCount[i]); + } + + int current_row = 0; // ʼǰΪʼ + + try { + // ʽ + WritableFont titleFont = new WritableFont(WritableFont.createFont(""), 13, WritableFont.BOLD); + WritableCellFormat titleCellFormat = new WritableCellFormat(titleFont); + titleCellFormat.setBorder(Border.ALL, BorderLineStyle.MEDIUM); + titleCellFormat.setAlignment(Alignment.CENTRE); + titleCellFormat.setVerticalAlignment(VerticalAlignment.CENTRE); + titleCellFormat.setWrap(true); + + WritableCellFormat titleCellFormat2 = new WritableCellFormat(titleFont); + titleCellFormat2.setAlignment(Alignment.CENTRE); + titleCellFormat2.setVerticalAlignment(VerticalAlignment.CENTRE); + titleCellFormat2.setWrap(true); + + // ʽ + WritableFont contentFont = new WritableFont(WritableFont.createFont(""), 12); + WritableCellFormat contentCellFormat = new WritableCellFormat(contentFont); + contentCellFormat.setBorder(Border.ALL, BorderLineStyle.THIN); + contentCellFormat.setAlignment(Alignment.CENTRE); + contentCellFormat.setVerticalAlignment(VerticalAlignment.CENTRE); + contentCellFormat.setWrap(true); + + WritableCellFormat contentCellFormat2 = new WritableCellFormat(contentFont); + contentCellFormat2.setAlignment(Alignment.CENTRE); + contentCellFormat2.setVerticalAlignment(VerticalAlignment.CENTRE); + contentCellFormat2.setWrap(true); + + Label labelTitle = new Label(0, current_row, "Ŀ", titleCellFormat2); + wsheet.addCell(labelTitle); + Label labelContent = new Label(1, current_row, ysr8_ProjectCodeVal[0], contentCellFormat2); + wsheet.addCell(labelContent); + + labelTitle = new Label(3, current_row, "", titleCellFormat2); + wsheet.addCell(labelTitle); + labelContent = new Label(4, current_row, ysr8_DesignDirectorVal[0], contentCellFormat2); + wsheet.addCell(labelContent); + + labelTitle = new Label(5, current_row, "", titleCellFormat2); + wsheet.addCell(labelTitle); + labelContent = new Label(6, current_row, ysr8_ChangerVal[0], contentCellFormat2); + wsheet.addCell(labelContent); + +// labelTitle = new Label(4, current_row, "Ŀ", titleCellFormat2); +// wsheet.addCell(labelTitle); +// labelContent = new Label(5, current_row, ysr8_SubProjectCodeVal[0], contentCellFormat2); +// wsheet.addCell(labelContent); + current_row = current_row + 1; + + labelTitle = new Label(0, current_row, "Ŀ", titleCellFormat2); + wsheet.addCell(labelTitle); + labelContent = new Label(1, current_row, ysr8_ProjectNameVal[0], contentCellFormat2); + wsheet.addCell(labelContent); + + labelTitle = new Label(3, current_row, "Ŀ", titleCellFormat2); + wsheet.addCell(labelTitle); + labelContent = new Label(4, current_row, ysr8_SubProjectNameVal[0], contentCellFormat2); + wsheet.addCell(labelContent); + + labelTitle = new Label(5, current_row, "", titleCellFormat2); + wsheet.addCell(labelTitle); + labelContent = new Label(6, current_row, ysr8_ApplicationDateVal[0], contentCellFormat2); + wsheet.addCell(labelContent); + + labelTitle = new Label(7, current_row, "Ҫӹʱ", titleCellFormat2); + wsheet.addCell(labelTitle); + labelContent = new Label(8, current_row, ysr8_PurchPlanDateVal[0], contentCellFormat2); + wsheet.addCell(labelContent); + current_row = current_row + 1; + + Map insertCol = new HashMap<>(); + insertCol.put(1, new String[] {"ĵ", ecn2Item.getProperty("item_id")}); + insertCol.put(3, new String[] {"Ŀ", ysr8_SubProjectCodeVal[0]}); + + // дб + int move = 0; + for (int i = 0; i < columnCount.length; i++) { + if(insertCol.containsKey(i+move)) { + labelTitle = new Label(i+move, current_row, insertCol.get(i+move)[0], titleCellFormat); + wsheet.addCell(labelTitle); + move++; + } + labelTitle = new Label(i+move, current_row, titles[i], titleCellFormat); + wsheet.addCell(labelTitle); + } + current_row = current_row + 1; + + // д + for (int i = 0; i < rowCount; i++) { + move = 0; + for (int j = 0; j < columnCount.length; j++) { + if(insertCol.containsKey(j + move)) { + labelContent = new Label(j + move, i + current_row, insertCol.get(j + move)[1], contentCellFormat); + wsheet.addCell(labelContent); + move++; + } + String val = getTableValue(table1, i, columnCount[j]); + if(j + move == 4) { + String val2 = getTableValue(table1, i, 3); +// System.out.println("val:"+val + val2); + if(!val.isEmpty() && !val2.isEmpty()) + val = val + "-" + val2; + else + val = val + val2; + } + labelContent = new Label(j + move, i + current_row, val, contentCellFormat); + wsheet.addCell(labelContent); + } + } + + // øʽ + wsheet.getSettings().setDefaultColumnWidth(20); + writeWorkBook.write(); + writeWorkBook.close(); + } catch (Exception e) { + e.printStackTrace(); + } + + // 򿪵ıļ + Runtime.getRuntime().exec("cmd /c \"" + reportFileName[0] + "\""); + + } catch (Exception e) { + e.printStackTrace(); + } + reporter.requestCanceling(); + btn.setEnabled(true); + } + }.start(); + } + + // kk ӹʱдж + public void PartModify() { + int dialogResult = AbstractAIFDialog.ID_CANCEL; + try { + JTable table = (JTable) fu.allComponentMap.get("a.141.11.11"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪ༭ݣ", "ʾ", MessageBox.INFORMATION); + return; + } + if (table.getValueAt(rows[0], 7) == null || table.getValueAt(rows[0], 14) == null + || !table.getValueAt(rows[0], 7).toString().equals("ԭ޸") + || !table.getValueAt(rows[0], 14).toString().equals("̿")) { + MessageBox.post("ݲڱ༭Χڣܽб༭", "ʾ", MessageBox.INFORMATION); + return; + } + String state = getTableValue(table, rows[0], 18); + if (state.equals("3") || state.equals("4") || state.equals("ѱ") || state.equals("Ѽ")) { + MessageBox.post("޸ģܽб༭", "ʾ", MessageBox.INFORMATION); + return; + } + if (table.getValueAt(rows[0], 5)!=null && table.getValueAt(rows[0], 25)!=null + && (table.getValueAt(rows[0], 5).toString().equals(table.getValueAt(rows[0], 25).toString()))) { + MessageBox.post("޸ģܽб༭", "ʾ", MessageBox.INFORMATION); + return; + } + + String ysr8_SubPurchFinishDateVal = ""; + + AIFComponentContext[] context1 = + fu.tcForm.whereReferencedByTypeRelation(new String[] { "YSR8_ECN2Revision" }, new String[] { "IMAN_master_form" }); + if (context1 != null && context1.length > 0) { +// TCComponentItemRevision ecn2Revision = (TCComponentItemRevision) context1[0].getComponent(); +// TCComponentItem ecn2Item = ecn2Revision.getItem(); + + int idx = Integer.parseInt(table.getValueAt(rows[0], 0).toString()); + System.out.println("ǰţ" + idx + ""); +// YSR8_ECN2RevisionMasterEditDialog dialog = new YSR8_ECN2RevisionMasterEditDialog(fu.session, ecn2Revision, fu.tcForm, idx); + YSR8_ECN2RevisionMasterEditDialog dialog = new YSR8_ECN2RevisionMasterEditDialog(fu.session, table, fu.tcForm, idx); + dialogResult = dialog.dialogResult(); + ysr8_SubPurchFinishDateVal = dialog.return_ysr8_SubPurchFinishDateVal; + System.out.println("########################################" + ysr8_SubPurchFinishDateVal); + if (dialogResult == AbstractAIFDialog.ID_OK) { + System.out.println("====================================" + table.getValueAt(rows[0], 4)); + table.setValueAt(ysr8_SubPurchFinishDateVal, rows[0], 11); +// table.setValueAt("3", rows[0], 18); + Boolean bIsAllEnd = true; + String lastEnd = "1900-01-01 00:00:00"; + for (int j = 0; j < table.getRowCount(); j++) { + String endTime = table.getValueAt(j, 11).toString(); + String subTaskManuState = getTableValue(table, j, 18); + if (!"װͼ".equals(table.getValueAt(j, 7).toString()) && (endTime.isEmpty() + || !subTaskManuState.equals("3") && !subTaskManuState.equals("4") + && !subTaskManuState.equals("ѱ") && !subTaskManuState.equals("Ѽ"))) { + bIsAllEnd = false; + break; + } + if (!"װͼ".equals(table.getValueAt(j, 7).toString()) && endTime.compareTo(lastEnd) > 0) { + lastEnd = endTime; + } + } + if (bIsAllEnd) { + System.out.println("@@@@@@@@@"); + + Date end = getDate(lastEnd); + DateButton ysr8_PurchFinishDate = (DateButton) fu.allComponentMap.get("ysr8_PurchFinishDate"); + ysr8_PurchFinishDate.setDate(end); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + + } + private void refrashTable2(int[] rows, boolean update) {//TODO 2ʾ + JTable table = (JTable) fu.allComponentMap.get("a.141.11.11"); + Map map1 = new HashMap<>(); + Map map2 = new HashMap<>(); + for(int i=0; i0"); + c.setTime(getDate(machPlan)); + c.add(Calendar.DAY_OF_MONTH, day); + table2.setValueAt(fu.getDateString(c.getTime()), i, 6); + } + if(!map1.get(getTableValue(table2, i, table2Map.get(""))).equals("װͼ")) { + Date machAsk = c.getTime(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date ask = sdf.parse(fu.getDateString(machAsk)+" 23:59:59"); + if(machFinish.isEmpty()) { + if(ask.after(new Date())) + table2.setValueAt("", i, table2Map.get("Ƿ")); + else + table2.setValueAt("", i, table2Map.get("Ƿ")); + }else { + if(!ask.after(getDate(machFinish.substring(0, 10)))) + table2.setValueAt("", i, table2Map.get("Ƿ")); + else + table2.setValueAt("", i, table2Map.get("Ƿ")); +// System.out.println(machAsk+"=="+machFinish+"=="+table2.getValueAt(i, table2Map.get("Ƿ"))); + } + }else + table2.setValueAt("", i, table2Map.get("Ƿ")); + } + } + }catch(Exception e) { + e.printStackTrace(); + } + } + private Date getDate(String s) throws Exception { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + if(s==null || s.isEmpty()) + return null; + if(s.length()>10) + sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + return sdf.parse(s); + } + private String getTableValue(JTable table, int r, int c) { + if(table.getValueAt(r, c)==null) + return ""; + else + return table.getValueAt(r, c).toString(); + } +} diff --git a/src/cn/com/ebewin/ysr/form/YSR8_ECN3RevisionMasterForm.java b/src/cn/com/ebewin/ysr/form/YSR8_ECN3RevisionMasterForm.java new file mode 100644 index 0000000..30b055f --- /dev/null +++ b/src/cn/com/ebewin/ysr/form/YSR8_ECN3RevisionMasterForm.java @@ -0,0 +1,1306 @@ +package cn.com.ebewin.ysr.form; + +import java.awt.Dimension; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.text.DecimalFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Vector; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JDialog; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JTable; +import javax.swing.RowSorter; +import javax.swing.SortOrder; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; + +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.commands.open.OpenFormDialog; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentGroupMember; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentPseudoFolder; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCFormProperty; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.iTextField; + +import cn.com.ebewin.ysr.util.CommonUtil; +import cn.com.ebewin.ysr.util.FormCheckUtil; +import cn.com.ebewin.ysr.util.FormUtil; +import cn.com.ebewin.ysr.util.POIUtil; +import cn.com.ebewin.ysr.util.TCUtil; + +@SuppressWarnings("deprecation") +public class YSR8_ECN3RevisionMasterForm extends AbstractRendering { + private static final long serialVersionUID = 1L; + private static Date refreshDate = null; + private Map map = null; + TCComponentForm form = null; + TCComponentItemRevision ecn3Rev = null; + TCComponentItem ecn3Item = null; + private Map table2Map; + + FormUtil fu = new FormUtil(this); + FormCheckUtil fcu = null; + + public YSR8_ECN3RevisionMasterForm(TCComponentForm arg0) throws Exception { + super(arg0); + form = arg0; + AIFComponentContext[] context1 = form.whereReferencedByTypeRelation + (new String[] { "YSR8_ECN3Revision" }, new String[] { "IMAN_master_form" }); + if (!(context1 != null && context1.length > 0)) { + return; + } + ecn3Rev = (TCComponentItemRevision) context1[0].getComponent(); + ecn3Item = ecn3Rev.getItem(); + table2Map = new HashMap<>(); + table2Map.put("", 1);// + table2Map.put("ID", 4); + table2Map.put("Ƿ", 9); + + Date currDate = new Date(); + if (refreshDate == null) { + arg0.refresh(); + refreshDate = currDate; + } else { + long diff = currDate.getTime() - refreshDate.getTime(); + long minutes = diff / 1000 / 60; + if (minutes >= 1) { + arg0.refresh(); + refreshDate = currDate; + } + } + + fu.readRenderingXML("YSR8_ECN3RevisionMasterForm"); + fu.initializeUI(arg0); + + JTable table = (JTable) fu.allComponentMap.get("a.111.11.11"); + table.setAutoCreateRowSorter(true); + TableRowSorter sorter = new TableRowSorter(table.getModel()); + ArrayList sortKeys = new ArrayList(); + sortKeys.add(new RowSorter.SortKey(1, SortOrder.ASCENDING)); + sorter.setSortKeys(sortKeys); + table.setRowSorter(sorter); + + loadRendering(); + getDefVal(); + setComboBoxValue_ysr8_SubProjectCode(); + + addActionListener(); + + int count = ((JTable) fu.allComponentMap.get("a.151.11.11")).getRowCount(); + if(count>0) { + int[] rows = new int[count]; + for(int i=0; i 0) { + TCComponentItemRevision ecn3Revision = (TCComponentItemRevision) context1[0].getComponent(); + TCComponentItem ecn3Item = ecn3Revision.getItem(); + + iTextField textfieldForm; + textfieldForm = (iTextField) fu.allComponentMap.get("Item_ID"); + textfieldForm.setText(ecn3Item.getProperty("item_id")); + } + + fu.loadRendering(); + + fcu = new FormCheckUtil(fu.tcForm, fu.allComponentMap); + fcu.checkHandler(); + } + + public void setRenderingReadOnly() { + setModifiableComponents(this, false); + if (getController() != null) + getController().setFormReadOnly(); + + JButton btn = (JButton) fu.allComponentMap.get("b.111.12.41"); + if (btn != null) { + btn.setEnabled(true); + if (btn.getParent() != null) + btn.getParent().setEnabled(true); + if (btn.getParent().getParent() != null) + btn.getParent().getParent().setEnabled(true); + } + } + + public void setRenderingReadWrite() { + if (fcu != null && fcu.isNeedCheck()) { + fcu.setEnable(); + fu.isCheckOut = true; + return; + } + setModifiableComponents(this, true); + + fu.allComponentMap.get("ysr8_ChangeReason").setEnabled(false); + fu.allComponentMap.get("ysr8_TechFinishDate").setEnabled(false); + fu.allComponentMap.get("ysr8_PurchFinishDate").setEnabled(false); + } + + private void setModifiableComponents(java.awt.Component currcomponent, boolean flag) { + if (fcu != null && flag) { + if (fcu.isNeedCheck()) { + return; + } + } + fu.setModifiableComponents(currcomponent, flag); + } + + /** + * (non-Javadoc) + * + * @see com.teamcenter.rac.form.AbstractTCForm#saveForm() + */ + @Override + public void saveRendering() { + if (!checkCanSave()) { + return; + } + countYsr8_SubTotalExpense(); + // try { + // if (fu.tcForm.getDoubleProperty("ysr8_TotalExpense") == 0.0) { + // countYsr8_TotalExpense(); + // } + // } catch (TCException e) { + // e.printStackTrace(); + // return; + // } + countYsr8_TotalExpense(); + + Integer idx = 0; + JTable table = (JTable) fu.allComponentMap.get("a.111.11.11"); + for (int i = 0; i < table.getRowCount(); i++) { + table.setValueAt((++idx), i, 0);// + } + + try { + fu.saveRendering(); + } catch (TCException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } catch (ParseException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } + + linkPR(); + } + + public boolean isRenderingModified() { + return fu.isRenderingModified(); + } + + private void addActionListener() { + { + @SuppressWarnings("unchecked") + final JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_SubProjectCode"); + cbx.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + iTextField SubProjectName = (iTextField) fu.allComponentMap.get("ysr8_SubProjectName"); + if(cbx.getSelectedItem().equals("")) { + SubProjectName.setText(""); + } else if(map.containsKey(cbx.getSelectedItem())) + SubProjectName.setText(map.get(cbx.getSelectedItem())); + } + }); + } + { + JButton btn = (JButton) fu.allComponentMap.get("b.061.15"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + countYsr8_TotalExpense(); + } + }); + + btn = (JButton) fu.allComponentMap.get("b.111.12.11"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.111.11.11"); + Object[] objData = new Object[ci.childComponentInfos.size()]; + for (int i = 0; i < objData.length; i++) { + objData[i] = ""; + } + ci.dataTableModel.addRow(objData); + } + }); + + btn = (JButton) fu.allComponentMap.get("b.111.12.21"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.111.11.11"); + JTable table = (JTable) fu.allComponentMap.get("a.111.11.11"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪƳУ", "ʾ", MessageBox.INFORMATION); + return; + } + for (int i = rows.length - 1; i >= 0; i--) { + ci.dataTableModel.removeRow(table.convertRowIndexToModel(rows[i])); + } + } + }); + + btn = (JButton) fu.allComponentMap.get("b.111.12.31"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.111.11.11"); + try { + for (int i = 0; i < ci.dataTableModel.getRowCount(); i++) { + ci.dataTableModel.setValueAt(Integer.toString(i + 1), i, 0); + + String ysr8_MaterialID = ""; + if (ci.dataTableModel.getValueAt(i, 1) != null) { + ysr8_MaterialID = ci.dataTableModel.getValueAt(i, 1).toString(); + } + if (ysr8_MaterialID.equals("")) { + continue; + } + + // String ysr8_MaterialName = ""; + // if (ci.dataTableModel.getValueAt(i, 2) != null) { + // ysr8_MaterialName = ci.dataTableModel.getValueAt(i, 2).toString(); + // } + // if (!ysr8_MaterialName.equals("")) { + // continue; + // } + + TCComponentItem materialItem = TCUtil.findItemByID(fu.session, ysr8_MaterialID); + if (materialItem == null) { + continue; + } + TCComponentItemRevision materialRevision = materialItem.getLatestItemRevision(); + TCComponentForm materialForm = TCUtil.getItemRevisionMasterForm(materialRevision); + String object_name = materialRevision.getStringProperty("object_name"); + String ysr8_summary1 = materialForm.getStringProperty("ysr8_summary1"); + String uom_tag = materialItem.getProperty("uom_tag"); + String ysr8_Brand1 = materialForm.getStringProperty("ysr8_Brand1"); + + ci.dataTableModel.setValueAt(object_name, i, 2); + ci.dataTableModel.setValueAt(ysr8_summary1, i, 3); + ci.dataTableModel.setValueAt(uom_tag, i, 5); + ci.dataTableModel.setValueAt(ysr8_Brand1, i, 6); + } + } catch (TCException ex) { + ex.printStackTrace(); + } + } + }); + + btn = (JButton) fu.allComponentMap.get("b.111.12.41"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + outputExcel(); + } + }); + + btn = (JButton) fu.allComponentMap.get("b.151.12.11");//TODO Ӱť + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + int option=JOptionPane.showOptionDialog(null, "ȷͬ񣬱ݻ", "ʾ", + JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE, null, new String[] {"ȷ","ȡ"}, ""); +// System.out.println("value:"+option); + if(option == 0) { + FormUtil.JTableInfo t2 = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.151.11.11"); + if(t2.dataTableModel.getRowCount()>0) + for(int i=t2.dataTableModel.getRowCount(); i>0; i--) + t2.dataTableModel.removeRow(i-1); + + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.111.11.11"); + if(ci.dataTableModel.getRowCount()>0) { + JTable table = (JTable) fu.allComponentMap.get("a.111.11.11"); + for(int i=0; i temp2 = new Vector<>(); + temp2.add(getTableValue(table, i, 0));// + temp2.add(getTableValue(table, i, 1));//ƷID + temp2.add(getTableValue(table, i, 3));//ͺ/ͼ + temp2.add(getTableValue(table, i, 2));// + temp2.add("");//ID + temp2.add("");//ɹʼƻʱ + temp2.add("");//ɹҪʱ + temp2.add("");//ɹʵʱ + temp2.add("");//ɹԭ + temp2.add("");//Ƿ + temp2.add("");//ļƻʱ + t2.dataTableModel.addRow(temp2); + } + } + } + } + }); + + btn = (JButton) fu.allComponentMap.get("b.151.12.21"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + JTable table = (JTable) fu.allComponentMap.get("a.151.11.11"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪƳУ", "ʾ", MessageBox.INFORMATION); + return; + } + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.151.11.11"); + for (int i = rows.length - 1; i >= 0; i--) { + boolean only = true; + for(int j=0; j temp2 = new Vector<>(); + temp2.add("");// + temp2.add(getTableValue(table, rows[0], 1));//ƷID + temp2.add(getTableValue(table, rows[0], 2));//ͺ/ͼ + temp2.add(getTableValue(table, rows[0], 3));// + temp2.add("");//ID + temp2.add("");//ɹʼƻʱ + temp2.add("");//ɹҪʱ + temp2.add("");//ɹʵʱ + temp2.add("");//ɹԭ + temp2.add("");//Ƿ + temp2.add("");//ļƻʱ + ci.dataTableModel.insertRow(rows[0]+1, temp2); + for(int i=0; i1) { + for(int i : rows) { + if(!getTableValue(table, rows[0], table2Map.get("ID")) + .equals(getTableValue(table, i, table2Map.get("ID")))) { + MessageBox.post("ѡаͬ޷༭", "ʾ", MessageBox.INFORMATION); + return; + } + if(!getTableValue(table, i, table2Map.get("Ƿ")).equals("")) { + MessageBox.post("ѡаδУ޷༭", "ʾ", MessageBox.INFORMATION); + return; + } + } + } + String[] lovs = TCUtil.getPreference(form.getSession(), TCPreferenceService.TC_preference_site, "YSR8_Ecn13DelayReason_LOV"); + final JDialog dialog = new JDialog(AIFUtility.getActiveDesktop().getFrame(), true); + dialog.setTitle("༭"); + JLabel label = new JLabel("ɹԭ"); + dialog.add(label); + label.setBounds(20, 20, 80, 24); +// final JTextArea area = new JTextArea(); +// area.setLineWrap(true); + final JComboBox area = new JComboBox<>(); + area.addItem(""); + if(lovs!=null && lovs.length>0) + for(String s : lovs) + area.addItem(s); + area.setEditable(true); + area.setBounds(100, 20, 200, 24); + dialog.add(area); + JButton btn1 = new JButton("ȷ"); + btn1.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent arg0) { + if(area.getSelectedItem().toString().isEmpty()) { + MessageBox.post("дɹԭ", "ʾ", MessageBox.WARNING); + return; + } + for(int i : rows) { + table.setValueAt(area.getSelectedItem().toString(), i, 8); + } + dialog.dispose(); + } + }); + dialog.add(btn1); + btn1.setBounds(20, 100, 80, 24); + JButton btn2 = new JButton("ȡ"); + btn2.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent arg0) { + dialog.dispose(); + } + }); + dialog.add(btn2); + btn2.setBounds(220, 100, 80, 24); + dialog.add(new JLabel("")); + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + dialog.setBounds((screenSize.width - 350)/2, (screenSize.height - 200)/2, 350, 200); + dialog.setVisible(true); + + } + }); + + btn = (JButton) fu.allComponentMap.get("b.151.12.61"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { +// FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.151.11.11"); + JTable table = (JTable) fu.allComponentMap.get("a.151.11.11"); + final int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪУ", "ʾ", MessageBox.INFORMATION); + return; + } + if(rows.length>1) { + Set set = new HashSet<>(); + for(int i : rows) { + if(set.contains(getTableValue(table, i, table2Map.get("")))) { + MessageBox.post("ͬһIJͬвͬ", "ʾ", MessageBox.INFORMATION); + return; + }else + set.add(getTableValue(table, i, table2Map.get(""))); + } + } + final JDialog dialog = new JDialog(AIFUtility.getActiveDesktop().getFrame(), true); + dialog.setTitle(""); + final JComboBox combo = new JComboBox<>(); + final Map techMap = new HashMap<>(); + final Map purchMap = new HashMap<>(); + try { + AIFComponentContext[] context2 = ecn3Item.whereReferencedByTypeRelation(new String[] { "YSR8_PRRevision" }, new String[] { "YSR8_ChangeForm" }); + if (context2 != null && context2.length > 0) { + for(int i=0; i 0)) { + return; + } + TCComponentItemRevision ecn3Revision = (TCComponentItemRevision) context1[0].getComponent(); + TCComponentItem ecn3Item = ecn3Revision.getItem(); + + AIFComponentContext[] context2 = ecn3Item.whereReferencedByTypeRelation(new String[] { "YSR8_PRRevision" }, new String[] { "YSR8_ChangeForm" }); + if (context2 != null && context2.length > 0) {// ⱨ + TCComponentItemRevision prRevision = (TCComponentItemRevision) context2[0].getComponent(); + TCComponentForm prForm = (TCComponentForm) prRevision.getRelatedComponent("IMAN_master_form_rev"); + if (prForm == null) { + return; + } + + List propList = new ArrayList(); + propList.add("ysr8_ProjectCode"); + propList.add("ysr8_ProjectName"); + propList.add("ysr8_ProjectManager"); + propList.add("ysr8_StationNo"); + propList.add("ysr8_DesignDirector"); + propList.add("ysr8_ElectricDirector"); + propList.add("ysr8_TechPlanDate"); + propList.add("ysr8_PurchPlanDate"); + HashMap propValueMap = new HashMap(); + for (String prop : propList) { + String propValue = ""; + TCFormProperty property1 = (TCFormProperty) prForm.getFormTCProperty(prop); + switch (property1.getPropertyType()) { + case TCProperty.PROP_string: + case TCProperty.PROP_long_string: + propValue = prForm.getStringProperty(prop); + break; + case TCProperty.PROP_short: + case TCProperty.PROP_int: + propValue = Integer.toString(prForm.getIntProperty(prop)); + break; + case TCProperty.PROP_double: + case TCProperty.PROP_float: + propValue = fu.getDoubleString(prForm.getDoubleProperty(prop)); + break; + case TCProperty.PROP_date: + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date date = prForm.getDateProperty(prop); + if (date != null) { + propValue = sdf.format(date); + } + break; + default: + propValue = prForm.getStringProperty(prop); + break; + } + propValueMap.put(prop, propValue); + } + + propValueMap.put("ysr8_CustomerName", ""); + String ysr8_ProjectCodeVal = propValueMap.get("ysr8_ProjectCode"); + if (!ysr8_ProjectCodeVal.equals("")) { + TCComponentItem xmqdItem = TCUtil.findItemByID(fu.session, ysr8_ProjectCodeVal + "_XMQD"); + if (xmqdItem != null) { + TCComponentItemRevision xmqdRevision = xmqdItem.getLatestItemRevision(); + TCComponentForm xmqdForm = TCUtil.getItemRevisionMasterForm(xmqdRevision); + propValueMap.put("ysr8_CustomerName", xmqdForm.getStringProperty("ysr8_CustomerName")); + } + } + + propValueMap.put("ysr8_SubProjectName", ""); + String ysr8_SubProjectCodeVal = propValueMap.get("ysr8_StationNo"); + if (!ysr8_SubProjectCodeVal.equals("")) { + TCComponentItem item = TCUtil.findItemByID(fu.session, ysr8_SubProjectCodeVal); + if (item != null) { + String object_name = item.getProperty("object_name"); + propValueMap.put("ysr8_SubProjectName", object_name); + } + } + + iTextField textfieldForm; + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ProjectCode"); + textfieldForm.setText(propValueMap.get("ysr8_ProjectCode")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ProjectName"); + textfieldForm.setText(propValueMap.get("ysr8_ProjectName")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_CustomerName"); + textfieldForm.setText(propValueMap.get("ysr8_CustomerName")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ProjectManager"); + textfieldForm.setText(propValueMap.get("ysr8_ProjectManager")); +// textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_SubProjectCode"); +// textfieldForm.setText(propValueMap.get("ysr8_StationNo")); + @SuppressWarnings("unchecked") + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_SubProjectCode"); + cbx.setSelectedItem(propValueMap.get("ysr8_StationNo")); + + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_SubProjectName"); + textfieldForm.setText(propValueMap.get("ysr8_SubProjectName")); + + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_DesignDirector"); + if (ysr8_SubProjectCodeVal.startsWith("SW")) { + textfieldForm.setText(propValueMap.get("ysr8_DesignDirector")); + } else if (ysr8_SubProjectCodeVal.startsWith("SE")) { + textfieldForm.setText(propValueMap.get("ysr8_ElectricDirector")); + } + + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_TechPlanDate"); + textfieldForm.setText(propValueMap.get("ysr8_TechPlanDate")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_PurchPlanDate"); + textfieldForm.setText(propValueMap.get("ysr8_PurchPlanDate")); + } else {// Ŀļ + AIFComponentContext[] context3 = ecn3Item.whereReferenced();// whereReferencedByTypeRelation(new String[] {"Folder"}, new String[] + // {"contents"}); + if (context3 == null) { + return; + } + if (context3.length <= 0) { + return; + } + TCComponentFolder folder = null; + String projectId = ""; + for (int i = 0; i < context3.length; i++) { + if (context3[i].getComponent() instanceof TCComponentFolder) { + folder = (TCComponentFolder) context3[i].getComponent(); + projectId = folder.getProperty("project_ids"); + break; + } + } + if (folder == null || projectId.equals("")) { + return; + } +// TCComponentSchedule schedule = TCUtil.findScheduleByID(fu.session, projectId + "-00"); +// TCComponentSchedule schedule = TCUtil.findScheduleByProjectID(fu.session, projectId); +// if (schedule == null) { +// return; +// } +// TCComponentForm projectForm = (TCComponentForm) schedule.getRelatedComponent("IMAN_reference"); +// if (projectForm == null) { +// return; +// } + TCComponentItem xmqdItem = TCUtil.findItemByID(fu.session, projectId + "_XMQD"); + if (xmqdItem == null) { + return; + } + TCComponentItemRevision xmqdRevision = xmqdItem.getLatestItemRevision(); + TCComponentForm xmqdForm = TCUtil.getItemRevisionMasterForm(xmqdRevision); + + List propList = new ArrayList(); + propList.add("ysr8_ProjectName"); + propList.add("ysr8_CustomerName"); + propList.add("ysr8_ProjectManager"); + propList.add("ysr8_DesignDirector"); + propList.add("ysr8_ElectricDirector"); + HashMap propValueMap = new HashMap(); + propValueMap.put("ysr8_ProjectCode", projectId); + for (String prop : propList) { + String propValue = ""; + TCFormProperty property1 = (TCFormProperty) xmqdForm.getFormTCProperty(prop); + switch (property1.getPropertyType()) { + case TCProperty.PROP_string: + case TCProperty.PROP_long_string: + propValue = xmqdForm.getStringProperty(prop); + break; + case TCProperty.PROP_short: + case TCProperty.PROP_int: + propValue = Integer.toString(xmqdForm.getIntProperty(prop)); + break; + case TCProperty.PROP_double: + case TCProperty.PROP_float: + propValue = fu.getDoubleString(xmqdForm.getDoubleProperty(prop)); + break; + case TCProperty.PROP_date: + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date date = xmqdForm.getDateProperty(prop); + if (date != null) { + propValue = sdf.format(date); + } + break; + default: + propValue = xmqdForm.getStringProperty(prop); + break; + } + propValueMap.put(prop, propValue); + } + //lidy20181009ļ´ʱĿĿԶд TODO + +// AIFComponentContext[] context4 = folder.whereReferenced(); +// if (context4 == null) { +// return; +// } +// if (context4.length <= 0) { +// return; +// } +// TCComponentItemRevision partRevision = null; +// TCComponentItem partItem = null; +// for (int i = 0; i < context4.length; i++) { +// if (context4[i].getComponent() instanceof TCComponentItemRevision) { +// partRevision = (TCComponentItemRevision) context4[i].getComponent(); +// partItem = partRevision.getItem(); +// break; +// } +// } +// if (partItem == null) { +// return; +// } + propValueMap.put("ysr8_SubProjectCode", ""); + propValueMap.put("ysr8_SubProjectName", ""); + String object_type = "";//partItem.getProperty("object_type"); + + iTextField textfieldForm; + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ProjectCode"); + textfieldForm.setText(propValueMap.get("ysr8_ProjectCode")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ProjectName"); + textfieldForm.setText(propValueMap.get("ysr8_ProjectName")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_CustomerName"); + textfieldForm.setText(propValueMap.get("ysr8_CustomerName")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ProjectManager"); + textfieldForm.setText(propValueMap.get("ysr8_ProjectManager")); +// textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_SubProjectCode"); +// textfieldForm.setText(propValueMap.get("ysr8_SubProjectCode")); +// textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_SubProjectName"); +// textfieldForm.setText(propValueMap.get("ysr8_SubProjectName")); + + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_DesignDirector"); + if (object_type.equals("еĿ")) { + textfieldForm.setText(propValueMap.get("ysr8_DesignDirector")); + } else if (object_type.equals("Ŀ")) { + textfieldForm.setText(propValueMap.get("ysr8_ElectricDirector")); + } + } + } catch (TCException ex) { + ex.printStackTrace(); + } + } + + public boolean checkCanSave() { + + JTable table = (JTable) fu.allComponentMap.get("a.111.11.11"); + JTable table2 = (JTable) fu.allComponentMap.get("a.151.11.11"); + Set idSet = new HashSet<>(); + for(int i=0; i 0) { + TCComponentItemRevision ecn3Revision = (TCComponentItemRevision) context1[0].getComponent(); + TCComponentItem ecn3Item = ecn3Revision.getItem(); + + AIFComponentContext[] context2 = ecn3Item.whereReferencedByTypeRelation(new String[] { "YSR8_PRRevision" }, new String[] { "YSR8_ChangeForm" }); + if (context2 != null && context2.length > 0) {// ĵ + for(int i=0; i 0) { + for(int j=0; j cbx = (JComboBox)fu.allComponentMap.get("ysr8_SubProjectCode"); + String ysr8_SubProjectCodeVal = cbx.getSelectedItem().toString(); +// String ysr8_SubProjectCodeVal = textfield.getText(); + if (ysr8_SubProjectCodeVal.startsWith("SW") || ysr8_SubProjectCodeVal.startsWith("SE")) { + ysr8_SubProjectCodeVal = ysr8_SubProjectCodeVal.substring(2); + } + ysr8_SubProjectCodeVal += "-JG"; + String ysr8_SubProjectNameVal = ysr8_SubProjectCodeVal + " "; + iTextField textfieldForm = (iTextField) fu.allComponentMap.get("Item_ID"); + String item_IDVal = textfieldForm.getText(); + + File reportFile = null; + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + int returnVal = fileChooser.showOpenDialog(fileChooser); + if (returnVal == JFileChooser.APPROVE_OPTION) { + String dir = fileChooser.getSelectedFile().getAbsolutePath();// ѡļе· + reportFile = new File(dir + "\\" + item_IDVal + ".xlsx"); + reportFile.delete(); + tempFile.renameTo(reportFile); + } + if (reportFile == null) { + return; + } + try { + AIFComponentContext[] context1 = fu.tcForm.whereReferencedByTypeRelation(new String[] { "YSR8_ECN3Revision" }, new String[] { "IMAN_master_form" }); + if (context1 == null || context1.length <= 0) { + return; + } +// TCComponentItemRevision ecn3Revision = (TCComponentItemRevision) context1[0].getComponent(); +// TCComponentItem ecn3Item = ecn3Revision.getItem(); + String id = ecn3Item.getProperty("item_id"); + + FileInputStream fileIn = new FileInputStream(reportFile); + // String fileName = reportFile.getName().toLowerCase(); + XSSFWorkbook workbook = new XSSFWorkbook(fileIn); + XSSFSheet sheet = workbook.getSheetAt(0); + + iTextField textfield = (iTextField) fu.allComponentMap.get("ysr8_ProjectCode"); + String ysr8_ProjectCodeVal = textfield.getText(); + sheet.getRow(5).getCell(2).setCellValue(ysr8_ProjectCodeVal); + + textfield = (iTextField) fu.allComponentMap.get("ysr8_ProjectName"); + String ysr8_ProjectNameVal = textfield.getText(); + sheet.getRow(5).getCell(4).setCellValue(ysr8_ProjectNameVal); + + sheet.getRow(6).getCell(2).setCellValue(ysr8_SubProjectCodeVal); + + sheet.getRow(6).getCell(4).setCellValue(ysr8_SubProjectNameVal); + + sheet.getRow(7).getCell(2).setCellValue(ecn3Item.getProperty("item_id")); + + TCComponentProject project = (TCComponentProject) ecn3Rev.getReferenceListProperty("project_list")[0]; + List team = project.getTeam(); + TCComponent[] members = (TCComponent[])team.get(0); + System.out.println("members" + members.length); + for(TCComponent c : members) { + if(c instanceof TCComponentGroupMember) { + TCComponentGroupMember member = (TCComponentGroupMember)c; + String role = member.getRole().getStringProperty("role_name"); +// System.out.println("role" + role); + if(role.equals("Purcher")) {//ɹ + sheet.getRow(8).getCell(4).setCellValue(member.getUser().getProperty("user_name"));// ɹԱ + break; + } + } + } + + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.111.11.11"); + if (ci.dataTableModel.getRowCount() > 0) { + if (ci.dataTableModel.getRowCount() > 1) { + POIUtil.insertRow(sheet, 10, ci.dataTableModel.getRowCount() - 1); + } + String cl = new StringBuilder("CL").append(ysr8_ProjectCodeVal.substring(0, 2)).append(ysr8_ProjectCodeVal.substring(ysr8_ProjectCodeVal.length()-4)) + .append(id.substring(id.lastIndexOf("-"))).append("-").toString(); + int currRowIdx = 10; + for (int i = 0; i < ci.dataTableModel.getRowCount(); i++) { + XSSFRow row = sheet.getRow(currRowIdx); + row.getCell(0).setCellValue(ci.dataTableModel.getValueAt(i, 0) == null ? "" : ci.dataTableModel.getValueAt(i, 0).toString()); + row.getCell(1).setCellValue(ci.dataTableModel.getValueAt(i, 1) == null ? "" : ci.dataTableModel.getValueAt(i, 1).toString()); + row.getCell(2).setCellValue(ci.dataTableModel.getValueAt(i, 2) == null ? "" : ci.dataTableModel.getValueAt(i, 2).toString()); + row.getCell(3).setCellValue(ci.dataTableModel.getValueAt(i, 3) == null ? "" : ci.dataTableModel.getValueAt(i, 3).toString()); + row.getCell(4).setCellValue(ci.dataTableModel.getValueAt(i, 4) == null ? "" : ci.dataTableModel.getValueAt(i, 4).toString()); + row.getCell(5).setCellValue(ci.dataTableModel.getValueAt(i, 5) == null ? "" : ci.dataTableModel.getValueAt(i, 5).toString()); + row.getCell(6).setCellValue(ci.dataTableModel.getValueAt(i, 6) == null ? "" : ci.dataTableModel.getValueAt(i, 6).toString()); + row.getCell(7).setCellValue(ci.dataTableModel.getValueAt(i, 11) == null ? "" : ci.dataTableModel.getValueAt(i, 11).toString()); + row.getCell(9).setCellValue(cl + new DecimalFormat("000").format(i+1));//TODO CL + currRowIdx++; + } + } + + FileOutputStream fileOut = new FileOutputStream(reportFile.getPath()); + workbook.write(fileOut); + fileOut.flush(); + fileOut.close(); + } catch (TCException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + + // 򿪵ıļ + try { + Runtime.getRuntime().exec("cmd /c \"" + reportFile.getPath() + "\""); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @SuppressWarnings("unchecked") + private void setComboBoxValue_ysr8_SubProjectCode() { + //JComboBoxInfo ci = (JComboBoxInfo)fu.allComponentInfos.get("ysr8_SubProjectCode"); + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_SubProjectCode"); + iTextField textfield = (iTextField)fu.allComponentMap.get("ysr8_ProjectCode"); + map = new HashMap(); + String projectCode = textfield.getText().toString(); + if (projectCode.equals("")) { + return; + } + try { + TCComponentItem systemPartsItem = TCUtil.findItemByID(fu.session, projectCode); + if (systemPartsItem != null) { + TCComponentItemRevision systemPartsRevision = systemPartsItem.getLatestItemRevision(); + TCComponentPseudoFolder folder = TCUtil.getRevisionPseudoFolder(systemPartsRevision, "ͼ"); + if (folder != null) { + AIFComponentContext[] comps = folder.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("еĿ") || objType.equals("Ŀ")) { + cbx.addItem(comp.getProperty("item_id")); + map.put(comp.getProperty("item_id"), comp.getProperty("object_name")); + } + } + } + } + } + } + cbx.addItem(""); + map.put("", ""); + + String ysr8_SubProjectCodeVal = fu.tcForm.getProperty("ysr8_SubProjectCode"); + if (!ysr8_SubProjectCodeVal.equals("")) { + cbx.setSelectedItem(ysr8_SubProjectCodeVal); + } + } catch (TCException e) { + e.printStackTrace(); + } + } + private void refrashTable2(int[] rows, boolean update) {//TODO 2ʾ + System.out.println("refrashTable2"); + JTable table = (JTable) fu.allComponentMap.get("a.111.11.11"); + Map map2 = new HashMap<>(); + for(int i=0; i0"); + c.setTime(getDate(purchPlan)); + c.add(Calendar.DAY_OF_MONTH, day); + table2.setValueAt(fu.getDateString(c.getTime()), i, 6); + } + Date machAsk = c.getTime(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date ask = sdf.parse(fu.getDateString(machAsk)+" 23:59:59"); + if(machFinish.isEmpty()) { + if(!ask.after(new Date())) + table2.setValueAt("", i, table2Map.get("Ƿ")); + else + table2.setValueAt("", i, table2Map.get("Ƿ")); + }else { + if(!ask.after(getDate(machFinish.substring(0, 10)))) + table2.setValueAt("", i, table2Map.get("Ƿ")); + else + table2.setValueAt("", i, table2Map.get("Ƿ")); + System.out.println(machAsk+"=="+machFinish+"=="+table2.getValueAt(i, table2Map.get("Ƿ"))); + } + } + } + }catch(Exception e) { + e.printStackTrace(); + } + } + private String getTableValue(JTable table, int r, int c) { + if(table.getValueAt(r, c)==null) + return ""; + else + return table.getValueAt(r, c).toString(); + } + private Date getDate(String s) throws ParseException { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + if(s==null || s.isEmpty()) + return null; + if(s.length()>10) + sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + return sdf.parse(s); + } +} diff --git a/src/cn/com/ebewin/ysr/form/YSR8_ECN4RevisionMasterForm.java b/src/cn/com/ebewin/ysr/form/YSR8_ECN4RevisionMasterForm.java new file mode 100644 index 0000000..cba2b3c --- /dev/null +++ b/src/cn/com/ebewin/ysr/form/YSR8_ECN4RevisionMasterForm.java @@ -0,0 +1,1429 @@ +package cn.com.ebewin.ysr.form; + +import java.awt.Dimension; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.io.File; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Vector; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JDialog; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JTable; +import javax.swing.RowSorter; +import javax.swing.SortOrder; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.commands.open.OpenFormDialog; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentPseudoFolder; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCFormProperty; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.iTextField; + +import cn.com.ebewin.ysr.dialog.ProgressReporterDialog; +import cn.com.ebewin.ysr.util.CommonUtil; +import cn.com.ebewin.ysr.util.FormCheckUtil; +import cn.com.ebewin.ysr.util.FormUtil; +import cn.com.ebewin.ysr.util.TCUtil; +import jxl.Workbook; +import jxl.format.Alignment; +import jxl.format.Border; +import jxl.format.BorderLineStyle; +import jxl.format.VerticalAlignment; +import jxl.write.Label; +import jxl.write.WritableCellFormat; +import jxl.write.WritableFont; +import jxl.write.WritableSheet; +import jxl.write.WritableWorkbook; +import jxl.write.WriteException; + +@SuppressWarnings("deprecation") +public class YSR8_ECN4RevisionMasterForm extends AbstractRendering { + private static final long serialVersionUID = 1L; + private static Date refreshDate = null; + private Map map = null; + + FormUtil fu = new FormUtil(this); + FormCheckUtil fcu = null; + TCComponentForm form = null; + TCComponentItem ecn4Item = null; + + private Map table2Map; + + public YSR8_ECN4RevisionMasterForm(TCComponentForm arg0) throws Exception { + super(arg0); + form = arg0; + + AIFComponentContext[] context1 = form.whereReferencedByTypeRelation + (new String[] { "YSR8_ECN4Revision" }, new String[] { "IMAN_master_form" }); + if (!(context1 != null && context1.length > 0)) { + return; + } + table2Map = new HashMap<>(); + table2Map.put("", 2);// + table2Map.put("ID", 4); + table2Map.put("Ƿ", 10); + ecn4Item = ((TCComponentItemRevision) context1[0].getComponent()).getItem(); + + Date currDate = new Date(); + if (refreshDate == null) { + arg0.refresh(); + refreshDate = currDate; + } else { + long diff = currDate.getTime() - refreshDate.getTime(); + long minutes = diff / 1000 / 60; + if (minutes >= 1) { + arg0.refresh(); + refreshDate = currDate; + } + } + + fu.readRenderingXML("YSR8_ECN4RevisionMasterForm"); + fu.initializeUI(arg0); + + JTable table = (JTable) fu.allComponentMap.get("a.111.11.11"); + table.setAutoCreateRowSorter(true); + TableRowSorter sorter = new TableRowSorter(table.getModel()); + ArrayList sortKeys = new ArrayList(); + sortKeys.add(new RowSorter.SortKey(2, SortOrder.ASCENDING)); + sorter.setSortKeys(sortKeys); + table.setRowSorter(sorter); + + loadRendering(); + getDefVal(); + setComboBoxValue_ysr8_SubProjectCode(); + + addActionListener(); + int count = ((JTable) fu.allComponentMap.get("a.151.11.11")).getRowCount(); + if(count>0) { + int[] rows = new int[count]; + for(int i=0; i 0) { + TCComponentItemRevision ecn4Revision = (TCComponentItemRevision) context1[0].getComponent(); + TCComponentItem ecn4Item = ecn4Revision.getItem(); + + iTextField textfieldForm; + textfieldForm = (iTextField) fu.allComponentMap.get("Item_ID"); + textfieldForm.setText(ecn4Item.getProperty("item_id")); + } + + fu.loadRendering(); + + fcu = new FormCheckUtil(fu.tcForm, fu.allComponentMap); + fcu.checkHandler(); + } + + public void setRenderingReadOnly() { + setModifiableComponents(this, false); + if (getController() != null) + getController().setFormReadOnly(); + + JButton btn = (JButton) fu.allComponentMap.get("b.111.12.41"); + if (btn != null) { + btn.setEnabled(true); +// if (btn.getParent() != null) +// btn.getParent().setEnabled(true); +// if (btn.getParent().getParent() != null) +// btn.getParent().getParent().setEnabled(true); + } + } + + public void setRenderingReadWrite() { + if (fcu != null && fcu.isNeedCheck()) { + fcu.setEnable(); + fu.isCheckOut = true; + return; + } + setModifiableComponents(this, true); + + fu.allComponentMap.get("ysr8_ChangeReason").setEnabled(false); + fu.allComponentMap.get("b.061.15").setEnabled(false); + fu.allComponentMap.get("ysr8_TechFinishDate").setEnabled(false); + fu.allComponentMap.get("ysr8_PurchFinishDate").setEnabled(false); + } + + private void setModifiableComponents(java.awt.Component currcomponent, boolean flag) { + if (fcu != null && flag) { + if (fcu.isNeedCheck()) { + return; + } + } + fu.setModifiableComponents(currcomponent, flag); + } + + /** + * (non-Javadoc) + * + * @see com.teamcenter.rac.form.AbstractTCForm#saveForm() + */ + @Override + public void saveRendering() { + if (!checkCanSave()) { + return; + } + countYsr8_SubTotalExpense(); + // try { + // if (fu.tcForm.getDoubleProperty("ysr8_TotalExpense") == 0.0) { + // countYsr8_TotalExpense(); + // } + // } catch (TCException e) { + // e.printStackTrace(); + // return; + // } + countYsr8_TotalExpense(); + + Integer idx = 0; + JTable table = (JTable) fu.allComponentMap.get("a.111.11.11"); + for (int i = 0; i < table.getRowCount(); i++) { + table.setValueAt((++idx), i, 0);// + } + + try { + fu.saveRendering(); + } catch (TCException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } catch (ParseException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } + + linkPR(); + } + + public boolean isRenderingModified() { + return fu.isRenderingModified(); + } + + private void addActionListener() { + { + @SuppressWarnings("unchecked") + final JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_SubProjectCode"); + cbx.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + iTextField SubProjectName = (iTextField) fu.allComponentMap.get("ysr8_SubProjectName"); + if(cbx.getSelectedItem().equals("")) { + SubProjectName.setText(""); + } else if(map.containsKey(cbx.getSelectedItem())) + SubProjectName.setText(map.get(cbx.getSelectedItem())); + } + }); + } + { + JButton btn = (JButton) fu.allComponentMap.get("b.061.15"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + countYsr8_TotalExpense(); + } + }); + } + ////////////////////////////////////////////////////// + { + JButton btn = (JButton) fu.allComponentMap.get("b.111.12.11"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.111.11.11"); + Object[] objData = new Object[ci.childComponentInfos.size()]; + for (int i = 0; i < objData.length; i++) { + if (i == 16) { // kk һ 14 + objData[i] = "1"; + } else { + objData[i] = ""; + } + } + ci.dataTableModel.addRow(objData); + } + }); + + btn = (JButton) fu.allComponentMap.get("b.111.12.21"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.111.11.11"); + JTable table = (JTable) fu.allComponentMap.get("a.111.11.11"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪƳУ", "ʾ", MessageBox.INFORMATION); + return; + } + for (int i = rows.length - 1; i >= 0; i--) { + ci.dataTableModel.removeRow(table.convertRowIndexToModel(rows[i])); + } + } + }); + + btn = (JButton) fu.allComponentMap.get("b.111.12.31"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.111.11.11"); + // JTable table = (JTable)fu.allComponentMap.get("a.111.11.11"); + + try { + AIFComponentContext[] context1 = fu.tcForm.whereReferencedByTypeRelation(new String[] { "YSR8_ECN4Revision" }, new String[] { "IMAN_master_form" }); + if (context1 == null || context1.length <= 0) { + return; + } + if(ci.dataTableModel.getRowCount()>0) + for(int j=ci.dataTableModel.getRowCount(); j>0; j--) + ci.dataTableModel.removeRow(j-1); + FormUtil.JTableInfo t2 = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.151.11.11");//ձ2 + if(t2.dataTableModel.getRowCount()>0) + for(int j=t2.dataTableModel.getRowCount(); j>0; j--) + t2.dataTableModel.removeRow(j-1); + // ±д + int newIndex=1; +// DecimalFormat df=new DecimalFormat("#"); + TCComponentItemRevision ecn4Revision = (TCComponentItemRevision) context1[0].getComponent(); + + TCComponentPseudoFolder pseudoFolder = TCUtil.getRevisionPseudoFolder(ecn4Revision, "ӹͼֽ"); + 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 TCComponentItemRevision) { + TCComponentItemRevision itemRevision = (TCComponentItemRevision) comp; + TCComponentItem item = itemRevision.getItem(); + String item_idVal = item.getProperty("item_id"); + String object_nameVal = item.getProperty("object_name"); + String item_revision_idVal = itemRevision.getProperty("item_revision_id"); + Object[] objData = new Object[ci.childComponentInfos.size()]; + for (int m = 0; m < objData.length; m++) { + if (m == 0) { + objData[m] = (ci.dataTableModel.getRowCount() + 1) + ""; + } else if (m == 1) { + objData[m] = item_revision_idVal; + } else if (m == 2) { + objData[m] = item_idVal; + } else if (m == 3) { + objData[m] = object_nameVal; + } else if (m == 16) { // kk һ 15 + objData[m] = "1"; + } else { + objData[m] = ""; + } + } + ci.dataTableModel.addRow(objData); + + Vector temp2 = new Vector<>();//TODO д2 + temp2.add((newIndex++)+"");// + temp2.add(item_revision_idVal);//汾 + temp2.add(item_idVal);// + temp2.add(object_nameVal);// + temp2.add("");//ID + temp2.add("");//ӹʼƻʱ + temp2.add("");//ӹҪʱ + temp2.add("");//ӹʵʱ + temp2.add("");//ӹԭ + temp2.add("");//ļƻʱ + temp2.add("");//Ƿ + t2.dataTableModel.addRow(temp2); + } + } + } + } catch (TCException ex) { + ex.printStackTrace(); + } + } + }); + + btn = (JButton) fu.allComponentMap.get("b.111.12.41"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + OutputExcel(); + } + }); + + btn = (JButton) fu.allComponentMap.get("b.151.12.11");//TODO Ӱť + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + int option=JOptionPane.showOptionDialog(null, "ȷͬ񣬱ݻ", "ʾ", + JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE, null, new String[] {"ȷ","ȡ"}, ""); +// System.out.println("value:"+option); + if(option == 0) { + FormUtil.JTableInfo t2 = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.151.11.11");// + if(t2.dataTableModel.getRowCount()>0) + for(int i=t2.dataTableModel.getRowCount(); i>0; i--) + t2.dataTableModel.removeRow(i-1); + + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.111.11.11"); + if(ci.dataTableModel.getRowCount()>0) { + JTable table = (JTable) fu.allComponentMap.get("a.111.11.11"); + for(int i=0; i temp2 = new Vector<>(); + temp2.add(getTableValue(table, i, 0));// + temp2.add(getTableValue(table, i, 1));//汾 + temp2.add(getTableValue(table, i, 2));// + temp2.add(getTableValue(table, i, 3));// + temp2.add("");//ID + temp2.add("");//ӹʼƻʱ + temp2.add("");//ӹҪʱ + temp2.add("");//ӹʵʱ + temp2.add("");//ӹԭ + temp2.add("");//ļƻʱ + temp2.add("");//Ƿ + t2.dataTableModel.addRow(temp2); + } + } + } + } + }); + + btn = (JButton) fu.allComponentMap.get("b.151.12.21"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + JTable table = (JTable) fu.allComponentMap.get("a.151.11.11"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪƳУ", "ʾ", MessageBox.INFORMATION); + return; + } + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.151.11.11"); + for (int i = rows.length - 1; i >= 0; i--) { + boolean only = true; + for(int j=0; j temp2 = new Vector<>(); + temp2.add("");// + temp2.add(getTableValue(table, rows[0], 1));//汾 + temp2.add(getTableValue(table, rows[0], 2));// + temp2.add(getTableValue(table, rows[0], 3));// + temp2.add("");//ID + temp2.add("");//ӹʼƻʱ + temp2.add("");//ӹҪʱ + temp2.add("");//ӹʵʱ + temp2.add("");//ӹԭ + temp2.add("");//ļƻʱ + temp2.add("");//Ƿ + ci.dataTableModel.insertRow(rows[0]+1, temp2); + for(int i=0; i1) { + for(int i : rows) { + if(!getTableValue(table, rows[0], table2Map.get("ID")) + .equals(getTableValue(table, i, table2Map.get("ID")))) { + MessageBox.post("ѡаͬ޷༭", "ʾ", MessageBox.INFORMATION); + return; + } + if(!getTableValue(table, i, table2Map.get("Ƿ")).equals("")) { + MessageBox.post("ѡаδУ޷༭", "ʾ", MessageBox.INFORMATION); + return; + } + } + } + String[] lovs = TCUtil.getPreference(form.getSession(), TCPreferenceService.TC_preference_site, "YSR8_Ecn24DelayReason_LOV"); + final JDialog dialog = new JDialog(AIFUtility.getActiveDesktop().getFrame(), true); + dialog.setTitle("༭"); + JLabel label = new JLabel("ӹԭ"); + dialog.add(label); + label.setBounds(20, 20, 80, 24); +// final JTextArea area = new JTextArea(); +// area.setLineWrap(true); + final JComboBox area = new JComboBox<>(); + area.addItem(""); + if(lovs!=null && lovs.length>0) + for(String s : lovs) + area.addItem(s); + area.setEditable(true); + area.setBounds(100, 20, 200, 24); + dialog.add(area); + JButton btn1 = new JButton("ȷ"); + btn1.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent arg0) { + if(area.getSelectedItem().toString().isEmpty()) { + MessageBox.post(dialog, "дӹԭ", "ʾ", MessageBox.WARNING); + return; + } + for(int i : rows) { + table.setValueAt(area.getSelectedItem().toString(), i, 8); + } + dialog.dispose(); + } + }); + dialog.add(btn1); + btn1.setBounds(20, 100, 80, 24); + JButton btn2 = new JButton("ȡ"); + btn2.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent arg0) { + dialog.dispose(); + } + }); + dialog.add(btn2); + btn2.setBounds(220, 100, 80, 24); + dialog.add(new JLabel("")); + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + dialog.setBounds((screenSize.width - 350)/2, (screenSize.height - 200)/2, 350, 200); + dialog.setVisible(true); + + } + }); + + btn = (JButton) fu.allComponentMap.get("b.151.12.61"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { +// FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.151.11.11"); + JTable table = (JTable) fu.allComponentMap.get("a.151.11.11"); + final int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪУ", "ʾ", MessageBox.INFORMATION); + return; + } + if(rows.length>1) { + Set set = new HashSet<>(); + for(int i : rows) { + if(set.contains(getTableValue(table, i, table2Map.get("")))) { + MessageBox.post("ͬһIJͬвͬ", "ʾ", MessageBox.INFORMATION); + return; + }else + set.add(getTableValue(table, i, table2Map.get(""))); + } + } + final JDialog dialog = new JDialog(AIFUtility.getActiveDesktop().getFrame(), true); + dialog.setTitle(""); + final JComboBox combo = new JComboBox<>(); + final Map techMap = new HashMap<>(); + final Map machMap = new HashMap<>(); + try { + AIFComponentContext[] context2 = ecn4Item.whereReferencedByTypeRelation(new String[] { "YSR8_PRRevision" }, new String[] { "YSR8_ChangeForm" }); + if (context2 != null && context2.length > 0) { + for(int i=0; i 0)) { + return; + } + TCComponentItemRevision ecn4Revision = (TCComponentItemRevision) context1[0].getComponent(); + TCComponentItem ecn4Item = ecn4Revision.getItem(); + + AIFComponentContext[] context2 = ecn4Item.whereReferencedByTypeRelation(new String[] { "YSR8_PRRevision" }, new String[] { "YSR8_ChangeForm" }); + if (context2 != null && context2.length > 0) {// ⱨ + TCComponentItemRevision prRevision = (TCComponentItemRevision) context2[0].getComponent(); + TCComponentForm prForm = (TCComponentForm) prRevision.getRelatedComponent("IMAN_master_form_rev"); + if (prForm == null) { + return; + } + + List propList = new ArrayList(); + propList.add("ysr8_ProjectCode"); + propList.add("ysr8_ProjectName"); + propList.add("ysr8_ProjectManager"); + propList.add("ysr8_StationNo"); + propList.add("ysr8_DesignDirector"); + propList.add("ysr8_ElectricDirector"); + propList.add("ysr8_TechPlanDate"); + propList.add("ysr8_MachinPlanDate"); + HashMap propValueMap = new HashMap(); + for (String prop : propList) { + String propValue = ""; + TCFormProperty property1 = (TCFormProperty) prForm.getFormTCProperty(prop); + switch (property1.getPropertyType()) { + case TCProperty.PROP_string: + case TCProperty.PROP_long_string: + propValue = prForm.getStringProperty(prop); + break; + case TCProperty.PROP_short: + case TCProperty.PROP_int: + propValue = Integer.toString(prForm.getIntProperty(prop)); + break; + case TCProperty.PROP_double: + case TCProperty.PROP_float: + propValue = fu.getDoubleString(prForm.getDoubleProperty(prop)); + break; + case TCProperty.PROP_date: + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date date = prForm.getDateProperty(prop); + if (date != null) { + propValue = sdf.format(date); + } + break; + default: + propValue = prForm.getStringProperty(prop); + break; + } + propValueMap.put(prop, propValue); + } + + propValueMap.put("ysr8_CustomerName", ""); + String ysr8_ProjectCodeVal = propValueMap.get("ysr8_ProjectCode"); + if (!ysr8_ProjectCodeVal.equals("")) { + TCComponentItem xmqdItem = TCUtil.findItemByID(fu.session, ysr8_ProjectCodeVal + "_XMQD"); + if (xmqdItem != null) { + TCComponentItemRevision xmqdRevision = xmqdItem.getLatestItemRevision(); + TCComponentForm xmqdForm = TCUtil.getItemRevisionMasterForm(xmqdRevision); + propValueMap.put("ysr8_CustomerName", xmqdForm.getStringProperty("ysr8_CustomerName")); + } + } + + propValueMap.put("ysr8_SubProjectName", ""); + String ysr8_SubProjectCodeVal = propValueMap.get("ysr8_StationNo"); + if (!ysr8_SubProjectCodeVal.equals("")) { + TCComponentItem item = TCUtil.findItemByID(fu.session, ysr8_SubProjectCodeVal); + if (item != null) { + String object_name = item.getProperty("object_name"); + propValueMap.put("ysr8_SubProjectName", object_name); + } + } + + iTextField textfieldForm; + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ProjectCode"); + textfieldForm.setText(propValueMap.get("ysr8_ProjectCode")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ProjectName"); + textfieldForm.setText(propValueMap.get("ysr8_ProjectName")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_CustomerName"); + textfieldForm.setText(propValueMap.get("ysr8_CustomerName")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ProjectManager"); + textfieldForm.setText(propValueMap.get("ysr8_ProjectManager")); +// textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_SubProjectCode"); +// textfieldForm.setText(propValueMap.get("ysr8_StationNo")); + @SuppressWarnings("unchecked") + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_SubProjectCode"); + cbx.setSelectedItem(propValueMap.get("ysr8_StationNo")); + + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_SubProjectName"); + textfieldForm.setText(propValueMap.get("ysr8_SubProjectName")); + + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_DesignDirector"); + if (ysr8_SubProjectCodeVal.startsWith("SW")) { + textfieldForm.setText(propValueMap.get("ysr8_DesignDirector")); + } else if (ysr8_SubProjectCodeVal.startsWith("SE")) { + textfieldForm.setText(propValueMap.get("ysr8_ElectricDirector")); + } + + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_TechPlanDate"); + textfieldForm.setText(propValueMap.get("ysr8_TechPlanDate")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_PurchPlanDate"); + textfieldForm.setText(propValueMap.get("ysr8_MachinPlanDate")); + } else {// Ŀļ + AIFComponentContext[] context3 = ecn4Item.whereReferenced();// whereReferencedByTypeRelation(new String[] {"Folder"}, new String[] + // {"contents"}); + if (context3 == null) { + return; + } + if (context3.length <= 0) { + return; + } + TCComponentFolder folder = null; + String projectId = ""; + for (int i = 0; i < context3.length; i++) { + if (context3[i].getComponent() instanceof TCComponentFolder) { + folder = (TCComponentFolder) context3[i].getComponent(); + projectId = folder.getProperty("project_ids"); + break; + } + } + if (folder == null || projectId.equals("")) { + return; + } +// TCComponentSchedule schedule = TCUtil.findScheduleByID(fu.session, projectId + "-00"); +// TCComponentSchedule schedule = TCUtil.findScheduleByProjectID(fu.session, projectId); +// if (schedule == null) { +// return; +// } +// TCComponentForm projectForm = (TCComponentForm) schedule.getRelatedComponent("IMAN_reference"); +// if (projectForm == null) { +// return; +// } + + TCComponentItem xmqdItem = TCUtil.findItemByID(fu.session, projectId + "_XMQD"); + if (xmqdItem == null) { + return; + } + TCComponentItemRevision xmqdRevision = xmqdItem.getLatestItemRevision(); + TCComponentForm xmqdForm = TCUtil.getItemRevisionMasterForm(xmqdRevision); + + List propList = new ArrayList(); + propList.add("ysr8_ProjectName"); + propList.add("ysr8_CustomerName"); + propList.add("ysr8_ProjectManager"); + propList.add("ysr8_DesignDirector"); + propList.add("ysr8_ElectricDirector"); + HashMap propValueMap = new HashMap(); + propValueMap.put("ysr8_ProjectCode", projectId); + for (String prop : propList) { + String propValue = ""; + TCFormProperty property1 = (TCFormProperty) xmqdForm.getFormTCProperty(prop); + switch (property1.getPropertyType()) { + case TCProperty.PROP_string: + case TCProperty.PROP_long_string: + propValue = xmqdForm.getStringProperty(prop); + break; + case TCProperty.PROP_short: + case TCProperty.PROP_int: + propValue = Integer.toString(xmqdForm.getIntProperty(prop)); + break; + case TCProperty.PROP_double: + case TCProperty.PROP_float: + propValue = fu.getDoubleString(xmqdForm.getDoubleProperty(prop)); + break; + case TCProperty.PROP_date: + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date date = xmqdForm.getDateProperty(prop); + if (date != null) { + propValue = sdf.format(date); + } + break; + default: + propValue = xmqdForm.getStringProperty(prop); + break; + } + propValueMap.put(prop, propValue); + } + + AIFComponentContext[] context4 = folder.whereReferenced(); + if (context4 == null) { + return; + } + if (context4.length <= 0) { + return; + } +// TCComponentItemRevision partRevision = null; +// TCComponentItem partItem = null; +// for (int i = 0; i < context4.length; i++) { +// if (context4[i].getComponent() instanceof TCComponentItemRevision) { +// partRevision = (TCComponentItemRevision) context4[i].getComponent(); +// partItem = partRevision.getItem(); +// break; +// } +// } + +// if (partItem == null) { +// return; +// } +// propValueMap.put("ysr8_SubProjectCode", partItem.getProperty("item_id")); +// propValueMap.put("ysr8_SubProjectName", partItem.getProperty("object_name")); + propValueMap.put("ysr8_SubProjectCode", ""); + propValueMap.put("ysr8_SubProjectName", ""); + String object_type = "";//partItem.getProperty("object_type"); + + iTextField textfieldForm; + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ProjectCode"); + textfieldForm.setText(propValueMap.get("ysr8_ProjectCode")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ProjectName"); + textfieldForm.setText(propValueMap.get("ysr8_ProjectName")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_CustomerName"); + textfieldForm.setText(propValueMap.get("ysr8_CustomerName")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ProjectManager"); + textfieldForm.setText(propValueMap.get("ysr8_ProjectManager")); +// textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_SubProjectCode"); +// textfieldForm.setText(propValueMap.get("ysr8_SubProjectCode")); +// textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_SubProjectName"); +// textfieldForm.setText(propValueMap.get("ysr8_SubProjectName")); + + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_DesignDirector"); + if (object_type.equals("еĿ")) { + textfieldForm.setText(propValueMap.get("ysr8_DesignDirector")); + } else if (object_type.equals("Ŀ")) { + textfieldForm.setText(propValueMap.get("ysr8_ElectricDirector")); + } + } + } catch (TCException ex) { + ex.printStackTrace(); + } + } + + public boolean checkCanSave() { + + JTable table = (JTable) fu.allComponentMap.get("a.111.11.11"); + JTable table2 = (JTable) fu.allComponentMap.get("a.151.11.11"); + Set idSet = new HashSet<>(); + for(int i=0; i 0) { + TCComponentItemRevision ecn4Revision = (TCComponentItemRevision) context1[0].getComponent(); + TCComponentItem ecn4Item = ecn4Revision.getItem(); + + AIFComponentContext[] context2 = ecn4Item.whereReferencedByTypeRelation(new String[] { "YSR8_PRRevision" }, new String[] { "YSR8_ChangeForm" }); + if (context2 != null && context2.length > 0) {// ĵ + for(int i=0; i 0) { + for(int j=0; j cbx = (JComboBox)fu.allComponentMap.get("ysr8_SubProjectCode"); + final String[] ysr8_SubProjectCodeVal = { cbx.getSelectedItem().toString() }; + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_SubProjectName"); + final String[] ysr8_SubProjectNameVal = { textfieldForm.getText() }; + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_DesignDirector"); + final String[] ysr8_DesignDirectorVal = { textfieldForm.getText() }; + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_Changer"); + final String[] ysr8_ChangerVal = { textfieldForm.getText() }; + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ApplicationDate"); + final String[] ysr8_ApplicationDateVal = { textfieldForm.getText() }; + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_PurchPlanDate"); + final String[] ysr8_PurchPlanDateVal = { textfieldForm.getText() }; + + final String[] reportFileName = { "" }; + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + int returnVal = fileChooser.showOpenDialog(fileChooser); + if (returnVal == JFileChooser.APPROVE_OPTION) { + String dir = fileChooser.getSelectedFile().getAbsolutePath();// ѡļе· + reportFileName[0] = dir + "\\" + item_IDVal + ".xls"; + } + if (reportFileName[0].equals("")) { + btn.setEnabled(true); + return; + } + + final JTable table1 = (JTable) fu.allComponentMap.get("a.111.11.11"); + + final ProgressReporterDialog reporter = new ProgressReporterDialog(); + reporter.reportProgressMessage("ڵ,Ժ..."); + new Thread(reporter).start(); + new Thread() { + public void run() { + try { + File reportFile = new File(reportFileName[0]); + reportFile.delete(); + // һдWorkbook + WritableWorkbook writeWorkBook = Workbook.createWorkbook(reportFile); + // + WritableSheet wsheet = writeWorkBook.createSheet("ļӹ", 0); + + // д + int[] columnCount = { 0, 1, 2, 3, 4 }; // + int rowCount = table1.getRowCount(); // + String[] titles = new String[columnCount.length]; // ͷ + + // ȡͷ + for (int i = 0; i < columnCount.length; i++) { + titles[i] = table1.getColumnName(columnCount[i]); + } + + int current_row = 0; // ʼǰΪʼ + + try { + // ʽ + WritableFont titleFont = new WritableFont(WritableFont.createFont(""), 13, WritableFont.BOLD); + WritableCellFormat titleCellFormat = new WritableCellFormat(titleFont); + titleCellFormat.setBorder(Border.ALL, BorderLineStyle.MEDIUM); + titleCellFormat.setAlignment(Alignment.CENTRE); + titleCellFormat.setVerticalAlignment(VerticalAlignment.CENTRE); + titleCellFormat.setWrap(true); + + WritableCellFormat titleCellFormat2 = new WritableCellFormat(titleFont); + titleCellFormat2.setAlignment(Alignment.CENTRE); + titleCellFormat2.setVerticalAlignment(VerticalAlignment.CENTRE); + titleCellFormat2.setWrap(true); + + // ʽ + WritableFont contentFont = new WritableFont(WritableFont.createFont(""), 12); + WritableCellFormat contentCellFormat = new WritableCellFormat(contentFont); + contentCellFormat.setBorder(Border.ALL, BorderLineStyle.THIN); + contentCellFormat.setAlignment(Alignment.CENTRE); + contentCellFormat.setVerticalAlignment(VerticalAlignment.CENTRE); + contentCellFormat.setWrap(true); + + WritableCellFormat contentCellFormat2 = new WritableCellFormat(contentFont); + contentCellFormat2.setAlignment(Alignment.CENTRE); + contentCellFormat2.setVerticalAlignment(VerticalAlignment.CENTRE); + contentCellFormat2.setWrap(true); + + Label labelTitle = new Label(0, current_row, "Ŀ", titleCellFormat2); + wsheet.addCell(labelTitle); + Label labelContent = new Label(1, current_row, ysr8_ProjectCodeVal[0], contentCellFormat2); + wsheet.addCell(labelContent); + + labelTitle = new Label(3, current_row, "", titleCellFormat2); + wsheet.addCell(labelTitle); + labelContent = new Label(4, current_row, ysr8_DesignDirectorVal[0], contentCellFormat2); + wsheet.addCell(labelContent); + + labelTitle = new Label(5, current_row, "", titleCellFormat2); + wsheet.addCell(labelTitle); + labelContent = new Label(6, current_row, ysr8_ChangerVal[0], contentCellFormat2); + wsheet.addCell(labelContent); + +// labelTitle = new Label(4, current_row, "Ŀ", titleCellFormat2); +// wsheet.addCell(labelTitle); +// labelContent = new Label(5, current_row, ysr8_SubProjectCodeVal[0], contentCellFormat2); +// wsheet.addCell(labelContent); + current_row = current_row + 1; + + labelTitle = new Label(0, current_row, "Ŀ", titleCellFormat2); + wsheet.addCell(labelTitle); + labelContent = new Label(1, current_row, ysr8_ProjectNameVal[0], contentCellFormat2); + wsheet.addCell(labelContent); + + labelTitle = new Label(3, current_row, "Ŀ", titleCellFormat2); + wsheet.addCell(labelTitle); + labelContent = new Label(4, current_row, ysr8_SubProjectNameVal[0], contentCellFormat2); + wsheet.addCell(labelContent); + + labelTitle = new Label(5, current_row, "", titleCellFormat2); + wsheet.addCell(labelTitle); + labelContent = new Label(6, current_row, ysr8_ApplicationDateVal[0], contentCellFormat2); + wsheet.addCell(labelContent); + + labelTitle = new Label(7, current_row, "Ҫӹʱ", titleCellFormat2); + wsheet.addCell(labelTitle); + labelContent = new Label(8, current_row, ysr8_PurchPlanDateVal[0], contentCellFormat2); + wsheet.addCell(labelContent); + current_row = current_row + 1; + + Map insertCol = new HashMap<>(); + insertCol.put(1, new String[] {"ĵ", ecn4Item.getProperty("item_id")}); + insertCol.put(3, new String[] {"Ŀ", ysr8_SubProjectCodeVal[0]}); + insertCol.put(6, new String[] {"ķ", "¼ӹ"}); + // дб + int move = 0; + for (int i = 0; i < columnCount.length; i++) { + if(insertCol.containsKey(i+move)) { + labelTitle = new Label(i+move, current_row, insertCol.get(i+move)[0], titleCellFormat); + wsheet.addCell(labelTitle); + move++; + }else if(i+move==5){ +// move--; + } + labelTitle = new Label(i+move, current_row, titles[i], titleCellFormat); + wsheet.addCell(labelTitle); + } + current_row = current_row + 1; + + // д + for (int i = 0; i < rowCount; i++) { + move = 0; + for (int j = 0; j < columnCount.length; j++) { + Object objValue = table1.getValueAt(i, columnCount[j]); + String val = ""; + if (objValue != null) { + val = String.valueOf(objValue); + } + if(j + move == 4) { + String val2 = String.valueOf(table1.getValueAt(i, columnCount[j+1])); + if(!val.isEmpty() && !val2.isEmpty()) + val = val + "-" + val2; + else + val = val + val2; + } + if(insertCol.containsKey(j + move)) { + labelContent = new Label(j + move, i + current_row, insertCol.get(j + move)[1], contentCellFormat); + wsheet.addCell(labelContent); + move++; + }else if(i+move==5){ +// move--; + } + labelContent = new Label(j + move, i + current_row, val, contentCellFormat); + wsheet.addCell(labelContent); + } + } + + // øʽ + wsheet.getSettings().setDefaultColumnWidth(20); + writeWorkBook.write(); + writeWorkBook.close(); + } catch (WriteException e) { + e.printStackTrace(); + } + + // 򿪵ıļ + Runtime.getRuntime().exec("cmd /c \"" + reportFileName[0] + "\""); + + } catch (Exception e) { + e.printStackTrace(); + } + reporter.requestCanceling(); + btn.setEnabled(true); + } + }.start(); + } + + @SuppressWarnings("unchecked") + private void setComboBoxValue_ysr8_SubProjectCode() { + //JComboBoxInfo ci = (JComboBoxInfo)fu.allComponentInfos.get("ysr8_SubProjectCode"); + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_SubProjectCode"); + iTextField textfield = (iTextField)fu.allComponentMap.get("ysr8_ProjectCode"); + map = new HashMap(); + String projectCode = textfield.getText().toString(); + if (projectCode.equals("")) { + return; + } + try { + TCComponentItem systemPartsItem = TCUtil.findItemByID(fu.session, projectCode); + if (systemPartsItem != null) { + TCComponentItemRevision systemPartsRevision = systemPartsItem.getLatestItemRevision(); + TCComponentPseudoFolder folder = TCUtil.getRevisionPseudoFolder(systemPartsRevision, "ͼ"); + if (folder != null) { + AIFComponentContext[] comps = folder.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("еĿ") || objType.equals("Ŀ")) { + cbx.addItem(comp.getProperty("item_id")); + map.put(comp.getProperty("item_id"), comp.getProperty("object_name")); + } + } + } + } + } + } + cbx.addItem(""); + map.put("", ""); + + String ysr8_SubProjectCodeVal = fu.tcForm.getProperty("ysr8_SubProjectCode"); + if (!ysr8_SubProjectCodeVal.equals("")) { + cbx.setSelectedItem(ysr8_SubProjectCodeVal); + } + } catch (TCException e) { + e.printStackTrace(); + } + } + private void refrashTable2(int[] rows, boolean update) {//TODO 2ʾ + JTable table = (JTable) fu.allComponentMap.get("a.111.11.11"); + Map map2 = new HashMap<>(); + for(int i=0; i0"); + c.setTime(getDate(machPlan)); + c.add(Calendar.DAY_OF_MONTH, day); + table2.setValueAt(fu.getDateString(c.getTime()), i, 6); + } + Date machAsk = c.getTime(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date ask = sdf.parse(fu.getDateString(machAsk)+" 23:59:59"); + if(machFinish.isEmpty()) { + if(!ask.after(new Date())) + table2.setValueAt("", i, table2Map.get("Ƿ")); + else + table2.setValueAt("", i, table2Map.get("Ƿ")); + }else { + if(!ask.after(getDate(machFinish.substring(0, 10)))) + table2.setValueAt("", i, table2Map.get("Ƿ")); + else + table2.setValueAt("", i, table2Map.get("Ƿ")); + System.out.println(machAsk+"=="+machFinish+"=="+table2.getValueAt(i, table2Map.get("Ƿ"))); + } + } + } + }catch(Exception e) { + e.printStackTrace(); + } + } + private Date getDate(String s) throws ParseException { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + if(s==null || s.isEmpty()) + return null; + if(s.length()>10) + sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + return sdf.parse(s); + } + private String getTableValue(JTable table, int r, int c) { + if(table.getValueAt(r, c)==null) + return ""; + else + return table.getValueAt(r, c).toString(); + } +} diff --git a/src/cn/com/ebewin/ysr/form/YSR8_INSPRecordRevisionMasterForm.java b/src/cn/com/ebewin/ysr/form/YSR8_INSPRecordRevisionMasterForm.java new file mode 100644 index 0000000..f57f3a3 --- /dev/null +++ b/src/cn/com/ebewin/ysr/form/YSR8_INSPRecordRevisionMasterForm.java @@ -0,0 +1,970 @@ +package cn.com.ebewin.ysr.form; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Vector; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JTable; + +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.iTextField; + +import cn.com.ebewin.ysr.dialog.ProgressReporterDialog; +import cn.com.ebewin.ysr.dialog.YSR8_INSPRecordDetailEditDialog; +import cn.com.ebewin.ysr.util.DialogUtil; +import cn.com.ebewin.ysr.util.FormCheckUtil; +import cn.com.ebewin.ysr.util.FormUtil; +import cn.com.ebewin.ysr.util.POIUtil07; +import cn.com.ebewin.ysr.util.TCUtil; + +@SuppressWarnings("deprecation") +public class YSR8_INSPRecordRevisionMasterForm extends AbstractRendering { + private static final long serialVersionUID = 1L; + private static Date refreshDate = null; + + FormUtil fu = new FormUtil(this); + Vector deletePic = new Vector(); + FormCheckUtil fcu = null; + private TCComponentItemRevision irRevision; + + private static final int TUHAO_INDEX=1; + private static final int LBJMC_INDEX=0; + private static final int BHGSL_INDEX=10; + private static final int BHGMS_INDEX=8; + private static final int SFJGCZJ_INDEX=11; + private static final int CLCS_INDEX=16; + + public YSR8_INSPRecordRevisionMasterForm(TCComponentForm arg0) throws Exception { + super(arg0); + + Date currDate = new Date(); + if (refreshDate == null) { + arg0.refresh(); + refreshDate = currDate; + } else { + long diff = currDate.getTime() - refreshDate.getTime(); + long minutes = diff / 1000 / 60; + if (minutes >= 1) { + arg0.refresh(); + refreshDate = currDate; + } + } + + fu.readRenderingXML("YSR8_INSPRecordRevisionMasterForm"); + +// String ysr8_PartTypeVal = arg0.getStringProperty("ysr8_PartType");//TODO lidy20190331ϲLOV +// if (ysr8_PartTypeVal.equals("2")) {// +// } else if (ysr8_PartTypeVal.equals("1")) {// ɢ +// CreateDialogUtil.JComboBoxInfo ci1 = (CreateDialogUtil.JComboBoxInfo) fu.allComponentInfos.get("ysr8_UnqualifiedType"); +// ci1.valueName = "YSR8_INSPR1_LOV"; +// CreateDialogUtil.JComboBoxInfo ci2 = (CreateDialogUtil.JComboBoxInfo) fu.allComponentInfos.get("ysr8_UnqualifiedType2"); +// ci2.valueName = "YSR8_INSPR1_LOV"; +// CreateDialogUtil.JComboBoxInfo ci3 = (CreateDialogUtil.JComboBoxInfo) fu.allComponentInfos.get("ysr8_UnqualifiedType3"); +// ci3.valueName = "YSR8_INSPR1_LOV"; +// CreateDialogUtil.JComboBoxInfo ci4 = (CreateDialogUtil.JComboBoxInfo) fu.allComponentInfos.get("ysr8_UnqualifiedType4"); +// ci4.valueName = "YSR8_INSPR1_LOV"; +// CreateDialogUtil.JComboBoxInfo ci5 = (CreateDialogUtil.JComboBoxInfo) fu.allComponentInfos.get("ysr8_UnqualifiedType5"); +// ci5.valueName = "YSR8_INSPR1_LOV"; +// +// CreateDialogUtil.JComboBoxInfo ci0 = (CreateDialogUtil.JComboBoxInfo) fu.allComponentInfos.get("ysr8_SubQualityResult"); +// ci0.valueName = "YSR8_INSPR5_LOV"; +// } + + fu.initializeUI(arg0); + addActionListener(); + loadRendering(); + getDefVal(); + } + + @Override + public void loadRendering() throws TCException { + iTextField textfieldForm; + AIFComponentContext[] context1 = fu.tcForm.whereReferencedByTypeRelation(new String[] { "YSR8_INSPRecordRevision" }, new String[] { "IMAN_master_form" }); + if (context1 != null && context1.length > 0) { + this.irRevision = (TCComponentItemRevision) context1[0].getComponent(); + TCComponentItem irItem = irRevision.getItem(); + + textfieldForm = (iTextField) fu.allComponentMap.get("Item_ID"); + textfieldForm.setText(irItem.getProperty("item_id")); + } + + fu.loadRendering(); + +// loadPic(); + + fcu = new FormCheckUtil(fu.tcForm, fu.allComponentMap); + fcu.checkHandler(); + } + + public void setRenderingReadOnly() { + setModifiableComponents(this, false); + if (getController() != null) { + getController().setFormReadOnly(); + } + } + + + public void setRenderingReadWrite() { + if (fcu != null && fcu.isNeedCheck()) { + fcu.setEnable(); + return; + } + setModifiableComponents(this, true); + } + + private void setModifiableComponents(java.awt.Component currcomponent, boolean flag) { + if (fcu != null && flag) { + if (fcu.isNeedCheck()) { + return; + } + } + fu.setModifiableComponents(currcomponent, flag); + } + + private void copyRow() { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.41.12.11"); + int row = ci.dataTable.getSelectedRow(); + if (row < 0) { + System.out.println("ûѡ"); + return; + } + System.out.println("ѡ˵" + row + "ни"); + Object[] objData = new Object[ci.childComponentInfos.size()]; + for (int i = 0; i < objData.length; i++) { + objData[i] = ci.dataTableModel.getValueAt(row, i); + } + ci.dataTableModel.insertRow(row, objData); + } + + private String exportExcel(TCSession session,JTable table,String qtyName,String srcFileTitle, String datasetName) { + File tempFile = TCUtil.findTemplete(session, qtyName, srcFileTitle); + if(tempFile==null) { + MessageBox.post("δҵ޵ģ壬ϵϵͳԱ","ʾ",MessageBox.INFORMATION); + return null; + } + int rowCount = table.getRowCount(); // + if(rowCount==0) { + MessageBox.post("¼Ϊգ޷޵","ʾ",MessageBox.INFORMATION); + return null; + } + final int PAGESIZE=7; + InputStream input=null; + FileOutputStream output=null; + String toPath = null; + try { +// String newFileTitle = "޼¼"; +// Date date = new Date(); +// SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); +// String time = sdf.format(date); +// toPath = System.getProperty("java.io.tmpdir") + newFileTitle + time + ".xlsx";//TODO lidy20190423޸ķ޵ + toPath = System.getProperty("java.io.tmpdir") + datasetName + ".xlsx"; + System.out.println("toPath1:" + toPath); + input=new FileInputStream(tempFile); + XSSFWorkbook wb=new XSSFWorkbook(input); + //д + int startRow = 6; // ʼǰΪʼ + //޸ģ + int pageCnt=rowCount%PAGESIZE==0?rowCount/PAGESIZE:rowCount/PAGESIZE+1; + XSSFSheet[] sheets=new XSSFSheet[pageCnt]; + sheets[0]=wb.getSheetAt(0); + //дͷϢ + //itemid + POIUtil07.setCellData(POIUtil07.getCell(1,sheets[0].getRow(2)), this.irRevision.getStringProperty("item_id")); + //汾 lidy20190314Ϊװͼ汾 +// POIUtil07.setCellData(POIUtil07.getCell(5,sheets[0].getRow(2)), this.irRevision.getStringProperty("item_revision_id")); +// System.out.println("ysr8_FinalRevision"+fu.tcForm.getProperty("ysr8_FinalRevision")); + POIUtil07.setCellData(POIUtil07.getCell(5,sheets[0].getRow(2)), fu.tcForm.getProperty("ysr8_DrawingREV")); + //ӹ + String jgc1=fu.tcForm.getProperty("ysr8_ManuFactory1"); + jgc1=(jgc1==null)?"":jgc1; + String jgc2=fu.tcForm.getProperty("ysr8_ManuFactory2"); + jgc2=(jgc2==null)?"":jgc2; + if(!"".equals(jgc1)&&!"".equals(jgc2)) { + jgc2=""+jgc2; + } + POIUtil07.setCellData(POIUtil07.getCell(4,sheets[0].getRow(3)), jgc1+jgc2); + // + POIUtil07.setCellData(POIUtil07.getCell(7,sheets[0].getRow(2)), fu.tcForm.getProperty("ysr8_PartType")); + // TODO lidy20190326 + POIUtil07.setCellData(POIUtil07.getCell(9,sheets[0].getRow(2)), fu.tcForm.getProperty("ysr8_AssemCode")); + //Ŀ + POIUtil07.setCellData(POIUtil07.getCell(1,sheets[0].getRow(3)), fu.tcForm.getProperty("ysr8_ProjectCode")); + //Ա + POIUtil07.setCellData(POIUtil07.getCell(6,sheets[0].getRow(3)), fu.tcForm.getProperty("ysr8_Tester")); + //ʱ + POIUtil07.setCellData(POIUtil07.getCell(9,sheets[0].getRow(3)), fu.getDateString(fu.tcForm.getDateProperty("ysr8_TestDate"))); + + //POIUtil07.setCellData(POIUtil07.getCell(1,sheets[0].getRow(1)), "1ҳ "+pageCnt+"ҳ"); + if(pageCnt>1) { + System.out.println("Ҫҳ"+(pageCnt-1)); + for(int i=1;i 0) { + return true; + } + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.51.12.11"); + for (int l = 0; l < ci.dataTableModel.getRowCount(); l++) { + if (ci.dataTableModel.getValueAt(l, 0) == null || ci.dataTableModel.getValueAt(l, 1) == null) { + continue; + } else { + String sign = ci.dataTableModel.getValueAt(l, 0).toString(); + if (sign.equalsIgnoreCase("")) { + return true; + } + } + }*/ + + return false; + } + + ///////////////////////////////////////////////////////////////// + @SuppressWarnings("unchecked") + private void addActionListener() { + { + iTextField textfield = (iTextField) fu.allComponentMap.get("ysr8_ManuPerson"); + final String ysr8_ManuPersonVal = textfield.getText(); + + JButton btn = (JButton) fu.allComponentMap.get("b.41.13.11"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + JComboBox cbx = (JComboBox) fu.allComponentMap.get("ysr8_PartType"); + String ysr8_PartTypeVal = cbx.getSelectedItem().toString(); + int ysr8_PartTypeIntVal = 1; + if (ysr8_PartTypeVal.equals("")) { + ysr8_PartTypeIntVal = 2; + } + + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.41.12.11"); +// String ysr8_ExaminingQuantity = ci.dataTableModel.getValueAt(rows[0], 5).toString(); + YSR8_INSPRecordDetailEditDialog dlg = new YSR8_INSPRecordDetailEditDialog(fu.session, ysr8_PartTypeIntVal, ysr8_ManuPersonVal, false); + dlg.showDlg(); + if (dlg.dialogResult() == AbstractAIFDialog.ID_OK) { + Object[] objData = new Object[ci.childComponentInfos.size()]; + for (int i = 0; i < objData.length; i++) { + DialogUtil.ComponentInfo cci = ci.childComponentInfos.get(i); + switch (cci.name) { + case "ysr8_PartCode": + objData[i] = dlg.ysr8_PartCodeVal; + break; + case "ysr8_PartName": + objData[i] = dlg.ysr8_PartNameVal; + break; + case "ysr8_UnqualifiedType": + objData[i] = dlg.ysr8_UnqualifiedTypeVal; + break; + case "ysr8_UnqualifiedType2": + objData[i] = dlg.ysr8_UnqualifiedType2Val; + break; + case "ysr8_UnqualifiedType3": + objData[i] = dlg.ysr8_UnqualifiedType3Val; + break; + case "ysr8_UnqualifiedType4": + objData[i] = dlg.ysr8_UnqualifiedType4Val; + break; + case "ysr8_UnqualifiedType5": + objData[i] = dlg.ysr8_UnqualifiedType5Val; + break; + case "ysr8_SubUnqualifiedQuantity": + objData[i] = dlg.ysr8_SubUnqualifiedQuantityVal; + break; + case "ysr8_PurchReasonDesc": + objData[i] = dlg.ysr8_PurchReasonDescVal; + break; + case "ysr8_Measures": + objData[i] = dlg.ysr8_MeasuresVal; + break; + case "ysr8_PurchPlanDate1": + objData[i] = dlg.ysr8_PurchPlanDate1Val; + break; + case "ysr8_DrawingReleaseDate": + objData[i] = dlg.ysr8_DrawingReleaseDateVal; + break; + case "ysr8_UnqualifiedDesc": + objData[i] = dlg.ysr8_UnqualifiedDescVal; + break; + case "ysr8_CompromiseAuthorizer": + objData[i] = dlg.ysr8_CompromiseAuthorizerVal; + break; + case "ysr8_FlowOutReason": + objData[i] = dlg.ysr8_FlowOutReasonVal; + break; + case "ysr8_ProduceReason": + objData[i] = dlg.ysr8_ProduceReasonVal; + break; + case "ysr8_YSRReason": + objData[i] = dlg.ysr8_YSRReasonVal; + break; + case "ysr8_FactorySurvey": + objData[i] = dlg.ysr8_FactorySurveyVal; + break; + case "ysr8_FactorySurveyQuantity": + objData[i] = dlg.ysr8_FactorySurveyQuantityVal; + break; + // case "ysr8_SubQualityFinishDate": + // objData[i] = dlg.ysr8_SubQualityFinishDateVal; + // break; + // case "ysr8_SubQualityResult": + // objData[i] = dlg.ysr8_SubQualityResultVal; + // break; + case "ysr8_SubTaskManuState": + objData[i] = "1"; + break; + default: + objData[i] = ""; + break; + } + } + ci.dataTableModel.addRow(objData); + } + } + }); + + btn = (JButton) fu.allComponentMap.get("b.41.13.41"); // kk TODO 0913 + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + copyRow(); + } + }); + + btn = (JButton) fu.allComponentMap.get("b.41.13.51"); // kk TODO 0913 ɷ޵ + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + try { + createFXD(); + } catch (Exception e1) { + MessageBox.post("ɷ޵"+e1.toString(),"",MessageBox.ERROR); + e1.printStackTrace(); + } + } + }); + + btn = (JButton) fu.allComponentMap.get("b.41.13.21"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + JComboBox cbx = (JComboBox) fu.allComponentMap.get("ysr8_PartType"); + String ysr8_PartTypeVal = cbx.getSelectedItem().toString(); + int ysr8_PartTypeIntVal = 1; + if (ysr8_PartTypeVal.equals("")) { + ysr8_PartTypeIntVal = 2; + } + + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.41.12.11"); + JTable table = (JTable) fu.allComponentMap.get("a.41.12.11"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪ༭У", "ʾ", MessageBox.INFORMATION); + return; + } + + Boolean isInTask = false; + if (fcu != null && fcu.isNeedCheck()) { + isInTask = true; + } + +// String ysr8_ExaminingQuantity = ci.dataTableModel.getValueAt(rows[0], 5).toString(); + YSR8_INSPRecordDetailEditDialog dlg = new YSR8_INSPRecordDetailEditDialog(fu.session, ysr8_PartTypeIntVal, ysr8_ManuPersonVal, isInTask); + for (int i = 0; i < ci.childComponentInfos.size(); i++) { + DialogUtil.ComponentInfo cci = ci.childComponentInfos.get(i); + switch (cci.name) { + case "ysr8_PartCode": + if (ci.dataTableModel.getValueAt(rows[0], i) != null) { + dlg.ysr8_PartCodeVal = ci.dataTableModel.getValueAt(rows[0], i).toString(); + } + break; + case "ysr8_PartName": + if (ci.dataTableModel.getValueAt(rows[0], i) != null) { + dlg.ysr8_PartNameVal = ci.dataTableModel.getValueAt(rows[0], i).toString(); + } + break; + case "ysr8_UnqualifiedType": + if (ci.dataTableModel.getValueAt(rows[0], i) != null) { + dlg.ysr8_UnqualifiedTypeVal = ci.dataTableModel.getValueAt(rows[0], i).toString(); + } + break; + case "ysr8_UnqualifiedType2": + if (ci.dataTableModel.getValueAt(rows[0], i) != null) { + dlg.ysr8_UnqualifiedType2Val = ci.dataTableModel.getValueAt(rows[0], i).toString(); + } + break; + case "ysr8_UnqualifiedType3": + if (ci.dataTableModel.getValueAt(rows[0], i) != null) { + dlg.ysr8_UnqualifiedType3Val = ci.dataTableModel.getValueAt(rows[0], i).toString(); + } + break; + case "ysr8_UnqualifiedType4": + if (ci.dataTableModel.getValueAt(rows[0], i) != null) { + dlg.ysr8_UnqualifiedType4Val = ci.dataTableModel.getValueAt(rows[0], i).toString(); + } + break; + case "ysr8_UnqualifiedType5": + if (ci.dataTableModel.getValueAt(rows[0], i) != null) { + dlg.ysr8_UnqualifiedType5Val = ci.dataTableModel.getValueAt(rows[0], i).toString(); + } + break; + case "ysr8_SubUnqualifiedQuantity": + if (ci.dataTableModel.getValueAt(rows[0], i) != null) { + dlg.ysr8_SubUnqualifiedQuantityVal = ci.dataTableModel.getValueAt(rows[0], i).toString(); + } + break; + case "ysr8_PurchReasonDesc": + if (ci.dataTableModel.getValueAt(rows[0], i) != null) { + dlg.ysr8_PurchReasonDescVal = ci.dataTableModel.getValueAt(rows[0], i).toString(); + } + break; + case "ysr8_Measures": + if (ci.dataTableModel.getValueAt(rows[0], i) != null) { + dlg.ysr8_MeasuresVal = ci.dataTableModel.getValueAt(rows[0], i).toString(); + } + break; + case "ysr8_PurchPlanDate1": + if (ci.dataTableModel.getValueAt(rows[0], i) != null) { + dlg.ysr8_PurchPlanDate1Val = ci.dataTableModel.getValueAt(rows[0], i).toString(); + } + break; + case "ysr8_DrawingReleaseDate": + if (ci.dataTableModel.getValueAt(rows[0], i) != null) { + dlg.ysr8_DrawingReleaseDateVal = ci.dataTableModel.getValueAt(rows[0], i).toString(); + } + break; + case "ysr8_UnqualifiedDesc": + if (ci.dataTableModel.getValueAt(rows[0], i) != null) + dlg.ysr8_UnqualifiedDescVal = ci.dataTableModel.getValueAt(rows[0], i).toString(); + break; + case "ysr8_CompromiseAuthorizer": + if (ci.dataTableModel.getValueAt(rows[0], i) != null) + dlg.ysr8_CompromiseAuthorizerVal = ci.dataTableModel.getValueAt(rows[0], i).toString(); + break; + case "ysr8_ProduceReason": + if (ci.dataTableModel.getValueAt(rows[0], i) != null) + dlg.ysr8_ProduceReasonVal = ci.dataTableModel.getValueAt(rows[0], i).toString(); + break; + case "ysr8_FlowOutReason": + if (ci.dataTableModel.getValueAt(rows[0], i) != null) + dlg.ysr8_FlowOutReasonVal = ci.dataTableModel.getValueAt(rows[0], i).toString(); + break; + case "ysr8_YSRReason": + if (ci.dataTableModel.getValueAt(rows[0], i) != null) + dlg.ysr8_YSRReasonVal = ci.dataTableModel.getValueAt(rows[0], i).toString(); + break; + case "ysr8_FactorySurvey": + if (ci.dataTableModel.getValueAt(rows[0], i) != null) + dlg.ysr8_FactorySurveyVal = ci.dataTableModel.getValueAt(rows[0], i).toString(); + break; + case "ysr8_FactorySurveyQuantity": + if (ci.dataTableModel.getValueAt(rows[0], i) != null) + dlg.ysr8_FactorySurveyQuantityVal = ci.dataTableModel.getValueAt(rows[0], i).toString(); + break; + // case "ysr8_SubQualityFinishDate": + // if (ci.dataTableModel.getValueAt(rows[0], i) != null) { + // dlg.ysr8_SubQualityFinishDateVal = ci.dataTableModel.getValueAt(rows[0], + // i).toString(); + // } + // break; + // case "ysr8_SubQualityResult": + // if (ci.dataTableModel.getValueAt(rows[0], i) != null) { + // dlg.ysr8_SubQualityResultVal = ci.dataTableModel.getValueAt(rows[0], + // i).toString(); + // } + // break; + default: + break; + } + } + dlg.showDlg(); + if (dlg.dialogResult() == AbstractAIFDialog.ID_OK) { + for (int i = 0; i < ci.childComponentInfos.size(); i++) { + DialogUtil.ComponentInfo cci = ci.childComponentInfos.get(i); + switch (cci.name) { + case "ysr8_PartCode": + ci.dataTableModel.setValueAt(dlg.ysr8_PartCodeVal, rows[0], i); + break; + case "ysr8_PartName": + ci.dataTableModel.setValueAt(dlg.ysr8_PartNameVal, rows[0], i); + break; + case "ysr8_UnqualifiedType": + ci.dataTableModel.setValueAt(dlg.ysr8_UnqualifiedTypeVal, rows[0], i); + break; + case "ysr8_UnqualifiedType2": + ci.dataTableModel.setValueAt(dlg.ysr8_UnqualifiedType2Val, rows[0], i); + break; + case "ysr8_UnqualifiedType3": + ci.dataTableModel.setValueAt(dlg.ysr8_UnqualifiedType3Val, rows[0], i); + break; + case "ysr8_UnqualifiedType4": + ci.dataTableModel.setValueAt(dlg.ysr8_UnqualifiedType4Val, rows[0], i); + break; + case "ysr8_UnqualifiedType5": + ci.dataTableModel.setValueAt(dlg.ysr8_UnqualifiedType5Val, rows[0], i); + break; + case "ysr8_SubUnqualifiedQuantity": + ci.dataTableModel.setValueAt(dlg.ysr8_SubUnqualifiedQuantityVal, rows[0], i); + break; + case "ysr8_PurchReasonDesc": + ci.dataTableModel.setValueAt(dlg.ysr8_PurchReasonDescVal, rows[0], i); + break; + case "ysr8_Measures": + ci.dataTableModel.setValueAt(dlg.ysr8_MeasuresVal, rows[0], i); + break; + case "ysr8_PurchPlanDate1": + ci.dataTableModel.setValueAt(dlg.ysr8_PurchPlanDate1Val, rows[0], i); + break; + case "ysr8_DrawingReleaseDate": + ci.dataTableModel.setValueAt(dlg.ysr8_DrawingReleaseDateVal, rows[0], i); + break; + case "ysr8_UnqualifiedDesc": + ci.dataTableModel.setValueAt(dlg.ysr8_UnqualifiedDescVal, rows[0], i); + break; + case "ysr8_CompromiseAuthorizer": + ci.dataTableModel.setValueAt(dlg.ysr8_CompromiseAuthorizerVal, rows[0], i); + break; + case "ysr8_ProduceReason": + ci.dataTableModel.setValueAt(dlg.ysr8_ProduceReasonVal, rows[0], i); + break; + case "ysr8_FlowOutReason": + ci.dataTableModel.setValueAt(dlg.ysr8_FlowOutReasonVal, rows[0], i); + break; + case "ysr8_YSRReason": + ci.dataTableModel.setValueAt(dlg.ysr8_YSRReasonVal, rows[0], i); + break; + case "ysr8_FactorySurvey": + ci.dataTableModel.setValueAt(dlg.ysr8_FactorySurveyVal, rows[0], i); + break; + case "ysr8_FactorySurveyQuantity": + ci.dataTableModel.setValueAt(dlg.ysr8_FactorySurveyQuantityVal, rows[0], i); + break; + // case "ysr8_SubQualityFinishDate": + // ci.dataTableModel.setValueAt(dlg.ysr8_SubQualityFinishDateVal, rows[0], i); + // break; + // case "ysr8_SubQualityResult": + // ci.dataTableModel.setValueAt(dlg.ysr8_SubQualityResultVal, rows[0], i); + // break; + default: + break; + } + } + } + } + }); + btn = (JButton) fu.allComponentMap.get("b.41.13.31"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.41.12.11"); + JTable table = (JTable) fu.allComponentMap.get("a.41.12.11"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪƳУ", "ʾ", MessageBox.INFORMATION); + return; + } + for (int i = rows.length - 1; i >= 0; i--) { + ci.dataTableModel.removeRow(rows[i]); + } + } + }); + } + ////////////////////////////////////////////////////// + /*{ + JButton btn = (JButton) fu.allComponentMap.get("b.51.13.11"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + addLocalPic(); + } + }); + + btn = (JButton) fu.allComponentMap.get("b.51.13.21"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.51.12.11"); + JTable table = (JTable) fu.allComponentMap.get("a.51.12.11"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪƳУ", "ʾ", MessageBox.INFORMATION); + return; + } + for (int i = rows.length - 1; i >= 0; i--) { + String sign = ci.dataTableModel.getValueAt(rows[i], 0).toString(); + if (sign.equalsIgnoreCase("ϴ")) { + deletePic.add(ci.dataTableModel.getValueAt(rows[i], 1).toString()); + } + ci.dataTableModel.removeRow(rows[i]); + } + } + }); + }*/ + iTextField component = (iTextField) fu.allComponentMap.get("ysr8_AssemNumber"); + component.addFocusListener(checkNumber); + } + private FocusListener checkNumber = new FocusListener(){ + + @Override + public void focusGained(FocusEvent arg0) { + + } + + @Override + public void focusLost(FocusEvent arg0) { + if(arg0.getComponent() instanceof iTextField){ + iTextField component = (iTextField)(arg0.getComponent()); + String text = component.getText(); + if(text!=null && !text.isEmpty()){ + if(text.startsWith(".")){ + text = "0" + text; + component.setText(text); + } + try { + new Double(text); + } catch(NumberFormatException e) { + MessageBox.post("Աд", "", 1); + component.setText(""); + } + } + } + } + + }; + + private void getDefVal() { + } + + /*private void loadPic() { + TCComponentItemRevision itemRevision = null; + TCComponentDataset dataset = null; + try { + AIFComponentContext[] context = fu.tcForm.whereReferencedByTypeRelation(new String[] { "YSR8_INSPRecordRevision" }, new String[] { "IMAN_master_form" }); + if (context != null && context.length > 0) { + itemRevision = (TCComponentItemRevision) context[0].getComponent(); + + TCComponent[] components = itemRevision.getRelatedComponents("IMAN_specification"); + if (components != null && components.length > 0) { + JTableInfo ci = (JTableInfo) fu.allComponentInfos.get("a.51.12.11"); + ci.dataTableModel.getDataVector().clear(); + int cols = ci.childComponentInfos.size(); + for (int i = 0; i < components.length; i++) { + dataset = (TCComponentDataset) components[i]; + String name = dataset.getProperty("object_string"); + + Object[] objData = new Object[cols]; + objData[0] = "ϴ"; + objData[1] = name; + ci.dataTableModel.addRow(objData); + } + } + } + } catch (TCException e1) { + e1.printStackTrace(); + } + } + + private void addLocalPic() { + String[][] fileTypes = { { ".gif;.bmp;.jpg;.png", "ͼƬļ" }, { ".doc;.docx;.xls;.xlsx", "Officeļ" } }; + File[] files = FileUtil.openFileChoosers(fileTypes); + if (files == null) { + return; + } + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.51.12.11"); + int cols = ci.childComponentInfos.size(); + for (int f = 0; f < files.length; f++) { + Object[] objData = new Object[cols]; + objData[0] = ""; + objData[1] = files[f].getAbsolutePath(); + ci.dataTableModel.addRow(objData); + } + } + + private void saveLocalPic() { + Vector addPic = new Vector(); + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.51.12.11"); + for (int l = 0; l < ci.dataTableModel.getRowCount(); l++) { + if (ci.dataTableModel.getValueAt(l, 0) == null || ci.dataTableModel.getValueAt(l, 1) == null) { + continue; + } else { + String sign = ci.dataTableModel.getValueAt(l, 0).toString(); + if (sign.equalsIgnoreCase("")) { + String fileName = ci.dataTableModel.getValueAt(l, 1).toString(); + addPic.add(fileName); + } + } + } + + TCComponentItemRevision itemRevision = null; + TCComponentDataset dataset = null; + try { + AIFComponentContext[] context = fu.tcForm.whereReferencedByTypeRelation(new String[] { "YSR8_INSPRecordRevision" }, new String[] { "IMAN_master_form" }); + if (context != null && context.length > 0) { + itemRevision = (TCComponentItemRevision) context[0].getComponent(); + + TCComponent[] components = itemRevision.getRelatedComponents("IMAN_specification"); + if (components != null && components.length > 0) { + for (int i = 0; i < components.length; i++) { + dataset = (TCComponentDataset) components[i]; + String name = dataset.getProperty("object_string"); + for (String pic : deletePic) { + if (pic.equalsIgnoreCase(name)) { + itemRevision.remove("IMAN_specification", dataset); + dataset.delete(); + } + } + } + } + + for (String pic : addPic) { + File file = new File(pic); + TCComponentDataset newDataset = TCUtil.createDataset(fu.session, file, file.getName()); + itemRevision.add("IMAN_specification", new TCComponent[] { newDataset }); + } + } + } catch (TCException e1) { + e1.printStackTrace(); + } + loadPic(); + }*/ + + public boolean checkCanSave() { + iTextField textfield = (iTextField) fu.allComponentMap.get("ysr8_TestNumber"); + String ysr8_TestNumberVal = TCUtil.getNumber(textfield.getText()); + textfield.setText(ysr8_TestNumberVal); + if (ysr8_TestNumberVal.equals("")) { + MessageBox.post("[]д...", "", MessageBox.ERROR); + return false; + } + try { + int numInt=Integer.parseInt(ysr8_TestNumberVal); + if(numInt<0) { + MessageBox.post("[]Ϊ", "ʾ", MessageBox.INFORMATION); + return false; + } + } catch (NumberFormatException e) { + MessageBox.post("[]д", "ʾ", MessageBox.INFORMATION); + e.printStackTrace(); + return false; + } + + textfield = (iTextField) fu.allComponentMap.get("ysr8_UnqualifiedQuantity"); + String ysr8_UnqualifiedQuantityVal = TCUtil.getNumber(textfield.getText()); + textfield.setText(ysr8_UnqualifiedQuantityVal); + if (ysr8_UnqualifiedQuantityVal.equals("")) { + MessageBox.post("[ϸ]д...", "", MessageBox.ERROR); + return false; + } + try { + int numInt=Integer.parseInt(ysr8_UnqualifiedQuantityVal); + if(numInt<0) { + MessageBox.post("[ϸ]Ϊ", "ʾ", MessageBox.INFORMATION); + return false; + } + } catch (NumberFormatException e) { + MessageBox.post("[ϸ]д", "ʾ", MessageBox.INFORMATION); + e.printStackTrace(); + return false; + } + + textfield = (iTextField) fu.allComponentMap.get("ysr8_Tester"); + String ysr8_TesterVal = textfield.getText(); + if (ysr8_TesterVal.equals("")) { + MessageBox.post("[Ա]д...", "", MessageBox.ERROR); + return false; + } + + DateButton dateButton = (DateButton) fu.allComponentMap.get("ysr8_TestDate"); + Date ysr8_TestDateVal = dateButton.getDate(); + if (ysr8_TestDateVal == null) { + MessageBox.post("[ʱ]д...", "", MessageBox.ERROR); + return false; + } + return true; + } +} diff --git a/src/cn/com/ebewin/ysr/form/YSR8_MotomanCRevisionMasterForm.java b/src/cn/com/ebewin/ysr/form/YSR8_MotomanCRevisionMasterForm.java new file mode 100644 index 0000000..8d2e59c --- /dev/null +++ b/src/cn/com/ebewin/ysr/form/YSR8_MotomanCRevisionMasterForm.java @@ -0,0 +1,1302 @@ +package cn.com.ebewin.ysr.form; + +import java.awt.Color; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.text.ParseException; +import java.util.Date; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; +import java.util.TreeMap; +import java.util.Vector; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JRadioButton; +import javax.swing.JTabbedPane; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.table.DefaultTableCellRenderer; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.iTextField; + +import cn.com.ebewin.ysr.dialog.SelectMotomanModleDialog; +import cn.com.ebewin.ysr.util.CommonUtil; +import cn.com.ebewin.ysr.util.FormUtil; +import cn.com.ebewin.ysr.util.TCUtil; + +public class YSR8_MotomanCRevisionMasterForm extends AbstractRendering { + private static final long serialVersionUID = 1L; + private static Date refreshDate = null; + + FormUtil fu = new FormUtil(this); + String YSRBWJClass = ""; + Vector> vecYSRBWJWriteBack = new Vector>(); + Vector> vecYSRBWJData = null; + String YSRXZJGClass = ""; + Vector> vecYSRXZJGWriteBack = new Vector>(); + Vector> vecYSRXZJGData = null; + + int beforeSelect_a214111211 = -1; + int beforeSelect_a214211211 = -1; + int beforeSelect_a214311211 = -1; + int beforeSelect_a214411211 = -1; + int beforeSelect_a214511211 = -1; + + public YSR8_MotomanCRevisionMasterForm(TCComponentForm arg0) throws Exception { + super(arg0); + + Date currDate = new Date(); + if (refreshDate == null) { + arg0.refresh(); + refreshDate = currDate; + } else { + long diff = currDate.getTime() - refreshDate.getTime(); + long minutes = diff / 1000 / 60; + if ( minutes >= 1 ) { + arg0.refresh(); + refreshDate = currDate; + } + } + + fu.readRenderingXML("YSR8_MotomanCRevisionMasterForm"); + fu.initializeUI(arg0); + addActionListener(); + loadRendering(); + } + + @Override + public void loadRendering() throws TCException { + { + //kk TODO ӹ̶֣ɫӴʾ + JLabel redLabel = (JLabel)fu.allComponentMap.get("kl2111112"); + Font font=redLabel.getFont(); + Font font2=new Font(font.getName(), Font.BOLD, font.getSize()); + redLabel.setFont(font2); + redLabel.setForeground(Color.RED); + + } + { + JTable table = (JTable)fu.allComponentMap.get("a214111211"); + DefaultTableCellRenderer tcr = new DefaultTableCellRenderer();// tableݾ + // tcr.setHorizontalAlignment(JLabel.CENTER);tcr.setHorizontalAlignment(SwingConstants.CENTER);// Ͼһ + table.setDefaultRenderer(Object.class, tcr); + } + { + JTable table = (JTable)fu.allComponentMap.get("a214211211"); + DefaultTableCellRenderer tcr = new DefaultTableCellRenderer();// tableݾ + table.setDefaultRenderer(Object.class, tcr); + } + { + JTable table = (JTable)fu.allComponentMap.get("a214311211"); + DefaultTableCellRenderer tcr = new DefaultTableCellRenderer();// tableݾ + table.setDefaultRenderer(Object.class, tcr); + } + { + JTable table = (JTable)fu.allComponentMap.get("a214411211"); + DefaultTableCellRenderer tcr = new DefaultTableCellRenderer();// tableݾ + table.setDefaultRenderer(Object.class, tcr); + } + { + JTable table = (JTable)fu.allComponentMap.get("a214511211"); + DefaultTableCellRenderer tcr = new DefaultTableCellRenderer();// tableݾ + table.setDefaultRenderer(Object.class, tcr); + } + { + JTable table = (JTable)fu.allComponentMap.get("a21511212112"); + DefaultTableCellRenderer tcr = new DefaultTableCellRenderer();// tableݾ + table.setDefaultRenderer(Object.class, tcr); + } + + fu.loadRendering(); + + SetTabbedTitle(); + } + + /** + * (non-Javadoc) + * @see com.teamcenter.rac.form.AbstractTCForm#saveForm() + */ + @Override + public void saveRendering() { + if (!checkCanSave()) { + return; + } + + CountWBZ(); + try { + fu.saveRendering(); + } catch (TCException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } catch (ParseException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } + } + + public boolean isRenderingModified() { + return fu.isRenderingModified(); + } + + public void setRenderingReadOnly() + { + setModifiableComponents(this, false); + if(getController() != null) + getController().setFormReadOnly(); + } + + public void setRenderingReadWrite() + { + setModifiableComponents(this, true); + + ChangeCheckBoxState1(); + ChangeCheckBoxState2(); + ChangeCheckBoxState3(); + ChangeComboBoxState_ysr8_CableSegmented(); + ChangeComboBoxState_ysr8_WelderYorN(); + ChangeComboBoxState_ysr8_PipelineYorN(); + + ChangeCheckBoxState4(); + } + + private void setModifiableComponents(java.awt.Component currcomponent, boolean flag) + { + fu.setModifiableComponents(currcomponent, flag); + } + + ///////////////////////////////////////////////////////////////// + @SuppressWarnings("unchecked") + void addActionListener() { + JButton btn = (JButton)fu.allComponentMap.get("ysr8_MotomanType_Select"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + SelectMotomanModleDialog dlg = new SelectMotomanModleDialog(fu.session); + if (dlg.dialogResult() == AbstractAIFDialog.ID_OK) { + iTextField text = (iTextField)fu.allComponentMap.get("ysr8_MotomanType"); + text.setText(dlg.retJQRXH); + text = (iTextField)fu.allComponentMap.get("ysr8_MotomanModle"); + text.setText(dlg.retBTXH); + text = (iTextField)fu.allComponentMap.get("ysr8_MotomanRemark"); + text.setText(dlg.retBZ); + text = (iTextField)fu.allComponentMap.get("ysr8_CabinetModel"); + text.setText(dlg.retKZGXH); + } + } + }); + ////////////////////////////////////////////////////// + { + btn = (JButton)fu.allComponentMap.get("b111117"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + SyncProperty(); + } + }); + } + ////////////////////////////////////////////////////// + { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_CableSegmented"); + cbx.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent itemevent) { + if (itemevent.getStateChange() == ItemEvent.SELECTED) { + ChangeComboBoxState_ysr8_CableSegmented(); + } + } + }); + } + ////////////////////////////////////////////////////// + { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_WelderYorN"); + cbx.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent itemevent) { + if (itemevent.getStateChange() == ItemEvent.SELECTED) { + ChangeComboBoxState_ysr8_WelderYorN(); + } + } + }); + } + ////////////////////////////////////////////////////// + { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_PipelineYorN"); + cbx.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent itemevent) { + if (itemevent.getStateChange() == ItemEvent.SELECTED) { + ChangeComboBoxState_ysr8_PipelineYorN(); + } + } + }); + } + ////////////////////////////////////////////////////// + { + JRadioButton rdo = (JRadioButton)fu.allComponentMap.get("ysr8_NotSegmented01"); + rdo.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent actionevent) { + ChangeCheckBoxState1(); + } + }); + JRadioButton rdo1 = (JRadioButton)fu.allComponentMap.get("ysr8_Segment01"); + rdo1.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent actionevent) { + ChangeCheckBoxState1(); + } + }); + if (!rdo.isSelected() && !rdo1.isSelected()) { + rdo.setSelected(true); + } + + rdo = (JRadioButton)fu.allComponentMap.get("ysr8_NotSegmented02"); + rdo.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent actionevent) { + ChangeCheckBoxState2(); + } + }); + rdo1 = (JRadioButton)fu.allComponentMap.get("ysr8_Segment02"); + rdo1.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent actionevent) { + ChangeCheckBoxState2(); + } + }); + if (!rdo.isSelected() && !rdo1.isSelected()) { + rdo.setSelected(true); + } + + rdo = (JRadioButton)fu.allComponentMap.get("ysr8_NotSegmented03"); + rdo.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent actionevent) { + ChangeCheckBoxState3(); + } + }); + rdo1 = (JRadioButton)fu.allComponentMap.get("ysr8_Segment03"); + rdo1.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent actionevent) { + ChangeCheckBoxState3(); + } + }); + if (!rdo.isSelected() && !rdo1.isSelected()) { + rdo.setSelected(true); + } + } + ////////////////////////////////////////////////////// + { + btn = (JButton)fu.allComponentMap.get("b214111311"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a214111211"); + Object[] objData = new Object[ci.childComponentInfos.size()]; + for (int i = 0; i < objData.length; i++) { + objData[i] = ""; + } + ci.dataTableModel.addRow(objData); + } + }); + + btn = (JButton)fu.allComponentMap.get("b214111321"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a214111211"); + JTable table = (JTable)fu.allComponentMap.get("a214111211"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪƳУ", "ʾ", MessageBox.INFORMATION); + return; + } + for (int i = rows.length - 1; i >= 0; i--) { + ci.dataTableModel.removeRow(rows[i]); + } + } + }); + } + ////////////////////////////////////////////////////// + { + btn = (JButton)fu.allComponentMap.get("b214211311"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a214211211"); + Object[] objData = new Object[ci.childComponentInfos.size()]; + for (int i = 0; i < objData.length; i++) { + objData[i] = ""; + } + ci.dataTableModel.addRow(objData); + } + }); + + btn = (JButton)fu.allComponentMap.get("b214211321"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a214211211"); + JTable table = (JTable)fu.allComponentMap.get("a214211211"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪƳУ", "ʾ", MessageBox.INFORMATION); + return; + } + for (int i = rows.length - 1; i >= 0; i--) { + ci.dataTableModel.removeRow(rows[i]); + } + } + }); + } + ////////////////////////////////////////////////////// + { + btn = (JButton)fu.allComponentMap.get("b214311311"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a214311211"); + Object[] objData = new Object[ci.childComponentInfos.size()]; + for (int i = 0; i < objData.length; i++) { + objData[i] = ""; + } + ci.dataTableModel.addRow(objData); + } + }); + + btn = (JButton)fu.allComponentMap.get("b214311321"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a214311211"); + JTable table = (JTable)fu.allComponentMap.get("a214311211"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪƳУ", "ʾ", MessageBox.INFORMATION); + return; + } + for (int i = rows.length - 1; i >= 0; i--) { + ci.dataTableModel.removeRow(rows[i]); + } + } + }); + } + ////////////////////////////////////////////////////// + { + btn = (JButton)fu.allComponentMap.get("b214411311"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a214411211"); + Object[] objData = new Object[ci.childComponentInfos.size()]; + for (int i = 0; i < objData.length; i++) { + objData[i] = ""; + } + ci.dataTableModel.addRow(objData); + } + }); + + btn = (JButton)fu.allComponentMap.get("b214411321"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a214411211"); + JTable table = (JTable)fu.allComponentMap.get("a214411211"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪƳУ", "ʾ", MessageBox.INFORMATION); + return; + } + for (int i = rows.length - 1; i >= 0; i--) { + ci.dataTableModel.removeRow(rows[i]); + } + } + }); + } + ////////////////////////////////////////////////////// + { + btn = (JButton)fu.allComponentMap.get("b214511311"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a214511211"); + Object[] objData = new Object[ci.childComponentInfos.size()]; + for (int i = 0; i < objData.length; i++) { + objData[i] = ""; + } + ci.dataTableModel.addRow(objData); + } + }); + + btn = (JButton)fu.allComponentMap.get("b214511321"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a214511211"); + JTable table = (JTable)fu.allComponentMap.get("a214511211"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪƳУ", "ʾ", MessageBox.INFORMATION); + return; + } + for (int i = rows.length - 1; i >= 0; i--) { + ci.dataTableModel.removeRow(rows[i]); + } + } + }); + } + ////////////////////////////////////////////////////// + { + btn = (JButton)fu.allComponentMap.get("b2147113"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + CountWBZ(); + } + }); + } + ////////////////////////////////////////////////////// + { + String[] writeBackMappings = TCUtil.getPreference(fu.session, TCPreferenceService.TC_preference_site, "YSR_Class_Writeback_Mapping"); + for (int i = 0; i < writeBackMappings.length; i++) { + String writeBackMapping = writeBackMappings[i]; + Vector wbmPart = CommonUtil.split2Vector(writeBackMapping, "="); + if (wbmPart.size() == 3) { + if (wbmPart.get(0).equalsIgnoreCase("YSRBWJ")) { + YSRBWJClass = wbmPart.get(1); + Vector wbmPart2 = CommonUtil.split2Vector(wbmPart.get(2), ";"); + if (wbmPart2.size() > 0) { + for (int j = 0; j < wbmPart2.size(); j++) { + Vector wbmPart3 = CommonUtil.split2Vector(wbmPart2.get(j), ":"); + if (wbmPart3.size() == 2) { + vecYSRBWJWriteBack.add(wbmPart3); + } + } + } + break; + } + } + } + if (vecYSRBWJWriteBack.size() != 0) { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_Type02"); + if (cbx != null) { + String sql = "SELECT "; + for (int i = 0; i < vecYSRBWJWriteBack.size(); i++) { + if (i == 0) { + sql += vecYSRBWJWriteBack.get(i).get(1); + } + else { + sql += ", " + vecYSRBWJWriteBack.get(i).get(1); + } + } + sql += " FROM PICM0 WHERE PCID = '" + YSRBWJClass + "' ORDER BY PSM01"; + vecYSRBWJData = TCUtil.GetCls_InstanceInfo(fu.session, sql); + for (Iterator> iterator = vecYSRBWJData.iterator(); iterator.hasNext();) { + Hashtable hashtable = (Hashtable) iterator.next(); + cbx.addItem(hashtable.get(vecYSRBWJWriteBack.get(0).get(1)).toString()); + } + + cbx.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent itemevent) { + if (itemevent.getStateChange() == ItemEvent.SELECTED) { + JComboBox cbx1 = (JComboBox)fu.allComponentMap.get("ysr8_Type02"); + if (cbx1.getSelectedIndex() > 0) { + Hashtable hashtable = vecYSRBWJData.get(cbx1.getSelectedIndex() - 1); + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a214211211"); + JTable table = (JTable)fu.allComponentMap.get("a214211211"); + int[] rows = table.getSelectedRows(); + if (rows != null && rows.length > 0) { + for (int i = 0; i < ci.childComponentInfos.size(); i++) { + FormUtil.ComponentInfo cci = ci.childComponentInfos.get(i); + for (int j = 0; j < vecYSRBWJWriteBack.size(); j++) { + if (cci.name.equalsIgnoreCase(vecYSRBWJWriteBack.get(j).get(0))) { + ci.dataTableModel.setValueAt(hashtable.get(vecYSRBWJWriteBack.get(j).get(1)), rows[0], i); + break; + } + } + } + } + } + } + } + }); + } + } + } + ////////////////////////////////////////////////////// + { + String[] writeBackMappings = TCUtil.getPreference(fu.session, TCPreferenceService.TC_preference_site, "YSR_Class_Writeback_Mapping"); + for (int i = 0; i < writeBackMappings.length; i++) { + String writeBackMapping = writeBackMappings[i]; + Vector wbmPart = CommonUtil.split2Vector(writeBackMapping, "="); + if (wbmPart.size() == 3) { + if (wbmPart.get(0).equalsIgnoreCase("YSRXZJG")) { + YSRXZJGClass = wbmPart.get(1); + Vector wbmPart2 = CommonUtil.split2Vector(wbmPart.get(2), ";"); + if (wbmPart2.size() > 0) { + for (int j = 0; j < wbmPart2.size(); j++) { + Vector wbmPart3 = CommonUtil.split2Vector(wbmPart2.get(j), ":"); + if (wbmPart3.size() == 2) { + vecYSRXZJGWriteBack.add(wbmPart3); + } + } + } + break; + } + } + } + if (vecYSRXZJGWriteBack.size() != 0) { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_Type03"); + if (cbx != null) { + String sql = "SELECT "; + for (int i = 0; i < vecYSRXZJGWriteBack.size(); i++) { + if (i == 0) { + sql += vecYSRXZJGWriteBack.get(i).get(1); + } + else { + sql += ", " + vecYSRXZJGWriteBack.get(i).get(1); + } + } + sql += " FROM PICM0 WHERE PCID = '" + YSRXZJGClass + "' ORDER BY PSM01"; + vecYSRXZJGData = TCUtil.GetCls_InstanceInfo(fu.session, sql); + for (Iterator> iterator = vecYSRXZJGData.iterator(); iterator.hasNext();) { + Hashtable hashtable = (Hashtable) iterator.next(); + cbx.addItem(hashtable.get(vecYSRXZJGWriteBack.get(0).get(1)).toString()); + } + + cbx.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent itemevent) { + if (itemevent.getStateChange() == ItemEvent.SELECTED) { + JComboBox cbx1 = (JComboBox)fu.allComponentMap.get("ysr8_Type03"); + if (cbx1.getSelectedIndex() > 0) { + Hashtable hashtable = vecYSRXZJGData.get(cbx1.getSelectedIndex() - 1); + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a214311211"); + JTable table = (JTable)fu.allComponentMap.get("a214311211"); + int[] rows = table.getSelectedRows(); + if (rows != null && rows.length > 0) { + for (int i = 0; i < ci.childComponentInfos.size(); i++) { + FormUtil.ComponentInfo cci = ci.childComponentInfos.get(i); + for (int j = 0; j < vecYSRXZJGWriteBack.size(); j++) { + if (cci.name.equalsIgnoreCase(vecYSRXZJGWriteBack.get(j).get(0))) { + ci.dataTableModel.setValueAt(hashtable.get(vecYSRXZJGWriteBack.get(j).get(1)), rows[0], i); + break; + } + } + } + } + } + } + } + }); + } + } + } + ////////////////////////////////////////////////////// + { + btn = (JButton)fu.allComponentMap.get("b21511212211"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a21511212112"); + Object[] objData = new Object[ci.childComponentInfos.size()]; + for (int i = 0; i < objData.length; i++) { + objData[i] = ""; + } + ci.dataTableModel.addRow(objData); + } + }); + + btn = (JButton)fu.allComponentMap.get("b21511212221"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a21511212112"); + JTable table = (JTable)fu.allComponentMap.get("a21511212112"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪƳУ", "ʾ", MessageBox.INFORMATION); + return; + } + for (int i = rows.length - 1; i >= 0; i--) { + ci.dataTableModel.removeRow(rows[i]); + } + } + }); + } + ////////////////////////////////////////////////////// + { + btn = (JButton)fu.allComponentMap.get("b214111331"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + btn_b214111331(); + } + }); + btn = (JButton)fu.allComponentMap.get("b214111341"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + btn_b214111341(); + } + }); + + btn = (JButton)fu.allComponentMap.get("b214211331"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + btn_b214211331(); + } + }); + btn = (JButton)fu.allComponentMap.get("b214211341"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + btn_b214211341(); + } + }); + + btn = (JButton)fu.allComponentMap.get("b214311331"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + btn_b214311331(); + } + }); + btn = (JButton)fu.allComponentMap.get("b214311341"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + btn_b214311341(); + } + }); + + btn = (JButton)fu.allComponentMap.get("b214411331"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + btn_b214411331(); + } + }); + btn = (JButton)fu.allComponentMap.get("b214411341"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + btn_b214411341(); + } + }); + + btn = (JButton)fu.allComponentMap.get("b214511331"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + btn_b214511331(); + } + }); + btn = (JButton)fu.allComponentMap.get("b214511341"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + btn_b214511341(); + } + }); + } + ////////////////////////////////////////////////////// + } + + @SuppressWarnings("unchecked") + void ChangeCheckBoxState1() { + JRadioButton rdo = (JRadioButton)fu.allComponentMap.get("ysr8_NotSegmented01"); + if (rdo.isSelected()) { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_CableLength01"); + cbx.setEnabled(true); + + cbx = (JComboBox)fu.allComponentMap.get("ysr8_CableLength2_1_01"); + cbx.setEnabled(false); + cbx = (JComboBox)fu.allComponentMap.get("ysr8_CableLength2_2_01"); + cbx.setEnabled(false); + cbx = (JComboBox)fu.allComponentMap.get("ysr8_CableRelayType01"); + cbx.setEnabled(false); + cbx = (JComboBox)fu.allComponentMap.get("ysr8_CableRelayYorN01"); + cbx.setEnabled(false); + } + else { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_CableLength01"); + cbx.setEnabled(false); + + cbx = (JComboBox)fu.allComponentMap.get("ysr8_CableLength2_1_01"); + cbx.setEnabled(true); + cbx = (JComboBox)fu.allComponentMap.get("ysr8_CableLength2_2_01"); + cbx.setEnabled(true); + cbx = (JComboBox)fu.allComponentMap.get("ysr8_CableRelayType01"); + cbx.setEnabled(true); + cbx = (JComboBox)fu.allComponentMap.get("ysr8_CableRelayYorN01"); + cbx.setEnabled(true); + } + } + @SuppressWarnings("unchecked") + void ChangeCheckBoxState2() { + JRadioButton rdo = (JRadioButton)fu.allComponentMap.get("ysr8_NotSegmented02"); + if (rdo.isSelected()) { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_CableLength02"); + cbx.setEnabled(true); + + cbx = (JComboBox)fu.allComponentMap.get("ysr8_CableLength2_1_02"); + cbx.setEnabled(false); + cbx = (JComboBox)fu.allComponentMap.get("ysr8_CableLength2_2_02"); + cbx.setEnabled(false); + cbx = (JComboBox)fu.allComponentMap.get("ysr8_CableRelayType02"); + cbx.setEnabled(false); + cbx = (JComboBox)fu.allComponentMap.get("ysr8_CableRelayYorN02"); + cbx.setEnabled(false); + } + else { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_CableLength02"); + cbx.setEnabled(false); + + cbx = (JComboBox)fu.allComponentMap.get("ysr8_CableLength2_1_02"); + cbx.setEnabled(true); + cbx = (JComboBox)fu.allComponentMap.get("ysr8_CableLength2_2_02"); + cbx.setEnabled(true); + cbx = (JComboBox)fu.allComponentMap.get("ysr8_CableRelayType02"); + cbx.setEnabled(true); + cbx = (JComboBox)fu.allComponentMap.get("ysr8_CableRelayYorN02"); + cbx.setEnabled(true); + } + } + @SuppressWarnings("unchecked") + void ChangeCheckBoxState3() { + JRadioButton rdo = (JRadioButton)fu.allComponentMap.get("ysr8_NotSegmented03"); + if (rdo.isSelected()) { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_CableLength03"); + cbx.setEnabled(true); + + cbx = (JComboBox)fu.allComponentMap.get("ysr8_CableLength2_1_03"); + cbx.setEnabled(false); + cbx = (JComboBox)fu.allComponentMap.get("ysr8_CableLength2_2_03"); + cbx.setEnabled(false); + cbx = (JComboBox)fu.allComponentMap.get("ysr8_CableRelayType03"); + cbx.setEnabled(false); + cbx = (JComboBox)fu.allComponentMap.get("ysr8_CableRelayYorN03"); + cbx.setEnabled(false); + } + else { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_CableLength03"); + cbx.setEnabled(false); + + cbx = (JComboBox)fu.allComponentMap.get("ysr8_CableLength2_1_03"); + cbx.setEnabled(true); + cbx = (JComboBox)fu.allComponentMap.get("ysr8_CableLength2_2_03"); + cbx.setEnabled(true); + cbx = (JComboBox)fu.allComponentMap.get("ysr8_CableRelayType03"); + cbx.setEnabled(true); + cbx = (JComboBox)fu.allComponentMap.get("ysr8_CableRelayYorN03"); + cbx.setEnabled(true); + } + } + void ChangeCheckBoxState4() { + /*JRadioButton rdo = (JRadioButton)fu.allComponentMap.get("ysr8_NotSegmented04"); + rdo.setEnabled(false); + rdo = (JRadioButton)fu.allComponentMap.get("ysr8_Segment04"); + rdo.setEnabled(false); + + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_CableLength04"); + cbx.setEnabled(false); + + cbx = (JComboBox)fu.allComponentMap.get("ysr8_CableLength2_1_04"); + cbx.setEnabled(false); + cbx = (JComboBox)fu.allComponentMap.get("ysr8_CableLength2_2_04"); + cbx.setEnabled(false); + cbx = (JComboBox)fu.allComponentMap.get("ysr8_CableRelayType04"); + cbx.setEnabled(false); + cbx = (JComboBox)fu.allComponentMap.get("ysr8_CableRelayYorN04"); + cbx.setEnabled(false);*/ + } + + @SuppressWarnings("unchecked") + void ChangeComboBoxState_ysr8_CableSegmented() { + JComboBox cbx1 = (JComboBox)fu.allComponentMap.get("ysr8_CableSegmented"); + if (cbx1.getSelectedItem().toString().equals("")) { + fu.allComponentMap.get("ysr8_CableLength1_1").setEnabled(true); + fu.allComponentMap.get("ysr8_CableLength1_2").setEnabled(true); + fu.allComponentMap.get("ysr8_CableRelay").setEnabled(true); + } else { + fu.allComponentMap.get("ysr8_CableLength1_1").setEnabled(false); + fu.allComponentMap.get("ysr8_CableLength1_2").setEnabled(false); + fu.allComponentMap.get("ysr8_CableRelay").setEnabled(false); + } + } + @SuppressWarnings("unchecked") + void ChangeComboBoxState_ysr8_WelderYorN() { + JComboBox cbx1 = (JComboBox)fu.allComponentMap.get("ysr8_WelderYorN"); + if (cbx1.getSelectedItem().toString().equals("")) { + fu.allComponentMap.get("ysr8_WelderType").setEnabled(true); + fu.allComponentMap.get("ysr8_PeripheraNumber").setEnabled(true); + fu.allComponentMap.get("ysr8_WireFeedNumber").setEnabled(true); + fu.allComponentMap.get("ysr8_WireDiameter").setEnabled(true); + fu.allComponentMap.get("ysr8_TorchCoolingMethod").setEnabled(true); + fu.allComponentMap.get("ysr8_TorchType").setEnabled(true); + fu.allComponentMap.get("ysr8_WeldingCable").setEnabled(true); + fu.allComponentMap.get("ysr8_CableLength").setEnabled(true); + fu.allComponentMap.get("ysr8_WeldingPower01").setEnabled(true); + fu.allComponentMap.get("ysr8_WeldingPower02").setEnabled(true); + fu.allComponentMap.get("ysr8_CableLength08").setEnabled(true); + fu.allComponentMap.get("ysr8_HoseLength").setEnabled(true); + } else { + fu.allComponentMap.get("ysr8_WelderType").setEnabled(false); + fu.allComponentMap.get("ysr8_PeripheraNumber").setEnabled(false); + fu.allComponentMap.get("ysr8_WireFeedNumber").setEnabled(false); + fu.allComponentMap.get("ysr8_WireDiameter").setEnabled(false); + fu.allComponentMap.get("ysr8_TorchCoolingMethod").setEnabled(false); + fu.allComponentMap.get("ysr8_TorchType").setEnabled(false); + fu.allComponentMap.get("ysr8_WeldingCable").setEnabled(false); + fu.allComponentMap.get("ysr8_CableLength").setEnabled(false); + fu.allComponentMap.get("ysr8_WeldingPower01").setEnabled(false); + fu.allComponentMap.get("ysr8_WeldingPower02").setEnabled(false); + fu.allComponentMap.get("ysr8_CableLength08").setEnabled(false); + fu.allComponentMap.get("ysr8_HoseLength").setEnabled(false); + } + } + @SuppressWarnings("unchecked") + void ChangeComboBoxState_ysr8_PipelineYorN() { + JComboBox cbx1 = (JComboBox)fu.allComponentMap.get("ysr8_PipelineYorN"); + if (cbx1.getSelectedItem().toString().equals("")) { + fu.allComponentMap.get("ysr8_PipelineType").setEnabled(true); + fu.allComponentMap.get("ysr8_OtherStyle").setEnabled(true); + } else { + fu.allComponentMap.get("ysr8_PipelineType").setEnabled(false); + fu.allComponentMap.get("ysr8_OtherStyle").setEnabled(false); + } + } + + void btn_b214111331() { + //FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a214111211"); + JTable table = (JTable)fu.allComponentMap.get("a214111211"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪƵУ", "ʾ", MessageBox.INFORMATION); + return; + } + beforeSelect_a214111211 = rows[0]; + } + void btn_b214111341() { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a214111211"); + JTable table = (JTable)fu.allComponentMap.get("a214111211"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪճУ", "ʾ", MessageBox.INFORMATION); + return; + } + if (beforeSelect_a214111211 < 0) { + MessageBox.post("ѡҪƵУ", "ʾ", MessageBox.INFORMATION); + return; + } + //Object[] objData = new Object[ci.childComponentInfos.size()]; + for (int i = 0; i < ci.childComponentInfos.size(); i++) { + table.setValueAt(table.getValueAt(beforeSelect_a214111211, i), rows[0], i); + } + } + void btn_b214211331() { + //FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a214211211"); + JTable table = (JTable)fu.allComponentMap.get("a214211211"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪƵУ", "ʾ", MessageBox.INFORMATION); + return; + } + beforeSelect_a214211211 = rows[0]; + } + void btn_b214211341() { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a214211211"); + JTable table = (JTable)fu.allComponentMap.get("a214211211"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪճУ", "ʾ", MessageBox.INFORMATION); + return; + } + if (beforeSelect_a214211211 < 0) { + MessageBox.post("ѡҪƵУ", "ʾ", MessageBox.INFORMATION); + return; + } + //Object[] objData = new Object[ci.childComponentInfos.size()]; + for (int i = 0; i < ci.childComponentInfos.size(); i++) { + table.setValueAt(table.getValueAt(beforeSelect_a214211211, i), rows[0], i); + } + } + void btn_b214311331() { + //FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a214311211"); + JTable table = (JTable)fu.allComponentMap.get("a214311211"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪƵУ", "ʾ", MessageBox.INFORMATION); + return; + } + beforeSelect_a214311211 = rows[0]; + } + void btn_b214311341() { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a214311211"); + JTable table = (JTable)fu.allComponentMap.get("a214311211"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪճУ", "ʾ", MessageBox.INFORMATION); + return; + } + if (beforeSelect_a214211211 < 0) { + MessageBox.post("ѡҪƵУ", "ʾ", MessageBox.INFORMATION); + return; + } + //Object[] objData = new Object[ci.childComponentInfos.size()]; + for (int i = 0; i < ci.childComponentInfos.size(); i++) { + table.setValueAt(table.getValueAt(beforeSelect_a214311211, i), rows[0], i); + } + } + void btn_b214411331() { + //FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a214411211"); + JTable table = (JTable)fu.allComponentMap.get("a214411211"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪƵУ", "ʾ", MessageBox.INFORMATION); + return; + } + beforeSelect_a214411211 = rows[0]; + } + void btn_b214411341() { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a214411211"); + JTable table = (JTable)fu.allComponentMap.get("a214411211"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪճУ", "ʾ", MessageBox.INFORMATION); + return; + } + if (beforeSelect_a214211211 < 0) { + MessageBox.post("ѡҪƵУ", "ʾ", MessageBox.INFORMATION); + return; + } + //Object[] objData = new Object[ci.childComponentInfos.size()]; + for (int i = 0; i < ci.childComponentInfos.size(); i++) { + table.setValueAt(table.getValueAt(beforeSelect_a214411211, i), rows[0], i); + } + } + void btn_b214511331() { + //FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a214511211"); + JTable table = (JTable)fu.allComponentMap.get("a214511211"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪƵУ", "ʾ", MessageBox.INFORMATION); + return; + } + beforeSelect_a214511211 = rows[0]; + } + void btn_b214511341() { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a214511211"); + JTable table = (JTable)fu.allComponentMap.get("a214511211"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪճУ", "ʾ", MessageBox.INFORMATION); + return; + } + if (beforeSelect_a214211211 < 0) { + MessageBox.post("ѡҪƵУ", "ʾ", MessageBox.INFORMATION); + return; + } + //Object[] objData = new Object[ci.childComponentInfos.size()]; + for (int i = 0; i < ci.childComponentInfos.size(); i++) { + table.setValueAt(table.getValueAt(beforeSelect_a214511211, i), rows[0], i); + } + } + + void SetTabbedTitle() { + iTextField textField = (iTextField)fu.allComponentMap.get("ysr8_OrderQuantity1"); + String t0 = textField.getText().toString(); + textField = (iTextField)fu.allComponentMap.get("ysr8_OrderQuantity2"); + String t1 = textField.getText().toString(); + textField = (iTextField)fu.allComponentMap.get("ysr8_OrderQuantity3"); + String t2 = textField.getText().toString(); + textField = (iTextField)fu.allComponentMap.get("ysr8_ExternalAxisSummary"); + String t3 = textField.getText().toString(); + + textField = (iTextField)fu.allComponentMap.get("ysr8_CableLength07"); + String t41 = textField.getText().toString(); + textField = (iTextField)fu.allComponentMap.get("ysr8_OrderQuantity4"); + String t42 = textField.getText().toString(); + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a21511212112"); + JTextArea textArea = (JTextArea)fu.allComponentMap.get("ysr8_OtherRequirements"); + String t43 = textArea.getText().toString(); + + JTabbedPane tabPane = (JTabbedPane)fu.allComponentMap.get("t21"); + if (!t0.equals("")) { + tabPane.setTitleAt(0, " " + tabPane.getTitleAt(0)); + } + if (!t1.equals("")) { + tabPane.setTitleAt(1, " " + tabPane.getTitleAt(1)); + } + if (!t2.equals("")) { + tabPane.setTitleAt(2, " " + tabPane.getTitleAt(2)); + } + if (!t3.equals("")) { + tabPane.setTitleAt(3, " " + tabPane.getTitleAt(3)); + } + if (!t41.equals("") || !t42.equals("") || !t43.equals("") || ci.dataTableModel.getRowCount() > 0) { + tabPane.setTitleAt(4, " " + tabPane.getTitleAt(4)); + } + } + + public boolean checkCanSave() { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a214111211"); + for (int i = 0; i < ci.dataTableModel.getRowCount(); i++) { + if (ci.dataTableModel.getValueAt(i, 1) == null && + ci.dataTableModel.getValueAt(i, 1) != "") { + MessageBox.post("ⲿ-λ" + (i + 1) + "" + (1 + 1) + "ûд޷!", "", MessageBox.ERROR); + } + } + + ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a214211211"); + for (int i = 0; i < ci.dataTableModel.getRowCount(); i++) { + if (ci.dataTableModel.getValueAt(i, 1) == null && + ci.dataTableModel.getValueAt(i, 1) != "") { + MessageBox.post("ⲿ-YSRλ(ת)" + (i + 1) + "" + (1 + 1) + "ûд޷!", "", MessageBox.ERROR); + } + } + + ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a214311211"); + for (int i = 0; i < ci.dataTableModel.getRowCount(); i++) { + if (ci.dataTableModel.getValueAt(i, 1) == null && + ci.dataTableModel.getValueAt(i, 1) != "") { + MessageBox.post("ⲿ-YSR߻()" + (i + 1) + "" + (1 + 1) + "ûд޷!", "", MessageBox.ERROR); + } + } + + ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a214411211"); + for (int i = 0; i < ci.dataTableModel.getRowCount(); i++) { + if (ci.dataTableModel.getValueAt(i, 1) == null && + ci.dataTableModel.getValueAt(i, 1) != "") { + MessageBox.post("ⲿ-ŷǯ(ǯ)" + (i + 1) + "" + (1 + 1) + "ûд޷!", "", MessageBox.ERROR); + } + } + + ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a214511211"); + for (int i = 0; i < ci.dataTableModel.getRowCount(); i++) { + if (ci.dataTableModel.getValueAt(i, 1) == null && + ci.dataTableModel.getValueAt(i, 1) != "") { + MessageBox.post("ⲿ-̶ŷǯ(ǯ)" + (i + 1) + "" + (1 + 1) + "ûд޷!", "", MessageBox.ERROR); + } + } + + return true; + } + + void CountWBZ() { + Map countMap = new TreeMap(); + int acbwj = 0; + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a214111211"); + for (int i = 0; i < ci.dataTableModel.getRowCount(); i++) { + if (ci.dataTableModel.getValueAt(i, 1) != null && ci.dataTableModel.getValueAt(i, 1) != "") { + int count = Integer.parseInt(ci.dataTableModel.getValueAt(i, 1).toString()); + acbwj += count; + } + } + + ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a214211211"); + for (int i = 0; i < ci.dataTableModel.getRowCount(); i++) { + if (ci.dataTableModel.getValueAt(i, 1) != null && ci.dataTableModel.getValueAt(i, 1) != "") { + int count = Integer.parseInt(ci.dataTableModel.getValueAt(i, 1).toString()); + String motorPower = ""; + if (ci.dataTableModel.getValueAt(i, 2) != null && ci.dataTableModel.getValueAt(i, 2) != "") { + motorPower = ci.dataTableModel.getValueAt(i, 2).toString().toUpperCase(); + //lidy20190104 ͳ߼޸ + if(!motorPower.equals("")) { + if(countMap.containsKey(motorPower)) { + countMap.put(motorPower, countMap.get(motorPower)+count); + } else { + countMap.put(motorPower, count); + } + } + } + if (ci.dataTableModel.getValueAt(i, 6) != null && ci.dataTableModel.getValueAt(i, 6) != "") { + motorPower = ci.dataTableModel.getValueAt(i, 6).toString().toUpperCase(); + //lidy20190104 ͳ߼޸ + if(!motorPower.equals("")) { + if(countMap.containsKey(motorPower)) { + countMap.put(motorPower, countMap.get(motorPower)+count); + } else { + countMap.put(motorPower, count); + } + } + } + if (ci.dataTableModel.getValueAt(i, 10) != null && ci.dataTableModel.getValueAt(i, 10) != "") { + motorPower = ci.dataTableModel.getValueAt(i, 10).toString().toUpperCase(); + //lidy20190104 ͳ߼޸ + if(!motorPower.equals("")) { + if(countMap.containsKey(motorPower)) { + countMap.put(motorPower, countMap.get(motorPower)+count); + } else { + countMap.put(motorPower, count); + } + } + } + if (ci.dataTableModel.getValueAt(i, 14) != null && ci.dataTableModel.getValueAt(i, 14) != "") { + motorPower = ci.dataTableModel.getValueAt(i, 14).toString().toUpperCase(); + //lidy20190104 ͳ߼޸ + if(!motorPower.equals("")) { + if(countMap.containsKey(motorPower)) { + countMap.put(motorPower, countMap.get(motorPower)+count); + } else { + countMap.put(motorPower, count); + } + } + } + if (ci.dataTableModel.getValueAt(i, 18) != null && ci.dataTableModel.getValueAt(i, 18) != "") { + motorPower = ci.dataTableModel.getValueAt(i, 18).toString().toUpperCase(); + //lidy20190104 ͳ߼޸ + if(!motorPower.equals("")) { + if(countMap.containsKey(motorPower)) { + countMap.put(motorPower, countMap.get(motorPower)+count); + } else { + countMap.put(motorPower, count); + } + } + } + } + } + + ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a214311211"); + for (int i = 0; i < ci.dataTableModel.getRowCount(); i++) { + if (ci.dataTableModel.getValueAt(i, 1) != null && ci.dataTableModel.getValueAt(i, 1) != "") { + int count = Integer.parseInt(ci.dataTableModel.getValueAt(i, 1).toString()); + String motorPower = ""; + if (ci.dataTableModel.getValueAt(i, 2) != null && + ci.dataTableModel.getValueAt(i, 2) != "") { + motorPower = ci.dataTableModel.getValueAt(i, 2).toString().toUpperCase(); + //lidy20190104 ͳ߼޸ + if(!motorPower.equals("")) { + if(countMap.containsKey(motorPower)) { + countMap.put(motorPower, countMap.get(motorPower)+count); + } else { + countMap.put(motorPower, count); + } + } + } + if (ci.dataTableModel.getValueAt(i, 6) != null && ci.dataTableModel.getValueAt(i, 6) != "") { + motorPower = ci.dataTableModel.getValueAt(i, 6).toString().toUpperCase(); + //lidy20190104 ͳ߼޸ + if(!motorPower.equals("")) { + if(countMap.containsKey(motorPower)) { + countMap.put(motorPower, countMap.get(motorPower)+count); + } else { + countMap.put(motorPower, count); + } + } + } + if (ci.dataTableModel.getValueAt(i, 10) != null && ci.dataTableModel.getValueAt(i, 10) != "") { + motorPower = ci.dataTableModel.getValueAt(i, 10).toString().toUpperCase(); + //lidy20190104 ͳ߼޸ + if(!motorPower.equals("")) { + if(countMap.containsKey(motorPower)) { + countMap.put(motorPower, countMap.get(motorPower)+count); + } else { + countMap.put(motorPower, count); + } + } + } + } + } + + ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a214411211"); + for (int i = 0; i < ci.dataTableModel.getRowCount(); i++) { + if (ci.dataTableModel.getValueAt(i, 1) != null && ci.dataTableModel.getValueAt(i, 1) != "") { + int count = Integer.parseInt(ci.dataTableModel.getValueAt(i, 1).toString()); + String motorPower = ""; + if (ci.dataTableModel.getValueAt(i, 2) != null && ci.dataTableModel.getValueAt(i, 2) != "") { + motorPower = ci.dataTableModel.getValueAt(i, 2).toString().toUpperCase(); + //lidy20190104 ͳ߼޸ + if(!motorPower.equals("")) { + if(countMap.containsKey(motorPower)) { + countMap.put(motorPower, countMap.get(motorPower)+count); + } else { + countMap.put(motorPower, count); + } + } + } + } + } + + ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a214511211"); + for (int i = 0; i < ci.dataTableModel.getRowCount(); i++) { + if (ci.dataTableModel.getValueAt(i, 1) != null && ci.dataTableModel.getValueAt(i, 1) != "") { + int count = Integer.parseInt(ci.dataTableModel.getValueAt(i, 1).toString()); + String motorPower = ""; + if (ci.dataTableModel.getValueAt(i, 2) != null && ci.dataTableModel.getValueAt(i, 2) != "") { + motorPower = ci.dataTableModel.getValueAt(i, 2).toString().toUpperCase(); + //lidy20190104 ͳ߼޸ + if(!motorPower.equals("")) { + if(countMap.containsKey(motorPower)) { + countMap.put(motorPower, countMap.get(motorPower)+count); + } else { + countMap.put(motorPower, count); + } + } + } + } + } + StringBuilder ysr8_ExternalAxisSummary = new StringBuilder(""); + //String.format("0.2KW(%d)+1.3KW(%d)+2.0KW(%d)+3.0KW(%d)+3.7KW(%d)+4.4KW(%d)+5.5KW(%d)", + // kw0_2, kw1_3, kw2_0, kw3_0, kw3_7, kw4_4, kw5_5); + if (acbwj != 0) { + String part = String.format("λ(%d)", acbwj); + if (ysr8_ExternalAxisSummary.length()==0) { + ysr8_ExternalAxisSummary.append(part); + } else { + ysr8_ExternalAxisSummary.append("+" + part); + } + } + if(countMap.size()>0) { + for(Entry entry : countMap.entrySet()) { + if (ysr8_ExternalAxisSummary.length()==0) { + ysr8_ExternalAxisSummary.append(entry.getKey()+"("+entry.getValue()+")"); + } else { + ysr8_ExternalAxisSummary.append("+"+entry.getKey()+"("+entry.getValue()+")"); + } + } + } + iTextField text = (iTextField)fu.allComponentMap.get("ysr8_ExternalAxisSummary"); + text.setText(ysr8_ExternalAxisSummary.toString()); + } + + void SyncProperty() { + String ysr8_OrderNumberVal; + try { + ysr8_OrderNumberVal = fu.tcForm.getStringProperty("ysr8_OrderNumber"); + + if (!ysr8_OrderNumberVal.equals("")) { + TCComponentItem xmqdItem = TCUtil.findItemByID(fu.session, ysr8_OrderNumberVal + "_XMQD"); + if (xmqdItem != null) { + TCComponentItemRevision xmqdRevision = xmqdItem.getLatestItemRevision(); + TCComponentForm xmqdForm = TCUtil.getItemRevisionMasterForm(xmqdRevision); + fu.tcForm.setStringProperty("ysr8_CustomerName", xmqdForm.getStringProperty("ysr8_CustomerName")); + System.out.println("xmqdForm---"+xmqdForm.getStringProperty("ysr8_CustomerName")); + } + } + } catch (TCException e) { + e.printStackTrace(); + } + } +} diff --git a/src/cn/com/ebewin/ysr/form/YSR8_PRRevisionMasterForm.java b/src/cn/com/ebewin/ysr/form/YSR8_PRRevisionMasterForm.java new file mode 100644 index 0000000..7ec567a --- /dev/null +++ b/src/cn/com/ebewin/ysr/form/YSR8_PRRevisionMasterForm.java @@ -0,0 +1,830 @@ +package cn.com.ebewin.ysr.form; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.io.File; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map.Entry; +import java.util.Vector; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JTable; +import javax.swing.JTextField; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.commands.open.OpenFormDialog; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentPseudoFolder; +import com.teamcenter.rac.kernel.TCComponentSchedule; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCFormProperty; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.iTextField; + +import cn.com.ebewin.ysr.util.CommonUtil; +import cn.com.ebewin.ysr.util.FileUtil; +import cn.com.ebewin.ysr.util.FormCheckUtil; +import cn.com.ebewin.ysr.util.FormUtil; +import cn.com.ebewin.ysr.util.TCUtil; +import cn.com.ebewin.ysr.util.UIUtil.JComboBoxInfo; +import cn.com.ebewin.ysr.util.UIUtil.JTableInfo; + +@SuppressWarnings("deprecation") +public class YSR8_PRRevisionMasterForm extends AbstractRendering { + private static final long serialVersionUID = 1L; + private static Date refreshDate = null; + + FormUtil fu = new FormUtil(this); + Vector deletePic = new Vector(); + FormCheckUtil fcu = null; + boolean setEnabled = false; + + public YSR8_PRRevisionMasterForm(TCComponentForm arg0) throws Exception { + super(arg0); + + Date currDate = new Date(); + if (refreshDate == null) { + arg0.refresh(); + refreshDate = currDate; + } else { + long diff = currDate.getTime() - refreshDate.getTime(); + long minutes = diff / 1000 / 60; + if ( minutes >= 1 ) { + arg0.refresh(); + refreshDate = currDate; + } + } + + fu.readRenderingXML("YSR8_PRRevisionMasterForm"); + fu.initializeUI(arg0); + addActionListener(); + loadRendering(); + getDefVal(); + setTechFinishDate(); + + setComboBoxValue_ysr8_StationNo(); + } + + + + @Override + public void displayDialog(AbstractAIFDialog arg0, boolean arg1) { + fu.fitToScreen(arg0); + super.displayDialog(arg0, arg1); + } + + + + @Override + public void displayDialog(OpenFormDialog arg0, boolean arg1) { + fu.fitToScreen(arg0); + super.displayDialog(arg0, arg1); + } + + + + @SuppressWarnings("unchecked") + @Override + public void loadRendering() throws TCException { + fu.loadRendering(); + + { + ChangeComboBoxState_ysr8_Class(); + + String ysr8_Part = fu.tcForm.getProperty("ysr8_Part"); + JComboBoxInfo ci = (JComboBoxInfo)fu.allComponentInfos.get("ysr8_Part"); + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_Part"); + if (!((JComboBoxInfo)ci).valueName.equals("") && ((JComboBoxInfo)ci).lovVal != null && + ysr8_Part != null && !ysr8_Part.equals("")) { + if (((JComboBoxInfo)ci).lovVal.get(ysr8_Part) == null || + ((JComboBoxInfo)ci).lovVal.get(ysr8_Part).equals("")) { + cbx.setSelectedItem(ysr8_Part); + } else { + cbx.setSelectedItem(((JComboBoxInfo)ci).lovVal.get(ysr8_Part)); + } + } + } + { + ChangeComboBoxState_ysr8_Part(); + + String ysr8_Project = fu.tcForm.getProperty("ysr8_Project"); + JComboBoxInfo ci = (JComboBoxInfo)fu.allComponentInfos.get("ysr8_Project"); + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_Project"); + if (!((JComboBoxInfo)ci).valueName.equals("") && ((JComboBoxInfo)ci).lovVal != null && + ysr8_Project != null && !ysr8_Project.equals("")) { + if (((JComboBoxInfo)ci).lovVal.get(ysr8_Project) == null || + ((JComboBoxInfo)ci).lovVal.get(ysr8_Project).equals("")) { + cbx.setSelectedItem(ysr8_Project); + } else { + cbx.setSelectedItem(((JComboBoxInfo)ci).lovVal.get(ysr8_Project)); + } + } + } + + loadPic(); + +// ViewEditHelper editHelp = new ViewEditHelper(fu.session); +// boolean checkedOut = editHelp.isCheckedOutByUser(fu.tcForm); +// if (checkedOut && isModifiable()) { +// fcu = new FormCheckUtil(fu.tcForm, fu.allComponentMap); +// fcu.checkHandler(); +// if (fcu.isNeedCheck()) { +// fcu.setEnable(); +// } +// } + fcu = new FormCheckUtil(fu.tcForm, fu.allComponentMap); + fcu.checkHandler(); + } + + public void setRenderingReadOnly() + { + setModifiableComponents(this, false); + if(getController() != null) + getController().setFormReadOnly(); + } + + public void setRenderingReadWrite() + { + System.out.println("setRenderingReadWrite");//TODO + DateButton datebtn = (DateButton)fu.allComponentMap.get("ysr8_PRRectificationTimeV"); + try { + if(datebtn.getDate()!=null && !datebtn.getDate().equals(fu.tcForm.getDateProperty("ysr8_PRRectificationTime"))) { + fu.tcForm.setDateProperty("ysr8_PRRectificationTime", datebtn.getDate()); + } + } catch (TCException e) { + e.printStackTrace(); + } + if (fcu != null) + System.out.println("fcu.isNeedCheck:"+fcu.isNeedCheck()); + if (fcu != null && fcu.isNeedCheck()) { + if(!setEnabled) { + fcu.setEnable(); + setEnabled = true; + } + }else { + setModifiableComponents(this, true); + + ChangeComboBoxState_ysr8_ProblemType(); + + fu.allComponentMap.get("ysr8_ProblemStatus").setEnabled(false); + fu.allComponentMap.get("ysr8_ProblemDate").setEnabled(false); + fu.allComponentMap.get("ysr8_RequirementDate").setEnabled(false); + + fu.allComponentMap.get("ysr8_TechStaff" + "_Select").setEnabled(false); + fu.allComponentMap.get("ysr8_Purcher2" + "_Select").setEnabled(false); + fu.allComponentMap.get("ysr8_Machiner2" + "_Select").setEnabled(false); + fu.allComponentMap.get("ysr8_Engineer" + "_Select").setEnabled(false); + + fu.allComponentMap.get("ysr8_TechPlanDate").setEnabled(false); + fu.allComponentMap.get("ysr8_PurchPlanDate").setEnabled(false); + fu.allComponentMap.get("ysr8_MachinPlanDate").setEnabled(false); + fu.allComponentMap.get("ysr8_EnginePlanDate").setEnabled(false); + + fu.allComponentMap.get("ysr8_PRReasonAnalysis").setEnabled(false); + fu.allComponentMap.get("ysr8_PRDelayReason").setEnabled(false); + fu.allComponentMap.get("ysr8_PRRectificationTimeV").setEnabled(false); + fu.allComponentMap.get("ysr8_PurchReason2").setEnabled(false); + fu.allComponentMap.get("ysr8_PurchReason").setEnabled(false); + fu.allComponentMap.get("ysr8_PurchFinishDate").setEnabled(false); + fu.allComponentMap.get("ysr8_MachReason").setEnabled(false); + fu.allComponentMap.get("ysr8_MachReason2").setEnabled(false); + fu.allComponentMap.get("ysr8_MachFinishDate").setEnabled(false); + fu.allComponentMap.get("ysr8_ReasonAnalysis2").setEnabled(false); + fu.allComponentMap.get("ysr8_FinishDate").setEnabled(false); + fu.allComponentMap.get("ysr8_ImplementReason").setEnabled(false); + + fu.allComponentMap.get("ysr8_ImplementStaff").setEnabled(false); + fu.allComponentMap.get("ysr8_ChangeStatus").setEnabled(false); + fu.allComponentMap.get("ysr8_AfterChange").setEnabled(false); + + //20240722 + fu.allComponentMap.get("ysr8_ElecDebug2FinishDate").setEnabled(false); + fu.allComponentMap.get("ysr8_ImplementReason").setEnabled(false); + fu.allComponentMap.get("ysr8_ElecReason").setEnabled(false); + fu.allComponentMap.get("ysr8_TechCenterFinishDate").setEnabled(false); + fu.allComponentMap.get("ysr8_TechCenterReason2").setEnabled(false); + fu.allComponentMap.get("ysr8_TechCenterReason").setEnabled(false); + } + +// setPlannerEdit(); + } + + private void setModifiableComponents(java.awt.Component currcomponent, boolean flag) + { + if (fcu != null && flag) { + if (fcu.isNeedCheck()) { + return; + } + } + fu.setModifiableComponents(currcomponent, flag); + } + + @Override + public void saveRendering() { + if (!checkCanSave()) { + return; + } + try { + fu.saveRendering(); + saveLocalPic(); + } catch (TCException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } catch (ParseException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } + } + + public boolean isRenderingModified() { + if (fu.isRenderingModified()) { + return true; + } + if (deletePic.size() > 0) { + return true; + } + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a.11.11.091.12.11"); + for (int l = 0; l < ci.dataTableModel.getRowCount(); l++) { + if (ci.dataTableModel.getValueAt(l, 0) == null || + ci.dataTableModel.getValueAt(l, 1) == null) { + continue; + } else { + String sign = ci.dataTableModel.getValueAt(l, 0).toString(); + if (sign.equalsIgnoreCase("")) { + return true; + } + } + } + + return false; + } + ///////////////////////////////////////////////////////////////// + @SuppressWarnings("unchecked") + private void addActionListener() { + { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_ProblemType"); + cbx.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent itemevent) { + if (itemevent.getStateChange() == ItemEvent.SELECTED) { + ChangeComboBoxState_ysr8_ProblemType(); + } + } + }); + } + ////////////////////////////////////////////////////// + { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_Class"); + cbx.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent itemevent) { + if (itemevent.getStateChange() == ItemEvent.SELECTED) { + ChangeComboBoxState_ysr8_Class(); + } + } + }); + } + ////////////////////////////////////////////////////// + { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_Part"); + cbx.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent itemevent) { + if (itemevent.getStateChange() == ItemEvent.SELECTED) { + ChangeComboBoxState_ysr8_Part(); + } + } + }); + } + ////////////////////////////////////////////////////// + { + JButton btn = (JButton)fu.allComponentMap.get("b.11.11.091.13.11"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + addLocalPic(); + } + }); + + btn = (JButton)fu.allComponentMap.get("b.11.11.091.13.21"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a.11.11.091.12.11"); + JTable table = (JTable)fu.allComponentMap.get("a.11.11.091.12.11"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪƳУ", "ʾ", MessageBox.INFORMATION); + return; + } + for (int i = rows.length - 1; i >= 0; i--) { + String sign = ci.dataTableModel.getValueAt(rows[i], 0).toString(); + if (sign.equalsIgnoreCase("ϴ")) { + deletePic.add(ci.dataTableModel.getValueAt(rows[i], 1).toString()); + } + ci.dataTableModel.removeRow(rows[i]); + } + } + }); + } + } + + @SuppressWarnings("unused") + private void setPlannerEdit() { + TCComponentUser user = fu.session.getUser(); + try { + if (fu.tcForm.getProperty("ysr8_Planner").equals(user.getProperty("user_name"))) { + System.out.println("11111111111111111111111111111111111111111111111111111111111111111111"); + fu.allComponentMap.get("ysr8_ChangeDept").setEnabled(true); + fu.allComponentMap.get("ysr8_ImplementDept").setEnabled(true); + fu.allComponentMap.get("ysr8_TechStaff").setEnabled(true); + fu.allComponentMap.get("ysr8_TechStaff_Select").setEnabled(true); + fu.allComponentMap.get("ysr8_Purcher2").setEnabled(true); + fu.allComponentMap.get("ysr8_Purcher2_Select").setEnabled(true); + fu.allComponentMap.get("ysr8_Machiner2").setEnabled(true); + fu.allComponentMap.get("ysr8_Machiner2_Select").setEnabled(true); + fu.allComponentMap.get("ysr8_Engineer").setEnabled(true); + fu.allComponentMap.get("ysr8_Engineer_Select").setEnabled(true); + fu.allComponentMap.get("ysr8_TechPlanDate").setEnabled(true); + fu.allComponentMap.get("ysr8_PurchPlanDate").setEnabled(true); + fu.allComponentMap.get("ysr8_MachinPlanDate").setEnabled(true); + fu.allComponentMap.get("ysr8_EnginePlanDate").setEnabled(true); + //20240722 + fu.allComponentMap.get("ysr8_ElecDebug2").setEnabled(true); + fu.allComponentMap.get("ysr8_TechCenter").setEnabled(true); + + fu.allComponentMap.get("ysr8_ElecDebug2PlanDate").setEnabled(true); + fu.allComponentMap.get("ysr8_TechCenterPlanDate").setEnabled(true); + + + } else { + fu.allComponentMap.get("ysr8_ChangeDept").setEnabled(false); + fu.allComponentMap.get("ysr8_ImplementDept").setEnabled(false); + fu.allComponentMap.get("ysr8_TechStaff").setEnabled(false); + fu.allComponentMap.get("ysr8_TechStaff_Select").setEnabled(false); + fu.allComponentMap.get("ysr8_Purcher2").setEnabled(false); + fu.allComponentMap.get("ysr8_Purcher2_Select").setEnabled(false); + fu.allComponentMap.get("ysr8_Machiner2").setEnabled(false); + fu.allComponentMap.get("ysr8_Machiner2_Select").setEnabled(false); + fu.allComponentMap.get("ysr8_Engineer").setEnabled(false); + fu.allComponentMap.get("ysr8_Engineer_Select").setEnabled(false); + fu.allComponentMap.get("ysr8_TechPlanDate").setEnabled(false); + fu.allComponentMap.get("ysr8_PurchPlanDate").setEnabled(false); + fu.allComponentMap.get("ysr8_MachinPlanDate").setEnabled(false); + fu.allComponentMap.get("ysr8_EnginePlanDate").setEnabled(false); + + //20240722 + fu.allComponentMap.get("ysr8_ElecDebug2").setEnabled(false); + fu.allComponentMap.get("ysr8_TechCenter").setEnabled(false); + + fu.allComponentMap.get("ysr8_ElecDebug2PlanDate").setEnabled(false); + fu.allComponentMap.get("ysr8_TechCenterPlanDate").setEnabled(false); + } + + if (fu.tcForm.getProperty("ysr8_TechStaff").equals(user.getProperty("user_name"))) { + fu.allComponentMap.get("ysr8_ReasonAnalysis").setEnabled(true); + fu.allComponentMap.get("ysr8_ChangeMeasures").setEnabled(true); + } else { + fu.allComponentMap.get("ysr8_ReasonAnalysis").setEnabled(false); + fu.allComponentMap.get("ysr8_ChangeMeasures").setEnabled(false); + } + + if (fu.tcForm.getProperty("ysr8_Engineer").equals(user.getProperty("user_name"))) { + fu.allComponentMap.get("ysr8_FinishDate").setEnabled(true); + fu.allComponentMap.get("ysr8_ReasonAnalysis2").setEnabled(true); + fu.allComponentMap.get("ysr8_AfterChange").setEnabled(true); + } else { + fu.allComponentMap.get("ysr8_FinishDate").setEnabled(false); + fu.allComponentMap.get("ysr8_ReasonAnalysis2").setEnabled(false); + fu.allComponentMap.get("ysr8_AfterChange").setEnabled(true); + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + @SuppressWarnings("unchecked") + private void ChangeComboBoxState_ysr8_ProblemType() { + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_ProblemType"); + if (cbx.getSelectedItem().toString().equals("")) { + fu.allComponentMap.get("ysr8_Class").setEnabled(true); + fu.allComponentMap.get("ysr8_Part").setEnabled(true); + fu.allComponentMap.get("ysr8_Project").setEnabled(true); + } else { + fu.allComponentMap.get("ysr8_Class").setEnabled(false); + fu.allComponentMap.get("ysr8_Part").setEnabled(false); + fu.allComponentMap.get("ysr8_Project").setEnabled(false); + } + } + + @SuppressWarnings("unchecked") + private void ChangeComboBoxState_ysr8_Class() { + JComboBoxInfo ci = (JComboBoxInfo)fu.allComponentInfos.get("ysr8_Class"); + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_Class"); + String currYsr8_Class = cbx.getSelectedItem().toString(); + if (currYsr8_Class.equals("") || ci.lovVal == null) { + return; + } + Iterator iter = ci.lovVal.keySet().iterator(); + while (iter.hasNext()) { + String lovKey = iter.next(); + String lovValue = ci.lovVal.get(lovKey); + if (lovValue.equalsIgnoreCase(currYsr8_Class)) { + + JComboBoxInfo ci1 = (JComboBoxInfo)fu.allComponentInfos.get("ysr8_Part"); + JComboBox cbx1 = (JComboBox)fu.allComponentMap.get("ysr8_Part"); + + ci1.valueName = lovKey; + ci1.lovVal = null; + cbx1.removeAllItems(); + cbx1.addItem(""); + fu.getlovValues(ci1); + if (ci1.lovVal != null && ci1.lovVal.size() > 0) { + for(Entry entry: ci1.lovVal.entrySet()){ + cbx1.addItem(entry.getValue()); + } + } + cbx1.setSelectedIndex(0); + break; + } + } + } + + @SuppressWarnings("unchecked") + private void ChangeComboBoxState_ysr8_Part() { + JComboBoxInfo ci = (JComboBoxInfo)fu.allComponentInfos.get("ysr8_Part"); + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_Part"); + String currYsr8_Part = cbx.getSelectedItem().toString(); + if (currYsr8_Part.equals("") || ci.lovVal == null) { + return; + } + Iterator iter = ci.lovVal.keySet().iterator(); + while (iter.hasNext()) { + String lovKey = iter.next(); + String lovValue = ci.lovVal.get(lovKey); + if (lovValue.equalsIgnoreCase(currYsr8_Part)) { + + JComboBoxInfo ci1 = (JComboBoxInfo)fu.allComponentInfos.get("ysr8_Project"); + JComboBox cbx1 = (JComboBox)fu.allComponentMap.get("ysr8_Project"); + + ci1.valueName = lovKey; + ci1.lovVal = null; + cbx1.removeAllItems(); + cbx1.addItem(""); + fu.getlovValues(ci1); + if (ci1.lovVal != null && ci1.lovVal.size() > 0) { + for(Entry entry: ci1.lovVal.entrySet()){ + cbx1.addItem(entry.getValue()); + } + } + cbx1.setSelectedIndex(0); + break; + } + } + } + + @SuppressWarnings("unchecked") + private void setComboBoxValue_ysr8_StationNo() { + //JComboBoxInfo ci = (JComboBoxInfo)fu.allComponentInfos.get("ysr8_SubProjectCode"); + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_StationNo"); + iTextField textfield = (iTextField)fu.allComponentMap.get("ysr8_ProjectCode"); + String projectCode = textfield.getText().toString(); + if (projectCode.equals("")) { + return; + } + try { + TCComponentItem systemPartsItem = TCUtil.findItemByID(fu.session, projectCode); + if (systemPartsItem != null) { + TCComponentItemRevision systemPartsRevision = systemPartsItem.getLatestItemRevision(); + TCComponentPseudoFolder folder = TCUtil.getRevisionPseudoFolder(systemPartsRevision, "ͼ"); + if (folder != null) { + AIFComponentContext[] comps = folder.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("еĿ") || objType.equals("Ŀ")) { + cbx.addItem(comp.getProperty("item_id")); + } + } + } + } + } + } + cbx.addItem(""); + + String ysr8_StationNoVal = fu.tcForm.getProperty("ysr8_StationNo"); + if (!ysr8_StationNoVal.equals("")) { + cbx.setSelectedItem(ysr8_StationNoVal); + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + private void getDefVal() { + iTextField textfield = (iTextField)fu.allComponentMap.get("ysr8_ProjectCode"); + String projectCode = textfield.getText().toString(); + textfield = (iTextField)fu.allComponentMap.get("ysr8_ProjectName"); + String projectName = textfield.getText().toString(); + if (!projectCode.equals("") && !projectName.equals("")) {//lidy20190304 + return; + } + + TCComponentItemRevision itemRevision = null; + projectCode = ""; + try { + AIFComponentContext[] context = fu.tcForm.whereReferencedByTypeRelation(new String[] {"YSR8_PRRevision"}, new String[] {"IMAN_master_form"}); + if (context != null && context.length > 0) { + itemRevision = (TCComponentItemRevision)context[0].getComponent(); + String itemId = itemRevision.getProperty("item_id"); + textfield = (iTextField)fu.allComponentMap.get("ysr8_ProblemNo"); + textfield.setText(itemId); + + Vector itemIdPart = CommonUtil.split2Vector(itemId, "-"); + if (itemIdPart.size() > 1) { + for (int i = 0; i < itemIdPart.size() - 1; i++) { + projectCode += itemIdPart.get(i); + if (i + 1 == itemIdPart.size() - 1) { + + } else { + projectCode += "-"; + } + } + + textfield = (iTextField)fu.allComponentMap.get("ysr8_ProjectCode"); + textfield.setText(projectCode); + } + } + + if (projectCode.equals("")) { + return; + } + HashMap valMap = new HashMap(); + TCComponentForm sourceForm = null; + //TCComponentSchedule schedule = TCUtil.findScheduleByID(fu.session, projectCode + "-00");//lidy20180823ΪͨĿʱ + TCComponentSchedule schedule = TCUtil.findScheduleByProjectID(fu.session, projectCode); + if (schedule == null) { + return; + } + sourceForm = (TCComponentForm)schedule.getRelatedComponent("IMAN_reference"); + + valMap.put("ysr8_ProjectName", "ysr8_ProjectName"); + valMap.put("ysr8_ProjectManager", "ysr8_ProjectManager"); + valMap.put("ysr8_Planner", "ysr8_Planner"); + valMap.put("ysr8_DesignDirector", "ysr8_DesignDirector"); + valMap.put("ysr8_ElectricDirector", "ysr8_ElectricDirector"); + valMap.put("ysr8_Purcher", "ysr8_Purcher"); + valMap.put("ysr8_Machiner", "ysr8_Machiner"); + valMap.put("ysr8_EngineerDebug", "ysr8_EngineerDebug"); + valMap.put("ysr8_ElecDebug", "ysr8_ElecDebug"); + + if (sourceForm == null) { + return; + } + + for(Entry entry: valMap.entrySet()){ + String key1 = entry.getKey(); + String key2 = entry.getValue(); + + String propValue = ""; + TCFormProperty property1 = (TCFormProperty)sourceForm.getFormTCProperty(key1); + switch (property1.getPropertyType()) { + case TCProperty.PROP_string: + case TCProperty.PROP_long_string: + propValue = sourceForm.getStringProperty(key1); + break; + case TCProperty.PROP_short: + case TCProperty.PROP_int: + propValue = Integer.toString(sourceForm.getIntProperty(key1)); + break; + case TCProperty.PROP_double: + case TCProperty.PROP_float: + propValue = fu.getDoubleString(sourceForm.getDoubleProperty(key1)); + break; + case TCProperty.PROP_date: + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date date = sourceForm.getDateProperty(key1); + if (date != null) { + propValue = sdf.format(date); + } + break; + default: + propValue = sourceForm.getStringProperty(key1); + break; + } + iTextField textfieldForm; + if (key2.equals("ysr8_ProjectName")) { + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_ProjectName"); + textfieldForm.setText(propValue); + } else if (key2.equals("ysr8_ProjectManager")) { + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_ProjectManager"); + textfieldForm.setText(propValue); + } else if (key2.equals("ysr8_Planner")) { + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_Planner"); + textfieldForm.setText(propValue); + } else if (key2.equals("ysr8_DesignDirector")) { + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_DesignDirector"); + textfieldForm.setText(propValue); + } else if (key2.equals("ysr8_ElectricDirector")) { + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_ElectricDirector"); + textfieldForm.setText(propValue); + } else if (key2.equals("ysr8_Purcher")) { + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_Purcher"); + textfieldForm.setText(propValue); +// textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_Purcher2"); +// textfieldForm.setText(propValue); + } else if (key2.equals("ysr8_Machiner")) { + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_Machiner"); + textfieldForm.setText(propValue); +// textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_Machiner2"); +// textfieldForm.setText(propValue); + } else if (key2.equals("ysr8_EngineerDebug")) { + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_EngineerDebug"); + textfieldForm.setText(propValue); +// textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_Engineer"); +// textfieldForm.setText(propValue); + } else if (key2.equals("ysr8_ElecDebug")) { + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_ElecDebug"); + textfieldForm.setText(propValue); + } + } + } catch (TCException ex) { + ex.printStackTrace(); + } + } + + private void loadPic() { + TCComponentItemRevision itemRevision = null; + TCComponentDataset dataset = null; + try { + AIFComponentContext[] context = fu.tcForm.whereReferencedByTypeRelation(new String[] {"YSR8_PRRevision"}, new String[] {"IMAN_master_form"}); + if (context != null && context.length > 0) { + itemRevision = (TCComponentItemRevision)context[0].getComponent(); + + TCComponent[] components = itemRevision.getRelatedComponents("IMAN_specification"); + if (components != null && components.length > 0) { + JTableInfo ci = (JTableInfo)fu.allComponentInfos.get("a.11.11.091.12.11"); + ci.dataTableModel.getDataVector().clear(); + int cols = ci.childComponentInfos.size(); + for (int i = 0; i < components.length; i++) { + if(components[i] instanceof TCComponentDataset) { + dataset = (TCComponentDataset) components[i]; + String name = dataset.getProperty("object_string"); + + Object[] objData = new Object[cols]; + objData[0] = "ϴ"; + objData[1] = name; + ci.dataTableModel.addRow(objData); + } + } + } + } + } catch (TCException e1) { + e1.printStackTrace(); + } + } + + private void addLocalPic() { + //lidy20180827ѹļʽ + String[][] fileTypes = { { ".gif;.bmp;.jpg;.png", "ͼƬļ" }, + { ".doc;.docx;.xls;.xlsx", "Officeļ" }, + { ".zip;.rar", "ѹļ" } + }; + File[] files = FileUtil.openFileChoosers(fileTypes); + if (files == null) { + return; + } + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a.11.11.091.12.11"); + int cols = ci.childComponentInfos.size(); + for (int f = 0; f < files.length; f++) { + Object[] objData = new Object[cols]; + objData[0] = ""; + objData[1] = files[f].getAbsolutePath(); + ci.dataTableModel.addRow(objData); + } + } + + private void saveLocalPic() { + Vector addPic = new Vector(); + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a.11.11.091.12.11"); + for (int l = 0; l < ci.dataTableModel.getRowCount(); l++) { + if (ci.dataTableModel.getValueAt(l, 0) == null || + ci.dataTableModel.getValueAt(l, 1) == null) { + continue; + } else { + String sign = ci.dataTableModel.getValueAt(l, 0).toString(); + if (sign.equalsIgnoreCase("")) { + String fileName = ci.dataTableModel.getValueAt(l, 1).toString(); + addPic.add(fileName); + } + } + } + + TCComponentItemRevision itemRevision = null; + TCComponentDataset dataset = null; + try { + AIFComponentContext[] context = fu.tcForm.whereReferencedByTypeRelation(new String[] {"YSR8_PRRevision"}, new String[] {"IMAN_master_form"}); + if (context != null && context.length > 0) { + itemRevision = (TCComponentItemRevision)context[0].getComponent(); + + TCComponent[] components = itemRevision.getRelatedComponents("IMAN_specification"); + if (components != null && components.length > 0) { + for (int i = 0; i < components.length; i++) { + dataset = (TCComponentDataset) components[i]; + String name = dataset.getProperty("object_string"); + for (String pic : deletePic) { + if (pic.equalsIgnoreCase(name)) { + itemRevision.remove("IMAN_specification", dataset); + dataset.delete(); + } + } + } + } + + for (String pic : addPic) { + File file = new File(pic); + TCComponentDataset newDataset = TCUtil.createDataset(fu.session, file, file.getName()); + itemRevision.add("IMAN_specification", new TCComponent[] { newDataset }); + } + } + } catch (TCException e1) { + e1.printStackTrace(); + } + loadPic(); + } + + public boolean checkCanSave() { + /*{ + DateButton datebtn1 = (DateButton)fu.allComponentMap.get("ysr8_EnginePlanDate"); + Date date1 = datebtn1.getDate(); + DateButton datebtn2 = (DateButton)fu.allComponentMap.get("ysr8_FinishDate"); + Date date2 = datebtn2.getDate();; + + if (date1 != null && date2 != null) { + JTextArea text = (JTextArea)fu.allComponentMap.get("ysr8_ReasonAnalysis2"); + String string = text.getText(); + if (date1.getTime() < date2.getTime() && string.equals("")) { + MessageBox.post("ڡƻʱ䡱ڡʵʱ䡱Աдԭ...", "ʾ", MessageBox.INFORMATION); + return false; + } + } + }*/ + return true; + } + private void setTechFinishDate() { + JTextField ysr8_TechStaff = (JTextField) fu.allComponentMap.get("ysr8_TechStaff"); + if(ysr8_TechStaff.getText().isEmpty()) + return; + try { + DateButton datebtn = (DateButton)fu.allComponentMap.get("ysr8_PRRectificationTimeV"); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date lastEnd = sdf.parse("1900-01-01"); + AIFComponentContext[] context = + fu.tcForm.whereReferencedByTypeRelation(new String[] {"YSR8_PRRevision"}, new String[] {"IMAN_master_form"}); + TCComponentItemRevision prRevision = (TCComponentItemRevision)context[0].getComponent(); + TCComponentPseudoFolder folder = TCUtil.getRevisionPseudoFolder(prRevision, "ĵ"); + if (folder != null) { + AIFComponentContext[] comps = folder.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 && comp.getType().startsWith("YSR8_ECN")) { + TCComponentForm ecnForm = TCUtil.getItemRevisionMasterForm(((TCComponentItem)comp).getLatestItemRevision()); + Date techFinishDate = ecnForm.getDateProperty("ysr8_TechFinishDate"); + if(techFinishDate==null) { + return; + } + if(String.format("%tF", techFinishDate).compareTo(String.format("%tF", lastEnd))>0) + lastEnd = techFinishDate; + } + } + if(!String.format("%tF", lastEnd).equals("1900-01-01")) + datebtn.setDate(lastEnd); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/cn/com/ebewin/ysr/form/YSR8_ProjectSRevisionMasterForm.java b/src/cn/com/ebewin/ysr/form/YSR8_ProjectSRevisionMasterForm.java new file mode 100644 index 0000000..816348c --- /dev/null +++ b/src/cn/com/ebewin/ysr/form/YSR8_ProjectSRevisionMasterForm.java @@ -0,0 +1,1498 @@ +package cn.com.ebewin.ysr.form; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.Enumeration; +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.Map.Entry; +import java.util.Vector; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.border.TitledBorder; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; + +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.common.viewedit.ViewEditHelper; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentContextList; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentGroupMember; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentRole; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCFormProperty; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTextService; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.ui.common.RACUIUtil; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.Registry; +import com.teamcenter.rac.util.iTextField; + +import cn.com.ebewin.ysr.dialog.SelectUserDialog; +import cn.com.ebewin.ysr.util.CommonUtil; +import cn.com.ebewin.ysr.util.FormUtil; +import cn.com.ebewin.ysr.util.TCUtil; + +@SuppressWarnings("deprecation") +public class YSR8_ProjectSRevisionMasterForm extends AbstractRendering { + private static final long serialVersionUID = 1L; + private static Date refreshDate = null; + + private FormUtil fu = new FormUtil(this); + + private TCFormProperty[] formProperties; + private TCSession session; + private Hashtable indices; + TCComponentForm tcForm; + private List allComponents = new ArrayList(); + + // ProjectInfo + // panel1 + private DateButton ReceiveDate;//յ + private JComboBox OriginateDept;// + private JComboBox StartType;// + // panel2 + private DateButton StartDate;// + private JComboBox Use;//Ŀ + private iTextField ProjectCode;// + private iTextField ysr8_SFGL;//ǷĿ + private iTextField ysr8_GLProjectCode;//Ŀ + private iTextField QuotationNo;//۵ + private iTextField OrderManufacturer;// + private iTextField CustomerName;//û + private iTextField ProjectName;//Ŀ + private DateButton CriticalDate;//ؼʱڵ + private iTextField UserWorkpieceName;//û + private iTextField CriticalDateDes;//ؼڵ + private DateButton ProductionDate;//Ԥʱ + private DateButton FinalAcceptance;//Ԥʱ + private iTextField Sales;//۸ + private JComboBox Factory;// + private JComboBox Section;//Ʊ + private JComboBox Product;//Ŀȼ + private iTextField ProjectManager;//Ŀ + private iTextField Planner;//ƻԱ + private iTextField DesignDirector;// + private iTextField ElectricDirector;// + private JComboBox ProjectLevel;//Ŀȼ + private JComboBox ProjectCategory;//Ŀ + private JTextArea ProjectContent;//Ŀ + private iTextField Creator;// + private iTextField Reviewer;// + private iTextField Approver;//׼ + private JButton synchronization;//ͬ + private JTextArea MotomanType;//ͺ + private iTextField MotomanQuantity;//̨ + + LinkedHashMap lovOriginateDept; + LinkedHashMap lovStartType; + LinkedHashMap lovProduct; + LinkedHashMap lovUse; + LinkedHashMap lovProjectLevel; + LinkedHashMap lovProjectCategory; + + // ProjectManInfo + JTable tblProjectMembers; + String[] columnNames; + DefaultTableModel dataTableModel; + Vector projectVector = new Vector(); + + public YSR8_ProjectSRevisionMasterForm(TCComponentForm arg0) throws Exception { + super(arg0); + + Date currDate = new Date(); + if (refreshDate == null) { + arg0.refresh(); + refreshDate = currDate; + } else { + long diff = currDate.getTime() - refreshDate.getTime(); + long minutes = diff / 1000 / 60; + if ( minutes >= 1 ) { + arg0.refresh(); + refreshDate = currDate; + } + } + +System.out.println("YSR8_ProjectSRevisionMasterForm"); + + this.session = null; + this.session = arg0.getSession(); + this.formProperties = null; + this.tcForm = arg0; + indices = new Hashtable(); + + lovOriginateDept = new LinkedHashMap(); + getlovValues("ysr8_OriginateDept_LOV", lovOriginateDept); + lovStartType = new LinkedHashMap(); + getlovValues("ysr8_StartType_LOV", lovStartType); + lovProduct = new LinkedHashMap(); + getlovValues("ysr8_Product_LOV", lovProduct); + lovUse = new LinkedHashMap(); + getlovValues("ysr8_Use_LOV", lovUse); + lovProjectLevel = new LinkedHashMap(); + getlovValues("ysr8_ProjectLevel_LOV", lovProjectLevel); + lovProjectCategory = new LinkedHashMap(); + getlovValues("ysr8_ProjectCategory_LOV", lovProjectCategory); + + initializeUI(); + setName(); + loadRendering(); + + if (ProjectCategory.getSelectedItem().toString().equals("") || ProjectCategory.getSelectedItem().toString().equals("ϵͳ1")) { + ProductionDate.setEnabled(false); + ProductionDate.setDate(""); + } else { + ProductionDate.setEnabled(true); + } + } + + private void initializeUI() { + try { + setLayout(new BorderLayout()); + setBackground(new JLabel("").getBackground()); + JTabbedPane tabPane = new JTabbedPane(); + tabPane.addTab("ĿϢ", getProjectInfoPanel()); + tabPane.addTab("ĿԱϢ", getProjectManInfoPanel()); + add(BorderLayout.WEST, new JLabel(" ")); + add(BorderLayout.CENTER, tabPane); + add(BorderLayout.EAST, new JLabel(" ")); + + ViewEditHelper editHelp = new ViewEditHelper(session); + boolean checkedOut = editHelp.isCheckedOutByUser(tcForm); + if (checkedOut && this.isModifiable()) { + setRenderingReadWrite(); + } else { + setRenderingReadOnly(); + } + } + catch (Exception e) { + e.printStackTrace(); + } + } + + private void setName() { + // panel1 + ReceiveDate.setName("ysr8_ReceiveDate"); + allComponents.add(ReceiveDate); + OriginateDept.setName("ysr8_OriginateDept"); + allComponents.add(OriginateDept); + StartType.setName("ysr8_StartType"); + allComponents.add(StartType); + + // panel2 + StartDate.setName("ysr8_StartDate"); + allComponents.add(StartDate); + Use.setName("ysr8_Use"); + allComponents.add(Use); + ProjectCode.setName("ysr8_ProjectCode"); + allComponents.add(ProjectCode); + ysr8_SFGL.setName("ysr8_SFGL"); + allComponents.add(ysr8_SFGL); + ysr8_GLProjectCode.setName("ysr8_GLProjectCode"); + allComponents.add(ysr8_GLProjectCode); + QuotationNo.setName("ysr8_QuotationNo"); + allComponents.add(QuotationNo); + OrderManufacturer.setName("ysr8_OrderManufacturer"); + allComponents.add(OrderManufacturer); + CustomerName.setName("ysr8_CustomerName"); + allComponents.add(CustomerName); + ProjectName.setName("ysr8_ProjectName"); + allComponents.add(ProjectName); + UserWorkpieceName.setName("ysr8_UserWorkpieceName"); + allComponents.add(UserWorkpieceName); + CriticalDate.setName("ysr8_CriticalDate"); + allComponents.add(CriticalDate); + UserWorkpieceName.setName("ysr8_UserWorkpieceName"); + allComponents.add(UserWorkpieceName); + CriticalDateDes.setName("ysr8_CriticalDateDes"); + allComponents.add(CriticalDateDes); + ProductionDate.setName("ysr8_ProductionDate"); + allComponents.add(ProductionDate); + FinalAcceptance.setName("ysr8_FinalAcceptance"); + allComponents.add(FinalAcceptance); + Sales.setName("ysr8_Sales"); + allComponents.add(Sales); + Factory.setName("ysr8_Factory"); + allComponents.add(Factory); + Section.setName("ysr8_Section"); + allComponents.add(Section); + Product.setName("ysr8_Product"); + allComponents.add(Product); + ProjectManager.setName("ysr8_ProjectManager"); + allComponents.add(ProjectManager); + Planner.setName("ysr8_Planner"); + allComponents.add(Planner); + DesignDirector.setName("ysr8_DesignDirector"); + allComponents.add(DesignDirector); + ElectricDirector.setName("ysr8_ElectricDirector"); + allComponents.add(ElectricDirector); + ProjectLevel.setName("ysr8_ProjectLevel"); + allComponents.add(ProjectLevel); + ProjectCategory.setName("ysr8_ProjectCategory"); + allComponents.add(ProjectCategory); + ProjectContent.setName("ysr8_ProjectContent"); + allComponents.add(ProjectContent); + Creator.setName("ysr8_Creator"); + allComponents.add(Creator); + Reviewer.setName("ysr8_Reviewer"); + allComponents.add(Reviewer); + Approver.setName("ysr8_Approver"); + allComponents.add(Approver); + MotomanType.setName("ysr8_MotomanType"); + allComponents.add(MotomanType); + MotomanQuantity.setName("ysr8_MotomanQuantity"); + allComponents.add(MotomanQuantity); + } + + private void getlovValues(String lovName, LinkedHashMap lovVal) { + try { + TCComponentListOfValuesType lovType = (TCComponentListOfValuesType) this.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(); + + for (int i = 0; i < code.length; i++) { + lovVal.put(code[i], name[i]); + } + } + } + catch (TCException e) { + e.printStackTrace(); + } + } + + private void setTextAreaStyle(JTextArea textArea, boolean setBackgroud) { + //textArea.setBorder(BorderFactory.createLoweredBevelBorder()); + textArea.setAutoscrolls(true); + textArea.setLineWrap(true); + textArea.setWrapStyleWord(true); + if (setBackgroud) { + textArea.setBackground(new JLabel("").getBackground()); + } + } + + private JScrollPane getProjectInfoPanel() { + // panel1 + JPanel panel1 = new JPanel(); + panel1.setLayout(new PropertyLayout()); + panel1.setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), "")); + + ReceiveDate = new DateButton(null , "yyyy-MM-dd", false, false, false); + ReceiveDate.setPreferredSize(new Dimension(194, 22)); + + OriginateDept = new JComboBox(); + OriginateDept.setPreferredSize(new Dimension(180, 22)); + OriginateDept.addItem(""); + if (lovOriginateDept != null && lovOriginateDept.size() > 0) { + for(Entry entry: lovOriginateDept.entrySet()){ + OriginateDept.addItem(entry.getValue()); + } + } + + StartType = new JComboBox(); + StartType.setPreferredSize(new Dimension(180, 22)); + StartType.addItem(""); + if (lovStartType != null && lovStartType.size() > 0) { + for(Entry entry: lovStartType.entrySet()){ + StartType.addItem(entry.getValue()); + } + } + + JPanel panel1_1 = new JPanel(); + panel1_1.setLayout(new PropertyLayout()); + panel1_1.add("1.1.left.center", new JLabel("")); + panel1_1.add("1.2.left.center", ReceiveDate); + panel1_1.add("1.3.left.center", new JLabel("ӵ")); + panel1_1.add("1.4.left.center", OriginateDept); + panel1_1.add("1.5.left.center", StartType); + panel1_1.add("1.6.left.center", new JLabel("Ŀʽ ")); + + panel1.add("1.1.left.center", new JLabel("")); + panel1.add("2.1.left.center", panel1_1); + panel1.add("3.1.left.center", new JLabel("")); + + ///////////////////////////////////////////////////////// + // panel2 + JPanel panel2 = new JPanel(); + panel2.setLayout(new PropertyLayout()); + panel2.setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), "")); + + StartDate = new DateButton(null , "yyyy-MM-dd", false, false, false); + StartDate.setPreferredSize(new Dimension(260, 22)); + + ProjectCategory = new JComboBox(); + ProjectCategory.setPreferredSize(new Dimension(260, 22)); + ProjectCategory.addItem(""); + if (lovProjectCategory != null && lovProjectCategory.size() > 0) { + for(Entry entry: lovProjectCategory.entrySet()){ + ProjectCategory.addItem(entry.getValue()); + } + } + ProjectCategory.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent itemevent) { + if (itemevent.getStateChange() == ItemEvent.SELECTED) { + ChangeComboBoxState_ProjectCategory(); + } + } + }); + + ProjectCode = new iTextField(); + ProjectCode.setPreferredSize(new Dimension(260, 22)); + ProjectCode.setEnabled(false); + + ysr8_SFGL = new iTextField(); + ysr8_SFGL.setPreferredSize(new Dimension(260, 22)); + ysr8_SFGL.setEnabled(false); + + ysr8_GLProjectCode = new iTextField(); + ysr8_GLProjectCode.setPreferredSize(new Dimension(260, 22)); + ysr8_GLProjectCode.setEnabled(false); + + QuotationNo = new iTextField(); + QuotationNo.setPreferredSize(new Dimension(260, 22)); + + OrderManufacturer = new iTextField(); + OrderManufacturer.setPreferredSize(new Dimension(698, 22)); + + CustomerName = new iTextField(); + CustomerName.setPreferredSize(new Dimension(698, 22)); + + ProjectName = new iTextField(); + ProjectName.setPreferredSize(new Dimension(698, 22)); + + CriticalDate = new DateButton(null , "yyyy-MM-dd", false, false, false); + CriticalDate.setPreferredSize(new Dimension(260, 22)); + + UserWorkpieceName = new iTextField(); + UserWorkpieceName.setPreferredSize(new Dimension(260, 22)); + + CriticalDateDes = new iTextField(); + CriticalDateDes.setPreferredSize(new Dimension(698, 22)); + + ProductionDate = new DateButton(null , "yyyy-MM-dd", false, false, false); + ProductionDate.setPreferredSize(new Dimension(260, 22)); + ProductionDate.setEnabled(false); + + FinalAcceptance = new DateButton(null , "yyyy-MM-dd", false, false, false); + FinalAcceptance.setPreferredSize(new Dimension(260, 22)); + + Sales = new iTextField(); + Sales.setPreferredSize(new Dimension(260, 22)); + + Factory = new JComboBox(); + Factory.setEditable(true); + Factory.setPreferredSize(new Dimension(130, 22)); + String[] s = TCUtil.getPreference(session, TCPreferenceService.TC_preference_site, "YSR8_LOV_Factory"); + Factory.addItem(""); + for(int i = 0; i < s.length; i++) + { + Factory.addItem(s[i]); + } + + Section = new JComboBox(); + Section.setPreferredSize(new Dimension(131, 22)); + String[] s2 = TCUtil.getPreference(session, TCPreferenceService.TC_preference_site, "YSR8_LOV_Section"); + Section.addItem(""); + for(int i = 0; i < s2.length; i++) + { + Section.addItem(s2[i]); + } + + Product = new JComboBox(); + Product.setPreferredSize(new Dimension(260, 22)); + Product.addItem(""); + if (lovProduct != null && lovProduct.size() > 0) { + for(Entry entry: lovProduct.entrySet()){ + Product.addItem(entry.getValue()); + } + } + + Use = new JComboBox(); + Use.setPreferredSize(new Dimension(260, 22)); + Use.addItem(""); + if (lovUse != null && lovUse.size() > 0) { + for(Entry entry: lovUse.entrySet()){ + Use.addItem(entry.getValue()); + } + } + + ProjectManager = new iTextField(); + ProjectManager.setEnabled(false); + ProjectManager.setPreferredSize(new Dimension(260, 22)); + JButton btnProjectManager = new JButton("..."); + btnProjectManager.setPreferredSize(new Dimension(24, 22)); + btnProjectManager.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + SelectUserDialog userSelect = new SelectUserDialog(session, "user"); + ProjectManager.setText(userSelect.getValue()); + } + }); + + Planner = new iTextField(); + Planner.setEnabled(false); + Planner.setPreferredSize(new Dimension(263, 22)); + JButton btnPlanner = new JButton("..."); + btnPlanner.setPreferredSize(new Dimension(24, 22)); + btnPlanner.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + SelectUserDialog userSelect = new SelectUserDialog(session, "user"); + Planner.setText(userSelect.getValue()); + } + }); + + DesignDirector = new iTextField(); + DesignDirector.setEnabled(false); + DesignDirector.setPreferredSize(new Dimension(260, 22)); + JButton btnDesignDirector = new JButton("..."); + btnDesignDirector.setPreferredSize(new Dimension(24, 22)); + btnDesignDirector.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + SelectUserDialog userSelect = new SelectUserDialog(session, "user"); + DesignDirector.setText(userSelect.getValue()); + } + }); + + ElectricDirector = new iTextField(); + ElectricDirector.setEnabled(false); + ElectricDirector.setPreferredSize(new Dimension(263, 22)); + JButton btnElectricDirector = new JButton("..."); + btnElectricDirector.setPreferredSize(new Dimension(24, 22)); + btnElectricDirector.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + SelectUserDialog userSelect = new SelectUserDialog(session, "user"); + ElectricDirector.setText(userSelect.getValue()); + } + }); + + ProjectLevel = new JComboBox(); + ProjectLevel.setPreferredSize(new Dimension(103, 22)); + ProjectLevel.addItem(""); + if (lovProjectLevel != null && lovProjectLevel.size() > 0) { + for(Entry entry: lovProjectLevel.entrySet()){ + ProjectLevel.addItem(entry.getValue()); + } + } + + MotomanQuantity = new iTextField(); + MotomanQuantity.setPreferredSize(new Dimension(263, 22)); + + MotomanType = new JTextArea(5, 115); + setTextAreaStyle(MotomanType, false); + JScrollPane MotomanTypePane = new JScrollPane(MotomanType); + MotomanTypePane.setPreferredSize(new Dimension(698,100)); + MotomanTypePane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); + + ProjectContent = new JTextArea(10, 115); + setTextAreaStyle(ProjectContent, false); + JScrollPane ProjectContentPane = new JScrollPane(ProjectContent); + ProjectContentPane.setPreferredSize(new Dimension(698,200)); + ProjectContentPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); + + Creator = new iTextField(); + Creator.setPreferredSize(new Dimension(147, 22)); + Creator.setEnabled(false); + + Reviewer = new iTextField(); + Reviewer.setPreferredSize(new Dimension(147, 22)); + Reviewer.setEnabled(false); + + Approver = new iTextField(); + Approver.setPreferredSize(new Dimension(147, 22)); + Approver.setEnabled(false); + + synchronization = new JButton("ͬ"); + synchronization.setPreferredSize(new Dimension(120, 22)); + synchronization.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + synchronizationPro(); + } + }); + + JPanel panel2_1 = new JPanel(); + panel2_1.setLayout(new PropertyLayout()); + panel2_1.add("1.1.left.center", new JLabel("ڡ")); + panel2_1.add("1.2.left.center", StartDate); + panel2_1.add("1.3.left.center", new JLabel("Ŀ𡡡")); + panel2_1.add("1.4.left.center", ProjectCategory); + + panel2_1.add("2.1.left.center", new JLabel("š")); + panel2_1.add("2.2.left.center", ProjectCode); + panel2_1.add("2.3.left.center", new JLabel("ίеš")); + panel2_1.add("2.4.left.center", QuotationNo); + + panel2_1.add("3.1.left.center", new JLabel("ǷĿ")); + panel2_1.add("3.2.left.center", ysr8_SFGL); + panel2_1.add("3.3.left.center", new JLabel(" Ŀ ")); + panel2_1.add("3.4.left.center", ysr8_GLProjectCode); + + panel2_1.add("4.1.left.center", new JLabel("ҡ")); + panel2_1.add("4.2.left.center", OrderManufacturer); + + panel2_1.add("5.1.left.center", new JLabel("ûơ")); + panel2_1.add("5.2.left.center", CustomerName); + + panel2_1.add("6.1.left.center", new JLabel("Ŀơ")); + panel2_1.add("6.2.left.center", ProjectName); + + panel2_1.add("7.1.left.center", new JLabel("ؼʱڵ㡡")); + panel2_1.add("7.2.left.center", CriticalDate); + panel2_1.add("7.3.left.center", new JLabel("ûơ")); + panel2_1.add("7.4.left.center", UserWorkpieceName); + + panel2_1.add("8.1.left.center", new JLabel("ؼڵ")); + panel2_1.add("8.2.left.center", CriticalDateDes); + + panel2_1.add("9.1.left.center", new JLabel("Ԥʱ䡡")); + panel2_1.add("9.2.left.center", ProductionDate); + panel2_1.add("9.3.left.center", new JLabel("Ԥʱ䡡")); + panel2_1.add("9.4.left.center", FinalAcceptance); + + panel2_1.add("10.1.left.center", new JLabel("۸ˡ")); + panel2_1.add("10.2.left.center", Sales); + panel2_1.add("10.3.left.center", new JLabel("")); + panel2_1.add("10.4.left.center", Factory); + panel2_1.add("10.5.left.center", new JLabel("Ʊ")); + panel2_1.add("10.6.left.center", Section); + + panel2_1.add("11.1.left.center", new JLabel("Ʒ")); + panel2_1.add("11.2.left.center", Product); + panel2_1.add("11.3.left.center", new JLabel(";")); + panel2_1.add("11.4.left.center", Use); + + panel2_1.add("12.1.left.center", new JLabel("Ŀ")); + panel2_1.add("12.2.left.center", ProjectManager); + panel2_1.add("12.3.left.center", btnProjectManager); + panel2_1.add("12.4.left.center", new JLabel(" ƻԱ")); + panel2_1.add("12.5.left.center", Planner); + panel2_1.add("12.6.left.center", btnPlanner); + + panel2_1.add("13.1.left.center", new JLabel("ܡ")); + panel2_1.add("13.2.left.center", DesignDirector); + panel2_1.add("13.3.left.center", btnDesignDirector); + panel2_1.add("13.4.left.center", new JLabel(" ܡ")); + panel2_1.add("13.5.left.center", ElectricDirector); + panel2_1.add("13.6.left.center", btnElectricDirector); + + panel2_1.add("14.1.left.center", new JLabel("Ŀȼ")); + panel2_1.add("14.2.left.center", ProjectLevel); + panel2_1.add("14.3.left.center", new JLabel("")); + panel2_1.add("14.4.left.center", MotomanQuantity); + + panel2_1.add("15.1.left.center", new JLabel("ͺš")); + //panel2_1.add("14.2.left.center", ProjectContent); + panel2_1.add("15.2.left.center", MotomanTypePane); + panel2_1.add("16.1.left.center", new JLabel("Ŀݡ")); + //panel2_1.add("14.2.left.center", ProjectContent); + panel2_1.add("16.2.left.center", ProjectContentPane); + + panel2_1.add("17.1.left.center", new JLabel("ɡ")); + panel2_1.add("17.2.left.center", Creator); + panel2_1.add("17.3.left.center", new JLabel("ˡ")); + panel2_1.add("17.4.left.center", Reviewer); + panel2_1.add("17.5.left.center", new JLabel("׼")); + panel2_1.add("17.6.left.center", Approver); + panel2_1.add("17.7.left.center", new JLabel("")); + panel2_1.add("17.8.left.center", synchronization); + + panel2.add("1.1.left.center", new JLabel("")); + panel2.add("2.1.left.center", panel2_1); + panel2.add("3.1.left.center", new JLabel("")); + + ///////////////////////////////////////////////////////// + JPanel panel = new JPanel(); + panel.setLayout(new PropertyLayout()); + panel.add("1.1.left.center", new JLabel("")); + panel.add("1.2.left.center", new JLabel("ţJL-8.3-02")); + panel.add("2.1.left.center", new JLabel("")); + panel.add("2.2.left.center", panel1); + panel.add("3.1.left.center", new JLabel("")); + panel.add("3.2.left.center", panel2); + + JScrollPane returnPanel = new JScrollPane(); + returnPanel.setViewportView(panel); + return returnPanel; + } + + void ChangeComboBoxState_ProjectCategory() { + if (ProjectCategory.getSelectedItem().toString().equals("") || + ProjectCategory.getSelectedItem().toString().equals("ϵͳ1")) { + ProductionDate.setEnabled(false); + ProductionDate.setDate(""); + } else { + ProductionDate.setEnabled(true); + } + } + + void synchronizationPro() { + String value = StartType.getSelectedItem().toString(); + if (value.equals("")) { + MessageBox.post("ѡ...", "ʾ", MessageBox.INFORMATION); + return; + } + String lovKey = ""; + Iterator iter = lovStartType.keySet().iterator(); + while (iter.hasNext()) { + lovKey = iter.next(); + String lovValue = lovStartType.get(lovKey); + if (lovValue.equals(value)) { + break; + } + } +// if (lovKey.equals("1")) { + + try { + String ProjectCodeVal = ProjectCode.getText().toString(); + + Vector attrVec = new Vector(); + Vector valVec = new Vector(); + attrVec.add("ysr8_ProjectCode"); + valVec.add(ProjectCodeVal); + String[] attrs = (String[]) attrVec.toArray(new String[attrVec.size()]); + String[] vals = (String[]) valVec.toArray(new String[attrVec.size()]); + TCComponent[] tcComponents = TCUtil.query(session, "SearchSaleOrder", attrs, vals); + if (tcComponents != null && tcComponents.length > 0) { + TCComponentItemRevision soRevision = (TCComponentItemRevision)tcComponents[0]; + TCComponentForm soForm = TCUtil.getItemRevisionMasterForm(soRevision); + System.out.println("11111111111111111111111111"); + List propList = new ArrayList(); + propList.add("ysr8_SystemType"); + propList.add("ysr8_OrderManufacturer"); + propList.add("ysr8_CustomerName"); + propList.add("ysr8_Sales"); + propList.add("ysr8_ProjectManager"); + propList.add("ysr8_Planner"); + propList.add("ysr8_ApproverDate"); + //ǷĿysr8_SFGL + propList.add("ysr8_SFGL"); + //Ŀ ȥ鱨ίе + propList.add("ysr8_GLProjectCode"); + //Ŀ + propList.add("ysr8_QuotationNo"); + propList.add("ysr8_RobotNum"); + HashMap propValueMap = new HashMap(); + for (String prop : propList) { + String propValue = ""; + TCFormProperty property1 = (TCFormProperty)soForm.getFormTCProperty(prop); + switch (property1.getPropertyType()) { + case TCProperty.PROP_string: + case TCProperty.PROP_long_string: + propValue = soForm.getStringProperty(prop); + break; + case TCProperty.PROP_short: + case TCProperty.PROP_int: + propValue = Integer.toString(soForm.getIntProperty(prop)); + break; + case TCProperty.PROP_double: + case TCProperty.PROP_float: + propValue = fu.getDoubleString(soForm.getDoubleProperty(prop)); + break; + case TCProperty.PROP_date: + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date date = soForm.getDateProperty(prop); + if (date != null) { + propValue = sdf.format(date); + } + break; + default: + propValue = soForm.getStringProperty(prop); + break; + } + //⴦ysr8_RobotNum + if(prop.equals("ysr8_RobotNum")) { + propValueMap.put("ysr8_MotomanQuantity", propValue); + }else { + propValueMap.put(prop, propValue); + } + + for (Entry map : propValueMap.entrySet()) { + System.out.println(map.getKey()+":"+map.getValue()); + } + } + + + + Iterator iter1 = lovOriginateDept.keySet().iterator(); + while (iter1.hasNext()) { + String lovKey1 = iter1.next(); + String lovValue1 = lovOriginateDept.get(lovKey1); + if (lovKey1.equals("1")) { + OriginateDept.setSelectedItem(lovValue1); + break; + } + } + Iterator iter2 = lovStartType.keySet().iterator(); + while (iter2.hasNext()) { + String lovKey2 = iter2.next(); + String lovValue2 = lovStartType.get(lovKey2); + if (lovKey2.equals("1")) { + StartType.setSelectedItem(lovValue2); + break; + } + } + Iterator iter3 = lovProjectCategory.keySet().iterator(); + while (iter3.hasNext()) { + String lovKey3 = iter3.next(); + String lovValue3 = lovProjectCategory.get(lovKey3); + if (propValueMap.get("ysr8_SystemType").equals(lovKey3)) { + ProjectCategory.setSelectedItem(lovValue3); + break; + } + } + + OrderManufacturer.setText(propValueMap.get("ysr8_OrderManufacturer")); + CustomerName.setText(propValueMap.get("ysr8_CustomerName")); + Sales.setText(propValueMap.get("ysr8_Sales")); + ProjectManager.setText(propValueMap.get("ysr8_ProjectManager")); + Planner.setText(propValueMap.get("ysr8_Planner")); + ReceiveDate.setText(propValueMap.get("ysr8_ApproverDate")); + //Ŀ + ysr8_GLProjectCode.setText(propValueMap.get("ysr8_GLProjectCode")); + MotomanQuantity.setText(propValueMap.get("ysr8_MotomanQuantity")); + QuotationNo.setText(propValueMap.get("ysr8_QuotationNo")); + //ǷĿ + ysr8_SFGL.setText(propValueMap.get("ysr8_SFGL")); + } else { + System.out.println("222222222222222222222222"); + Vector attrVec2 = new Vector(); + Vector valVec2 = new Vector(); + attrVec2.add("ysr8_ProjectCode"); + valVec2.add(ProjectCodeVal); + String[] attrs2 = (String[]) attrVec2.toArray(new String[attrVec2.size()]); + String[] vals2 = (String[]) valVec2.toArray(new String[attrVec2.size()]); + TCComponent[] tcComponents2 = TCUtil.query(session, "SearchSaleProject", attrs2, vals2); + if (tcComponents2 != null && tcComponents2.length > 0) { + TCComponentForm newSpForm = null; + Date dtForm = null; + for (int i = 0; i < tcComponents2.length; i++) { + TCComponentItemRevision spRevision = (TCComponentItemRevision)tcComponents2[i]; + TCComponentForm spForm = TCUtil.getItemRevisionMasterForm(spRevision); + if (dtForm == null) { + dtForm = spForm.getDateProperty("creation_date"); + newSpForm = spForm; + } else { + if (spForm.getDateProperty("creation_date").after(dtForm)) { + dtForm = spForm.getDateProperty("creation_date"); + newSpForm = spForm; + } + } + } + List propList = new ArrayList(); + propList.add("ysr8_ProjectCategory"); + propList.add("ysr8_OrderManufacturer"); + propList.add("ysr8_CustomerName"); + propList.add("ysr8_Sales"); + propList.add("ysr8_ProjectManager"); + propList.add("ysr8_Planner"); + propList.add("ysr8_ProjectName"); + propList.add("ysr8_ProjectContent"); + //ǷĿysr8_SFGL + propList.add("ysr8_SFGL"); + //Ŀ ȥ鱨ίе + propList.add("ysr8_GLProjectCode"); + //Ŀ + propList.add("ysr8_QuotationNo"); + + HashMap propValueMap = new HashMap(); + for (String prop : propList) { + String propValue = ""; + TCFormProperty property1 = (TCFormProperty)newSpForm.getFormTCProperty(prop); + switch (property1.getPropertyType()) { + case TCProperty.PROP_string: + case TCProperty.PROP_long_string: + propValue = newSpForm.getStringProperty(prop); + break; + case TCProperty.PROP_short: + case TCProperty.PROP_int: + propValue = Integer.toString(newSpForm.getIntProperty(prop)); + break; + case TCProperty.PROP_double: + case TCProperty.PROP_float: + propValue = fu.getDoubleString(newSpForm.getDoubleProperty(prop)); + break; + case TCProperty.PROP_date: + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date date = newSpForm.getDateProperty(prop); + if (date != null) { + propValue = sdf.format(date); + } + break; + default: + propValue = newSpForm.getStringProperty(prop); + break; + } + propValueMap.put(prop, propValue); + for (Entry map : propValueMap.entrySet()) { + System.out.println(map.getKey()+":"+map.getValue()); + } + } + + Iterator iter1 = lovOriginateDept.keySet().iterator(); + while (iter1.hasNext()) { + String lovKey1 = iter1.next(); + String lovValue1 = lovOriginateDept.get(lovKey1); + if (lovKey1.equals("1")) { + OriginateDept.setSelectedItem(lovValue1); + break; + } + } + Iterator iter2 = lovStartType.keySet().iterator(); + while (iter2.hasNext()) { + String lovKey2 = iter2.next(); + String lovValue2 = lovStartType.get(lovKey2); + if (lovKey2.equals("2")) { + StartType.setSelectedItem(lovValue2); + break; + } + } + Iterator iter3 = lovProjectCategory.keySet().iterator(); + while (iter3.hasNext()) { + String lovKey3 = iter3.next(); + String lovValue3 = lovProjectCategory.get(lovKey3); + if (propValueMap.get("ysr8_ProjectCategory").equals(lovKey3)) { + ProjectCategory.setSelectedItem(lovValue3); + break; + } + } + + OrderManufacturer.setText(propValueMap.get("ysr8_OrderManufacturer")); + CustomerName.setText(propValueMap.get("ysr8_CustomerName")); + Sales.setText(propValueMap.get("ysr8_Sales")); + ProjectManager.setText(propValueMap.get("ysr8_ProjectManager")); + Planner.setText(propValueMap.get("ysr8_Planner")); + ProjectName.setText(propValueMap.get("ysr8_ProjectName")); + ProjectContent.setText(propValueMap.get("ysr8_ProjectContent")); + //ǷĿ + ysr8_SFGL.setText(propValueMap.get("ysr8_SFGL")); + //Ŀţysr8_GLProjectCode Ŀ(YSR8_SaleProjectRevisionMaster)ȡ + //ίеţysr8_QuotationNo Ӷ֪ͨYSR8_SaleOrderRevisionMasterĿϻȡĸлȡǸУԶ֪ͨΪ׼ + if(!(ysr8_GLProjectCode.getText().length() > 0)) {//жǷֵ + ysr8_GLProjectCode.setText(propValueMap.get("ysr8_GLProjectCode")); + } + QuotationNo.setText(propValueMap.get("ysr8_QuotationNo")); + MotomanQuantity.setText(propValueMap.get("ysr8_MotomanQuantity")); + ReceiveDate.setText(propValueMap.get("ysr8_ApproverDate")); + } else { + MessageBox.post("δѯ۲֪ͨĿ֪ͨ...", "ʾ", MessageBox.INFORMATION); + } + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + private JScrollPane getProjectManInfoPanel() { + JPanel panel = new JPanel(new PropertyLayout()); + /////////////////////////////// + columnNames = new String[]{"Ŀɫ","֯ɫ","ĿԱ()"}; + dataTableModel = new DefaultTableModel(columnNames, 0); + tblProjectMembers = new JTable(dataTableModel){ + private static final long serialVersionUID = 1L; + public boolean isCellEditable(int row, int col) { + return false; + } + }; + tblProjectMembers.getTableHeader().setReorderingAllowed(false); + tblProjectMembers.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + tblProjectMembers.setAutoscrolls(true); + tblProjectMembers.setShowGrid(true); + TableColumnModel columns = tblProjectMembers.getColumnModel(); + TableColumn column0 = columns.getColumn(0); + column0.setPreferredWidth(150); + TableColumn column1 = columns.getColumn(1); + column1.setPreferredWidth(448); + TableColumn column2 = columns.getColumn(2); + column2.setPreferredWidth(200); + + JScrollPane panel1 = new JScrollPane(tblProjectMembers); + panel1.setAutoscrolls(true); + //panel1.getViewport().setBackground(Color.white); + panel1.setPreferredSize(new Dimension(800, 600)); + panel.add("1.1.left.center", panel1); + /////////////////////////////// + JScrollPane returnPanel = new JScrollPane(); + returnPanel.setViewportView(panel); + return returnPanel; + } + + @SuppressWarnings("unchecked") + @Override + public void loadRendering() throws TCException { +System.out.println("loadForm------------------------start"); + try { + // ProjectInfo + final String[] currProjectCode = new String[1]; + this.formProperties = tcForm.getAllFormProperties(); + int length = this.formProperties.length; + for (int k = 0; k < length; ++k) { + String propName = this.formProperties[k].getPropertyName().trim(); + for (int i = 0; i < allComponents.size(); i++) { + Component component = allComponents.get(i); + String name = component.getName().trim(); + if (propName.equalsIgnoreCase(name)) { + if (component instanceof iTextField) { + iTextField textField = (iTextField) component; + String propValue = this.formProperties[k].getStringValue(); + if (propValue.equals("") && name.equalsIgnoreCase("ysr8_Creator")) { + textField.setText(session.getUser().getRelatedComponent("person").getProperty("user_name")); + } else if (propValue.equals("") && name.equalsIgnoreCase("ysr8_ProjectCode")) { + try { + AIFComponentContext[] context = tcForm.whereReferencedByTypeRelation(new String[] {"YSR8_ProjectSRevision"}, new String[] {"IMAN_master_form"}); + if (context != null && context.length > 0) { + TCComponentItemRevision itemRevision = (TCComponentItemRevision)context[0].getComponent(); + String itemId = itemRevision.getProperty("item_id"); + Vector itemIdParts = CommonUtil.split2Vector(itemId, "_"); + if (itemIdParts.size() > 0) { + textField.setText(itemIdParts.get(0)); + } + + } + } catch (TCException e1) { + e1.printStackTrace(); + } + } else { + textField.setText(propValue); + } + indices.put(formProperties[k], textField); + if (propName.equalsIgnoreCase("ysr8_ProjectCode")) { + currProjectCode[0] = propValue; + } + break; + } else if (component instanceof JCheckBox) { + JCheckBox ckBt = (JCheckBox) component; + ckBt.setSelected((Boolean)this.formProperties[k].getLogicalValue2()); + indices.put(formProperties[k], ckBt); + break; + } else if (component instanceof JTextArea) { + JTextArea textArea = (JTextArea) component; + String propValue = this.formProperties[k].getStringValue(); + textArea.setText(propValue); + indices.put(formProperties[k], textArea); + break; + } else if (component instanceof JComboBox) { + JComboBox combox = (JComboBox) component; + String propValue = this.formProperties[k].getStringValue(); + if (propValue != null && !propValue.equals("")) { + if (propName.equalsIgnoreCase("ysr8_OriginateDept")) { + combox.setSelectedItem(lovOriginateDept.get(propValue)); + } else if (propName.equalsIgnoreCase("ysr8_StartType")) { + combox.setSelectedItem(lovStartType.get(propValue)); + } else if (propName.equalsIgnoreCase("ysr8_Product")) { + combox.setSelectedItem(lovProduct.get(propValue)); + } else if (propName.equalsIgnoreCase("ysr8_Use")) { + combox.setSelectedItem(lovUse.get(propValue)); + } else if (propName.equalsIgnoreCase("ysr8_ProjectLevel")) { + combox.setSelectedItem(lovProjectLevel.get(propValue)); + } else if (propName.equalsIgnoreCase("ysr8_ProjectCategory")) { + combox.setSelectedItem(lovProjectCategory.get(propValue)); + } else { + combox.setSelectedItem(propValue); + } + } + indices.put(formProperties[k], combox); + break; + } else if (component instanceof DateButton) { + DateButton btn = (DateButton) component; + if (!this.formProperties[k].isPropValueNull()) { + btn.setDate(this.formProperties[k].getDateValue()); + } + indices.put(formProperties[k], btn); + break; + } + } + } + } + + // ProjectManInfo + if (!currProjectCode[0].equals("")) { + //currProjectCode[0] = currProjectCode[0].substring(0, currProjectCode[0].indexOf("_")); + new Thread() { + public void run() { + projectVector.clear(); + for (int i = dataTableModel.getDataVector().size()-1; i>-1; i--) { + dataTableModel.removeRow(i); + } + try { + TCComponentQueryType querytype; + try { + TCTextService textService = RACUIUtil.getTCSession().getTextService(); + + querytype = (TCComponentQueryType) RACUIUtil.getTCSession().getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) querytype.find("ProjectSearchByID"); + if(null == query){ + MessageBox.post("ʹòѯѯProjectSearchByID!", "ʾ", MessageBox.INFORMATION); + return; + } + querytype.clearCache(); + + Vector vtKey = new Vector(); + Map hmkey = new HashMap(); + + vtKey.add(textService.getTextValue("project_id")); + hmkey.put(textService.getTextValue("project_id"), currProjectCode[0]); + + int size = vtKey.size(); + String []attr = new String[size]; + String []values = new String[size]; + for(int i = 0 ; i< vtKey.size(); i++){ + attr[i] = vtKey.get(i); + values[i] = hmkey.get(attr[i]); + } + + TCComponentContextList list = query.getExecuteResultsList(attr, values); + if (list != null && list.getListCount() > 0) { + TCComponentProject projectComp = (TCComponentProject)list.get(0).getComponent(); + if (projectComp != null) { + List oldvtUser = projectComp.getTeam(); + Vector vtProjectAdmin = new Vector(); + Vector vtProjectMembers = new Vector(); + HashMap hmUserRole = new HashMap(); + //System.out.println( Integer.toString(oldvtUser.size())); + //System.out.println( oldvtUser.get(0).getClass().getName()); + //System.out.println( oldvtUser.get(1).getClass().getName()); + //System.out.println( oldvtUser.get(2).getClass().getName()); + TCComponent[] teamMembers = (TCComponent[]) oldvtUser.get(0); + TCComponentUser[] teamAdmins = (TCComponentUser[]) oldvtUser.get(1); + + for (int j = 0; j < teamAdmins.length; j++) { + TCComponent compUser = teamAdmins[j]; + //System.out.println("1compUser = " + compUser); + TCComponentUser user = null; + if (compUser instanceof TCComponentGroupMember) { + TCComponentGroupMember tmpGroupMember = (TCComponentGroupMember) compUser; + try { + user = tmpGroupMember.getUser(); + } catch (TCException e) { + e.printStackTrace(); + } + if (vtProjectAdmin.contains(user)) { + continue; + } + vtProjectAdmin.add(user); + hmUserRole.put(user, compUser.toString()); + }else if(compUser instanceof TCComponentGroup){ + TCComponentGroup group = (TCComponentGroup)compUser; + getGroup(group, false, vtProjectAdmin, hmUserRole); + }else if (compUser instanceof TCComponentUser){ + user = (TCComponentUser) compUser; + if (vtProjectAdmin.contains(user)) { + continue; + } + vtProjectAdmin.add(user); + hmUserRole.put(user, compUser.toString()); + } + } + + for (int j = 0; j < teamMembers.length; j++) { + TCComponent compUser = teamMembers[j]; + //System.out.println("2compUser = " + compUser); + TCComponentUser user = null; + if (compUser instanceof TCComponentGroupMember) { + TCComponentGroupMember tmpGroupMember = (TCComponentGroupMember) compUser; + try { + user = tmpGroupMember.getUser(); + } catch (TCException e) { + e.printStackTrace(); + } + if (vtProjectMembers.contains(user)) { + continue; + } + vtProjectMembers.add(user); + hmUserRole.put(user, compUser.toString()); + }else if(compUser instanceof TCComponentGroup){ + TCComponentGroup group = (TCComponentGroup)compUser; + getGroup(group, false, vtProjectMembers, hmUserRole); + }else if (compUser instanceof TCComponentUser){ + user = (TCComponentUser) compUser; + if (vtProjectMembers.contains(user)) { + continue; + } + vtProjectMembers.add(user); + hmUserRole.put(user, compUser.toString()); + } + } + + Object[] objData; + for (int i = 0; vtProjectAdmin != null && i < vtProjectAdmin.size(); i++) { + TCComponentUser user = vtProjectAdmin.get(i); + //System.out.println("user1 = " + user); + String strRoleName = "Ŀ"; + String strGroupName = hmUserRole.get(user); + if(strGroupName == null){ + continue; + } + //System.out.println("i = " + i + ":: strGroupName = " + strGroupName); + strGroupName = strGroupName.substring(0, strGroupName.lastIndexOf("/")); + strGroupName = strGroupName.replace(".", "/"); + + String strUserName = user.getProperty("user_name"); + + objData = new Object[] { strRoleName, strGroupName, strUserName }; + dataTableModel.addRow(objData); + } + + for (int i = 0; vtProjectMembers != null && i < vtProjectMembers.size(); i++) { + TCComponentUser user = vtProjectMembers.get(i); + //System.out.println("user2 = " + user); + if (vtProjectAdmin.contains(user)) { + continue; + } + String strRoleName = "ĿԱ"; + String strGroupName = hmUserRole.get(user); + if(strGroupName == null){ + continue; + } + //System.out.println("i = " + i + ":: strGroupName = " + strGroupName); + strGroupName = strGroupName.substring(0, strGroupName.lastIndexOf("/")); + strGroupName = strGroupName.replace(".", "/"); + + String strUserName = user.getProperty("user_name"); + + objData = new Object[] { strRoleName, strGroupName, strUserName }; + dataTableModel.addRow(objData); + } + } + } + } catch (TCException e) { + e.printStackTrace(); + } + } catch (Exception imanexception) { + throw imanexception; + } + } + }.start(); + } + } + catch (TCException imanexception) { + throw imanexception; + } + if (this.formProperties == null) { + Registry registry = Registry.getRegistry(this); + throw new TCException(registry.getString("failedLoadingFormProperties")); + } +//System.out.println("loadForm----------------------end"); + } + + /** + * getGroup::õUser + * @param TCComponentGroup group + * */ + private void getGroup(TCComponentGroup group, boolean isAdmin, Vector vtProjectMembers, HashMap hmUserRole){ + try { + TCComponent[] comprolegroup = group.getRolesAndGroups(); + for(int i = 0; i < comprolegroup.length ; i++){ + TCComponent tccomponent = comprolegroup[i]; + if(tccomponent instanceof TCComponentRole) + { + getRole((TCComponentRole)tccomponent, group, isAdmin, vtProjectMembers, hmUserRole); + continue; + } + if(tccomponent instanceof TCComponentGroup){ + getGroup((TCComponentGroup)tccomponent, isAdmin, vtProjectMembers, hmUserRole); + } + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + /** + * getRole::roleõUser + * @param TCComponentRole + * @param TCComponentGroup + * */ + private void getRole(TCComponentRole tccomponentrole, TCComponentGroup tccomponentgroup, boolean isAdmin, Vector vtProjectMembers, HashMap hmUserRole){ + try { + TCComponentGroupMember atccomponentgroupmember[] = tccomponentrole.getGroupMembers(tccomponentgroup); + for(int i = 0; i < atccomponentgroupmember.length ;i++){ + TCComponentUser user = atccomponentgroupmember[i].getUser(); + + if(!isAdmin){ + if (vtProjectMembers.contains(user)) { + continue; + } + vtProjectMembers.add(user); + } + hmUserRole.put(user, atccomponentgroupmember[i].toString()); + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + public void setRenderingReadOnly() + { + setModifiableComponents(this, false); + if(getController() != null) + getController().setFormReadOnly(); + } + + public void setRenderingReadWrite() + { + setModifiableComponents(this, true); + + ChangeComboBoxState_ProjectCategory(); + } + + private void setModifiableComponents(java.awt.Component currcomponent, boolean flag) + { + fu.setModifiableComponents(currcomponent, flag); + } + + /** + * (non-Javadoc) + * @see com.teamcenter.rac.form.AbstractTCForm#saveForm() + */ + @SuppressWarnings("unchecked") + @Override + public void saveRendering() { +System.out.println("saveForm------------------------start"); + Enumeration enumeration = this.indices.keys(); + Enumeration enumeration1 = this.indices.elements(); + TCFormProperty[] aimanformproperty = new TCFormProperty[this.indices.size()]; + for (int i = 0; enumeration.hasMoreElements(); i++) { + TCFormProperty imanformproperty = (TCFormProperty) enumeration.nextElement(); + Object component = enumeration1.nextElement(); + if (component instanceof iTextField) { + setStringToPropertyValue(imanformproperty, ((iTextField) component).getText().toString()); + } else if (component instanceof JTextArea) { + setStringToPropertyValue(imanformproperty, ((JTextArea) component).getText().toString()); + } else if (component instanceof JComboBox) { + JComboBox combox = (JComboBox) component; + String name = combox.getName().trim(); + String value = combox.getSelectedItem().toString(); + if (name.equalsIgnoreCase("ysr8_OriginateDept")) { + Iterator iter = lovOriginateDept.keySet().iterator(); + while (iter.hasNext()) { + String lovKey = iter.next(); + String lovValue = lovOriginateDept.get(lovKey); + if (lovValue.equals(value)) { + setStringToPropertyValue(imanformproperty, lovKey); + break; + } + } + } else if (name.equalsIgnoreCase("ysr8_StartType")) { + Iterator iter = lovStartType.keySet().iterator(); + while (iter.hasNext()) { + String lovKey = iter.next(); + String lovValue = lovStartType.get(lovKey); + if (lovValue.equals(value)) { + setStringToPropertyValue(imanformproperty, lovKey); + break; + } + } + } else if (name.equalsIgnoreCase("ysr8_Product")) { + Iterator iter = lovProduct.keySet().iterator(); + while (iter.hasNext()) { + String lovKey = iter.next(); + String lovValue = lovProduct.get(lovKey); + if (lovValue.equals(value)) { + setStringToPropertyValue(imanformproperty, lovKey); + break; + } + } + } else if (name.equalsIgnoreCase("ysr8_Use")) { + Iterator iter = lovUse.keySet().iterator(); + while (iter.hasNext()) { + String lovKey = iter.next(); + String lovValue = lovUse.get(lovKey); + if (lovValue.equals(value)) { + setStringToPropertyValue(imanformproperty, lovKey); + break; + } + } + } else if (name.equalsIgnoreCase("ysr8_ProjectLevel")) { + Iterator iter = lovProjectLevel.keySet().iterator(); + while (iter.hasNext()) { + String lovKey = iter.next(); + String lovValue = lovProjectLevel.get(lovKey); + if (lovValue.equals(value)) { + setStringToPropertyValue(imanformproperty, lovKey); + break; + } + } + } else if (name.equalsIgnoreCase("ysr8_ProjectCategory")) { + Iterator iter = lovProjectCategory.keySet().iterator(); + while (iter.hasNext()) { + String lovKey = iter.next(); + String lovValue = lovProjectCategory.get(lovKey); + if (lovValue.equals(value)) { + setStringToPropertyValue(imanformproperty, lovKey); + break; + } + } + } else if (name.equalsIgnoreCase("ysr8_Factory")) { + setStringToPropertyValue(imanformproperty, ((JTextField)combox.getEditor().getEditorComponent()).getText()); + } else { + setStringToPropertyValue(imanformproperty, value); + } + } else if (component instanceof DateButton) { + Date date = ((DateButton)component).getDate(); + if (date == null) { + imanformproperty.setPropValueNull(true); + } else { + imanformproperty.setDateValueData(date); + } + } + aimanformproperty[i] = imanformproperty; + } + try { + tcForm.setTCProperties(aimanformproperty); + } + catch (Exception exception) { + exception.printStackTrace(); + MessageBox.post(exception); + } +System.out.println("saveForm------------------------end"); + } + + @SuppressWarnings("unchecked") + public boolean isRenderingModified() { +// if (isReadOnly) { +//System.out.println("isRenderingModified------------------------false1"); +// return false; +// } + Enumeration enumeration = this.indices.keys(); + Enumeration enumeration1 = this.indices.elements(); + try { + for (; enumeration.hasMoreElements();) { + TCFormProperty imanformproperty = (TCFormProperty) enumeration.nextElement(); + Object component = enumeration1.nextElement(); + if (component instanceof iTextField) { + String strTempValue = ((iTextField) component).getText().toString(); + if(!imanformproperty.getStringValue().equals(strTempValue)){ + System.out.println("isRenderingModified------------------------" + imanformproperty.getName()); + return true; + } + } else if (component instanceof JTextArea) { + String strTempValue = ((JTextArea) component).getText().toString(); + if(!imanformproperty.getStringValue().equals(strTempValue)){ + System.out.println("isRenderingModified------------------------" + imanformproperty.getName()); + return true; + } + } else if (component instanceof DateButton) { + if(!fu.getDateString(imanformproperty.getDateValue()).equals(fu.getDateString(((DateButton)component).getDate()))) { + System.out.println("isRenderingModified------------------------" + imanformproperty.getName()); + return true; + } + } else if (component instanceof JComboBox) { + JComboBox combox = (JComboBox) component; + String strTempValue = combox.getSelectedItem().toString(); + String name = combox.getName().trim(); + String value = combox.getSelectedItem().toString(); + if (name.equalsIgnoreCase("ysr8_OriginateDept")) { + Iterator iter = lovOriginateDept.keySet().iterator(); + while (iter.hasNext()) { + String lovKey = iter.next(); + String lovValue = lovOriginateDept.get(lovKey); + if (lovValue.equals(value)) { + strTempValue = lovKey; + break; + } + } + } else if (name.equalsIgnoreCase("ysr8_StartType")) { + Iterator iter = lovStartType.keySet().iterator(); + while (iter.hasNext()) { + String lovKey = iter.next(); + String lovValue = lovStartType.get(lovKey); + if (lovValue.equals(value)) { + strTempValue = lovKey; + break; + } + } + } else if (name.equalsIgnoreCase("ysr8_Product")) { + Iterator iter = lovProduct.keySet().iterator(); + while (iter.hasNext()) { + String lovKey = iter.next(); + String lovValue = lovProduct.get(lovKey); + if (lovValue.equals(value)) { + strTempValue = lovKey; + break; + } + } + } else if (name.equalsIgnoreCase("ysr8_Use")) { + Iterator iter = lovUse.keySet().iterator(); + while (iter.hasNext()) { + String lovKey = iter.next(); + String lovValue = lovUse.get(lovKey); + if (lovValue.equals(value)) { + strTempValue = lovKey; + break; + } + } + } else if (name.equalsIgnoreCase("ysr8_ProjectLevel")) { + Iterator iter = lovProjectLevel.keySet().iterator(); + while (iter.hasNext()) { + String lovKey = iter.next(); + String lovValue = lovProjectLevel.get(lovKey); + if (lovValue.equals(value)) { + strTempValue = lovKey; + break; + } + } + } else if (name.equalsIgnoreCase("ysr8_ProjectCategory")) { + Iterator iter = lovProjectCategory.keySet().iterator(); + while (iter.hasNext()) { + String lovKey = iter.next(); + String lovValue = lovProjectCategory.get(lovKey); + if (lovValue.equals(value)) { + strTempValue = lovKey; + break; + } + } + } + if(!imanformproperty.getStringValue().equals(strTempValue)){ + System.out.println("isRenderingModified------------------------" + imanformproperty.getName()); + return true; + } + } + } + } + catch (Exception imane) { + imane.printStackTrace(); + } + return false; + } +} diff --git a/src/cn/com/ebewin/ysr/form/YSR8_ProjectSimRevisionMasterForm.java b/src/cn/com/ebewin/ysr/form/YSR8_ProjectSimRevisionMasterForm.java new file mode 100644 index 0000000..b7d48ff --- /dev/null +++ b/src/cn/com/ebewin/ysr/form/YSR8_ProjectSimRevisionMasterForm.java @@ -0,0 +1,897 @@ +package cn.com.ebewin.ysr.form; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.text.ParseException; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.Vector; + +import javax.swing.JButton; +import javax.swing.JTextArea; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.commands.open.OpenFormDialog; +import com.teamcenter.rac.kernel.TCComponentContextList; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCTextService; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.ui.common.RACUIUtil; +import com.teamcenter.rac.util.MessageBox; +import cn.com.ebewin.ysr.util.UIUtil.ComponentInfo; +import cn.com.ebewin.ysr.util.UIUtil.JComboBoxInfo; +import cn.com.ebewin.ysr.util.UIUtil.JTextAreaInfo; +import cn.com.ebewin.ysr.util.FormUtil; + +public class YSR8_ProjectSimRevisionMasterForm extends AbstractRendering { + private static final long serialVersionUID = 1L; + private static Date refreshDate = null; + + FormUtil fu = new FormUtil(this); + + public YSR8_ProjectSimRevisionMasterForm(TCComponentForm arg0) throws Exception { + super(arg0); + + Date currDate = new Date(); + if (refreshDate == null) { + arg0.refresh(); + refreshDate = currDate; + } else { + long diff = currDate.getTime() - refreshDate.getTime(); + long minutes = diff / 1000 / 60; + if ( minutes >= 1 ) { + arg0.refresh(); + refreshDate = currDate; + } + } + + //////////////////////////////////////////// + ComponentInfo ci = fu.new ComponentInfo(); + ci.name = "sp"; + ci.type = "JScrollPane"; + ci.row = 0; + ci.col = 0; + fu.firstComponentInfo = ci; + fu.allComponentInfos.put(ci.name, ci); + ComponentInfo cisp = ci; + + ci = fu.new ComponentInfo(); + ci.name = "p"; + ci.type = "JPanel"; + ci.row = 0; + ci.col = 0; + fu.allComponentInfos.put(ci.name, ci); + cisp.childComponentInfos.add(ci); + ComponentInfo cip = ci; + //////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "p11"; + ci.type = "JPanel"; + ci.row = 1; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip.childComponentInfos.add(ci); + ComponentInfo cip11 = ci; + + ci = fu.new ComponentInfo(); + ci.name = "kl111111"; + ci.type = "JLabel"; + ci.title = "ţJL-8.3-27"; + ci.row = 1; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip11.childComponentInfos.add(ci); + + //////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "p1111"; + ci.type = "JPanel"; + ci.row = 2; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip11.childComponentInfos.add(ci); + ComponentInfo cip1111 = ci; + //////////////////////////////////////////// + /*ci = fu.new ComponentInfo(); + ci.name = "l111111"; + ci.type = "JLabel"; + ci.title = ""; + ci.row = 1; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip1111.childComponentInfos.add(ci);*/ + + ci = fu.new ComponentInfo(); + ci.name = "l111121"; + ci.type = "JLabel"; + ci.title = "Ŀš"; + ci.row = 1; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip1111.childComponentInfos.add(ci); + + ci = fu.new iTextFieldInfo(); + ci.name = "ysr8_ProjectCode"; + ci.type = "iTextField"; + ci.row = 1; + ci.col = 2; + ci.isProComponent = true; + fu.allComponentInfos.put(ci.name, ci); + cip1111.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l111123"; + ci.type = "JLabel"; + ci.title = "ͻơ"; + ci.row = 1; + ci.col = 3; + fu.allComponentInfos.put(ci.name, ci); + cip1111.childComponentInfos.add(ci); + + ci = fu.new iTextFieldInfo(); + ci.name = "ysr8_CustomerName"; + ci.type = "iTextField"; + ci.row = 1; + ci.col = 4; + ci.isProComponent = true; + fu.allComponentInfos.put(ci.name, ci); + cip1111.childComponentInfos.add(ci); + //////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "l111131"; + ci.type = "JLabel"; + ci.title = "Ŀơ"; + ci.row = 2; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip1111.childComponentInfos.add(ci); + + ci = fu.new iTextFieldInfo(); + ci.name = "ysr8_ProjectName"; + ci.type = "iTextField"; + ci.row = 2; + ci.col = 2; + ci.isProComponent = true; + fu.allComponentInfos.put(ci.name, ci); + cip1111.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l111133"; + ci.type = "JLabel"; + ci.title = "ܡ"; + ci.row = 2; + ci.col = 3; + fu.allComponentInfos.put(ci.name, ci); + cip1111.childComponentInfos.add(ci); + + ci = fu.new iTextFieldInfo(); + ci.name = "ysr8_DesignDirector"; + ci.type = "iTextField"; + ci.row = 2; + ci.col = 4; + ci.isProComponent = true; + fu.allComponentInfos.put(ci.name, ci); + cip1111.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l111141"; + ci.type = "JLabel"; + ci.title = "Ŀ"; + ci.row = 3; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip1111.childComponentInfos.add(ci); + + ci = fu.new iTextFieldInfo(); + ci.name = "ysr8_ProjectManager"; + ci.type = "iTextField"; + ci.row = 3; + ci.col = 2; + ci.isProComponent = true; + fu.allComponentInfos.put(ci.name, ci); + cip1111.childComponentInfos.add(ci); + //////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "p1121"; + ci.type = "JPanel"; + ci.row = 3; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip11.childComponentInfos.add(ci); + ComponentInfo cip1121 = ci; + //////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "l112111"; + ci.type = "JLabel"; + ci.title = "Ŀ"; + ci.row = 1; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip1121.childComponentInfos.add(ci); + + ci = fu.new JTextAreaInfo(); + ci.name = "ysr8_SimSubprojectNum"; + ci.type = "JTextArea"; + ci.row = 1; + ci.col = 2; + ci.width = 442; + ci.height = 50; + ((JTextAreaInfo)ci).areaWidth = 70; + ((JTextAreaInfo)ci).areaHeight = 3; + ci.isProComponent = true; + fu.allComponentInfos.put(ci.name, ci); + cip1121.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "B112113"; + ci.type = "JButton"; + ci.title = "ȡ..."; + ci.row = 1; + ci.col = 3; + ci.width = 85; + ci.height = 24; + fu.allComponentInfos.put(ci.name, ci); + cip1121.childComponentInfos.add(ci); + //////////////////////////////////////////// + //////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "p21"; + ci.type = "JPanelEtchedBorder"; + ci.title = "Ŀṩ"; + ci.row = 2; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip.childComponentInfos.add(ci); + ComponentInfo cip21 = ci; + //////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "p2111"; + ci.type = "JPanel"; + ci.row = 1; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip21.childComponentInfos.add(ci); + ComponentInfo cip2111 = ci; + //////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "l211111"; + ci.type = "JLabel"; + ci.title = " ϵͳϣʩ飨ͼϵͳĿ¼տͺšǹ/ǯƷͺšλתλϼ߶ȵϢ"; + ci.row = 1; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip2111.childComponentInfos.add(ci); +// +// ci = fu.new ComponentInfo(); +// ci.name = "l211121"; +// ci.type = "JLabel"; +// ci.title = ""; +// ci.row = 2; +// ci.col = 1; +// fu.allComponentInfos.put(ci.name, ci); +// cip2111.childComponentInfos.add(ci); + //////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "p2121"; + ci.type = "JPanel"; + ci.row = 2; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip21.childComponentInfos.add(ci); + ComponentInfo cip2121 = ci; + //////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "l212111"; + ci.type = "JLabel"; + ci.title = " "; + ci.row = 1; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip2121.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l212112"; + ci.type = "JLabel"; + ci.title = "ٶ"; + ci.row = 1; + ci.col = 2; + fu.allComponentInfos.put(ci.name, ci); + cip2121.childComponentInfos.add(ci); + + ci = fu.new iTextFieldInfo(); + ci.name = "ysr8_MotomanSpeed"; + ci.type = "iTextField"; + ci.row = 1; + ci.col = 3; + ci.width = 30; + ci.isProComponent = true; + fu.allComponentInfos.put(ci.name, ci); + cip2121.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l212114"; + ci.type = "JLabel"; + ci.title = "m/minٶ˵"; + ci.row = 1; + ci.col = 4; + fu.allComponentInfos.put(ci.name, ci); + cip2121.childComponentInfos.add(ci); + + ci = fu.new iTextFieldInfo(); + ci.name = "ysr8_OtherSpeed"; + ci.type = "iTextField"; + ci.row = 1; + ci.col = 5; + ci.isProComponent = true; + fu.allComponentInfos.put(ci.name, ci); + cip2121.childComponentInfos.add(ci); + //////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "l212121"; + ci.type = "JLabel"; + ci.title = " "; + ci.row = 2; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip2121.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l212122"; + ci.type = "JLabel"; + ci.title = "Ҫʱݣн"; + ci.row = 2; + ci.col = 2; + fu.allComponentInfos.put(ci.name, ci); + cip2121.childComponentInfos.add(ci); + + ci = fu.new iTextFieldInfo(); + ci.name = "ysr8_DelayClamping"; + ci.type = "iTextField"; + ci.row = 2; + ci.col = 3; + ci.width = 30; + ci.isProComponent = true; + fu.allComponentInfos.put(ci.name, ci); + cip2121.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l212124"; + ci.type = "JLabel"; + ci.title = "sɿ"; + ci.row = 2; + ci.col = 4; + fu.allComponentInfos.put(ci.name, ci); + cip2121.childComponentInfos.add(ci); + + ci = fu.new iTextFieldInfo(); + ci.name = "ysr8_DelayRelease"; + ci.type = "iTextField"; + ci.row = 2; + ci.col = 5; + ci.width = 30; + ci.isProComponent = true; + fu.allComponentInfos.put(ci.name, ci); + cip2121.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l212126"; + ci.type = "JLabel"; + ci.title = "sϨ"; + ci.row = 2; + ci.col = 6; + fu.allComponentInfos.put(ci.name, ci); + cip2121.childComponentInfos.add(ci); + + ci = fu.new iTextFieldInfo(); + ci.name = "ysr8_DelayWelding"; + ci.type = "iTextField"; + ci.row = 2; + ci.col = 7; + ci.width = 30; + ci.isProComponent = true; + fu.allComponentInfos.put(ci.name, ci); + cip2121.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l212128"; + ci.type = "JLabel"; + ci.title = "sȡ"; + ci.row = 2; + ci.col = 8; + fu.allComponentInfos.put(ci.name, ci); + cip2121.childComponentInfos.add(ci); + //////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "l212131"; + ci.type = "JLabel"; + ci.title = " "; + ci.row = 3; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip2121.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l212132"; + ci.type = "JLabel"; + ci.title = "Ҫ"; + ci.row = 3; + ci.col = 2; + fu.allComponentInfos.put(ci.name, ci); + cip2121.childComponentInfos.add(ci); + + ci = fu.new iTextFieldInfo(); + ci.name = "ysr8_BeatRequirements"; + ci.type = "iTextField"; + ci.row = 3; + ci.col = 3; + ci.width = 30; + ci.isProComponent = true; + fu.allComponentInfos.put(ci.name, ci); + cip2121.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l212134"; + ci.type = "JLabel"; + ci.title = "s"; + ci.row = 3; + ci.col = 4; + fu.allComponentInfos.put(ci.name, ci); + cip2121.childComponentInfos.add(ci); + //////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "l212141"; + ci.type = "JLabel"; + ci.title = " Ҫ"; + ci.row = 4; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip2121.childComponentInfos.add(ci); + + ci = fu.new iTextFieldInfo(); + ci.name = "ysr8_SpecialRequirements"; + ci.type = "iTextField"; + ci.row = 4; + ci.col = 2; + ci.isProComponent = true; + fu.allComponentInfos.put(ci.name, ci); + cip2121.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l212143"; + ci.type = "JLabel"; + ci.title = "𻡡Ϩ˳ͷ򣬺ӽǶȵȣ"; + ci.row = 4; + ci.col = 3; + fu.allComponentInfos.put(ci.name, ci); + cip2121.childComponentInfos.add(ci); + //////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "l212151"; + ci.type = "JLabel"; + ci.title = " Ҫ"; + ci.row = 5; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip2121.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_OtherRequirements"; + ci.type = "JComboBox"; + ci.row = 5; + ci.col = 2; + ci.width = 220; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_OtherReq_LOV"; + fu.allComponentInfos.put(ci.name, ci); + cip2121.childComponentInfos.add(ci); + ////////////////////////////////////////// + ////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "p31"; + ci.type = "JPanelEtchedBorder"; + ci.title = "еṩ"; + ci.row = 3; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip.childComponentInfos.add(ci); + ComponentInfo cip31 = ci; + //////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "l3111"; + ci.type = "JLabel"; + ci.title = " 1˹λãбҪտĿṩ졢λиͿλãλã"; + ci.row = 1; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip31.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l3121"; + ci.type = "JLabel"; + ci.title = " 2ļоݣ߲ۡ䡢δ״̬"; + ci.row = 2; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip31.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l3131"; + ci.type = "JLabel"; + ci.title = " 3İȫģȫ豸ģ׼ȷդλã˺ĿռǷ㹻"; + ci.row = 3; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip31.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l3141"; + ci.type = "JLabel"; + ci.title = " 4ߵġת"; + ci.row = 4; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip31.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l3151"; + ci.type = "JLabel"; + ci.title = " 5˹λ˵"; + ci.row = 5; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip31.childComponentInfos.add(ci); + //////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "p41"; + ci.type = "JPanelEtchedBorder"; + ci.title = "Ҫ"; + ci.row = 4; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip.childComponentInfos.add(ci); + ComponentInfo cip41 = ci; + //////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "l4111"; + ci.type = "JLabel"; + ci.title = "ȷϻѡ"; + ci.row = 1; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip41.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_ProjectSim01"; + ci.type = "JComboBox"; + ci.row = 1; + ci.col = 2; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_YorN_LOV"; + fu.allComponentInfos.put(ci.name, ci); + cip41.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l4113"; + ci.type = "JLabel"; + ci.title = "ȷϻǷ㸺"; + ci.row = 1; + ci.col = 3; + fu.allComponentInfos.put(ci.name, ci); + cip41.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_ProjectSim06"; + ci.type = "JComboBox"; + ci.row = 1; + ci.col = 4; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_YorN_LOV"; + fu.allComponentInfos.put(ci.name, ci); + cip41.childComponentInfos.add(ci); + ////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "l4121"; + ci.type = "JLabel"; + ci.title = "ȷϻ/װλ"; + ci.row = 2; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip41.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_ProjectSim02"; + ci.type = "JComboBox"; + ci.row = 2; + ci.col = 2; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_YorN_LOV"; + fu.allComponentInfos.put(ci.name, ci); + cip41.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l4123"; + ci.type = "JLabel"; + ci.title = "ȷϽġ"; + ci.row = 2; + ci.col = 3; + fu.allComponentInfos.put(ci.name, ci); + cip41.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_ProjectSim07"; + ci.type = "JComboBox"; + ci.row = 2; + ci.col = 4; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_YorN_LOV"; + fu.allComponentInfos.put(ci.name, ci); + cip41.childComponentInfos.add(ci); + ////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "l4131"; + ci.type = "JLabel"; + ci.title = "ȷϻ˶Χ/ɴ"; + ci.row = 3; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip41.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_ProjectSim03"; + ci.type = "JComboBox"; + ci.row = 3; + ci.col = 2; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_YorN_LOV"; + fu.allComponentInfos.put(ci.name, ci); + cip41.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l4133"; + ci.type = "JLabel"; + ci.title = "Ƶ"; + ci.row = 3; + ci.col = 3; + fu.allComponentInfos.put(ci.name, ci); + cip41.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_ProjectSim08"; + ci.type = "JComboBox"; + ci.row = 3; + ci.col = 4; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_ProjectSim08_LOV"; + fu.allComponentInfos.put(ci.name, ci); + cip41.childComponentInfos.add(ci); + ////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "l4141"; + ci.type = "JLabel"; + ci.title = "ȷϹл˼ߺǷ"; + ci.row = 4; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip41.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_ProjectSim04"; + ci.type = "JComboBox"; + ci.row = 4; + ci.col = 2; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_YorN_LOV"; + fu.allComponentInfos.put(ci.name, ci); + cip41.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l4143"; + ci.type = "JLabel"; + ci.title = "ṩ̬ͼ"; + ci.row = 4; + ci.col = 3; + fu.allComponentInfos.put(ci.name, ci); + cip41.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_ProjectSim09"; + ci.type = "JComboBox"; + ci.row = 4; + ci.col = 4; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_YorN_LOV"; + fu.allComponentInfos.put(ci.name, ci); + cip41.childComponentInfos.add(ci); + ////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "l4151"; + ci.type = "JLabel"; + ci.title = "ȷϹл̬Ƿ"; + ci.row = 5; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip41.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_ProjectSim05"; + ci.type = "JComboBox"; + ci.row = 5; + ci.col = 2; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_YorN_LOV"; + fu.allComponentInfos.put(ci.name, ci); + cip41.childComponentInfos.add(ci); + ////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "l4161"; + ci.type = "JLabel"; + ci.title = "Ҫ"; + ci.row = 6; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip41.childComponentInfos.add(ci); + + ci = fu.new JTextAreaInfo(); + ci.name = "ysr8_SimOtherSpeed"; + ci.type = "JTextArea"; + ci.row = 6; + ci.col = 2; + ci.width = 526; + ci.height = 100; + ((JTextAreaInfo)ci).areaWidth = 87; + ((JTextAreaInfo)ci).areaHeight = 10; + ci.isProComponent = true; + fu.allComponentInfos.put(ci.name, ci); + cip41.childComponentInfos.add(ci); + ////////////////////////////////////////// + ////////////////////////////////////////// + fu.initializeUI(arg0); + addActionListener(); + loadRendering(); + } + + + + @Override + public void displayDialog(AbstractAIFDialog arg0, boolean arg1) { + fu.fitToScreen(arg0); + super.displayDialog(arg0, arg1); + } + + + + @Override + public void displayDialog(OpenFormDialog arg0, boolean arg1) { + fu.fitToScreen(arg0); + super.displayDialog(arg0, arg1); + } + + + + @Override + public void loadRendering() throws TCException { + fu.loadRendering(); + } + + @Override + public void saveRendering() { + try { + fu.saveRendering(); + } catch (TCException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } catch (ParseException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } + } + + public boolean isRenderingModified() { + return fu.isRenderingModified(); + } + + ///////////////////////////////////////////////////////////////// + void addActionListener() { + { + JButton btn = (JButton)fu.allComponentMap.get("B112113"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + String itemId = ""; + String ver = ""; + try { + AIFComponentContext[] context = fu.tcForm.whereReferencedByTypeRelation(new String[] {"YSR8_ProjectSimRevision"}, new String[] {"IMAN_master_form"}); + if (context != null && context.length > 0) { + TCComponentItemRevision itemRevision = (TCComponentItemRevision)context[0].getComponent(); + itemId = itemRevision.getProperty("item_id"); + ver = itemRevision.getProperty("item_revision_id"); +System.out.println("itemRevision.getProperty:itemId-----" + itemId + "-----ver----" + ver); + } + } catch (TCException e1) { + e1.printStackTrace(); + } + if (itemId.equals("") || ver.equals("")) { + MessageBox.post("޷ҵĿϢ!", "ʾ", MessageBox.INFORMATION); + return; + } + + String propValue = ""; + try { + TCComponentQueryType querytype; + try { + TCTextService textService = RACUIUtil.getTCSession().getTextService(); + + querytype = (TCComponentQueryType) RACUIUtil.getTCSession().getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) querytype.find("SearchMachParts"); + if(null == query){ + MessageBox.post("ʹòѯѯSearchMachParts!", "ʾ", MessageBox.INFORMATION); + return; + } + querytype.clearCache(); + + Vector vtKey = new Vector(); + Map hmkey = new HashMap(); + + vtKey.add(textService.getTextValue("ID")); + hmkey.put(textService.getTextValue("ID"), itemId); + vtKey.add(textService.getTextValue("Revision")); + hmkey.put(textService.getTextValue("Revision"), ver); + + int size = vtKey.size(); + String []attr = new String[size]; + String []values = new String[size]; + for(int i = 0 ; i< vtKey.size(); i++){ + attr[i] = vtKey.get(i); + values[i] = hmkey.get(attr[i]); + } + + TCComponentContextList list = query.getExecuteResultsList(attr, values); + if (list != null && list.getListCount() > 0) { + for (int j = 0; j < list.getListCount(); j++) { + TCComponentItem jxzxm = (TCComponentItem)list.get(j).getComponent(); + if (jxzxm != null) { + if (!propValue.equals("")) { + propValue += ";"; + } + propValue += jxzxm.getProperty("item_id"); +System.out.println("jxzxm.getProperty:propValue-----" + propValue); + } + } + } else { + MessageBox.post("ģļδֻеĿ뽫ҪĻеĿƵģļС", "ʾ", MessageBox.INFORMATION); + return; + } + } catch (TCException e2) { + e2.printStackTrace(); + } + } catch (Exception e3) { + throw e3; + } + + JTextArea textarea = (JTextArea)fu.allComponentMap.get("ysr8_SimSubprojectNum"); + textarea.setText(propValue); + } + }); + } + } + +} diff --git a/src/cn/com/ebewin/ysr/form/YSR8_SaleOrderRevisionMasterForm.java b/src/cn/com/ebewin/ysr/form/YSR8_SaleOrderRevisionMasterForm.java new file mode 100644 index 0000000..5d92634 --- /dev/null +++ b/src/cn/com/ebewin/ysr/form/YSR8_SaleOrderRevisionMasterForm.java @@ -0,0 +1,182 @@ +package cn.com.ebewin.ysr.form; + +import java.awt.Desktop; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.text.ParseException; +import java.util.Date; + +import javax.swing.JButton; + +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.iTextField; + +import cn.com.ebewin.ysr.util.FormUtil; + +public class YSR8_SaleOrderRevisionMasterForm extends AbstractRendering { + private static final long serialVersionUID = 1L; + private static Date refreshDate = null; + + FormUtil fu = new FormUtil(this); + + public YSR8_SaleOrderRevisionMasterForm(TCComponentForm arg0) throws Exception { + super(arg0); + + Date currDate = new Date(); + if (refreshDate == null) { + arg0.refresh(); + refreshDate = currDate; + } else { + long diff = currDate.getTime() - refreshDate.getTime(); + long minutes = diff / 1000 / 60; + if ( minutes >= 1 ) { + arg0.refresh(); + refreshDate = currDate; + } + } + + fu.readRenderingXML("YSR8_SaleOrderRevisionMasterForm"); + fu.initializeUI(arg0); + addActionListener(); + loadRendering(); + getDefVal(); + } + + @Override + public void loadRendering() throws TCException { + iTextField textfieldForm; + AIFComponentContext[] context1 = fu.tcForm.whereReferencedByTypeRelation(new String[] {"YSR8_SaleOrderRevision"}, new String[] {"IMAN_master_form"}); + if (context1 != null && context1.length > 0) { + TCComponentItemRevision soRevision = (TCComponentItemRevision)context1[0].getComponent(); + TCComponentItem soItem = soRevision.getItem(); + + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_ProjectCode"); + textfieldForm.setText(soItem.getProperty("item_id")); + } + + fu.loadRendering(); + } + + public void setRenderingReadOnly() + { + setModifiableComponents(this, false); + if(getController() != null) + getController().setFormReadOnly(); + + JButton btn = (JButton)fu.allComponentMap.get("b.141.11"); + if (btn != null) { + btn.setEnabled(true); + if(btn.getParent() != null) + btn.getParent().setEnabled(true); + if(btn.getParent().getParent() != null) + btn.getParent().getParent().setEnabled(true); + } + } + + public void setRenderingReadWrite() + { + setModifiableComponents(this, true); + + JButton btn = (JButton)fu.allComponentMap.get("b.141.11"); + if (btn != null) { + btn.setEnabled(true); + } + } + + private void setModifiableComponents(java.awt.Component currcomponent, boolean flag) + { + fu.setModifiableComponents(currcomponent, flag); + } + + @Override + public void saveRendering() { + if (!checkCanSave()) { + return; + } + + try { + fu.saveRendering(); + } catch (TCException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } catch (ParseException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } + } + + public boolean isRenderingModified() { + return fu.isRenderingModified(); + } + + private void addActionListener() { + { + JButton btn = (JButton)fu.allComponentMap.get("b.141.11"); + if (btn != null) { + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + BPM(); + } + }); + } + } + } + + public void getDefVal() { + } + + public boolean checkCanSave() { + return true; + } + + public void BPM() { + try { + final String urlStr = fu.tcForm.getProperty("ysr8_BPMURL_DHTZ"); + if(urlStr != null && !urlStr.equals("")){ +// IWorkbenchWindow localIWorkbenchWindow = AIFUtility.getActiveDesktop().getDesktopWindow(); +// final IWorkbenchPage workbenchpage = localIWorkbenchWindow.getActivePage(); +// final BrowserView viewDK = (BrowserView)workbenchpage.findView("com.teamcenter.rac.aifrcp.BrowserView"); +// if(viewDK == null){ +// Display.getDefault().syncExec(new Runnable() { +// public void run() { +// try { +// ((BrowserView) workbenchpage.showView("com.teamcenter.rac.aifrcp.BrowserView")).setUrl(urlStr); +//// viewDK.setUrl(urlStr); +// } catch (PartInitException e) { +// e.printStackTrace(); +// } +// } +// }); +// } else { +// Display.getDefault().syncExec(new Runnable() { +// +// @Override +// public void run() { +// viewDK.setUrl(urlStr); +// } +// }); +// } + URI uri = new URI(urlStr); + Desktop.getDesktop().browse(uri); + } + } catch (URISyntaxException e) { + e.printStackTrace(); + } catch (TCException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/src/cn/com/ebewin/ysr/form/YSR8_SaleProjectRevisionMasterForm.java b/src/cn/com/ebewin/ysr/form/YSR8_SaleProjectRevisionMasterForm.java new file mode 100644 index 0000000..3b6ae4c --- /dev/null +++ b/src/cn/com/ebewin/ysr/form/YSR8_SaleProjectRevisionMasterForm.java @@ -0,0 +1,152 @@ +package cn.com.ebewin.ysr.form; + +import java.awt.Desktop; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.text.ParseException; +import java.util.Date; + +import javax.swing.JButton; + +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.iTextField; + +import cn.com.ebewin.ysr.util.FormUtil; + +public class YSR8_SaleProjectRevisionMasterForm extends AbstractRendering { + private static final long serialVersionUID = 1L; + private static Date refreshDate = null; + + FormUtil fu = new FormUtil(this); + + public YSR8_SaleProjectRevisionMasterForm(TCComponentForm arg0) throws Exception { + super(arg0); + + Date currDate = new Date(); + if (refreshDate == null) { + arg0.refresh(); + refreshDate = currDate; + } else { + long diff = currDate.getTime() - refreshDate.getTime(); + long minutes = diff / 1000 / 60; + if ( minutes >= 1 ) { + arg0.refresh(); + refreshDate = currDate; + } + } + + fu.readRenderingXML("YSR8_SaleProjectRevisionMasterForm"); + fu.initializeUI(arg0); + addActionListener(); + loadRendering(); + getDefVal(); + } + + @Override + public void loadRendering() throws TCException { + iTextField textfieldForm; + AIFComponentContext[] context1 = fu.tcForm.whereReferencedByTypeRelation(new String[] {"YSR8_SaleProjectRevision"}, new String[] {"IMAN_master_form"}); + if (context1 != null && context1.length > 0) { + TCComponentItemRevision soRevision = (TCComponentItemRevision)context1[0].getComponent(); + TCComponentItem soItem = soRevision.getItem(); + + textfieldForm = (iTextField)fu.allComponentMap.get("ItemID"); + textfieldForm.setText(soItem.getProperty("item_id")); + } + + fu.loadRendering(); + } + + public void setRenderingReadOnly() + { + setModifiableComponents(this, false); + + if(getController() != null) + getController().setFormReadOnly(); + JButton btn = (JButton)fu.allComponentMap.get("b.161.11"); + btn.setEnabled(true); + if(btn.getParent() != null) + btn.getParent().setEnabled(true); + if(btn.getParent().getParent() != null) + btn.getParent().getParent().setEnabled(true); + } + + public void setRenderingReadWrite() + { + setModifiableComponents(this, true); + JButton btn = (JButton)fu.allComponentMap.get("b.161.11"); + btn.setEnabled(true); + } + + private void setModifiableComponents(java.awt.Component currcomponent, boolean flag) + { + fu.setModifiableComponents(currcomponent, flag); + } + + @Override + public void saveRendering() { + if (!checkCanSave()) { + return; + } + + try { + fu.saveRendering(); + } catch (TCException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } catch (ParseException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } + } + + public boolean isRenderingModified() { + return fu.isRenderingModified(); + } + + private void addActionListener() { + { + JButton btn = (JButton)fu.allComponentMap.get("b.161.11"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + BPM(); + } + }); + } + } + + public void getDefVal() { + } + + public boolean checkCanSave() { + return true; + } + + public void BPM() { + try { + final String urlStr = fu.tcForm.getProperty("ysr8_BPMURL_QDTZ"); + if(urlStr != null && !urlStr.equals("")){ + URI uri = new URI(urlStr); + Desktop.getDesktop().browse(uri); + } + } catch (URISyntaxException e) { + e.printStackTrace(); + } catch (TCException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/src/cn/com/ebewin/ysr/form/YSR8_SimConRevisionMasterForm.java b/src/cn/com/ebewin/ysr/form/YSR8_SimConRevisionMasterForm.java new file mode 100644 index 0000000..c4864fb --- /dev/null +++ b/src/cn/com/ebewin/ysr/form/YSR8_SimConRevisionMasterForm.java @@ -0,0 +1,997 @@ +package cn.com.ebewin.ysr.form; + +import java.text.ParseException; +import java.util.Date; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.commands.open.OpenFormDialog; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.util.MessageBox; + +import cn.com.ebewin.ysr.util.FormUtil; +import cn.com.ebewin.ysr.util.UIUtil.ComponentInfo; +import cn.com.ebewin.ysr.util.UIUtil.JComboBoxInfo; +import cn.com.ebewin.ysr.util.UIUtil.JTextAreaInfo; + +public class YSR8_SimConRevisionMasterForm extends AbstractRendering { + private static final long serialVersionUID = 1L; + private static Date refreshDate = null; + + FormUtil fu = new FormUtil(this); + + public YSR8_SimConRevisionMasterForm(TCComponentForm arg0) throws Exception { + super(arg0); + + Date currDate = new Date(); + if (refreshDate == null) { + arg0.refresh(); + refreshDate = currDate; + } else { + long diff = currDate.getTime() - refreshDate.getTime(); + long minutes = diff / 1000 / 60; + if ( minutes >= 1 ) { + arg0.refresh(); + refreshDate = currDate; + } + } + + //////////////////////////////////////////// + ComponentInfo ci = fu.new ComponentInfo(); + ci.name = "sp"; + ci.type = "JScrollPane"; + ci.row = 0; + ci.col = 0; + fu.firstComponentInfo = ci; + fu.allComponentInfos.put(ci.name, ci); + ComponentInfo cisp = ci; + + ci = fu.new ComponentInfo(); + ci.name = "p"; + ci.type = "JPanel"; + ci.row = 0; + ci.col = 0; + fu.allComponentInfos.put(ci.name, ci); + cisp.childComponentInfos.add(ci); + ComponentInfo cip = ci; + //////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "l11"; + ci.type = "JLabel"; + ci.title = "ţJL-8.3-11"; + ci.row = 1; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "p21"; + ci.type = "JPanelEtchedBorder"; + ci.title = "о߿ɴ"; + ci.row = 2; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip.childComponentInfos.add(ci); + ComponentInfo cip21 = ci; + //////////////////////////////////////////// + + + ci = fu.new ComponentInfo(); + ci.name = "k0"; + ci.type = "JPanelEtchedBorder"; + ci.row = 1; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip21.childComponentInfos.add(ci); + ComponentInfo k0 = ci; + + + ci = fu.new ComponentInfo(); + ci.name = "l1111"; + ci.type = "JLabel"; + ci.title = "ɴԡ"; + ci.row = 1; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + k0.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l1112"; + ci.type = "JLabel"; + ci.title = "жλǷɴ"; + ci.row = 1; + ci.col = 2; + fu.allComponentInfos.put(ci.name, ci); + k0.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_SimCon01"; + ci.type = "JComboBox"; + ci.row = 1; + ci.col = 3; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_YorN_LOV"; + fu.allComponentInfos.put(ci.name, ci); + k0.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l1114"; + ci.type = "JLabel"; + ci.title = "ӽǶǷá"; + ci.row = 1; + ci.col = 4; + fu.allComponentInfos.put(ci.name, ci); + k0.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_SimCon03"; + ci.type = "JComboBox"; + ci.row = 1; + ci.col = 5; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_YorN_LOV"; + fu.allComponentInfos.put(ci.name, ci); + k0.childComponentInfos.add(ci); + //////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "l1121"; + ci.type = "JLabel"; + ci.title = ""; + ci.row = 2; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + k0.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l1122"; + ci.type = "JLabel"; + ci.title = "Ƿл˵޵Ķ(С100mm) "; + ci.row = 2; + ci.col = 2; + fu.allComponentInfos.put(ci.name, ci); + k0.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_SimCon02"; + ci.type = "JComboBox"; + ci.row = 2; + ci.col = 3; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_YorN_LOV"; + fu.allComponentInfos.put(ci.name, ci); + k0.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l1124"; + ci.type = "JLabel"; + ci.title = "ѵĺӽǶǷƺĿȷϡ"; + ci.row = 2; + ci.col = 4; + fu.allComponentInfos.put(ci.name, ci); + k0.childComponentInfos.add(ci); + + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_SimCon04"; + ci.type = "JComboBox"; + ci.row = 2; + ci.col = 5; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_YorN_LOV"; + fu.allComponentInfos.put(ci.name, ci); + k0.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "k1"; + ci.type = "JPanelEtchedBorder"; + ci.row = 2; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip21.childComponentInfos.add(ci); + ComponentInfo k1 = ci; + + //////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "l1131"; + ci.type = "JLabel"; + ci.title = "桡"; + ci.row = 1; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + k1.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l1132"; + ci.type = "JLabel"; + ci.title = "ߺͼоߣǷ桡"; + ci.row = 1; + ci.col = 2; + fu.allComponentInfos.put(ci.name, ci); + k1.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_SimCon05"; + ci.type = "JComboBox"; + ci.row = 1; + ci.col = 3; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_YorN_LOV"; + fu.allComponentInfos.put(ci.name, ci); + k1.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l1134"; + ci.type = "JLabel"; + ci.title = "ϵĹǷͼо߸桡"; + ci.row = 1; + ci.col = 4; + fu.allComponentInfos.put(ci.name, ci); + k1.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_SimCon07"; + ci.type = "JComboBox"; + ci.row = 1; + ci.col = 5; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_YorN_LOV"; + fu.allComponentInfos.put(ci.name, ci); + k1.childComponentInfos.add(ci); + //////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "l1141"; + ci.type = "JLabel"; + ci.title = ""; + ci.row = 2; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + k1.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l1142"; + ci.type = "JLabel"; + ci.title = "˱ͼоǷ桡"; + ci.row = 2; + ci.col = 2; + fu.allComponentInfos.put(ci.name, ci); + k1.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_SimCon06"; + ci.type = "JComboBox"; + ci.row = 2; + ci.col = 3; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_YorN_LOV"; + fu.allComponentInfos.put(ci.name, ci); + k1.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "k3"; + ci.type = "JPanelEtchedBorder"; + ci.row = 3; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip21.childComponentInfos.add(ci); + ComponentInfo k3 = ci; + + //////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "l1151"; + ci.type = "JLabel"; + ci.title = "㺸ء"; + ci.row = 1; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + k3.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l1152"; + ci.type = "JLabel"; + ci.title = "ǯĥǷ10mm"; + ci.row = 1; + ci.col = 2; + fu.allComponentInfos.put(ci.name, ci); + k3.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_SimCon08"; + ci.type = "JComboBox"; + ci.row = 1; + ci.col = 3; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_YorN_LOV"; + fu.allComponentInfos.put(ci.name, ci); + k3.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l1154"; + ci.type = "JLabel"; + ci.title = "ǹǷʹ졡"; + ci.row = 1; + ci.col = 4; + fu.allComponentInfos.put(ci.name, ci); + k3.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_SimCon10"; + ci.type = "JComboBox"; + ci.row = 1; + ci.col = 5; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_YorN_LOV"; + fu.allComponentInfos.put(ci.name, ci); + k3.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "k4"; + ci.type = "JPanelEtchedBorder"; + ci.row = 4; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip21.childComponentInfos.add(ci); + ComponentInfo k4 = ci; + + //////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "l1161"; + ci.type = "JLabel"; + ci.title = "ء"; + ci.row = 1; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + k4.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l1162"; + ci.type = "JLabel"; + ci.title = "Ƿʹ缫ñ"; + ci.row = 1; + ci.col = 2; + fu.allComponentInfos.put(ci.name, ci); + k4.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_SimCon09"; + ci.type = "JComboBox"; + ci.row = 1; + ci.col = 3; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_YorN_LOV"; + fu.allComponentInfos.put(ci.name, ci); + k4.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l1164"; + ci.type = "JLabel"; + ci.title = "DX200 Ƿʹ׺ǹ "; + ci.row = 1; + ci.col = 4; + fu.allComponentInfos.put(ci.name, ci); + k4.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_SimCon11"; + ci.type = "JComboBox"; + ci.row = 1; + ci.col = 5; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_YorN_LOV"; + fu.allComponentInfos.put(ci.name, ci); + k4.childComponentInfos.add(ci); + //////////////////////////////////////////// + //////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "p31"; + ci.type = "JPanelEtchedBorder"; + ci.title = "վ"; + ci.row = 3; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip.childComponentInfos.add(ci); + ComponentInfo cip31 = ci; + //////////////////////////////////////////// + + ci = fu.new ComponentInfo(); + ci.name = "p31"; + ci.type = "JPanelEtchedBorder"; + ci.row = 1; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip31.childComponentInfos.add(ci); + ComponentInfo k11 = ci; + + ci = fu.new ComponentInfo(); + ci.name = "l2111"; + ci.type = "JLabel"; + ci.title = ""; + ci.row = 1; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + k11.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l2112"; + ci.type = "JLabel"; + ci.title = "˶ǷͰȫ桡"; + ci.row = 1; + ci.col = 2; + fu.allComponentInfos.put(ci.name, ci); + k11.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_SimCon12"; + ci.type = "JComboBox"; + ci.row = 1; + ci.col = 3; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_YorN_LOV"; + fu.allComponentInfos.put(ci.name, ci); + k11.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l2114"; + ci.type = "JLabel"; + ci.title = "˶ǷӰڹλ"; + ci.row = 1; + ci.col = 4; + fu.allComponentInfos.put(ci.name, ci); + k11.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_SimCon16"; + ci.type = "JComboBox"; + ci.row = 1; + ci.col = 5; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_YorN_LOV"; + fu.allComponentInfos.put(ci.name, ci); + k11.childComponentInfos.add(ci); + //////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "l2121"; + ci.type = "JLabel"; + ci.title = ""; + ci.row = 2; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + k11.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l2122"; + ci.type = "JLabel"; + ci.title = "˶Ƿĥ˿װø"; + ci.row = 2; + ci.col = 2; + fu.allComponentInfos.put(ci.name, ci); + k11.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_SimCon13"; + ci.type = "JComboBox"; + ci.row = 2; + ci.col = 3; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_YorN_LOV"; + fu.allComponentInfos.put(ci.name, ci); + k11.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l2124"; + ci.type = "JLabel"; + ci.title = "˺ռǷ㹻500mm "; + ci.row = 2; + ci.col = 4; + fu.allComponentInfos.put(ci.name, ci); + k11.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_SimCon17"; + ci.type = "JComboBox"; + ci.row = 2; + ci.col = 5; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_YorN_LOV"; + fu.allComponentInfos.put(ci.name, ci); + k11.childComponentInfos.add(ci); + //////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "l2131"; + ci.type = "JLabel"; + ci.title = ""; + ci.row = 3; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + k11.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l2132"; + ci.type = "JLabel"; + ci.title = "վ˱干ͬʱǷ桡"; + ci.row = 3; + ci.col = 2; + fu.allComponentInfos.put(ci.name, ci); + k11.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_SimCon14"; + ci.type = "JComboBox"; + ci.row = 3; + ci.col = 3; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_YorN_LOV"; + fu.allComponentInfos.put(ci.name, ci); + k11.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l2134"; + ci.type = "JLabel"; + ci.title = "˹ɵǷͰȫи豸桡"; + ci.row = 3; + ci.col = 4; + fu.allComponentInfos.put(ci.name, ci); + k11.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_SimCon18"; + ci.type = "JComboBox"; + ci.row = 3; + ci.col = 5; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_YorN_LOV"; + fu.allComponentInfos.put(ci.name, ci); + k11.childComponentInfos.add(ci); + //////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "l2141"; + ci.type = "JLabel"; + ci.title = ""; + ci.row = 4; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + k11.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l2142"; + ci.type = "JLabel"; + ci.title = "վ˿ͬʱǷ桡"; + ci.row = 4; + ci.col = 2; + fu.allComponentInfos.put(ci.name, ci); + k11.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_SimCon15"; + ci.type = "JComboBox"; + ci.row = 4; + ci.col = 3; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_YorN_LOV"; + fu.allComponentInfos.put(ci.name, ci); + k11.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "p31"; + ci.type = "JPanelEtchedBorder"; + ci.row = 2; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip31.childComponentInfos.add(ci); + ComponentInfo k12 = ci; + + ////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "l2151"; + ci.type = "JLabel"; + ci.title = "λ"; + ci.row = 1; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + k12.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l2152"; + ci.type = "JLabel"; + ci.title = "תλʱǷΪǶȡ"; + ci.row = 1; + ci.col = 2; + fu.allComponentInfos.put(ci.name, ci); + k12.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_SimCon19"; + ci.type = "JComboBox"; + ci.row = 1; + ci.col = 3; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_YorN_LOV"; + fu.allComponentInfos.put(ci.name, ci); + k12.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l2154"; + ci.type = "JLabel"; + ci.title = "оλתʱǷ͵棬ȫ桡"; + ci.row = 1; + ci.col = 4; + fu.allComponentInfos.put(ci.name, ci); + k12.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_SimCon20"; + ci.type = "JComboBox"; + ci.row = 1; + ci.col = 5; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_YorN_LOV"; + fu.allComponentInfos.put(ci.name, ci); + k12.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "p31"; + ci.type = "JPanelEtchedBorder"; + ci.row = 3; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip31.childComponentInfos.add(ci); + ComponentInfo k13 = ci; + + ////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "l2161"; + ci.type = "JLabel"; + ci.title = ""; + ci.row = 1; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + k13.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l2162"; + ci.type = "JLabel"; + ci.title = "оǷ񵲹դ"; + ci.row = 1; + ci.col = 2; + fu.allComponentInfos.put(ci.name, ci); + k13.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_SimCon21"; + ci.type = "JComboBox"; + ci.row = 1; + ci.col = 3; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_YorN_LOV"; + fu.allComponentInfos.put(ci.name, ci); + k13.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l2164"; + ci.type = "JLabel"; + ci.title = "ץִ״̬Ƿ桡"; + ci.row = 1; + ci.col = 4; + fu.allComponentInfos.put(ci.name, ci); + k13.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_SimCon22"; + ci.type = "JComboBox"; + ci.row = 1; + ci.col = 5; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_YorN_LOV"; + fu.allComponentInfos.put(ci.name, ci); + k13.childComponentInfos.add(ci); + ////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "l2171"; + ci.type = "JLabel"; + ci.title = " "; + ci.row = 2; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + k13.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l2172"; + ci.type = "JLabel"; + ci.title = "ϵĹǷͰȫ桡"; + ci.row = 2; + ci.col = 2; + fu.allComponentInfos.put(ci.name, ci); + k13.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_SimCon24"; + ci.type = "JComboBox"; + ci.row = 2; + ci.col = 3; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_YorN_LOV"; + fu.allComponentInfos.put(ci.name, ci); + k13.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l2174"; + ci.type = "JLabel"; + ci.title = "ץйǷ棨̬Ʋ鿴Ƿ棩"; + ci.row = 2; + ci.col = 4; + fu.allComponentInfos.put(ci.name, ci); + k13.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_SimCon23"; + ci.type = "JComboBox"; + ci.row = 2; + ci.col = 5; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_YorN_LOV"; + fu.allComponentInfos.put(ci.name, ci); + k13.childComponentInfos.add(ci); + //////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "p41"; + ci.type = "JPanelEtchedBorder"; + ci.title = ""; + ci.row = 4; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip.childComponentInfos.add(ci); + ComponentInfo cip41 = ci; + ////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "l3111"; + ci.type = "JLabel"; + ci.title = ""; + ci.row = 1; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip41.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l3112"; + ci.type = "JLabel"; + ci.title = " ǷṩٶҪ󡡡"; + ci.row = 1; + ci.col = 2; + fu.allComponentInfos.put(ci.name, ci); + cip41.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_SimCon25"; + ci.type = "JComboBox"; + ci.row = 1; + ci.col = 3; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_YorN_LOV"; + fu.allComponentInfos.put(ci.name, ci); + cip41.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l3114"; + ci.type = "JLabel"; + ci.title = "ǷṩҪʱݣнɿϨȣ"; + ci.row = 1; + ci.col = 4; + fu.allComponentInfos.put(ci.name, ci); + cip41.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_SimCon26"; + ci.type = "JComboBox"; + ci.row = 1; + ci.col = 5; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_YorN_LOV"; + fu.allComponentInfos.put(ci.name, ci); + cip41.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l3114"; + ci.type = "JLabel"; + ci.title = ""; + ci.row = 1; + ci.col = 6; + fu.allComponentInfos.put(ci.name, ci); + cip41.childComponentInfos.add(ci); + //////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "l3121"; + ci.type = "JLabel"; + ci.title = ""; + ci.row = 2; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip41.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l3122"; + ci.type = "JLabel"; + ci.title = " ǷҪ󡡡"; + ci.row = 2; + ci.col = 2; + fu.allComponentInfos.put(ci.name, ci); + cip41.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_SimCon27"; + ci.type = "JComboBox"; + ci.row = 2; + ci.col = 3; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_YorN_LOV"; + fu.allComponentInfos.put(ci.name, ci); + cip41.childComponentInfos.add(ci); + //////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "p51"; + ci.type = "JPanelEtchedBorder"; + ci.title = ""; + ci.row = 5; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip.childComponentInfos.add(ci); + ComponentInfo cip51 = ci; + ////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "l4111"; + ci.type = "JLabel"; + ci.title = ""; + ci.row = 1; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip51.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l4112"; + ci.type = "JLabel"; + ci.title = " ǯץֵİװʽ(TCPֵģת)Ƿϴ"; + ci.row = 1; + ci.col = 2; + fu.allComponentInfos.put(ci.name, ci); + cip51.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_SimCon28"; + ci.type = "JComboBox"; + ci.width = 152; + ci.row = 1; + ci.col = 3; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_YorN_LOV"; + fu.allComponentInfos.put(ci.name, ci); + cip51.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "123123123123"; + ci.type = "JLabel"; + ci.title= " "; + ci.row = 1; + ci.col = 4; + fu.allComponentInfos.put(ci.name, ci); + cip51.childComponentInfos.add(ci); + ////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "p61"; + ci.type = "JPanelEtchedBorder"; + ci.title = ""; + ci.row = 6; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip.childComponentInfos.add(ci); + ComponentInfo cip61 = ci; + ////////////////////////////////////////// + /*ci = fu.new ComponentInfo(); + ci.name = "l6111"; + ci.type = "JLabel"; + ci.title = " "; + ci.row = 1; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip61.childComponentInfos.add(ci);*/ + + ci = fu.new JTextAreaInfo(); + ci.name = "ysr8_RemainingProblem"; + ci.type = "JTextArea"; + ci.row = 1; + ci.col = 1; + ci.width = 1029; + ci.height = 150; + ((JTextAreaInfo)ci).areaWidth = 158; + ((JTextAreaInfo)ci).areaHeight = 10; + ci.isProComponent = true; + fu.allComponentInfos.put(ci.name, ci); + cip61.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l6121"; + ci.type = "JLabel"; + ci.title = ""; + ci.row = 2; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip61.childComponentInfos.add(ci); + ////////////////////////////////////////// + + fu.initializeUI(arg0); + loadRendering(); + } + + + + @Override + public void displayDialog(AbstractAIFDialog arg0, boolean arg1) { + fu.fitToScreen(arg0); + super.displayDialog(arg0, arg1); + } + + + + @Override + public void displayDialog(OpenFormDialog arg0, boolean arg1) { + fu.fitToScreen(arg0); + super.displayDialog(arg0, arg1); + } + + + + @Override + public void loadRendering() throws TCException { + fu.loadRendering(); + } + + /** + * (non-Javadoc) + * @see com.teamcenter.rac.form.AbstractTCForm#saveForm() + */ + @Override + public void saveRendering() { + try { + fu.saveRendering(); + } catch (TCException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } catch (ParseException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } + } + + public boolean isRenderingModified() { + return fu.isRenderingModified(); + } + +} diff --git a/src/cn/com/ebewin/ysr/form/YSR8_TaskRevisionMasterForm.java b/src/cn/com/ebewin/ysr/form/YSR8_TaskRevisionMasterForm.java new file mode 100644 index 0000000..430bb7b --- /dev/null +++ b/src/cn/com/ebewin/ysr/form/YSR8_TaskRevisionMasterForm.java @@ -0,0 +1,360 @@ +package cn.com.ebewin.ysr.form; + +import java.text.ParseException; +import java.util.Date; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.commands.open.OpenFormDialog; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.util.MessageBox; + +import cn.com.ebewin.ysr.util.FormUtil; +import cn.com.ebewin.ysr.util.UIUtil.ComponentInfo; +import cn.com.ebewin.ysr.util.UIUtil.JComboBoxInfo; +import cn.com.ebewin.ysr.util.UIUtil.JTextAreaInfo; + +public class YSR8_TaskRevisionMasterForm extends AbstractRendering { + private static final long serialVersionUID = 1L; + private static Date refreshDate = null; + + FormUtil fu = new FormUtil(this); + + public YSR8_TaskRevisionMasterForm(TCComponentForm arg0) throws Exception { + super(arg0); + + Date currDate = new Date(); + if (refreshDate == null) { + arg0.refresh(); + refreshDate = currDate; + } else { + long diff = currDate.getTime() - refreshDate.getTime(); + long minutes = diff / 1000 / 60; + if ( minutes >= 1 ) { + arg0.refresh(); + refreshDate = currDate; + } + } + + //////////////////////////////////////////// + ComponentInfo ci = fu.new ComponentInfo(); + ci.name = "sp"; + ci.type = "JScrollPane"; + ci.row = 0; + ci.col = 0; + fu.firstComponentInfo = ci; + fu.allComponentInfos.put(ci.name, ci); + ComponentInfo cisp = ci; + + ci = fu.new ComponentInfo(); + ci.name = "p"; + ci.type = "JPanel"; + ci.row = 0; + ci.col = 0; + fu.allComponentInfos.put(ci.name, ci); + cisp.childComponentInfos.add(ci); + ComponentInfo cip = ci; + //////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "p11"; + ci.type = "JPanel"; + ci.row = 1; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip.childComponentInfos.add(ci); + ComponentInfo cip11 = ci; + //////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "l1111"; + ci.type = "JLabel"; + ci.title = ""; + ci.row = 1; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip11.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l1121"; + ci.type = "JLabel"; + ci.title = "롡"; + ci.row = 2; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip11.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_TrusteeDept"; + ci.type = "JComboBox"; + ci.row = 2; + ci.col = 2; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_department_LOV"; + fu.allComponentInfos.put(ci.name, ci); + cip11.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l1123"; + ci.type = "JLabel"; + ci.title = "¹"; + ci.row = 2; + ci.col = 3; + fu.allComponentInfos.put(ci.name, ci); + cip11.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l1131"; + ci.type = "JLabel"; + ci.title = ""; + ci.row = 3; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip11.childComponentInfos.add(ci); + //////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "p21"; + ci.type = "JPanelEtchedBorder"; + ci.title = ""; + ci.row = 2; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip.childComponentInfos.add(ci); + ComponentInfo cip21 = ci; + //////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "l2111"; + ci.type = "JLabel"; + ci.title = ""; + ci.row = 1; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip21.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l2121"; + ci.type = "JLabel"; + ci.title = "ûơ"; + ci.row = 2; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip21.childComponentInfos.add(ci); + + ci = fu.new iTextFieldInfo(); + ci.name = "ysr8_CustomerName"; + ci.type = "iTextField"; + ci.row = 2; + ci.col = 2; + ci.width = 478; + ci.isProComponent = true; + fu.allComponentInfos.put(ci.name, ci); + cip21.childComponentInfos.add(ci); + //////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "l2131"; + ci.type = "JLabel"; + ci.title = "Ŀš"; + ci.row = 3; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip21.childComponentInfos.add(ci); + + ci = fu.new iTextFieldInfo(); + ci.name = "ysr8_OrderNumber"; + ci.type = "iTextField"; + ci.row = 3; + ci.col = 2; + ci.isProComponent = true; + fu.allComponentInfos.put(ci.name, ci); + cip21.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l2133"; + ci.type = "JLabel"; + ci.title = "Ŀơ"; + ci.row = 3; + ci.col = 3; + fu.allComponentInfos.put(ci.name, ci); + cip21.childComponentInfos.add(ci); + + ci = fu.new iTextFieldInfo(); + ci.name = "ysr8_ProjectName"; + ci.type = "iTextField"; + ci.row = 3; + ci.col = 4; + ci.isProComponent = true; + fu.allComponentInfos.put(ci.name, ci); + cip21.childComponentInfos.add(ci); + //////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "l2141"; + ci.type = "JLabel"; + ci.title = "۸ˡ"; + ci.row = 4; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip21.childComponentInfos.add(ci); + + ci = fu.new iTextFieldInfo(); + ci.name = "ysr8_Sales"; + ci.type = "iTextField"; + ci.row = 4; + ci.col = 2; + ci.isProComponent = true; + fu.allComponentInfos.put(ci.name, ci); + cip21.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l2143"; + ci.type = "JLabel"; + ci.title = "ʱҪ󡡡"; + ci.row = 4; + ci.col = 3; + fu.allComponentInfos.put(ci.name, ci); + cip21.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "ysr8_CriticalDate"; + ci.type = "DateButton"; + ci.row = 4; + ci.col = 4; + ci.width=150; + ci.isProComponent = true; + fu.allComponentInfos.put(ci.name, ci); + cip21.childComponentInfos.add(ci); + //////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "l2151"; + ci.type = "JLabel"; + ci.title = "Ŀݡ"; + ci.row = 5; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip21.childComponentInfos.add(ci); + + ci = fu.new JTextAreaInfo(); + ci.name = "ysr8_ProjectContent"; + ci.type = "JTextArea"; + ci.row = 5; + ci.col = 2; + ci.width = 478; + ci.height = 100; + ((JTextAreaInfo)ci).areaWidth = 80; + ((JTextAreaInfo)ci).areaHeight = 10; + ci.isProComponent = true; + fu.allComponentInfos.put(ci.name, ci); + cip21.childComponentInfos.add(ci); + //////////////////////////////////////////// + ci = fu.new ComponentInfo(); + ci.name = "l2161"; + ci.type = "JLabel"; + ci.title = "ίвš"; + ci.row = 6; + ci.col = 1; + fu.allComponentInfos.put(ci.name, ci); + cip21.childComponentInfos.add(ci); + + ci = fu.new JComboBoxInfo(); + ci.name = "ysr8_OriginateDept"; + ci.type = "JComboBox"; + ci.width = 100; + ci.row = 6; + ci.col = 2; + ci.isProComponent = true; + ((JComboBoxInfo)ci).valueType = "lov"; + ((JComboBoxInfo)ci).valueName = "YSR8_department_LOV"; + fu.allComponentInfos.put(ci.name, ci); + cip21.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l2163"; + ci.type = "JLabel"; + ci.title = "ίˡ"; + ci.row = 6; + ci.col = 3; + fu.allComponentInfos.put(ci.name, ci); + cip21.childComponentInfos.add(ci); + + ci = fu.new iTextFieldInfo(); + ci.name = "ysr8_Principal"; + ci.type = "iTextField"; + ci.width = 80; + ci.row = 6; + ci.col = 4; + ci.readOnly = true; + ci.defValType = "sys"; + ci.defVal = "user"; + ci.isProComponent = true; + fu.allComponentInfos.put(ci.name, ci); + cip21.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "l2165"; + ci.type = "JLabel"; + ci.title = "ί "; + ci.row = 6; + ci.col = 5; + fu.allComponentInfos.put(ci.name, ci); + cip21.childComponentInfos.add(ci); + + ci = fu.new ComponentInfo(); + ci.name = "ysr8_CommissionDate"; + ci.type = "DateButton"; + ci.width = 150; + ci.row = 6; + ci.col = 6; + ci.isProComponent = true; + fu.allComponentInfos.put(ci.name, ci); + cip21.childComponentInfos.add(ci); + ////////////////////////////////////////// + + fu.initializeUI(arg0); + loadRendering(); + } + + @Override + public void loadRendering() throws TCException { +//System.out.println("loadForm------------------------start"); + fu.loadRendering(); +//System.out.println("loadForm----------------------end"); + } + + /** + * (non-Javadoc) + * @see com.teamcenter.rac.form.AbstractTCForm#saveForm() + */ + + + + @Override + public void saveRendering() { + try { + fu.saveRendering(); + } catch (TCException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } catch (ParseException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } + } + + @Override + public void displayDialog(AbstractAIFDialog arg0, boolean arg1) { + fu.fitToScreen(arg0); + super.displayDialog(arg0, arg1); + } + + @Override + public void displayDialog(OpenFormDialog arg0, boolean arg1) { + fu.fitToScreen(arg0); + super.displayDialog(arg0, arg1); + } + + public boolean isRenderingModified() { + return fu.isRenderingModified(); + } + +} diff --git a/src/cn/com/ebewin/ysr/form/YSR8_TaskStartRevisionMasterForm.java b/src/cn/com/ebewin/ysr/form/YSR8_TaskStartRevisionMasterForm.java new file mode 100644 index 0000000..b21ac31 --- /dev/null +++ b/src/cn/com/ebewin/ysr/form/YSR8_TaskStartRevisionMasterForm.java @@ -0,0 +1,608 @@ +package cn.com.ebewin.ysr.form; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Vector; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JTable; + +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.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCComponentPseudoFolder; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.iTextField; + +import cn.com.ebewin.ysr.dialog.Show_AddTaskStartDialog; +import cn.com.ebewin.ysr.util.CommonUtil; +import cn.com.ebewin.ysr.util.FormCheckUtil; +import cn.com.ebewin.ysr.util.FormUtil; +import cn.com.ebewin.ysr.util.POIUtil07; +import cn.com.ebewin.ysr.util.TCUtil; + +public class YSR8_TaskStartRevisionMasterForm extends AbstractRendering { + private static final long serialVersionUID = 1L; + private static Date refreshDate = null; + + FormUtil fu = new FormUtil(this); + FormCheckUtil fcu = null; + + String projectCode = ""; + int beforeSelect_a0311111 = -1; + + public YSR8_TaskStartRevisionMasterForm(TCComponentForm arg0) throws Exception { + super(arg0); + + Date currDate = new Date(); + if (refreshDate == null) { + arg0.refresh(); + refreshDate = currDate; + } else { + long diff = currDate.getTime() - refreshDate.getTime(); + long minutes = diff / 1000 / 60; + if (minutes >= 1) { + arg0.refresh(); + refreshDate = currDate; + } + } + + fu.readRenderingXML("YSR8_TaskStartRevisionMasterForm"); + fu.initializeUI(arg0); + + setComboBoxValue_ysr8_SubProjectCode(arg0); + + addActionListener(); + loadRendering(); + getDefVal(); + + } + + @Override + public void loadRendering() throws TCException { + fu.loadRendering(); + + fcu = new FormCheckUtil(fu.tcForm, fu.allComponentMap); + fcu.checkHandler(); + } + + public void setRenderingReadOnly() { + setModifiableComponents(this, false); + if (getController() != null) + getController().setFormReadOnly(); + // TODO ťһֱ b.031.12.51 + JButton btn = (JButton) fu.allComponentMap.get("b.031.12.51"); + btn.setEnabled(true); + } + + public void setRenderingReadWrite() { + if (fcu != null && fcu.isNeedCheck()) { + fcu.setEnable(); + return; + } + setModifiableComponents(this, true); + } + + private void setModifiableComponents(java.awt.Component currcomponent, boolean flag) { + if (fcu != null && flag) { + if (fcu.isNeedCheck()) { + return; + } + } + fu.setModifiableComponents(currcomponent, flag); + } + + /** + * (non-Javadoc) + * + * @see com.teamcenter.rac.form.AbstractTCForm#saveForm() + */ + @Override + public void saveRendering() { + if (!checkCanSave()) { + return; + } + + try { + fu.saveRendering(); + } catch (TCException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } catch (ParseException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } + } + + public boolean isRenderingModified() { + return fu.isRenderingModified(); + } + + @SuppressWarnings("unchecked") + private void addActionListener() { + { + JComboBox cbx = (JComboBox) fu.allComponentMap.get("ysr8_SubProjectCode"); + cbx.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent itemevent) { + if (itemevent.getStateChange() == ItemEvent.SELECTED) { + ChangeComboBoxState_ysr8_SubProjectCode(); + } + } + }); + } + { + // + JButton btn = (JButton) fu.allComponentMap.get("b.031.12.11"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.031.11.11"); + new Thread(new Show_AddTaskStartDialog(ci, "", 1,(JComboBox) fu.allComponentMap.get("ysr8_SubProjectCode"))).start(); + //new Show_AddTaskStartDialog((JDialog) YSR8_TaskStartRevisionMasterForm.this.getParent(),ci, "", 1,(JComboBox) fu.allComponentMap.get("ysr8_SubProjectCode")).show(); + // Object[] objData = new + // Object[ci.childComponentInfos.size()]; + + // for (int i = 0; i < objData.length; i++) { + // objData[i] = ""; + // } + // ci.dataTableModel.addRow(objData); + } + }); + btn = (JButton) fu.allComponentMap.get("b.031.12.111"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.031.11.11"); + if (ci.dataTable.getSelectedRow() < 0) { + MessageBox.post("ѡһݺٽС༭", "", MessageBox.WARNING); + return; + } + new Thread(new Show_AddTaskStartDialog(ci, "༭", 3, (JComboBox) fu.allComponentMap.get("ysr8_SubProjectCode"))).start(); + //new Show_AddTaskStartDialog((JDialog) YSR8_TaskStartRevisionMasterForm.this.getParent(),ci, "༭", 3, (JComboBox) fu.allComponentMap.get("ysr8_SubProjectCode")).show(); + // Object[] objData = new + // Object[ci.childComponentInfos.size()]; + + // for (int i = 0; i < objData.length; i++) { + // objData[i] = ""; + // } + // ci.dataTableModel.addRow(objData); + } + }); + btn = (JButton) fu.allComponentMap.get("b.031.12.21"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.031.11.11"); + JTable table = (JTable) fu.allComponentMap.get("a.031.11.11"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪƳУ", "ʾ", MessageBox.INFORMATION); + return; + } + for (int i = rows.length - 1; i >= 0; i--) { + ci.dataTableModel.removeRow(rows[i]); + } + } + }); + btn = (JButton) fu.allComponentMap.get("b.031.12.31"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + //FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.031.11.11"); + JTable table = (JTable) fu.allComponentMap.get("a.031.11.11"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪƵУ", "ʾ", MessageBox.INFORMATION); + return; + } + beforeSelect_a0311111 = rows[0]; + } + }); + btn = (JButton) fu.allComponentMap.get("b.031.12.41"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo) fu.allComponentInfos.get("a.031.11.11"); + JTable table = (JTable) fu.allComponentMap.get("a.031.11.11"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪճУ", "ʾ", MessageBox.INFORMATION); + return; + } + if (beforeSelect_a0311111 < 0) { + MessageBox.post("ѡҪƵУ", "ʾ", MessageBox.INFORMATION); + return; + } + //Object[] objData = new Object[ci.childComponentInfos.size()]; + for (int i = 0; i < ci.childComponentInfos.size(); i++) { + table.setValueAt(table.getValueAt(beforeSelect_a0311111, i), rows[0], i); + } + } + }); + btn = (JButton) fu.allComponentMap.get("b.031.12.51"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + String modelId = fu.session.getPreferenceService().getStringValue("YSR8_TaskStart_EXCEL_ID"); + if (modelId == null || "".equals(modelId)) { + MessageBox.post("ѡYSR8_TaskStart_EXCEL_ID", "ʾ", MessageBox.INFORMATION); + return; + } + System.out.println("ʼExcel"); + try { + exportToExcel(modelId, component); + System.out.println(""); + } catch (Exception e1) { + MessageBox.post("Excelˣ\n" + e1.getMessage(), "ʾ", MessageBox.INFORMATION); + e1.printStackTrace(); + } + } + }); + } + // //////////////////////////////////////////////////// + + } + + // kk export to excel + protected void exportToExcel(String modelId, TCComponent component) throws Exception { + TCComponent comp = fu.session.stringToComponent(modelId); + if (comp == null) { + throw new TCException("ѡYSR8_TaskStart_EXCEL_ID"); + } + if (!"MSExcelX".equals(comp.getType())) { + throw new TCException("ѡYSR8_TaskStart_EXCEL_ID\n" + comp + "MSExcelXݼ"); + } + TCComponentDataset dataset = (TCComponentDataset) comp; + String[] fileNames = dataset.getFileNames("excel"); + if (fileNames.length == 0) { + throw new Exception("Ŀģ" + dataset + "ݼûҵexcelļ"); + } + if (fileNames.length > 1) { + throw new Exception("Ŀģ" + dataset + "ݼ´ڶexcelļϵԱ"); + } + Date date = new Date(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + String time = sdf.format(date); + String toPath = System.getProperty("java.io.tmpdir") + "ί" + time + ".xlsx"; + File targetFile = new File(toPath); + if (!targetFile.exists()) { + if (!targetFile.createNewFile()) { + throw new TCException("ļʧ:" + toPath); + } + } + File tempFile = dataset.getFile("excel", fileNames[0], System.getProperty("java.io.tmpdir"));// get temp file + FileInputStream input = null; + FileOutputStream output = null; + try { + input = new FileInputStream(tempFile); + XSSFWorkbook wb = new XSSFWorkbook(input); + XSSFSheet sheet = wb.getSheetAt(0); + writeData(wb, sheet, component); + output = new FileOutputStream(targetFile); + wb.write(output); + // 򿪵ıļ + Runtime.getRuntime().exec("cmd /c \"" + toPath + "\""); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + if (output != null) { + try { + output.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + /** + * תLOV + * + * @param tcsession + * @param s + * @return + */ + public TCComponentListOfValues findLOVByName(TCSession tcsession, String s) { + TCComponentListOfValues tccomponentlistofvalues = null; + try { + TCComponentListOfValuesType tccomponentlistofvaluestype = (TCComponentListOfValuesType) tcsession.getTypeComponent("ListOfValues"); + TCComponentListOfValues atccomponentlistofvalues[] = tccomponentlistofvaluestype.find(s); + if (atccomponentlistofvalues != null && atccomponentlistofvalues.length > 0) + tccomponentlistofvalues = atccomponentlistofvalues[0]; + else + tccomponentlistofvalues = null; + } catch (TCException tcexception) { + tccomponentlistofvalues = null; + } + return tccomponentlistofvalues; + } + + private void writeData(XSSFWorkbook wb, XSSFSheet sheet, TCComponent component) throws Exception { + if (!(component instanceof TCComponentForm)) { + return; + } + // prepare data + // ///////////////////////////////////// + TCComponentForm form = (TCComponentForm) component; + // List Props + String[] subProjectCode = form.getTCProperty("ysr8_SubProjectCode").getStringArrayValue(); + String[] taskEquipName = form.getTCProperty("ysr8_TaskEquipName").getStringArrayValue(); + String[] count = form.getTCProperty("ysr8_Count").getStringArrayValue(); + String[] taskDesignType = form.getTCProperty("ysr8_TaskDesignType").getStringArrayValue(); + String[] taskReason = form.getTCProperty("ysr8_TaskReason").getStringArrayValue(); + String[] recommendPlace = form.getTCProperty("ysr8_ChoiceUnit").getStringArrayValue(); + String[] taskUnitRank = form.getTCProperty("ysr8_TaskUnitRank").getStringArrayValue(); + String[] projectFamiliarity = form.getTCProperty("ysr8_ProjectFamiliarity").getStringArrayValue(); + String[] manageRank = form.getTCProperty("ysr8_ManageRank").getStringArrayValue(); + // lovs + TCComponentListOfValues taskDesignTypeLov = findLOVByName(fu.session, "YSR8_TaskDesignType_LOV"); + TCComponentListOfValues taskUnitRankLov = findLOVByName(fu.session, "YSR8_TaskUnitRank_LOV"); + TCComponentListOfValues projectFamiliarityLov = findLOVByName(fu.session, "YSR8_ProjectFamiliarity_LOV"); + TCComponentListOfValues manageRankLov = findLOVByName(fu.session, "YSR8_ManageRank_LOV"); + int rowCnt = 0; + rowCnt = subProjectCode.length > rowCnt ? subProjectCode.length : rowCnt; + rowCnt = taskEquipName.length > rowCnt ? taskEquipName.length : rowCnt; + rowCnt = count.length > rowCnt ? count.length : rowCnt; + rowCnt = taskDesignType.length > rowCnt ? taskDesignType.length : rowCnt; + rowCnt = taskReason.length > rowCnt ? taskReason.length : rowCnt; + rowCnt = recommendPlace.length > rowCnt ? recommendPlace.length : rowCnt; + rowCnt = taskUnitRank.length > rowCnt ? taskUnitRank.length : rowCnt; + rowCnt = projectFamiliarity.length > rowCnt ? projectFamiliarity.length : rowCnt; + rowCnt = manageRank.length > rowCnt ? manageRank.length : rowCnt; + // String Props + String projectManager = form.getProperty("ysr8_ProjectManager"); + String projectCode = form.getProperty("ysr8_ProjectCode"); + String projectName = form.getProperty("ysr8_ProjectName"); + String declarationDate = form.getProperty("ysr8_DeclarationDate"); + String planFinishDate = form.getProperty("ysr8_PlanFinishDate"); + String declaration = form.getProperty("ysr8_Declaration"); + // bottom table + String[] propNames = new String[] { "ysr8_SystemApprover", "ysr8_SystemApproveDate", "ysr8_SystemConfirm", "ysr8_DesignApprover", "ysr8_DesignApproveDate", "ysr8_DesignConfirm", + "ysr8_TechApprover", "ysr8_TechApproveDate", "ysr8_TechConfirm", "ysr8_PurchApprover", "ysr8_PurchApproveDate", "ysr8_PurchConfirm", "ysr8_EngineApprover", "ysr8_EngineApproveDate", + "ysr8_EngineConfirm" }; + String[] approveData = form.getProperties(propNames); + // adjust Excel- + // ////////////////////////////////////// + int rowToAdd = (rowCnt - 4 > 0) ? (rowCnt - 4) : 0; + if (rowToAdd > 0) { + POIUtil07.insertRow(wb, sheet, 8, rowCnt - 4); + } + // write data + XSSFRow row = null; + //XSSFCell cell = null; + // ////////////////////////////////////// + // write head + row = sheet.getRow(2); + setCellData(row, 1, projectManager); + setCellData(row, 3, projectCode); + setCellData(row, 6, projectName); + row = sheet.getRow(3); + setCellData(row, 1, declarationDate); + setCellData(row, 3, planFinishDate); + setCellData(row, 6, declaration); + // write subproject + int startRow = 5; + for (int i = 0; i < rowCnt; i++) { + row = sheet.getRow(startRow + i); + setCellData(row, 1, projectName); + } + writeColumn(startRow, 0, sheet, subProjectCode); + writeColumn(startRow, 2, sheet, taskEquipName); + writeColumn(startRow, 3, sheet, count); + writeColumn(startRow, 4, sheet, taskDesignType,taskDesignTypeLov); + writeColumn(startRow, 5, sheet, taskReason); + writeColumn(startRow, 6, sheet, recommendPlace); + writeColumn(startRow, 7, sheet, taskUnitRank,taskUnitRankLov); + writeColumn(startRow, 8, sheet, projectFamiliarity,projectFamiliarityLov); + writeColumn(startRow, 9, sheet, manageRank,manageRankLov); + // write approvers + startRow = 12 + rowToAdd; + row = sheet.getRow(startRow); + setCellData(row, 1, approveData[0]); + setCellData(row, 3, approveData[1]); + setCellData(row, 6, approveData[2]); + row = sheet.getRow(startRow + 1); + setCellData(row, 1, approveData[3]); + setCellData(row, 3, approveData[4]); + setCellData(row, 6, approveData[5]); + row = sheet.getRow(startRow + 2); + setCellData(row, 1, approveData[6]); + setCellData(row, 3, approveData[7]); + setCellData(row, 6, approveData[8]); + row = sheet.getRow(startRow + 3); + setCellData(row, 1, approveData[9]); + setCellData(row, 3, approveData[10]); + setCellData(row, 6, approveData[11]); + row = sheet.getRow(startRow + 4); + setCellData(row, 1, approveData[12]); + setCellData(row, 3, approveData[13]); + setCellData(row, 6, approveData[14]); + + } + + private void writeColumn(int startRow, int col, XSSFSheet sheet, String[] data, TCComponentListOfValues lov) { + if (lov != null) { + try { + ListOfValuesInfo lovinfo = lov.getListOfValues(); + for(int i=0;i 0)) { + return; + } + TCComponentItemRevision taskStartRevision = (TCComponentItemRevision) context1[0].getComponent(); + TCComponentItem taskStartItem = taskStartRevision.getItem(); + String item_idVal = taskStartItem.getProperty("item_id"); + Vector itemIdPart = CommonUtil.split2Vector(item_idVal, "_"); + if (itemIdPart.size() > 1) { + for (int i = 0; i < itemIdPart.size() - 1; i++) { + projectCode += itemIdPart.get(i); + if (i + 1 == itemIdPart.size() - 1) { + + } else { + projectCode += "_"; + } + } + } + } + + //JComboBoxInfo ci = (JComboBoxInfo) fu.allComponentInfos.get("ysr8_SubProjectCode"); + JComboBox cbx = (JComboBox) fu.allComponentMap.get("ysr8_SubProjectCode"); + TCComponentItem systemPartsItem = TCUtil.findItemByID(fu.session, projectCode); + if (systemPartsItem == null) { + return; + } + TCComponentItemRevision systemPartsRevision = systemPartsItem.getLatestItemRevision(); + TCComponentPseudoFolder folder = TCUtil.getRevisionPseudoFolder(systemPartsRevision, "ͼ"); + if (folder == null) { + return; + } + AIFComponentContext[] comps = folder.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 objType = comp.getProperty("object_type"); + if (objType.equals("еĿ") || objType.equals("Ŀ")) { + cbx.addItem(comp.getProperty("item_id")); + } + } + } + } + // String ysr8_SubProjectCodeVal = + // fu.tcForm.getProperty("ysr8_SubProjectCode"); + // if (!ysr8_SubProjectCodeVal.equals("")) { + // cbx.setSelectedItem(ysr8_SubProjectCodeVal); + // } + } catch (TCException e1) { + e1.printStackTrace(); + } + } + + @SuppressWarnings("unchecked") + private void ChangeComboBoxState_ysr8_SubProjectCode() { + try { + JComboBox cbx = (JComboBox) fu.allComponentMap.get("ysr8_SubProjectCode"); + String ysr8_SubProjectCodeVal = cbx.getSelectedItem().toString(); + TCComponentItem item = TCUtil.findItemByID(fu.session, ysr8_SubProjectCodeVal); + if (item == null) { + return; + } + + JTable table = (JTable) fu.allComponentMap.get("a.031.11.11"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + return; + } + table.setValueAt(item.getProperty("object_name"), rows[0], 1); + } catch (TCException e1) { + e1.printStackTrace(); + } + } + + public void getDefVal() { + try { + if (!fu.tcForm.getStringProperty("ysr8_ProjectCode").equals("")) { + return; + } + + iTextField textfieldForm; + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ProjectCode"); + textfieldForm.setText(projectCode); + + TCComponentItem xmqdItem = TCUtil.findItemByID(fu.session, projectCode + "_XMQD"); + if (xmqdItem != null) { + TCComponentItemRevision xmqdRevision = xmqdItem.getLatestItemRevision(); + TCComponentForm xmqdForm = TCUtil.getItemRevisionMasterForm(xmqdRevision); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ProjectName"); + textfieldForm.setText(xmqdForm.getProperty("ysr8_ProjectName")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ProjectManager"); + textfieldForm.setText(xmqdForm.getProperty("ysr8_ProjectManager")); + } + + } catch (TCException ex) { + ex.printStackTrace(); + } + } + + public boolean checkCanSave() { + return true; + } +} diff --git a/src/cn/com/ebewin/ysr/form/YSR8_TravelORDENRevisionMasterForm.java b/src/cn/com/ebewin/ysr/form/YSR8_TravelORDENRevisionMasterForm.java new file mode 100644 index 0000000..3a72dc3 --- /dev/null +++ b/src/cn/com/ebewin/ysr/form/YSR8_TravelORDENRevisionMasterForm.java @@ -0,0 +1,511 @@ +package cn.com.ebewin.ysr.form; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; +import java.util.Vector; + +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextField; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.text.Document; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.commands.open.OpenFormDialog; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCFormProperty; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.iTextField; + +import cn.com.ebewin.ysr.dialog.SelectUserDialog; +import cn.com.ebewin.ysr.util.FormCheckUtil; +import cn.com.ebewin.ysr.util.FormUtil; +import cn.com.ebewin.ysr.util.TCUtil; + +public class YSR8_TravelORDENRevisionMasterForm extends AbstractRendering { + private static final long serialVersionUID = 1L; + private static Date refreshDate = null; + + String projectCode = ""; + FormUtil fu = new FormUtil(this); + FormCheckUtil fcu = null; + TCComponentForm form = null; + + Vector> vecUserNameData = null; + + public YSR8_TravelORDENRevisionMasterForm(TCComponentForm arg0) throws Exception { + super(arg0); + form =arg0; + + Date currDate = new Date(); + if (refreshDate == null) { + arg0.refresh(); + refreshDate = currDate; + } else { + long diff = currDate.getTime() - refreshDate.getTime(); + long minutes = diff / 1000 / 60; + if (minutes >= 1) { + arg0.refresh(); + refreshDate = currDate; + } + } + + fu.readRenderingXML("YSR8_TravelORDENRevisionMasterForm"); + + fu.initializeUI(arg0); + addActionListener(); + loadRendering(); + getDefVal(); + } + + @Override + public void loadRendering() throws TCException { +// @SuppressWarnings("unchecked") +// JComboBox cbx = (JComboBox) fu.allComponentMap.get("ysr8_UserName"); +// for (Iterator> iterator = vecUserNameData.iterator(); iterator.hasNext();) { +// Hashtable hashtable = (Hashtable) iterator.next(); +// cbx.addItem(hashtable.get("PID").toString()); +// } + fu.loadRendering(); + iTextField textfieldForm; + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_Principal"); + String ysr8_PrincipalVal = textfieldForm.getText(); + if (!ysr8_PrincipalVal.equals("")) { + TCComponentUser user = TCUtil.findUserById(fu.session, ysr8_PrincipalVal); + if (user != null) { + ysr8_PrincipalVal = user.getRelatedComponent("person").getProperty("user_name"); + textfieldForm.setText(ysr8_PrincipalVal); + } + } + String user_name = form.getProperty("ysr8_UserName"); + JButton UserName = (JButton) fu.allComponentMap.get("UserName"); + Font f=new Font("",Font.BOLD,16); + UserName.setFont(f); + if(user_name.equals("")) { + UserName.setText("ѡԱ"); + } else + UserName.setText(user_name); + + fcu = new FormCheckUtil(fu.tcForm, fu.allComponentMap); + fcu.checkHandler(); + } + + @Override + public void displayDialog(OpenFormDialog openFormDialog, boolean bl) { + fu.fitToScreen(openFormDialog); + super.displayDialog(openFormDialog, bl); + } + + @Override + public void displayDialog(AbstractAIFDialog abstractAIFDialog, boolean bl) { + fu.fitToScreen(abstractAIFDialog); + super.displayDialog(abstractAIFDialog, bl); + } + + public void setRenderingReadOnly() { + setModifiableComponents(this, false); + if (getController() != null) + getController().setFormReadOnly(); + } + + public void setRenderingReadWrite() { + if (fcu != null && fcu.isNeedCheck()) { + fcu.setEnable(); + return; + } + setModifiableComponents(this, true); + //fu.allComponentMap.get("ysr8_Receipt").setEnabled(false); + } + + private void setModifiableComponents(java.awt.Component currcomponent, boolean flag) { + if (fcu != null && flag) { + if (fcu.isNeedCheck()) { + return; + } + } + fu.setModifiableComponents(currcomponent, flag); + } + + @Override + public void saveRendering() { + if (!checkCanSave()) { + return; + } + + try { + + JButton UserName = (JButton) fu.allComponentMap.get("UserName"); + TCFormProperty ysr8_UserName = (TCFormProperty)form.getFormTCProperty("ysr8_UserName"); + if(!UserName.getText().equals("ѡԱ")) + ysr8_UserName.setStringValue(UserName.getText()); + fu.saveRendering(); + } catch (TCException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } catch (ParseException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } + } + + public boolean isRenderingModified() { + return fu.isRenderingModified(); + } + + private void addActionListener() { + String sql = String.format("SELECT PID, PSM01 FROM picm0 WHERE PCID = 'gyzh'"); + vecUserNameData = TCUtil.getDBInfo3(fu.session, sql); + { +// JComboBox cbx = (JComboBox) fu.allComponentMap.get("ysr8_UserName"); +// cbx.addItemListener(new ItemListener() { +// @Override +// public void itemStateChanged(ItemEvent itemevent) { +// if (itemevent.getStateChange() == ItemEvent.SELECTED) { +// JComboBox cbx = (JComboBox) fu.allComponentMap.get("ysr8_UserName"); +// String userName = cbx.getSelectedItem().toString(); +// for (Iterator> iterator = vecUserNameData.iterator(); iterator.hasNext();) { +// Hashtable hashtable = (Hashtable) iterator.next(); +// if (hashtable.get("PID").toString().equals(userName)) { +// iTextField textfieldForm; +// textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_EngineerDebug"); +// textfieldForm.setText(hashtable.get("PSM01").toString()); +// } +// } +// } +// } +// }); + final JButton UserName = (JButton) fu.allComponentMap.get("UserName"); + final iTextField textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_EngineerDebug"); + UserName.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + final JDialog dialog = new JDialog(); + dialog.setLayout(new BorderLayout()); + JPanel panel = new JPanel(); + JLabel nameLabel = new JLabel(""); + nameLabel.setSize(60,20); + panel.add(nameLabel); + final JTextField nameText = new JTextField(15); + panel.add(nameText); + nameText.requestFocus(); + final JPanel panel2 = new JPanel(); + panel2.setSize(500, 400); + panel2.setLayout(new FlowLayout()); +// int i = 0, j=0; + final Vector buttons = new Vector(); + for (Iterator> iterator = vecUserNameData.iterator(); iterator.hasNext(); ) { + final Hashtable hashtable = (Hashtable) iterator.next(); + JButton button = new JButton(hashtable.get("PID").toString()); +// if(i>420) { +// i = 0; +// j = j + 32; +// } +// button.setBounds(i+2, j+10, 70, 30); +// button.setSize(70, 30); + button.setPreferredSize(new Dimension(70, 30)); + button.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + UserName.setText(hashtable.get("PID").toString()); + textfieldForm.setText(hashtable.get("PSM01").toString()); + dialog.dispose(); + } + }); + panel2.add(button); + buttons.add(button); + } + Document document = nameText.getDocument(); + document.addDocumentListener(new DocumentListener() { + + @Override + public void insertUpdate(DocumentEvent e) { +// System.out.println("insert"); + panel2.removeAll(); + for (final JButton button : buttons) { + if(!nameText.getText().equals("") && button.getText().indexOf(nameText.getText()) >= 0) { + panel2.add(button); + } + } + int width=dialog.getWidth(); + int height=dialog.getHeight(); + dialog.pack(); + dialog.setSize(width, height); + } + + @Override + public void removeUpdate(DocumentEvent e) { + panel2.removeAll(); + for (final JButton button : buttons) { + if(button.getText().indexOf(nameText.getText()) >= 0 || nameText.getText().equals("")) { + panel2.add(button); + } + } + int width=dialog.getWidth(); + int height=dialog.getHeight(); + dialog.pack(); + dialog.setSize(width, height); + } + + @Override + public void changedUpdate(DocumentEvent e) { + + } + + }); + + JScrollPane scroll = new JScrollPane(panel2); + panel2.setPreferredSize(new Dimension(455, 400)); +// scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + dialog.add(panel, BorderLayout.NORTH); + dialog.add(scroll, BorderLayout.CENTER); + dialog.setBounds(600, 200, 490, 500); +// dialog.setModal(true); + dialog.setVisible(true); + } + }); + } + { + JButton btn = (JButton) fu.allComponentMap.get("k.b.071.23"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + SelectDebugPersons(); + } + }); + } + { + JButton btn = (JButton) fu.allComponentMap.get("b.071.23"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + SelectPurchPersons(); + } + }); + } + { + JButton btn = (JButton) fu.allComponentMap.get("b.071.26"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + SelectTravelPersons(); + } + }); + } + { + final JCheckBox ysr8_Part1 = (JCheckBox) fu.allComponentMap.get("ysr8_Part1"); + final JCheckBox ysr8_Part2 = (JCheckBox) fu.allComponentMap.get("ysr8_Part2"); + ysr8_Part1.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if(ysr8_Part1.isSelected()) + ysr8_Part2.setSelected(false); + } + }); + ysr8_Part2.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if(ysr8_Part2.isSelected()) + ysr8_Part1.setSelected(false); + } + }); + } + } + + public void getDefVal() { + + iTextField textfield = (iTextField) fu.allComponentMap.get("ysr8_ProjectCode"); + this.projectCode = textfield.getText().toString(); + if (!projectCode.equals("")) { + return; + } + + TCComponentItemRevision itemRevision = null; + projectCode = ""; + try { + // ȡ汾 + AIFComponentContext[] context = fu.tcForm.whereReferencedByTypeRelation(new String[] { "YSR8_TravelORDENRevision" }, new String[] { "IMAN_master_form" }); + if (context != null && context.length > 0) { + itemRevision = (TCComponentItemRevision) context[0].getComponent(); + + // ȡItem + TCComponentItem travelORDENItem = itemRevision.getItem(); + + AIFComponentContext[] contextFolder = travelORDENItem.whereReferenced(); + if (contextFolder == null || contextFolder.length <= 0) { + return; + } + TCComponentFolder folder = null; + for (int i = 0; i < contextFolder.length; i++) { + if (contextFolder[i].getComponent() instanceof TCComponentFolder) { + folder = (TCComponentFolder) contextFolder[i].getComponent(); + projectCode = folder.getProperty("project_ids"); + break; + } + } + if (folder == null || projectCode.equals("")) { + return; + } + + textfield = (iTextField) fu.allComponentMap.get("ysr8_ProjectCode"); + textfield.setText(projectCode); + + //lidy20180828ĿȡBUG +// textfield = (iTextField) fu.allComponentMap.get("Project_Name"); +// textfield.setText(travelORDENItem.getProperty("item_id")); + + } + + if (projectCode.equals("")) { + return; + } + + List propList = new ArrayList(); + propList.add("ysr8_ProjectName"); + propList.add("ysr8_CustomerName"); + propList.add("ysr8_ProjectManager"); + propList.add("ysr8_Planner"); + + HashMap propValueMap = new HashMap(); + + TCComponentItem xmqdItem = TCUtil.findItemByID(fu.session, projectCode + "_XMQD"); + if (xmqdItem == null) { + return; + } + TCComponentItemRevision xmqdRevision = xmqdItem.getLatestItemRevision(); + TCComponentForm xmqdForm = TCUtil.getItemRevisionMasterForm(xmqdRevision); + + for (String prop : propList) { + String propValue = ""; + TCFormProperty property1 = (TCFormProperty) xmqdForm.getFormTCProperty(prop); + switch (property1.getPropertyType()) { + case TCProperty.PROP_string: + case TCProperty.PROP_long_string: + propValue = xmqdForm.getStringProperty(prop); + break; + case TCProperty.PROP_short: + case TCProperty.PROP_int: + propValue = Integer.toString(xmqdForm.getIntProperty(prop)); + break; + case TCProperty.PROP_double: + case TCProperty.PROP_float: + propValue = fu.getDoubleString(xmqdForm.getDoubleProperty(prop)); + break; + case TCProperty.PROP_date: + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date date = xmqdForm.getDateProperty(prop); + if (date != null) { + propValue = sdf.format(date); + } + break; + default: + propValue = xmqdForm.getStringProperty(prop); + break; + } + propValueMap.put(prop, propValue); + } + + iTextField textfieldForm; + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ProjectName"); + textfieldForm.setText(propValueMap.get("ysr8_ProjectName")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_CustomerName"); + textfieldForm.setText(propValueMap.get("ysr8_CustomerName")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_ProjectManager"); + textfieldForm.setText(propValueMap.get("ysr8_ProjectManager")); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_Planner"); + textfieldForm.setText(propValueMap.get("ysr8_Planner")); + ; + TCComponentUser user = fu.session.getUser(); + textfieldForm = (iTextField) fu.allComponentMap.get("ysr8_Principal"); + textfieldForm.setText(user.getProperty("user_id")); + + } catch (TCException e) { + e.printStackTrace(); + } + } + + public boolean checkCanSave() { + return true; + } + + public void SelectEngineerDebug() { + @SuppressWarnings("unused") + iTextField textField = (iTextField) fu.allComponentMap.get("ysr8_EngineerDebug"); +// textField = (iTextField) fu.allComponentMap.get("ysr8_UserName"); + } + + public void SelectDebugPersons() { + SelectUserDialog userSelect = new SelectUserDialog(fu.session, "user"); + iTextField iDebugPersons = (iTextField) fu.allComponentMap.get("ysr8_ElecDebug"); + String strTravelPersons = iDebugPersons.getText(); + if (strTravelPersons == null || strTravelPersons.isEmpty()) { + strTravelPersons = userSelect.getValue(); + } else if(userSelect.getValue().equals("")){ + } else { + strTravelPersons += "" + userSelect.getValue(); + } + iDebugPersons.setText(strTravelPersons); + } + + public void SelectPurchPersons() { + SelectUserDialog userSelect = new SelectUserDialog(fu.session, "user"); + iTextField iPurchPersons = (iTextField) fu.allComponentMap.get("ysr8_Purcher"); + String strPurchPersons = iPurchPersons.getText(); + if (strPurchPersons == null || strPurchPersons.isEmpty()) { + strPurchPersons = userSelect.getValue(); + } else if(userSelect.getValue().equals("")){ + } else { + strPurchPersons += "" + userSelect.getValue(); + } + iPurchPersons.setText(strPurchPersons); + } + + public void SelectTravelPersons() { + SelectUserDialog userSelect = new SelectUserDialog(fu.session, "user"); + iTextField iTravelPersons = (iTextField) fu.allComponentMap.get("ysr8_TravelPersons"); + String strTravelPersons = iTravelPersons.getText(); + if (strTravelPersons == null || strTravelPersons.isEmpty()) { + strTravelPersons = userSelect.getValue(); + } else if(userSelect.getValue().equals("")){ + } else { + strTravelPersons += "" + userSelect.getValue(); + } + iTravelPersons.setText(strTravelPersons); + } +// class MyButtonUI extends BasicButtonUI { +// protected void paintText(Graphics g, JComponent c, Rectangle textRect, String text) { +// AbstractButton b = (AbstractButton) c; +// FontMetrics fm = SwingUtilities2.getFontMetrics(c, g); +// int mnemIndex = b.getDisplayedMnemonicIndex(); +// g.setColor(b.getForeground()); +// SwingUtilities2.drawStringUnderlineCharAt(c, g,text,mnemIndex, +// textRect.x, textRect.y + fm.getAscent()); +// } +// } +} diff --git a/src/cn/com/ebewin/ysr/form/YSR8_TravelOrderRevisionMasterForm.java b/src/cn/com/ebewin/ysr/form/YSR8_TravelOrderRevisionMasterForm.java new file mode 100644 index 0000000..8ed5668 --- /dev/null +++ b/src/cn/com/ebewin/ysr/form/YSR8_TravelOrderRevisionMasterForm.java @@ -0,0 +1,156 @@ +package cn.com.ebewin.ysr.form; + +import java.awt.Desktop; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.text.ParseException; +import java.util.Date; + +import javax.swing.JButton; + +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.iTextField; + +import cn.com.ebewin.ysr.dialog.SelectUserDialog; +import cn.com.ebewin.ysr.util.FormUtil; + +public class YSR8_TravelOrderRevisionMasterForm extends AbstractRendering { + private static final long serialVersionUID = 1L; + private static Date refreshDate = null; + + FormUtil fu = new FormUtil(this); + + public YSR8_TravelOrderRevisionMasterForm(TCComponentForm arg0) throws Exception { + super(arg0); + + Date currDate = new Date(); + if (refreshDate == null) { + arg0.refresh(); + refreshDate = currDate; + } else { + long diff = currDate.getTime() - refreshDate.getTime(); + long minutes = diff / 1000 / 60; + if ( minutes >= 1 ) { + arg0.refresh(); + refreshDate = currDate; + } + } + + fu.readRenderingXML("YSR8_TravelOrderRevisionMasterForm"); + fu.initializeUI(arg0); + addActionListener(); + loadRendering(); + getDefVal(); + } + + @Override + public void loadRendering() throws TCException { + fu.loadRendering(); + } + + public void setRenderingReadOnly() + { + setModifiableComponents(this, false); + + if(getController() != null) + getController().setFormReadOnly(); + JButton btn = (JButton)fu.allComponentMap.get("b.111.11"); + btn.setEnabled(true); + if(btn.getParent() != null) + btn.getParent().setEnabled(true); + if(btn.getParent().getParent() != null) + btn.getParent().getParent().setEnabled(true); + } + + public void setRenderingReadWrite() + { + setModifiableComponents(this, true); + JButton btn = (JButton)fu.allComponentMap.get("b.111.11"); + btn.setEnabled(true); + } + + private void setModifiableComponents(java.awt.Component currcomponent, boolean flag) + { + fu.setModifiableComponents(currcomponent, flag); + } + + @Override + public void saveRendering() { + if (!checkCanSave()) { + return; + } + + try { + fu.saveRendering(); + } catch (TCException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } catch (ParseException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } + } + + public boolean isRenderingModified() { + return fu.isRenderingModified(); + } + + private void addActionListener() { + { + JButton btn = (JButton)fu.allComponentMap.get("b.111.11"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + BPM(); + } + }); + + btn = (JButton)fu.allComponentMap.get("b.81.15"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + SelectUser(); + } + }); + + + } + } + + public void getDefVal() { + } + + public boolean checkCanSave() { + return true; + } + + public void SelectUser() { + SelectUserDialog userSelect = new SelectUserDialog(fu.session, "user"); + iTextField iTravelersr = (iTextField)fu.allComponentMap.get("ysr8_Travelers"); + iTravelersr.setText(userSelect.getValue()); + } + + public void BPM() { + try { + final String urlStr = fu.tcForm.getProperty("ysr8_BPMURL_DHTZ"); + if(urlStr != null && !urlStr.equals("")){ + URI uri = new URI(urlStr); + Desktop.getDesktop().browse(uri); + } + } catch (URISyntaxException e) { + e.printStackTrace(); + } catch (TCException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/src/cn/com/ebewin/ysr/form/YSR8_WorkHoursRevisionMasterForm.java b/src/cn/com/ebewin/ysr/form/YSR8_WorkHoursRevisionMasterForm.java new file mode 100644 index 0000000..9af1026 --- /dev/null +++ b/src/cn/com/ebewin/ysr/form/YSR8_WorkHoursRevisionMasterForm.java @@ -0,0 +1,527 @@ +package cn.com.ebewin.ysr.form; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.text.ParseException; +import java.util.Date; +import java.util.Vector; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JTable; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.commands.open.OpenFormDialog; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.iTextField; + +import cn.com.ebewin.ysr.util.FileUtil; +import cn.com.ebewin.ysr.util.FormCheckUtil; +import cn.com.ebewin.ysr.util.FormUtil; +import cn.com.ebewin.ysr.util.TCUtil; +import cn.com.ebewin.ysr.util.UIUtil.JTableInfo; + +@SuppressWarnings("deprecation") +public class YSR8_WorkHoursRevisionMasterForm extends AbstractRendering { + private static final long serialVersionUID = 1L; + private static Date refreshDate = null; + String projectCode = ""; + + FormUtil fu = new FormUtil(this); + Vector deletePic = new Vector(); + FormCheckUtil fcu = null; + + public YSR8_WorkHoursRevisionMasterForm(TCComponentForm arg0) throws Exception { + super(arg0); + + Date currDate = new Date(); + if (refreshDate == null) { + arg0.refresh(); + refreshDate = currDate; + } else { + long diff = currDate.getTime() - refreshDate.getTime(); + long minutes = diff / 1000 / 60; + if ( minutes >= 1 ) { + arg0.refresh(); + refreshDate = currDate; + } + } + + fu.readRenderingXML("YSR8_WorkHoursRevisionMasterForm"); + + getysr8_TravelORDCode(arg0); + + + fu.initializeUI(arg0); + addActionListener(); + getDefVal(); + loadRendering(); + } + + @Override + public void loadRendering() throws TCException { + iTextField textfieldForm; + AIFComponentContext[] context1 = fu.tcForm.whereReferencedByTypeRelation(new String[] {"YSR8_WorkHoursRevision"}, new String[] {"IMAN_master_form"}); + if (context1 != null && context1.length > 0) { + TCComponentItemRevision whRevision = (TCComponentItemRevision)context1[0].getComponent(); + TCComponentItem whItem = whRevision.getItem(); + + textfieldForm = (iTextField)fu.allComponentMap.get("Item_ID"); + textfieldForm.setText(whItem.getProperty("item_id")); + } + + fu.loadRendering(); + + textfieldForm = (iTextField)fu.allComponentMap.get("ysr8_ProjectCode"); + projectCode = textfieldForm.getText(); + + loadPic(); + } + + + + @Override + public void displayDialog(AbstractAIFDialog arg0, boolean arg1) { + fu.fitToScreen(arg0); + super.displayDialog(arg0, arg1); + } + + @Override + public void displayDialog(OpenFormDialog arg0, boolean arg1) { + fu.fitToScreen(arg0); + super.displayDialog(arg0, arg1); + } + + /** + * (non-Javadoc) + * @see com.teamcenter.rac.form.AbstractTCForm#saveForm() + */ + @Override + public void saveRendering() { + if (!checkCanSave()) { + return; + } + + try { + CountTotalHours(); + fu.saveRendering(); + System.out.println("saveRendering"); + saveLocalFile(); + } catch (TCException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } catch (ParseException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return; + } + } + + public boolean isRenderingModified() { + //return fu.isRenderingModified(); + //lidy20180827޸ݼ޷ϴBUG + if (fu.isRenderingModified()) { + return true; + } + if (deletePic.size() > 0) { + return true; + } + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a.41.12.11"); + for (int l = 0; l < ci.dataTableModel.getRowCount(); l++) { + if (ci.dataTableModel.getValueAt(l, 0) == null || + ci.dataTableModel.getValueAt(l, 1) == null) { + continue; + } else { + String sign = ci.dataTableModel.getValueAt(l, 0).toString(); + if (sign.equalsIgnoreCase("")) { + return true; + } + } + } + + return false; + } + + private void addActionListener() { + { + JButton btn = (JButton)fu.allComponentMap.get("b.31.12"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + AddAttachFile(); + } + }); + } + ////////////////////////////////////////////////////// + { + JButton btn = (JButton)fu.allComponentMap.get("b.31.13"); + btn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a.41.12.11"); + JTable table = (JTable)fu.allComponentMap.get("a.41.12.11"); + int[] rows = table.getSelectedRows(); + if (rows == null || rows.length == 0) { + MessageBox.post("ѡҪƳУ", "ʾ", MessageBox.INFORMATION); + return; + } + for (int i = rows.length - 1; i >= 0; i--) { + ci.dataTableModel.removeRow(rows[i]); + } + } + }); + } + } + + private void getDefVal() { +// iTextField textfield = (iTextField)fu.allComponentMap.get("ysr8_ProjectCode"); +// this.projectCode = textfield.getText().toString(); +// if (!projectCode.equals("")) { +// return; +// } +// +// TCComponentItemRevision itemRevision = null; +// projectCode = ""; +// try { +// AIFComponentContext[] context = fu.tcForm.whereReferencedByTypeRelation(new String[] {"YSR8_WorkHoursRevision"}, new String[] {"IMAN_master_form"}); +// if (context != null && context.length > 0) { +// itemRevision = (TCComponentItemRevision)context[0].getComponent(); +// String itemId = itemRevision.getProperty("item_id"); +//System.out.println("itemId-----wlqWorkHours---" + itemId); +// Vector itemIdPart = CommonUtil.split2Vector(itemId, "-"); +// if (itemIdPart.size() > 1) { +// for (int i = 0; i < itemIdPart.size() - 1; i++) { +// projectCode += itemIdPart.get(i); +// if (i + 1 == itemIdPart.size() - 1) { +// +// } else { +// projectCode += "-"; +// } +// } +// textfield = (iTextField)fu.allComponentMap.get("ysr8_ProjectCode"); +// textfield.setText(projectCode); +// } +// } +// +//System.out.println("projectId-----wlqWorkHours---" + projectCode); +// if (projectCode.equals("")) { +// return; +// } +// +// //ȡձ +// textfield = (iTextField)fu.allComponentMap.get("Item_ID"); +// String itemID = textfield.getText().toString(); +// if (itemID.equals("")) { +// +// TCComponentUser user = fu.session.getUser(); +// String user_id = user.getProperty("user_id").toString(); +// +// SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); +// String curDate = sdf.format(new Date()); +// +// itemID = curDate + "-" + user_id; +// +// //textfield.setText(itemID); +// } +// System.out.println("projectId-----wlqWorkHours---" + itemID); +// +// HashMap valMap = new HashMap(); +// TCComponentForm sourceForm = null; +// TCComponentSchedule schedule = TCUtil.findScheduleByID(fu.session, projectCode+"00"); +// if (schedule == null) { +//System.out.println("projectId-----wlqWorkHours1---00"); +// return; +// } +//System.out.println("projectId-----wlqWorkHours1---"); +// sourceForm = (TCComponentForm)TCUtil.getChildComponent(fu.session, schedule, "IMAN_reference", "YSR8_ProjectForm"); +// +//System.out.println("projectId-----wlqWorkHours2---"); +// valMap.put("ysr8_ProjectCode", "ysr8_ProjectCode"); +// //valMap.put("ysr8_ProjectName", "ysr8_ProjectName"); +//// valMap.put("ysr8_ProjectManager", "ysr8_ProjectManager"); +//// valMap.put("ysr8_Planner", "ysr8_Planner"); +//// valMap.put("ysr8_DesignDirector", "ysr8_DesignDirector"); +//// valMap.put("ysr8_ElectricDirector", "ysr8_ElectricDirector"); +//// valMap.put("ysr8_Machiner", "ysr8_Machiner"); +//// valMap.put("ysr8_EngineerDebug", "ysr8_EngineerDebug"); +//// valMap.put("ysr8_ElecDebug", "ysr8_ElecDebug"); +// +// +// if (sourceForm == null) { +// return; +// } +// System.out.println("projectId-----wlqWorkHours3---"); +// for(Entry entry: valMap.entrySet()){ +// String key1 = entry.getKey(); +// String key2 = entry.getValue(); +// +// String propValue = ""; +// TCFormProperty property1 = (TCFormProperty)sourceForm.getFormTCProperty(key1); +// switch (property1.getPropertyType()) { +// case TCProperty.PROP_string: +// case TCProperty.PROP_long_string: +// propValue = sourceForm.getStringProperty(key1); +// break; +// case TCProperty.PROP_short: +// case TCProperty.PROP_int: +// propValue = Integer.toString(sourceForm.getIntProperty(key1)); +// break; +// case TCProperty.PROP_double: +// case TCProperty.PROP_float: +// propValue = new DecimalFormat("#.00").format(sourceForm.getDoubleProperty(key1)); +// break; +// case TCProperty.PROP_date: +// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); +// Date date = sourceForm.getDateProperty(key1); +// if (date != null) { +// propValue = sdf.format(date); +// } +// break; +// default: +// propValue = sourceForm.getStringProperty(key1); +// break; +// } +//System.out.println("key1-----" + key1 + "------key2-----" + key2 + "-----------propValue-----" + propValue); +// +// TCFormProperty property2 = (TCFormProperty)fu.tcForm.getFormTCProperty(key2); +// switch (property2.getPropertyType()) { +// case TCProperty.PROP_string: +// case TCProperty.PROP_long_string: +// fu.tcForm.setStringProperty(key2, propValue); +// break; +// case TCProperty.PROP_short: +// case TCProperty.PROP_int: +// fu.tcForm.setIntProperty(key2, Integer.parseInt(propValue)); +// break; +// case TCProperty.PROP_double: +// case TCProperty.PROP_float: +// fu.tcForm.setDoubleProperty(key2, Double.parseDouble(propValue)); +// break; +// case TCProperty.PROP_date: +// if (!propValue.equals("")) { +// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); +// Date date = sdf.parse(propValue); +// if (date != null) { +// fu.tcForm.setDateProperty(key2, date); +// } +// } +// break; +// default: +// fu.tcForm.setStringProperty(key2, propValue); +// break; +// } +// } +// } catch (TCException ex) { +// ex.printStackTrace(); +// } catch (ParseException ex) { +// ex.printStackTrace(); +// } +// +// +// System.out.println("getDefVal ------------------------------------------"); + } + + public void AddAttachFile() { + //lidy20180827ѹļʽ + String[][] fileTypes = { { ".gif;.bmp;.jpg;.png", "ͼƬļ" }, + { ".doc;.docx;.xls;.xlsx", "Officeļ" }, + { ".zip;.rar", "ѹļ" } + }; + File[] files = FileUtil.openFileChoosers(fileTypes); + if (files == null) { + return; + } + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a.41.12.11"); + int cols = ci.childComponentInfos.size(); + //int nRows = ci.dataTableModel.getRowCount(); + for (int f = 0; f < files.length; f++) { + Object[] objData = new Object[cols]; + //nRows++; + //String sIdx = Integer.toString(nRows); + objData[0] = ""; + objData[1] = files[f].getAbsolutePath(); + ci.dataTableModel.addRow(objData); + } + } + + private void loadPic() { + TCComponentItemRevision itemRevision = null; + TCComponentDataset dataset = null; + try { + AIFComponentContext[] context = fu.tcForm.whereReferencedByTypeRelation(new String[] {"YSR8_WorkHoursRevision"}, new String[] {"IMAN_master_form"}); + if (context != null && context.length > 0) { + itemRevision = (TCComponentItemRevision)context[0].getComponent(); + + TCComponent[] components = itemRevision.getRelatedComponents("IMAN_specification"); + if (components != null && components.length > 0) { + JTableInfo ci = (JTableInfo)fu.allComponentInfos.get("a.41.12.11"); + ci.dataTableModel.getDataVector().clear(); + int cols = ci.childComponentInfos.size(); + for (int i = 0; i < components.length; i++) { + dataset = (TCComponentDataset) components[i]; + String name = dataset.getProperty("object_string"); + + Object[] objData = new Object[cols]; + objData[0] = "ϴ"; + objData[1] = name; + ci.dataTableModel.addRow(objData); + } + } + } + } catch (TCException e1) { + e1.printStackTrace(); + } + } + + @SuppressWarnings({ "unchecked" }) + public boolean checkCanSave() { + DateButton btn = (DateButton)fu.allComponentMap.get("ysr8_DeclarationDate"); + Date dt = btn.getDate(); + if (dt == null) { + MessageBox.post("д[걨]޷棡", "ʾ", MessageBox.INFORMATION); + return false; + } + + JComboBox cbx = (JComboBox)fu.allComponentMap.get("ysr8_WorkPlace"); + String val = cbx.getSelectedItem().toString(); + try { + if (val.equals("")) { + String Item_ID = projectCode + "-TSGH"; + TCComponentItem dbpItem = TCUtil.findItemByID(fu.session, Item_ID); + TCComponentItemRevision dbpRevision = dbpItem.getLatestItemRevision(); + TCComponentForm dbpForm = TCUtil.getItemRevisionMasterForm(dbpRevision); + if (!dbpForm.getStringProperty("ysr8_Check1").equals("1")) { + MessageBox.post("δͨˣύ⹤ձ!", "ʾ", MessageBox.INFORMATION); + return false; + } + //kk TODO 20180711 ձԡԽ׶Ρǩ뱣ʱ߼߼ȡ + /*cbx = (JComboBox)fu.allComponentMap.get("ysr8_DebugPhase"); + val = cbx.getSelectedItem().toString(); + if (val.equals("豸")) { + if (!dbpForm.getStringProperty("ysr8_Check2").equals("1")) { + MessageBox.post("ʩȷϵδͨˣύ豸Թձ!", "ʾ", MessageBox.INFORMATION); + return false; + } + }*/ + } + } catch (TCException e) { + e.printStackTrace(); + return false; + } + + return true; + } + + private void CountTotalHours(){ + iTextField textfield = (iTextField)fu.allComponentMap.get("ysr8_WorkdayHours"); + String ysr8_WorkdayHours = textfield.getText().toString(); + double ysr8_WorkdayHoursDoubleVal = 0.0; + if (!ysr8_WorkdayHours.equals("")) { + ysr8_WorkdayHoursDoubleVal = Double.parseDouble(ysr8_WorkdayHours); + } + + textfield = (iTextField)fu.allComponentMap.get("ysr8_OvertimeHours"); + String ysr8_OvertimeHours = textfield.getText().toString(); + double ysr8_OvertimeHoursDoubleVal = 0.0; + if (!ysr8_OvertimeHours.equals("")) { + ysr8_OvertimeHoursDoubleVal = Double.parseDouble(ysr8_OvertimeHours); + } + + textfield = (iTextField)fu.allComponentMap.get("ysr8_HOvertimeHours"); + String ysr8_HOvertimeHours = textfield.getText().toString(); + double ysr8_HOvertimeHoursDoubleVal = 0.0; + if (!ysr8_HOvertimeHours.equals("")) { + ysr8_HOvertimeHoursDoubleVal = Double.parseDouble(ysr8_HOvertimeHours); + } + + double ysr8_TotalHoursDoubleVal = ysr8_WorkdayHoursDoubleVal + ysr8_OvertimeHoursDoubleVal + ysr8_HOvertimeHoursDoubleVal; + textfield = (iTextField)fu.allComponentMap.get("ysr8_TotalHours"); + textfield.setText(fu.getDoubleString(ysr8_TotalHoursDoubleVal)); + } + + private void saveLocalFile() { + Vector addPic = new Vector(); + FormUtil.JTableInfo ci = (FormUtil.JTableInfo)fu.allComponentInfos.get("a.41.12.11"); + for (int l = 0; l < ci.dataTableModel.getRowCount(); l++) { + if (ci.dataTableModel.getValueAt(l, 0) == null || + ci.dataTableModel.getValueAt(l, 1) == null) { + continue; + } else { + String sign = ci.dataTableModel.getValueAt(l, 0).toString(); + if (sign.equalsIgnoreCase("")) { + String fileName = ci.dataTableModel.getValueAt(l, 1).toString(); + addPic.add(fileName); + } + } + } + + TCComponentItemRevision itemRevision = null; + TCComponentDataset dataset = null; + //String itemId = null; + try { + AIFComponentContext[] context = fu.tcForm.whereReferencedByTypeRelation(new String[] {"YSR8_WorkHoursRevision"}, new String[] {"IMAN_master_form"}); + if (context != null && context.length > 0) { + itemRevision = (TCComponentItemRevision)context[0].getComponent(); + + TCComponent[] components = itemRevision.getRelatedComponents("IMAN_specification"); + if (components != null && components.length > 0) { + for (int i = 0; i < components.length; i++) { + dataset = (TCComponentDataset) components[i]; + String name = dataset.getProperty("object_string"); + for (String pic : deletePic) { + if (pic.equalsIgnoreCase(name)) { + itemRevision.remove("IMAN_specification", dataset); + dataset.delete(); + } + } + } + } + + for (String pic : addPic) { + File file = new File(pic); + TCComponentDataset newDataset = TCUtil.createDataset(fu.session, file, file.getName()); + itemRevision.add("IMAN_specification", new TCComponent[] { newDataset }); + } + } + } catch (TCException e1) { + e1.printStackTrace(); + } + loadPic(); + } + + private void getysr8_TravelORDCode(TCComponentForm tcForm) { + try { + String ysr8_ProjectCodeVal = tcForm.getProperty("ysr8_ProjectCode"); + String[] attrs = new String[1]; + String[] vals = new String[1]; + attrs[0] = "ysr8_ProjectCode"; + vals[0] = ysr8_ProjectCodeVal; + TCComponent[] tcComponents = TCUtil.query(tcForm.getSession(), "SearchTravelORDEN", attrs, vals); + if (tcComponents != null) { + FormUtil.JComboBoxInfo ci = (FormUtil.JComboBoxInfo)fu.allComponentInfos.get("ysr8_TravelORDCode"); + ci.valueType = "list"; + ci.values = new Vector(); + for (int i = 0; i < tcComponents.length; i++) { + TCComponentItemRevision TravelORDENItemRevision = (TCComponentItemRevision)tcComponents[i]; + TCComponentItem TravelORDENItem = TravelORDENItemRevision.getItem(); + //TCComponentForm TravelORDENForm = TCUtil.getItemRevisionMasterForm(TravelORDENItemRevision); + + ci.values.add(TravelORDENItem.getProperty("item_id")); + } + } + } catch (TCException e) { + e.printStackTrace(); + } + } +} diff --git a/src/cn/com/ebewin/ysr/handlers/CustomizationHandler.java b/src/cn/com/ebewin/ysr/handlers/CustomizationHandler.java new file mode 100644 index 0000000..2138a4c --- /dev/null +++ b/src/cn/com/ebewin/ysr/handlers/CustomizationHandler.java @@ -0,0 +1,46 @@ +package cn.com.ebewin.ysr.handlers; + +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.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + +import cn.com.ebewin.ysr.dialog.CustomizationDialog; +import cn.com.ebewin.ysr.dialog.MaterialPurchasingSearchDialog; + +public class CustomizationHandler extends AbstractHandler { + + private AbstractAIFUIApplication app; + private TCSession session; +// private InterfaceAIFComponent target; + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + app = AIFUtility.getCurrentApplication(); + session = (TCSession) app.getSession(); +// target = app.getTargetComponent(); +// if (target == null || !(target instanceof TCComponentFolder)) { +// MessageBox.post(app.getDesktop(), "ѡϵͳĿ¼ļне룡", "λѡ", MessageBox.WARNING); +// return null; +// } + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + try { + new CustomizationDialog(session); + } catch (TCException e) { + e.printStackTrace(); + } + } + }); + + return null; + } + +} diff --git a/src/cn/com/ebewin/ysr/handlers/DebugingInfoHandler.java b/src/cn/com/ebewin/ysr/handlers/DebugingInfoHandler.java new file mode 100644 index 0000000..d78bda5 --- /dev/null +++ b/src/cn/com/ebewin/ysr/handlers/DebugingInfoHandler.java @@ -0,0 +1,46 @@ +package cn.com.ebewin.ysr.handlers; + +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.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + +import cn.com.ebewin.ysr.dialog.YSR8_DebugingInfoDlg; + +public class DebugingInfoHandler extends AbstractHandler { + + private AbstractAIFUIApplication app; + private TCSession session; +// private InterfaceAIFComponent target; + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + app = AIFUtility.getCurrentApplication(); + session = (TCSession) app.getSession(); +// target = app.getTargetComponent(); +// if (target == null || !(target instanceof TCComponentFolder)) { +// MessageBox.post(app.getDesktop(), "ѡϵͳĿ¼ļне룡", "λѡ", MessageBox.WARNING); +// return null; +// } + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + try { + new YSR8_DebugingInfoDlg(session); + //d.setModal(true); + } catch (TCException e) { + e.printStackTrace(); + } + } + }); + + return null; + } + +} diff --git a/src/cn/com/ebewin/ysr/handlers/KBatchImportHandler.java b/src/cn/com/ebewin/ysr/handlers/KBatchImportHandler.java new file mode 100644 index 0000000..64a448c --- /dev/null +++ b/src/cn/com/ebewin/ysr/handlers/KBatchImportHandler.java @@ -0,0 +1,23 @@ +package cn.com.ebewin.ysr.handlers; + +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.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +import cn.com.ebewin.ysr.dialog.KBatchImportDialog; + +public class KBatchImportHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + final TCSession session=(TCSession) AIFUtility.getCurrentApplication().getSession(); + SwingUtilities.invokeLater(new KBatchImportDialog(session)); + return null; + } + +} diff --git a/src/cn/com/ebewin/ysr/handlers/KTestHandler.java b/src/cn/com/ebewin/ysr/handlers/KTestHandler.java new file mode 100644 index 0000000..ee35f6b --- /dev/null +++ b/src/cn/com/ebewin/ysr/handlers/KTestHandler.java @@ -0,0 +1,66 @@ +package cn.com.ebewin.ysr.handlers; + +import java.awt.Dimension; + +import javax.swing.BorderFactory; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.border.TitledBorder; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.util.PropertyLayout; + + +public class KTestHandler extends AbstractHandler{ + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + System.out.println("Let's test"); + showTestDialog(); + return null; + } + + protected void showTestDialog() { + TestDialog dialog=new TestDialog(); + new Thread(dialog).start(); + } + + @SuppressWarnings("serial") + private class TestDialog extends AbstractAIFDialog{ + public TestDialog() { + super(true); + } + + @Override + public void run() { + initUI(); + } + + private void initUI() { + this.setTitle("TEST"); + this.setLayout(new PropertyLayout(10,10,100,100,100,100)); + JLabel l1=new JLabel("T1"); + l1.setPreferredSize(new Dimension(30, 23)); + JLabel l2=new JLabel("T2"); + l2.setPreferredSize(new Dimension(30, 23)); + + JTextField t1=new JTextField(12); + JPanel t2=new JPanel(); + t2.setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), "test")); + t2.setPreferredSize(new Dimension(50, 50)); + this.add("1.1.left.top",l1); + this.add("1.2.left.top",t1); + this.add("1.3.left.top",l2); + this.add("1.4.left.top",t2); + this.showDialog(); + } + + + } + +} diff --git a/src/cn/com/ebewin/ysr/handlers/MachiningDynamicsManageHandler.java b/src/cn/com/ebewin/ysr/handlers/MachiningDynamicsManageHandler.java new file mode 100644 index 0000000..839d9bb --- /dev/null +++ b/src/cn/com/ebewin/ysr/handlers/MachiningDynamicsManageHandler.java @@ -0,0 +1,44 @@ +package cn.com.ebewin.ysr.handlers; + +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.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +import cn.com.ebewin.ysr.dialog.MachiningDynamicsManageDialog; + +public class MachiningDynamicsManageHandler extends AbstractHandler { + + private AbstractAIFUIApplication app; + private TCSession session; +// private InterfaceAIFComponent target; + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + app = AIFUtility.getCurrentApplication(); + session = (TCSession) app.getSession(); +// target = app.getTargetComponent(); +// if (target == null || !(target instanceof TCComponentFolder)) { +// MessageBox.post(app.getDesktop(), "ѡϵͳĿ¼ļне룡", "λѡ", MessageBox.WARNING); +// return null; +// } + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + try { + new MachiningDynamicsManageDialog(session); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + + return null; + } + +} diff --git a/src/cn/com/ebewin/ysr/handlers/MaterialPurchasingSearchHandler.java b/src/cn/com/ebewin/ysr/handlers/MaterialPurchasingSearchHandler.java new file mode 100644 index 0000000..98745ea --- /dev/null +++ b/src/cn/com/ebewin/ysr/handlers/MaterialPurchasingSearchHandler.java @@ -0,0 +1,45 @@ +package cn.com.ebewin.ysr.handlers; + +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.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + +import cn.com.ebewin.ysr.dialog.MaterialPurchasingSearchDialog; + +public class MaterialPurchasingSearchHandler extends AbstractHandler { + + private AbstractAIFUIApplication app; + private TCSession session; +// private InterfaceAIFComponent target; + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + app = AIFUtility.getCurrentApplication(); + session = (TCSession) app.getSession(); +// target = app.getTargetComponent(); +// if (target == null || !(target instanceof TCComponentFolder)) { +// MessageBox.post(app.getDesktop(), "ѡϵͳĿ¼ļне룡", "λѡ", MessageBox.WARNING); +// return null; +// } + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + try { + new MaterialPurchasingSearchDialog(session); + } catch (TCException e) { + e.printStackTrace(); + } + } + }); + + return null; + } + +} diff --git a/src/cn/com/ebewin/ysr/handlers/PMSBRevisionSearchHandler.java b/src/cn/com/ebewin/ysr/handlers/PMSBRevisionSearchHandler.java new file mode 100644 index 0000000..1024ddb --- /dev/null +++ b/src/cn/com/ebewin/ysr/handlers/PMSBRevisionSearchHandler.java @@ -0,0 +1,46 @@ +package cn.com.ebewin.ysr.handlers; + +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.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + +import cn.com.ebewin.ysr.dialog.YSR8_PMSBRevisionSearchDialog; + +public class PMSBRevisionSearchHandler extends AbstractHandler { + + private AbstractAIFUIApplication app; + private TCSession session; +// private InterfaceAIFComponent target; + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + app = AIFUtility.getCurrentApplication(); + session = (TCSession) app.getSession(); +// target = app.getTargetComponent(); +// if (target == null || !(target instanceof TCComponentFolder)) { +// MessageBox.post(app.getDesktop(), "ѡϵͳĿ¼ļне룡", "λѡ", MessageBox.WARNING); +// return null; +// } + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + try { + new YSR8_PMSBRevisionSearchDialog(session); + //d.setModal(true); + } catch (TCException e) { + e.printStackTrace(); + } + } + }); + + return null; + } + +} diff --git a/src/cn/com/ebewin/ysr/handlers/PipingLinePlanningManagementHandler.java b/src/cn/com/ebewin/ysr/handlers/PipingLinePlanningManagementHandler.java new file mode 100644 index 0000000..82c50dc --- /dev/null +++ b/src/cn/com/ebewin/ysr/handlers/PipingLinePlanningManagementHandler.java @@ -0,0 +1,39 @@ +package cn.com.ebewin.ysr.handlers; + +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.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + +import cn.com.ebewin.ysr.dialog.PipingLinePlanningManagementDialog; + +public class PipingLinePlanningManagementHandler extends AbstractHandler { + + private AbstractAIFUIApplication app; + private TCSession session; + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + app = AIFUtility.getCurrentApplication(); + session = (TCSession) app.getSession(); + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + try { + new PipingLinePlanningManagementDialog(session); + } catch (TCException e) { + e.printStackTrace(); + } + } + }); + + return null; + } + +} diff --git a/src/cn/com/ebewin/ysr/handlers/ProblemBoardHandler.java b/src/cn/com/ebewin/ysr/handlers/ProblemBoardHandler.java new file mode 100644 index 0000000..474faf9 --- /dev/null +++ b/src/cn/com/ebewin/ysr/handlers/ProblemBoardHandler.java @@ -0,0 +1,45 @@ +package cn.com.ebewin.ysr.handlers; + +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.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + +import cn.com.ebewin.ysr.dialog.ProblemBoardDialog; + +public class ProblemBoardHandler extends AbstractHandler { + + private AbstractAIFUIApplication app; + private TCSession session; +// private InterfaceAIFComponent target; + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + app = AIFUtility.getCurrentApplication(); + session = (TCSession) app.getSession(); +// target = app.getTargetComponent(); +// if (target == null || !(target instanceof TCComponentFolder)) { +// MessageBox.post(app.getDesktop(), "ѡϵͳĿ¼ļне룡", "λѡ", MessageBox.WARNING); +// return null; +// } + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + try { + new ProblemBoardDialog(session); + } catch (TCException e) { + e.printStackTrace(); + } + } + }); + + return null; + } + +} diff --git a/src/cn/com/ebewin/ysr/handlers/QERevisionSearchHandler.java b/src/cn/com/ebewin/ysr/handlers/QERevisionSearchHandler.java new file mode 100644 index 0000000..f124fa5 --- /dev/null +++ b/src/cn/com/ebewin/ysr/handlers/QERevisionSearchHandler.java @@ -0,0 +1,45 @@ +package cn.com.ebewin.ysr.handlers; + +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.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +import cn.com.ebewin.ysr.dialog.YSR8_QERevisionSearchDialog; + +public class QERevisionSearchHandler extends AbstractHandler { + + private AbstractAIFUIApplication app; + private TCSession session; +// private InterfaceAIFComponent target; + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + app = AIFUtility.getCurrentApplication(); + session = (TCSession) app.getSession(); +// target = app.getTargetComponent(); +// if (target == null || !(target instanceof TCComponentFolder)) { +// MessageBox.post(app.getDesktop(), "ѡϵͳĿ¼ļне룡", "λѡ", MessageBox.WARNING); +// return null; +// } + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + try { + new YSR8_QERevisionSearchDialog(session); + //d.setModal(true); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + + return null; + } + +} diff --git a/src/cn/com/ebewin/ysr/handlers/QualityManagementBoardHandler.java b/src/cn/com/ebewin/ysr/handlers/QualityManagementBoardHandler.java new file mode 100644 index 0000000..09ba22e --- /dev/null +++ b/src/cn/com/ebewin/ysr/handlers/QualityManagementBoardHandler.java @@ -0,0 +1,39 @@ +package cn.com.ebewin.ysr.handlers; + +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.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + +import cn.com.ebewin.ysr.dialog.QualityManagementBoardDialog; + +public class QualityManagementBoardHandler extends AbstractHandler { + + private AbstractAIFUIApplication app; + private TCSession session; + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + app = AIFUtility.getCurrentApplication(); + session = (TCSession) app.getSession(); + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + try { + new QualityManagementBoardDialog(session); + } catch (TCException e) { + e.printStackTrace(); + } + } + }); + + return null; + } + +} diff --git a/src/cn/com/ebewin/ysr/handlers/RectificationPurchasingImportHandler.java b/src/cn/com/ebewin/ysr/handlers/RectificationPurchasingImportHandler.java new file mode 100644 index 0000000..279773c --- /dev/null +++ b/src/cn/com/ebewin/ysr/handlers/RectificationPurchasingImportHandler.java @@ -0,0 +1,45 @@ +package cn.com.ebewin.ysr.handlers; + +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.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + +import cn.com.ebewin.ysr.dialog.RectificationPurchasingImportDialog; + +public class RectificationPurchasingImportHandler extends AbstractHandler { + + private AbstractAIFUIApplication app; + private TCSession session; +// private InterfaceAIFComponent target; + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + app = AIFUtility.getCurrentApplication(); + session = (TCSession) app.getSession(); +// target = app.getTargetComponent(); +// if (target == null || !(target instanceof TCComponentFolder)) { +// MessageBox.post(app.getDesktop(), "ѡϵͳĿ¼ļне룡", "λѡ", MessageBox.WARNING); +// return null; +// } + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + try { + new RectificationPurchasingImportDialog(session); + } catch (TCException e) { + e.printStackTrace(); + } + } + }); + + return null; + } + +} diff --git a/src/cn/com/ebewin/ysr/handlers/ScheduleTaskEditHandler.java b/src/cn/com/ebewin/ysr/handlers/ScheduleTaskEditHandler.java new file mode 100644 index 0000000..748d9f4 --- /dev/null +++ b/src/cn/com/ebewin/ysr/handlers/ScheduleTaskEditHandler.java @@ -0,0 +1,28 @@ +package cn.com.ebewin.ysr.handlers; + +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.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +import cn.com.ebewin.ysr.dialog.ScheduleTaskEditDialog; + +public class ScheduleTaskEditHandler extends AbstractHandler{ + + private AbstractAIFUIApplication app; + private TCSession session; + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + app = AIFUtility.getCurrentApplication(); + session = (TCSession) app.getSession(); + SwingUtilities.invokeLater(new ScheduleTaskEditDialog(app,session)); + return null; + } + +} diff --git a/src/cn/com/ebewin/ysr/handlers/YSR8_DrawingListCreateHandler.java b/src/cn/com/ebewin/ysr/handlers/YSR8_DrawingListCreateHandler.java new file mode 100644 index 0000000..31a1dca --- /dev/null +++ b/src/cn/com/ebewin/ysr/handlers/YSR8_DrawingListCreateHandler.java @@ -0,0 +1,134 @@ +package cn.com.ebewin.ysr.handlers; + +import java.util.HashMap; +import java.util.Map; + +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.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +import cn.com.ebewin.ysr.dialog.YSR8_DrawingListCreateDialog; +import cn.com.ebewin.ysr.util.TCUtil; + +public class YSR8_DrawingListCreateHandler extends AbstractHandler { + + private InterfaceAIFComponent target; + private AbstractAIFUIApplication app; + private TCSession session; + private TCComponentBOMLine bomline; + private TCComponentItemRevision partItemRevision; + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + app = AIFUtility.getCurrentApplication(); + session = (TCSession) app.getSession(); + target = app.getTargetComponent(); + bomline = (TCComponentBOMLine) target; + + try { + partItemRevision = bomline.getItemRevision(); + String objectType = partItemRevision.getItem().getProperty("object_type"); + if (!objectType.equals("еĿ")) { + MessageBox.post(app.getDesktop(), "ѡϵеĿͼĿ¼", "ʾ", MessageBox.WARNING); + return null; + } + String projectId = partItemRevision.getProperty("project_ids"); + if (projectId == null) { + MessageBox.post(app.getDesktop(), "δָɵĿ˶ԣ", "ʾ", MessageBox.WARNING); + return null; + } + + Boolean moreRev = moreRev(bomline); + if (moreRev) { + return null; + } + } catch (TCException e) { + e.printStackTrace(); + } + + + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + try { + new YSR8_DrawingListCreateDialog(session, bomline, partItemRevision); + } catch (TCException e) { + e.printStackTrace(); + } + } + }); + + return null; + } + + private Boolean moreRev(TCComponentBOMLine bomline) { + String lineId = null, preId = null; + try { + Map mapLine = new HashMap(); + Map mapPre = new HashMap(); + lineId = loopLine(bomline, mapLine); + + TCComponent[] revlist = bomline.getItem().getRelatedComponents("revision_list"); + System.out.println("revlist:" + revlist.length); + if (revlist.length > 1) { + TCComponentItemRevision preRev = (TCComponentItemRevision) revlist[revlist.length - 2]; + TCComponentBOMLine preLine = TCUtil.getBOMLine(session, preRev); + preId = loopLine(preLine, mapPre); + } + String message = ""; + if (revlist.length > 1) { + if (lineId != null || preId != null) { + message = (preId + " " + lineId).replace("null", "").replace(" ", ""); + } + } else { + if (lineId != null) { + message = lineId; + } + } + if (message.length() > 0) { + MessageBox.post(app.getDesktop(), "ͬһ㲿汾:" + message, "汾", MessageBox.WARNING); + return true; + } + } catch (TCException e) { + e.printStackTrace(); + } + return false; + } + + private String loopLine(TCComponentBOMLine bomline, Map mapLine) { + AIFComponentContext[] context; + try { + context = bomline.getChildren(); + for (int i = 0; i < context.length; i++) { + bomline = (TCComponentBOMLine) context[i].getComponent(); + String itemId = bomline.getProperty("bl_item_item_id"); + String revId = bomline.getItemRevision().getProperty("item_revision_id"); + if (mapLine.containsKey(itemId)) { + if (!mapLine.get(itemId).equals(revId)) { + return itemId; + } + } else { + mapLine.put(itemId, revId); + } + loopLine(bomline, mapLine); + } + } catch (TCException e) { + e.printStackTrace(); + } + return null; + } + +} diff --git a/src/cn/com/ebewin/ysr/handlers/YSR8_ProjectFormExportHandler.java b/src/cn/com/ebewin/ysr/handlers/YSR8_ProjectFormExportHandler.java new file mode 100644 index 0000000..ed63308 --- /dev/null +++ b/src/cn/com/ebewin/ysr/handlers/YSR8_ProjectFormExportHandler.java @@ -0,0 +1,46 @@ +package cn.com.ebewin.ysr.handlers; + +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.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + +import cn.com.ebewin.ysr.dialog.YSR8_ProjectFormSearchDialog; + +public class YSR8_ProjectFormExportHandler extends AbstractHandler{ + + private AbstractAIFUIApplication app; + private TCSession session; +// private InterfaceAIFComponent target; + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + app = AIFUtility.getCurrentApplication(); + session = (TCSession) app.getSession(); +// target = app.getTargetComponent(); +// if (target == null || !(target instanceof TCComponentFolder)) { +// MessageBox.post(app.getDesktop(), "ѡϵͳĿ¼ļне룡", "λѡ", MessageBox.WARNING); +// return null; +// } + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + try { + new YSR8_ProjectFormSearchDialog(session); + //d.setModal(true); + } catch (TCException e) { + e.printStackTrace(); + } + } + }); + + return null; + } + +} diff --git a/src/cn/com/ebewin/ysr/handlers/YSR8_TotalContentHandler.java b/src/cn/com/ebewin/ysr/handlers/YSR8_TotalContentHandler.java new file mode 100644 index 0000000..0cd3d7c --- /dev/null +++ b/src/cn/com/ebewin/ysr/handlers/YSR8_TotalContentHandler.java @@ -0,0 +1,47 @@ +package cn.com.ebewin.ysr.handlers; + +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.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + +import cn.com.ebewin.ysr.dialog.YSR8_PMSBRevisionSearchDialog; +import cn.com.ebewin.ysr.dialog.YSR8_TotalContentDialog; + +public class YSR8_TotalContentHandler extends AbstractHandler { + + private AbstractAIFUIApplication app; + private TCSession session; +// private InterfaceAIFComponent target; + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + app = AIFUtility.getCurrentApplication(); + session = (TCSession) app.getSession(); +// target = app.getTargetComponent(); +// if (target == null || !(target instanceof TCComponentFolder)) { +// MessageBox.post(app.getDesktop(), "ѡϵͳĿ¼ļне룡", "λѡ", MessageBox.WARNING); +// return null; +// } + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + try { + new YSR8_TotalContentDialog(session); + //d.setModal(true); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + + return null; + } + +} diff --git a/src/cn/com/ebewin/ysr/handlers/YSR8_TravelORDENCreateHandler.java b/src/cn/com/ebewin/ysr/handlers/YSR8_TravelORDENCreateHandler.java new file mode 100644 index 0000000..93532c5 --- /dev/null +++ b/src/cn/com/ebewin/ysr/handlers/YSR8_TravelORDENCreateHandler.java @@ -0,0 +1,99 @@ +package cn.com.ebewin.ysr.handlers; + +import java.util.List; + +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.TCComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +import cn.com.ebewin.ysr.dialog.YSR8_TravelORDENCreateDialog; +import cn.com.ebewin.ysr.util.TCUtil; + +public class YSR8_TravelORDENCreateHandler extends AbstractHandler { + + private AbstractAIFUIApplication app; + private TCSession session; + private InterfaceAIFComponent target; + private String projectCode; + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + app = AIFUtility.getCurrentApplication(); + session = (TCSession) app.getSession(); + target = app.getTargetComponent(); + try { + if (target == null || !(target instanceof TCComponentFolder)||!target.getProperty("object_name").equals("8ίе")) { + MessageBox.post(app.getDesktop(), "ѡίеļнд", "λѡ", MessageBox.WARNING); + return null; + } + projectCode = ((TCComponentFolder)target).getProperty("project_ids"); + if (projectCode.trim().equals("")) { + MessageBox.post(app.getDesktop(), "ļδָɵĿƻԱϵ", "λѡ", MessageBox.WARNING); + return null; + } + System.out.println(projectCode); + + Boolean isPrivilegedUser = false; + String[] attrs = {"ProjectID"}; + String[] vals = {projectCode}; + //TCComponent[] TCproject = TCUtil.query(fu.session, "Ŀ...", attrs, vals); + TCComponent[] TCproject = TCUtil.query(session, "Projects...", attrs, vals); + //TCComponentProjectType tccomponentprojecttype = (TCComponentProjectType) session.getTypeComponent("TC_Project"); + if(TCproject.length==0) { + MessageBox.post(app.getDesktop(), "ļδָɵĿƻԱϵ", "λѡ", MessageBox.WARNING); + return null; + } + List team = ((TCComponentProject)TCproject[0]).getTeam(); + Object privileged = team.get(2); + if(privileged instanceof TCComponentUser[]) { + TCComponentUser[] privilegedUsers = (TCComponentUser[])privileged; + for(TCComponentUser user : privilegedUsers) { + //System.out.println(user); + if(session.getUser().equals(user)) + isPrivilegedUser = true; + } + } + + if(session.getUser().equals(((TCComponentProject)TCproject[0]).getPAUser())) + isPrivilegedUser = true; + //System.out.println(((TCComponentProject)TCproject[0]).getPAUser()); + //System.out.println(session.getUser()); + + System.out.println("projectCode-----" + projectCode); + if (!isPrivilegedUser) { + MessageBox.post(app.getDesktop(), "ǸĿȨûƻԱϵ", "", MessageBox.WARNING); + return null; + } + } catch (Exception e1) { + e1.printStackTrace(); + return null; + } + + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + try { + new YSR8_TravelORDENCreateDialog(session, (TCComponentFolder)target, projectCode); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + + return null; + } + + +} diff --git a/src/cn/com/ebewin/ysr/handlers/YSR8_WorkHoursCreateHandler.java b/src/cn/com/ebewin/ysr/handlers/YSR8_WorkHoursCreateHandler.java new file mode 100644 index 0000000..bde4e0e --- /dev/null +++ b/src/cn/com/ebewin/ysr/handlers/YSR8_WorkHoursCreateHandler.java @@ -0,0 +1,69 @@ +package cn.com.ebewin.ysr.handlers; + +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.TCComponentFolder; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +import cn.com.ebewin.ysr.dialog.YSR8_WorkHoursCreateDialog; + +public class YSR8_WorkHoursCreateHandler extends AbstractHandler { + + private AbstractAIFUIApplication app; + private TCSession session; + private InterfaceAIFComponent target; + private String projectCode; + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + app = AIFUtility.getCurrentApplication(); + session = (TCSession) app.getSession(); + target = app.getTargetComponent(); + try { +//{ +//TCComponentScheduleTask scheduTask = (TCComponentScheduleTask)target; +//TCProperty property = scheduTask.getTCProperty("fnd0status"); +//System.out.println("scheduTask.getProperty(fnd0status)======" + property.getStringValue()); +//if (true) { +//return null; +//} +//} + if (target == null || !(target instanceof TCComponentFolder)) { + MessageBox.post(app.getDesktop(), "ѡձļнд", "λѡ", MessageBox.WARNING); + return null; + } + projectCode = ((TCComponentFolder)target).getProperty("project_ids"); + if (projectCode.equals("")) { + MessageBox.post(app.getDesktop(), "ѡձļнд", "λѡ", MessageBox.WARNING); + return null; + } + System.out.println("projectCode-----" + projectCode); + } catch (TCException e1) { + e1.printStackTrace(); + return null; + } + + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + try { + new YSR8_WorkHoursCreateDialog(session, (TCComponentFolder)target, projectCode); + } catch (TCException e) { + e.printStackTrace(); + } + } + }); + + return null; + } + +} diff --git a/src/cn/com/ebewin/ysr/handlers/YSR8_wysjTimeHandler.java b/src/cn/com/ebewin/ysr/handlers/YSR8_wysjTimeHandler.java new file mode 100644 index 0000000..514f904 --- /dev/null +++ b/src/cn/com/ebewin/ysr/handlers/YSR8_wysjTimeHandler.java @@ -0,0 +1,48 @@ +package cn.com.ebewin.ysr.handlers; + +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.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + +import cn.com.ebewin.ysr.dialog.YSR8_PMSBRevisionSearchDialog; +import cn.com.ebewin.ysr.dialog.YSR8_TotalContentDialog; +import cn.com.ebewin.ysr.dialog.YSR8_wysjTimeDialog; + +public class YSR8_wysjTimeHandler extends AbstractHandler { + + private AbstractAIFUIApplication app; + private TCSession session; +// private InterfaceAIFComponent target; + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + app = AIFUtility.getCurrentApplication(); + session = (TCSession) app.getSession(); +// target = app.getTargetComponent(); +// if (target == null || !(target instanceof TCComponentFolder)) { +// MessageBox.post(app.getDesktop(), "ѡϵͳĿ¼ļне룡", "λѡ", MessageBox.WARNING); +// return null; +// } + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + try { + new YSR8_wysjTimeDialog(session); + //d.setModal(true); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + + return null; + } + +} diff --git a/src/cn/com/ebewin/ysr/util/CommonUtil.java b/src/cn/com/ebewin/ysr/util/CommonUtil.java new file mode 100644 index 0000000..2e11430 --- /dev/null +++ b/src/cn/com/ebewin/ysr/util/CommonUtil.java @@ -0,0 +1,210 @@ +package cn.com.ebewin.ysr.util; + +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/com/ebewin/ysr/util/CreateDialogUtil.java b/src/cn/com/ebewin/ysr/util/CreateDialogUtil.java new file mode 100644 index 0000000..e3bbf72 --- /dev/null +++ b/src/cn/com/ebewin/ysr/util/CreateDialogUtil.java @@ -0,0 +1,73 @@ +package cn.com.ebewin.ysr.util; + +import java.text.ParseException; +import java.util.Vector; + +import javax.swing.JFrame; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCFormProperty; + +public class CreateDialogUtil extends DialogUtil { + public String itemType = ""; + public TCComponentItem newItem = null; + public TCComponentItemRevision newRevision = null; + public TCComponentForm newForm = null; + + public CreateDialogUtil(AbstractAIFDialog rendering, String title, String dialogName, String itemType) { + super(rendering, title, dialogName); + this.itemType = itemType; + } + + public CreateDialogUtil(JFrame rendering, String title, String dialogName, String itemType) { + super(rendering, title, dialogName); + this.itemType = itemType; + } + + public void createItem(String item_ID, String name) throws TCException { + newItem = TCUtil.createItem(session, item_ID, name, itemType); + newRevision = newItem.getLatestItemRevision(); + newForm = TCUtil.getItemRevisionMasterForm(newRevision); + + try { + this.formProperties = newForm.getAllFormProperties(); + + Vector formPropertys = super.GetPropertiesValue(); + TCFormProperty[] formPropertyArray = new TCFormProperty[formPropertys.size()]; +//System.out.println("length-----" + formPropertyArray.length); +//for (TCFormProperty tcFormProperty : formPropertyArray) { +// if (tcFormProperty == null) { +// continue; +// } +// switch (tcFormProperty.getPropertyType()) { +// case TCProperty.PROP_string: +// case TCProperty.PROP_long_string: +// System.out.println("createItem-----" + tcFormProperty.getName() + "-----formProperty-----" + tcFormProperty.getStringValue()); +// break; +// case TCProperty.PROP_short: +// case TCProperty.PROP_int: +// System.out.println("createItem-----" + tcFormProperty.getName() + "-----formProperty-----" + tcFormProperty.getIntValue()); +// break; +// case TCProperty.PROP_double: +// case TCProperty.PROP_float: +// System.out.println("createItem-----" + tcFormProperty.getName() + "-----formProperty-----" + tcFormProperty.getDoubleValue()); +// break; +// case TCProperty.PROP_date: +// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); +// if (tcFormProperty.getDateValue() != null) { +// System.out.println("createItem-----" + tcFormProperty.getName() + "-----formProperty-----" + sdf.format(tcFormProperty.getDateValue())); +// } +// break; +// } +//} + formPropertys.toArray(formPropertyArray); + newForm.setTCProperties(formPropertyArray); + } catch (ParseException e) { + e.printStackTrace(); + } + } +} diff --git a/src/cn/com/ebewin/ysr/util/DialogUtil.java b/src/cn/com/ebewin/ysr/util/DialogUtil.java new file mode 100644 index 0000000..ec0b4d0 --- /dev/null +++ b/src/cn/com/ebewin/ysr/util/DialogUtil.java @@ -0,0 +1,171 @@ +package cn.com.ebewin.ysr.util; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.JViewport; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.iTextField; + +@SuppressWarnings("deprecation") +public class DialogUtil extends UIUtil { + public AbstractAIFDialog rendering; + public JFrame frame; + + public DialogUtil(AbstractAIFDialog rendering, String title, String dialogName) { + this.rendering = rendering; + + rendering.setTitle(title); + readRenderingXML(dialogName); + } + + public DialogUtil(JFrame frame, String title, String dialogName) { + this.frame = frame; + + frame.setTitle(title); + readRenderingXML(dialogName); + } + + public void initializeUI(TCSession session) { + this.session = session; + try { + if (rendering != null) { + JPanel paneMain = new JPanel(new PropertyLayout()); + List firstComponentInfos = new ArrayList(); + firstComponentInfos.add(firstComponentInfo); + getFormPanel(paneMain, firstComponentInfos); + rendering.getContentPane().add(paneMain); + rendering.pack(); + rendering.setResizable(false); + } + if (frame != null) { + JPanel paneMain = new JPanel(new PropertyLayout()); + List firstComponentInfos = new ArrayList(); + firstComponentInfos.add(firstComponentInfo); + getFormPanel(paneMain, firstComponentInfos); + frame.setLayout(new BorderLayout()); + try {// if can't do it , don't do it + addDragListenerToFrame(frame, paneMain); + } catch (Exception e) { + System.out.println("add Listener failed: "+e.getMessage()); + //e.printStackTrace(); + } + frame.add(paneMain.getComponent(0), BorderLayout.CENTER);//should be put under addDragListenerToFrame + frame.pack(); + fitToScreen(frame); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + private void addDragListenerToFrame(JFrame frame, JPanel paneMain) throws Exception { + // JPanel @_@ + //////////////////////////////////// + JPanel comp = (JPanel) ((JPanel) ((JPanel) ((JViewport) ((JScrollPane) paneMain.getComponent(0)).getComponent(0)).getComponent(0)).getComponent(1)).getComponent(1); + int size = comp.getComponentCount(); + //get scrollpanes + /////////////////////////////////// + final Map scrollPanes = new HashMap<>(); + for (int i = 0; i < size; i++) { + JPanel c = (JPanel) comp.getComponent(i); + Component content = c.getComponent(0); + if (content instanceof JScrollPane) { + scrollPanes.put((JScrollPane) content, content.getPreferredSize()); + } + } + final int count = scrollPanes.size(); + if (count == 0) { + return; + } + // record origin size + /////////////////////////////////// + final double oWidth = paneMain.getPreferredSize().getWidth()+43; + final double oHeight = paneMain.getPreferredSize().getHeight()+63; + //System.out.println(sWidth+"|"+sHeight); + // add listener + /////////////////////////////////// + frame.addComponentListener(new ComponentAdapter() { + @Override + public void componentResized(ComponentEvent e) { + int cWidth = e.getComponent().getWidth(); + int cHeight = e.getComponent().getHeight(); + for (JScrollPane pane : scrollPanes.keySet()) { + Dimension od = scrollPanes.get(pane); + int width = (int) (od.getWidth() + cWidth - oWidth); + int height = (int)(od.getHeight() + (cHeight - oHeight)/ count); + pane.setSize(width, height); + pane.setPreferredSize(new Dimension(width, height)); + } + } + }); + } + + public void getDefVal() { + try { + Iterator> iter = allComponentInfos.entrySet().iterator(); + while (iter.hasNext()) { + Map.Entry entry = (Map.Entry) iter.next(); + String name = entry.getKey(); + ComponentInfo cci = entry.getValue(); + if (cci == null) { + continue; + } + if (cci.type.equalsIgnoreCase("iTextField")) { + iTextField textField = (iTextField) allComponentMap.get(name); + if (((iTextFieldInfo) cci).defValType.equalsIgnoreCase("sys")) { + if (((iTextFieldInfo) cci).defVal.equalsIgnoreCase("user")) { + textField.setText(session.getUser().getRelatedComponent("person").getProperty("user_name")); + } else if (((iTextFieldInfo) cci).defVal.equalsIgnoreCase("user2")) { + TCComponentUser user = session.getUser(); + textField.setText(user.getProperty("user_id")); + } else if (((iTextFieldInfo) cci).defVal.equalsIgnoreCase("user3")) { + TCComponentUser user = session.getUser(); + textField.setText(user.getRelatedComponent("person").getProperty("user_name") + "(" + user.getProperty("user_id") + ")"); + } else if (((iTextFieldInfo) cci).defVal.equalsIgnoreCase("date")) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + textField.setText(sdf.format(new Date())); + } + } else if (((iTextFieldInfo) cci).defValType.equalsIgnoreCase("normal")) { + textField.setText(((iTextFieldInfo) cci).defVal); + } + } else if (cci.type.equalsIgnoreCase("DateButton")) { + DateButton btn = (DateButton) allComponentMap.get(name); + if (cci.defValType.equalsIgnoreCase("sys") && cci.defVal.equalsIgnoreCase("date")) { + btn.setDate(new Date()); + } + } else if (cci.type.equalsIgnoreCase("JComboBox")) { + + } else if (cci.type.equalsIgnoreCase("JTextArea")) { + JTextArea textArea = (JTextArea) allComponentMap.get(name); + if (cci.defValType.equalsIgnoreCase("normal")) { + textArea.setText(cci.defVal); + } + } + } + } catch (TCException e) { + e.printStackTrace(); + } + } +} diff --git a/src/cn/com/ebewin/ysr/util/FileUtil.java b/src/cn/com/ebewin/ysr/util/FileUtil.java new file mode 100644 index 0000000..dc3f3d7 --- /dev/null +++ b/src/cn/com/ebewin/ysr/util/FileUtil.java @@ -0,0 +1,312 @@ +package cn.com.ebewin.ysr.util; + +import java.awt.Frame; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Vector; + +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import javax.swing.JTable; +import javax.swing.filechooser.FileFilter; +import javax.swing.filechooser.FileNameExtensionFilter; +import javax.swing.filechooser.FileSystemView; + +import org.apache.log4j.Logger; +import org.apache.poi.hssf.usermodel.HSSFDateUtil; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.Name; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.util.AreaReference; +import org.apache.poi.ss.util.CellReference; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +public class FileUtil { + + private static final Logger log = Logger.getLogger(FileUtil.class); + + public static void main(String[] args) { + String path = "E:\\TEMP\\2.xlsx"; + File file = new File(path); + getCellValueByName(file, "Ŀ"); + } + + + public static void writeToExcel(File file, JTable table) { + Integer colCount = table.getColumnCount() - 1; + Integer rowCount = table.getRowCount(); + try { + String fileName = file.getName().toLowerCase(); + Workbook workBook = fileName.endsWith("xls") ? new HSSFWorkbook() : new XSSFWorkbook(); + Sheet sheet = workBook.createSheet("sheet0"); + + for (int i = 0; i < rowCount; i++) { + Row row = sheet.createRow(i); + for (int j = 0; j < colCount; j++) { + row.createCell(j); + } + } + // ӱ + for (int i = 0; i < colCount; i++) { + sheet.getRow(0).getCell(i).setCellValue(table.getColumnName(i)); + } + + // + for (int i = 1; i < rowCount; i++) { + for (int j = 0; j < colCount; j++) { + Object value = table.getValueAt(i, j); + sheet.getRow(i).getCell(j).setCellValue(value != null ? value + "" : ""); + } + } + + CellStyle style = workBook.createCellStyle(); + + for (int i = 0; i < sheet.getPhysicalNumberOfRows(); i++) { + Row row = sheet.getRow(i); + row.setHeightInPoints(20f); + for (int k = 0; k < row.getLastCellNum(); k++) { + row.getCell(k).setCellStyle(style); + sheet.setColumnWidth(k, 5000); + } + } + sheet.setColumnWidth(0, 5000); + + FileOutputStream fileOut = new FileOutputStream(file); + workBook.write(fileOut); + fileOut.flush(); + fileOut.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static String[] getCellValueByName(File file, String cellName) { + String[] cellValue = null; + try { + log.info("file:" + file.getAbsolutePath()); + FileInputStream fileIn = new FileInputStream(file); + boolean isExcelX = file.getName().matches("^.+\\.(?i)(xlsx)$"); + + Workbook workbook = isExcelX ? new XSSFWorkbook(fileIn) : new HSSFWorkbook(fileIn); + int nameIndex = workbook.getNameIndex(cellName); + log.info("nameIndex:" + nameIndex); + if (nameIndex < 0) { + return null; + } + Name name = workbook.getNameAt(nameIndex); + AreaReference aref = new AreaReference(name.getRefersToFormula()); + CellReference[] cellRef = aref.getAllReferencedCells(); + cellValue = new String[cellRef.length]; + for (int i = 0; i < cellRef.length; i++) { + Sheet sheet = workbook.getSheet(cellRef[i].getSheetName()); + Row row = sheet.getRow(cellRef[i].getRow()); + Cell cell = row.getCell(cellRef[i].getCol()); + cellValue[i] = cell.toString(); + log.info("cellValue:" + cellValue[i]); + } + } catch (IOException e) { + e.printStackTrace(); + } + return cellValue; + } + + public static List> readExcel(File file) { + try { + log.info("file:" + file.getAbsolutePath()); + FileInputStream fileIn = new FileInputStream(file); + boolean isExcelX = file.getName().matches("^.+\\.(?i)(xlsx)$"); + + Workbook workbook = isExcelX ? new XSSFWorkbook(fileIn) : new HSSFWorkbook(fileIn); + Sheet sheet = workbook.getSheetAt(0); + log.info("sheet:" + workbook.getSheetName(0)); + if (sheet.getRow(1) == null || sheet.getRow(1).getCell(0) == null) { + log.info("sheet.getRow(0).getCell(0) == null"); + return null; + } + + List> listDatas = new ArrayList>(); + + Integer totalRows = sheet.getPhysicalNumberOfRows(); + Integer totalCells = 0; + if (totalRows >= 1 && sheet.getRow(1) != null) { + totalCells = sheet.getRow(1).getPhysicalNumberOfCells(); + } + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + for (int r = 0; r < totalRows; r++) { + Row row = sheet.getRow(r); + if (row == null) { + continue; + } + ArrayList listRows = new ArrayList(); + + for (short c = 0; c < totalCells; c++) { + Cell cell = row.getCell(c); + String cellValue = ""; + if (cell == null) { + cellValue = ""; + } else if (Cell.CELL_TYPE_NUMERIC == cell.getCellType()) { + if (HSSFDateUtil.isCellDateFormatted(cell)) { + //cellValue = String.valueOf(DateUtil.getExcelDate(cell.getDateCellValue())); + Date date = cell.getDateCellValue(); + if (date == null) { + cellValue = ""; + } else { + cellValue = sdf.format(date); + } + } else { + cellValue = getRightStr(cell.getNumericCellValue() + ""); + } + } else if (Cell.CELL_TYPE_STRING == cell.getCellType()) { + cellValue = cell.getStringCellValue().trim(); + } else if (Cell.CELL_TYPE_BOOLEAN == cell.getCellType()) { + cellValue = cell.getBooleanCellValue() + ""; + } else { + cellValue = cell.toString().trim(); + } + listRows.add(cellValue); + } + listDatas.add(listRows); + } + fileIn.close(); + return listDatas; + } catch (IOException e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, e.getMessage(), null, JOptionPane.ERROR_MESSAGE); + return null; + } + } + + private static String getRightStr(String sNum) { + DecimalFormat decimalFormat = new DecimalFormat("#.000000"); + String resultStr = decimalFormat.format(new Double(sNum)); + if (resultStr.matches("^[-+]?\\d+\\.[0]+$")) { + resultStr = resultStr.substring(0, resultStr.indexOf(".")); + } + return resultStr; + } + + public static File saveExcelChooser(File file) { + File dir = null; + JFileChooser chooser = new JFileChooser(); + chooser.setAcceptAllFileFilterUsed(false); + File currentDir = FileSystemView.getFileSystemView().getDefaultDirectory(); + chooser.setCurrentDirectory(currentDir); +// String saveType[] = { "xls", "xlsx" }; +// chooser.setFileFilter(new FileNameExtensionFilter("Microsoft Excel *.xls, *.xlsx", saveType)); + String saveType[] = { "xlsx" }; + chooser.setFileFilter(new FileNameExtensionFilter("Microsoft Excel *.xlsx", saveType)); + if (file != null) { + chooser.setSelectedFile(file); + } + int returnVal = chooser.showSaveDialog(new Frame()); + if (returnVal == JFileChooser.APPROVE_OPTION) { + dir = chooser.getSelectedFile(); + System.out.println("saveExcelChooser1:" + dir.getPath()); + if (!dir.getPath().endsWith(".xlsx")) { + dir.renameTo(new File(dir.getPath() + ".xlsx")); + } + System.out.println("saveExcelChooser2:" + dir.getPath()); + } + return dir; + } + +// String[][] fileENames = { { ".java", "JAVAԴ ļ(*.java)" }, +// { ".doc", "MS-Word 2003 ļ(*.doc)" }, +// { ".xls", "MS-Excel 2003 ļ(*.xls)" } +// }; + public static File openFileChooser(String[][] fileTypes) { + JFileChooser chooser = new JFileChooser(); + for (final String[] fileType : fileTypes) { + chooser.setFileFilter(new FileFilter() { + public boolean accept(File file) { + if (file.getName().toLowerCase().endsWith(fileType[0]) || file.isDirectory()) { + return true; + } + return false; + } + public String getDescription() { + return fileType[1]; + } + }); + } + chooser.setAcceptAllFileFilterUsed(false); + chooser.setMultiSelectionEnabled(false); + chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + File desktopDir = FileSystemView.getFileSystemView().getHomeDirectory(); + chooser.setSelectedFile(desktopDir); + File file = null; + int returnVal = chooser.showOpenDialog(new Frame()); + if (returnVal == JFileChooser.APPROVE_OPTION) { + file = chooser.getSelectedFile(); + if (file == null) { + JOptionPane.showMessageDialog(new Frame(), "file not exists"); + return null; + } + } + return file; + } + public static File[] openFileChoosers(String[][] fileTypes) { + JFileChooser chooser = new JFileChooser(); + for (final String[] fileType : fileTypes) { + chooser.setFileFilter(new FileFilter() { + public boolean accept(File file) { + if (file == null) { + return false; + } + if (file.isDirectory()) { + return true; + } + String extension = getExtension(file); + Vector fileTypePartVec = CommonUtil.split2Vector(fileType[0], ";"); + for (String fileTypePart : fileTypePartVec) { + if (extension != null && extension.equalsIgnoreCase(fileTypePart)) { + return true; + } + } + return false; + } + public String getDescription() { + return fileType[1]; + } + private String getExtension(File f) { + if (f != null) { + String filename = f.getName(); + int i = filename.lastIndexOf('.'); + if (i > 0 && i < filename.length() - 1) { + return filename.substring(i).toLowerCase(); + } + } + return null; + } + }); + } + chooser.setAcceptAllFileFilterUsed(false); + chooser.setMultiSelectionEnabled(true); + chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + File desktopDir = FileSystemView.getFileSystemView().getHomeDirectory(); + chooser.setSelectedFile(desktopDir); + File[] files = null; + int returnVal = chooser.showOpenDialog(new Frame()); + if (returnVal == JFileChooser.APPROVE_OPTION) { + files = chooser.getSelectedFiles(); + if (files == null) { + JOptionPane.showMessageDialog(new Frame(), "file not exists"); + return null; + } + } + return files; + } + +} diff --git a/src/cn/com/ebewin/ysr/util/FormCheckUtil.java b/src/cn/com/ebewin/ysr/util/FormCheckUtil.java new file mode 100644 index 0000000..4667c70 --- /dev/null +++ b/src/cn/com/ebewin/ysr/util/FormCheckUtil.java @@ -0,0 +1,258 @@ +package cn.com.ebewin.ysr.util; + +import java.awt.Color; +import java.awt.Component; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map.Entry; +import java.util.Vector; + +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JRadioButton; +import javax.swing.JTable; +import javax.swing.JTextArea; + +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentRuleHandler; +import com.teamcenter.rac.kernel.TCComponentTask; +import com.teamcenter.rac.kernel.TCComponentTaskTemplate; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCHandlerType; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.iTextField; + +@SuppressWarnings("deprecation") +public class FormCheckUtil { + private TCComponentForm tcform; + private HashMap allComponents = new HashMap(); + public boolean isNeedCheck = false; + public Vector vtModifiableAttr = new Vector(); // ޸ + public Vector vtReqAttr = new Vector(); // + + public FormCheckUtil(TCComponentForm tcform, HashMap allComponents) { + this.tcform = tcform; + this.allComponents = allComponents; + } + + + public boolean isNeedCheck() { + return isNeedCheck; + } + + + public void setNeedCheck(boolean isNeedCheck) { + this.isNeedCheck = isNeedCheck; + } + + /** + * checkHandler:ȡHanderõIJ + */ + public void checkHandler() { + //System.out.println("checkHandler ....start"); + try { + TCComponent[] component = tcform.getReferenceListProperty("process_stage_list"); + //System.out.println("component.length=============" + component.length); + if(component == null || component.length == 0){ + return; + } + Vector componentV = new Vector(); + for(TCComponent c : component) { + System.out.println("componentV=============" + c); + componentV.add(c); + } +// String strProcessStage = tcform.getProperty("process_stage"); + TCComponent[] strProcessStage = tcform.getReferenceListProperty("process_stage_list"); + String strProcess = ""; +// if(strProcessStage.indexOf(",")>strProcessStage.indexOf("/")+ 1) { +// strProcess = strProcessStage.substring(strProcessStage.indexOf("/")+ 1,strProcessStage.indexOf(","));//lidy20181001 TODO +// } else +// strProcess = strProcessStage.substring(strProcessStage.indexOf("/")+ 1); + if(strProcessStage!=null) { + if(strProcessStage.length>1) + strProcess = strProcessStage[1].getReferenceProperty("parent_process").toString(); + else + strProcess = strProcessStage[0].getReferenceProperty("parent_process").toString(); + } + System.out.println("strProcess = " + strProcess); + + TCComponentTask task = null; + TCSession session = tcform.getSession(); + TCComponentUser user = session.getUser(); + TCComponent taskinbox = user.getReferenceProperty("taskinbox"); + TCComponent[] tasks = taskinbox.getReferenceListProperty("contents"); + //System.out.println("tasks.length=============" + tasks.length); + for(int i = 0; i < tasks.length ; i++){ + if(tasks[i].getType().equals("TasksToPerform")){ + TCComponent[] mytasks = tasks[i].getReferenceListProperty("contents"); + System.out.println("mytasks.length=============" + mytasks.length); + for(int j = 0 ; j < mytasks.length ;j++){ + TCComponent parentProcess = mytasks[j].getReferenceProperty("parent_process"); + System.out.println("parentProcess=============" + parentProcess); + if(strProcess.equals(parentProcess.toString())){ +// if(componentV.contains(parentProcess)){//TODO lidy20190115 + TCComponent taskparent = null; + String strTaskType = mytasks[j].getType(); + System.out.println("strTaskType = " + strTaskType); + if(strTaskType.equals("EPMConditionTask") || + strTaskType.equals("EPMDoTask") || + strTaskType.equals("EPMTask") || + strTaskType.equals("EPMAcknowledgeTask") || + strTaskType.equals("EPMReviewTask")){ + taskparent = mytasks[j]; + }else{ + taskparent = mytasks[j].getReferenceProperty("parent_task"); + } + for(int k = 1; k < component.length ; k ++){ + System.out.println("taskparent.getUid()======" + taskparent.getUid() + "======component[k].getUid()======" + component[k].getUid()); + if(taskparent.equals(component[k])){ + task = (TCComponentTask) taskparent; + break; + } + } + } + } + } + } + if(task == null){ + return; + } + System.out.println("task = " + task); + String strFormType = tcform.getType(); + System.out.println("strFormType = " + strFormType); + + TCComponent handlerComponent = task.getHandler(TCHandlerType.RULE, TCComponentTaskTemplate.START_ACTION, "EPMC_check_form_attribute"); + System.out.println("handlerComponent = " + handlerComponent); + if (handlerComponent != null && handlerComponent instanceof TCComponentRuleHandler) { + TCComponentRuleHandler handler = (TCComponentRuleHandler) handlerComponent; + String[] args = handler.getArguments(); + if (args != null && args.length > 0) { + for (int i = 0; i < args.length; i++) { + System.out.println("args[" + i + "]:::::::::::" + args[i]); + String argumentValue = args[i].split("=")[1]; + if (args[i].startsWith("-form_type")) { + argumentValue = argumentValue.replace("", ";"); + if (argumentValue.contains(";")) { + String[] arrValue = argumentValue.split(";"); + for (int j = 0; j < arrValue.length; j++) { + if(strFormType.equals(arrValue[j])){ + isNeedCheck = true; + break; + } + } + } else { + if(strFormType.equals(argumentValue)){ + isNeedCheck = true; + } + } + System.out.println("Formͣform_type::::" + argumentValue); + } else if (args[i].startsWith("-modifiable_attr")) { + argumentValue = argumentValue.replace("", ";"); + if (argumentValue.contains(";")) { + String[] arrValue = argumentValue.split(";"); + for (int j = 0; j < arrValue.length; j++) { + vtModifiableAttr.add(arrValue[j]); + } + } else { + vtModifiableAttr.add(argumentValue); + } + System.out.println("Formдԣmodifiable_attr::::" + argumentValue); + } else if (args[i].startsWith("-require_attr")) { + argumentValue = argumentValue.replace("", ";"); + if (argumentValue.contains(";")) { + String[] arrValue = argumentValue.split(";"); + for (int j = 0; j < arrValue.length; j++) { + vtReqAttr.add(arrValue[j]); + } + } else { + vtReqAttr.add(argumentValue); + } + System.out.println("Formԣrequire_attr::::" + argumentValue); + } + } + } + } + System.out.println("isNeedCheck = " + isNeedCheck); + System.out.println("vtModifiableAttr = " + vtModifiableAttr); + System.out.println("vtReqAttr = " + vtReqAttr); + } catch (TCException e) { + e.printStackTrace(); + } + //System.out.println("checkHandler ....end"); + } + + /** + * setEnable:Կɱ༭ + */ + @SuppressWarnings("unchecked") + public void setEnable() { + System.out.println("setEnable()...start"); + //FormUtilApi formApi = new FormUtilApi(tcform.getSession()); + if (vtModifiableAttr.size() > 0) { + Iterator> iter = allComponents.entrySet().iterator(); + while(iter.hasNext()) { + Entry entry = (Entry)iter.next(); + String name = (String)entry.getKey(); + Component component = (Component)entry.getValue(); + if(!vtModifiableAttr.contains(name)){ + if (component instanceof iTextField || + component instanceof DateButton || + component instanceof JButton || + component instanceof JRadioButton || + component instanceof JCheckBox || + component instanceof JTextArea || + component instanceof JTable || + component instanceof JComboBox) { + component.setEnabled(false); + } else { + component.setEnabled(true); + } + continue; + } + if (component instanceof iTextField) { + iTextField textField = (iTextField) component; + System.out.println("iTextField-" + name + "=======setEnabled"); + textField.setEnabled(true); + textField.setEditable(true); + }else if(component instanceof JTextArea){ + JTextArea areaField = (JTextArea) component; + System.out.println("JTextArea-" + name + "=======setEnabled"); + areaField.setEnabled(true); + areaField.setEditable(true); + areaField.setBackground(Color.WHITE); + }else if(component instanceof JComboBox){ + JComboBox cbo = (JComboBox) component; + System.out.println("JComboBox-" + name + "=======setEnabled"); + cbo.setEnabled(true); + //cbo.setEditable(true); + cbo.setBackground(Color.white); + }else if(component instanceof DateButton){ + DateButton datebtn = (DateButton) component; + System.out.println("DateButton-" + name + "=======setEnabled"); + datebtn.setEnabled(true); + }else if(component instanceof JButton){ + JButton btn = (JButton) component; + System.out.println("JButton-" + name + "=======setEnabled"); + btn.setEnabled(true); + }else if(component instanceof JCheckBox){ + JCheckBox btn = (JCheckBox) component; + System.out.println("JCheckBox-" + name + "=======setEnabled"); + btn.setEnabled(true); + }else if(component instanceof JTable){ + JTable table = (JTable) component; + System.out.println("JTable-" + name + "=======setEnabled"); + table.setEnabled(true); + } + } + } + System.out.println("setEnable()...end"); + } + +// private Boolean inProcess(TCComponent target, TCComponent process) { +// return false; +// } +} diff --git a/src/cn/com/ebewin/ysr/util/FormUtil.java b/src/cn/com/ebewin/ysr/util/FormUtil.java new file mode 100644 index 0000000..aa629d6 --- /dev/null +++ b/src/cn/com/ebewin/ysr/util/FormUtil.java @@ -0,0 +1,465 @@ +package cn.com.ebewin.ysr.util; + +import java.awt.BorderLayout; +import java.text.DecimalFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Date; +import java.util.Vector; + +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.JRadioButton; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.JTabbedPane; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.JViewport; +import javax.swing.table.JTableHeader; +import javax.swing.text.JTextComponent; + +import com.teamcenter.rac.common.viewedit.ViewEditHelper; +import com.teamcenter.rac.conditionalproperties.FormFieldManager; +import com.teamcenter.rac.conditionalproperties.WidgetTypeAdapter; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCFormProperty; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCPropertyDescriptor; +import com.teamcenter.rac.stylesheet.AbstractPropertyComponent; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.stylesheet.InterfacePropertyComponent; +import com.teamcenter.rac.stylesheet.InterfaceRendererEvent; +import com.teamcenter.rac.stylesheet.PropertyArray; +import com.teamcenter.rac.stylesheet.PropertyComment; +import com.teamcenter.rac.stylesheet.PropertyLogicalPanel; +import com.teamcenter.rac.stylesheet.PropertyObjectLink; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.Registry; +import com.teamcenter.rac.util.iTextField; +import com.teamcenter.rac.util.DateButton; + + +//TCUserService userService = session.getUserService(); +//Object[] objParams = new Object[2]; +//String cmd = "Get_Class_InstanceName"; +//String params = UNCTID; +//objParams[0] = cmd; +//objParams[1] = params; +//long startime = System.currentTimeMillis(); +//String result = (String) userService.call("YSR8UserService", objParams); +//long endtime = System.currentTimeMillis(); +//System.out.println("Cʱ" + (endtime - startime) + ""); +//System.out.println(result); + +@SuppressWarnings("deprecation") +public class FormUtil extends UIUtil { + public AbstractRendering rendering; + public TCComponentForm tcForm = null; + public boolean isReadOnly = false; + + public FormUtil(AbstractRendering rendering) throws Exception { + System.out.println("FormUtil"); + this.rendering = rendering; + } + + public void initializeUI(TCComponentForm tcForm) { + if (tcForm != null) { + this.tcForm = tcForm; + } + this.session = this.tcForm.getSession(); + ViewEditHelper editHelp = new ViewEditHelper(session); + isCheckOut = editHelp.isCheckedOutByUser(tcForm); + try { + rendering.setLayout(new BorderLayout()); + + rendering.add(BorderLayout.WEST, new JLabel(" ")); + List firstComponentInfos = new ArrayList(); + firstComponentInfos.add(firstComponentInfo); + getFormPanel(rendering, firstComponentInfos); + rendering.add(BorderLayout.EAST, new JLabel(" ")); + + if (isCheckOut && rendering.isModifiable()) { + rendering.setRenderingReadWrite(); + } else { + isReadOnly = true; + rendering.setRenderingReadOnly(); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void loadRendering() throws TCException { + this.formProperties = tcForm.getAllFormProperties(); + ViewEditHelper editHelp = new ViewEditHelper(session); + isCheckOut = editHelp.isCheckedOutByUser(tcForm); + if (this.formProperties == null) { + Registry registry = Registry.getRegistry(this); + throw new TCException(registry.getString("failedLoadingFormProperties")); + } + + try { + super.loadPropertiesValue(); + } catch (TCException imanexception) { + throw imanexception; + } + } + + public void saveRendering() throws TCException, ParseException { + try { + Vector formPropertys = super.GetPropertiesValue(); + + TCFormProperty[] formPropertyArray = new TCFormProperty[formPropertys.size()]; + formPropertys.toArray(formPropertyArray); + tcForm.setTCProperties(formPropertyArray); + } catch (TCException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + } + } + + public boolean isRenderingModified() { +// System.out.println(tcForm.getType()+"isRenderingModified"); + int length = this.formProperties.length; + for (int k = 0; k < length; ++k) { + TCFormProperty formProperty = this.formProperties[k]; + String propName = formProperty.getPropertyName().trim(); + //System.out.println("isRenderingModified:propName-----" + propName); + ComponentInfo ci = allComponentInfos.get(propName); + if (ci == null) { + continue; + } + + if (ci.parentTableInfo == null) { + Object component = indices.get(formProperties[k]); + if (component instanceof iTextField) { + String value = ((iTextField)component).getText().toString(); + String propValue = ""; + switch (this.formProperties[k].getPropertyType()) { + case TCProperty.PROP_string: + case TCProperty.PROP_long_string: + propValue = this.formProperties[k].getStringValue(); + break; + case TCProperty.PROP_short: + case TCProperty.PROP_int: + propValue = Integer.toString(this.formProperties[k].getIntValue()); + break; + case TCProperty.PROP_double: + case TCProperty.PROP_float: + String val = getDoubleString(this.formProperties[k].getDoubleValue()); + if (val.startsWith(".")) { + val = "0" + val; + } + propValue = val; + break; + case TCProperty.PROP_date: + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date date = this.formProperties[k].getDateValue(); + if (date != null) { + propValue = sdf.format(date); + } + break; + default: + propValue = this.formProperties[k].getStringValue(); + break; + } + if(!propValue.equals(value)){ + System.out.println("isRenderingModified:propName-----" + propName + "-----type-----" + ci.type + "-----------TRUE1"); + return true; + } else { + //System.out.println("isRenderingModified:propName-----" + propName + "-----type-----" + ci.type + "-----------FALSE1"); + } + } else if (component instanceof JTextArea) { + String value = ((JTextArea)component).getText().toString(); + if(!formProperty.getStringValue().equals(value)){ + System.out.println("isRenderingModified:propName-----" + propName + "-----type-----" + ci.type + "-----------TRUE2"); + return true; + } else { + //System.out.println("isRenderingModified:propName-----" + propName + "-----type-----" + ci.type + "-----------FALSE2"); + } + } else if (component instanceof JCheckBox) { + Boolean value = ((JCheckBox)component).isSelected(); + if(formProperty.getBoolValue() != value){ + System.out.println("isRenderingModified:propName-----" + propName + "-----type-----" + ci.type + "-----------TRUE3"); + return true; + } else { + //System.out.println("isRenderingModified:propName-----" + propName + "-----type-----" + ci.type + "-----------FALSE3"); + } + } else if (component instanceof JRadioButton) { + Boolean value = ((JRadioButton)component).isSelected(); + if(formProperty.getBoolValue() != value){ + System.out.println("isRenderingModified:propName-----" + propName + "-----type-----" + ci.type + "-----------TRUE4"); + return true; + } else { + //System.out.println("isRenderingModified:propName-----" + propName + "-----type-----" + ci.type + "-----------FALSE4"); + } + } else if (component instanceof DateButton) { + if(!getDateString(formProperty.getDateValue()).equals(getDateString(((DateButton)component).getDate()))) { + System.out.println("isRenderingModified:propName-----" + propName + "-----type-----" + ci.type + "-----------TRUE5"); + return true; + } else { + //System.out.println("isRenderingModified:propName-----" + propName + "-----type-----" + ci.type + "-----------FALSE5"); + } + } else if (component instanceof JComboBox) { + @SuppressWarnings("unchecked") + JComboBox cbx = (JComboBox)component; + String value = ""; + if (!((JComboBoxInfo)ci).canWrite) { + value = cbx.getSelectedItem().toString(); + } else { + value = ((JTextField)cbx.getEditor().getEditorComponent()).getText(); + } + if (((JComboBoxInfo)ci).valueType.equalsIgnoreCase("lov")) { + if (((JComboBoxInfo)ci).lovVal != null) { + Iterator iter = ((JComboBoxInfo)ci).lovVal.keySet().iterator(); + while (iter.hasNext()) { + String lovKey = iter.next(); + String lovValue = ((JComboBoxInfo)ci).lovVal.get(lovKey); + if (lovValue.equalsIgnoreCase(value)) { + value = lovKey; + break; + } + } + } + } else if (((JComboBoxInfo)ci).valueType.equalsIgnoreCase("Cls_Class")) { + if (((JComboBoxInfo)ci).key_values != null) { + for (int i = 0; i < ((JComboBoxInfo)ci).key_values.size(); i++) { + String res = ((JComboBoxInfo)ci).key_values.get(i).get("PNAME").toString(); + if (res.equalsIgnoreCase(value)) { + value = ((JComboBoxInfo)ci).key_values.get(i).get("PCID").toString(); + break; + } + } + } + } + if(!formProperty.getStringValue().equals(value)){ + System.out.println("isRenderingModified:propName-----" + propName + "-----type-----" + ci.type + "-----------TRUE6"); + return true; + } else { + //System.out.println(formProperty.getStringValue() + "---------------" + value); + //System.out.println("isRenderingModified:propName-----" + propName + "-----type-----" + ci.type + "-----------FALSE6"); + } + } + } else { + int colIdx = -1; + for (int j = 0; j < ci.parentTableInfo.childComponentInfos.size(); j++) { + ComponentInfo tcci = ci.parentTableInfo.childComponentInfos.get(j); + if (tcci.name.equalsIgnoreCase(propName)) { + colIdx = j; + break; + } + } + if (colIdx != -1) { + Vector values = new Vector(); + switch (this.formProperties[k].getPropertyType()) { + case TCProperty.PROP_string: + case TCProperty.PROP_long_string: + String[] strvals = formProperties[k].getStringArrayValue(); + for (int l = 0; l < strvals.length; l++) { + values.add(strvals[l]); + } + break; + case TCProperty.PROP_short: + case TCProperty.PROP_int: + int[] ivals = formProperties[k].getIntArrayValue(); + for (int l = 0; l < ivals.length; l++) { + values.add(Integer.toString(ivals[l])); + } + break; + case TCProperty.PROP_double: + case TCProperty.PROP_float: + double[] doublevals = formProperties[k].getDoubleArrayValue(); + for (int l = 0; l < doublevals.length; l++) { + String val1 = new DecimalFormat("#.00").format(doublevals[l]); + if (val1.equals("0.00")) { + values.add(""); + } else { + String val = getDoubleString(doublevals[l]); +// System.out.println("getDoubleString(doublevals["+l+"])====" + val); + values.add(val); + } + } + break; + case TCProperty.PROP_date: + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date[] datevals = formProperties[k].getDateValueArray(); + for (int l = 0; l < datevals.length; l++) { + if (datevals[l] != null) { + //TODO lidy20190521ͼֽĵڸʽ + if(fromType.equals("YSR8_ECN2RevisionMasterForm") || fromType.equals("YSR8_ECN4RevisionMasterForm") || + fromType.equals("YSR8_INSPRecordRevisionMasterForm")) { + sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + values.add(sdf.format(datevals[l])); + }else + values.add(sdf.format(datevals[l])); + } else { + values.add(""); + } + } + break; + default: + String[] strvals1 = formProperties[k].getStringArrayValue(); + for (int l = 0; l < strvals1.length; l++) { + values.add(strvals1[l]); + } + break; + } + if (values.size() != ci.parentTableInfo.dataTableModel.getRowCount()) { + System.out.println("isRenderingModified:propName-----" + propName + "-----type-----" + ci.type + "-----------TRUE7----------" + values.size() + "=========" + ci.parentTableInfo.dataTableModel.getRowCount()); + return true; + } else if (values.size() == 0 && ci.parentTableInfo.dataTableModel.getRowCount() == 0) { + //System.out.println("isRenderingModified:propName-----" + propName + "-----type-----" + ci.type + "-----------FALSE7"); + } else { + for (int l = 0; l < values.size(); l++) { + if (ci.parentTableInfo.dataTableModel.getValueAt(l, colIdx) == null) { + if (values.get(l) == null) { + //System.out.println("isRenderingModified:propName-----" + propName + "-----type-----" + ci.type + "-----------FALSE8"); + } else if (values.get(l).equals("")) { + //System.out.println("isRenderingModified:propName-----" + propName + "-----type-----" + ci.type + "-----------FALSE9"); + } else { + System.out.println("isRenderingModified:propName-----" + propName + "-----type-----" + ci.type + "-----------TRUE10"); + return true; + } + } else { + if (ci.type.equalsIgnoreCase("JComboBox") && + ((JComboBoxInfo)ci).valueType.equalsIgnoreCase("lov") && + !((JComboBoxInfo)ci).valueName.equals("")) { + if (!ci.parentTableInfo.dataTableModel.getValueAt(l, colIdx).toString().equalsIgnoreCase(((JComboBoxInfo)ci).lovVal.get(values.get(l))) && + !ci.parentTableInfo.dataTableModel.getValueAt(l, colIdx).toString().equalsIgnoreCase(values.get(l))) { + System.out.println("isRenderingModified:propName-----" + propName + "-----type-----" + ci.type + "-----------TRUE11"); + return true; + } + } else if (ci.type.equalsIgnoreCase("JComboBox") && + ((JComboBoxInfo)ci).valueType.equalsIgnoreCase("Cls_Class") && + !((JComboBoxInfo)ci).valueName.equals("")) { + if (((JComboBoxInfo)ci).key_values != null) { + for (int j = 0; j < ((JComboBoxInfo)ci).key_values.size(); j++) { + String key = ((JComboBoxInfo)ci).key_values.get(j).get("PCID").toString(); + if (key.equalsIgnoreCase(values.get(l))) { + ci.parentTableInfo.dataTableModel.setValueAt(((JComboBoxInfo)ci).key_values.get(j).get("PNAME").toString(), l, colIdx); + if (!ci.parentTableInfo.dataTableModel.getValueAt(l, colIdx).toString().equalsIgnoreCase(((JComboBoxInfo)ci).key_values.get(j).get("PNAME").toString())) { + System.out.println("isRenderingModified:propName-----" + propName + "-----type-----" + ci.type + "-----------TRUE12"); + return true; + } + } + } + } + } else { + if (!ci.parentTableInfo.dataTableModel.getValueAt(l, colIdx).toString().equalsIgnoreCase(values.get(l))) { + if(!tcForm.getType().equals("YSR8_DrawingListRevisionMaster") || !propName.equals("ysr8_SerialNo")) { + System.out.println("isRenderingModified:propName-----" + propName + "-----type-----" + ci.type + "-----------TRUE13----" + + ci.parentTableInfo.dataTableModel.getValueAt(l, colIdx).toString() + "----" + values.get(l)); + return true; + } + } + } + } + } + } + } + } + } + //System.out.println("isRenderingModified:Last-----------FALSE14"); + return false; + } + + public void setModifiableComponents(java.awt.Component currcomponent, boolean flag) + { + if(currcomponent == null) + return; + if(tcForm!=null) { + ViewEditHelper editHelp = new ViewEditHelper(session); + isCheckOut = editHelp.isCheckedOutByUser(tcForm); + } + //System.out.println("component-----------" + currcomponent.getClass().getTypeName() + "------" + currcomponent.getName()); + boolean flag1 = flag; + if(flag && (currcomponent instanceof PropertyComment)) { + flag1 = ((PropertyComment)currcomponent).isLabelEditable(); + } else { + if(flag && (currcomponent instanceof InterfacePropertyComponent)) + { + String s = ((InterfacePropertyComponent)currcomponent).getProperty(); + try + { + TCPropertyDescriptor tcpropertydescriptor = rendering.getTypeComponent().getPropertyDescriptor(s); + if(tcpropertydescriptor != null) + { + flag1 = tcpropertydescriptor.isEnabled(); + if(rendering.getComponent() != null) + { + TCProperty tcproperty = rendering.getComponent().getTCProperty(s); + boolean flag3 = tcproperty.isEnabled(); + flag1 = flag3; + } + if(rendering.isConditionalFieldBehaviorEnabled() && FormFieldManager.isCustomizationEnabled()) + { + boolean flag2 = WidgetTypeAdapter.isInterfacePropertyComponentEnabled((InterfacePropertyComponent)currcomponent); + flag1 = flag1 && flag2; + } + } + } + catch(TCException tcexception) + { + //Logger.getLogger("com.teamcenter.rac.stylesheet.AbstractRendering").info(tcexception.getLocalizedMessage()); + } + } + } + + if(!(currcomponent instanceof JTabbedPane) && !(currcomponent instanceof JSplitPane) && + !(currcomponent instanceof JPanel) && !(currcomponent instanceof JLabel) && + !(currcomponent instanceof JScrollPane) && !(currcomponent instanceof JViewport) && + !(currcomponent instanceof JProgressBar) && !(currcomponent instanceof JTableHeader)) { + if(currcomponent instanceof JTextComponent) + ((JTextComponent)currcomponent).setEditable(flag1); + else + currcomponent.setEnabled(flag1); + } + + if(currcomponent instanceof InterfaceRendererEvent) { + if(flag1) + ((InterfaceRendererEvent)currcomponent).setReadWrite(); + else + ((InterfaceRendererEvent)currcomponent).setReadOnly(); + } + + if(currcomponent instanceof PropertyArray) { + ((PropertyArray)currcomponent).setModifiable(flag1); + } else if(currcomponent instanceof PropertyObjectLink) { + ((PropertyObjectLink)currcomponent).setModifiable(flag1); + } else if(currcomponent instanceof PropertyLogicalPanel) { + ((PropertyLogicalPanel)currcomponent).setModifiable(flag1); + } else if(currcomponent instanceof AbstractPropertyComponent) { + ((AbstractPropertyComponent)currcomponent).setModifiable(flag1); + } else if(currcomponent instanceof JScrollPane) { + JScrollPane jscrollpane = (JScrollPane)currcomponent; + java.awt.Component component2 = jscrollpane.getCorner("LOWER_LEFT_CORNER"); + if(component2 != null) + setModifiableComponents(component2, flag1); + component2 = jscrollpane.getCorner("LOWER_RIGHT_CORNER"); + if(component2 != null) + setModifiableComponents(component2, flag1); + component2 = jscrollpane.getCorner("UPPER_LEFT_CORNER"); + if(component2 != null) + setModifiableComponents(component2, flag1); + component2 = jscrollpane.getCorner("UPPER_RIGHT_CORNER"); + if(component2 != null) + setModifiableComponents(component2, flag1); + setModifiableComponents(((java.awt.Component) (jscrollpane.getViewport())), flag1); + } else if(currcomponent instanceof java.awt.Container) { + java.awt.Component acomponent[] = ((java.awt.Container)currcomponent).getComponents(); + if(acomponent != null) + { + for(int i = 0; i < acomponent.length; i++) + setModifiableComponents(acomponent[i], flag1); + } + } + } +} diff --git a/src/cn/com/ebewin/ysr/util/KUtil.java b/src/cn/com/ebewin/ysr/util/KUtil.java new file mode 100644 index 0000000..9faf7cb --- /dev/null +++ b/src/cn/com/ebewin/ysr/util/KUtil.java @@ -0,0 +1,238 @@ +package cn.com.ebewin.ysr.util; + +import java.lang.reflect.Method; +import java.util.Date; +import java.util.List; +import java.util.Vector; + +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentContextList; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.schedule.ScheduleViewApplication; +import com.teamcenter.rac.schedule.project.server.RACInterface.RACInterface; +import com.teamcenter.rac.schedule.project.server.RACInterface.RACInterfaceFactory; +import com.teamcenter.rac.schedule.scheduler.componentutils.TaskHelper; +import com.teamcenter.rac.schedule.soainterface.LoadSchedulesRunner; +import com.teamcenter.services.rac.projectmanagement._2011_06.ScheduleManagement; + +public class KUtil { + + public static final int SCH_TASK_TYPE_JIAGONG = 1; + public static final int SCH_TASK_TYPE_FENPI = 5; + public static final int SCH_TASK_TYPE_YIBAOJIAN = 3; + public static final int SCH_TASK_STATE_YIJIANYAN = 4; + public static final int TYPE_STRING = 1; + public static final int TYPE_DATE = 2; + private static final String TYPE_INSPRecord = "YSR8_INSPRecord"; + + private static int getINSPRecordMaxNum(String prefix,TCComponentQuery query,int max) throws Exception{ + String[] keys=new String[] {" ID",""}; + String[] vals=new String[] {prefix,TYPE_INSPRecord}; + AIFComponentContext[] res = ((TCComponentQuery)query).getExecuteResults(keys, vals); + System.out.println("ѯ "+prefix); + System.out.println("ѯ"+res.length); + for (AIFComponentContext c : res) { + InterfaceAIFComponent comp = c.getComponent(); + String id=comp.getProperty("item_id"); + String numStr=id.substring(prefix.length()-1); + System.out.println(id); + int num=0; + try { + num=Integer.parseInt(numStr); + } catch (Exception e) { + System.out.println("#޷id"+id); + e.printStackTrace(); + } + if(num>max) { + max=num; + } + } + return max; + } + + public static String getNewINSPRecordNum(String prefix, TCSession session) throws Exception { + System.out.println("ʼѯɢ¼ˮ..."); + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponent query=queryType.find("Item..."); + if(query==null) { + throw new Exception("ûҵѯItem..."); + } + if(!prefix.endsWith("*")) { + prefix=prefix+"*"; + } + int max=0; + max=getINSPRecordMaxNum(prefix,(TCComponentQuery) query,max); + prefix="FX-"+prefix; + max=getINSPRecordMaxNum(prefix,(TCComponentQuery) query,max); + max++; + if(max>9999) { + throw new Exception("ˮѴﵽֵ"); + } + return String.format("%04d", max); + } + + // kk 0905 TODO + public static TCProperty getNewlyAddedArrayProperty(String propName, TCComponentForm form, int count) throws Exception { + TCProperty prop = form.getFormTCProperty(propName); + if (prop == null) { + return null; + } + int cnt = prop.getStringArrayValue().length; + if (cnt == 0 && count > 0) { + String[] val = new String[count]; + for (int i = 0; i < count; i++) { +// val[i] = "ë˼ɵģ"; + val[i] = ""; + } +// CommonUtil.setByPass(true); +// prop.setStringValueArray(val); +// CommonUtil.setByPass(false); + } + return prop; + } + public static void setNewArrayProperty(TCComponentForm form) throws Exception { + System.out.println("setNewArrayProperty"); + TCProperty prop = form.getFormTCProperty("ysr8_ExWarehouseState"); + if (prop == null) { + return; + } + int cnt = prop.getStringArrayValue().length; + int count = form.getFormTCProperty("ysr8_SubTaskManuState").getStringValueArray().length; + if (cnt == 0 && count > 0) { + String[] val = new String[count]; + for (int i = 0; i < count; i++) { +// val[i] = "ë˼ɵģ"; + val[i] = ""; + } + Date[] dates = new Date[count]; + for (int i = 0; i < count; i++) { +// val[i] = "ë˼ɵģ"; + dates[i] = null; + } + CommonUtil.setByPass(true); + prop.setStringValueArray(val); + prop = form.getFormTCProperty("ysr8_ExWarehousePerson"); + prop.setStringValueArray(val); + prop = form.getFormTCProperty("ysr8_ExWarehouseRemark"); + prop.setStringValueArray(val); + prop = form.getFormTCProperty("ysr8_ExWarehouseQuantity"); + prop.setStringValueArray(val); + prop = form.getFormTCProperty("ysr8_ExWarehouseDate"); + prop.setDateValueArray(dates); + CommonUtil.setByPass(false); + } + } + + public static double getDoubleFromString(Object num, String numName) throws Exception { + double res = 0; + if (num != null && !"".equals(num)) { + try { + res = Double.parseDouble(TCUtil.getNumber(num.toString())); + } catch (Exception e) { + throw new Exception("" + numName + "" + num); + } + } + return res; + } + //TODO lidy20190529 + public static int getIntFromString(Object num, String numName) throws Exception { + int res = 0; + if (num != null && !"".equals(num)) { + try { + res = Integer.parseInt(TCUtil.getNumber(num.toString())); + } catch (Exception e) { + throw new Exception("" + numName + "" + num); + } + } + return res; + } + + public static List getTaskpredecessors(TCComponentScheduleTask task, TCSession session) throws Exception { + TCComponent schedule = TaskHelper.getScheduleForTask(task); + boolean isCurrentlyLoaded = false; + RACInterface racInterface = RACInterfaceFactory.singleton().getRACInterface(session, schedule); + if (ScheduleViewApplication.getApplication() != null) { + TCComponent tCComponent = ScheduleViewApplication.getApplication().getCurrentProject(); + if (tCComponent != null && tCComponent.equals(schedule)) { + System.out.println("ʱϵͳм"); + isCurrentlyLoaded = true; + } + } + if (!isCurrentlyLoaded) { + System.out.println("ʼʱ..."); + Object object; + LoadSchedulesRunner runner; + ScheduleManagement.LoadScheduleContainer[] arrloadScheduleContainer = new ScheduleManagement.LoadScheduleContainer[] { new ScheduleManagement.LoadScheduleContainer() }; + arrloadScheduleContainer[0].scheduleUids = new String[] { schedule.getUid() }; + runner = new LoadSchedulesRunner(arrloadScheduleContainer); + int n = runner.execute(); + if (n == 0 && (object = runner.getResults()) instanceof ScheduleManagement.MultipleScheduleLoadResponses) { + ScheduleManagement.MultipleScheduleLoadResponses multipleScheduleLoadResponses = (ScheduleManagement.MultipleScheduleLoadResponses) object; + ScheduleManagement.ScheduleLoadResponse[] arrscheduleLoadResponse = multipleScheduleLoadResponses.scheduleData; + if (arrscheduleLoadResponse != null && arrscheduleLoadResponse.length > 0) { + ScheduleManagement.ScheduleLoadResponse scheduleLoadResponse = arrscheduleLoadResponse[0]; + Class c = racInterface.getClass(); + Method m = c.getDeclaredMethod("populateDependencyCache", ScheduleManagement.ScheduleLoadResponse.class); + m.setAccessible(true); + m.invoke(racInterface, scheduleLoadResponse); + } + } else { + throw new Exception("ʱʧ"); + } + System.out.println("ʱ"); + } + List predecessors = racInterface.getPredecessorTasks(task); + return predecessors; + } + + public static TCComponentScheduleTask searchScheduleTask(TCSession session, String projectId, String taskType, String taskName) { + Vector attrVec = new Vector(); + Vector valVec = new Vector(); + attrVec.add(";"); + attrVec.add("Ŀ"); + attrVec.add(""); + valVec.add(taskType); + valVec.add(projectId); + valVec.add(taskName); + String[] attrs = (String[]) attrVec.toArray(new String[attrVec.size()]); + String[] vals = (String[]) valVec.toArray(new String[attrVec.size()]); + TCComponent[] tasks; + try { + tasks = query(session, "SearchSchedulTaskPLP_02", attrs, vals); + } catch (TCException e) { + e.printStackTrace(); + return null; + } + if (tasks != null && tasks.length > 0) { + for (TCComponent t : tasks) { + System.out.println("task : " + t); + } + } else { + return null; + } + return (TCComponentScheduleTask) tasks[0]; + } + + 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) { + throw new TCException("ûҵѯ" + queryName); + } + aKey = session.getTextService().getTextValues(aKey); + System.out.println("ѯ<" + queryName + ">"); + for (int i = 0; i < aKey.length; i++) { + System.out.println(aKey[i] + " = " + aVal[i]); + } + TCComponentContextList componentContextList = imancomponentquery.getExecuteResultsList(aKey, aVal); + return componentContextList.toTCComponentArray(); + } +} diff --git a/src/cn/com/ebewin/ysr/util/POIUtil.java b/src/cn/com/ebewin/ysr/util/POIUtil.java new file mode 100644 index 0000000..26fd72c --- /dev/null +++ b/src/cn/com/ebewin/ysr/util/POIUtil.java @@ -0,0 +1,363 @@ +package cn.com.ebewin.ysr.util; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +import javax.swing.JTable; + +import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.hssf.usermodel.HSSFRow; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.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.kernel.TCSession; + +public class POIUtil { + + /** + * Уʵλ + * @param sheet + * @param startRow:ʼ + * @param rows: + */ + public static void insertRow(Sheet sheet, int starRow, int rows) { + if(starRow>"+sourceCell); + if(sourceCell!=null) { + targetCell.setCellStyle(sourceCell.getCellStyle()); + targetCell.setCellType(sourceCell.getCellType()); + } + } + } + } + + public static void insertRow2(Sheet sheet, int startRow, int rows) { + sheet.shiftRows(startRow, sheet.getLastRowNum(), rows, true, false); + for (int i = 0; i < rows; i++) { + Row sourceRow = null;// ԭʼλ + Row targetRow = null;// ƶλ + Cell sourceCell = null; + Cell targetCell = null; + sourceRow = sheet.createRow(startRow); + targetRow = sheet.getRow(startRow + rows); + sourceRow.setHeight(targetRow.getHeight()); + if(targetRow!=null) {// add if null + for (int m = targetRow.getFirstCellNum(); m < targetRow.getLastCellNum(); m++) { + sourceCell = sourceRow.createCell(m); + targetCell = targetRow.getCell(m); + if(targetCell!=null) { + sourceCell.setCellStyle(targetCell.getCellStyle()); + sourceCell.setCellType(targetCell.getCellType()); + } + } + } + startRow++; + } + } + + //lidy20180913ͰDouble + public static void setCellData(HSSFCell cell,Object data) { + if(data!=null) { + try { + Double number = new Double(data.toString().replace(",", "")); + cell.setCellValue(number); + } catch(NumberFormatException e) { + try { + DateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + format.setLenient(false); + Date date=format.parse(data.toString()); + cell.setCellValue(date); + } catch(ParseException e1) { +// switch(cell.getCellType()) { +// case HSSFCell.CELL_TYPE_STRING: +// cell.setCellValue(String.valueOf(data)); +// break; +// case HSSFCell.CELL_TYPE_NUMERIC: +// cell.setCellValue(Double.valueOf(data.toString())); +// break; +// default: + cell.setCellType(XSSFCell.CELL_TYPE_STRING); + cell.setCellValue(String.valueOf(data)); +// } + } + } + } + } + private static void setCellData(XSSFCell cell,Object data) { + if(data!=null) { + try { + Double number = new Double(data.toString().replace(",", "")); + cell.setCellValue(number); + } catch(NumberFormatException e) { + try { + DateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + format.setLenient(false); + Date date=format.parse(data.toString()); + cell.setCellValue(date); + } catch(ParseException e1) { +// switch(cell.getCellType()) { +// case XSSFCell.CELL_TYPE_STRING: +// cell.setCellValue(String.valueOf(data)); +// break; +// case XSSFCell.CELL_TYPE_NUMERIC: +// cell.setCellValue(Double.valueOf(data.toString())); +// break; +// default: + cell.setCellType(XSSFCell.CELL_TYPE_STRING); + cell.setCellValue(String.valueOf(data)); +// } + } + } + } + } + + /** + * kk ʱΪģ嵼 + * @param table + */ + public static void outputExcel(TCSession session,JTable table,String qtyName,String srcFileTitle,String newFileTitle) { + File tempFile = TCUtil.findTemplete(session, qtyName, srcFileTitle); + if(tempFile==null) { + return; + } + InputStream input=null; + FileOutputStream output=null; + try { + Date date = new Date(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + String time = sdf.format(date); + String toPath = System.getProperty("java.io.tmpdir") + newFileTitle + time + ".xls"; + input=new FileInputStream(tempFile); + HSSFWorkbook wb=new HSSFWorkbook(input); + HSSFSheet sheet=wb.getSheetAt(0); + //д + int columnCount = table.getColumnCount(); // + int rowCount = table.getRowCount(); // + int startRow = 1; // ʼǰΪʼ + // + POIUtil.insertRow(sheet, 1, rowCount); + //д + HSSFRow row; + HSSFCell cell; + for (int i = 0; i < rowCount; i++) { + row=sheet.getRow(startRow+i); + for (int j = 0; j < columnCount; j++) { + cell=row.getCell(j); + if(cell==null) { + cell=row.createCell(j); + } + setCellData(cell, table.getValueAt(i, j)); + } + } + /*startRow = startRow + 1; + // д + for (int i = 0; i < rowCount; i++) { + for (int j = 0; j < columnCount; j++) { + Object objValue = table.getValueAt(i, j); + Label labelContent = new Label(j, i + startRow, String.valueOf(objValue), contentCellFormat); + wsheet.addCell(labelContent); + } + } + + // øʽ + wsheet.getSettings().setDefaultColumnWidth(20); + writeWorkBook.write(); + writeWorkBook.close();*/ + + output=new FileOutputStream(toPath); + wb.write(output); + + // 򿪵ıļ + Runtime.getRuntime().exec("cmd /c \"" + toPath + "\""); + + } catch (Exception e) { + e.printStackTrace(); + }finally { + if(output!=null) { + try { + output.close(); + } catch (IOException e) { + } + } + if(input!=null) { + try { + input.close(); + } catch (IOException e) { + } + } + tempFile.delete(); + } + } + public static void outputXlsx(TCSession session,JTable table,String qtyName,String srcFileTitle,String newFileTitle) { + File tempFile = TCUtil.findTemplete(session, qtyName, srcFileTitle); + if(tempFile==null) { + return; + } + InputStream input=null; + FileOutputStream output=null; + try { + Date date = new Date(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + String time = sdf.format(date); + String toPath = System.getProperty("java.io.tmpdir") + newFileTitle + time + ".xlsx"; + input=new FileInputStream(tempFile); + XSSFWorkbook wb=new XSSFWorkbook(input); + XSSFSheet sheet=wb.getSheetAt(0); + //д + int columnCount = table.getColumnCount(); // + int rowCount = table.getRowCount(); // + int startRow = 1; // ʼǰΪʼ + // + POIUtil.insertRow(sheet, 1, rowCount); + //д + XSSFRow row; + XSSFCell cell; + for (int i = 0; i < rowCount; i++) { +// if(i>0) +// copyRows(sheet, i+1, i+1, i+1); + row=sheet.getRow(startRow+i); + for (int j = 0; j < columnCount; j++) { +// System.out.println(startRow+"--"+i+"--"+j); + if(row.getCell(j)==null) { + cell=row.createCell(j); + }else { + cell=row.getCell(j); + } + setCellData(cell, table.getValueAt(i, j)); + } + } + /*startRow = startRow + 1; + // д + for (int i = 0; i < rowCount; i++) { + for (int j = 0; j < columnCount; j++) { + Object objValue = table.getValueAt(i, j); + Label labelContent = new Label(j, i + startRow, String.valueOf(objValue), contentCellFormat); + wsheet.addCell(labelContent); + } + } + + // øʽ + wsheet.getSettings().setDefaultColumnWidth(20); + writeWorkBook.write(); + writeWorkBook.close();*/ + + output=new FileOutputStream(toPath); + wb.write(output); + + // 򿪵ıļ + Runtime.getRuntime().exec("cmd /c \"" + toPath + "\""); + + } catch (Exception e) { + e.printStackTrace(); + }finally { + if(output!=null) { + try { + output.close(); + } catch (IOException e) { + } + } + if(input!=null) { + try { + input.close(); + } catch (IOException e) { + } + } + tempFile.delete(); + } + } +// private static void copyRows(XSSFSheet currentSheet, int startRow, int endRow, int pPosition) { +// int pStartRow = startRow - 1; +// int pEndRow = endRow - 1; +// int targetRowFrom; +// int targetRowTo; +// int columnCount; +// CellRangeAddress region = null; +// int i; +// int j; +// if (pStartRow == -1 || pEndRow == -1) { +// return; +// } +// for (i = 0; i < currentSheet.getNumMergedRegions(); i++) { +// region = currentSheet.getMergedRegion(i); +// if ((region.getFirstRow() >= pStartRow) && (region.getLastRow() <= pEndRow)) { +// targetRowFrom = region.getFirstRow() - pStartRow + pPosition; +// targetRowTo = region.getLastRow() - pStartRow + pPosition; +// CellRangeAddress newRegion = region.copy(); +// newRegion.setFirstRow(targetRowFrom); +// newRegion.setFirstColumn(region.getFirstColumn()); +// newRegion.setLastRow(targetRowTo); +// newRegion.setLastColumn(region.getLastColumn()); +// currentSheet.addMergedRegion(newRegion); +// } +// } +// for (i = pStartRow; i <= pEndRow; i++) { +// XSSFRow sourceRow = currentSheet.getRow(i); +// columnCount = sourceRow.getLastCellNum(); +// if (sourceRow != null) { +// XSSFRow newRow = currentSheet.createRow(pPosition - pStartRow + i); +// newRow.setHeight(sourceRow.getHeight()); +// for (j = 0; j < columnCount; j++) { +// XSSFCell templateCell = sourceRow.getCell(j); +// if (templateCell != null) { +// XSSFCell newCell = newRow.createCell(j); +// copyCell(templateCell, newCell); +// } +// } +// } +// } +// } +// private static void copyCell(XSSFCell srcCell, XSSFCell distCell) { +// distCell.setCellStyle(srcCell.getCellStyle()); +// if (srcCell.getCellComment() != null) { +// distCell.setCellComment(srcCell.getCellComment()); +// } +// int srcCellType = srcCell.getCellType(); +// distCell.setCellType(srcCellType); +// if (srcCellType == XSSFCell.CELL_TYPE_NUMERIC) { +// if (DateUtil.isCellDateFormatted(srcCell)) { +// distCell.setCellValue(srcCell.getDateCellValue()); +// } else { +// distCell.setCellValue(srcCell.getNumericCellValue()); +// } +// } else if (srcCellType == XSSFCell.CELL_TYPE_STRING) { +// distCell.setCellValue(srcCell.getRichStringCellValue()); +// } else if (srcCellType == XSSFCell.CELL_TYPE_BLANK) { +// // nothing21 +// } else if (srcCellType == XSSFCell.CELL_TYPE_BOOLEAN) { +// distCell.setCellValue(srcCell.getBooleanCellValue()); +// } else if (srcCellType == XSSFCell.CELL_TYPE_ERROR) { +// distCell.setCellErrorValue(srcCell.getErrorCellValue()); +// } else if (srcCellType == XSSFCell.CELL_TYPE_FORMULA) { +// distCell.setCellFormula(srcCell.getCellFormula()); +// } else { // nothing29 +// +// } +// } +} diff --git a/src/cn/com/ebewin/ysr/util/POIUtil07.java b/src/cn/com/ebewin/ysr/util/POIUtil07.java new file mode 100644 index 0000000..aee247d --- /dev/null +++ b/src/cn/com/ebewin/ysr/util/POIUtil07.java @@ -0,0 +1,162 @@ +package cn.com.ebewin.ysr.util; + +import java.util.List; + +import org.apache.poi.POIXMLDocumentPart; +import org.apache.poi.ss.usermodel.ClientAnchor; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFDrawing; +import org.apache.poi.xssf.usermodel.XSSFPicture; +import org.apache.poi.xssf.usermodel.XSSFPrintSetup; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFShape; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +public class POIUtil07 { + + /** + * excelв + * @param wb Workbook + * @param sheet sheet + * @param starRow ʼУӴ濪ʼ + * @param rows + */ + public static void insertRow(XSSFWorkbook wb, XSSFSheet sheet, int starRow, int rows) { + if(starRow= sheetFrom.getFirstRowNum()) && (region.getLastRow() <= sheetFrom.getLastRowNum())) { + sheetTo.addMergedRegion(region); + } + } + for (int intRow = sheetFrom.getFirstRowNum(); intRow < sheetFrom.getLastRowNum(); intRow++) { + rowFrom = sheetFrom.getRow(intRow); + rowTo = sheetTo.createRow(intRow); + if (null == rowFrom) + continue; + rowTo.setHeight(rowFrom.getHeight()); + for (int intCol = 0; intCol < rowFrom.getLastCellNum(); intCol++) { + sheetTo.setDefaultColumnStyle(intCol, sheetFrom.getColumnStyle(intCol)); + sheetTo.setColumnWidth(intCol, sheetFrom.getColumnWidth(intCol)); + cellFrom = rowFrom.getCell(intCol); + cellTo = rowTo.createCell(intCol); + if (null == cellFrom) + continue; + cellTo.setCellStyle(cellFrom.getCellStyle()); + int cType = cellFrom.getCellType(); + cellTo.setCellType(cType); + switch (cType) { + case XSSFCell.CELL_TYPE_STRING: + cellTo.setCellValue(cellFrom.getRichStringCellValue()); + break; + case XSSFCell.CELL_TYPE_NUMERIC: + cellTo.setCellValue(cellFrom.getNumericCellValue()); + break; + case XSSFCell.CELL_TYPE_FORMULA: + cellTo.setCellFormula(cellFrom.getCellFormula()); + break; + case XSSFCell.CELL_TYPE_BOOLEAN: + cellTo.setCellValue(cellFrom.getBooleanCellValue()); + break; + case XSSFCell.CELL_TYPE_ERROR: + cellTo.setCellValue(cellFrom.getErrorCellValue()); + break; + default: + cellTo.setCellValue(cellFrom.getRichStringCellValue()); + break; + } + /*if (null != cellFrom.getStringCellValue() && !"".equals(cellFrom.getStringCellValue().trim())) + cellTo.setCellValue(cellFrom.getStringCellValue());*/ + } + } + for (POIXMLDocumentPart dr : sheetFrom.getRelations()) { + if (dr instanceof XSSFDrawing) { + XSSFDrawing drawing = (XSSFDrawing) dr; + List shapes = drawing.getShapes(); + for (XSSFShape shape : shapes) { + XSSFPicture pic = (XSSFPicture) shape; + patriarchTo.createPicture((ClientAnchor) pic.getAnchor(), workbook.addPicture(pic.getPictureData().getData(),XSSFWorkbook.PICTURE_TYPE_PNG)); + } + } + } + //kk 0909 Ƶʱƴӡ + XSSFPrintSetup srcPrintSetup = sheetFrom.getPrintSetup(); + if (srcPrintSetup != null) { + XSSFPrintSetup printSetup = (XSSFPrintSetup) sheetTo.getPrintSetup(); + printSetup.setOrientation(srcPrintSetup.getOrientation()); + printSetup.setPaperSize(srcPrintSetup.getPaperSize()); + printSetup.setFitHeight(srcPrintSetup.getFitHeight()); + printSetup.setFitWidth(srcPrintSetup.getFitWidth()); + printSetup.setFooterMargin(srcPrintSetup.getFooterMargin()); + printSetup.setHeaderMargin(srcPrintSetup.getHeaderMargin()); + } + sheetTo.setMargin(XSSFSheet.TopMargin, sheetFrom.getMargin(XSSFSheet.TopMargin)); + sheetTo.setMargin(XSSFSheet.BottomMargin, sheetFrom.getMargin(XSSFSheet.BottomMargin)); + sheetTo.setMargin(XSSFSheet.LeftMargin, sheetFrom.getMargin(XSSFSheet.LeftMargin)); + sheetTo.setMargin(XSSFSheet.RightMargin, sheetFrom.getMargin(XSSFSheet.RightMargin)); + String area = workbook.getPrintArea(workbook.getSheetIndex(sheetFrom)); + workbook.setPrintArea(workbook.getSheetIndex(sheetTo), area); + sheetTo.setDisplayGridlines(false); + sheetTo.setZoom(100, 100); + return sheetTo; + } +} diff --git a/src/cn/com/ebewin/ysr/util/PolymorphicJList.java b/src/cn/com/ebewin/ysr/util/PolymorphicJList.java new file mode 100644 index 0000000..9c3de03 --- /dev/null +++ b/src/cn/com/ebewin/ysr/util/PolymorphicJList.java @@ -0,0 +1,331 @@ +package cn.com.ebewin.ysr.util; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Font; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Image; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.StreamTokenizer; + +import javax.swing.DefaultListModel; +import javax.swing.ImageIcon; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.ListCellRenderer; +import javax.swing.ScrollPaneConstants; +import javax.swing.UIDefaults; +import javax.swing.UIManager; + +@SuppressWarnings({"rawtypes","unchecked"}) +public class PolymorphicJList extends JList { + + private static final long serialVersionUID = 1L; + + static Color listForeground, listBackground, listSelectionForeground, listSelectionBackground; + static { + UIDefaults uid = UIManager.getLookAndFeel().getDefaults(); + listForeground = uid.getColor("List.foreground"); + listBackground = uid.getColor("List.background"); + listSelectionForeground = uid.getColor("List.selectionForeground"); + listSelectionBackground = uid.getColor("List.selectionBackground"); + } + ImageIcon fileIcon, textFileIcon, directoryIcon, imageFileIcon, pngFileIcon, gifFileIcon, jpegFileIcon; + JComponent fileCellPrototype, textCellPrototype, imageCellPrototype, directoryCellPrototype; + JLabel fileNameLabel, textNameLabel, directoryNameLabel, imageNameLabel, fileSizeLabel, textSizeLabel, + textWordCountLabel, directoryCountLabel, imageSizeLabel, imageIconLabel; + + public PolymorphicJList(File dir) { + super(); + buildPrototypeCells(); + setCellRenderer(new PolyRenderer()); + setModel(new DefaultListModel()); + if (!dir.isDirectory()) + dir = new File(dir.getParent()); + buildModelFromDir(dir); + } + + public static void main(String[] args) { + File dir = new File("."); + if (args.length > 0) + dir = new File(args[0]); + JList list = new PolymorphicJList(dir); + JScrollPane pain = new JScrollPane(list, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, + ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + JFrame frame = new JFrame("PolymorphicJList"); + frame.getContentPane().add(pain); + frame.pack(); + frame.setVisible(true); + } + + protected void buildModelFromDir(File dir) { + File[] files = dir.listFiles(); + DefaultListModel mod = (DefaultListModel) getModel(); + for (int i = 0; i < files.length; i++) { + if (isTextFile(files[i])) + mod.addElement(new TextFileItem(files[i])); + else if (isImageFile(files[i])) + mod.addElement(new ImageFileItem(files[i])); + else if (files[i].isDirectory()) + mod.addElement(new DirectoryItem(files[i])); + else + mod.addElement(new FileItem(files[i])); + } + } + + protected boolean isImageFile(File f) { + if (f.isDirectory()) + return false; + String name = f.getName(); + return name.endsWith(".gif") || name.endsWith(".GIF") || name.endsWith(".jpg") || name.endsWith(".JPG") + || name.endsWith(".jpeg") || name.endsWith(".JPEG") || name.endsWith(".bmp") || name.endsWith(".BMP") + || name.endsWith(".png") || name.endsWith(".PNG"); + } + + protected boolean isTextFile(File f) { + if (f.isDirectory()) + return false; + String name = f.getName(); + return name.endsWith(".txt") || name.endsWith(".html") || name.endsWith(".xml") || name.endsWith(".xhtml") + || name.endsWith(".java") || name.endsWith(".c") || name.endsWith(".cpp") || name.endsWith(".c++") + || name.endsWith(".m") || name.endsWith(".h"); + } + + protected void buildIcons() { + String SEP = System.getProperty("file.separator"); + fileIcon = new ImageIcon("images" + SEP + "generic.gif"); + textFileIcon = new ImageIcon("images" + SEP + "text.gif"); + directoryIcon = new ImageIcon("images" + SEP + "folder.gif"); + imageFileIcon = new ImageIcon("images" + SEP + "image.gif"); + pngFileIcon = new ImageIcon("images" + SEP + "png.gif"); + gifFileIcon = new ImageIcon("images" + SEP + "gif.gif"); + jpegFileIcon = new ImageIcon("images" + SEP + "jpeg.gif"); + + } + + protected void buildPrototypeCells() { + buildIcons(); + fileCellPrototype = new JPanel(); + fileCellPrototype.setLayout(new GridBagLayout()); + addWithGridBag(new JLabel(fileIcon), fileCellPrototype, 0, 0, 1, 2, GridBagConstraints.WEST, + GridBagConstraints.BOTH, 0, 0); + fileNameLabel = new JLabel(); + Font defaultLabelFont = fileNameLabel.getFont(); + Font nameFont = defaultLabelFont.deriveFont(Font.BOLD, defaultLabelFont.getSize() + 2); + fileNameLabel.setFont(nameFont); + addWithGridBag(fileNameLabel, fileCellPrototype, 1, 0, 1, 1, GridBagConstraints.NORTH, + GridBagConstraints.HORIZONTAL, 1, 0); + fileSizeLabel = new JLabel(); + addWithGridBag(fileSizeLabel, fileCellPrototype, 1, 1, 1, 1, GridBagConstraints.SOUTH, + GridBagConstraints.HORIZONTAL, 1, 0); + opacify(fileCellPrototype); + // text file + textCellPrototype = new JPanel(); + textCellPrototype.setLayout(new GridBagLayout()); + addWithGridBag(new JLabel(textFileIcon), textCellPrototype, 0, 0, 1, 2, GridBagConstraints.WEST, + GridBagConstraints.BOTH, 0, 0); + textNameLabel = new JLabel(); + textNameLabel.setFont(nameFont); + addWithGridBag(textNameLabel, textCellPrototype, 1, 0, 2, 1, GridBagConstraints.NORTH, + GridBagConstraints.HORIZONTAL, 1, 0); + textSizeLabel = new JLabel(); + textWordCountLabel = new JLabel(); + addWithGridBag(textSizeLabel, textCellPrototype, 1, 1, 1, 1, GridBagConstraints.NORTH, + GridBagConstraints.HORIZONTAL, 0, 0); + addWithGridBag(textWordCountLabel, textCellPrototype, 2, 1, 1, 1, GridBagConstraints.SOUTH, + GridBagConstraints.HORIZONTAL, 1, 0); + + opacify(textCellPrototype); + // directory + directoryCellPrototype = new JPanel(); + directoryCellPrototype.setLayout(new GridBagLayout()); + addWithGridBag(new JLabel(directoryIcon), directoryCellPrototype, 0, 0, 1, 2, GridBagConstraints.WEST, + GridBagConstraints.BOTH, 0, 0); + directoryNameLabel = new JLabel(); + directoryNameLabel.setFont(nameFont); + addWithGridBag(directoryNameLabel, directoryCellPrototype, 1, 0, 1, 1, GridBagConstraints.NORTH, + GridBagConstraints.HORIZONTAL, 1, 0); + directoryCountLabel = new JLabel(); + addWithGridBag(directoryCountLabel, directoryCellPrototype, 1, 1, 1, 1, GridBagConstraints.SOUTH, + GridBagConstraints.HORIZONTAL, 1, 0); + opacify(directoryCellPrototype); + // image + imageCellPrototype = new JPanel(); + imageCellPrototype.setLayout(new GridBagLayout()); + addWithGridBag(new JLabel(imageFileIcon), imageCellPrototype, 0, 0, 1, 2, GridBagConstraints.WEST, + GridBagConstraints.BOTH, 0, 0); + imageNameLabel = new JLabel(); + imageNameLabel.setFont(nameFont); + addWithGridBag(imageNameLabel, imageCellPrototype, 1, 0, 1, 1, GridBagConstraints.NORTH, + GridBagConstraints.HORIZONTAL, 1, 0); + imageSizeLabel = new JLabel(); + addWithGridBag(imageSizeLabel, imageCellPrototype, 1, 1, 1, 1, GridBagConstraints.SOUTH, + GridBagConstraints.HORIZONTAL, 1, 0); + imageIconLabel = new JLabel(); + addWithGridBag(imageIconLabel, imageCellPrototype, 2, 0, 1, 2, GridBagConstraints.EAST, + GridBagConstraints.VERTICAL, 0, 0); + opacify(imageCellPrototype); + } + + private void addWithGridBag(Component comp, Container cont, int x, int y, int width, int height, int anchor, + int fill, int weightx, int weighty) { + GridBagConstraints gbc = new GridBagConstraints(); + gbc.gridx = x; + gbc.gridy = y; + gbc.gridwidth = width; + gbc.gridheight = height; + gbc.anchor = anchor; + gbc.fill = fill; + gbc.weightx = weightx; + gbc.weighty = weighty; + cont.add(comp, gbc); + + } + + private void opacify(Container prototype) { + Component[] comps = prototype.getComponents(); + for (int i = 0; i < comps.length; i++) { + if (comps[i] instanceof JComponent) + ((JComponent) comps[i]).setOpaque(true); + } + } + + class FileItem extends Object { + File file; + + public FileItem(File f) { + file = f; + } + } + + class ImageFileItem extends FileItem { + ImageIcon icon; + + public ImageFileItem(File f) { + super(f); + initIcon(); + } + + void initIcon() { + icon = new ImageIcon(file.getPath()); + // scale to 32 pix in largest dimension + Image img = icon.getImage(); + float factor = 1.0f; + if (img.getWidth(null) > img.getHeight(null)) + factor = Math.min(32f / img.getWidth(null), 1.0f); + else + factor = Math.min(32f / img.getHeight(null), 1.0f); + Image scaledImage = img.getScaledInstance((int) (img.getWidth(null) * factor), + (int) (img.getHeight(null) * factor), Image.SCALE_FAST); + icon.setImage(scaledImage); + } + } + + class DirectoryItem extends FileItem { + int childCount; + + public DirectoryItem(File f) { + super(f); + initChildCount(); + } + + public int getChildCount() { + return childCount; + } + + void initChildCount() { + if (!file.isDirectory()) + childCount = -1; + else + childCount = file.listFiles().length; + System.out.println(file.getPath() + ": " + childCount + " items"); + } + } + + class TextFileItem extends FileItem { + int wordCount = -1; + + public TextFileItem(File f) { + super(f); + initWordCount(); + } + + public int getWordCount() { + return wordCount; + } + + protected void initWordCount() { + try { + StreamTokenizer izer = new StreamTokenizer(new BufferedReader(new FileReader(file))); + while (izer.nextToken() != StreamTokenizer.TT_EOF) + wordCount++; + } catch (Exception e) { + e.printStackTrace(); + wordCount = -1; + } + System.out.println(file.getPath() + ": " + wordCount + " words"); + } + } + + class PolyRenderer extends Object implements ListCellRenderer { + + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, + boolean cellHasFocus) { + + if (value instanceof DirectoryItem) { + DirectoryItem item = (DirectoryItem) value; + directoryNameLabel.setText(item.file.getName()); + directoryCountLabel.setText(item.getChildCount() + " items"); + setColorsForSelectionState(directoryCellPrototype, isSelected); + return directoryCellPrototype; + } else if (value instanceof TextFileItem) { + TextFileItem item = (TextFileItem) value; + // populate values + textNameLabel.setText(item.file.getName()); + textSizeLabel.setText(item.file.length() + " bytes "); + textWordCountLabel.setText(item.getWordCount() + " words"); + setColorsForSelectionState(textCellPrototype, isSelected); + return textCellPrototype; + } else if (value instanceof ImageFileItem) { + ImageFileItem item = (ImageFileItem) value; + // pouplate values + imageNameLabel.setText(item.file.getName()); + imageSizeLabel.setText(item.file.length() + " bytes"); + imageIconLabel.setIcon(item.icon); + setColorsForSelectionState(imageCellPrototype, isSelected); + return imageCellPrototype; + } else { + FileItem item = (FileItem) value; + // pouplate values + fileNameLabel.setText(item.file.getName()); + fileSizeLabel.setText(item.file.length() + " bytes"); + setColorsForSelectionState(fileCellPrototype, isSelected); + return fileCellPrototype; + } + } + + private void setColorsForSelectionState(Container prototype, boolean isSelected) { + + Component[] comps = prototype.getComponents(); + for (int i = 0; i < comps.length; i++) { + if (isSelected) { + comps[i].setForeground(listSelectionForeground); + comps[i].setBackground(listSelectionBackground); + } else { + comps[i].setForeground(listForeground); + comps[i].setBackground(listBackground); + + } + } + } + } +} \ No newline at end of file diff --git a/src/cn/com/ebewin/ysr/util/TCUtil.java b/src/cn/com/ebewin/ysr/util/TCUtil.java new file mode 100644 index 0000000..eb7e428 --- /dev/null +++ b/src/cn/com/ebewin/ysr/util/TCUtil.java @@ -0,0 +1,1262 @@ +package cn.com.ebewin.ysr.util; + +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; + } + + /** + * ȽBOMLinePSEгֵĴ + * @param preBomLine + * @param currentBomLine + * @return + */ + 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 }; + } + } + + /** + * (ѰһbomLinePSEгֵĴ) + * + * @param bomLine + * @return + */ + public static double totalBOMLineQuantity(TCComponentBOMLine bomLine) { + + double count = 0; + try { + String itemID = bomLine.getProperty("bl_item_item_id");//bomlineIDB09-043 + String install = bomLine.getProperty("YSR8_InstallP_bom"); + TCComponentBOMLine rootBomLine = bomLine; + while (rootBomLine.parent() != null) { + rootBomLine = rootBomLine.parent(); + } + String rootBomlineItemId = rootBomLine.getProperty("bl_item_item_id"); + System.out.println("ִloopΣ\n ڵ="+rootBomlineItemId+",\n ǰbomlineĸڵ㣨ûиڵȡǰbomline="+itemID); + count += loop(rootBomLine, itemID + install, true); + } catch (TCException e) { + e.printStackTrace(); + } + return count; + } + + /** + * ѰһbomLinePSEгֵĴ + * Ѱbomlineġid͡ƴַbomṹгֵĴ + * @param rootBomLine rootBomLine + * @param itemID bomlineԣid + YSR8_InstallP_bomֵ + * @param loopFlag ǷҪв + * @throws TCException + */ + private static double loop(TCComponentBOMLine rootBomLine, String itemID, Boolean loopFlag) throws TCException { + + System.out.println("============================"); + System.out.println("bomline"+itemID+"loopʼ"); + System.out.println("============================"); + String inputBomline = rootBomLine.getProperty("bl_item_item_id"); + System.out.println("rootBomLineڵ㣺"+inputBomline); + double count = 0; + AIFComponentContext[] context = rootBomLine.getChildren(); + String parentQuantity = rootBomLine.getProperty("bl_quantity"); + System.out.println("parentQuantity="+parentQuantity); + 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 rootInstall = rootBomLine.getProperty("YSR8_InstallP_bom"); + System.out.println("ǰchildItem" + childrenID + rootInstall); + if ((childrenID + rootInstall).equals(itemID)) { + String quantity = children.getProperty("bl_quantity"); + quantity = quantity.isEmpty() ? "1" : quantity; + System.out.println("ƥɹǰbomline"+childrenID+"quantity="+quantity+" bomline"+itemID+"count++"); + count += Double.parseDouble(quantity); + System.out.println("count"+count); + } else if (loopFlag) { + System.out.println("ҪӼвѯid"+itemID); + count += loop(children, itemID, loopFlag); + System.out.println("count="+count); + // System.out.println("ҪItem" + itemID + " ϼBomLine" + parentQuantity + "Ŀǰ" + count); + } + } + System.out.println("loopշ="+count); + System.out.println("============================"); + System.out.println("bomline"+itemID+"loop"); + System.out.println("============================"); + //TODO 20250414жcountǷΪ0Ϊ0ֵֶ1 + 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汾 + * @param pseudoFolder + * @param item_id + * @return + */ + 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/com/ebewin/ysr/util/TableColorRender.java b/src/cn/com/ebewin/ysr/util/TableColorRender.java new file mode 100644 index 0000000..0d913cc --- /dev/null +++ b/src/cn/com/ebewin/ysr/util/TableColorRender.java @@ -0,0 +1,71 @@ +package cn.com.ebewin.ysr.util; + +import java.awt.Color; +import java.awt.Component; +import java.util.HashMap; + +import javax.swing.JTable; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.TableCellRenderer; + +public class TableColorRender implements TableCellRenderer { + // + public static final DefaultTableCellRenderer DEFAULT_RENDERER = new DefaultTableCellRenderer(); + + //Integer Stringʶ Colorɫ + public HashMap> allForegroundInfos = new HashMap>(); + public HashMap allFColorColumn = new HashMap(); + + //Integer Stringʶ Colorɫ + public HashMap> allBackgroundInfos = new HashMap>(); + public HashMap allBColorColumn = new HashMap(); + + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + Component renderer = DEFAULT_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + + if (value != null && value instanceof String) { + Color foreground = table.getForeground(); + Color background = table.getBackground(); + if (isSelected) { + background = new Color(10, 36, 106); + } + + Boolean bSetFG = false; + Integer infoCol = allFColorColumn.get(column); + if (infoCol != null) { + HashMap fgc = allForegroundInfos.get(infoCol); + if (fgc != null) { + String infoValue = table.getValueAt(row, infoCol).toString(); + Color color = fgc.get(infoValue); + if (color != null) { + foreground = color; + bSetFG = true; + } + } + } + + Boolean bSetBG = false; + infoCol = allBColorColumn.get(column); + if (infoCol != null) { + HashMap bgc = allBackgroundInfos.get(infoCol); + if (bgc != null) { + String infoValue = table.getValueAt(row, infoCol).toString(); + Color color = bgc.get(infoValue); + if (color != null) { + background = color; + bSetBG = true; + } + } + } + + if (!bSetFG && !bSetBG && isSelected) { + foreground = Color.WHITE; + } + + renderer.setForeground(foreground); + renderer.setBackground(background); + } + + return renderer; + } +} \ No newline at end of file diff --git a/src/cn/com/ebewin/ysr/util/Test.java b/src/cn/com/ebewin/ysr/util/Test.java new file mode 100644 index 0000000..0e937a7 --- /dev/null +++ b/src/cn/com/ebewin/ysr/util/Test.java @@ -0,0 +1,191 @@ +package cn.com.ebewin.ysr.util; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Stack; + +public class Test { + private static final char M = '"'; + + public static void main(String[] args) { + /*String[] s = new String[] { "2", "1", "5", "4", "9", "6", "10", "1" }; + int n = s.length; + String temp; + for (int i = 0; i < n; i++) { + for (int j = 0; j < n - i - 1; j++) { + if (s[j].compareTo(s[j + 1]) > 0) { + temp = s[j]; + s[j] = s[j + 1]; + s[j + 1] = temp; + } + } + } + for (String string : s) { + System.out.println(string); + }*/ + /*double d=2.1; + System.out.println(Math.round(d)); + + double d1 = 234.3434343; + DecimalFormat df=new DecimalFormat("#"); + System.out.println(df.format(d1));*/ + List t=new ArrayList<>(); + t.add("1"); + t.add("1"); + t.add("1"); + t.add("1"); + System.out.println(t.toArray(new String[] {})); + + } + + public static void calculate() { + Map vaMap = new HashMap<>(); + vaMap.put("a", new BigDecimal(1)); + vaMap.put("b", new BigDecimal(2)); + vaMap.put("c", new BigDecimal(3)); + vaMap.put("d", new BigDecimal(4)); + vaMap.put("e", new BigDecimal(5)); + // "a"+"b"*("c"+"d")+"e" + String formular = "\"a\"+\"b\"*(\"c\"+\"d\")+\"e\""; + try { + BigDecimal res = doTheMath(vaMap, formular); + System.out.println(res); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static BigDecimal doTheMath(Map variables, String formular) throws Exception { + String newFormualr = parseFormular(variables, formular); + System.out.println(newFormualr); + return getResult(newFormualr); + } + + private static String parseFormular(Map variables, String formular) throws Exception { + StringBuilder res = new StringBuilder(); + for (int i = 0; i < formular.length(); i++) { + char c = formular.charAt(i); + if (c == M) { + String var = formular.substring(i + 1); + int ind = var.indexOf(M); + if (ind == -1) { + throw new Exception("formular error"); + } + var = var.substring(0, ind); + if (variables.containsKey(var)) { + res.append(variables.get(var)); + } else { + throw new Exception("var not set"); + } + i = i + var.length() + 1; + } else { + res.append(c); + } + } + return res.toString(); + } + + public static BigDecimal getResult(String input) { + // 淶ʽ,û + input = input.replaceAll("", "("); + input = input.replaceAll("", ")"); + // 빫ʽ,/,ÿոֿ,Ա + String[] inputs = input.split(""); + String format = ""; + for (int i = 0; i < inputs.length; i++) { + if (inputs[i].equals(" ")) { + continue; + } else if (inputs[i].equals("(") || inputs[i].equals(")") || inputs[i].equals("+") || inputs[i].equals("-") || inputs[i].equals("*") || inputs[i].equals("/")) { + format += " " + inputs[i] + " "; + } else { + format += inputs[i]; + } + } + List strings = changeInfixExpressionToPostfixExpression(format); + Stack stack = new Stack(); + for (int i = 0; i < strings.size(); i++) { + if (strings.get(i).equals("+")) { + BigDecimal a = new BigDecimal(stack.pop()); + BigDecimal b = new BigDecimal(stack.pop()); + stack.add(b.add(a).toString()); + } else if (strings.get(i).equals("-")) { + BigDecimal a = new BigDecimal(stack.pop()); + BigDecimal b = new BigDecimal(stack.pop()); + stack.add(b.subtract(a).toString()); + } else if (strings.get(i).equals("*")) { + BigDecimal a = new BigDecimal(stack.pop()); + BigDecimal b = new BigDecimal(stack.pop()); + stack.add(b.multiply(a).toString()); + } else if (strings.get(i).equals("/")) { + BigDecimal a = new BigDecimal(stack.pop()); + BigDecimal b = new BigDecimal(stack.pop()); + // 1000Ժľȷλ,1000λҲٶ,һʽ0.01ھ,dz + stack.add(b.divide(a, 1000, BigDecimal.ROUND_HALF_DOWN).toString()); + } else { + stack.add(strings.get(i)); + } + } + // صʱʽһ,ȡСλ + return new BigDecimal(stack.pop()).setScale(2, BigDecimal.ROUND_HALF_DOWN); + } + + public static List changeInfixExpressionToPostfixExpression(String input) { + List resultList = new ArrayList(); + Stack tempStack = new Stack(); + String[] splitArray = input.split(" "); + for (int i = 0; i < splitArray.length; i++) { + if (splitArray[i].equals("")) { + continue; + } + // ַŵĻ,˵ǰһй,ջһ֮ǰȫӵList + if (splitArray[i].equals(")")) { + while (!tempStack.peek().equals("(")) { + resultList.add(tempStack.pop()); + } + tempStack.pop();// ȥǰ + } else if (splitArray[i].equals("(")) { + // ,ôֱӽȥ + tempStack.add("("); + } else if (splitArray[i].equals("+") || splitArray[i].equals("-")) { + // ǼӼ,Ҫж + if (tempStack.empty() || tempStack.peek().equals("(")) { + tempStack.add(splitArray[i]); + } else if (tempStack.peek().equals("+") || tempStack.peek().equals("-")) { + // ʱջĶ,ҲǼӼȡһ,ʱջ,dz˳ͿʼȡΪֹ + resultList.add(tempStack.pop()); + tempStack.add(splitArray[i]); + } else { + while (!tempStack.empty()) { + if (tempStack.peek().equals("(")) { + break; + } else { + resultList.add(tempStack.pop()); + } + } + tempStack.add(splitArray[i]); + } + } else if (splitArray[i].equals("*") || splitArray[i].equals("/")) { + // dz˳ + if (!tempStack.empty()) { + // жʱջջɶ,dz˳,ȡһ,ʱջ + if (tempStack.peek().equals("*") || tempStack.peek().equals("/")) { + resultList.add(tempStack.pop()); + } + } + tempStack.add(splitArray[i]); + } else { + // ˵ǷǷ,ӽȥ + resultList.add(splitArray[i]); + } + } + // ,ʱstackĶӵstackȥ + while (!tempStack.empty()) { + resultList.add(tempStack.pop()); + } + return resultList; + } + +} diff --git a/src/cn/com/ebewin/ysr/util/UIUtil.java b/src/cn/com/ebewin/ysr/util/UIUtil.java new file mode 100644 index 0000000..43b025e --- /dev/null +++ b/src/cn/com/ebewin/ysr/util/UIUtil.java @@ -0,0 +1,2010 @@ +package cn.com.ebewin.ysr.util; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.io.InputStream; +import java.text.DecimalFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.EventObject; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map.Entry; +import java.util.Vector; + +import javax.swing.AbstractCellEditor; +import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; +import javax.swing.DefaultCellEditor; +import javax.swing.Icon; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.border.TitledBorder; +import javax.swing.plaf.basic.BasicTableUI; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; + +import cn.com.ebewin.ysr.dialog.SelectUserDialog; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.commands.open.OpenFormDialog; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCFormProperty; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.stylesheet.PropertyDateButton; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.iTextField; + +//PackCodeDescInfos packCodeDescInfos = new PackCodeDescInfos(); +////(new NewCodeItemDialog(AIFDesktop.getActiveDesktop().getShell(), itemType, packCodeDescInfos)).open(); +//(new NewCodeItemDialog(AIFDesktop.getActiveDesktop().getShell(), "", packCodeDescInfos)).open(); +//if(packCodeDescInfos.getGenerateID() != null) +//{ +// itemIDText.setText(packCodeDescInfos.getGenerateID()); +//} + +@SuppressWarnings({ "deprecation", "unchecked" }) +public class UIUtil { + public TCSession session = null; + public static final int MINWIDTH = 1280; + public static final int MINHEIGHT = 768; + public boolean isCheckOut = false; + protected String fromType = ""; + + public class ComponentInfo { + public String name = ""; + public String type = "JLabel";// JPanelEtchedBorder-ο;JPanel-;JScrollPane- + public String title = ""; + public String valueStyle = "";// int-;uint-;float-С;floatn-С,nλ + public String defValType = "";// normal-ͨ;sys-ϵͳ; + public String defVal = "";// user-ǰû; + public int width = 150; + public int height = 23; + + public int row = 1; + public int col = 1; + + public boolean readOnly = false; + public boolean required = false; + + public boolean isProComponent = false; + + public JTableInfo parentTableInfo = null; + public List childComponentInfos = new ArrayList(); + + public Component linkComponent = null; + } + + public void fitToScreen(AbstractAIFDialog abstractAIFDialog) { + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + double screenWidth = screenSize.getWidth(); + double screenHeight = screenSize.getHeight(); + Dimension dialogSize = abstractAIFDialog.getSize(); + if (screenWidth < MINWIDTH && dialogSize.getWidth() > 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 void fitToScreen(OpenFormDialog openFormDialog) { + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + double screenWidth = screenSize.getWidth(); + double screenHeight = screenSize.getHeight(); + Dimension dialogSize = openFormDialog.getSize(); + if (screenWidth < MINWIDTH && dialogSize.getWidth() > screenWidth) { + openFormDialog.setSize(new Dimension((int) Math.floor(screenWidth - 20), (int) Math.floor(dialogSize.getHeight()))); + openFormDialog.setLocation(10, (int) Math.floor(openFormDialog.getLocation().getY())); + } + if (screenHeight < MINHEIGHT && dialogSize.getHeight() > screenHeight) { + openFormDialog.setSize(new Dimension((int) Math.floor(dialogSize.getWidth()), (int) Math.floor(screenHeight - 20))); + openFormDialog.setLocation((int) Math.floor(openFormDialog.getLocation().getX()), 10); + } + /* + * if((screenWidth + * MINWIDTH||dialogSize.getHeight()>MINHEIGHT)) { openFormDialog.setSize(new + * Dimension((int)Math.floor(screenWidth-20),(int)Math.floor(screenHeight-20))); + * openFormDialog.setLocation(10, 10); } + */ + } + + public void fitToScreen(JFrame frame) { + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + double screenWidth = screenSize.getWidth(); + double screenHeight = screenSize.getHeight(); + Dimension dialogSize = frame.getSize(); + System.out.println(dialogSize); + if (screenWidth < MINWIDTH && dialogSize.getWidth() > screenWidth) { + frame.setSize(new Dimension((int) Math.floor(screenWidth - 30), (int) Math.floor(dialogSize.getHeight()))); + frame.setLocation(10, (int) Math.floor(frame.getLocation().getY())); + } + if (screenHeight < MINHEIGHT && dialogSize.getHeight() > screenHeight) { + frame.setSize(new Dimension((int) Math.floor(dialogSize.getWidth()), (int) Math.floor(screenHeight - 20))); + frame.setLocation((int) Math.floor(frame.getLocation().getX()), 10); + } + /* + * if((screenWidth + * MINWIDTH||dialogSize.getHeight()>MINHEIGHT)) { openFormDialog.setSize(new + * Dimension((int)Math.floor(screenWidth-20),(int)Math.floor(screenHeight-20))); + * openFormDialog.setLocation(10, 10); } + */ + } + + public class iTextFieldInfo extends ComponentInfo { + public String btnType = "";// user-û;dep-֯;class-;extern-ⲿݿ + public String btnValue = "";// ť + } + + public class JComboBoxInfo extends ComponentInfo { + public String valueType = "";// list-ַ;lov-lovֵ;class-(˻ȡ);class-java(ͻJavaȡ) + public String valueName = ""; + public boolean canWrite = true; + public Vector values = null;// list + public Vector objvalues = null;// list + public Vector> key_values = null;// Cls_Class + public LinkedHashMap lovVal = null;// lov + } + + public class JRadioButtonInfo extends ComponentInfo { + public String buttonGroupName = ""; + } + + public class JTableInfo extends ComponentInfo { + public DefaultTableModel dataTableModel; + public JTable dataTable; + // public Vector formVector = new + // Vector(); + } + + public class JTextAreaInfo extends ComponentInfo { + public int areaWidth = 120; + public int areaHeight = 6; + } + public class TextAreaRenderer extends JTextArea implements TableCellRenderer { + private static final long serialVersionUID = 1L; + Vector area; + + public TextAreaRenderer(Vector area) { + this.area = area; + setLineWrap(true); //JTextAreaԶз + setWrapStyleWord(true); + } + + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + // 㵱еѸ߶ + int maxPreferredHeight = 22; + JTextArea cell = new JTextArea(); +// cell.setLineWrap(true); + for (int i : area) { + cell.setText("" + table.getValueAt(row, i)); +// maxPreferredHeight = Math.max(maxPreferredHeight,cell.getPreferredSize().height); +// if(row == 19) +// System.out.println(i+">>>"+table.getValueAt(row, i)+">>>"+cell.getPreferredSize().width+","+cell.getPreferredSize().height); + maxPreferredHeight = Math.max(maxPreferredHeight, + (cell.getPreferredSize().width/table.getColumnModel().getColumn(i).getWidth()+1)*cell.getPreferredSize().height+7); + } + + if (table.getRowHeight(row) != maxPreferredHeight) + // Ϲæ + table.setRowHeight(row, maxPreferredHeight); + //System.out.println(row+":"+maxPreferredHeight); + + setText(value == null ? "" : value.toString()); + fillColor(table,this,isSelected); + return this; + } + + public void fillColor(JTable t,JTextArea l,boolean isSelected ){ + if(isSelected){ + l.setBackground(t.getSelectionBackground()); + l.setForeground(t.getSelectionForeground()); + } else { + l.setBackground(t.getBackground()); + l.setForeground(t.getForeground()); + } + } + } + //lidy20180829 + class TravelTableUI extends BasicTableUI { + @Override + public void paint(Graphics g, JComponent c) { + Rectangle r = g.getClipBounds(); + rendererPane.removeAll(); + + int firstCol = table.columnAtPoint(new Point(r.x, 0)); + int lastCol = table.columnAtPoint(new Point(r.x + r.width, 0)); + // -1 is a flag that the ending point is outside the table + if (lastCol < 0) { + lastCol = table.getColumnCount() - 1; + } + for (int i = firstCol; i <= lastCol; i++) { + paintCol(i, g); + } + + paintGrid(g, 0, table.getRowCount() - 1, 0, table.getColumnCount() - 1); + } + + private void paintCol(int col, Graphics g) { + Rectangle r = g.getClipBounds(); + for (int i = 0; i < table.getRowCount(); i++) { + Rectangle r1 = table.getCellRect(i, col, false); + if (r1.intersects(r)) // at least a part is visible + { +// System.out.println("r:"+r.x+","+r.y+","+r.width+","+r.height+","+i); +// System.out.println("r1:"+r1.x+","+r1.y+","+r1.width+","+r1.height); + int sk ; + if(i<2 && col>1) { + sk=0; + }else + sk=i; + paintCell(sk, col, g, r1); + // increment the column counter + //i += 1; + } + } + } + + private void paintCell(int row, int column, Graphics g, Rectangle area) { + int verticalMargin = table.getRowMargin(); + int horizontalMargin = table.getColumnModel().getColumnMargin(); + + area.setBounds(area.x + horizontalMargin / 2, area.y + verticalMargin / 2, area.width - horizontalMargin, area.height - verticalMargin); + + if (table.isEditing() && table.getEditingRow() == row && table.getEditingColumn() == column) { + Component component = table.getEditorComponent(); + component.setBounds(area); + component.validate(); + } else { + TableCellRenderer renderer = table.getCellRenderer(row, column); + Component component = table.prepareRenderer(renderer, row, column); + if (component.getParent() == null) { + rendererPane.add(component); + } + rendererPane.paintComponent(g, component, table, area.x, area.y, + area.width, area.height, true); + } + } + + private void paintGrid(Graphics g, int rMin, int rMax, int cMin, int cMax) { + g.setColor(table.getGridColor()); + + Rectangle minCell = table.getCellRect(rMin, cMin, true); + Rectangle maxCell = table.getCellRect(rMax, cMax, true); + Rectangle damagedArea = minCell.union(maxCell); + + if (table.getShowHorizontalLines()) { + for (int row = rMin; row <= rMax; row++) { + for (int column = cMin; column <= cMax; column++) { + Rectangle cellRect = table.getCellRect(row, column, true); + if (row<2 && column>1) { + int visibleCell = 0; + int span = 2; + if (span > 1 && row < visibleCell + span - 1) { + } else { + g.drawLine(cellRect.x, cellRect.y + cellRect.height - 1, cellRect.x + cellRect.width - 1, cellRect.y + cellRect.height - 1); + } + } else { + g.drawLine(cellRect.x, cellRect.y + cellRect.height - 1, cellRect.x + cellRect.width - 1, cellRect.y + cellRect.height - 1); + } + } + } + } + if (table.getShowVerticalLines()) { + TableColumnModel cm = table.getColumnModel(); + int tableHeight = damagedArea.y + damagedArea.height; + int x; + if (table.getComponentOrientation().isLeftToRight()) { + x = damagedArea.x; + for (int column = cMin; column <= cMax; column++) { + int w = cm.getColumn(column).getWidth(); + x += w; + g.drawLine(x - 1, 0, x - 1, tableHeight - 1); + } + } else { + x = damagedArea.x; + for (int column = cMax; column >= cMin; column--) { + int w = cm.getColumn(column).getWidth(); + x += w; + g.drawLine(x - 1, 0, x - 1, tableHeight - 1); + } + } + } + } + } + public class TravelTable extends JTable { + + private static final long serialVersionUID = 1L; + + public TravelTable(DefaultTableModel dataTableModel) { + super(dataTableModel); + super.setUI(new TravelTableUI() ); + } + + public int rowAtPoint(Point p) {//lidy20180830ίдϲԪ + int column = super.columnAtPoint(p); + int row = super.rowAtPoint(p); + if(column>1&&row==1) + return 0; + + return super.rowAtPoint(p); + } + public Rectangle getCellRect(int row, int column, boolean includeSpacing) { + if (row>1||column<2) { + return super.getCellRect(row, column, includeSpacing); + } + Rectangle rect1 = super.getCellRect(0, column, includeSpacing); + rect1.height += this.getRowHeight(1); + + return rect1; + } +// public TableCellRenderer getDefaultRenderer(Class columnClass) { +// DefaultTableCellRenderer cr = (DefaultTableCellRenderer)super.getDefaultRenderer(columnClass); +// cr.setHorizontalAlignment(DefaultTableCellRenderer.CENTER); +// return cr; +// } + } + + public class TableButton extends DateButton { + private static final long serialVersionUID = -6546334664166791133L; + public int row; + public int column; + + public TableButton() { + } + + public TableButton(Date dt) { + super(dt, "yyyy-MM-dd", false, false, false); + } + } + + public abstract class TableButtonEvent extends EventObject { + private static final long serialVersionUID = 6496098798146410884L; + + public TableButtonEvent(Object source) { + super(source); + } + + public abstract void invoke(ActionEvent e); + } + + public class TableButtonRenderer implements TableCellRenderer { + private JPanel panel; + private TableButton button; + + public TableButtonRenderer() { + button = new TableButton(null); + panel = new JPanel(); + panel.setLayout(new BorderLayout()); + panel.add(button, BorderLayout.CENTER); + } + + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + return panel; + } + } + + public class TableButtonEditor extends AbstractCellEditor implements TableCellEditor { + private static final long serialVersionUID = -6546334664166791132L; + // private JPanel panel; + private TableButton button; + private TableButtonEvent event; + + public TableButtonEditor() { + initButton(null); + // panel = new JPanel(); + // panel.setLayout(new BorderLayout()); + // panel.add(this.button, BorderLayout.CENTER); + } + + public TableButtonEditor(Date dt) { + initButton(dt); + } + + private void initButton(Date dt) { + button = new TableButton(dt); + button.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + event.invoke(e); + } + }); + } + + public TableButtonEditor(TableButtonEvent e) { + this(); + this.event = e; + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + // return panel; + System.out.println(CommonUtil.debug(new Throwable().getStackTrace()[0]) + button); + return button; + } + + @Override + public Object getCellEditorValue() { + return button.getDate(); + } + + public DateButton GetBtn() { + return button; + } + } + + public ComponentInfo firstComponentInfo = new ComponentInfo(); + public HashMap allComponentInfos = new HashMap(); + + public HashMap bgMap = new HashMap(); + + public HashMap allComponentMap = new HashMap(); + public List proComponents = new ArrayList(); + + public TCFormProperty[] formProperties = null; + public Hashtable indices = new Hashtable(); + + public void readRenderingXML(String formName) { + org.dom4j.io.SAXReader saxReader = new org.dom4j.io.SAXReader(); + org.dom4j.Document document; + try { + InputStream is = this.getClass().getResourceAsStream("/Rendering.xml"); + if (is != null) { + document = saxReader.read(is); + } else { + System.out.println("saxReader.read(is)----------Error"); + return; + } + org.dom4j.Element rootElement = document.getRootElement(); + if (rootElement == null) { + System.out.println("document.getRootElement()----------Error"); + return; + } + org.dom4j.Element fromElement = rootElement.element(formName); + if (fromElement == null) { + System.out.println("document.getFromElement()----------Error"); + return; + } + fromType = formName; + org.dom4j.Element componentInfosElement = fromElement.element("ComponentInfos"); + if (componentInfosElement == null) { + System.out.println("fromElement.element(\"ComponentInfos\")----------Error"); + return; + } + List eleList = componentInfosElement.elements("ComponentInfo"); + if (eleList.isEmpty()) { + System.out.println("fromElement.element(\"First ComponentInfo\")----------Error"); + return; + } + org.dom4j.Element element = eleList.get(0); + + String type = element.attributeValue("type"); + if (type == null || type.equals("")) { + System.out.println("type == null || type.equals(\"\")----------Error"); + return; + } + + String val; + val = element.attributeValue("name"); + if (val == null || val.equals("")) { + return; + } + firstComponentInfo.name = val; + // System.out.println("ci.name----------" + ci.name); + + firstComponentInfo.type = type; + + val = element.attributeValue("title"); + if (val != null && !val.equals("")) { + firstComponentInfo.title = val; + } + + val = element.attributeValue("width"); + if (val != null && !val.equals("")) { + firstComponentInfo.width = Integer.parseInt(val); + } + + val = element.attributeValue("height"); + if (val != null && !val.equals("")) { + firstComponentInfo.height = Integer.parseInt(val); + } + + allComponentInfos.put(firstComponentInfo.name, firstComponentInfo); + readRenderingXML_Sub(element, firstComponentInfo); + } catch (org.dom4j.DocumentException e) { + e.printStackTrace(); + } + } + + public void readRenderingXML_Sub(org.dom4j.Element parentElement, ComponentInfo parentci) { + try { + List eleList = parentElement.elements("ComponentInfo"); + for (Iterator iter = eleList.iterator(); iter.hasNext();) { + org.dom4j.Element element = iter.next(); + + ComponentInfo ci = null; + String type = element.attributeValue("type"); + if (type == null || type.equals("")) { + return; + } else if (type.equalsIgnoreCase("iTextField")) { + ci = new iTextFieldInfo(); + } else if (type.equalsIgnoreCase("JComboBox")) { + ci = new JComboBoxInfo(); + } else if (type.equalsIgnoreCase("JRadioButton")) { + ci = new JRadioButtonInfo(); + } else if (type.equalsIgnoreCase("JTable")) { + ci = new JTableInfo(); + } else if (type.equalsIgnoreCase("JTextArea")) { + ci = new JTextAreaInfo(); + } else if (type.equalsIgnoreCase("Boolean")) { + ci = new JComboBoxInfo(); + } else { + ci = new ComponentInfo(); + } + + String val; + val = element.attributeValue("name"); + if (val == null || val.equals("")) { + return; + } + ci.name = val; + + ci.type = type; + + val = element.attributeValue("title"); + if (val != null && !val.equals("")) { + ci.title = val; + } + + val = element.attributeValue("valueStyle"); + if (val != null && !val.equals("")) { + ci.valueStyle = val; + } + + val = element.attributeValue("defValType"); + if (val != null && !val.equals("")) { + ci.defValType = val; + } + + val = element.attributeValue("defVal"); + if (val != null && !val.equals("")) { + ci.defVal = val; + } + + val = element.attributeValue("width"); + if (val != null && !val.equals("")) { + ci.width = Integer.parseInt(val); + } + + val = element.attributeValue("height"); + if (val != null && !val.equals("")) { + ci.height = Integer.parseInt(val); + } + + val = element.attributeValue("row"); + if (val != null && !val.equals("")) { + ci.row = Integer.parseInt(val); + } + + val = element.attributeValue("col"); + if (val != null && !val.equals("")) { + ci.col = Integer.parseInt(val); + } + + val = element.attributeValue("readOnly"); + if (val != null && !val.equals("")) { + ci.readOnly = Boolean.parseBoolean(val); + } + + val = element.attributeValue("required"); + if (val != null && !val.equals("")) { + ci.required = Boolean.parseBoolean(val); + } + + val = element.attributeValue("isProComponent"); + if (val != null && !val.equals("")) { + ci.isProComponent = Boolean.parseBoolean(val); + } + + if (type.equalsIgnoreCase("iTextField")) { + val = element.attributeValue("btnType"); + if (val != null && !val.equals("")) { + ((iTextFieldInfo) ci).btnType = val; + } + + val = element.attributeValue("btnValue"); + if (val != null && !val.equals("")) { + ((iTextFieldInfo) ci).btnValue = val; + } + } else if (type.equalsIgnoreCase("JComboBox")) { + val = element.attributeValue("valueType"); + if (val != null && !val.equals("")) { + ((JComboBoxInfo) ci).valueType = val; + } + + val = element.attributeValue("valueName"); + if (val != null && !val.equals("")) { + ((JComboBoxInfo) ci).valueName = val; + } + + val = element.attributeValue("canWrite"); + if (val != null && !val.equals("")) { + ((JComboBoxInfo) ci).canWrite = Boolean.parseBoolean(val); + } + } else if (type.equalsIgnoreCase("JRadioButton")) { + val = element.attributeValue("buttonGroupName"); + if (val != null && !val.equals("")) { + ((JRadioButtonInfo) ci).buttonGroupName = val; + } + } else if (type.equalsIgnoreCase("JTextArea")) { + val = element.attributeValue("areaWidth"); + if (val != null && !val.equals("")) { + ((JTextAreaInfo) ci).areaWidth = Integer.parseInt(val); + } + + val = element.attributeValue("areaHeight"); + if (val != null && !val.equals("")) { + ((JTextAreaInfo) ci).areaHeight = Integer.parseInt(val); + } + } + + if (parentci.type.equalsIgnoreCase("JTable")) { + ci.parentTableInfo = (JTableInfo) parentci; + } + + allComponentInfos.put(ci.name, ci); + parentci.childComponentInfos.add(ci); + readRenderingXML_Sub(element, ci); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void getlovValues(JComboBoxInfo cci) { + if (cci.lovVal != null || cci.valueName.equals("")) { + return; + } + + cci.lovVal = TCUtil.getlovValues(this.session, cci.valueName); + } + + public class IntegerKeyListener implements KeyListener { + @Override + public void keyTyped(KeyEvent e) { + int keyChar = e.getKeyChar(); + if (keyChar >= KeyEvent.VK_0 && keyChar <= KeyEvent.VK_9) { + } else { + e.consume(); + } + } + + @Override + public void keyPressed(KeyEvent e) { + } + + @Override + public void keyReleased(KeyEvent e) { + } + } + + public class DoubleKeyListener implements KeyListener { + @Override + public void keyTyped(KeyEvent e) { + int keyChar = e.getKeyChar(); + if ((keyChar >= KeyEvent.VK_0 && keyChar <= KeyEvent.VK_9) || keyChar == KeyEvent.VK_PERIOD) { + } else { + e.consume(); + } + } + + @Override + public void keyPressed(KeyEvent e) { + } + + @Override + public void keyReleased(KeyEvent e) { + } + } + + public String getDateString(Date date) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + if (date != null) { + return sdf.format(date); + } + return ""; + } + + public String getDateTimeString(Date date) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + if (date != null) { + return sdf.format(date); + } + return ""; + } + + public String getDateTimeString2(Date date) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss"); + if (date != null) { + return sdf.format(date); + } + return ""; + } + + public Date getDateFromString(String date) { + if (date.isEmpty()) { + return null; + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + try { + return sdf.parse(date); + } catch (ParseException e) { + e.printStackTrace(); + return null; + } + } + + public String getDoubleString(Double val) { + String val1 = new DecimalFormat("#.00").format(val); + if (val1.startsWith(".")) { + val1 = "0" + val1; + } + if (val1.indexOf(".") >= 0) { + while (val1.endsWith("0") || val1.endsWith(".")) { + val1 = val1.substring(0, val1.length() - 1); + if (val1.indexOf(".") < 0) { + break; + } + } + } + return val1; + } + + public Double getDoubleFromString(String val) { + if (val.isEmpty()) { + return 0.0; + } + return Double.parseDouble(val); + } + + public DateButton newDateButton() { + DateButton db = new PropertyDateButton() { + private static final long serialVersionUID = 1L; + + @Override + public void setEnabled(boolean f) { + super.setEnabled(false); + } + }; + return db; + } + + public void getFormPanel(Object parent, List childComponentInfos) { + int cciCount = childComponentInfos.size(); + for (int cciIdx = 0; cciIdx < cciCount; cciIdx++) { + final ComponentInfo cci = childComponentInfos.get(cciIdx); + // System.out.println("getFormPanel:cci.name-----" + cci.name + + // "-----cci.type-----" + cci.type); + if (cci.type.equalsIgnoreCase("JLabel")) { + JLabel label = new JLabel(cci.title); + // if(cci.col!=1) {//kk JLabelø߶Զı + label.setPreferredSize(new Dimension(label.getPreferredSize().width, cci.height)); + // } + label.setName(cci.name); + allComponentMap.put(cci.name, label); + + if (parent instanceof JPanel) { + ((JPanel) parent).add(Integer.toString(cci.row) + "." + Integer.toString(cci.col) + ".left.top", label); + } + } else if (cci.type.equalsIgnoreCase("iTextField")) { + iTextField textfield = new iTextField(); + textfield.setPreferredSize(new Dimension(cci.width, cci.height)); + textfield.setName(cci.name); + allComponentMap.put(cci.name, textfield); + textfield.setDisabledTextColor(new Color(0, 0, 0)); + if (cci.isProComponent) { + proComponents.add(textfield); + } + if (cci.readOnly) { + textfield.setEnabled(false); + } + if (cci.required) { + textfield.setRequired(true); + } + + if (cci.valueStyle.equalsIgnoreCase("int")) { + textfield.addKeyListener(new IntegerKeyListener()); + } else if (cci.valueStyle.equalsIgnoreCase("double")) { + textfield.addKeyListener(new DoubleKeyListener()); + } + + if (parent instanceof JPanel) { + ((JPanel) parent).add(Integer.toString(cci.row) + "." + Integer.toString(cci.col) + ".left.top", textfield); + } else if (parent instanceof JScrollPane) { + ((JScrollPane) parent).setViewportView(textfield); + } + + if (!((iTextFieldInfo) cci).btnType.equals("")) { + JButton btn = new JButton("..."); + String btnName = cci.name + "_Select"; + btn.setName(btnName); + btn.setPreferredSize(new Dimension(22, 22)); + allComponentMap.put(btnName, btn); + cci.linkComponent = btn; + if (parent instanceof JPanel) { + ((JPanel) parent).add(Integer.toString(cci.row) + "." + Integer.toString(cci.col + 1) + ".left.top", btn); + } + + if (((iTextFieldInfo) cci).btnType.equalsIgnoreCase("user")) { + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + String strSourceName = ((JButton) ae.getSource()).getName(); + SelectUserDialog userSelect = new SelectUserDialog(session, "user"); + iTextField textField = (iTextField) allComponentMap.get(strSourceName.substring(0, strSourceName.length() - 7)); + String user = userSelect.getValue(); + + if (!((iTextFieldInfo) cci).btnValue.equals("")) { + iTextField depTextfield = (iTextField) allComponentMap.get(((iTextFieldInfo) cci).btnValue); + String group = userSelect.getUserOfDep(); + //TODO lidy20190314IJż + if(((iTextFieldInfo) cci).btnValue.equals("ysr8_ChangeDept")) { +// System.out.println("getValue:"+user+" getValue:"+group); + if(!group.equals("") && group.indexOf("е")<0 && group.indexOf("")<0 + && group.indexOf("")<0 && group.indexOf("")<0 + && group.indexOf("ϵͳ")<0 && group.indexOf("Ŀ")<0) { + MessageBox.post("IJֻΪϵͳơеơƻ򹤳̿", "ʾ", MessageBox.INFORMATION); + return; + } + } + depTextfield.setText(group); + } + textField.setText(user); + } + }); + } else if (((iTextFieldInfo) cci).btnType.equalsIgnoreCase("dep")) { + btn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + String strSourceName = ((JButton) ae.getSource()).getName(); + SelectUserDialog userSelect = new SelectUserDialog(session, "organization"); + iTextField textField = (iTextField) allComponentMap.get(strSourceName.substring(0, strSourceName.length() - 7)); + textField.setText(userSelect.getValue()); + } + }); + } else if (((iTextFieldInfo) cci).btnType.equalsIgnoreCase("extern")) { + + } + } + } else if (cci.type.equalsIgnoreCase("DateButton")) { + DateButton datebtn = new DateButton(null, "yyyy-MM-dd", false, false, false); + // datebtn.setPreferredSize(new Dimension(cci.width, cci.height)); + datebtn.setName(cci.name); + datebtn.setBounds(0, 0, cci.width, cci.height); + allComponentMap.put(cci.name, datebtn); + if (cci.isProComponent) { + proComponents.add(datebtn); + } + if (cci.readOnly) { + datebtn.setEnabled(false); + } + if (cci.required) { + datebtn.setMandatory(true); + } + JPanel panelDate = new JPanel(new BorderLayout()); + panelDate.add(BorderLayout.CENTER, datebtn); + if (cci.readOnly) { + panelDate.setEnabled(false); + } + /* + * datebtn.setContentAreaFilled(false); datebtn.setFocusPainted(false); + * datebtn.setOpaque(true); + */ + cci.linkComponent = panelDate; + panelDate.setPreferredSize(new Dimension(cci.width, cci.height)); + // panelDate.setBorder(BorderFactory.createLineBorder(Color.BLACK)); + if (parent instanceof JPanel) { + ((JPanel) parent).add(Integer.toString(cci.row) + "." + Integer.toString(cci.col) + ".left.top", panelDate); + } + } else if (cci.type.equalsIgnoreCase("JComboBox")) { + JComboBox cbx = new JComboBox(); + cbx.setPreferredSize(new Dimension(cci.width, cci.height)); + cbx.setName(cci.name); + allComponentMap.put(cci.name, cbx); + if (cci.isProComponent) { + proComponents.add(cbx); + } + if (cci.readOnly) { + cbx.setEnabled(false); + } + JComboBoxInfo info = (JComboBoxInfo) cci; + if (info.canWrite) { + cbx.setEditable(true); + } + cbx.addItem(""); + if (info.valueType.equalsIgnoreCase("list")) { + if (!info.valueName.equals("")) { + info.values = CommonUtil.split2Vector(info.valueName, "@@"); + } + for (Iterator iterator = info.values.iterator(); iterator.hasNext();) { + String val = (String) iterator.next(); + cbx.addItem(val); + } + } else if (info.valueType.equalsIgnoreCase("preference")) { + String[] s = TCUtil.getPreference(session, TCPreferenceService.TC_preference_site, info.valueName); + System.out.println("info.valueName========"+info.valueName); + for (int i = 0; i < s.length; i++) { + if (info.values == null) { + info.values = new Vector(); + } + info.values.add(s[i]); + } + if (info.values != null) { + for (Iterator iterator = info.values.iterator(); iterator.hasNext();) { + String val = (String) iterator.next(); + cbx.addItem(val); + } + } + } else if (info.valueType.equalsIgnoreCase("lov")) { + getlovValues(info); + if (info.lovVal != null && info.lovVal.size() > 0) { + for (Entry entry : info.lovVal.entrySet()) { + cbx.addItem(entry.getValue()); + } + } + } else if (info.valueType.equalsIgnoreCase("Cls_Class")) { + String UNCTID = ""; + String[] valueNameTypes = info.valueName.split(":"); + if (valueNameTypes.length == 2) { + String[] preferences = TCUtil.getPreference(session, 4, valueNameTypes[0]); + for (int i = 0; i < preferences.length; i++) { + String[] preferencePart = preferences[i].split("="); + if (preferencePart.length == 2) { + if (preferencePart[0].equalsIgnoreCase(valueNameTypes[1])) { + UNCTID = preferencePart[1]; + break; + } + } + } + } + if (UNCTID.equals("")) { + System.out.println("ȡUNCTIDʧܣ"); + } else { + try { + info.key_values = TCUtil.GetCls_Class(session, UNCTID); + if (info.key_values != null) { + for (int i = 0; i < info.key_values.size(); i++) { + String res = info.key_values.get(i).get("PNAME").toString(); + cbx.addItem(res); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } else if (info.valueType.equalsIgnoreCase("Cls_Instance2")) { + String UNCTID = info.valueName; + try { + info.lovVal = TCUtil.GetCls_InstanceInfo2(session, UNCTID); + if (info.lovVal != null && info.lovVal.size() > 0) { + for (Entry entry : info.lovVal.entrySet()) { + cbx.addItem(entry.getValue()); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + }else if(info.valueType.equalsIgnoreCase("ZXMH")) {//Ŀŵͨťѯ + + } + + if (parent instanceof JPanel) { + ((JPanel) parent).add(Integer.toString(cci.row) + "." + Integer.toString(cci.col) + ".left.top", cbx); + } + } else if (cci.type.equalsIgnoreCase("JTextArea")) { + JTextArea textarea = new JTextArea(((JTextAreaInfo) cci).areaHeight, ((JTextAreaInfo) cci).areaWidth); + textarea.setName(cci.name); + allComponentMap.put(cci.name, textarea); + if (cci.isProComponent) { + proComponents.add(textarea); + } + if (cci.readOnly) { + textarea.setEnabled(false); + } + + textarea.setAutoscrolls(true); + textarea.setLineWrap(true); + textarea.setWrapStyleWord(true); + JScrollPane textareaPane = new JScrollPane(textarea); + textareaPane.setPreferredSize(new Dimension(cci.width, cci.height)); + textareaPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); + cci.linkComponent = textareaPane; + + if (parent instanceof JPanel) { + ((JPanel) parent).add(Integer.toString(cci.row) + "." + Integer.toString(cci.col) + ".left.top", textareaPane); + } else if (parent instanceof JScrollPane) { + ((JScrollPane) parent).setViewportView(textareaPane); + } + } else if (cci.type.equalsIgnoreCase("JCheckBox")) { + JCheckBox ckb = new JCheckBox(cci.title); + ckb.setPreferredSize(new Dimension(cci.width, cci.height)); + ckb.setName(cci.name); + allComponentMap.put(cci.name, ckb); + if (cci.isProComponent) { + proComponents.add(ckb); + } + if (cci.readOnly) { + ckb.setEnabled(false); + // System.out.println(cci.name + "==========" + + // "setEnabled(false)"); + } + + if (parent instanceof JPanel) { + ((JPanel) parent).add(Integer.toString(cci.row) + "." + Integer.toString(cci.col) + ".left.top", ckb); + } + } else if (cci.type.equalsIgnoreCase("JRadioButton")) { + JRadioButton btn = new JRadioButton(cci.title); + ButtonGroup bg = bgMap.get(((JRadioButtonInfo) cci).buttonGroupName); + if (bg == null) { + bg = new ButtonGroup(); + bgMap.put(((JRadioButtonInfo) cci).buttonGroupName, bg); + } + bg.add(btn); + btn.setPreferredSize(new Dimension(cci.width, cci.height)); + btn.setName(cci.name); + allComponentMap.put(cci.name, btn); + if (cci.isProComponent) { + proComponents.add(btn); + } + if (cci.readOnly) { + btn.setEnabled(false); + } + + if (parent instanceof JPanel) { + ((JPanel) parent).add(Integer.toString(cci.row) + "." + Integer.toString(cci.col) + ".left.top", btn); + } + } else if (cci.type.equalsIgnoreCase("JButton")) { + JButton btn = new JButton(cci.title); + btn.setPreferredSize(new Dimension(cci.width, cci.height)); + btn.setName(cci.name); + allComponentMap.put(cci.name, btn); + if (cci.readOnly) { + btn.setEnabled(false); + } + + if (parent instanceof JPanel) { + ((JPanel) parent).add(Integer.toString(cci.row) + "." + Integer.toString(cci.col) + ".left.top", btn); + } + } else if (cci.type.equalsIgnoreCase("ImageIcon")) { + Icon cnimage = new ImageIcon(this.getClass().getResource("/Image/" + cci.title)); + JLabel label = new JLabel(cnimage, JLabel.CENTER); + label.setName(cci.name); + allComponentMap.put(cci.name, label); + + if (parent instanceof JPanel) { + ((JPanel) parent).add(Integer.toString(cci.row) + "." + Integer.toString(cci.col) + ".left.top", label); + } else if (parent instanceof JScrollPane) { + ((JScrollPane) parent).setViewportView(label); + } + } else if (cci.type.equalsIgnoreCase("JTable")) { + int ccciCount = cci.childComponentInfos.size(); + String[] columnNames = new String[ccciCount]; + for (int ccciIdx = 0; ccciIdx < ccciCount; ccciIdx++) { + ComponentInfo ccci = cci.childComponentInfos.get(ccciIdx); + columnNames[ccciIdx] = ccci.title; + } + ((JTableInfo) cci).dataTableModel = new DefaultTableModel(columnNames, 0); + JTable table = null; + + if(cci.name.equals("t.041.41")) { + table = new TravelTable(((JTableInfo) cci).dataTableModel) {//lidy20180830ίд + + private static final long serialVersionUID = 1L; + public boolean isCellEditable(int row, int col) { + String name = this.getName(); + ComponentInfo ciTable = allComponentInfos.get(name); + ComponentInfo ciTableChild = ciTable.childComponentInfos.get(col); + if(name.equals("t.041.41")) { + if(col == 3&&row > 2) + return false; + } + if (ciTableChild != null) { + if (ciTableChild.readOnly) { + return false; + } else if (ciTableChild.type.equalsIgnoreCase("iTextField")) { + return true; + } else if (ciTableChild.type.equalsIgnoreCase("JCheckBox")) { + return true; + } else if (ciTableChild.type.equalsIgnoreCase("JTextArea")) { + return true; + } else if (ciTableChild.type.equalsIgnoreCase("JComboBox")) { + if ((ciTableChild instanceof JComboBoxInfo) && ((JComboBoxInfo) ciTableChild).canWrite) {// + return true; + } + } + } + return false; + } + public Class getColumnClass(int column) { //lidy20180829JTableиѡ + ComponentInfo ciTable = allComponentInfos.get(this.getName()); + ComponentInfo ciTableChild = ciTable.childComponentInfos.get(column); + if (ciTableChild.type.equalsIgnoreCase("JCheckBox")) { + return Boolean.class; + } + return super.getColumnClass(column); + } + }; + }else { + + table = new JTable(((JTableInfo) cci).dataTableModel) { + + private static final long serialVersionUID = 1L; + + public boolean isCellEditable(int row, int col) { + String name = this.getName(); + ComponentInfo ciTable = allComponentInfos.get(name); + ComponentInfo ciTableChild = ciTable.childComponentInfos.get(col); + if(name.equals("t.041.41")) {//lidy20180830ίд + if(col == 3&&row > 2) + return false; + } else if(name.equals("ecn1.141.11.11")||name.equals("a.141.11.11")||name.equals("a.151.11.11")) { + //TODO lidy20180830ĵ +// ViewEditHelper editHelp = new ViewEditHelper(session); +// boolean checkedOut = editHelp.isCheckedOutByUser(tcForm); + if (ciTableChild != null) { + if (ciTableChild.readOnly) { + return false; + } + } + return isCheckOut; + } else if (ciTableChild != null) { + if (ciTableChild.readOnly) { + return false; + } else if (ciTableChild.type.equalsIgnoreCase("iTextField")) { + return true; + } else if (ciTableChild.type.equalsIgnoreCase("JCheckBox")) { + return true; + } else if (ciTableChild.type.equalsIgnoreCase("JTextArea")) { + return true; + } else if (ciTableChild.type.equalsIgnoreCase("JComboBox")) { + if ((ciTableChild instanceof JComboBoxInfo) && ((JComboBoxInfo) ciTableChild).canWrite) {// + return true; + } + } + } + return false; + } + public Class getColumnClass(int column) { //lidy20180829JTableиѡ + ComponentInfo ciTable = allComponentInfos.get(this.getName()); + ComponentInfo ciTableChild = ciTable.childComponentInfos.get(column); + if (ciTableChild.type.equalsIgnoreCase("JCheckBox")) { + return Boolean.class; + } + return super.getColumnClass(column); + } + }; + } + ((JTableInfo) cci).dataTable = table; + JTableHeader tableHeader = table.getTableHeader(); + tableHeader.setReorderingAllowed(false);// вƶ + DefaultTableCellRenderer hr = (DefaultTableCellRenderer) tableHeader.getDefaultRenderer(); + hr.setHorizontalAlignment(DefaultTableCellRenderer.CENTER);// + // table.getTableHeader().setReorderingAllowed(false); + table.setRowHeight(22); + table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + table.setAutoscrolls(true); + // table.setFillsViewportHeight(false); + table.setShowGrid(true); + + Vector Area = new Vector<>(); + for (int ccciIdx = 0; ccciIdx < ccciCount; ccciIdx++) { + ComponentInfo ccci = cci.childComponentInfos.get(ccciIdx); + if (ccci.type.equalsIgnoreCase("JTextArea")) { + Area.add(ccciIdx); + } + } + TableColumnModel columns = table.getColumnModel(); + for (int ccciIdx = 0; ccciIdx < ccciCount; ccciIdx++) { + ComponentInfo ccci = cci.childComponentInfos.get(ccciIdx); + // System.out.println("JTable-----" + ccci.name + + // "-----ccci.type-----" + ccci.type); + TableColumn column = columns.getColumn(ccciIdx); + column.setPreferredWidth(ccci.width); + + if (ccci.type.equalsIgnoreCase("iTextField")) { + } else if (ccci.type.equalsIgnoreCase("JCheckBox")) { + column.setCellEditor(new DefaultCellEditor(new JCheckBox())); +// ((DefaultTableCellRenderer)column.getCellRenderer()).setHorizontalAlignment(DefaultTableCellRenderer.CENTER); +// r = (DefaultTableCellRenderer)column.getCellRenderer(); +// r.setHorizontalAlignment(DefaultTableCellRenderer.CENTER); +// column.setCellRenderer(r); + } else if (ccci.type.equalsIgnoreCase("JTextArea")) { + column.setCellRenderer(new TextAreaRenderer(Area)); + } else if (ccci.type.equalsIgnoreCase("DateButton")) { + // column.setCellRenderer(new TableButtonRenderer()); + TableButtonEditor tbe = new TableButtonEditor(); + column.setCellEditor(new TableButtonEditor()); + allComponentMap.put(ccci.name, tbe.GetBtn());// ϴ˾䣬cbx + } else if (ccci.type.equalsIgnoreCase("JComboBox")) { + JComboBox cbx = new JComboBox(); + if (((JComboBoxInfo) ccci).readOnly) { + cbx.setEnabled(false); + } + if (((JComboBoxInfo) ccci).canWrite) { + cbx.setEditable(true); + } + ccci.linkComponent = table; + allComponentMap.put(ccci.name, cbx);// ϴ˾䣬cbx + + cbx.addItem(""); + if (((JComboBoxInfo) ccci).valueType.equalsIgnoreCase("list")) { + ((JComboBoxInfo) cci).values = CommonUtil.split2Vector(((JComboBoxInfo) ccci).valueName, "@@"); + for (Iterator iterator = ((JComboBoxInfo) cci).values.iterator(); iterator.hasNext();) { + String val = (String) iterator.next(); + cbx.addItem(val); + } + } else if (((JComboBoxInfo) ccci).valueType.equalsIgnoreCase("lov")) { + getlovValues((JComboBoxInfo) ccci); + if (((JComboBoxInfo) ccci).lovVal != null && ((JComboBoxInfo) ccci).lovVal.size() > 0) { + for (Entry entry : ((JComboBoxInfo) ccci).lovVal.entrySet()) { + cbx.addItem(entry.getValue()); + } + } + } else if (((JComboBoxInfo) ccci).valueType.equalsIgnoreCase("Cls_Class")) { + String[] valueNameTypes = ((JComboBoxInfo) ccci).valueName.split(":"); + if (valueNameTypes.length == 2) { + String UNCTID = ""; + String[] preferences = TCUtil.getPreference(session, 4, valueNameTypes[0]); + for (int i = 0; i < preferences.length; i++) { + String[] preferencePart = preferences[i].split("="); + if (preferencePart.length == 2) { + if (preferencePart[0].equalsIgnoreCase(valueNameTypes[1])) { + UNCTID = preferencePart[1]; + break; + } + } + } + if (UNCTID.equals("")) { + System.out.println("ȡUNCTIDʧܣ"); + } else { + try { + ((JComboBoxInfo) ccci).key_values = TCUtil.GetCls_Class(session, UNCTID); + for (int i = 0; i < ((JComboBoxInfo) ccci).key_values.size(); i++) { + String res = ((JComboBoxInfo) ccci).key_values.get(i).get("PCID").toString(); + cbx.addItem(res); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } else if (((JComboBoxInfo) ccci).valueType.equalsIgnoreCase("Cls_Instance2")) { + String UNCTID = ((JComboBoxInfo) ccci).valueName; + try { + ((JComboBoxInfo) ccci).lovVal = TCUtil.GetCls_InstanceInfo2(session, UNCTID); + if (((JComboBoxInfo) ccci).lovVal != null && ((JComboBoxInfo) ccci).lovVal.size() > 0) { + for (Entry entry : ((JComboBoxInfo) cci).lovVal.entrySet()) { + cbx.addItem(entry.getValue()); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + column.setCellEditor(new DefaultCellEditor(cbx)); + + // Set up tool tips for the sport cells. + DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); + renderer.setToolTipText("ѡ"); + column.setCellRenderer(renderer); + } + } + + table.setName(cci.name); + allComponentMap.put(cci.name, table); + if (cci.readOnly) { + table.setEnabled(false); + } + if (parent instanceof JScrollPane) { + ((JScrollPane) parent).setPreferredSize(new Dimension(cci.width, cci.height + 35)); + ((JScrollPane) parent).setViewportView(table); + } + } else if (cci.type.equalsIgnoreCase("JPanel")) { + JPanel panel = new JPanel(); + panel.setLayout(new PropertyLayout()); + panel.setName(cci.name); + allComponentMap.put(cci.name, panel); + + if (parent instanceof AbstractRendering) { + ((AbstractRendering) parent).add(BorderLayout.CENTER, panel); + } else if (parent instanceof JPanel) { + ((JPanel) parent).add(Integer.toString(cci.row) + "." + Integer.toString(cci.col) + ".left.top", panel); + } else if (parent instanceof JScrollPane) { + ((JScrollPane) parent).setViewportView(panel); + } + getFormPanel(panel, cci.childComponentInfos); + } else if (cci.type.equalsIgnoreCase("JPanelEtchedBorder")) { + JPanel panel = new JPanel(); + panel.setLayout(new PropertyLayout(5,5,5,5,5,5)); + panel.setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), cci.title)); + panel.setName(cci.name); + allComponentMap.put(cci.name, panel); + + if (parent instanceof AbstractRendering) { + ((AbstractRendering) parent).add(BorderLayout.CENTER, panel); + } else if (parent instanceof JPanel) { + ((JPanel) parent).add(Integer.toString(cci.row) + "." + Integer.toString(cci.col) + ".left.top", panel); + } else if (parent instanceof JScrollPane) { + ((JScrollPane) parent).setViewportView(panel); + } + getFormPanel(panel, cci.childComponentInfos); + } else if (cci.type.equalsIgnoreCase("JScrollPane")) { + JScrollPane panel = new JScrollPane(); + panel.setName(cci.name); + allComponentMap.put(cci.name, panel); + + if (parent instanceof AbstractRendering) { + ((AbstractRendering) parent).add(BorderLayout.CENTER, panel); + } else if (parent instanceof AbstractAIFDialog) { + ((AbstractAIFDialog) parent).add(BorderLayout.CENTER, panel); + } else if (parent instanceof JPanel) { + ((JPanel) parent).add(Integer.toString(cci.row) + "." + Integer.toString(cci.col) + ".left.top", panel); + } else if (parent instanceof JScrollPane) { + ((JScrollPane) parent).setViewportView(panel); + } + getFormPanel(panel, cci.childComponentInfos); + } else if (cci.type.equalsIgnoreCase("JTabbedPane")) { + JTabbedPane tabPane = new JTabbedPane(); + tabPane.setName(cci.name); + allComponentMap.put(cci.name, tabPane); + + if (parent instanceof AbstractRendering) { + ((AbstractRendering) parent).add(BorderLayout.CENTER, tabPane); + } else if (parent instanceof JPanel) { + ((JPanel) parent).add(Integer.toString(cci.row) + "." + Integer.toString(cci.col) + ".left.top", tabPane); + } else if (parent instanceof JScrollPane) { + ((JScrollPane) parent).setViewportView(tabPane); + } + getFormPanel(tabPane, cci.childComponentInfos); + } else if (cci.type.equalsIgnoreCase("JTabbedPaneTabItem")) { + JScrollPane panel = new JScrollPane(); + panel.setName(cci.name); + allComponentMap.put(cci.name, panel); + if (parent instanceof JTabbedPane) { + ((JTabbedPane) parent).addTab(cci.title, panel); + } + JPanel panelChild = new JPanel(); + panelChild.setName(cci.name + "-1"); + panelChild.setLayout(new PropertyLayout()); + panel.setViewportView(panelChild); + allComponentMap.put(cci.name, panelChild); + + getFormPanel(panelChild, cci.childComponentInfos); + } + } + } + + public void loadPropertiesValue() throws TCException { + System.out.println("firstComponentInfo:##########"+firstComponentInfo.name); + if (this.formProperties == null) { + return; + } + + try { + int length = this.formProperties.length; + for (int k = 0; k < length; ++k) { + String propName = this.formProperties[k].getPropertyName().trim(); +// if(!propName.startsWith("ysr")) { +// System.out.println("UIUtil"+propName); +//// System.out.println("ǩ"+formProperties[k].getStringValue()); +// } + // System.out.println("loadRendering:propName-----" + propName); + ComponentInfo ci = allComponentInfos.get(propName); + if (ci == null) { + continue; + } + // System.out.println("loadRendering:propName-----" + propName + + // "-----type-----" + ci.type + "-----getPropertyType()-----" + + // Integer.toString(this.formProperties[k].getPropertyType())); + + if (ci.parentTableInfo == null) { + if (!formProperties[k].isNotArray()) { + // System.out.println("loadRendering:propName-----" + + // propName + "-----isArray"); + } + for (int i = 0; i < proComponents.size(); i++) { + Component component = proComponents.get(i); + String name = component.getName().trim(); + if (propName.equalsIgnoreCase(name)) { + if (component instanceof iTextField) { + iTextField textField = (iTextField) component; + String propValue = ""; + switch (this.formProperties[k].getPropertyType()) { + case TCProperty.PROP_string: + case TCProperty.PROP_long_string: + propValue = this.formProperties[k].getStringValue(); + break; + case TCProperty.PROP_short: + case TCProperty.PROP_int: + propValue = Integer.toString(this.formProperties[k].getIntValue()); + break; + case TCProperty.PROP_double: + case TCProperty.PROP_float: + String val = getDoubleString(this.formProperties[k].getDoubleValue()); + propValue = val; + break; + case TCProperty.PROP_date: + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date date = this.formProperties[k].getDateValue(); + if (date != null) { + propValue = sdf.format(date); + } + break; + default: + propValue = this.formProperties[k].getStringValue(); + break; + } + if (propValue.equals("")) { + if (((iTextFieldInfo) ci).defValType.equalsIgnoreCase("sys")) { + if (((iTextFieldInfo) ci).defVal.equalsIgnoreCase("user")) { + textField.setText(session.getUser().getRelatedComponent("person").getProperty("user_name")); + } else if (((iTextFieldInfo) ci).defVal.equalsIgnoreCase("user2")) { + TCComponentUser user = session.getUser(); + textField.setText(user.getProperty("user_id")); + } else if (((iTextFieldInfo) ci).defVal.equalsIgnoreCase("user3")) { + TCComponentUser user = session.getUser(); + textField.setText(user.getRelatedComponent("person").getProperty("user_name") + "(" + user.getProperty("user_id") + ")"); + } else if (((iTextFieldInfo) ci).defVal.equalsIgnoreCase("date")) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + textField.setText(sdf.format(new Date())); + } + } else if (((iTextFieldInfo) ci).defValType.equalsIgnoreCase("normal")) { + textField.setText(((iTextFieldInfo) ci).defVal); + } + } else { + textField.setText(propValue); + } + + indices.put(formProperties[k], textField); + break; + } else if (component instanceof JTextArea) { + JTextArea textarea = (JTextArea) component; + String propValue = this.formProperties[k].getStringValue(); + textarea.setText(propValue); + indices.put(formProperties[k], textarea); + break; + } else if (component instanceof JCheckBox) { + JCheckBox ckb = (JCheckBox) component; + ckb.setSelected(this.formProperties[k].getBoolValue()); + indices.put(formProperties[k], ckb); + break; + } else if (component instanceof JRadioButton) { + JRadioButton btn = (JRadioButton) component; + btn.setSelected(this.formProperties[k].getBoolValue()); + indices.put(formProperties[k], btn); + break; + } else if (component instanceof DateButton) { + DateButton btn = (DateButton) component; + if (!this.formProperties[k].isPropValueNull()) { + btn.setDate(this.formProperties[k].getDateValue()); + } else { + if (ci.defValType.equalsIgnoreCase("sys") && ci.defVal.equalsIgnoreCase("date")) { + btn.setDate(new Date()); + } + } + indices.put(formProperties[k], btn); + break; + } else if (component instanceof JComboBox) { + JComboBox cbx = (JComboBox) component; + String propValue = this.formProperties[k].getStringValue(); + if (propValue.equals("")) { + if (ci.defValType.equalsIgnoreCase("normal")) { + propValue = ci.defVal; + } + } + if (((JComboBoxInfo) ci).valueType.equalsIgnoreCase("lov")) { + if (!((JComboBoxInfo) ci).valueName.equals("") && ((JComboBoxInfo) ci).lovVal != null && propValue != null && !propValue.equals("")) { + if (((JComboBoxInfo) ci).lovVal.get(propValue) == null || ((JComboBoxInfo) ci).lovVal.get(propValue).equals("")) { + cbx.setSelectedItem(propValue); + } else { + cbx.setSelectedItem(((JComboBoxInfo) ci).lovVal.get(propValue)); + } + } + } else if (((JComboBoxInfo) ci).valueType.equalsIgnoreCase("Cls_Class")) { + if (!((JComboBoxInfo) ci).valueName.equals("") && propValue != null && !propValue.equals("")) { + if (((JComboBoxInfo) ci).key_values != null) { + boolean find = false; + for (int j = 0; j < ((JComboBoxInfo) ci).key_values.size(); j++) { + String key = ((JComboBoxInfo) ci).key_values.get(j).get("PCID").toString(); + if (key.equalsIgnoreCase(propValue)) { + cbx.setSelectedItem(((JComboBoxInfo) ci).key_values.get(j).get("PNAME").toString()); + find = true; + break; + } + } + if (!find) { + cbx.setSelectedItem(propValue); + } + } else { + cbx.setSelectedItem(propValue); + } + } + } else if (((JComboBoxInfo) ci).valueType.equalsIgnoreCase("Cls_Instance2")) { + if (!((JComboBoxInfo) ci).valueName.equals("") && ((JComboBoxInfo) ci).lovVal != null && propValue != null && !propValue.equals("")) { + if (((JComboBoxInfo) ci).lovVal.get(propValue) == null || ((JComboBoxInfo) ci).lovVal.get(propValue).equals("")) { + cbx.setSelectedItem(propValue); + } else { + cbx.setSelectedItem(((JComboBoxInfo) ci).lovVal.get(propValue)); + } + } + } else { + cbx.setSelectedItem(propValue); + } + indices.put(formProperties[k], cbx); + break; + } + } + } + } else { + if (formProperties[k].isNotArray()) { + // System.out.println("loadRendering:propName-----" + + // propName + "-----isNotArray"); + } + int colIdx = -1; + for (int j = 0; j < ci.parentTableInfo.childComponentInfos.size(); j++) { + ComponentInfo tcci = ci.parentTableInfo.childComponentInfos.get(j); + if (tcci.name.equalsIgnoreCase(propName)) { + colIdx = j; + break; + } + } + if (colIdx != -1) { + Vector values = new Vector(); + switch (this.formProperties[k].getPropertyType()) { + case TCProperty.PROP_string: + case TCProperty.PROP_long_string: + String[] strvals = formProperties[k].getStringArrayValue(); + for (int l = 0; l < strvals.length; l++) { +// System.out.println(strvals[l]); + values.add(strvals[l]); + } + break; + case TCProperty.PROP_short: + case TCProperty.PROP_int: + int[] ivals = formProperties[k].getIntArrayValue(); + for (int l = 0; l < ivals.length; l++) { + values.add(Integer.toString(ivals[l])); + } + break; + case TCProperty.PROP_double: + case TCProperty.PROP_float: + double[] doublevals = formProperties[k].getDoubleArrayValue(); + for (int l = 0; l < doublevals.length; l++) { + String val = getDoubleString(doublevals[l]); + values.add(val); + } + break; + case TCProperty.PROP_date: + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date[] datevals = formProperties[k].getDateValueArray(); + for (int l = 0; l < datevals.length; l++) { + if (datevals[l] != null) { + //TODO lidy20190521ͼֽĵڸʽ + if(fromType.equals("YSR8_ECN2RevisionMasterForm") || fromType.equals("YSR8_ECN4RevisionMasterForm") || + fromType.equals("YSR8_INSPRecordRevisionMasterForm")) { + sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + values.add(sdf.format(datevals[l])); +// System.out.println(sdf.format(datevals[l])); + }else + values.add(sdf.format(datevals[l])); + } else { + values.add(""); + } + } + break; + default: + String[] strvals1 = formProperties[k].getStringArrayValue(); + for (int l = 0; l < strvals1.length; l++) { + values.add(strvals1[l]); + } + break; + } + if (values != null) { + for (int l = 0; l < values.size(); l++) { + if (ci.parentTableInfo.dataTableModel.getRowCount() <= l) { + Vector rowData = new Vector(); + for (int j = 0; j < ci.parentTableInfo.childComponentInfos.size(); j++) { + rowData.add(""); + } + ci.parentTableInfo.dataTableModel.addRow(rowData.toArray()); + } + if (ci.type.equalsIgnoreCase("JComboBox") && ((JComboBoxInfo) ci).valueType.equalsIgnoreCase("lov") && !((JComboBoxInfo) ci).valueName.equals("")) { + if (((JComboBoxInfo) ci).lovVal.get(values.get(l)) == null || ((JComboBoxInfo) ci).lovVal.get(values.get(l)).equals("")) { + ci.parentTableInfo.dataTableModel.setValueAt(values.get(l), l, colIdx); + } else { + ci.parentTableInfo.dataTableModel.setValueAt(((JComboBoxInfo) ci).lovVal.get(values.get(l)), l, colIdx); + } + } else if (ci.type.equalsIgnoreCase("JComboBox") && ((JComboBoxInfo) ci).valueType.equalsIgnoreCase("Cls_Class") && !((JComboBoxInfo) ci).valueName.equals("")) { + if (((JComboBoxInfo) ci).key_values != null) { + for (int j = 0; j < ((JComboBoxInfo) ci).key_values.size(); j++) { + String key = ((JComboBoxInfo) ci).key_values.get(j).get("PCID").toString(); + if (key.equalsIgnoreCase(values.get(l))) { + ci.parentTableInfo.dataTableModel.setValueAt(((JComboBoxInfo) ci).key_values.get(j).get("PNAME").toString(), l, colIdx); + break; + } + } + } + } else if (ci.type.equalsIgnoreCase("JComboBox") && ((JComboBoxInfo) ci).valueType.equalsIgnoreCase("Cls_Instance2") && !((JComboBoxInfo) ci).valueName.equals("")) { + if (((JComboBoxInfo) ci).lovVal.get(values.get(l)) == null || ((JComboBoxInfo) ci).lovVal.get(values.get(l)).equals("")) { + ci.parentTableInfo.dataTableModel.setValueAt(values.get(l), l, colIdx); + } else { + ci.parentTableInfo.dataTableModel.setValueAt(((JComboBoxInfo) ci).lovVal.get(values.get(l)), l, colIdx); + } + } else if (ci.type.equalsIgnoreCase("DateButton")) { + ci.parentTableInfo.dataTableModel.setValueAt(values.get(l), l, colIdx); + } else { + ci.parentTableInfo.dataTableModel.setValueAt(values.get(l), l, colIdx); + } + } + } + } + } + } + } catch (TCException imanexception) { + throw imanexception; + } + } + + public Vector GetPropertiesValue() throws TCException, ParseException { + int length = this.formProperties.length; + // System.out.println("length-----" + length); + Vector formPropertys = new Vector(); + try { + for (int k = 0; k < length; ++k) { + TCFormProperty formProperty = this.formProperties[k]; + String propName = formProperty.getPropertyName().trim(); + ComponentInfo ci = allComponentInfos.get(propName); + if (ci == null) { + continue; + } + // System.out.println("saveRendering-----" + propName + + // "-----type-----" + ci.type); + + if (ci.parentTableInfo == null) { + Object component = indices.get(formProperties[k]); + if (component == null) { + component = allComponentMap.get(propName); + } + + if (component instanceof iTextField) { + try { + switch (this.formProperties[k].getPropertyType()) { + case TCProperty.PROP_string: + case TCProperty.PROP_long_string: + formProperty.setStringValue(((iTextField) component).getText().toString()); + break; + case TCProperty.PROP_short: + case TCProperty.PROP_int: + formProperty.setIntValue(Integer.parseInt(((iTextField) component).getText().toString())); + break; + case TCProperty.PROP_double: + case TCProperty.PROP_float: + formProperty.setDoubleValue(Double.parseDouble(((iTextField) component).getText().toString())); + break; + case TCProperty.PROP_date: + String val = ((iTextField) component).getText().toString(); + if (!val.equals("")) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date date = sdf.parse(val); + if (date != null) { + formProperty.setDateValue(date); + } + } + break; + default: + formProperty.setStringValue(((iTextField) component).getText().toString()); + break; + } + } catch (NumberFormatException e) { + e.printStackTrace(); + } catch (TCException e) { + e.printStackTrace(); + } + } else if (component instanceof JTextArea) { + formProperty.setStringValue(((JTextArea) component).getText().toString()); + } else if (component instanceof JCheckBox) { + try { + formProperty.setLogicalValue(((JCheckBox) component).isSelected()); + } catch (TCException e) { + e.printStackTrace(); + } + } else if (component instanceof JRadioButton) { + try { + formProperty.setLogicalValue(((JRadioButton) component).isSelected()); + } catch (TCException e) { + e.printStackTrace(); + } + } else if (component instanceof DateButton) { + Date dt = ((DateButton) component).getDate(); + if (dt == null) { + formProperty.setPropValueNull(true); + } else { + formProperty.setDateValueData(dt); + } + } else if (component instanceof JComboBox) { + JComboBox cbx = (JComboBox) component; + String value = ""; + if (!((JComboBoxInfo) ci).canWrite) { + if (cbx.getSelectedItem() != null) { + value = cbx.getSelectedItem().toString(); + } + } else { + value = ((JTextField) cbx.getEditor().getEditorComponent()).getText(); + } + if (((JComboBoxInfo) ci).valueType.equalsIgnoreCase("lov")) { + if (((JComboBoxInfo) ci).lovVal != null) { + Iterator iter = ((JComboBoxInfo) ci).lovVal.keySet().iterator(); + boolean find = false; + while (iter.hasNext()) { + String lovKey = iter.next(); + String lovValue = ((JComboBoxInfo) ci).lovVal.get(lovKey); + if (lovValue.equalsIgnoreCase(value)) { + formProperty.setStringValue(lovKey); + find = true; + // System.out.println("saveRendering1-------------------------------" + // + propName + "-----value-----" + + // lovKey); + break; + } + } + if (!find) { + formProperty.setStringValue(value); + // System.out.println("saveRendering2-------------------------------" + // + propName + "-----value-----" + value); + } + } + } else if (((JComboBoxInfo) ci).valueType.equalsIgnoreCase("Cls_Class")) { + boolean find = false; + if (((JComboBoxInfo) ci).key_values != null) { + for (int i = 0; i < ((JComboBoxInfo) ci).key_values.size(); i++) { + String res = ((JComboBoxInfo) ci).key_values.get(i).get("PNAME").toString(); + if (res.equalsIgnoreCase(value)) { + formProperty.setStringValue(((JComboBoxInfo) ci).key_values.get(i).get("PCID").toString()); + find = true; + break; + } + } + } + if (!find && ((JComboBoxInfo) ci).canWrite) { + formProperty.setStringValue(value); + } + } else if (((JComboBoxInfo) ci).valueType.equalsIgnoreCase("Cls_Instance2")) { + if (((JComboBoxInfo) ci).lovVal != null) { + Iterator iter = ((JComboBoxInfo) ci).lovVal.keySet().iterator(); + boolean find = false; + while (iter.hasNext()) { + String lovKey = iter.next(); + String lovValue = ((JComboBoxInfo) ci).lovVal.get(lovKey); + if (lovValue.equalsIgnoreCase(value)) { + formProperty.setStringValue(lovKey); + find = true; + // System.out.println("saveRendering1-------------------------------" + // + propName + "-----value-----" + + // lovKey); + break; + } + } + if (!find) { + formProperty.setStringValue(value); + // System.out.println("saveRendering2-------------------------------" + // + propName + "-----value-----" + value); + } + } + } else { + formProperty.setStringValue(value); + } + } + formPropertys.add(formProperty); + // { + // switch (formProperty.getPropertyType()) { + // case TCProperty.PROP_string: + // case TCProperty.PROP_long_string: + // System.out.println("saveRendering-----" + propName + + // "-----type-----" + ci.type + "-----formProperty-----" + + // formProperty.getStringValue()); + // break; + // case TCProperty.PROP_short: + // case TCProperty.PROP_int: + // System.out.println("saveRendering-----" + propName + + // "-----type-----" + ci.type + "-----formProperty-----" + + // formProperty.getIntValue()); + // break; + // case TCProperty.PROP_double: + // case TCProperty.PROP_float: + // System.out.println("saveRendering-----" + propName + + // "-----type-----" + ci.type + "-----formProperty-----" + + // formProperty.getDoubleValue()); + // break; + // case TCProperty.PROP_date: + // SimpleDateFormat sdf = new + // SimpleDateFormat("yyyy-MM-dd"); + // if (formProperty.getDateValue() != null) { + // System.out.println("saveRendering-----" + propName + + // "-----type-----" + ci.type + "-----formProperty-----" + + // sdf.format(formProperty.getDateValue())); + // } + // break; + // } + // } + } else { + int colIdx = -1; + for (int j = 0; j < ci.parentTableInfo.childComponentInfos.size(); j++) { + ComponentInfo tcci = ci.parentTableInfo.childComponentInfos.get(j); + if (tcci.name.equalsIgnoreCase(propName)) { + colIdx = j; + break; + } + } + if (colIdx != -1) { + Vector rowData = new Vector(); + for (int l = 0; l < ci.parentTableInfo.dataTableModel.getRowCount(); l++) { + if (ci.parentTableInfo.dataTableModel.getValueAt(l, colIdx) == null) { + rowData.add(""); + } else { + String valCell = ci.parentTableInfo.dataTableModel.getValueAt(l, colIdx).toString(); + if (ci.type.equalsIgnoreCase("JComboBox") && ((JComboBoxInfo) ci).valueType.equalsIgnoreCase("lov") && !((JComboBoxInfo) ci).valueName.equals("")) { + Iterator iter = ((JComboBoxInfo) ci).lovVal.keySet().iterator(); + boolean find = false; + while (iter.hasNext()) { + String lovKey = iter.next(); + String lovValue = ((JComboBoxInfo) ci).lovVal.get(lovKey); + if (lovValue.equalsIgnoreCase(valCell)) { + rowData.add(lovKey); + find = true; + break; + } + } + if (!find) { + rowData.add(valCell); + } + } else if (ci.type.equalsIgnoreCase("JComboBox") && ((JComboBoxInfo) ci).valueType.equalsIgnoreCase("Cls_Class") && !((JComboBoxInfo) ci).valueName.equals("")) { + if (((JComboBoxInfo) ci).key_values != null) { + for (int i = 0; i < ((JComboBoxInfo) ci).key_values.size(); i++) { + String res = ((JComboBoxInfo) ci).key_values.get(i).get("PNAME").toString(); + if (res.equalsIgnoreCase(valCell)) { + rowData.add(((JComboBoxInfo) ci).key_values.get(i).get("PCID").toString()); + break; + } + } + } + } else { + rowData.add(valCell); + } + } + } + if (rowData.size() > 0) { + String[] strRowData = new String[rowData.size()]; + rowData.toArray(strRowData); + // System.out.println(CommonUtil.debug(new + // Throwable().getStackTrace()[0]) + ci.name + + // "========" + rowData); + try { + switch (this.formProperties[k].getPropertyType()) { + case TCProperty.PROP_string: + case TCProperty.PROP_long_string: + formProperty.setStringValueArray(strRowData); + break; + case TCProperty.PROP_short: + case TCProperty.PROP_int: + int[] iRowData = new int[strRowData.length]; + for (int i = 0; i < strRowData.length; i++) { + if (strRowData[i].equals("")) { + iRowData[i] = 0; + } else { + iRowData[i] = Integer.parseInt(strRowData[i]); + } + } + formProperty.setIntValueArray(iRowData); + break; + case TCProperty.PROP_double: + case TCProperty.PROP_float: + double[] doubleRowData = new double[strRowData.length]; + for (int i = 0; i < strRowData.length; i++) { + if (strRowData[i].equals("")) { + doubleRowData[i] = 0.0; + } else { + doubleRowData[i] = Double.parseDouble(strRowData[i]); + } + } + formProperty.setDoubleValueArray(doubleRowData); + break; + case TCProperty.PROP_date: + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date[] dateRowData = new Date[strRowData.length]; + for (int i = 0; i < strRowData.length; i++) { + if (strRowData[i].equals("")) { + dateRowData[i] = null; + } else { + Date date = null; + //TODO lidy20190521ͼֽĵڸʽ + if((fromType.equals("YSR8_ECN2RevisionMasterForm") || fromType.equals("YSR8_ECN4RevisionMasterForm")|| + fromType.equals("YSR8_INSPRecordRevisionMasterForm")) && strRowData[i].length()>10) { + date = sdf2.parse(strRowData[i]); + }else + date = sdf.parse(strRowData[i]); + dateRowData[i] = date; + } + } + formProperty.setDateValueArray(dateRowData); + break; + default: + formProperty.setStringValueArray(strRowData); + break; + } + } catch (NumberFormatException e) { + e.printStackTrace(); + } catch (TCException e) { + e.printStackTrace(); + } + } else { + formProperty.setPropValueNull(true); + } + formPropertys.add(formProperty); + } + } + } + } catch (TCException ex) { + ex.printStackTrace(); + MessageBox.post(ex); + return null; + } + return formPropertys; + } + +} diff --git a/src/cn/com/ebewin/ysr/view/ImageCellRender.java b/src/cn/com/ebewin/ysr/view/ImageCellRender.java new file mode 100644 index 0000000..f0751dd --- /dev/null +++ b/src/cn/com/ebewin/ysr/view/ImageCellRender.java @@ -0,0 +1,42 @@ +package cn.com.ebewin.ysr.view; + +import java.awt.Component; +import java.io.File; +import java.util.ArrayList; + +import javax.swing.DefaultListCellRenderer; +import javax.swing.ImageIcon; +import javax.swing.JList; +import javax.swing.SwingConstants; + +import com.teamcenter.rac.kernel.TCComponentItem; + +public class ImageCellRender extends DefaultListCellRenderer { + + private static final long serialVersionUID = 1L; + + @SuppressWarnings("unchecked") + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + + if (value instanceof ArrayList) { + ArrayList itemData = (ArrayList)value; + TCComponentItem partItem = (TCComponentItem)itemData.get(0); + File imageFile = (File)itemData.get(4); + if (imageFile == null) { + return this; + } + try { + ImageIcon icon = new ImageIcon(imageFile.getPath()); + setIcon(icon); + setText(partItem.getProperty("item_id") + "-" + partItem.getProperty("object_name")); + setVerticalTextPosition(SwingConstants.BOTTOM); + setHorizontalTextPosition(SwingConstants.CENTER); + } catch (Exception e) { + e.printStackTrace(); + } + } + + return this; + } +} \ No newline at end of file diff --git a/src/cn/com/ebewin/ysr/view/ImageListModel.java b/src/cn/com/ebewin/ysr/view/ImageListModel.java new file mode 100644 index 0000000..e48e683 --- /dev/null +++ b/src/cn/com/ebewin/ysr/view/ImageListModel.java @@ -0,0 +1,31 @@ +package cn.com.ebewin.ysr.view; + +import java.util.ArrayList; +import javax.swing.AbstractListModel; + +public class ImageListModel extends AbstractListModel> { + + private static final long serialVersionUID = 1L; + + //item rev from dataset file + private ArrayList> itemDatas = new ArrayList>(); + + public void addElement(ArrayList itemData){ + this.itemDatas.add(itemData); + } + + public int getSize() { + return itemDatas.size(); + } + + public ArrayList getElementAt(int index) { + if (index >= itemDatas.size()) { + return null; + } + return itemDatas.get(index); + } + + public void RemoveAll() { + itemDatas.removeAll(itemDatas); + } +} \ No newline at end of file diff --git a/src/cn/com/ebewin/ysr/view/ebewinPartView.java b/src/cn/com/ebewin/ysr/view/ebewinPartView.java new file mode 100644 index 0000000..c25ed6a --- /dev/null +++ b/src/cn/com/ebewin/ysr/view/ebewinPartView.java @@ -0,0 +1,287 @@ +package cn.com.ebewin.ysr.view; + +import java.awt.BorderLayout; +import java.awt.Font; +import java.awt.Frame; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.File; +import java.util.ArrayList; + +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JScrollPane; +import javax.swing.SwingUtilities; + +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.swt.SWT; +import org.eclipse.swt.awt.SWT_AWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.ISelectionListener; +import org.eclipse.ui.IViewSite; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.part.ViewPart; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + +import cn.com.ebewin.ysr.util.CommonUtil; +import cn.com.ebewin.ysr.util.TCUtil; + +public class ebewinPartView extends ViewPart implements ISelectionListener { + + private Frame frame = null; + private JScrollPane scrollPane = null; + private JLabel lable = null; + private JList> list = null; + private ImageListModel listModel = null; + private File defaultThumbnailPicFile = null; + private int colMax = 4; + + private AbstractAIFUIApplication app = null; + private TCSession session = null; + private TCComponentFolder currFolder = null; + + public ebewinPartView() { + super(); + } + + @Override + public void createPartControl(Composite parent) { + Composite composite = new Composite(parent, SWT.EMBEDDED); + frame = SWT_AWT.new_Frame(composite); + //frame.setSize(802, 620); + + list = new JList>(); + listModel = new ImageListModel(); + list.setModel(listModel); + list.setCellRenderer(new ImageCellRender()); + list.setLayoutOrientation(JList.HORIZONTAL_WRAP); + list.setFont(new Font("΢ź", Font.PLAIN, 12)); + + list.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + //System.out.println(CommonUtil.debug(new Throwable().getStackTrace()[0]) + "mouseClicked"); + //System.out.println(CommonUtil.debug(new Throwable().getStackTrace()[0]) + list.getSelectedIndex()); + if(list.getSelectedIndex() != -1) { + if(e.getClickCount() == 1) + oneClick(list.getSelectedValue()); + if(e.getClickCount() == 2) + twoClick(list.getSelectedValue()); + } + } + }); + + scrollPane = new JScrollPane(list); + //scrollPane.setPreferredSize(new Dimension(800,600)); + //frame.getContentPane().add(scrollPane, BorderLayout.CENTER); + //frame.getContentPane().add(new JLabel("㲿"),BorderLayout.NORTH); + frame.add(BorderLayout.CENTER, scrollPane); + lable = new JLabel("㲿"); + lable.setFont(new Font("΢ź", Font.PLAIN, 20)); + frame.add(BorderLayout.NORTH, lable); + frame.setLocationRelativeTo(null); + frame.pack(); + frame.setVisible(true); + + this.getSite().getPage().addSelectionListener(this); + + try { + app = AIFUtility.getCurrentApplication(); + session = (TCSession)app.getSession(); + TCComponentItem item = TCUtil.findItemByID(session, "DefaultThumbnailPicFile"); + if (item != null) { + TCComponentItemRevision revision = item.getLatestItemRevision(); + TCComponent[] components = revision.getRelatedComponents("IMAN_specification"); + if (components != null && components.length > 0) { + for (int j = 0; j < components.length;) { + TCComponentDataset dataset = (TCComponentDataset) components[j]; + File file = TCUtil.exportFile(dataset, "PNG", "DefaultThumbnailPicFile.png", CommonUtil.tmpDir); + if (file != null) { + defaultThumbnailPicFile = file; + } + break; + } + } + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + private void oneClick(Object value) { + // + } + + private void twoClick(Object value) { + //˫ + @SuppressWarnings("unchecked") + ArrayList itemData = (ArrayList)value; + //System.out.println(CommonUtil.debug(new Throwable().getStackTrace()[0]) + itemData); + final TCComponentItem partItem = (TCComponentItem)itemData.get(0); + if (SwingUtilities.isEventDispatchThread()) { + //System.out.println(CommonUtil.debug(new Throwable().getStackTrace()[0]) + "isEventDispatchThread1"); + new Runnable() { + public void run() { + AIFDesktop localAIFDesktop; + try { + localAIFDesktop = AIFUtility.getActiveDesktop(); + AbstractAIFCommand localAbstractAIFCommand = session.getOpenCommand(new Object[] { localAIFDesktop, partItem }); + if (localAbstractAIFCommand == null) { + return; + } + localAbstractAIFCommand.executeModeless(); + } catch (java.lang.Exception localException) { + } + } + }.run(); + } else { + //System.out.println(CommonUtil.debug(new Throwable().getStackTrace()[0]) + "isEventDispatchThread2"); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + AIFDesktop localAIFDesktop; + try { + localAIFDesktop = AIFUtility.getActiveDesktop(); + AbstractAIFCommand localAbstractAIFCommand = session.getOpenCommand(new Object[] { localAIFDesktop, partItem }); + if (localAbstractAIFCommand == null) { + return; + } + localAbstractAIFCommand.executeModeless(); + } catch (java.lang.Exception localException) { + } + } + }); + } + } + + @Override + public void setFocus() { + } + + @Override + public IViewSite getViewSite() { + return super.getViewSite(); + } + + public void selectionChanged(IWorkbenchPart arg0, ISelection arg1) { + //System.out.println(CommonUtil.debug(new Throwable().getStackTrace()[0]) + "selectionChanged"); + if(arg1 == null) { + return; + } + //System.out.println(CommonUtil.debug(new Throwable().getStackTrace()[0]) + arg1); + if (arg1 instanceof StructuredSelection) { + StructuredSelection selection = (StructuredSelection)arg1; + Object object = selection.getFirstElement(); + //System.out.println(CommonUtil.debug(new Throwable().getStackTrace()[0]) + object); + //System.out.println(CommonUtil.debug(new Throwable().getStackTrace()[0]) + object.getClass()); + if(object != null) { + if (object instanceof TCComponentFolder) { + //System.out.println(CommonUtil.debug(new Throwable().getStackTrace()[0]) + "selectionChanged1"); + getFolderItemDatas((TCComponentFolder)object); + } else if (object instanceof AIFComponentContext) { + Object object1 = ((AIFComponentContext)object).getComponent(); + if (object1 instanceof TCComponentFolder) { + //System.out.println(CommonUtil.debug(new Throwable().getStackTrace()[0]) + "selectionChanged2"); + getFolderItemDatas((TCComponentFolder)object1); + } + } + } + } + } + + private void getFolderItemDatas(final TCComponentFolder folder) { + if (currFolder != null && currFolder.getUid().equals(folder.getUid())) { + return; + } + currFolder = folder; + //System.out.println(CommonUtil.debug(new Throwable().getStackTrace()[0]) + "getFolderItemDatas"); + + new Thread(new Runnable() { + @Override + public void run() { + try { + listModel.RemoveAll(); + + lable.setText(folder.getProperty("object_name") + "㲿"); + //System.out.println(CommonUtil.debug(new Throwable().getStackTrace()[0]) + folder.getProperty("object_name")); + + AIFComponentContext[] context = folder.getChildren("contents"); + //System.out.println(CommonUtil.debug(new Throwable().getStackTrace()[0]) + context.length); + for (int i = 0; i < context.length; i++) { + TCComponent childPart = (TCComponent) context[i].getComponent(); + String object_typeVal = childPart.getProperty("object_type"); + //System.out.println(CommonUtil.debug(new Throwable().getStackTrace()[0]) + object_typeVal); + if (object_typeVal.equalsIgnoreCase("׼") || + object_typeVal.equalsIgnoreCase("") || + object_typeVal.equalsIgnoreCase("ɹ") || + object_typeVal.equalsIgnoreCase("㲿") || + object_typeVal.equalsIgnoreCase("Ԫ") + ) { + TCComponentItem partItem = (TCComponentItem)childPart; + //System.out.println(CommonUtil.debug(new Throwable().getStackTrace()[0]) + partItem); + TCComponentItemRevision partRevision = partItem.getLatestItemRevision(); + //System.out.println(CommonUtil.debug(new Throwable().getStackTrace()[0]) + partRevision); + TCComponentForm partForm = TCUtil.getItemRevisionMasterForm(partRevision); + ArrayList objarr = new ArrayList(); + objarr.add(partItem); + objarr.add(partRevision); + objarr.add(partForm); + + Boolean findPNG = false; + TCComponent[] components = partRevision.getRelatedComponents("IMAN_specification"); + //System.out.println(CommonUtil.debug(new Throwable().getStackTrace()[0]) + components.length); + if (components != null && components.length > 0) { + for (int j = 0; j < components.length; j++) { + TCComponentDataset dataset = (TCComponentDataset) components[j]; + //System.out.println(CommonUtil.debug(new Throwable().getStackTrace()[0]) + dataset); + String type = dataset.getProperty("object_type"); + //System.out.println(CommonUtil.debug(new Throwable().getStackTrace()[0]) + type); + if (!type.equals("SolidWorks ") && !type.equals("SolidWorks װ")) { + continue; + } + String name = dataset.getProperty("object_string"); + //System.out.println(CommonUtil.debug(new Throwable().getStackTrace()[0]) + name); + File file = TCUtil.exportFile(dataset, "PNG", name + ".png", CommonUtil.tmpDir); + if (file != null) { + //System.out.println(CommonUtil.debug(new Throwable().getStackTrace()[0]) + file); + objarr.add(dataset); + objarr.add(file); + findPNG = true; + break; + } + } + } + if (!findPNG) { + objarr.add(null); + objarr.add(defaultThumbnailPicFile); + } + System.out.println(CommonUtil.debug(new Throwable().getStackTrace()[0]) + objarr); + listModel.addElement(objarr); + } + } + list.setVisibleRowCount(listModel.getSize() % colMax == 0 ? listModel.getSize() / colMax : listModel.getSize() / colMax + 1); + } catch (TCException e) { + e.printStackTrace(); + } +// list.revalidate(); +// list.repaint(); +// frame.revalidate(); + frame.repaint(); +// frame.setVisible(false); +// frame.setVisible(true); + } + }).start(); + } +} 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..daf2a7e --- /dev/null +++ b/src/com/teamcenter/rac/stylesheet/stylesheet_user.properties @@ -0,0 +1,22 @@ +YSR8_ProjectSRevisionMaster.FORMJAVARENDERING=cn.com.ebewin.ysr.form.YSR8_ProjectSRevisionMasterForm +YSR8_TaskRevisionMaster.FORMJAVARENDERING=cn.com.ebewin.ysr.form.YSR8_TaskRevisionMasterForm +YSR8_ProjectSimRevisionMaster.FORMJAVARENDERING=cn.com.ebewin.ysr.form.YSR8_ProjectSimRevisionMasterForm +YSR8_SimConRevisionMaster.FORMJAVARENDERING=cn.com.ebewin.ysr.form.YSR8_SimConRevisionMasterForm +YSR8_MotomanCRevisionMaster.FORMJAVARENDERING=cn.com.ebewin.ysr.form.YSR8_MotomanCRevisionMasterForm +YSR8_DesignTaskRevisionMaster.FORMJAVARENDERING=cn.com.ebewin.ysr.form.YSR8_DesignTaskRevisionMasterForm +YSR8_PRRevisionMaster.FORMJAVARENDERING=cn.com.ebewin.ysr.form.YSR8_PRRevisionMasterForm +YSR8_ECN1RevisionMaster.FORMJAVARENDERING=cn.com.ebewin.ysr.form.YSR8_ECN1RevisionMasterForm +YSR8_ECN2RevisionMaster.FORMJAVARENDERING=cn.com.ebewin.ysr.form.YSR8_ECN2RevisionMasterForm +YSR8_ECN3RevisionMaster.FORMJAVARENDERING=cn.com.ebewin.ysr.form.YSR8_ECN3RevisionMasterForm +YSR8_ECN4RevisionMaster.FORMJAVARENDERING=cn.com.ebewin.ysr.form.YSR8_ECN4RevisionMasterForm +YSR8_WorkHoursRevisionMaster.FORMJAVARENDERING=cn.com.ebewin.ysr.form.YSR8_WorkHoursRevisionMasterForm +YSR8_DGPlanningRevisionMaster.FORMJAVARENDERING=cn.com.ebewin.ysr.form.YSR8_DGPlanningRevisionMasterForm +YSR8_SaleProjectRevisionMaster.FORMJAVARENDERING=cn.com.ebewin.ysr.form.YSR8_SaleProjectRevisionMasterForm +YSR8_SaleOrderRevisionMaster.FORMJAVARENDERING=cn.com.ebewin.ysr.form.YSR8_SaleOrderRevisionMasterForm +YSR8_TravelOrderRevisionMaster.FORMJAVARENDERING=cn.com.ebewin.ysr.form.YSR8_TravelOrderRevisionMasterForm +YSR8_TravelORDENRevisionMaster.FORMJAVARENDERING=cn.com.ebewin.ysr.form.YSR8_TravelORDENRevisionMasterForm +YSR8_AccepComRevisionMaster.FORMJAVARENDERING=cn.com.ebewin.ysr.form.YSR8_AccepComRevisionMasterForm +YSR8_DeliveryRevisionMaster.FORMJAVARENDERING=cn.com.ebewin.ysr.form.YSR8_DeliveryRevisionMasterForm +YSR8_INSPRecordRevisionMaster.FORMJAVARENDERING=cn.com.ebewin.ysr.form.YSR8_INSPRecordRevisionMasterForm +YSR8_DrawingListRevisionMaster.FORMJAVARENDERING=cn.com.ebewin.ysr.form.YSR8_DrawingListRevisionMasterForm +YSR8_TaskStartRevisionMaster.FORMJAVARENDERING=cn.com.ebewin.ysr.form.YSR8_TaskStartRevisionMasterForm \ No newline at end of file