commit 091f74ae942c9ed8f7c2be2eca679df2013ec2f5 Author: xiongcz Date: Fri Jun 6 13:46:04 2025 +0800 1 diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..7786cf3 --- /dev/null +++ b/.classpath @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..463c03e --- /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/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..d7b5d73 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.project b/.project new file mode 100644 index 0000000..4cc9d5f --- /dev/null +++ b/.project @@ -0,0 +1,28 @@ + + + com.connor.zf.plm + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..9f6ece8 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF new file mode 100644 index 0000000..f442ca6 --- /dev/null +++ b/META-INF/MANIFEST.MF @@ -0,0 +1,54 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Plm +Bundle-SymbolicName: com.connor.zf.plm;singleton:=true +Bundle-Version: 1.0.0 +Bundle-Vendor: CONNOR +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + com.teamcenter.rac.aifrcp;bundle-version="13000.1.0", + com.teamcenter.rac.external;bundle-version="13000.1.0", + com.teamcenter.rac.kernel;bundle-version="13000.1.0", + com.teamcenter.rac.ui;bundle-version="13000.1.0", + com.teamcenter.rac.util;bundle-version="13000.1.0", + com.teamcenter.rac.common;bundle-version="13000.1.0", + com.teamcenter.rac.ui.commands;bundle-version="13000.1.0", + com.teamcenter.rac.ui.views;bundle-version="13000.1.0", + com.teamcenter.rac.activity;bundle-version="13000.1.0", + com.teamcenter.rac.tcapps;bundle-version="13000.1.0", + TcSoaCoreRac;bundle-version="13000.1.0", + TcSoaCommon;bundle-version="13000.1.0", + TcSoaCoreTypes;bundle-version="13000.1.0", + org.apache.poi.39;bundle-version="3.9.0" +Automatic-Module-Name: com.connor.zf.plm +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Bundle-ClassPath: jdbc_lib/sqljdbc4.jar, + lib/swingx-1.6.1.jar, + ., + lib/apache-mime4j-core-0.7.2.jar, + lib/axiom-api-1.2.13.jar, + lib/axiom-dom-1.2.13.jar, + lib/axiom-impl-1.2.13.jar, + lib/axis2-adb-1.6.2.jar, + lib/axis2-adb-codegen-1.6.2.jar, + lib/axis2-ant-plugin-1.6.2.jar, + lib/axis2-clustering-1.6.2.jar, + lib/axis2-codegen-1.6.2.jar, + lib/axis2-corba-1.6.2.jar, + lib/axis2-fastinfoset-1.6.2.jar, + lib/axis2-java2wsdl-1.6.2.jar, + lib/axis2-jaxbri-1.6.2.jar, + lib/axis2-jaxws-1.6.2.jar, + lib/axis2-jibx-1.6.2.jar, + lib/axis2-json-1.6.2.jar, + lib/axis2-kernel-1.6.2.jar, + lib/axis2-metadata-1.6.2.jar, + lib/axis2-mtompolicy-1.6.2.jar, + lib/axis2-saaj-1.6.2.jar, + lib/axis2-soapmonitor-servlet-1.6.2.jar, + lib/axis2-spring-1.6.2.jar, + lib/axis2-transport-http-1.6.2.jar, + lib/axis2-transport-local-1.6.2.jar, + lib/axis2-xmlbeans-1.6.2.jar, + lib/fastjson-1.2.9.jar, + lib/ojdbc7.jar diff --git a/bin/com/connor/hs2/plm/PFMEA/create/CreatePFMEAHandler.class b/bin/com/connor/hs2/plm/PFMEA/create/CreatePFMEAHandler.class new file mode 100644 index 0000000..7f1963a Binary files /dev/null and b/bin/com/connor/hs2/plm/PFMEA/create/CreatePFMEAHandler.class differ diff --git a/bin/com/connor/hs2/plm/PFMEA/create/Test.class b/bin/com/connor/hs2/plm/PFMEA/create/Test.class new file mode 100644 index 0000000..be99866 Binary files /dev/null and b/bin/com/connor/hs2/plm/PFMEA/create/Test.class differ diff --git a/bin/com/connor/hs2/plm/PFMEA/design/DesignPFMEACommand.class b/bin/com/connor/hs2/plm/PFMEA/design/DesignPFMEACommand.class new file mode 100644 index 0000000..cc222ec Binary files /dev/null and b/bin/com/connor/hs2/plm/PFMEA/design/DesignPFMEACommand.class differ diff --git a/bin/com/connor/hs2/plm/PFMEA/design/DesignPFMEADialog$AddRowsDialog.class b/bin/com/connor/hs2/plm/PFMEA/design/DesignPFMEADialog$AddRowsDialog.class new file mode 100644 index 0000000..4c6cca0 Binary files /dev/null and b/bin/com/connor/hs2/plm/PFMEA/design/DesignPFMEADialog$AddRowsDialog.class differ diff --git a/bin/com/connor/hs2/plm/PFMEA/design/DesignPFMEADialog$LibraryDialog.class b/bin/com/connor/hs2/plm/PFMEA/design/DesignPFMEADialog$LibraryDialog.class new file mode 100644 index 0000000..703dce9 Binary files /dev/null and b/bin/com/connor/hs2/plm/PFMEA/design/DesignPFMEADialog$LibraryDialog.class differ diff --git a/bin/com/connor/hs2/plm/PFMEA/design/DesignPFMEADialog$SpecialDialog.class b/bin/com/connor/hs2/plm/PFMEA/design/DesignPFMEADialog$SpecialDialog.class new file mode 100644 index 0000000..567229a Binary files /dev/null and b/bin/com/connor/hs2/plm/PFMEA/design/DesignPFMEADialog$SpecialDialog.class differ diff --git a/bin/com/connor/hs2/plm/PFMEA/design/DesignPFMEADialog$selectExportPath.class b/bin/com/connor/hs2/plm/PFMEA/design/DesignPFMEADialog$selectExportPath.class new file mode 100644 index 0000000..cfff9c1 Binary files /dev/null and b/bin/com/connor/hs2/plm/PFMEA/design/DesignPFMEADialog$selectExportPath.class differ diff --git a/bin/com/connor/hs2/plm/PFMEA/design/DesignPFMEADialog.class b/bin/com/connor/hs2/plm/PFMEA/design/DesignPFMEADialog.class new file mode 100644 index 0000000..4aadc81 Binary files /dev/null and b/bin/com/connor/hs2/plm/PFMEA/design/DesignPFMEADialog.class differ diff --git a/bin/com/connor/hs2/plm/PFMEA/design/DesignPFMEAHandler.class b/bin/com/connor/hs2/plm/PFMEA/design/DesignPFMEAHandler.class new file mode 100644 index 0000000..e300df2 Binary files /dev/null and b/bin/com/connor/hs2/plm/PFMEA/design/DesignPFMEAHandler.class differ diff --git a/bin/com/connor/hs2/plm/PFMEA/design/DesignPFMEAOperation.class b/bin/com/connor/hs2/plm/PFMEA/design/DesignPFMEAOperation.class new file mode 100644 index 0000000..0fad140 Binary files /dev/null and b/bin/com/connor/hs2/plm/PFMEA/design/DesignPFMEAOperation.class differ diff --git a/bin/com/connor/hs2/plm/PFMEA/design/InsertPictureToExcelTest.class b/bin/com/connor/hs2/plm/PFMEA/design/InsertPictureToExcelTest.class new file mode 100644 index 0000000..63a9094 Binary files /dev/null and b/bin/com/connor/hs2/plm/PFMEA/design/InsertPictureToExcelTest.class differ diff --git a/bin/com/connor/hs2/plm/PFMEA/design/MultiLineHeaderRenderer.class b/bin/com/connor/hs2/plm/PFMEA/design/MultiLineHeaderRenderer.class new file mode 100644 index 0000000..24b646f Binary files /dev/null and b/bin/com/connor/hs2/plm/PFMEA/design/MultiLineHeaderRenderer.class differ diff --git a/bin/com/connor/hs2/plm/PFMEA/design/PFMEABean.class b/bin/com/connor/hs2/plm/PFMEA/design/PFMEABean.class new file mode 100644 index 0000000..3852ca1 Binary files /dev/null and b/bin/com/connor/hs2/plm/PFMEA/design/PFMEABean.class differ diff --git a/bin/com/connor/hs2/plm/PFMEA/design/Result.class b/bin/com/connor/hs2/plm/PFMEA/design/Result.class new file mode 100644 index 0000000..db79cb3 Binary files /dev/null and b/bin/com/connor/hs2/plm/PFMEA/design/Result.class differ diff --git a/bin/com/connor/hs2/plm/PFMEA/design/SavePfmea.class b/bin/com/connor/hs2/plm/PFMEA/design/SavePfmea.class new file mode 100644 index 0000000..24dc6cc Binary files /dev/null and b/bin/com/connor/hs2/plm/PFMEA/design/SavePfmea.class differ diff --git a/bin/com/connor/hs2/plm/PFMEA/design/SqlUtilT.class b/bin/com/connor/hs2/plm/PFMEA/design/SqlUtilT.class new file mode 100644 index 0000000..a69abab Binary files /dev/null and b/bin/com/connor/hs2/plm/PFMEA/design/SqlUtilT.class differ diff --git a/bin/com/connor/hs2/plm/PFMEA/design/TMomMethodUtil.class b/bin/com/connor/hs2/plm/PFMEA/design/TMomMethodUtil.class new file mode 100644 index 0000000..09e0f38 Binary files /dev/null and b/bin/com/connor/hs2/plm/PFMEA/design/TMomMethodUtil.class differ diff --git a/bin/com/connor/hs2/plm/PFMEA/design/TableCellTextAreaRenderer.class b/bin/com/connor/hs2/plm/PFMEA/design/TableCellTextAreaRenderer.class new file mode 100644 index 0000000..7540402 Binary files /dev/null and b/bin/com/connor/hs2/plm/PFMEA/design/TableCellTextAreaRenderer.class differ diff --git a/bin/com/connor/hs2/plm/PFMEA/design/TableCellTextAreaRenderer2.class b/bin/com/connor/hs2/plm/PFMEA/design/TableCellTextAreaRenderer2.class new file mode 100644 index 0000000..ca211fd Binary files /dev/null and b/bin/com/connor/hs2/plm/PFMEA/design/TableCellTextAreaRenderer2.class differ diff --git a/bin/com/connor/hs2/plm/PFMEA/design/Test.class b/bin/com/connor/hs2/plm/PFMEA/design/Test.class new file mode 100644 index 0000000..e654688 Binary files /dev/null and b/bin/com/connor/hs2/plm/PFMEA/design/Test.class differ diff --git a/bin/com/connor/hs2/plm/PFMEA/design/TreeBean.class b/bin/com/connor/hs2/plm/PFMEA/design/TreeBean.class new file mode 100644 index 0000000..9469ba3 Binary files /dev/null and b/bin/com/connor/hs2/plm/PFMEA/design/TreeBean.class differ diff --git a/bin/com/connor/hs2/plm/PFMEA/design/sql.properties b/bin/com/connor/hs2/plm/PFMEA/design/sql.properties new file mode 100644 index 0000000..bda2428 --- /dev/null +++ b/bin/com/connor/hs2/plm/PFMEA/design/sql.properties @@ -0,0 +1,37 @@ +SETPFMEASELECT=SELECT * FROM AHMC_PFMEA WHERE PROCESSPUID = \'%s\' AND REVISIONID=\'%s\' ORDER BY to_number(NO),to_number(HH) +PFMEALIBRARYSELECT2=SELECT * FROM AHMC_PFMEALIBRARY WHERE PUID = \'%s\' order by NUM + +BOMCHECKSAVESELECTPFMEA=select MEOPID,STATION,gybh,GCMC from AHMC_PFMEA where PROCESSPUID = \'%s\'REVISIONID=\'%s\' + +BOMCHECKSAVESELECTPFMEA2=select * from AHMC_PFMEA where PROCESSPUID = \'%s\' and MEOPID not in %s + +DELETEPFMEA=delete from AHMC_PFMEA where MEOPID = \'%s\' and PROCESSPUID = \'%s\' + +INSERTPFMEA=INSERT INTO AHMC_PFMEA VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) + +PFMEALIBRARYSELECT=SELECT * FROM AHMC_PFMEA_NODE WHERE PARENT_ID = \'%s\' order BY ID +SETPFMEASELECT2=SELECT MEOPID,REQUIREMENT from AHMC_PFMEA where PROCESSPUID = \'%s\' group by MEOPID,REQUIREMENT +SETPFMEADELETE=delete from AHMC_PFMEA where PLMEID = \'%s\' + +SETPFMEAUPDATE=update AHMC_PFMEA set GYBH = ?,GCMC = ?,STATION = ?,REQUIREMENT = ?,QZSXMS = ?,QZSXHG = ?,YZD = ?,JB = ?,QZSXQY = ?,XXGCKZYF = ?,PDS = ?,XXGCKZTC = ?,TCD = ?,RPN = ?,JYCS = ?,ZZR = ?,JHWCRQ = ?,CQDCS = ?,NEW_SEV = ?,NEW_OCC = ?,NEW_DET = ?,NEW_RPN = ?,IDEAL_STATE = ?,SPECIAL = ?,HH = ?,HBDYG = ? ,OCCURRRENCE = ?,DETECTION = ?,PRIORITY = ?,P1 = ?,P2 = ?,P3 = ?,P4 = ?,P5 = ? where plmeid = \'%s\' AND revisionid=\'%s\' +TM2PFMEATREESELECT=select * from AHMC_PFMEA_TREE ORDER BY PARENT_ID,ID + +CONTROLPLANLIBRARYSELECT=SELECT * FROM AHMC_CONTROLPLAN_NODE WHERE PARENT_ID = \'%s\' order BY ID + +TM2CONTROLPLANTREESELECT=select * from AHMC_CONTROLPLAN_TREE ORDER BY TO_NUMBER(PARENT_ID) + +TM2THESAURUSTREESELECT=select * from AHMC_THESAURUS_TREE ORDER BY TO_NUMBER(PARENT_ID) + +TM2THESAURUSNODESELECT=SELECT * FROM AHMC_THESAURUS_NODE WHERE PARENT_ID = \'%s\' order BY ID + +PFMEALIBRARYUPDATE=update AHMC_PFMEA_NODE set ID = ?, STATION = ?,REQUIREMENT = ?,QZSXMS = ?,QZSXHG = ?,YZD = ?,JB = ?,QZSXQY = ?,XXGCKZYF = ?,PDS = ?,XXGCKZTC = ?,TCD = ?,RPN = ?,JYCS = ?,ZZR = ?,JHWCRQ = ?,CQDCS = ?,NEW_SEV = ?,NEW_OCC = ?,NEW_DET = ?,NEW_RPN = ?,IDEAL_STATE = ?,SPECIAL = ?,P1 = ?,P2 = ?,P3 = ?,P4 = ?,P5 = ?,P6 = ?,P7 = ?,P8 = ? where plmeid = \'%s\' + +PFMEALIBRARYDELETE=delete from AHMC_PFMEA_NODE where PLMEID = \'%s\' + +PFMEALIBRARYINSERT=INSERT INTO AHMC_PFMEA_NODE VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) + + +SELECTFRAMESIZE=select * from AHMC_PFMEAFRAME_SIZE WHERE USERNAME = \'%s\' AND TYPE = \'%s\' +FRAMESIZEINSERT=INSERT INTO AHMC_PFMEAFRAME_SIZE VALUES(?,?,?,?,?,?) +FRAMESIZEDELETE=DELETE FROM AHMC_PFMEAFRAME_SIZE WHERE USERNAME = \'%s\' AND TYPE = \'%s\' +FRAMESIZEUPDATE=update AHMC_PFMEAFRAME_SIZE set FRAMESIZE = ?, TABLE1SIZE = ?, TABLE2SIZE = ? WHERE USERNAME = \'%s\' AND TYPE = \'%s\' \ No newline at end of file diff --git a/bin/com/connor/hs2/plm/PFMEA/design/utils.class b/bin/com/connor/hs2/plm/PFMEA/design/utils.class new file mode 100644 index 0000000..0dc4c34 Binary files /dev/null and b/bin/com/connor/hs2/plm/PFMEA/design/utils.class differ diff --git a/bin/com/connor/hs2/plm/PFMEA/library/LibraryCommand$NaturalOrderComparator.class b/bin/com/connor/hs2/plm/PFMEA/library/LibraryCommand$NaturalOrderComparator.class new file mode 100644 index 0000000..795e0eb Binary files /dev/null and b/bin/com/connor/hs2/plm/PFMEA/library/LibraryCommand$NaturalOrderComparator.class differ diff --git a/bin/com/connor/hs2/plm/PFMEA/library/LibraryCommand.class b/bin/com/connor/hs2/plm/PFMEA/library/LibraryCommand.class new file mode 100644 index 0000000..fd53250 Binary files /dev/null and b/bin/com/connor/hs2/plm/PFMEA/library/LibraryCommand.class differ diff --git a/bin/com/connor/hs2/plm/PFMEA/library/LibraryDialog$AddRowsDialog.class b/bin/com/connor/hs2/plm/PFMEA/library/LibraryDialog$AddRowsDialog.class new file mode 100644 index 0000000..f85ab85 Binary files /dev/null and b/bin/com/connor/hs2/plm/PFMEA/library/LibraryDialog$AddRowsDialog.class differ diff --git a/bin/com/connor/hs2/plm/PFMEA/library/LibraryDialog$NaturalOrderComparator.class b/bin/com/connor/hs2/plm/PFMEA/library/LibraryDialog$NaturalOrderComparator.class new file mode 100644 index 0000000..4fe21c4 Binary files /dev/null and b/bin/com/connor/hs2/plm/PFMEA/library/LibraryDialog$NaturalOrderComparator.class differ diff --git a/bin/com/connor/hs2/plm/PFMEA/library/LibraryDialog$SpecialDialog.class b/bin/com/connor/hs2/plm/PFMEA/library/LibraryDialog$SpecialDialog.class new file mode 100644 index 0000000..aa32b8f Binary files /dev/null and b/bin/com/connor/hs2/plm/PFMEA/library/LibraryDialog$SpecialDialog.class differ diff --git a/bin/com/connor/hs2/plm/PFMEA/library/LibraryDialog.class b/bin/com/connor/hs2/plm/PFMEA/library/LibraryDialog.class new file mode 100644 index 0000000..c4cac1f Binary files /dev/null and b/bin/com/connor/hs2/plm/PFMEA/library/LibraryDialog.class differ diff --git a/bin/com/connor/hs2/plm/PFMEA/library/LibraryHandler.class b/bin/com/connor/hs2/plm/PFMEA/library/LibraryHandler.class new file mode 100644 index 0000000..6507387 Binary files /dev/null and b/bin/com/connor/hs2/plm/PFMEA/library/LibraryHandler.class differ diff --git a/bin/com/connor/hs2/plm/PFMEA/library/sql.properties b/bin/com/connor/hs2/plm/PFMEA/library/sql.properties new file mode 100644 index 0000000..f88d458 --- /dev/null +++ b/bin/com/connor/hs2/plm/PFMEA/library/sql.properties @@ -0,0 +1,37 @@ +SETPFMEASELECT=SELECT * FROM AHMC_PFMEA WHERE PROCESSPUID = \'%s\' AND REVISIONID=\'%s\' ORDER BY to_number(NO),to_number(HH) +PFMEALIBRARYSELECT2=SELECT * FROM AHMC_PFMEALIBRARY WHERE PUID = \'%s\' order by NUM + +BOMCHECKSAVESELECTPFMEA=select MEOPID,STATION,gybh,GCMC from AHMC_PFMEA where PROCESSPUID = \'%s\' + +BOMCHECKSAVESELECTPFMEA2=select * from AHMC_PFMEA where PROCESSPUID = \'%s\' and MEOPID not in %s + +DELETEPFMEA=delete from AHMC_PFMEA where MEOPID = \'%s\' and PROCESSPUID = \'%s\' + +INSERTPFMEA=INSERT INTO AHMC_PFMEA VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) + +PFMEALIBRARYSELECT=SELECT * FROM AHMC_PFMEA_NODE WHERE PARENT_ID = \'%s\' order BY ID +SETPFMEASELECT2=SELECT MEOPID,REQUIREMENT from AHMC_PFMEA where PROCESSPUID = \'%s\' group by MEOPID,REQUIREMENT +SETPFMEADELETE=delete from AHMC_PFMEA where PLMEID = \'%s\' + +SETPFMEAUPDATE=update AHMC_PFMEA set GYBH = ?,GCMC = ?,STATION = ?,REQUIREMENT = ?,QZSXMS = ?,QZSXHG = ?,YZD = ?,JB = ?,QZSXQY = ?,XXGCKZYF = ?,PDS = ?,XXGCKZTC = ?,TCD = ?,RPN = ?,JYCS = ?,ZZR = ?,JHWCRQ = ?,CQDCS = ?,NEW_SEV = ?,NEW_OCC = ?,NEW_DET = ?,NEW_RPN = ?,IDEAL_STATE = ?,SPECIAL = ?,HH = ?,HBDYG = ? ,OCCURRRENCE = ?,DETECTION = ?,PRIORITY = ?,P1 = ?,P2 = ?,P3 = ?,P4 = ?,P5 = ? where plmeid = \'%s\' AND revisionid=\'%s\' +TM2PFMEATREESELECT=select * from AHMC_PFMEA_TREE ORDER BY PARENT_ID,ID + +CONTROLPLANLIBRARYSELECT=SELECT * FROM AHMC_CONTROLPLAN_NODE WHERE PARENT_ID = \'%s\' order BY ID + +TM2CONTROLPLANTREESELECT=select * from AHMC_CONTROLPLAN_TREE ORDER BY TO_NUMBER(PARENT_ID) + +TM2THESAURUSTREESELECT=select * from AHMC_THESAURUS_TREE ORDER BY TO_NUMBER(PARENT_ID) + +TM2THESAURUSNODESELECT=SELECT * FROM AHMC_THESAURUS_NODE WHERE PARENT_ID = \'%s\' order BY ID + +PFMEALIBRARYUPDATE=update AHMC_PFMEA_NODE set ID = ?, STATION = ?,REQUIREMENT = ?,QZSXMS = ?,QZSXHG = ?,YZD = ?,JB = ?,QZSXQY = ?,XXGCKZYF = ?,PDS = ?,XXGCKZTC = ?,TCD = ?,RPN = ?,JYCS = ?,ZZR = ?,JHWCRQ = ?,CQDCS = ?,NEW_SEV = ?,NEW_OCC = ?,NEW_DET = ?,NEW_RPN = ?,IDEAL_STATE = ?,SPECIAL = ?,P1 = ?,P2 = ?,P3 = ?,P4 = ?,P5 = ?,P6 = ?,P7 = ?,P8 = ? where plmeid = \'%s\' + +PFMEALIBRARYDELETE=delete from AHMC_PFMEA_NODE where PLMEID = \'%s\' + +PFMEALIBRARYINSERT=INSERT INTO AHMC_PFMEA_NODE VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) + + +SELECTFRAMESIZE=select * from AHMC_PFMEAFRAME_SIZE WHERE USERNAME = \'%s\' AND TYPE = \'%s\' +FRAMESIZEINSERT=INSERT INTO AHMC_PFMEAFRAME_SIZE VALUES(?,?,?,?,?,?) +FRAMESIZEDELETE=DELETE FROM AHMC_PFMEAFRAME_SIZE WHERE USERNAME = \'%s\' AND TYPE = \'%s\' +FRAMESIZEUPDATE=update AHMC_PFMEAFRAME_SIZE set FRAMESIZE = ?, TABLE1SIZE = ?, TABLE2SIZE = ? WHERE USERNAME = \'%s\' AND TYPE = \'%s\' \ No newline at end of file diff --git a/bin/com/connor/renben/process/plm/message/Message.properties b/bin/com/connor/renben/process/plm/message/Message.properties new file mode 100644 index 0000000..f2fdd2f --- /dev/null +++ b/bin/com/connor/renben/process/plm/message/Message.properties @@ -0,0 +1,1594 @@ +xljid_display.TITLE=New Item ID +bbid_display.TITLE=Revision ID +mc_display.TITLE=Name +jlzjid_display.TITLE=Old Item ID +qd_display.TITLE=Sure +qx_display.TITLE=Cancel +cxdr_display.TITLE=Re-import +hbgykdc_display.TITLE=Export horizontal plate process card +sbgykdc_display.TITLE=Export vertical process card +zpgykdc_display.TITLE=Export of assembly process card +zyjzsdc_display.TITLE=Operation reference book export +xzdctp_display.TITLE=Select export picture +sc08_display.TITLE=Delete +lx_display.TITLE=Type +dw_display.TITLE=Unit +scgc_display.TITLE=Production plant +xljxx_display.TITLE=New Item Information +jy_display.TITLE=Based_on +lzjxx_display.TITLE=Item Information +sx_display.TITLE=Attribute +sxsj_display.TITLE=Refresh +ssckzjh_display.TITLE=Pilot production control plan +sckzjh_display.TITLE=Production control plan +dc_display.TITLE=Export +xzlj_display.TITLE=Select path +xzwjj_display.TITLE=Select Folder: +pldctz_display.TITLE=Batch export drawings +dcd_display.TITLE=Export to: +ll_display.TITLE=Browse... +txkzjh_display.TITLE=Fill in control plan +bc_display.TITLE=Save +CP/kzjh_display.TITLE=CONTROL PLAN/Control plan +yj_display.TITLE=Sample +ssc_display.TITLE=Trial production +sc_display.TITLE=Production +kzjhbh_display.TITLE=Control plan number +zylxrbzr_display.TITLE=Main contact / Preparer +zylxrdhbzrdh_display.TITLE=Main contact telephone number / Preparer telephone number +rq(bz)_display.TITLE=Date (Preparation) +rq(xd)_display.TITLE=Date (Revised) +SORhmmc_display.TITLE=SOR Number / Name +ljhzzbb_display.TITLE=Part number / Final version +hxxz_display.TITLE=Core group +gkgcpzrq_display.TITLE=Customer engineering approval / Date +khtzbh_display.TITLE=Customer drawing number +ljmcms_display.TITLE=Item name / Description +gfgcpzrq_display.TITLE=Supplier / Factory approval / Date +gkzlpzrq_display.TITLE=Customer quality approval / Date +gfgc_display.TITLE=Supplier / Factory +gfdh_display.TITLE=Supplier code +gkpzrq_display.TITLE=Customer approval / Date +qtpzrq_display.TITLE=Other approval / Date +tjh_display.TITLE=Add rows +tjdh_display.TITLE=Add multiple lines +tjhbh_display.TITLE=Add merge row +tjdghbh_display.TITLE=Add multiple merged rows +tjgx_display.TITLE=Add procedure +hbh_display.TITLE=Merge lines +cfhbdyg_display.TITLE=Split and merge cells +yczh_display.TITLE=Remove entire row +sxxzl_display.TITLE=Zoom out the selected column +qxsxxzl_display.TITLE=Cancel narrowing selected column +txbz_display.TITLE=Filling standard +dcnbkzjh_display.TITLE=Export internal control plan +fqsh_display.TITLE=Initiate audit +kzjhk_display.TITLE=Control plan library +ck_display.TITLE=Lexicon +cxjz_display.TITLE=Reload +qksj_display.TITLE=Clear all data +cjgy_display.TITLE=Create technology +xh_display.TITLE=Model +cpmc_display.TITLE=Product name +cxyj_display.TITLE=Forming press +khmc_display.TITLE=Customer name +khth_display.TITLE=Customer drawing number +zxyj_display.TITLE=Integral press +khxmh_display.TITLE=Customer project number +clbz_display.TITLE=Material standard +sjry_display.TITLE=Designers +cjrq_display.TITLE=Creation date +cx06_display.TITLE=Query +cph06_display.TITLE=Product ID +gybh06_display.TITLE=Process number +mc06_display.TITLE=Name +gyfg08_display.TITLE=Process division +xzz08_display.TITLE=Selection value: +yhm08_display.TITLE=User name: +ss08_display.TITLE=Search +txPFMEA10_display.TITLE=Fill in PFMEA +qzsxmsjhgfx10_display.TITLE=Potential failure mode and consequence analysis +gsmc10_display.TITLE=Corporate name +xm10_display.TITLE=Project +PFMEAIDbh10_display.TITLE=PFMEA ID number +zzdz10_display.TITLE=Manufacturing address +PFMEAksrq10_display.TITLE=PFMEA start date +PFMEAxdrq10_display.TITLE=PFMEA revision date +gczz10_display.TITLE=Process responsibilities +gkmc10_display.TITLE=Customer name +bmjb10_display.TITLE=Security level +cxpt10_display.TITLE=Model / Platform +kzntd10_display.TITLE=Cross functional team +ll10_display.TITLE=PFMEA experience database +wc10_display.TITLE=Complete +dcPFMEA10_display.TITLE=Export PFMEA +PFMEAc10_display.TITLE=PFMEA Library +xztsfh10_display.TITLE=Select special symbol +cz10_display.TITLE=Search +fzdh10_display.TITLE=Copy multiple lines +crhs10_display.TITLE=Insert rows +ych12_display.TITLE=Remove row +tjjd12_display.TITLE=Add node +ycjd12_display.TITLE=Remove node +gxjd12_display.TITLE=Update node +jdmc12_display.TITLE=Node name +jdID12_display.TITLE=Node ID +xztsfh12_display.TITLE=Select special symbol +bzgy17_display.TITLE=Packaging technology +cpdh17_display.TITLE=Product code +cpmc17_display.TITLE=Product name +yhth17_display.TITLE=User drawing number +chmc17_display.TITLE=Customer name +jszg17_display.TITLE=Technical director +sjxzljtp17_display.TITLE=Double click to select the part image +bzfs17_display.TITLE=Packing method +jyfs17_display.TITLE=Oil immersion method +mxsl17_display.TITLE=Quantity per case +jx17_display.TITLE=Pieces / case +wzxm17_display.TITLE=Name of outer carton +bzde17_display.TITLE=Packaging quota +xs17_display.TITLE=Case / hour +nldm17_display.TITLE=Name of nylon bag +cpdz17_display.TITLE=Unit weight of finished product +xsm17_display.TITLE=Blister name +zxmz17_display.TITLE=Gross weight of full container +wxbq17_display.TITLE=Outer box label +rktp17_display.TITLE=Storage tray +xc17_display.TITLE=Box / layer +ct17_display.TITLE=Floor / tray +sjxztp17_display.TITLE=Double click to select Picture +bzsm17_display.TITLE=Step description +zysx17_display.TITLE=Matters needing attention +bzry17_display.TITLE=Staffing +pzry17_display.TITLE=Approved personnel +xgrq17_display.TITLE=Modification date +bz17_display.TITLE=Remarks +ysbzlx17_display.TITLE=Type of transport package +dbfs17_display.TITLE=Packing method +tpgg17_display.TITLE=Tray specification +jgfs17_display.TITLE=Reinforcement method +sjxzdbt17_display.TITLE=Double click to select packing map +dybzxx17_display.TITLE=Unit packaging information +ysbzxx17_display.TITLE=Transport package information +dh17_display.TITLE=Code-named +cckcg17_display.TITLE=Length * width * height (CM) +hd17_display.TITLE=Thickness (MM) +cl17_display.TITLE=Material +gg17_display.TITLE=Specifications +ks17_display.TITLE=Number of holes +cp17_display.TITLE=Product +xgdj18_display.TITLE=Revision level +cxnd18_display.TITLE=Model / year +bz18_display.TITLE=Tagging +ycbz18_display.TITLE=Remove dimension +kzjhdc19_display.TITLE=Control plan export +gx19_display.TITLE=Procedure +cx19_display.TITLE=Query +kzjhwjmc19_display.TITLE=Name of control plan document +drkzjh20_display.TITLE=Import control plan +xzkzjhwj20_display.TITLE=Select control plan file +qcwcbj21_display.TITLE=Clear completion flag +xzgytz23_display.TITLE=Select process drawings +gytz23_display.TITLE=Process drawings: +xz24_display.TITLE=Select +kzjh24_display.TITLE=Control plan +yqrq25_display.TITLE=Overdue date +PDMEAtj25_display.TITLE=PFMEA statistics +dcbb25_display.TITLE=Export report +gb25_display.TITLE=Close +jcfxwtd27_display.TITLE=Inspection and analysis order +wtdbh27_display.TITLE=Relegated bill number +jclx27_display.TITLE=Testing type +jcbm27_display.TITLE=Testing department +wtdw27_display.TITLE=Entrusted unit +wtr27_display.TITLE=Entrusted person +wtdz27_display.TITLE=Entrusted address +wtrlxfs27_display.TITLE=Contact information of client +wtrq27_display.TITLE=Date of commission +xwwcsj27_display.TITLE=Expected completion time +jcyt27_display.TITLE=Testing purpose +jcjg27_display.TITLE=Testing result +xmdj27_display.TITLE=Project level +khdj27_display.TITLE=Customer level +xmbh27_display.TITLE=Project number +yyly27_display.TITLE=Application area +xmmc27_display.TITLE=Project name +cph27_display.TITLE=Product ID +wlh27_display.TITLE=Material number +cplx27_display.TITLE=Product type +scdw27_display.TITLE=Production unit +ypsl27_display.TITLE=Number of samples +ypzt27_display.TITLE=Sample status +wldh27_display.TITLE=Logistics order No +ypbh27_display.TITLE=Sample number +ypclfs27_display.TITLE=Sample handling method +sybw27_display.TITLE=Application site +syhj27_display.TITLE=Use environment +gzzh27_display.TITLE=Working load +zhlx27_display.TITLE=Load type +xzfs27_display.TITLE=Rotation way +xzsd27_display.TITLE=Rotation speed +gzwd27_display.TITLE=Working temperature +xzwtnr27_display.TITLE=Select delegation content +bz27_display.TITLE=Remarks +ypydxc27_display.TITLE=The sample has arrived at the scene +sysj27_display.TITLE=Sample receiving time +syr27_display.TITLE=Sample receiver +ypshjg27_display.TITLE=Sample audit results +yqwcsj27_display.TITLE=Expected completion time +thyy27_display.TITLE=Reason for return +jcrwzb27_display.TITLE=Host of testing task +jcrwxb27_display.TITLE=Testing task jointly +jhkssj27_display.TITLE=Planned start time +jhwcsj27_display.TITLE=Planned completion time +djdywtd27_display.TITLE=Click Print Order +djdyypbs27_display.TITLE=Click to print sample identification +sjwcsj27_display.TITLE=Actual completion time +jcjgsm27_display.TITLE=Description of test results +ypcz27_display.TITLE=Sample disposal +cywz27_display.TITLE=Sample storage location +shsj27_display.TITLE=Audit time +shy27_display.TITLE=Auditor +shjg27_display.TITLE=Audit results +wtxx27_display.TITLE=Delegation information +clfx27_display.TITLE=Material analysis +jljc27_display.TITLE=Metrological testing +wtnr27_display.TITLE=Content of entrustment +zygyk28_display.TITLE=Operation process card +gsmc28_display.TITLE=Corporate name +ljdh28_display.TITLE=Part number +sbxh28_display.TITLE=Product name +bgx28_display.TITLE=This process +sbmc28_display.TITLE=Equipment name +gzmx28_display.TITLE=Tooling details +jgcs28_display.TITLE=Processing parameters +cptxkzyq28_display.TITLE=Product characteristic control requirements +zpgyk29_display.TITLE=Assembly process card +gsmc29_display.TITLE=Corporate name +ljdh29_display.TITLE=Part code +sbxh29_display.TITLE=Equipment model +zyjzs30_display.TITLE=Operation standard +xzdclj31_display.TITLE=Select export path +wjmc31_display.TITLE=File name +jyjzs33_display.TITLE=Inspection standard +bzbz34_display.TITLE=Packaging standard +ljh34_display.TITLE=Part number +ljmc34_display.TITLE=Part name +gys34_display.TITLE=Supplier +gysdh34_display.TITLE=Supplier Code +syzcdmmc34_display.TITLE=Applicable assembly code / name +ljdw(tg)34_display.TITLE=Parts unit (set / piece) +ljgg34_display.TITLE=Part specification (mm) +ljzl34_display.TITLE=Weight of parts (kg) +bzbzclfhdjyms34_display.TITLE=Brief description of packaging, packaging materials, protection, etc +bqgshwz34_display.TITLE=Label format and location +zt35_display.TITLE=Status +wtdsh35_display.TITLE=Authorization form approval +gzfp35_display.TITLE=Assignment of work +scjl35_display.TITLE=Upload record +wtrq35_display.TITLE=Date of commission +wtdh35_display.TITLE=Odd Numbers of commission +wtdw35_display.TITLE=entrusted unit +jclx35_display.TITLE=Test type +xmdj35_display.TITLE=Project level +ycwcrq35_display.TITLE=Expected completion date +jhwcrq35_display.TITLE=Planned completion date +zbry35_display.TITLE=Sponsor +lcjs35_display.TITLE=Process monitoring +dqzt35_display.TITLE=Current status +wtdhypsh35_display.TITLE=Order and sample audit +gzfp35_display.TITLE=Assignment of work +scjg35_display.TITLE=Upload results +sywtd41_display.TITLE=Test order +wtdbh41_display.TITLE=Order No: +scdw41_display.TITLE=Production unit +ccxh41_display.TITLE=Bearing model +sych41_display.TITLE=Use occasion +xmmc41_display.TITLE=entry name +xmbh41_display.TITLE=Project number +xmdj41_display.TITLE=Project level +wtsylx41_display.TITLE=Type of commission test +yzsy41_display.TITLE=Verification test +tzxxsy41_display.TITLE=Special new type test +khyq41_display.TITLE=Customer requirements +sybj41_display.TITLE=Background of the experiment +symd41_display.TITLE=Purpose of the experiment +sygfsjry41_display.TITLE=Test specification (designer) +yjgsyry41_display.TITLE=handed over to the tester +qtsyyq41_display.TITLE=Other test requirements +wtr41_display.TITLE=client +lxfs41_display.TITLE=contact information +gsdz41_display.TITLE=Company address +gscz41_display.TITLE=Company fax +shr41_display.TITLE=Reviewer +shrq41_display.TITLE=Audit date +zjlpz41_display.TITLE=Approved by general manager +sywtftx41_display.TITLE=Fill in by test client +psjl41_display.TITLE=Review record +jhkssj41_display.TITLE=Planned start time +jhjssj41_display.TITLE=Planned end time +syfzr41_display.TITLE=Person in charge of the test +lxdh41_display.TITLE=contact number +psrq41_display.TITLE=Review / date +pzrq41_display.TITLE=Approval / date +swtftx41_display.TITLE=Fill in by client +bz41_display.TITLE=Remarks +gzsjtd41_display.TITLE=Tooling design team +xzscgztz41_display.TITLE=Select upload tooling drawing +qxzyscdwj41_display.TITLE=Please select the file to upload +qd41_display.TITLE=determine +gzsjwcrq141_display.TITLE=Tooling design completion date +gzsj141_display.TITLE=Tooling design +gzdhrq41_display.TITLE=Tooling arrival date +gzsjrq41_display.TITLE=Tooling inspection date +gzsjwcrq41_display.TITLE=Tooling inspection completion date +gzjcbgbh41_display.TITLE=Tooling test report (record) No +gzsj41_display.TITLE=Tooling inspection +ypdyrq41_display.TITLE=Sample arrival date +syqypjcwcrq41_display.TITLE=Sample test completion date before test +syqypjcbgbh41_display.TITLE=Sample test report (record) No. before test +syksrq41_display.TITLE=Test start date +sywcrq41_display.TITLE=Test completion date +syss41_display.TITLE=Test implementation +syhypjcwcrq41_display.TITLE=Completion date of sample test after test +syhypjcbg41_display.TITLE=Sample test report (record) No. after test +ypjc41_display.TITLE=Sample testing +xzscsybg41_display.TITLE=Select upload test report +sywcrq241_display.TITLE=Test completion date +sybgbh41_display.TITLE=Test report no +sybg241_display.TITLE=Test report +sywtd241_display.TITLE=Test order +sykxljap41_display.TITLE=The test is feasible,and arrange immediately +sybkx41_display.TITLE=The test is not feasible +zybcfjywwsy41_display.TITLE=The resources are not enough, suggest to subcontract the test +qijy241_display.TITLE=Other suggestions +btxxbnwk41_display.TITLE=Required item cannot be empty! +gzcg41_display.TITLE=Tooling procurement +xqsp41_display.TITLE=Requirement approval +fxwtd40_display.TITLE=Analysis order +CEAwtd40_display.TITLE=CAE order +wtdbh40_display.TITLE=Order No: +kemc40_display.TITLE=Customer name +xmsstd40_display.TITLE=Project team +xmmc40_display.TITLE=Project name +xmjl40_display.TITLE=Project manager +xmdj40_display.TITLE=Project level +sjbsstd40_display.TITLE=Team of design department +xmbh40_display.TITLE=Project number +sjfzr40_display.TITLE=Design director +xmlx40_display.TITLE=Project type +qwwcsj40_display.TITLE=Expected completion time +jbxx40_display.TITLE=1.Basic Information +scfxry40_display.TITLE=Last analyst +scbgsj40_display.TITLE=Last report time +ggd40_display.TITLE=Change point +ggyy40_display.TITLE=Reason for change +srzl40_display.TITLE=2.Input information +cjtd40_display.TITLE=Undertaking team +xmwtsj40_display.TITLE=Project entrustment time +cjr40_display.TITLE=Undertaker +xmggcs40_display.TITLE=Number of project changes +xbr40_display.TITLE=Co sponsor +jhkssj40_display.TITLE=Planned start time +Romaxjf40_display.TITLE=Romax integral +jsxqts40_display.TITLE=Calculate demand days +yxyjf40_display.TITLE=Finite element integration +jswcsj40_display.TITLE=Calculate completion time +xmcjxx40_display.TITLE=3. Project undertaking information +bghjgmc40_display.TITLE=Report or result name +bgbh40_display.TITLE=Report no +bghjgscsj40_display.TITLE=Report or result upload time +bghjgfk40_display.TITLE=4.Report or result feedback +jdr40_display.TITLE=Check reader +jdsj40_display.TITLE=Check reading time +jdjg40_display.TITLE=Check reading results +thyy40_display.TITLE=Reason for return +bghjgjd40_display.TITLE=5.Report or result check +khmc40_display.TITLE=Customer name +xmbssty40_display.TITLE=Team of project department +sybw40_display.TITLE=Application site +srzl40_display.TITLE=2.Input information +bxqrbgxxx40_display.TITLE=Information must be confirmed and checked +jsscxm40_display.TITLE=Calculate output items +kgxxx40_display.TITLE=Checkable information +ydndqjddjgzwd40_display.TITLE=Kinematic viscosity, cleanliness grade, working temperature +EPtjj40_display.TITLE=EP additive +ysr40_display.TITLE=Pre judge +yssj40_display.TITLE=Preliminary hearing time +ysjg40_display.TITLE=Preliminary results +zbdzys40_display.TITLE=1.Pre-review by team leader +wtdbh240_display.TITLE=Order No +jhwcsj40_display.TITLE=Planned completion time +xmcjxx240_display.TITLE=2.Project undertaking information +jsfxjm40_display.TITLE=Computational analysis modeling +bczlsj40_display.TITLE=Supplementary information time +zyss40_display.TITLE=3.Work implementation +bghjgfk240_display.TITLE=4.Report or result feedback +bghjgjd240_display.TITLE=5.Report or result check +CAEfxxqwtd40_display.TITLE=CAE analysis demand order +jsfxtdcjd40_display.TITLE=Calculation and analysis team acceptance order +ggxmwtd40_display.TITLE=Change project order +tk_display.TITLE=Picture library + + +ljgybh04_display.TITLE=Part / process number +gcmc04_display.TITLE=Process name +jqsbgzjj04_display.TITLE=Machine, equipment, tooling, fixture +smjyzyzb04_display.TITLE=Initial and final inspection / operation preparation +bh04_display.TITLE=Number +cp04_display.TITLE=product +gc04_display.TITLE=process +tstxfl04_display.TITLE=Classification of special characteristics +cpgcgfgc04_display.TITLE=Product / process / specification / tolerance +pgclff04_display.TITLE=Evaluation / measurement method +rl04_display.TITLE=capacity +pl04_display.TITLE=frequency +kzff04_display.TITLE=Control method +fyjh04_display.TITLE=Response plan +tsfhwz04_display.TITLE=Special symbol location +sfwc04_display.TITLE=Complete +fjdID04_display.TITLE=Parent node ID +tszfszwz04_display.TITLE=Location of special characters +xh04_display.TITLE=Serial number +z04_display.TITLE=value +mc04_display.TITLE=name +gysjfdygc34_display.TITLE=Composition of supplier delivery unit +yjbz34_display.TITLE=Primary packaging +ejbz34_display.TITLE=Secondary packaging +sjbz34_display.TITLE=Tertiary packaging + + +wxzcpdxqcxxz02_display.TITLE=Product object is not selected, please Reselect! +qxzzcdxhcj02_display.TITLE=Please select the assembly object and create it +gy02_display.TITLE=Technology +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= + diff --git a/bin/com/connor/renben/process/plm/message/Message_zh_CN.properties b/bin/com/connor/renben/process/plm/message/Message_zh_CN.properties new file mode 100644 index 0000000..5c01029 --- /dev/null +++ b/bin/com/connor/renben/process/plm/message/Message_zh_CN.properties @@ -0,0 +1,1172 @@ +xljid_display.TITLE=\u5DE5\u5E8FID +bbid_display.TITLE=\u7248\u672c\u0049\u0044 +mc_display.TITLE=\u540d\u79f0 +jlzjid_display.TITLE=\u65e7\u96f6\u7ec4\u4ef6\u0049\u0044 +qd_display.TITLE=\u786e\u5b9a +qx_display.TITLE=\u53d6\u6d88 +bc_display.TITLE=\u4FDD\u5B58 +cxdr_display.TITLE=\u91CD\u65B0\u5BFC\u5165 +hbgykdc_display.TITLE=\u6A2A\u7248\u5DE5\u827A\u5361\u5BFC\u51FA +sbgykdc_display.TITLE=\u7AD6\u7248\u5DE5\u827A\u5361\u5BFC\u51FA +zpgykdc_display.TITLE=\u88C5\u914D\u5DE5\u827A\u5361\u5BFC\u51FA +zyjzsdc_display.TITLE=\u4F5C\u4E1A\u57FA\u51C6\u4E66\u5BFC\u51FA +xzdctp_display.TITLE=\u9009\u62E9\u5BFC\u51FA\u56FE\u7247 +sc08_display.TITLE=\u5220\u9664 +lx_display.TITLE=\u7c7b\u578b +dw_display.TITLE=\u5355\u4f4d +scgc_display.TITLE=\u751F\u4EA7\u5DE5\u5382 +xljxx_display.TITLE=\u65b0\u96f6\u4ef6\u4fe1\u606f +jy_display.TITLE=\u57fa\u4e8e +lzjxx_display.TITLE=\u96f6\u7ec4\u4ef6\u4fe1\u606f +sx_display.TITLE=\u5c5e\u6027 +sxsj_display.TITLE=\u5237\u65B0 +ssckzjh_display.TITLE=\u8bd5\u751f\u4ea7\u63a7\u5236\u8ba1\u5212 +sckzjh_display.TITLE=\u751f\u4ea7\u63a7\u5236\u8ba1\u5212 +dc_display.TITLE=\u5bfc\u51fa +xzlj_display.TITLE=\u9009\u62E9\u8DEF\u5F84 +xzwjj_display.TITLE=\u9009\u62e9\u6587\u4ef6\u5939\u003a +pldctz_display.TITLE=\u6279\u91cf\u5bfc\u51fa\u56fe\u7eb8 +dcd_display.TITLE=\u5BFC\u51FA\u5230\uFF1A +ll_display.TITLE=\u6D4F\u89C8... +txkzjh_display.TITLE=\u586B\u5199\u63A7\u5236\u8BA1\u5212 +CP/kzjh_display.TITLE=\u0043\u004f\u004e\u0054\u0052\u004f\u004c\u0020\u0050\u004c\u0041\u004e\u002f\u63a7\u5236\u8ba1\u5212 +yj_display.TITLE=\u6837\u4EF6 +ssc_display.TITLE=\u8BD5\u751F\u4EA7 +sc_display.TITLE=\u751F\u4EA7 +kzjhbh_display.TITLE=\u63A7\u5236\u8BA1\u5212\u7F16\u53F7 +zylxrbzr_display.TITLE=\u4E3B\u8981\u8054\u7CFB\u4EBA/\u7F16\u5236\u4EBA +zylxrdhbzrdh_display.TITLE=\u4E3B\u8981\u8054\u7CFB\u4EBA\u7535\u8BDD/\u7F16\u5236\u4EBA\u7535\u8BDD +rq(bz)_display.TITLE=\u65E5\u671F\uFF08\u7F16\u5236\uFF09 +rq(xd)_display.TITLE=\u65E5\u671F\uFF08\u4FEE\u8BA2\uFF09 +SORhmmc_display.TITLE=SOR\u53F7\u7801/\u540D\u79F0 +ljhzzbb_display.TITLE=\u96F6\u4EF6\u53F7/\u6700\u7EC8\u7248\u672C +hxxz_display.TITLE=\u6838\u5FC3\u5C0F\u7EC4 +gkgcpzrq_display.TITLE=\u987E\u5BA2\u5DE5\u7A0B\u6279\u51C6/\u65E5\u671F +khtzbh_display.TITLE=\u5BA2\u6237\u56FE\u7EB8\u7F16\u53F7 +ljmcms_display.TITLE=\u96F6\u4EF6\u540D\u79F0/\u63CF\u8FF0 +gfgcpzrq_display.TITLE=\u4F9B\u65B9/\u5DE5\u5382\u6279\u51C6/\u65E5\u671F +gkzlpzrq_display.TITLE=\u987E\u5BA2\u8D28\u91CF\u6279\u51C6/\u65E5\u671F +gfgc_display.TITLE=\u4F9B\u65B9/\u5DE5\u5382 +gfdh_display.TITLE=\u4F9B\u65B9\u4EE3\u53F7 +gkpzrq_display.TITLE=\u987E\u5BA2\u6279\u51C6/\u65E5\u671F +qtpzrq_display.TITLE=\u5176\u4ED6\u6279\u51C6/\u65E5\u671F +tjh_display.TITLE=\u6DFB\u52A0\u884C +tjdh_display.TITLE=\u6DFB\u52A0\u591A\u884C +tjhbh_display.TITLE=\u6DFB\u52A0\u5408\u5E76\u884C +tjdghbh_display.TITLE=\u6DFB\u52A0\u591A\u4E2A\u5408\u5E76\u884C +tjgx_display.TITLE=\u6DFB\u52A0\u5DE5\u5E8F +hbh_display.TITLE=\u5408\u5E76\u884C +cfhbdyg_display.TITLE=\u62C6\u5206\u5408\u5E76\u5355\u5143\u683C +yczh_display.TITLE=\u79FB\u9664\u6574\u884C +sxxzl_display.TITLE=\u7F29\u5C0F\u9009\u4E2D\u5217 +qxsxxzl_display.TITLE=\u53D6\u6D88\u7F29\u5C0F\u9009\u4E2D\u5217 +txbz_display.TITLE=\u586B\u5199\u6807\u51C6 +dcnbkzjh_display.TITLE=\u5BFC\u51FA\u63A7\u5236\u8BA1\u5212 +fqsh_display.TITLE=\u53D1\u8D77\u5BA1\u6838 +kzjhk_display.TITLE=\u63A7\u5236\u8BA1\u5212\u5E93 +ck_display.TITLE=\u8BCD\u5E93 +cxjz_display.TITLE=\u91CD\u65B0\u52A0\u8F7D +qksj_display.TITLE=\u6E05\u7A7A\u6570\u636E +cjgy_display.TITLE=\u521B\u5EFA\u5DE5\u827A +xh_display.TITLE=\u578B\u53F7 +cpmc_display.TITLE=\u4EA7\u54C1\u540D\u79F0 +cxyj_display.TITLE=\u6210\u5F62\u538B\u673A +khmc_display.TITLE=\u5BA2\u6237\u540D\u79F0 +khth_display.TITLE=\u5BA2\u6237\u56FE\u53F7 +zxyj_display.TITLE=\u6574\u578B\u538B\u673A +khxmh_display.TITLE=\u5BA2\u6237\u9879\u76EE\u53F7 +clbz_display.TITLE=\u6750\u6599\u6807\u51C6 +sjry_display.TITLE=\u8BBE\u8BA1\u4EBA\u5458 +cjrq_display.TITLE=\u521B\u5EFA\u65E5\u671F +cx06_display.TITLE=\u67E5\u8BE2 +cph06_display.TITLE=\u4EA7\u54C1\u53F7 +gybh06_display.TITLE=\u5DE5\u827A\u7F16\u53F7 +mc06_display.TITLE=\u540D\u79F0 +gyfg08_display.TITLE=\u5DE5\u827A\u5206\u5DE5 +xzz08_display.TITLE=\u9009\u62E9\u503C\uFF1A +yhm08_display.TITLE=\u7528\u6237\u540D\uFF1A +ss08_display.TITLE=\u641C\u7D22 +txPFMEA10_display.TITLE=\u586B\u5199PFMEA +qzsxmsjhgfx10_display.TITLE=\u6F5C\u5728\u5931\u6548\u6A21\u5F0F\u53CA\u540E\u679C\u5206\u6790 +gsmc10_display.TITLE=\u516C\u53F8\u540D\u79F0 +xm10_display.TITLE=\u9879\u76EE +PFMEAIDbh10_display.TITLE=PFMEA ID\u7F16\u53F7 +zzdz10_display.TITLE=\u5236\u9020\u5730\u5740 +PFMEAksrq_display.TITLE=PFMEA\u5F00\u59CB\u65E5\u671F +PFMEAxdrq10_display.TITLE=PFMEA\u4FEE\u8BA2\u65E5\u671F +gczz10_display.TITLE=\u8FC7\u7A0B\u804C\u8D23 +gkmc10_display.TITLE=\u987E\u5BA2\u540D\u79F0 +bmjb10_display.TITLE=\u4FDD\u5BC6\u7EA7\u522B +cxpt10_display.TITLE=\u8F66\u578B/\u5E73\u53F0 +kzntd10_display.TITLE=\u8DE8\u804C\u80FD\u56E2\u961F +ll10_display.TITLE=PFMEA\u7ECF\u9A8C\u6570\u636E\u5E93 +wc10_display.TITLE=\u5B8C\u6210 +dcPFMEA10_display.TITLE=\u5BFC\u51FAPFMEA +PFMEAc10_display.TITLE=PFMEA\u5E93 +xztsfh10_display.TITLE=\u9009\u62E9\u7279\u6B8A\u7B26\u53F7 +cz10_display.TITLE=\u67E5\u627E +fzdh10_display.TITLE=\u590D\u5236\u591A\u884C +crhs10_display.TITLE=\u63D2\u5165\u884C\u6570 +ych12_display.TITLE=\u79FB\u9664\u884C +tjjd12_display.TITLE=\u6DFB\u52A0\u8282\u70B9 +ycjd12_display.TITLE=\u79FB\u9664\u8282\u70B9 +gxjd12_display.TITLE=\u66F4\u65B0\u8282\u70B9 +jdmc12_display.TITLE=\u8282\u70B9\u540D\u79F0 +jdID12_display.TITLE=\u8282\u70B9ID +xztsfh12_display.TITLE=\u9009\u62E9\u7279\u6B8A\u7B26\u53F7 +bzgy17_display.TITLE=\u5305\u88C5\u5DE5\u827A +cpdh17_display.TITLE=\u4EA7\u54C1\u4EE3\u53F7 +cpmc17_display.TITLE=\u4EA7\u54C1\u540D\u79F0 +yhth17_display.TITLE=\u7528\u6237\u56FE\u53F7 +chmc17_display.TITLE=\u5BA2\u6237\u540D\u79F0 +jszg17_display.TITLE=\u6280\u672F\u4E3B\u7BA1 +sjxzljtp17_display.TITLE=\u53CC\u51FB\u9009\u62E9\u96F6\u4EF6\u56FE\u7247 +bzfs17_display.TITLE=\u5305\u88C5\u65B9\u5F0F +jyfs17_display.TITLE=\u6D78\u6CB9\u65B9\u5F0F +mxsl17_display.TITLE=\u6BCF\u7BB1\u6570\u91CF +jx17_display.TITLE=\u4EF6/\u7BB1 +wzxm17_display.TITLE=\u5916\u7EB8\u7BB1\u540D +bzde17_display.TITLE=\u5305\u88C5\u5B9A\u989D +xs17_display.TITLE=\u7BB1/\u65F6 +nldm17_display.TITLE=\u5C3C\u9F99\u888B\u540D +cpdz17_display.TITLE=\u6210\u54C1\u5355\u91CD +xsm17_display.TITLE= \u5438\u5851\u540D +zxmz17_display.TITLE=\u6574\u7BB1\u6BDB\u91CD +wxbq17_display.TITLE=\u5916\u7BB1\u6807\u7B7E +rktp17_display.TITLE=\u5165\u5E93\u6258\u76D8 +xc17_display.TITLE=\u7BB1/\u5C42 +ct17_display.TITLE=\u5C42/\u6258 +sjxztp17_display.TITLE=\u53CC\u51FB\u9009\u62E9\u56FE\u7247 +bzsm17_display.TITLE=\u6B65\u9AA4\u8BF4\u660E +zysx17_display.TITLE=\u6CE8\u610F\u4E8B\u9879 +bzry17_display.TITLE=\u7F16\u5236\u4EBA\u5458 +pzry17_display.TITLE=\u6279\u51C6\u4EBA\u5458 +xgrq17_display.TITLE=\u4FEE\u6539\u65E5\u671F +bz17_display.TITLE=\u5907 \u6CE8 +ysbzlx17_display.TITLE=\u8FD0\u8F93\u5305\u88C5\u7C7B\u578B +dbfs17_display.TITLE=\u6253\u5305\u65B9\u5F0F +tpgg17_display.TITLE=\u6258\u76D8\u89C4\u683C +jgfs17_display.TITLE=\u52A0\u56FA\u65B9\u5F0F +sjxzdbt17_display.TITLE=\u53CC\u51FB\u9009\u62E9\u6253\u5305\u56FE +dybzxx17_display.TITLE=\u5355\u5143\u5305\u88C5\u4FE1\u606F +ysbzxx17_display.TITLE=\u8FD0\u8F93\u5305\u88C5\u4FE1\u606F +dh17_display.TITLE=\u4EE3\u53F7 +cckcg17_display.TITLE=\u957F*\u5BBD*\u9AD8\uFF08cm\uFF09 +hd17_display.TITLE=\u539A\u5EA6\uFF08mm\uFF09 +cl17_display.TITLE=\u6750\u6599 +gg17_display.TITLE=\u89C4\u683C +ks17_display.TITLE=\u5B54\u6570 +cp17_display.TITLE=\u4EA7\u54C1 +xgdj18_display.TITLE=\u4FEE\u6539\u7B49\u7EA7 +cxnd18_display.TITLE=\u8F66\u578B/\u5E74\u5EA6 +bz18_display.TITLE=\u6807\u6CE8 +ycbz18_display.TITLE=\u79FB\u9664\u6807\u6CE8 +kzjhdc19_display.TITLE=\u63A7\u5236\u8BA1\u5212\u5BFC\u51FA +gx19_display.TITLE=\u5DE5\u5E8F: +cx19_display.TITLE=\u67E5\u8BE2 +kzjhwjmc19_display.TITLE=\u63A7\u5236\u8BA1\u5212\u6587\u4EF6\u540D\u79F0 +drkzjh20_display.TITLE=\u5BFC\u5165\u63A7\u5236\u8BA1\u5212 +xzkzjhwj20_display.TITLE=\u9009\u62E9\u63A7\u5236\u8BA1\u5212\u6587\u4EF6 +qcwcbj21_display.TITLE=\u6E05\u9664\u5B8C\u6210\u6807\u8BB0 +xzgytz23_display.TITLE=\u9009\u62E9\u5DE5\u827A\u56FE\u7EB8 +gytz23_display.TITLE=\u5DE5\u827A\u56FE\u7EB8\uFF1A +xz24_display.TITLE=\u9009\u62E9 +kzjh24_display.TITLE=\u63A7\u5236\u8BA1\u5212 +yqrq25_display.TITLE=\u903E\u671F\u65E5\u671F +PDMEAtj25_display.TITLE=PFMEA\u7EDF\u8BA1 +dcbb25_display.TITLE=\u5BFC\u51FA\u62A5\u8868 +gb25_display.TITLE=\u5173\u95ED +jcfxwtd27_display.TITLE=\u68C0\u6D4B\u5206\u6790\u59D4\u6258\u5355 +wtdbh27_display.TITLE=\u59D4\u6258\u5355\u7F16\u53F7\uFF1A +jclx27_display.TITLE=\u68C0\u6D4B\u7C7B\u578B +jcbm27_display.TITLE=\u68C0\u6D4B\u90E8\u95E8 +wtdw27_display.TITLE=\u59D4\u6258\u5355\u4F4D +wtr27_display.TITLE=\u59D4\u6258\u4EBA +wtdz27_display.TITLE=\u59D4\u6258\u5730\u5740 +wtrlxfs27_display.TITLE=\u59D4\u6258\u4EBA\u8054\u7CFB\u65B9\u5F0F +wtrq27_display.TITLE=\u59D4\u6258\u65E5\u671F +xwwcsj27_display.TITLE=\u5E0C\u671B\u5B8C\u6210\u65F6\u95F4 +jcyt27_display.TITLE=\u68C0\u6D4B\u7528\u9014 +jcjg27_display.TITLE=\u68C0\u6D4B\u7ED3\u679C +xmdj27_display.TITLE=\u9879\u76EE\u7B49\u7EA7 +khdj27_display.TITLE=\u5BA2\u6237\u7B49\u7EA7 +xmbh27_display.TITLE=\u9879\u76EE\u7F16\u53F7 +yyly27_display.TITLE=\u5E94\u7528\u9886\u57DF +xmmc27_display.TITLE=\u9879\u76EE\u540D\u79F0 +cph27_display.TITLE=\u4EA7\u54C1\u53F7 +wlh27_display.TITLE=\u7269\u6599\u53F7 +cplx27_display.TITLE=\u4EA7\u54C1\u7C7B\u578B +scdw27_display.TITLE=\u751F\u4EA7\u5355\u4F4D +ypsl27_display.TITLE=\u6837\u54C1\u6570\u91CF +ypzt27_display.TITLE=\u6837\u54C1\u72B6\u6001 +wldh27_display.TITLE=\u7269\u6D41\u5355\u53F7 +ypbh27_display.TITLE=\u6837\u54C1\u7F16\u53F7 +ypclfs27_display.TITLE=\u6837\u54C1\u5904\u7406\u65B9\u5F0F +sybw27_display.TITLE=\u4F7F\u7528\u90E8\u4F4D +syhj27_display.TITLE=\u4F7F\u7528\u73AF\u5883 +gzzh27_display.TITLE=\u5DE5\u4F5C\u8F7D\u8377 +zhlx27_display.TITLE=\u8F7D\u8377\u7C7B\u578B +xzfs27_display.TITLE=\u65CB\u8F6C\u65B9\u5F0F +xzsd27_display.TITLE=\u65CB\u8F6C\u901F\u5EA6 +gzwd27_display.TITLE=\u5DE5\u4F5C\u6E29\u5EA6 +xzwtnr27_display.TITLE=\u9009\u62E9\u59D4\u6258\u5185\u5BB9 +bz27_display.TITLE=\u5907\u6CE8 +ypydxc27_display.TITLE=\u6837\u54C1\u5DF2\u5230\u8FBE\u73B0\u573A +sysj27_display.TITLE=\u6536\u6837\u65F6\u95F4 +syr27_display.TITLE=\u6536\u6837\u4EBA +ypshjg27_display.TITLE=\u6837\u54C1\u5BA1\u6838\u7ED3\u679C +yqwcsj27_display.TITLE=\u9884\u671F\u5B8C\u6210\u65F6\u95F4 +thyy27_display.TITLE=\u9000\u56DE\u539F\u56E0 +jcrwzb27_display.TITLE=\u68C0\u6D4B\u4EFB\u52A1\u4E3B\u529E +jcrwxb27_display.TITLE=\u68C0\u6D4B\u4EFB\u52A1\u534F\u529E +jhkssj27_display.TITLE=\u8BA1\u5212\u5F00\u59CB\u65F6\u95F4 +jhwcsj27_display.TITLE=\u8BA1\u5212\u5B8C\u6210\u65F6\u95F4 +djdywtd27_display.TITLE=\u70B9\u51FB\u6253\u5370\u59D4\u6258\u5355 +djdyypbs27_display.TITLE=\u70B9\u51FB\u6253\u5370\u6837\u54C1\u6807\u8BC6 +sjwcsj27_display.TITLE=\u5B9E\u9645\u5B8C\u6210\u65F6\u95F4 +jcjgsm27_display.TITLE=\u68C0\u6D4B\u7ED3\u679C\u8BF4\u660E +ypcz27_display.TITLE=\u6837\u54C1\u5904\u7F6E +cywz27_display.TITLE=\u5B58\u6837\u4F4D\u7F6E +shsj27_display.TITLE=\u5BA1\u6838\u65F6\u95F4 +shy27_display.TITLE=\u5BA1\u6838\u5458 +shjg27_display.TITLE=\u5BA1\u6838\u7ED3\u679C +wtxx27_display.TITLE=\u59D4\u6258\u4FE1\u606F +clfx27_display.TITLE=\u6750\u6599\u5206\u6790 +jljc27_display.TITLE=\u8BA1\u91CF\u68C0\u6D4B +wtnr27_display.TITLE=\u59D4\u6258\u5185\u5BB9 +zygyk28_display.TITLE=\u4F5C\u4E1A\u5DE5\u827A\u5361 +gsmc28_display.TITLE=\u516C\u53F8\u540D\u79F0 +ljdh28_display.TITLE=\u96F6\u4EF6\u4EE3\u53F7 +sbxh28_display.TITLE=\u4EA7\u54C1\u540D\u79F0 +bgx28_display.TITLE=\u672C\u5DE5\u5E8F +sbmc28_display.TITLE=\u8BBE\u5907\u540D\u79F0 +gzmx28_display.TITLE=\u5DE5\u88C5\u660E\u7EC6 +jgcs28_display.TITLE=\u52A0\u5DE5\u53C2\u6570 +cptxkzyq28_display.TITLE=\u4EA7\u54C1\u7279\u6027\u63A7\u5236\u8981\u6C42 +zpgyk29_display.TITLE=\u88C5\u914D\u5DE5\u827A\u5361 +gsmc29_display.TITLE=\u516C\u53F8\u540D\u79F0 +ljdh29_display.TITLE=\u96F6\u4EF6\u4EE3\u53F7 +sbxh29_display.TITLE=\u8BBE\u5907\u578B\u53F7 +zyjzs30_display.TITLE=\u4F5C\u4E1A\u57FA\u51C6\u4E66 +xzdclj31_display.TITLE=\u9009\u62E9\u5BFC\u51FA\u8DEF\u5F84 +wjmc31_display.TITLE=\u6587\u4EF6\u540D\u79F0 +jyjzs33_display.TITLE=\u68C0\u9A8C\u57FA\u51C6\u4E66 +bzbz34_display.TITLE=\u5305\u88C5\u6807\u51C6 +ljh34_display.TITLE=\u96F6\u4EF6\u53F7 +ljmc34_display.TITLE=\u96F6\u4EF6\u540D\u79F0 +gys34_display.TITLE=\u4F9B\u5E94\u5546 +gysdh34_display.TITLE=\u4F9B\u5E94\u5546\u4EE3\u53F7 +syzcdmmc34_display.TITLE=\u9002\u7528\u603B\u6210\u4EE3\u7801/\u540D\u79F0 +ljdw(tg)34_display.TITLE=\u96F6\u4EF6\u5355\u4F4D\uFF08\u5957/\u4E2A\uFF09 +ljgg34_display.TITLE=\u96F6\u4EF6\u89C4\u683C\uFF08mm\uFF09 +ljzl34_display.TITLE=\u96F6\u4EF6\u91CD\u91CF\uFF08kg\uFF09 +bzbzclfhdjyms34_display.TITLE=\u5305\u88C5\u3001\u5305\u88C5\u6750\u6599\u3001\u9632\u62A4\u7B49\u7B80\u8981\u63CF\u8FF0 +bqgshwz34_display.TITLE=\u6807\u7B7E\u683C\u5F0F\u548C\u4F4D\u7F6E +zt35_display.TITLE=\u72B6\u6001 +wtdsh35_display.TITLE=\u59D4\u6258\u5355\u5BA1\u6838 +gzfp35_display.TITLE=\u5DE5\u4F5C\u5206\u914D +scjl35_display.TITLE=\u4E0A\u4F20\u8BB0\u5F55 +wtrq35_display.TITLE=\u59D4\u6258\u65E5\u671F +wtdh35_display.TITLE=\u59D4\u6258\u5355\u53F7 +wtdw35_display.TITLE=\u59D4\u6258\u5355\u4F4D +jclx35_display.TITLE=\u68C0\u6D4B\u7C7B\u578B +xmdj35_display.TITLE=\u9879\u76EE\u7B49\u7EA7 +ycwcrq35_display.TITLE=\u9884\u671F\u5B8C\u6210\u65E5\u671F +jhwcrq35_display.TITLE=\u8BA1\u5212\u5B8C\u6210\u65E5\u671F +zbry35_display.TITLE=\u4E3B\u529E\u4EBA\u5458 +lcjs35_display.TITLE=\u6D41\u7A0B\u76D1\u89C6 +dqzt35_display.TITLE=\u5F53\u524D\u72B6\u6001 +wtdhypsh35_display.TITLE=\u59D4\u6258\u5355\u548C\u6837\u54C1\u5BA1\u6838 +gzfp35_display.TITLE=\u5DE5\u4F5C\u5206\u914D +scjg35_display.TITLE=\u4E0A\u4F20\u7ED3\u679C +sywtd41_display.TITLE=\u8BD5\u9A8C\u59D4\u6258\u5355 +wtdbh41_display.TITLE=\u59D4\u6258\u5355\u7F16\u53F7\uFF1A +scdw41_display.TITLE=\u751F\u4EA7\u5355\u4F4D +ccxh41_display.TITLE=\u8F74\u627F\u578B\u53F7 +sych41_display.TITLE=\u4F7F\u7528\u573A\u5408 +xmmc41_display.TITLE=\u9879\u76EE\u540D\u79F0 +xmbh41_display.TITLE=\u9879\u76EE\u7F16\u53F7 +xmdj41_display.TITLE=\u9879\u76EE\u7B49\u7EA7 +wtsylx41_display.TITLE=\u59D4\u6258\u8BD5\u9A8C\u7C7B\u578B +yzsy41_display.TITLE=\u9A8C\u8BC1\u8BD5\u9A8C +tzxxsy41_display.TITLE=\u7279\u79CD\u65B0\u578B\u8BD5\u9A8C +khyq41_display.TITLE=\u5BA2\u6237\u8981\u6C42 +sybj41_display.TITLE=\u8BD5\u9A8C\u80CC\u666F +symd41_display.TITLE=\u8BD5\u9A8C\u76EE\u7684 +sygfsjry41_display.TITLE=\u8BD5\u9A8C\u89C4\u8303\uFF08\u8BBE\u8BA1\u4EBA\u5458\uFF09 +yjgsyry41_display.TITLE=\u5DF2\u4EA4\u7ED9\u8BD5\u9A8C\u4EBA\u5458 +qtsyyq41_display.TITLE=\u5176\u4ED6\u8BD5\u9A8C\u8981\u6C42 +wtr41_display.TITLE=\u59D4\u6258\u4EBA +lxfs41_display.TITLE=\u8054\u7CFB\u65B9\u5F0F +gsdz41_display.TITLE=\u516C\u53F8\u5730\u5740 +gscz41_display.TITLE=\u516C\u53F8\u4F20\u771F +shr41_display.TITLE=\u5BA1\u6838\u4EBA +shrq41_display.TITLE=\u5BA1\u6838\u65E5\u671F +zjlpz41_display.TITLE=\u603B\u7ECF\u7406\u6279\u51C6 +sywtftx41_display.TITLE=\u8BD5\u9A8C\u59D4\u6258\u65B9\u586B\u5199 +psjl41_display.TITLE=\u8BC4\u5BA1\u8BB0\u5F55 +jhkssj41_display.TITLE=\u8BA1\u5212\u5F00\u59CB\u65F6\u95F4 +jhjssj41_display.TITLE=\u8BA1\u5212\u7ED3\u675F\u65F6\u95F4 +syfzr41_display.TITLE=\u8BD5\u9A8C\u8D1F\u8D23\u4EBA +lxdh41_display.TITLE=\u8054\u7CFB\u7535\u8BDD +psrq41_display.TITLE=\u8BC4\u5BA1/\u65E5\u671F +pzrq41_display.TITLE=\u6279\u51C6/\u65E5\u671F +swtftx41_display.TITLE=\u53D7\u59D4\u6258\u65B9\u586B\u5199 +bz41_display.TITLE=\u5907\u6CE8 +gzsjtd41_display.TITLE=\u5DE5\u88C5\u8BBE\u8BA1\u56E2\u961F +xzscgztz41_display.TITLE=\u9009\u62E9\u4E0A\u4F20\u5DE5\u88C5\u56FE\u7EB8 +qxzyscdwj41_display.TITLE=\u8BF7\u9009\u62E9\u8981\u4E0A\u4F20\u7684\u6587\u4EF6... +qd41_display.TITLE=\u786E\u5B9A +gzsjwcrq141_display.TITLE=\u5DE5\u88C5\u8BBE\u8BA1\u5B8C\u6210\u65E5\u671F +gzsj141_display.TITLE=\u5DE5\u88C5\u8BBE\u8BA1 +gzdhrq41_display.TITLE=\u5DE5\u88C5\u5230\u8D27\u65E5\u671F +gzsjrq41_display.TITLE=\u5DE5\u88C5\u9001\u68C0\u65E5\u671F +gzsjwcrq41_display.TITLE=\u5DE5\u88C5\u9001\u68C0\u5B8C\u6210\u65E5\u671F +gzjcbgbh41_display.TITLE=\u5DE5\u88C5\u68C0\u6D4B\u62A5\u544A\uFF08\u8BB0\u5F55\uFF09\u7F16\u53F7 +gzsj41_display.TITLE=\u5DE5\u88C5\u9001\u68C0 +ypdyrq41_display.TITLE=\u6837\u54C1\u5230\u6837\u65E5\u671F +syqypjcwcrq41_display.TITLE=\u8BD5\u9A8C\u524D\u6837\u54C1\u68C0\u6D4B\u5B8C\u6210\u65E5\u671F +syqypjcbgbh41_display.TITLE=\u8BD5\u9A8C\u524D\u6837\u54C1\u68C0\u6D4B\u62A5\u544A\uFF08\u8BB0\u5F55\uFF09\u7F16\u53F7 +syksrq41_display.TITLE=\u8BD5\u9A8C\u5F00\u59CB\u65E5\u671F +sywcrq41_display.TITLE=\u8BD5\u9A8C\u5B8C\u6210\u65E5\u671F +syss41_display.TITLE=\u8BD5\u9A8C\u5B9E\u65BD +syhypjcwcrq41_display.TITLE=\u8BD5\u9A8C\u540E\u6837\u54C1\u68C0\u6D4B\u5B8C\u6210\u65E5\u671F +syhypjcbg41_display.TITLE=\u8BD5\u9A8C\u540E\u6837\u54C1\u68C0\u6D4B\u62A5\u544A\uFF08\u8BB0\u5F55\uFF09\u7F16\u53F7 +ypjc41_display.TITLE=\u6837\u54C1\u68C0\u6D4B +xzscsybg41_display.TITLE=\u9009\u62E9\u4E0A\u4F20\u8BD5\u9A8C\u62A5\u544A +sywcrq241_display.TITLE=\u8BD5\u9A8C\u5B8C\u6210\u65E5\u671F +sybgbh41_display.TITLE=\u8BD5\u9A8C\u62A5\u544A\u7F16\u53F7 +sybg241_display.TITLE=\u8BD5\u9A8C\u62A5\u544A +sywtd241_display.TITLE=\u8BD5\u9A8C\u59D4\u6258\u5355 +sykxljap41_display.TITLE=\u8BD5\u9A8C\u53EF\u884C\uFF0C\u7ACB\u5373\u5B89\u6392 +sybkx41_display.TITLE=\u8BD5\u9A8C\u4E0D\u53EF\u884C +zybcfjywwsy41_display.TITLE=\u8D44\u6E90\u4E0D\u5145\u5206\uFF0C\u5EFA\u8BAE\u59D4\u5916\u8BD5\u9A8C +qijy241_display.TITLE=\u5176\u4ED6\u5EFA\u8BAE +btxxbnwk41_display.TITLE=\u5FC5\u586B\u9879\u4E0D\u80FD\u4E3A\u7A7A\uFF01 +gzcg41_display.TITLE=\u5DE5\u88C5\u91C7\u8D2D +xqsp41_display.TITLE=\u9700\u6C42\u5BA1\u6279 + + + +fxwtd40_display.TITLE=\u5206\u6790\u59D4\u6258\u5355 +CEAwtd40_display.TITLE=CAE\u59D4\u6258\u5355 +wtdbh40_display.TITLE=\u59D4\u6258\u5355\u7F16\u53F7\uFF1A +kemc40_display.TITLE=\u5BA2\u6237\u540D\u79F0 +xmsstd40_display.TITLE=\u9879\u76EE\u6240\u5C5E\u56E2\u961F +xmmc40_display.TITLE=\u9879\u76EE\u540D\u79F0 +xmjl40_display.TITLE=\u9879\u76EE\u7ECF\u7406 +xmdj40_display.TITLE=\u9879\u76EE\u7B49\u7EA7 +sjbsstd40_display.TITLE=\u8BBE\u8BA1\u90E8\u6240\u5C5E\u56E2\u961F +xmbh40_display.TITLE=\u9879\u76EE\u7F16\u53F7 +sjfzr40_display.TITLE=\u8BBE\u8BA1\u8D1F\u8D23\u4EBA +xmlx40_display.TITLE=\u9879\u76EE\u7C7B\u578B +qwwcsj40_display.TITLE=\u671F\u671B\u5B8C\u6210\u65F6\u95F4 +jbxx40_display.TITLE=1.\u57FA\u672C\u4FE1\u606F +scfxry40_display.TITLE=\u4E0A\u6B21\u5206\u6790\u4EBA\u5458 +scbgsj40_display.TITLE=\u4E0A\u6B21\u62A5\u544A\u65F6\u95F4 +ggd40_display.TITLE=\u66F4\u6539\u70B9 +ggyy40_display.TITLE=\u66F4\u6539\u539F\u56E0 +srzl40_display.TITLE=2.\u8F93\u5165\u8D44\u6599 +cjtd40_display.TITLE=\u627F\u63A5\u56E2\u961F +xmwtsj40_display.TITLE=\u9879\u76EE\u59D4\u6258\u65F6\u95F4 +cjr40_display.TITLE=\u627F\u63A5\u4EBA +xmggcs40_display.TITLE=\u9879\u76EE\u66F4\u6539\u6B21\u6570 +xbr40_display.TITLE=\u534F\u529E\u4EBA +jhkssj40_display.TITLE=\u8BA1\u5212\u5F00\u59CB\u65F6\u95F4 +Romaxjf40_display.TITLE=Romax\u79EF\u5206 +jsxqts40_display.TITLE=\u8BA1\u7B97\u9700\u6C42\u5929\u6570 +yxyjf40_display.TITLE=\u6709\u9650\u5143\u79EF\u5206 +jswcsj40_display.TITLE=\u8BA1\u7B97\u5B8C\u6210\u65F6\u95F4 +xmcjxx40_display.TITLE=3.\u9879\u76EE\u627F\u63A5\u4FE1\u606F +bghjgmc40_display.TITLE=\u62A5\u544A\u6216\u7ED3\u679C\u540D\u79F0 +bgbh40_display.TITLE=\u62A5\u544A\u7F16\u53F7 +bghjgscsj40_display.TITLE=\u62A5\u544A\u6216\u7ED3\u679C\u4E0A\u4F20\u65F6\u95F4 +bghjgfk40_display.TITLE=4.\u62A5\u544A\u6216\u7ED3\u679C\u53CD\u9988 +jdr40_display.TITLE=\u6821\u5BF9\u4EBA +jdsj40_display.TITLE=\u6821\u5BF9\u65F6\u95F4 +jdjg40_display.TITLE=\u6821\u5BF9\u7ED3\u679C +thyy40_display.TITLE=\u9000\u56DE\u539F\u56E0 +bghjgjd40_display.TITLE=5.\u62A5\u544A\u6216\u7ED3\u679C\u6821\u5BF9 +khmc40_display.TITLE=\u5BA2\u6237\u540D\u79F0 +xmbssty40_display.TITLE=\u9879\u76EE\u90E8\u6240\u5C5E\u56E2\u961F +sybw40_display.TITLE=\u4F7F\u7528\u90E8\u4F4D +srzl40_display.TITLE=2.\u8F93\u5165\u8D44\u6599 +bxqrbgxxx40_display.TITLE=\u5FC5\u987B\u786E\u8BA4\u5E76\u52FE\u9009\u4FE1\u606F +jsscxm40_display.TITLE=\u8BA1\u7B97\u8F93\u51FA\u9879\u76EE +kgxxx40_display.TITLE=\u53EF\u52FE\u9009\u4FE1\u606F +ydndqjddjgzwd40_display.TITLE=\u8FD0\u52A8\u7C98\u5EA6\u3001\u6E05\u6D01\u5EA6\u7B49\u7EA7\u3001\u5DE5\u4F5C\u6E29\u5EA6 +EPtjj40_display.TITLE=EP\u6DFB\u52A0\u5242 +ysr40_display.TITLE=\u9884\u5BA1\u4EBA +yssj40_display.TITLE=\u9884\u5BA1\u65F6\u95F4 +ysjg40_display.TITLE=\u9884\u5BA1\u7ED3\u679C +zbdzys40_display.TITLE=1.\u503C\u73ED\u56E2\u961F\u957F\u9884\u5BA1 +wtdbh240_display.TITLE=\u59D4\u6258\u5355\u7F16\u53F7 +jhwcsj40_display.TITLE=\u8BA1\u5212\u5B8C\u6210\u65F6\u95F4 +xmcjxx240_display.TITLE=2.\u9879\u76EE\u627F\u63A5\u4FE1\u606F +jsfxjm40_display.TITLE=\u8BA1\u7B97\u5206\u6790\u5EFA\u6A21 +bczlsj40_display.TITLE=\u8865\u5145\u8D44\u6599\u65F6\u95F4 +zyss40_display.TITLE=3.\u4F5C\u4E1A\u5B9E\u65BD +bghjgfk240_display.TITLE=4.\u62A5\u544A\u6216\u7ED3\u679C\u53CD\u9988 +bghjgjd240_display.TITLE=5.\u62A5\u544A\u6216\u7ED3\u679C\u6821\u5BF9 +CAEfxxqwtd40_display.TITLE=CAE\u5206\u6790\u9700\u6C42\u59D4\u6258\u5355 +jsfxtdcjd40_display.TITLE=\u8BA1\u7B97\u5206\u6790\u56E2\u961F\u627F\u63A5\u5355 +ggxmwtd40_display.TITLE=\u66F4\u6539\u9879\u76EE\u59D4\u6258\u5355 +tk_display.TITLE=\u56FE\u5E93 + + +ljgybh04_display.TITLE=\u96F6\u4EF6/\u5DE5\u827A\u7F16\u53F7 +gcmc04_display.TITLE=\u8FC7\u7A0B\u540D\u79F0 +jqsbgzjj04_display.TITLE=\u673A\u5668,\u8BBE\u5907,\u5DE5\u88C5\uFF0C\u5939\u5177 +smjyzyzb04_display.TITLE=\u9996\u672B\u68C0\u9A8C/\u4F5C\u4E1A\u51C6\u5907 +bh04_display.TITLE=\u7F16\u53F7 +cp04_display.TITLE=\u4EA7\u54C1 +gc04_display.TITLE=\u8FC7\u7A0B +tstxfl04_display.TITLE=\u7279\u6B8A\u7279\u6027\u5206\u7C7B +cpgcgfgc04_display.TITLE=\u4EA7\u54C1/\u8FC7\u7A0B/\u89C4\u683C/\u516C\u5DEE +pgclff04_display.TITLE=\u8BC4\u4F30/\u6D4B\u91CF\u65B9\u6CD5 +rl04_display.TITLE=\u5BB9\u91CF +pl04_display.TITLE=\u9891\u7387 +kzff04_display.TITLE=\u63A7\u5236\u65B9\u6CD5 +fyjh04_display.TITLE=\u53CD\u5E94\u8BA1\u5212 +tsfhwz04_display.TITLE=\u7279\u6B8A\u7B26\u53F7\u4F4D\u7F6E +sfwc04_display.TITLE=\u662F\u5426\u5B8C\u6210 +fjdID04_display.TITLE=\u7236\u8282\u70B9ID +tszfszwz04_display.TITLE=\u7279\u6B8A\u5B57\u7B26\u6240\u5728\u4F4D\u7F6E +xh04_display.TITLE=\u5E8F\u53F7 +z04_display.TITLE=\u503C +mc04_display.TITLE=\u540D\u79F0 +gysjfdygc34_display.TITLE=\u4F9B\u5E94\u5546\u4EA4\u4ED8\u5355\u5143\u6784\u6210 +yjbz34_display.TITLE=\u4E00\u7EA7\u5305\u88C5 +ejbz34_display.TITLE=\u4E8C\u7EA7\u5305\u88C5 +sjbz34_display.TITLE=\u4E09\u7EA7\u5305\u88C5 + + + +wxzcpdxqcxxz02_display.TITLE=\u672A\u9009\u4E2D\u4EA7\u54C1\u5BF9\u8C61\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\uFF01 +qxzzcdxhcj02_display.TITLE=\u8BF7\u9009\u62E9\u603B\u6210\u5BF9\u8C61\u540E\u521B\u5EFA +gy02_display.TITLE=\u5DE5\u827A +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= \ No newline at end of file diff --git a/bin/com/connor/renben/process/plm/util/Adapter.class b/bin/com/connor/renben/process/plm/util/Adapter.class new file mode 100644 index 0000000..a057629 Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/Adapter.class differ diff --git a/bin/com/connor/renben/process/plm/util/Adapter1.class b/bin/com/connor/renben/process/plm/util/Adapter1.class new file mode 100644 index 0000000..3964abd Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/Adapter1.class differ diff --git a/bin/com/connor/renben/process/plm/util/AutoCompleter.class b/bin/com/connor/renben/process/plm/util/AutoCompleter.class new file mode 100644 index 0000000..bae28e6 Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/AutoCompleter.class differ diff --git a/bin/com/connor/renben/process/plm/util/CTMap.class b/bin/com/connor/renben/process/plm/util/CTMap.class new file mode 100644 index 0000000..0833c9d Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/CTMap.class differ diff --git a/bin/com/connor/renben/process/plm/util/CTMap2.class b/bin/com/connor/renben/process/plm/util/CTMap2.class new file mode 100644 index 0000000..f066578 Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/CTMap2.class differ diff --git a/bin/com/connor/renben/process/plm/util/CTUI.class b/bin/com/connor/renben/process/plm/util/CTUI.class new file mode 100644 index 0000000..6b1fe6d Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/CTUI.class differ diff --git a/bin/com/connor/renben/process/plm/util/CTable.class b/bin/com/connor/renben/process/plm/util/CTable.class new file mode 100644 index 0000000..17d8a9f Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/CTable.class differ diff --git a/bin/com/connor/renben/process/plm/util/CTextField.class b/bin/com/connor/renben/process/plm/util/CTextField.class new file mode 100644 index 0000000..db64f95 Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/CTextField.class differ diff --git a/bin/com/connor/renben/process/plm/util/CTextFieldButton$1.class b/bin/com/connor/renben/process/plm/util/CTextFieldButton$1.class new file mode 100644 index 0000000..a249422 Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/CTextFieldButton$1.class differ diff --git a/bin/com/connor/renben/process/plm/util/CTextFieldButton$2.class b/bin/com/connor/renben/process/plm/util/CTextFieldButton$2.class new file mode 100644 index 0000000..d6290f9 Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/CTextFieldButton$2.class differ diff --git a/bin/com/connor/renben/process/plm/util/CTextFieldButton.class b/bin/com/connor/renben/process/plm/util/CTextFieldButton.class new file mode 100644 index 0000000..6981ce1 Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/CTextFieldButton.class differ diff --git a/bin/com/connor/renben/process/plm/util/CellSpan.class b/bin/com/connor/renben/process/plm/util/CellSpan.class new file mode 100644 index 0000000..3e32c9b Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/CellSpan.class differ diff --git a/bin/com/connor/renben/process/plm/util/ChangeCharset.class b/bin/com/connor/renben/process/plm/util/ChangeCharset.class new file mode 100644 index 0000000..ac50e0b Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/ChangeCharset.class differ diff --git a/bin/com/connor/renben/process/plm/util/CheckBoxCellEditor$1.class b/bin/com/connor/renben/process/plm/util/CheckBoxCellEditor$1.class new file mode 100644 index 0000000..c84520f Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/CheckBoxCellEditor$1.class differ diff --git a/bin/com/connor/renben/process/plm/util/CheckBoxCellEditor$2.class b/bin/com/connor/renben/process/plm/util/CheckBoxCellEditor$2.class new file mode 100644 index 0000000..ab0b6eb Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/CheckBoxCellEditor$2.class differ diff --git a/bin/com/connor/renben/process/plm/util/CheckBoxCellEditor.class b/bin/com/connor/renben/process/plm/util/CheckBoxCellEditor.class new file mode 100644 index 0000000..e5b27d7 Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/CheckBoxCellEditor.class differ diff --git a/bin/com/connor/renben/process/plm/util/CheckListCellRenderer.class b/bin/com/connor/renben/process/plm/util/CheckListCellRenderer.class new file mode 100644 index 0000000..bd56801 Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/CheckListCellRenderer.class differ diff --git a/bin/com/connor/renben/process/plm/util/CheckValue.class b/bin/com/connor/renben/process/plm/util/CheckValue.class new file mode 100644 index 0000000..c9229fe Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/CheckValue.class differ diff --git a/bin/com/connor/renben/process/plm/util/CollectControlPlan.class b/bin/com/connor/renben/process/plm/util/CollectControlPlan.class new file mode 100644 index 0000000..294a3c4 Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/CollectControlPlan.class differ diff --git a/bin/com/connor/renben/process/plm/util/CollectPfmea.class b/bin/com/connor/renben/process/plm/util/CollectPfmea.class new file mode 100644 index 0000000..062f52e Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/CollectPfmea.class differ diff --git a/bin/com/connor/renben/process/plm/util/ComboBoxCellEditor$1.class b/bin/com/connor/renben/process/plm/util/ComboBoxCellEditor$1.class new file mode 100644 index 0000000..3818c93 Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/ComboBoxCellEditor$1.class differ diff --git a/bin/com/connor/renben/process/plm/util/ComboBoxCellEditor.class b/bin/com/connor/renben/process/plm/util/ComboBoxCellEditor.class new file mode 100644 index 0000000..d0fb309 Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/ComboBoxCellEditor.class differ diff --git a/bin/com/connor/renben/process/plm/util/CreateItemHandler.class b/bin/com/connor/renben/process/plm/util/CreateItemHandler.class new file mode 100644 index 0000000..690af01 Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/CreateItemHandler.class differ diff --git a/bin/com/connor/renben/process/plm/util/CreateNewBOHandler$CreateNewBOSWTDialog.class b/bin/com/connor/renben/process/plm/util/CreateNewBOHandler$CreateNewBOSWTDialog.class new file mode 100644 index 0000000..a40972c Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/CreateNewBOHandler$CreateNewBOSWTDialog.class differ diff --git a/bin/com/connor/renben/process/plm/util/CreateNewBOHandler.class b/bin/com/connor/renben/process/plm/util/CreateNewBOHandler.class new file mode 100644 index 0000000..5ecc867 Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/CreateNewBOHandler.class differ diff --git a/bin/com/connor/renben/process/plm/util/DraggableTabbedPane$1.class b/bin/com/connor/renben/process/plm/util/DraggableTabbedPane$1.class new file mode 100644 index 0000000..7b2befe Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/DraggableTabbedPane$1.class differ diff --git a/bin/com/connor/renben/process/plm/util/DraggableTabbedPane$2.class b/bin/com/connor/renben/process/plm/util/DraggableTabbedPane$2.class new file mode 100644 index 0000000..295aa1f Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/DraggableTabbedPane$2.class differ diff --git a/bin/com/connor/renben/process/plm/util/DraggableTabbedPane.class b/bin/com/connor/renben/process/plm/util/DraggableTabbedPane.class new file mode 100644 index 0000000..39cf304 Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/DraggableTabbedPane.class differ diff --git a/bin/com/connor/renben/process/plm/util/ExcelFilter.class b/bin/com/connor/renben/process/plm/util/ExcelFilter.class new file mode 100644 index 0000000..d5d155b Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/ExcelFilter.class differ diff --git a/bin/com/connor/renben/process/plm/util/ExcelUtil.class b/bin/com/connor/renben/process/plm/util/ExcelUtil.class new file mode 100644 index 0000000..ea7fdcf Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/ExcelUtil.class differ diff --git a/bin/com/connor/renben/process/plm/util/ExcelUtil07.class b/bin/com/connor/renben/process/plm/util/ExcelUtil07.class new file mode 100644 index 0000000..c91e9b3 Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/ExcelUtil07.class differ diff --git a/bin/com/connor/renben/process/plm/util/ImageFilter.class b/bin/com/connor/renben/process/plm/util/ImageFilter.class new file mode 100644 index 0000000..6caef47 Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/ImageFilter.class differ diff --git a/bin/com/connor/renben/process/plm/util/JAutoCompleteComboBox.class b/bin/com/connor/renben/process/plm/util/JAutoCompleteComboBox.class new file mode 100644 index 0000000..f533c45 Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/JAutoCompleteComboBox.class differ diff --git a/bin/com/connor/renben/process/plm/util/MultiComboBox$EditorHandler.class b/bin/com/connor/renben/process/plm/util/MultiComboBox$EditorHandler.class new file mode 100644 index 0000000..33e6158 Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/MultiComboBox$EditorHandler.class differ diff --git a/bin/com/connor/renben/process/plm/util/MultiComboBox$MulitComboboxLayout.class b/bin/com/connor/renben/process/plm/util/MultiComboBox$MulitComboboxLayout.class new file mode 100644 index 0000000..8438bf6 Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/MultiComboBox$MulitComboboxLayout.class differ diff --git a/bin/com/connor/renben/process/plm/util/MultiComboBox$PopupAction.class b/bin/com/connor/renben/process/plm/util/MultiComboBox$PopupAction.class new file mode 100644 index 0000000..c0697a1 Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/MultiComboBox$PopupAction.class differ diff --git a/bin/com/connor/renben/process/plm/util/MultiComboBox.class b/bin/com/connor/renben/process/plm/util/MultiComboBox.class new file mode 100644 index 0000000..d5f1a96 Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/MultiComboBox.class differ diff --git a/bin/com/connor/renben/process/plm/util/MultiPopup$1.class b/bin/com/connor/renben/process/plm/util/MultiPopup$1.class new file mode 100644 index 0000000..ba930b0 Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/MultiPopup$1.class differ diff --git a/bin/com/connor/renben/process/plm/util/MultiPopup$2.class b/bin/com/connor/renben/process/plm/util/MultiPopup$2.class new file mode 100644 index 0000000..dfd479a Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/MultiPopup$2.class differ diff --git a/bin/com/connor/renben/process/plm/util/MultiPopup$3.class b/bin/com/connor/renben/process/plm/util/MultiPopup$3.class new file mode 100644 index 0000000..dc3f07d Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/MultiPopup$3.class differ diff --git a/bin/com/connor/renben/process/plm/util/MultiPopup.class b/bin/com/connor/renben/process/plm/util/MultiPopup.class new file mode 100644 index 0000000..8c48c03 Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/MultiPopup.class differ diff --git a/bin/com/connor/renben/process/plm/util/MyComboBox$1.class b/bin/com/connor/renben/process/plm/util/MyComboBox$1.class new file mode 100644 index 0000000..b7ced6d Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/MyComboBox$1.class differ diff --git a/bin/com/connor/renben/process/plm/util/MyComboBox$2.class b/bin/com/connor/renben/process/plm/util/MyComboBox$2.class new file mode 100644 index 0000000..259d9e7 Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/MyComboBox$2.class differ diff --git a/bin/com/connor/renben/process/plm/util/MyComboBox.class b/bin/com/connor/renben/process/plm/util/MyComboBox.class new file mode 100644 index 0000000..35d1ccf Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/MyComboBox.class differ diff --git a/bin/com/connor/renben/process/plm/util/MyTableModel.class b/bin/com/connor/renben/process/plm/util/MyTableModel.class new file mode 100644 index 0000000..81d188f Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/MyTableModel.class differ diff --git a/bin/com/connor/renben/process/plm/util/PosParamCellEditor.class b/bin/com/connor/renben/process/plm/util/PosParamCellEditor.class new file mode 100644 index 0000000..1c6a998 Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/PosParamCellEditor.class differ diff --git a/bin/com/connor/renben/process/plm/util/ProgressBar$TaskThread.class b/bin/com/connor/renben/process/plm/util/ProgressBar$TaskThread.class new file mode 100644 index 0000000..f5787e2 Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/ProgressBar$TaskThread.class differ diff --git a/bin/com/connor/renben/process/plm/util/ProgressBar.class b/bin/com/connor/renben/process/plm/util/ProgressBar.class new file mode 100644 index 0000000..971cfc8 Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/ProgressBar.class differ diff --git a/bin/com/connor/renben/process/plm/util/ProgressBarThread.class b/bin/com/connor/renben/process/plm/util/ProgressBarThread.class new file mode 100644 index 0000000..f9bccb9 Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/ProgressBarThread.class differ diff --git a/bin/com/connor/renben/process/plm/util/TMomFinalUtil.class b/bin/com/connor/renben/process/plm/util/TMomFinalUtil.class new file mode 100644 index 0000000..0c92268 Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/TMomFinalUtil.class differ diff --git a/bin/com/connor/renben/process/plm/util/TMomMethodUtil.class b/bin/com/connor/renben/process/plm/util/TMomMethodUtil.class new file mode 100644 index 0000000..71c7046 Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/TMomMethodUtil.class differ diff --git a/bin/com/connor/renben/process/plm/util/TableCellCheckboxRenderer$1.class b/bin/com/connor/renben/process/plm/util/TableCellCheckboxRenderer$1.class new file mode 100644 index 0000000..0db8f99 Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/TableCellCheckboxRenderer$1.class differ diff --git a/bin/com/connor/renben/process/plm/util/TableCellCheckboxRenderer.class b/bin/com/connor/renben/process/plm/util/TableCellCheckboxRenderer.class new file mode 100644 index 0000000..ea0bdbf Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/TableCellCheckboxRenderer.class differ diff --git a/bin/com/connor/renben/process/plm/util/TableCellTextAreaRenderer.class b/bin/com/connor/renben/process/plm/util/TableCellTextAreaRenderer.class new file mode 100644 index 0000000..6e8e592 Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/TableCellTextAreaRenderer.class differ diff --git a/bin/com/connor/renben/process/plm/util/TextAreaCellEditor.class b/bin/com/connor/renben/process/plm/util/TextAreaCellEditor.class new file mode 100644 index 0000000..6a45066 Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/TextAreaCellEditor.class differ diff --git a/bin/com/connor/renben/process/plm/util/TreeTableCellEditor.class b/bin/com/connor/renben/process/plm/util/TreeTableCellEditor.class new file mode 100644 index 0000000..97b1103 Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/TreeTableCellEditor.class differ diff --git a/bin/com/connor/renben/process/plm/util/TreeTableCellRenderer.class b/bin/com/connor/renben/process/plm/util/TreeTableCellRenderer.class new file mode 100644 index 0000000..6406c27 Binary files /dev/null and b/bin/com/connor/renben/process/plm/util/TreeTableCellRenderer.class differ diff --git a/bin/com/connor/zf/controlplan/Adapter.class b/bin/com/connor/zf/controlplan/Adapter.class new file mode 100644 index 0000000..ee476c1 Binary files /dev/null and b/bin/com/connor/zf/controlplan/Adapter.class differ diff --git a/bin/com/connor/zf/controlplan/CTMap.class b/bin/com/connor/zf/controlplan/CTMap.class new file mode 100644 index 0000000..3085c2b Binary files /dev/null and b/bin/com/connor/zf/controlplan/CTMap.class differ diff --git a/bin/com/connor/zf/controlplan/CTUI.class b/bin/com/connor/zf/controlplan/CTUI.class new file mode 100644 index 0000000..4dc1404 Binary files /dev/null and b/bin/com/connor/zf/controlplan/CTUI.class differ diff --git a/bin/com/connor/zf/controlplan/CTable.class b/bin/com/connor/zf/controlplan/CTable.class new file mode 100644 index 0000000..f7ee250 Binary files /dev/null and b/bin/com/connor/zf/controlplan/CTable.class differ diff --git a/bin/com/connor/zf/controlplan/CTextField.class b/bin/com/connor/zf/controlplan/CTextField.class new file mode 100644 index 0000000..f82d38e Binary files /dev/null and b/bin/com/connor/zf/controlplan/CTextField.class differ diff --git a/bin/com/connor/zf/controlplan/CXBean.class b/bin/com/connor/zf/controlplan/CXBean.class new file mode 100644 index 0000000..8849e8e Binary files /dev/null and b/bin/com/connor/zf/controlplan/CXBean.class differ diff --git a/bin/com/connor/zf/controlplan/CellSpan.class b/bin/com/connor/zf/controlplan/CellSpan.class new file mode 100644 index 0000000..3f41ad7 Binary files /dev/null and b/bin/com/connor/zf/controlplan/CellSpan.class differ diff --git a/bin/com/connor/zf/controlplan/CheckBoxCellEditor$1.class b/bin/com/connor/zf/controlplan/CheckBoxCellEditor$1.class new file mode 100644 index 0000000..d7adb39 Binary files /dev/null and b/bin/com/connor/zf/controlplan/CheckBoxCellEditor$1.class differ diff --git a/bin/com/connor/zf/controlplan/CheckBoxCellEditor$2.class b/bin/com/connor/zf/controlplan/CheckBoxCellEditor$2.class new file mode 100644 index 0000000..309de9e Binary files /dev/null and b/bin/com/connor/zf/controlplan/CheckBoxCellEditor$2.class differ diff --git a/bin/com/connor/zf/controlplan/CheckBoxCellEditor.class b/bin/com/connor/zf/controlplan/CheckBoxCellEditor.class new file mode 100644 index 0000000..6c5c329 Binary files /dev/null and b/bin/com/connor/zf/controlplan/CheckBoxCellEditor.class differ diff --git a/bin/com/connor/zf/controlplan/ClassPropBean.class b/bin/com/connor/zf/controlplan/ClassPropBean.class new file mode 100644 index 0000000..1a34f76 Binary files /dev/null and b/bin/com/connor/zf/controlplan/ClassPropBean.class differ diff --git a/bin/com/connor/zf/controlplan/ClassProperty.class b/bin/com/connor/zf/controlplan/ClassProperty.class new file mode 100644 index 0000000..a8542a6 Binary files /dev/null and b/bin/com/connor/zf/controlplan/ClassProperty.class differ diff --git a/bin/com/connor/zf/controlplan/ComboBoxCellEditor$1.class b/bin/com/connor/zf/controlplan/ComboBoxCellEditor$1.class new file mode 100644 index 0000000..50a0879 Binary files /dev/null and b/bin/com/connor/zf/controlplan/ComboBoxCellEditor$1.class differ diff --git a/bin/com/connor/zf/controlplan/ComboBoxCellEditor.class b/bin/com/connor/zf/controlplan/ComboBoxCellEditor.class new file mode 100644 index 0000000..a9b6aa1 Binary files /dev/null and b/bin/com/connor/zf/controlplan/ComboBoxCellEditor.class differ diff --git a/bin/com/connor/zf/controlplan/ControlPlanBean.class b/bin/com/connor/zf/controlplan/ControlPlanBean.class new file mode 100644 index 0000000..d0f35ab Binary files /dev/null and b/bin/com/connor/zf/controlplan/ControlPlanBean.class differ diff --git a/bin/com/connor/zf/controlplan/ControlPlanComboBoxBean.class b/bin/com/connor/zf/controlplan/ControlPlanComboBoxBean.class new file mode 100644 index 0000000..c506d3a Binary files /dev/null and b/bin/com/connor/zf/controlplan/ControlPlanComboBoxBean.class differ diff --git a/bin/com/connor/zf/controlplan/CreateControlplanHandler.class b/bin/com/connor/zf/controlplan/CreateControlplanHandler.class new file mode 100644 index 0000000..ab9291a Binary files /dev/null and b/bin/com/connor/zf/controlplan/CreateControlplanHandler.class differ diff --git a/bin/com/connor/zf/controlplan/EntrustmentFormBean.class b/bin/com/connor/zf/controlplan/EntrustmentFormBean.class new file mode 100644 index 0000000..7e4626a Binary files /dev/null and b/bin/com/connor/zf/controlplan/EntrustmentFormBean.class differ diff --git a/bin/com/connor/zf/controlplan/JBoxTestCell.class b/bin/com/connor/zf/controlplan/JBoxTestCell.class new file mode 100644 index 0000000..39f0179 Binary files /dev/null and b/bin/com/connor/zf/controlplan/JBoxTestCell.class differ diff --git a/bin/com/connor/zf/controlplan/JDMethodUtil.class b/bin/com/connor/zf/controlplan/JDMethodUtil.class new file mode 100644 index 0000000..c68c9d1 Binary files /dev/null and b/bin/com/connor/zf/controlplan/JDMethodUtil.class differ diff --git a/bin/com/connor/zf/controlplan/JobProcessFormBean.class b/bin/com/connor/zf/controlplan/JobProcessFormBean.class new file mode 100644 index 0000000..c8ea8e6 Binary files /dev/null and b/bin/com/connor/zf/controlplan/JobProcessFormBean.class differ diff --git a/bin/com/connor/zf/controlplan/MultiComboBox$EditorHandler.class b/bin/com/connor/zf/controlplan/MultiComboBox$EditorHandler.class new file mode 100644 index 0000000..6838f83 Binary files /dev/null and b/bin/com/connor/zf/controlplan/MultiComboBox$EditorHandler.class differ diff --git a/bin/com/connor/zf/controlplan/MultiComboBox$MulitComboboxLayout.class b/bin/com/connor/zf/controlplan/MultiComboBox$MulitComboboxLayout.class new file mode 100644 index 0000000..ecf2cae Binary files /dev/null and b/bin/com/connor/zf/controlplan/MultiComboBox$MulitComboboxLayout.class differ diff --git a/bin/com/connor/zf/controlplan/MultiComboBox$PopupAction.class b/bin/com/connor/zf/controlplan/MultiComboBox$PopupAction.class new file mode 100644 index 0000000..02335e3 Binary files /dev/null and b/bin/com/connor/zf/controlplan/MultiComboBox$PopupAction.class differ diff --git a/bin/com/connor/zf/controlplan/MultiComboBox.class b/bin/com/connor/zf/controlplan/MultiComboBox.class new file mode 100644 index 0000000..c8eb799 Binary files /dev/null and b/bin/com/connor/zf/controlplan/MultiComboBox.class differ diff --git a/bin/com/connor/zf/controlplan/MultiLineHeaderRenderer.class b/bin/com/connor/zf/controlplan/MultiLineHeaderRenderer.class new file mode 100644 index 0000000..ce5732d Binary files /dev/null and b/bin/com/connor/zf/controlplan/MultiLineHeaderRenderer.class differ diff --git a/bin/com/connor/zf/controlplan/MultiPopup$1.class b/bin/com/connor/zf/controlplan/MultiPopup$1.class new file mode 100644 index 0000000..6af0be7 Binary files /dev/null and b/bin/com/connor/zf/controlplan/MultiPopup$1.class differ diff --git a/bin/com/connor/zf/controlplan/MultiPopup$2.class b/bin/com/connor/zf/controlplan/MultiPopup$2.class new file mode 100644 index 0000000..b1e18e1 Binary files /dev/null and b/bin/com/connor/zf/controlplan/MultiPopup$2.class differ diff --git a/bin/com/connor/zf/controlplan/MultiPopup$3.class b/bin/com/connor/zf/controlplan/MultiPopup$3.class new file mode 100644 index 0000000..4b76c14 Binary files /dev/null and b/bin/com/connor/zf/controlplan/MultiPopup$3.class differ diff --git a/bin/com/connor/zf/controlplan/MultiPopup.class b/bin/com/connor/zf/controlplan/MultiPopup.class new file mode 100644 index 0000000..30fcbdd Binary files /dev/null and b/bin/com/connor/zf/controlplan/MultiPopup.class differ diff --git a/bin/com/connor/zf/controlplan/MyTableModel.class b/bin/com/connor/zf/controlplan/MyTableModel.class new file mode 100644 index 0000000..d2f325f Binary files /dev/null and b/bin/com/connor/zf/controlplan/MyTableModel.class differ diff --git a/bin/com/connor/zf/controlplan/ProcessBean.class b/bin/com/connor/zf/controlplan/ProcessBean.class new file mode 100644 index 0000000..1b1ad63 Binary files /dev/null and b/bin/com/connor/zf/controlplan/ProcessBean.class differ diff --git a/bin/com/connor/zf/controlplan/SaveControlPlan.class b/bin/com/connor/zf/controlplan/SaveControlPlan.class new file mode 100644 index 0000000..e3eae30 Binary files /dev/null and b/bin/com/connor/zf/controlplan/SaveControlPlan.class differ diff --git a/bin/com/connor/zf/controlplan/SqlUtil.class b/bin/com/connor/zf/controlplan/SqlUtil.class new file mode 100644 index 0000000..e2d9371 Binary files /dev/null and b/bin/com/connor/zf/controlplan/SqlUtil.class differ diff --git a/bin/com/connor/zf/controlplan/SqlUtilT.class b/bin/com/connor/zf/controlplan/SqlUtilT.class new file mode 100644 index 0000000..94c980f Binary files /dev/null and b/bin/com/connor/zf/controlplan/SqlUtilT.class differ diff --git a/bin/com/connor/zf/controlplan/StringCreateUtil.class b/bin/com/connor/zf/controlplan/StringCreateUtil.class new file mode 100644 index 0000000..23a75b9 Binary files /dev/null and b/bin/com/connor/zf/controlplan/StringCreateUtil.class differ diff --git a/bin/com/connor/zf/controlplan/TMom004LibraryTree.class b/bin/com/connor/zf/controlplan/TMom004LibraryTree.class new file mode 100644 index 0000000..d5a076c Binary files /dev/null and b/bin/com/connor/zf/controlplan/TMom004LibraryTree.class differ diff --git a/bin/com/connor/zf/controlplan/TMom004SetControlPlanCommand.class b/bin/com/connor/zf/controlplan/TMom004SetControlPlanCommand.class new file mode 100644 index 0000000..743c170 Binary files /dev/null and b/bin/com/connor/zf/controlplan/TMom004SetControlPlanCommand.class differ diff --git a/bin/com/connor/zf/controlplan/TMom004SetControlPlanDialog$AddMeopDialog.class b/bin/com/connor/zf/controlplan/TMom004SetControlPlanDialog$AddMeopDialog.class new file mode 100644 index 0000000..76fcf39 Binary files /dev/null and b/bin/com/connor/zf/controlplan/TMom004SetControlPlanDialog$AddMeopDialog.class differ diff --git a/bin/com/connor/zf/controlplan/TMom004SetControlPlanDialog$AddRowsDialog.class b/bin/com/connor/zf/controlplan/TMom004SetControlPlanDialog$AddRowsDialog.class new file mode 100644 index 0000000..c4d9a46 Binary files /dev/null and b/bin/com/connor/zf/controlplan/TMom004SetControlPlanDialog$AddRowsDialog.class differ diff --git a/bin/com/connor/zf/controlplan/TMom004SetControlPlanDialog$AddStandard.class b/bin/com/connor/zf/controlplan/TMom004SetControlPlanDialog$AddStandard.class new file mode 100644 index 0000000..b9c8fcb Binary files /dev/null and b/bin/com/connor/zf/controlplan/TMom004SetControlPlanDialog$AddStandard.class differ diff --git a/bin/com/connor/zf/controlplan/TMom004SetControlPlanDialog$LibraryDialog.class b/bin/com/connor/zf/controlplan/TMom004SetControlPlanDialog$LibraryDialog.class new file mode 100644 index 0000000..66b6fd7 Binary files /dev/null and b/bin/com/connor/zf/controlplan/TMom004SetControlPlanDialog$LibraryDialog.class differ diff --git a/bin/com/connor/zf/controlplan/TMom004SetControlPlanDialog$NaturalOrderComparator.class b/bin/com/connor/zf/controlplan/TMom004SetControlPlanDialog$NaturalOrderComparator.class new file mode 100644 index 0000000..ad539b3 Binary files /dev/null and b/bin/com/connor/zf/controlplan/TMom004SetControlPlanDialog$NaturalOrderComparator.class differ diff --git a/bin/com/connor/zf/controlplan/TMom004SetControlPlanDialog$SpecialDialog.class b/bin/com/connor/zf/controlplan/TMom004SetControlPlanDialog$SpecialDialog.class new file mode 100644 index 0000000..488f35f Binary files /dev/null and b/bin/com/connor/zf/controlplan/TMom004SetControlPlanDialog$SpecialDialog.class differ diff --git a/bin/com/connor/zf/controlplan/TMom004SetControlPlanDialog$ThesaurusDialog.class b/bin/com/connor/zf/controlplan/TMom004SetControlPlanDialog$ThesaurusDialog.class new file mode 100644 index 0000000..7c19bd1 Binary files /dev/null and b/bin/com/connor/zf/controlplan/TMom004SetControlPlanDialog$ThesaurusDialog.class differ diff --git a/bin/com/connor/zf/controlplan/TMom004SetControlPlanDialog$selectExportPath.class b/bin/com/connor/zf/controlplan/TMom004SetControlPlanDialog$selectExportPath.class new file mode 100644 index 0000000..106983b Binary files /dev/null and b/bin/com/connor/zf/controlplan/TMom004SetControlPlanDialog$selectExportPath.class differ diff --git a/bin/com/connor/zf/controlplan/TMom004SetControlPlanDialog.class b/bin/com/connor/zf/controlplan/TMom004SetControlPlanDialog.class new file mode 100644 index 0000000..af4f75e Binary files /dev/null and b/bin/com/connor/zf/controlplan/TMom004SetControlPlanDialog.class differ diff --git a/bin/com/connor/zf/controlplan/TMom004SetControlPlanHandler.class b/bin/com/connor/zf/controlplan/TMom004SetControlPlanHandler.class new file mode 100644 index 0000000..c132e68 Binary files /dev/null and b/bin/com/connor/zf/controlplan/TMom004SetControlPlanHandler.class differ diff --git a/bin/com/connor/zf/controlplan/TMom004SetControlPlanOperation.class b/bin/com/connor/zf/controlplan/TMom004SetControlPlanOperation.class new file mode 100644 index 0000000..f23e0c3 Binary files /dev/null and b/bin/com/connor/zf/controlplan/TMom004SetControlPlanOperation.class differ diff --git a/bin/com/connor/zf/controlplan/TMomControlPlanBean.class b/bin/com/connor/zf/controlplan/TMomControlPlanBean.class new file mode 100644 index 0000000..66270cc Binary files /dev/null and b/bin/com/connor/zf/controlplan/TMomControlPlanBean.class differ diff --git a/bin/com/connor/zf/controlplan/TMomControlPlanSimpleBean.class b/bin/com/connor/zf/controlplan/TMomControlPlanSimpleBean.class new file mode 100644 index 0000000..80b75ac Binary files /dev/null and b/bin/com/connor/zf/controlplan/TMomControlPlanSimpleBean.class differ diff --git a/bin/com/connor/zf/controlplan/TMomFinalUtil.class b/bin/com/connor/zf/controlplan/TMomFinalUtil.class new file mode 100644 index 0000000..0f8e10d Binary files /dev/null and b/bin/com/connor/zf/controlplan/TMomFinalUtil.class differ diff --git a/bin/com/connor/zf/controlplan/TMomItemBean.class b/bin/com/connor/zf/controlplan/TMomItemBean.class new file mode 100644 index 0000000..02a7558 Binary files /dev/null and b/bin/com/connor/zf/controlplan/TMomItemBean.class differ diff --git a/bin/com/connor/zf/controlplan/TMomMethodUtil.class b/bin/com/connor/zf/controlplan/TMomMethodUtil.class new file mode 100644 index 0000000..f49276c Binary files /dev/null and b/bin/com/connor/zf/controlplan/TMomMethodUtil.class differ diff --git a/bin/com/connor/zf/controlplan/TMomPropExplictBean.class b/bin/com/connor/zf/controlplan/TMomPropExplictBean.class new file mode 100644 index 0000000..0df957b Binary files /dev/null and b/bin/com/connor/zf/controlplan/TMomPropExplictBean.class differ diff --git a/bin/com/connor/zf/controlplan/TMomUserBean.class b/bin/com/connor/zf/controlplan/TMomUserBean.class new file mode 100644 index 0000000..23ba0db Binary files /dev/null and b/bin/com/connor/zf/controlplan/TMomUserBean.class differ diff --git a/bin/com/connor/zf/controlplan/TableCellCheckboxRenderer$1.class b/bin/com/connor/zf/controlplan/TableCellCheckboxRenderer$1.class new file mode 100644 index 0000000..5b53b6b Binary files /dev/null and b/bin/com/connor/zf/controlplan/TableCellCheckboxRenderer$1.class differ diff --git a/bin/com/connor/zf/controlplan/TableCellCheckboxRenderer.class b/bin/com/connor/zf/controlplan/TableCellCheckboxRenderer.class new file mode 100644 index 0000000..43deb7a Binary files /dev/null and b/bin/com/connor/zf/controlplan/TableCellCheckboxRenderer.class differ diff --git a/bin/com/connor/zf/controlplan/TableCellTextAreaRenderer.class b/bin/com/connor/zf/controlplan/TableCellTextAreaRenderer.class new file mode 100644 index 0000000..e85236d Binary files /dev/null and b/bin/com/connor/zf/controlplan/TableCellTextAreaRenderer.class differ diff --git a/bin/com/connor/zf/controlplan/TableCellTextAreaRenderer2.class b/bin/com/connor/zf/controlplan/TableCellTextAreaRenderer2.class new file mode 100644 index 0000000..32f2b20 Binary files /dev/null and b/bin/com/connor/zf/controlplan/TableCellTextAreaRenderer2.class differ diff --git a/bin/com/connor/zf/controlplan/TextAreaCellEditor.class b/bin/com/connor/zf/controlplan/TextAreaCellEditor.class new file mode 100644 index 0000000..406fc9d Binary files /dev/null and b/bin/com/connor/zf/controlplan/TextAreaCellEditor.class differ diff --git a/bin/com/connor/zf/controlplan/TreeBean.class b/bin/com/connor/zf/controlplan/TreeBean.class new file mode 100644 index 0000000..37edb4c Binary files /dev/null and b/bin/com/connor/zf/controlplan/TreeBean.class differ diff --git a/bin/com/connor/zf/controlplan/outPutExcel.class b/bin/com/connor/zf/controlplan/outPutExcel.class new file mode 100644 index 0000000..a9b968b Binary files /dev/null and b/bin/com/connor/zf/controlplan/outPutExcel.class differ diff --git a/bin/com/connor/zf/controlplan/test.class b/bin/com/connor/zf/controlplan/test.class new file mode 100644 index 0000000..307c830 Binary files /dev/null and b/bin/com/connor/zf/controlplan/test.class differ diff --git a/bin/com/connor/zf/controlplanlibrary/CTMap.class b/bin/com/connor/zf/controlplanlibrary/CTMap.class new file mode 100644 index 0000000..d482a02 Binary files /dev/null and b/bin/com/connor/zf/controlplanlibrary/CTMap.class differ diff --git a/bin/com/connor/zf/controlplanlibrary/CTUI.class b/bin/com/connor/zf/controlplanlibrary/CTUI.class new file mode 100644 index 0000000..d9edf83 Binary files /dev/null and b/bin/com/connor/zf/controlplanlibrary/CTUI.class differ diff --git a/bin/com/connor/zf/controlplanlibrary/CTable.class b/bin/com/connor/zf/controlplanlibrary/CTable.class new file mode 100644 index 0000000..cb062f2 Binary files /dev/null and b/bin/com/connor/zf/controlplanlibrary/CTable.class differ diff --git a/bin/com/connor/zf/controlplanlibrary/CellSpan.class b/bin/com/connor/zf/controlplanlibrary/CellSpan.class new file mode 100644 index 0000000..6a8ca55 Binary files /dev/null and b/bin/com/connor/zf/controlplanlibrary/CellSpan.class differ diff --git a/bin/com/connor/zf/controlplanlibrary/ComboBoxCellEditor$1.class b/bin/com/connor/zf/controlplanlibrary/ComboBoxCellEditor$1.class new file mode 100644 index 0000000..432bcca Binary files /dev/null and b/bin/com/connor/zf/controlplanlibrary/ComboBoxCellEditor$1.class differ diff --git a/bin/com/connor/zf/controlplanlibrary/ComboBoxCellEditor.class b/bin/com/connor/zf/controlplanlibrary/ComboBoxCellEditor.class new file mode 100644 index 0000000..c47d52a Binary files /dev/null and b/bin/com/connor/zf/controlplanlibrary/ComboBoxCellEditor.class differ diff --git a/bin/com/connor/zf/controlplanlibrary/TMom012ControlPlanLibraryCommand$NaturalOrderComparator.class b/bin/com/connor/zf/controlplanlibrary/TMom012ControlPlanLibraryCommand$NaturalOrderComparator.class new file mode 100644 index 0000000..a386afe Binary files /dev/null and b/bin/com/connor/zf/controlplanlibrary/TMom012ControlPlanLibraryCommand$NaturalOrderComparator.class differ diff --git a/bin/com/connor/zf/controlplanlibrary/TMom012ControlPlanLibraryCommand.class b/bin/com/connor/zf/controlplanlibrary/TMom012ControlPlanLibraryCommand.class new file mode 100644 index 0000000..73f743e Binary files /dev/null and b/bin/com/connor/zf/controlplanlibrary/TMom012ControlPlanLibraryCommand.class differ diff --git a/bin/com/connor/zf/controlplanlibrary/TMom012ControlPlanLibraryDialog$AddRowsDialog.class b/bin/com/connor/zf/controlplanlibrary/TMom012ControlPlanLibraryDialog$AddRowsDialog.class new file mode 100644 index 0000000..67ddb3c Binary files /dev/null and b/bin/com/connor/zf/controlplanlibrary/TMom012ControlPlanLibraryDialog$AddRowsDialog.class differ diff --git a/bin/com/connor/zf/controlplanlibrary/TMom012ControlPlanLibraryDialog$NaturalOrderComparator.class b/bin/com/connor/zf/controlplanlibrary/TMom012ControlPlanLibraryDialog$NaturalOrderComparator.class new file mode 100644 index 0000000..d754fb5 Binary files /dev/null and b/bin/com/connor/zf/controlplanlibrary/TMom012ControlPlanLibraryDialog$NaturalOrderComparator.class differ diff --git a/bin/com/connor/zf/controlplanlibrary/TMom012ControlPlanLibraryDialog$SpecialDialog.class b/bin/com/connor/zf/controlplanlibrary/TMom012ControlPlanLibraryDialog$SpecialDialog.class new file mode 100644 index 0000000..32bfce1 Binary files /dev/null and b/bin/com/connor/zf/controlplanlibrary/TMom012ControlPlanLibraryDialog$SpecialDialog.class differ diff --git a/bin/com/connor/zf/controlplanlibrary/TMom012ControlPlanLibraryDialog.class b/bin/com/connor/zf/controlplanlibrary/TMom012ControlPlanLibraryDialog.class new file mode 100644 index 0000000..4312778 Binary files /dev/null and b/bin/com/connor/zf/controlplanlibrary/TMom012ControlPlanLibraryDialog.class differ diff --git a/bin/com/connor/zf/controlplanlibrary/TMom012ControlPlanLibraryHandler.class b/bin/com/connor/zf/controlplanlibrary/TMom012ControlPlanLibraryHandler.class new file mode 100644 index 0000000..2726e7f Binary files /dev/null and b/bin/com/connor/zf/controlplanlibrary/TMom012ControlPlanLibraryHandler.class differ diff --git a/bin/com/connor/zf/controlplanlibrary/TMom012ControlPlanLibraryOperation.class b/bin/com/connor/zf/controlplanlibrary/TMom012ControlPlanLibraryOperation.class new file mode 100644 index 0000000..f15730a Binary files /dev/null and b/bin/com/connor/zf/controlplanlibrary/TMom012ControlPlanLibraryOperation.class differ diff --git a/bin/com/connor/zf/controlplanlibrary/TableCellTextAreaRenderer.class b/bin/com/connor/zf/controlplanlibrary/TableCellTextAreaRenderer.class new file mode 100644 index 0000000..d9e75e9 Binary files /dev/null and b/bin/com/connor/zf/controlplanlibrary/TableCellTextAreaRenderer.class differ diff --git a/bin/com/connor/zf/controlplanlibrary/TableCellTextAreaRenderer2.class b/bin/com/connor/zf/controlplanlibrary/TableCellTextAreaRenderer2.class new file mode 100644 index 0000000..36d8c17 Binary files /dev/null and b/bin/com/connor/zf/controlplanlibrary/TableCellTextAreaRenderer2.class differ diff --git a/bin/com/connor/zf/controlplanlibrary/TextAreaCellEditor.class b/bin/com/connor/zf/controlplanlibrary/TextAreaCellEditor.class new file mode 100644 index 0000000..c8da997 Binary files /dev/null and b/bin/com/connor/zf/controlplanlibrary/TextAreaCellEditor.class differ diff --git a/bin/com/connor/zf/editClassAttr/AutoCompleter.class b/bin/com/connor/zf/editClassAttr/AutoCompleter.class new file mode 100644 index 0000000..c079477 Binary files /dev/null and b/bin/com/connor/zf/editClassAttr/AutoCompleter.class differ diff --git a/bin/com/connor/zf/editClassAttr/JAutoCompleteComboBox.class b/bin/com/connor/zf/editClassAttr/JAutoCompleteComboBox.class new file mode 100644 index 0000000..91c6ebd Binary files /dev/null and b/bin/com/connor/zf/editClassAttr/JAutoCompleteComboBox.class differ diff --git a/bin/com/connor/zf/plm/bean/NodeBean.class b/bin/com/connor/zf/plm/bean/NodeBean.class new file mode 100644 index 0000000..afc1cca Binary files /dev/null and b/bin/com/connor/zf/plm/bean/NodeBean.class differ diff --git a/bin/com/connor/zf/plm/xmlUtil/CNCompontent.class b/bin/com/connor/zf/plm/xmlUtil/CNCompontent.class new file mode 100644 index 0000000..c0ef078 Binary files /dev/null and b/bin/com/connor/zf/plm/xmlUtil/CNCompontent.class differ diff --git a/bin/com/connor/zf/plm/xmlUtil/CNPart.class b/bin/com/connor/zf/plm/xmlUtil/CNPart.class new file mode 100644 index 0000000..5e8de16 Binary files /dev/null and b/bin/com/connor/zf/plm/xmlUtil/CNPart.class differ diff --git a/bin/com/connor/zf/plm/xmlUtil/CNPartList.class b/bin/com/connor/zf/plm/xmlUtil/CNPartList.class new file mode 100644 index 0000000..3ec4861 Binary files /dev/null and b/bin/com/connor/zf/plm/xmlUtil/CNPartList.class differ diff --git a/bin/com/connor/zf/plm/xmlUtil/CNProperty.class b/bin/com/connor/zf/plm/xmlUtil/CNProperty.class new file mode 100644 index 0000000..a48495d Binary files /dev/null and b/bin/com/connor/zf/plm/xmlUtil/CNProperty.class differ diff --git a/bin/com/connor/zf/plm/xmlUtil/CNXmlUtil.class b/bin/com/connor/zf/plm/xmlUtil/CNXmlUtil.class new file mode 100644 index 0000000..6aed341 Binary files /dev/null and b/bin/com/connor/zf/plm/xmlUtil/CNXmlUtil.class differ diff --git a/bin/com/connor/zf/plm001/DDInClassDialog.class b/bin/com/connor/zf/plm001/DDInClassDialog.class new file mode 100644 index 0000000..492d5f5 Binary files /dev/null and b/bin/com/connor/zf/plm001/DDInClassDialog.class differ diff --git a/bin/com/connor/zf/plm001/MaintenanceProcedureHandler.class b/bin/com/connor/zf/plm001/MaintenanceProcedureHandler.class new file mode 100644 index 0000000..eeeb76f Binary files /dev/null and b/bin/com/connor/zf/plm001/MaintenanceProcedureHandler.class differ diff --git a/bin/com/connor/zf/plm001/TMom005CreateOPByModuleOperation.class b/bin/com/connor/zf/plm001/TMom005CreateOPByModuleOperation.class new file mode 100644 index 0000000..83528b3 Binary files /dev/null and b/bin/com/connor/zf/plm001/TMom005CreateOPByModuleOperation.class differ diff --git a/bin/com/connor/zf/plm002/CopyProcessRouteDialog.class b/bin/com/connor/zf/plm002/CopyProcessRouteDialog.class new file mode 100644 index 0000000..ce7df54 Binary files /dev/null and b/bin/com/connor/zf/plm002/CopyProcessRouteDialog.class differ diff --git a/bin/com/connor/zf/plm002/CopyProcessRouteHandler.class b/bin/com/connor/zf/plm002/CopyProcessRouteHandler.class new file mode 100644 index 0000000..29b6e90 Binary files /dev/null and b/bin/com/connor/zf/plm002/CopyProcessRouteHandler.class differ diff --git a/bin/com/connor/zf/plm002/CreateProcessRouteDialog.class b/bin/com/connor/zf/plm002/CreateProcessRouteDialog.class new file mode 100644 index 0000000..3d0aaad Binary files /dev/null and b/bin/com/connor/zf/plm002/CreateProcessRouteDialog.class differ diff --git a/bin/com/connor/zf/plm002/CreateProcessRouteHandler.class b/bin/com/connor/zf/plm002/CreateProcessRouteHandler.class new file mode 100644 index 0000000..c98868d Binary files /dev/null and b/bin/com/connor/zf/plm002/CreateProcessRouteHandler.class differ diff --git a/bin/com/connor/zf/plm002/JTreeTable.class b/bin/com/connor/zf/plm002/JTreeTable.class new file mode 100644 index 0000000..a501da0 Binary files /dev/null and b/bin/com/connor/zf/plm002/JTreeTable.class differ diff --git a/bin/com/connor/zf/plm002/JTreeTableModel.class b/bin/com/connor/zf/plm002/JTreeTableModel.class new file mode 100644 index 0000000..783e55c Binary files /dev/null and b/bin/com/connor/zf/plm002/JTreeTableModel.class differ diff --git a/bin/com/connor/zf/plm002/TableCellCheckboxRenderer.class b/bin/com/connor/zf/plm002/TableCellCheckboxRenderer.class new file mode 100644 index 0000000..4684c7a Binary files /dev/null and b/bin/com/connor/zf/plm002/TableCellCheckboxRenderer.class differ diff --git a/bin/com/connor/zf/plm003/CreateToolingDialog.class b/bin/com/connor/zf/plm003/CreateToolingDialog.class new file mode 100644 index 0000000..a40bd5f Binary files /dev/null and b/bin/com/connor/zf/plm003/CreateToolingDialog.class differ diff --git a/bin/com/connor/zf/plm003/CreateToolingHandler.class b/bin/com/connor/zf/plm003/CreateToolingHandler.class new file mode 100644 index 0000000..496ac1a Binary files /dev/null and b/bin/com/connor/zf/plm003/CreateToolingHandler.class differ diff --git a/bin/com/connor/zf/plm003/Test.class b/bin/com/connor/zf/plm003/Test.class new file mode 100644 index 0000000..617f292 Binary files /dev/null and b/bin/com/connor/zf/plm003/Test.class differ diff --git a/bin/com/connor/zf/util/ClassPropBean.class b/bin/com/connor/zf/util/ClassPropBean.class new file mode 100644 index 0000000..27c1a21 Binary files /dev/null and b/bin/com/connor/zf/util/ClassPropBean.class differ diff --git a/bin/com/connor/zf/util/ClassProperty.class b/bin/com/connor/zf/util/ClassProperty.class new file mode 100644 index 0000000..f598630 Binary files /dev/null and b/bin/com/connor/zf/util/ClassProperty.class differ diff --git a/bin/com/connor/zf/util/JDMethodUtil.class b/bin/com/connor/zf/util/JDMethodUtil.class new file mode 100644 index 0000000..cce8031 Binary files /dev/null and b/bin/com/connor/zf/util/JDMethodUtil.class differ diff --git a/bin/com/connor/zf/util/SoaServerUtil.class b/bin/com/connor/zf/util/SoaServerUtil.class new file mode 100644 index 0000000..a904a4c Binary files /dev/null and b/bin/com/connor/zf/util/SoaServerUtil.class differ diff --git a/bin/com/connor/zf/util/StringCreateUtil.class b/bin/com/connor/zf/util/StringCreateUtil.class new file mode 100644 index 0000000..97f6818 Binary files /dev/null and b/bin/com/connor/zf/util/StringCreateUtil.class differ diff --git a/bin/com/connor/zf/utils/AutoCompleter.class b/bin/com/connor/zf/utils/AutoCompleter.class new file mode 100644 index 0000000..a2f5a3b Binary files /dev/null and b/bin/com/connor/zf/utils/AutoCompleter.class differ diff --git a/bin/com/connor/zf/utils/CheckBoxTableHeaderRenderer$1.class b/bin/com/connor/zf/utils/CheckBoxTableHeaderRenderer$1.class new file mode 100644 index 0000000..8b0a6e5 Binary files /dev/null and b/bin/com/connor/zf/utils/CheckBoxTableHeaderRenderer$1.class differ diff --git a/bin/com/connor/zf/utils/CheckBoxTableHeaderRenderer.class b/bin/com/connor/zf/utils/CheckBoxTableHeaderRenderer.class new file mode 100644 index 0000000..e99bc07 Binary files /dev/null and b/bin/com/connor/zf/utils/CheckBoxTableHeaderRenderer.class differ diff --git a/bin/com/connor/zf/utils/CreateNewBOHandler$CreateNewBOSWTDialog.class b/bin/com/connor/zf/utils/CreateNewBOHandler$CreateNewBOSWTDialog.class new file mode 100644 index 0000000..e956ec3 Binary files /dev/null and b/bin/com/connor/zf/utils/CreateNewBOHandler$CreateNewBOSWTDialog.class differ diff --git a/bin/com/connor/zf/utils/CreateNewBOHandler.class b/bin/com/connor/zf/utils/CreateNewBOHandler.class new file mode 100644 index 0000000..12b9726 Binary files /dev/null and b/bin/com/connor/zf/utils/CreateNewBOHandler.class differ diff --git a/bin/com/connor/zf/utils/JAutoCompleteComboBox.class b/bin/com/connor/zf/utils/JAutoCompleteComboBox.class new file mode 100644 index 0000000..3421ed6 Binary files /dev/null and b/bin/com/connor/zf/utils/JAutoCompleteComboBox.class differ diff --git a/bin/com/connor/zf/utils/JFomMethodUtil.class b/bin/com/connor/zf/utils/JFomMethodUtil.class new file mode 100644 index 0000000..2c7b696 Binary files /dev/null and b/bin/com/connor/zf/utils/JFomMethodUtil.class differ diff --git a/bin/com/connor/zf/utils/SqlUtilT.class b/bin/com/connor/zf/utils/SqlUtilT.class new file mode 100644 index 0000000..6001e5f Binary files /dev/null and b/bin/com/connor/zf/utils/SqlUtilT.class differ diff --git a/bin/com/connor/zf/utils/TCUtil.class b/bin/com/connor/zf/utils/TCUtil.class new file mode 100644 index 0000000..82c062c Binary files /dev/null and b/bin/com/connor/zf/utils/TCUtil.class differ diff --git a/bin/com/connor/zf/utils/TMomFinalUtil.class b/bin/com/connor/zf/utils/TMomFinalUtil.class new file mode 100644 index 0000000..0e570fe Binary files /dev/null and b/bin/com/connor/zf/utils/TMomFinalUtil.class differ diff --git a/bin/com/connor/zf/utils/TMomMethodUtil.class b/bin/com/connor/zf/utils/TMomMethodUtil.class new file mode 100644 index 0000000..50b8c67 Binary files /dev/null and b/bin/com/connor/zf/utils/TMomMethodUtil.class differ diff --git a/bin/com/connor/zf/zygyk/Adapter.class b/bin/com/connor/zf/zygyk/Adapter.class new file mode 100644 index 0000000..e310848 Binary files /dev/null and b/bin/com/connor/zf/zygyk/Adapter.class differ diff --git a/bin/com/connor/zf/zygyk/CTMap.class b/bin/com/connor/zf/zygyk/CTMap.class new file mode 100644 index 0000000..8bae04f Binary files /dev/null and b/bin/com/connor/zf/zygyk/CTMap.class differ diff --git a/bin/com/connor/zf/zygyk/CTUI.class b/bin/com/connor/zf/zygyk/CTUI.class new file mode 100644 index 0000000..32cc6c8 Binary files /dev/null and b/bin/com/connor/zf/zygyk/CTUI.class differ diff --git a/bin/com/connor/zf/zygyk/CTable.class b/bin/com/connor/zf/zygyk/CTable.class new file mode 100644 index 0000000..4b62820 Binary files /dev/null and b/bin/com/connor/zf/zygyk/CTable.class differ diff --git a/bin/com/connor/zf/zygyk/CellSpan.class b/bin/com/connor/zf/zygyk/CellSpan.class new file mode 100644 index 0000000..20d7e1d Binary files /dev/null and b/bin/com/connor/zf/zygyk/CellSpan.class differ diff --git a/bin/com/connor/zf/zygyk/CheckBoxCellEditor$1.class b/bin/com/connor/zf/zygyk/CheckBoxCellEditor$1.class new file mode 100644 index 0000000..cefbecb Binary files /dev/null and b/bin/com/connor/zf/zygyk/CheckBoxCellEditor$1.class differ diff --git a/bin/com/connor/zf/zygyk/CheckBoxCellEditor$2.class b/bin/com/connor/zf/zygyk/CheckBoxCellEditor$2.class new file mode 100644 index 0000000..4f5b7f1 Binary files /dev/null and b/bin/com/connor/zf/zygyk/CheckBoxCellEditor$2.class differ diff --git a/bin/com/connor/zf/zygyk/CheckBoxCellEditor.class b/bin/com/connor/zf/zygyk/CheckBoxCellEditor.class new file mode 100644 index 0000000..7e00ccb Binary files /dev/null and b/bin/com/connor/zf/zygyk/CheckBoxCellEditor.class differ diff --git a/bin/com/connor/zf/zygyk/ComboBoxCellEditor$1.class b/bin/com/connor/zf/zygyk/ComboBoxCellEditor$1.class new file mode 100644 index 0000000..01d5152 Binary files /dev/null and b/bin/com/connor/zf/zygyk/ComboBoxCellEditor$1.class differ diff --git a/bin/com/connor/zf/zygyk/ComboBoxCellEditor.class b/bin/com/connor/zf/zygyk/ComboBoxCellEditor.class new file mode 100644 index 0000000..1557784 Binary files /dev/null and b/bin/com/connor/zf/zygyk/ComboBoxCellEditor.class differ diff --git a/bin/com/connor/zf/zygyk/CreateZYGYKHandler.class b/bin/com/connor/zf/zygyk/CreateZYGYKHandler.class new file mode 100644 index 0000000..9dc7d1f Binary files /dev/null and b/bin/com/connor/zf/zygyk/CreateZYGYKHandler.class differ diff --git a/bin/com/connor/zf/zygyk/TableCellCheckboxRenderer$1.class b/bin/com/connor/zf/zygyk/TableCellCheckboxRenderer$1.class new file mode 100644 index 0000000..4225999 Binary files /dev/null and b/bin/com/connor/zf/zygyk/TableCellCheckboxRenderer$1.class differ diff --git a/bin/com/connor/zf/zygyk/TableCellCheckboxRenderer.class b/bin/com/connor/zf/zygyk/TableCellCheckboxRenderer.class new file mode 100644 index 0000000..d9547c2 Binary files /dev/null and b/bin/com/connor/zf/zygyk/TableCellCheckboxRenderer.class differ diff --git a/bin/com/connor/zf/zygyk/TableCellTextAreaRenderer.class b/bin/com/connor/zf/zygyk/TableCellTextAreaRenderer.class new file mode 100644 index 0000000..059ff91 Binary files /dev/null and b/bin/com/connor/zf/zygyk/TableCellTextAreaRenderer.class differ diff --git a/bin/com/connor/zf/zygyk/TextAreaCellEditor.class b/bin/com/connor/zf/zygyk/TextAreaCellEditor.class new file mode 100644 index 0000000..f4a15b7 Binary files /dev/null and b/bin/com/connor/zf/zygyk/TextAreaCellEditor.class differ diff --git a/bin/com/connor/zf/zygyk/ZYGYKCommand.class b/bin/com/connor/zf/zygyk/ZYGYKCommand.class new file mode 100644 index 0000000..8b91924 Binary files /dev/null and b/bin/com/connor/zf/zygyk/ZYGYKCommand.class differ diff --git a/bin/com/connor/zf/zygyk/ZYGYKDialog$AddRowsDialog.class b/bin/com/connor/zf/zygyk/ZYGYKDialog$AddRowsDialog.class new file mode 100644 index 0000000..8d16b3b Binary files /dev/null and b/bin/com/connor/zf/zygyk/ZYGYKDialog$AddRowsDialog.class differ diff --git a/bin/com/connor/zf/zygyk/ZYGYKDialog$PicDialog.class b/bin/com/connor/zf/zygyk/ZYGYKDialog$PicDialog.class new file mode 100644 index 0000000..906dedf Binary files /dev/null and b/bin/com/connor/zf/zygyk/ZYGYKDialog$PicDialog.class differ diff --git a/bin/com/connor/zf/zygyk/ZYGYKDialog.class b/bin/com/connor/zf/zygyk/ZYGYKDialog.class new file mode 100644 index 0000000..783c704 Binary files /dev/null and b/bin/com/connor/zf/zygyk/ZYGYKDialog.class differ diff --git a/bin/com/connor/zf/zygyk/ZYGYKHandler.class b/bin/com/connor/zf/zygyk/ZYGYKHandler.class new file mode 100644 index 0000000..9179173 Binary files /dev/null and b/bin/com/connor/zf/zygyk/ZYGYKHandler.class differ diff --git a/bin/com/connor/zf/zygyk/ZYGYKOperation.class b/bin/com/connor/zf/zygyk/ZYGYKOperation.class new file mode 100644 index 0000000..767db35 Binary files /dev/null and b/bin/com/connor/zf/zygyk/ZYGYKOperation.class differ diff --git a/bin/sql.properties b/bin/sql.properties new file mode 100644 index 0000000..fc02e06 --- /dev/null +++ b/bin/sql.properties @@ -0,0 +1,61 @@ +SETPFMEASELECT=SELECT * FROM AHMC_PFMEA WHERE PROCESSPUID = \'%s\' AND REVISIONID=\'%s\' ORDER BY P5,HH +PFMEALIBRARYSELECT2=SELECT * FROM AHMC_PFMEALIBRARY WHERE PUID = \'%s\' ORDER BY HHC + +BOMCHECKSAVESELECTPFMEA=SELECT MEOPID,STATION,GYBH,GCMC FROM AHMC_PFMEA WHERE PROCESSPUID = \'%s\' AND REVISIONID=\'%s\' + +BOMCHECKSAVESELECTPFMEA2=SELECT * FROM AHMC_PFMEA WHERE PROCESSPUID = \'%s\' AND MEOPID NOT IN %s + +DELETEPFMEA=DELETE FROM AHMC_PFMEA WHERE MEOPID = \'%s\' AND PROCESSPUID = \'%s\' + +INSERTPFMEA=INSERT INTO AHMC_PFMEA VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) +# ORDER BY ID +PFMEALIBRARYSELECT=SELECT * FROM AHMC_PFMEA_NODE WHERE PARENT_ID = \'%s\' ORDER BY ROWNUMD ASC +SETPFMEASELECT2=SELECT MEOPID,REQUIREMENT FROM AHMC_PFMEA WHERE PROCESSPUID = \'%s\' GROUP BY MEOPID,REQUIREMENT +SETPFMEADELETE=DELETE FROM AHMC_PFMEA WHERE PLMEID = \'%s\' + +SETPFMEAUPDATE=UPDATE AHMC_PFMEA SET GYBH = ?,GCMC = ?,STATION = ?,REQUIREMENT = ?,QZSXMS = ?,QZSXHG = ?,YZD = ?,JB = ?,QZSXQY = ?,XXGCKZYF = ?,PDS = ?,XXGCKZTC = ?,TCD = ?,RPN = ?,JYCS = ?,ZZR = ?,JHWCRQ = ?,CQDCS = ?,NEW_SEV = ?,NEW_OCC = ?,NEW_DET = ?,NEW_RPN = ?,IDEAL_STATE = ?,SPECIAL = ?,HH = ?,HBDYG = ? ,OCCURRRENCE = ?,DETECTION = ?,PRIORITY = ?,P1 = ?,P2 = ?,P3 = ?,P4 = ?,P5 = ? WHERE PLMEID = \'%s\' AND REVISIONID=\'%s\' +TM2PFMEATREESELECT=SELECT * FROM AHMC_PFMEA_TREE ORDER BY PARENT_ID,ID + +CONTROLPLANLIBRARYSELECT=SELECT * FROM AHMC_CONTROLPLAN_NODE WHERE PARENT_ID = \'%s\' ORDER BY ID + +TM2CONTROLPLANTREESELECT=SELECT * FROM AHMC_CONTROLPLAN_TREE ORDER BY PARENT_ID + +TM2THESAURUSTREESELECT=SELECT * FROM AHMC_THESAURUS_TREE ORDER BY PARENT_ID + +TM2THESAURUSNODESELECT=SELECT * FROM AHMC_THESAURUS_NODE WHERE PARENT_ID = \'%s\' ORDER BY ID + +PFMEALIBRARYUPDATE=UPDATE AHMC_PFMEA_NODE SET ID = ?,LSBG =?, STATION = ?,REQUIREMENT = ?,QZSXMS = ?,QZSXHG = ?,YZD = ?,JB = ?,QZSXQY = ?,XXGCKZYF = ?,PDS = ?,XXGCKZTC = ?,TCD = ?,RPN = ?,JYCS = ?,ZZR = ?,JHWCRQ = ?,CQDCS = ?,NEW_SEV = ?,NEW_OCC = ?,NEW_DET = ?,NEW_RPN = ?,IDEAL_STATE = ?,SPECIAL = ?,P1 = ?,P2 = ?,P3 = ?,P4 = ?,P5 = ?,P6 = ?,P7 = ?,P8 = ? , HBDYG=?, ROWNUMD=? WHERE PLMEID = \'%s\' + +PFMEALIBRARYDELETE=DELETE FROM AHMC_PFMEA_NODE WHERE PLMEID = \'%s\' +PFMENODEDELETE=DELETE FROM AHMC_PFMEA_TREE WHERE PARENT_ID = \'%s\' +PFMEALIBRARYINSERT=INSERT INTO AHMC_PFMEA_NODE VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) + +#zw +CONTROLPLANSELECT=select * from ZF6_CONTROLPLAN where PROCESSPUID = \'%s\' and PUID = \'%s\' order by CAST(NO AS INT),CAST(ZF6_HH AS INT) +CONTROLPLANUPDATE=update ZF6_CONTROLPLAN set LJGCBH = ?,GCMC = ?,JQZHJJGZ = ?,BH = ?,CP = ?,GC = ?,TSTXFL = ?,CPGC = ?,JSCLJS = ?,XM = ?,RL = ?,PL = ?,ZRR = ?,KZFF = ?,FYJH = ?,NO = ?,ZF6_HH = ?,ZF6_HBDYG = ?,ZF6_HHC = ? where PLMEID = \'%s\' and PUID=\'%s\' +CONTROLPLANOPERATIONSELECT=select ZF6_MEOPID,zf6_gybh from ZF6_CONTROLPLAN where PROCESSPUID = \'%s\' and ZF6_MEOPID is not null group by ZF6_MEOPID,zf6_gybh +CONTROLPLANOPERATIONSELECT2=select ZF6_MEOPID,NO from ZF6_CONTROLPLAN where PROCESSPUID = \'%s\' and ZF6_MEOPID is not null group by ZF6_MEOPID,NO +CONTROLPLANDELETE=delete from ZF6_CONTROLPLAN where PLMEID = \'%s\' +RB3_meopNameToID=select GCMC,PROCESSID from ZF6_CONTROLPLAN where PUID = \'%s\' GROUP BY GCMC ,PROCESSID +CONTROLPLAN_IDTONO=select PROCESSID,NO from ZF6_CONTROLPLAN where PUID = \'%s\' GROUP BY PROCESSID,NO +CONTROLPLANHEADSELECT=select * from ZF6_CONTROLPLANHEAD where PUID = \'%s\' +CONTROLPLANHEADUPDATE=update ZF6_CONTROLPLANHEAD set TYPE = ?,KZJHBH = ?,ZYLXR = ?,BZRIQ = ?,XDRQ = ?,LJBH = ?,HXXZ = ?,GKGCPZ = ?,LJMC = ?,GFPZRQ = ?,GKZLPZ = ?,ZZDM = ?,QTPZ = ?,QTPZRQ = ? where PLMEID = \'%s\' and PUID=\'%s\' +INSERTSQL=insert into ZF6_CONTROLPLAN values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) +RB3_PRODUCTSELECT=select * from ZF6_PRODUCTCHARACTER where PUID = \'%s\' order by CAST(NO AS INT) +RB3_PROCESSSELECT=select * from ZF6_PROCESSCHARACTER where PUID = \'%s\' order by CAST(NO AS INT) +RB3_CONTROLPLANTOGYK=select * from ZF6_CONTROLPLAN where PUID = \'%s\' AND PROCESSID = \'%s\' order by CAST(ZF6_HH AS INT) +RB3_ZYGYKHEADSELECT=select * from ZF6_ZYGYKHEAD where PUID = \'%s\' +RB3_PRODUCTDELETE=delete from ZF6_PRODUCTCHARACTER where PLMEID = \'%s\' AND PUID = \'%s\' +RB3_PROCESSDELETE=delete from ZF6_PROCESSCHARACTER where PLMEID = \'%s\' AND PUID = \'%s\' +RB3_PRODUCTUPDATE=update ZF6_PRODUCTCHARACTER set NO = ?,JCXM = ?,ZYD = ?,YQ = ?,JCFF = ?,SJ1 = ?,ZJPC = ?,SJ2 = ?,JYPC = ?,FYJH = ? where PLMEID = \'%s\' and PUID = \'%s\' +RB3_PROCESSUPDATE=update ZF6_PROCESSCHARACTER set NO = ?,JCXM = ?,ZYD = ?,YQ = ?,JCFF = ?,RL = ?,PL = ?,FYJH = ? where PLMEID = \'%s\' and PUID = \'%s\' +RB3_PRODUCTINSERT=insert into ZF6_PRODUCTCHARACTER values(?,?,?,?,?,?,?,?,?,?,?,?) +RB3_PROCESSINSERT=insert into ZF6_PROCESSCHARACTER values(?,?,?,?,?,?,?,?,?,?) +RB3_ZYGYKHEADUPDATE=update ZF6_ZYGYKHEAD set GYKLX = ?,CPXH = ?,GXMC = ?,SLYSGG = ?,SLYSCZ = ?,SBXH = ?,CHSBXH = ?,YHSBXH = ?,DJDPXH = ?,LJMC = ? where PLMEID = \'%s\' and PUID = \'%s\' + + + +SELECTFRAMESIZE=SELECT * FROM AHMC_PFMEAFRAME_SIZE WHERE USERNAME = \'%s\' AND TYPE = \'%s\' +FRAMESIZEINSERT=INSERT INTO AHMC_PFMEAFRAME_SIZE VALUES(?,?,?,?,?,?) +FRAMESIZEDELETE=DELETE FROM AHMC_PFMEAFRAME_SIZE WHERE USERNAME = \'%s\' AND TYPE = \'%s\' +FRAMESIZEUPDATE=UPDATE AHMC_PFMEAFRAME_SIZE SET FRAMESIZE = ?, TABLE1SIZE = ?, TABLE2SIZE = ? WHERE USERNAME = \'%s\' AND TYPE = \'%s\' \ No newline at end of file diff --git a/build.properties b/build.properties new file mode 100644 index 0000000..26a6569 --- /dev/null +++ b/build.properties @@ -0,0 +1,35 @@ +source.. = src/ +output.. = bin/ +bin.includes = plugin.xml,\ + META-INF/,\ + .,\ + icons/,\ + jdbc_lib/sqljdbc4.jar,\ + lib/swingx-1.6.1.jar,\ + lib/apache-mime4j-core-0.7.2.jar,\ + lib/axiom-api-1.2.13.jar,\ + lib/axiom-dom-1.2.13.jar,\ + lib/axiom-impl-1.2.13.jar,\ + lib/axis2-adb-1.6.2.jar,\ + lib/axis2-adb-codegen-1.6.2.jar,\ + lib/axis2-ant-plugin-1.6.2.jar,\ + lib/axis2-clustering-1.6.2.jar,\ + lib/axis2-codegen-1.6.2.jar,\ + lib/axis2-corba-1.6.2.jar,\ + lib/axis2-fastinfoset-1.6.2.jar,\ + lib/axis2-java2wsdl-1.6.2.jar,\ + lib/axis2-jaxbri-1.6.2.jar,\ + lib/axis2-jaxws-1.6.2.jar,\ + lib/axis2-jibx-1.6.2.jar,\ + lib/axis2-json-1.6.2.jar,\ + lib/axis2-kernel-1.6.2.jar,\ + lib/axis2-metadata-1.6.2.jar,\ + lib/axis2-mtompolicy-1.6.2.jar,\ + lib/axis2-saaj-1.6.2.jar,\ + lib/axis2-soapmonitor-servlet-1.6.2.jar,\ + lib/axis2-spring-1.6.2.jar,\ + lib/axis2-transport-http-1.6.2.jar,\ + lib/axis2-transport-local-1.6.2.jar,\ + lib/axis2-xmlbeans-1.6.2.jar,\ + lib/fastjson-1.2.9.jar,\ + lib/ojdbc7.jar diff --git a/icons/sample.png b/icons/sample.png new file mode 100644 index 0000000..02c4b79 Binary files /dev/null and b/icons/sample.png differ diff --git a/icons/sample@2x.png b/icons/sample@2x.png new file mode 100644 index 0000000..c1224d1 Binary files /dev/null and b/icons/sample@2x.png differ diff --git a/jdbc_lib/sqljdbc4.jar b/jdbc_lib/sqljdbc4.jar new file mode 100644 index 0000000..d6b7f6d Binary files /dev/null and b/jdbc_lib/sqljdbc4.jar differ diff --git a/lib/activation-1.1.jar b/lib/activation-1.1.jar new file mode 100644 index 0000000..53f82a1 Binary files /dev/null and b/lib/activation-1.1.jar differ diff --git a/lib/antlr-2.7.7.jar b/lib/antlr-2.7.7.jar new file mode 100644 index 0000000..5e5f14b Binary files /dev/null and b/lib/antlr-2.7.7.jar differ diff --git a/lib/apache-mime4j-core-0.7.2.jar b/lib/apache-mime4j-core-0.7.2.jar new file mode 100644 index 0000000..b5c225b Binary files /dev/null and b/lib/apache-mime4j-core-0.7.2.jar differ diff --git a/lib/axiom-api-1.2.13.jar b/lib/axiom-api-1.2.13.jar new file mode 100644 index 0000000..84cb42c Binary files /dev/null and b/lib/axiom-api-1.2.13.jar differ diff --git a/lib/axiom-dom-1.2.13.jar b/lib/axiom-dom-1.2.13.jar new file mode 100644 index 0000000..4890bb2 Binary files /dev/null and b/lib/axiom-dom-1.2.13.jar differ diff --git a/lib/axiom-impl-1.2.13.jar b/lib/axiom-impl-1.2.13.jar new file mode 100644 index 0000000..a959b28 Binary files /dev/null and b/lib/axiom-impl-1.2.13.jar differ diff --git a/lib/axis2-adb-1.6.2.jar b/lib/axis2-adb-1.6.2.jar new file mode 100644 index 0000000..6234fdb Binary files /dev/null and b/lib/axis2-adb-1.6.2.jar differ diff --git a/lib/axis2-adb-codegen-1.6.2.jar b/lib/axis2-adb-codegen-1.6.2.jar new file mode 100644 index 0000000..7d037d4 Binary files /dev/null and b/lib/axis2-adb-codegen-1.6.2.jar differ diff --git a/lib/axis2-ant-plugin-1.6.2.jar b/lib/axis2-ant-plugin-1.6.2.jar new file mode 100644 index 0000000..771b222 Binary files /dev/null and b/lib/axis2-ant-plugin-1.6.2.jar differ diff --git a/lib/axis2-clustering-1.6.2.jar b/lib/axis2-clustering-1.6.2.jar new file mode 100644 index 0000000..e45be99 Binary files /dev/null and b/lib/axis2-clustering-1.6.2.jar differ diff --git a/lib/axis2-codegen-1.6.2.jar b/lib/axis2-codegen-1.6.2.jar new file mode 100644 index 0000000..f742f19 Binary files /dev/null and b/lib/axis2-codegen-1.6.2.jar differ diff --git a/lib/axis2-corba-1.6.2.jar b/lib/axis2-corba-1.6.2.jar new file mode 100644 index 0000000..ee3c78e Binary files /dev/null and b/lib/axis2-corba-1.6.2.jar differ diff --git a/lib/axis2-fastinfoset-1.6.2.jar b/lib/axis2-fastinfoset-1.6.2.jar new file mode 100644 index 0000000..d10c36a Binary files /dev/null and b/lib/axis2-fastinfoset-1.6.2.jar differ diff --git a/lib/axis2-java2wsdl-1.6.2.jar b/lib/axis2-java2wsdl-1.6.2.jar new file mode 100644 index 0000000..0bb869d Binary files /dev/null and b/lib/axis2-java2wsdl-1.6.2.jar differ diff --git a/lib/axis2-jaxbri-1.6.2.jar b/lib/axis2-jaxbri-1.6.2.jar new file mode 100644 index 0000000..616eec9 Binary files /dev/null and b/lib/axis2-jaxbri-1.6.2.jar differ diff --git a/lib/axis2-jaxws-1.6.2.jar b/lib/axis2-jaxws-1.6.2.jar new file mode 100644 index 0000000..064351a Binary files /dev/null and b/lib/axis2-jaxws-1.6.2.jar differ diff --git a/lib/axis2-jibx-1.6.2.jar b/lib/axis2-jibx-1.6.2.jar new file mode 100644 index 0000000..75f9d1a Binary files /dev/null and b/lib/axis2-jibx-1.6.2.jar differ diff --git a/lib/axis2-json-1.6.2.jar b/lib/axis2-json-1.6.2.jar new file mode 100644 index 0000000..edd7936 Binary files /dev/null and b/lib/axis2-json-1.6.2.jar differ diff --git a/lib/axis2-kernel-1.6.2.jar b/lib/axis2-kernel-1.6.2.jar new file mode 100644 index 0000000..3ae5f7a Binary files /dev/null and b/lib/axis2-kernel-1.6.2.jar differ diff --git a/lib/axis2-metadata-1.6.2.jar b/lib/axis2-metadata-1.6.2.jar new file mode 100644 index 0000000..492f1ac Binary files /dev/null and b/lib/axis2-metadata-1.6.2.jar differ diff --git a/lib/axis2-mtompolicy-1.6.2.jar b/lib/axis2-mtompolicy-1.6.2.jar new file mode 100644 index 0000000..561e84a Binary files /dev/null and b/lib/axis2-mtompolicy-1.6.2.jar differ diff --git a/lib/axis2-saaj-1.6.2.jar b/lib/axis2-saaj-1.6.2.jar new file mode 100644 index 0000000..c14531d Binary files /dev/null and b/lib/axis2-saaj-1.6.2.jar differ diff --git a/lib/axis2-soapmonitor-servlet-1.6.2.jar b/lib/axis2-soapmonitor-servlet-1.6.2.jar new file mode 100644 index 0000000..276dac7 Binary files /dev/null and b/lib/axis2-soapmonitor-servlet-1.6.2.jar differ diff --git a/lib/axis2-spring-1.6.2.jar b/lib/axis2-spring-1.6.2.jar new file mode 100644 index 0000000..30b9baa Binary files /dev/null and b/lib/axis2-spring-1.6.2.jar differ diff --git a/lib/axis2-transport-http-1.6.2.jar b/lib/axis2-transport-http-1.6.2.jar new file mode 100644 index 0000000..b1dad78 Binary files /dev/null and b/lib/axis2-transport-http-1.6.2.jar differ diff --git a/lib/axis2-transport-local-1.6.2.jar b/lib/axis2-transport-local-1.6.2.jar new file mode 100644 index 0000000..34a7073 Binary files /dev/null and b/lib/axis2-transport-local-1.6.2.jar differ diff --git a/lib/axis2-xmlbeans-1.6.2.jar b/lib/axis2-xmlbeans-1.6.2.jar new file mode 100644 index 0000000..58fba9b Binary files /dev/null and b/lib/axis2-xmlbeans-1.6.2.jar differ diff --git a/lib/fastjson-1.2.9.jar b/lib/fastjson-1.2.9.jar new file mode 100644 index 0000000..839cea3 Binary files /dev/null and b/lib/fastjson-1.2.9.jar differ diff --git a/lib/ojdbc7.jar b/lib/ojdbc7.jar new file mode 100644 index 0000000..811da0f Binary files /dev/null and b/lib/ojdbc7.jar differ diff --git a/lib/swingx-1.6.1.jar b/lib/swingx-1.6.1.jar new file mode 100644 index 0000000..b0bcc87 Binary files /dev/null and b/lib/swingx-1.6.1.jar differ diff --git a/plugin.xml b/plugin.xml new file mode 100644 index 0000000..147f042 --- /dev/null +++ b/plugin.xml @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/com/connor/hs2/plm/PFMEA/create/CreateNewBOHandler.java b/src/com/connor/hs2/plm/PFMEA/create/CreateNewBOHandler.java new file mode 100644 index 0000000..f6905e8 --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/create/CreateNewBOHandler.java @@ -0,0 +1,194 @@ +//package com.connor.hs2.plm.PFMEA.create; +// +//import org.eclipse.core.commands.AbstractHandler; +//import org.eclipse.core.commands.ExecutionEvent; +//import org.eclipse.core.commands.ExecutionException; +//import org.eclipse.core.runtime.CoreException; +//import org.eclipse.core.runtime.IConfigurationElement; +//import org.eclipse.core.runtime.IExecutableExtension; +//import org.eclipse.swt.widgets.Shell; +//import org.eclipse.ui.IWorkbenchWindow; +//import org.eclipse.ui.handlers.HandlerUtil; +//import org.eclipse.jface.dialogs.MessageDialog; +//import org.eclipse.jface.viewers.ISelection; +//import org.eclipse.jface.viewers.StructuredSelection; +//import org.eclipse.jface.wizard.Wizard; +//import org.eclipse.jface.wizard.WizardDialog; +// +//import com.teamcenter.rac.aif.AIFDesktop; +//import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +//import com.teamcenter.rac.aifrcp.AIFUtility; +//import com.teamcenter.rac.aifrcp.SelectionHelper; +//import com.teamcenter.rac.kernel.TCSession; +// +//import com.teamcenter.rac.ui.commands.Messages; +//import com.teamcenter.rac.ui.commands.RACUICommandsActivator; +//import com.teamcenter.rac.ui.commands.create.bo.NewBOModel; +//import com.teamcenter.rac.ui.commands.create.bo.NewBOWizard; +//import com.teamcenter.rac.ui.commands.handlers.NewBOHandler; +// +//import com.teamcenter.rac.util.SWTUIUtilities; +//import com.teamcenter.rac.util.UIUtilities; +//import com.teamcenter.rac.util.wizard.extension.BaseExternalWizardDialog; +//import com.teamcenter.rac.util.wizard.extension.WizardExtensionHelper; +// +///** +// * Our sample handler extends AbstractHandler, an IHandler base class. +// * +// * @see org.eclipse.core.commands.IHandler +// * @see org.eclipse.core.commands.AbstractHandler +// */ +//public class CreateNewBOHandler extends AbstractHandler implements +// IExecutableExtension { +// private String itemtype; +// +// public CreateNewBOHandler(String itemtype) { +// this.itemtype = itemtype; +// } +// +// private class CreateNewBOSWTDialog implements Runnable { +// +// public void run() { +// NewBOWizard newbowizard = (NewBOWizard) getWizard(); +// if (newbowizard == null) +// newbowizard = new NewBOWizard(wizardId); +// m_boModel.setSession(session); +// m_boModel.reInitializeTransientData(); +// newbowizard.setBOModel(m_boModel); +// newbowizard.setShell(m_shell); +// newbowizard.setParentFrame(AIFUtility.getActiveDesktop()); +// newbowizard.setTargetArray(selectedCmps); +// newbowizard.setCurrentSelection(m_currentSelection); +// newbowizard.setWindowTitle(getWizardTitle()); +// newbowizard.setRevisionFlag(m_revisionFlag); +// newbowizard.setDefaultType(m_type); +// // newbowizard.setWizardId("123"); +// Shell shell = UIUtilities.getCurrentModalShell(); +// dialog = new BaseExternalWizardDialog(m_shell, newbowizard); +// dialog.create(); +// newbowizard.retrievePersistedDialogSettings(dialog); +// newbowizard.setWizardDialog(dialog); +// UIUtilities.setCurrentModalShell(dialog.getShell()); +// dialog.open(); +// dialog = null; +// m_boModel = null; +// UIUtilities.setCurrentModalShell(shell); +// System.out.println("关闭"); +// } +// +// private final Shell m_shell; +// private final boolean m_revisionFlag; +// private final String m_type; +// final CreateNewBOHandler this$0; +// +// private CreateNewBOSWTDialog(Shell shell, boolean flag, String s) { +// super(); +// this$0 = CreateNewBOHandler.this; +// m_shell = shell; +// m_revisionFlag = flag; +// m_type = s; +// } +// +// CreateNewBOSWTDialog(Shell shell, boolean flag, String s, +// CreateNewBOSWTDialog createnewboswtdialog) { +// this(shell, flag, s); +// } +// } +// +// public Object execute(ExecutionEvent executionevent) +// throws ExecutionException { +// if (executionevent == null) +// throw new IllegalArgumentException("Event can't be null"); +// boolean flag = false; +// if (executionevent.getParameters() != null +// && executionevent.getParameters().containsKey("selection")) { +// Object obj = executionevent.getParameters().get("selection"); +// if (obj instanceof InterfaceAIFComponent[]) { +// selectedCmps = (InterfaceAIFComponent[]) obj; +// m_currentSelection = new StructuredSelection(selectedCmps); +// flag = true; +// } +// } +// if (!flag) { +// m_currentSelection = HandlerUtil +// .getCurrentSelection(executionevent); +// selectedCmps = SelectionHelper +// .getTargetComponents(m_currentSelection); +// } +// m_boModel = getBOModel(); +// try { +// session = (TCSession) RACUICommandsActivator.getDefault() +// .getSession(); +// } catch (Exception _ex) { +// session = (TCSession) AIFUtility.getDefaultSession(); +// } +// launchWizard(executionevent); +// return null; +// } +// +// public void setInitializationData( +// IConfigurationElement iconfigurationelement, String s, Object obj) +// throws CoreException { +// } +// +// protected NewBOModel getBOModel() { +// if (m_boModel == null) +// m_boModel = new NewBOModel(this); +// return m_boModel; +// } +// +// public Wizard getWizard() { +// if (wizardId == null || wizardId.length() == 0) +// wizardId = "com.teamcenter.rac.ui.commands.create.bo.NewBOWizard"; +// return WizardExtensionHelper.getWizard(wizardId); +// } +// +// public String getWizardTitle() { +// return Messages.getString("wizard.TITLE"); +// } +// +// public void launchWizard() { +// launchWizard(null); +// } +// +// public void launchWizard(ExecutionEvent executionevent) { +// boolean flag = false; +// // String s = "RT4Item"; +// if (executionevent != null && executionevent.getParameters() != null) { +// if (executionevent.getParameters().containsKey("revisionFlag")) +// flag = ((Boolean) executionevent.getParameters().get( +// "revisionFlag")).booleanValue(); +// // s = (String)executionevent.getParameters().get("objectType"); +// if (executionevent.getParameters().containsKey("pasteRelation")) { +// String s1 = (String) executionevent.getParameters().get( +// "pasteRelation"); +// if (s1 != null) { +// String as[] = null; +// as = s1.split(","); +// m_boModel.setRelType(as[0]); +// m_boModel.setPreAssignedRelType(as); +// } +// } +// } +// +// +// AIFDesktop aifdesktop = AIFUtility.getActiveDesktop(); +// Shell shell = aifdesktop.getShell(); +// if (shell != null) +// // if(itemtype!=null) +// SWTUIUtilities.asyncExec(new CreateNewBOSWTDialog(shell, flag, +// itemtype, null)); +// } +// +// protected void readDisplayParameters(NewBOWizard newbowizard, +// WizardDialog wizarddialog) { +// newbowizard.retrievePersistedDialogSettings(wizarddialog); +// } +// +// protected InterfaceAIFComponent selectedCmps[]; +// protected ISelection m_currentSelection; +// protected String wizardId; +// protected BaseExternalWizardDialog dialog; +// protected TCSession session; +// protected NewBOModel m_boModel; +//} diff --git a/src/com/connor/hs2/plm/PFMEA/create/CreatePFMEAHandler.java b/src/com/connor/hs2/plm/PFMEA/create/CreatePFMEAHandler.java new file mode 100644 index 0000000..5269325 --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/create/CreatePFMEAHandler.java @@ -0,0 +1,316 @@ +package com.connor.hs2.plm.PFMEA.create; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.util.CreateNewBOHandler; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +import java.awt.Dimension; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.util.Arrays; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JTextField; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; + +import org.eclipse.core.commands.AbstractHandler; + +public class CreatePFMEAHandler extends AbstractHandler{ // implements DocumentListener + + private TCComponentItemRevision itemRevision; + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + + + + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + + TCSession session =(TCSession) app.getSession(); + + String type = targetComponent.getType(); + + if(type.equals("ZF6_ZCTRevision")) { + + itemRevision = (TCComponentItemRevision)targetComponent; + + new Thread() { + + public void run() { + + JFrame frame = new JFrame(); + + frame.setLayout(new PropertyLayout()); + + frame.setPreferredSize(new Dimension(450,150)); + + JTextField textField = new JTextField(); +// textName.setEditable(false); + textField.setPreferredSize(new Dimension(300,20)); + JButton btn = new JButton("指派"); + frame.add("1.1.left.center",new JLabel (" ID: ")); + frame.add("1.2.left.center",textField); + frame.add("1.3.left.center",btn); +// btn.add +// btn.getDocument().addDocumentListener(this); + btn.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + try { + String zctId = itemRevision.getStringProperty("item_id"); + + TCComponentItemType itemTypeComp = (TCComponentItemType) session.getTypeComponent("ZF6_PFMEA"); + + String pfmeaId = "HZF-PF-"+zctId+"-"; + + int ids = getItemRevision(session,pfmeaId); + + while(true) { + + ids = ids+1; + + String format = String.format("%03d", ids); + + String idString = pfmeaId+format; + + TCComponentItem find = itemTypeComp.find(idString); + + if(find==null) { + pfmeaId = idString; + break; + } + + } + + textField.setText(pfmeaId); + textField.setEditable(false); + + } catch (Exception er) { + // TODO Auto-generated catch block + er.printStackTrace(); + } + } + }); + frame.add("2.1.left.center",new JLabel (" 名称: ")); + + JTextField textField2 = new JTextField(); +// textName.setEditable(false); + textField2.setPreferredSize(new Dimension(300,20)); + frame.add("2.2.left.center",textField2); + JButton btn1 = new JButton("完成"); + btn1.setEnabled(false); + textField2.getDocument().addDocumentListener(new DocumentListener() { + + @Override + public void removeUpdate(DocumentEvent e) { + // TODO Auto-generated method stub + if(!textField2.getText().trim().equals("")) { + btn1.setEnabled(true); + }else { + btn1.setEnabled(false); + } + } + + @Override + public void insertUpdate(DocumentEvent e) { + // TODO Auto-generated method stub + if(!textField2.getText().trim().equals("")) { + btn1.setEnabled(true); + }else { + btn1.setEnabled(false); + } + } + + @Override + public void changedUpdate(DocumentEvent e) { + // TODO Auto-generated method stub + if(!textField2.getText().trim().equals("")) { + btn1.setEnabled(true); + }else { + btn1.setEnabled(false); + } + } + }); + + JButton btn2 = new JButton("取消"); + btn1.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + try { + TCComponentItemType itemTypeComp = (TCComponentItemType) session.getTypeComponent("ZF6_PFMEA"); + + TCComponentItem create = itemTypeComp.create(textField.getText(), itemTypeComp.getNewRev(null) ,"ZF6_PFMEA",textField2.getText() , "", null); + String obName = create.getStringProperty("object_string"); + textField.setText(""); + textField2.setText(""); + btn1.setEnabled(false); + Boolean flag = false; + String folderName = ""; +// MessageBox.post("创建完成","提示",2); + String userId = session.getUser().getUserId(); + AIFComponentContext[] whereReferenced = itemRevision.getItem().whereReferenced(); + for(AIFComponentContext context:whereReferenced) { + + InterfaceAIFComponent component = context.getComponent(); + + if(component instanceof TCComponentFolder) { + + TCComponentFolder folder = (TCComponentFolder)component; + + String userName = folder.getReferenceProperty("owning_user") + .getStringProperty("user_id"); + if(userId.equals(userName)) { + flag = true; + folderName = folder.getStringProperty("object_name"); + folder.add("contents", create); + break; + } + } + } + + if(flag) { + MessageBox.post(obName+"创建到了"+folderName+"文件夹下","提示",2); + }else { + session.getUser().getHomeFolder().add("contents", create); + MessageBox.post(obName+"创建到了HOME下","提示",2); + } + + + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + } + }); + btn2.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + frame.dispose(); + + } + }); + frame.add("3.1.left.center",btn1); + frame.add("3.2.left.center",btn2); + Toolkit toolkit = Toolkit.getDefaultToolkit(); + + int x = (int)(toolkit.getScreenSize().getWidth()-frame.getWidth())/2; + + int y = (int)(toolkit.getScreenSize().getHeight()-frame.getHeight())/2; + + frame.setLocation(x, y); + frame.pack(); + frame.setResizable(false); + frame.show(); + + } + + + }.start(); + + +// CreateNewBOHandler handler = new CreateNewBOHandler("ZF6_PFMEA"); +// handler.execute(arg0); + + + }else { + MessageBox.post("请选中ZF6_ZCTRevision对象","提示",2); + } + + + return null; + } + public static int getItemRevision(TCSession session, String itemId) throws Exception { + System.out.println("Search Revision: " + itemId ); + if (isEmpty(itemId)) { + return 0; + } else { + String queryName = "Item Revision..."; + String[] keys = new String[]{getText(session, "ItemID")}; + String[] vals = new String[]{itemId}; + TCComponent[] res = query(session, queryName, keys, vals); + + if(res==null) { + return 0; + } + + return res.length; + + } + } + public static boolean isEmpty(String str) { + return str == null || "".equals(str.trim()); + } + public static String getText(TCSession session, String str) throws Exception { + if (isEmpty(str)) { + return str; + } else { + String res = session.getTextService().getTextValue(str); + return !isEmpty(res) ? res : str; + } + } + public static TCComponent[] query(TCSession session, String queryName, String[] keys, String[] vals) + throws Exception { + System.out.println("Query: " + queryName); + System.out.println("keys = " + Arrays.toString(keys)); + System.out.println("vals = " + Arrays.toString(vals)); + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + System.out.println("null"+queryName); + } else { + query.clearCache(); + query.refresh(); + return query.execute(keys, vals); + } + return null; + } +// @Override +// public void insertUpdate(DocumentEvent e) { +// // TODO Auto-generated method stub +// +// } +// @Override +// public void removeUpdate(DocumentEvent e) { +// // TODO Auto-generated method stub +// +// } +// @Override +// public void changedUpdate(DocumentEvent e) { +// // TODO Auto-generated method stub +// +// } +} diff --git a/src/com/connor/hs2/plm/PFMEA/create/Test.java b/src/com/connor/hs2/plm/PFMEA/create/Test.java new file mode 100644 index 0000000..ab43a66 --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/create/Test.java @@ -0,0 +1,49 @@ +package com.connor.hs2.plm.PFMEA.create; + +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.DataFlavor; + +public class Test { + + public static void main(String[] args) { + + Clipboard system = Toolkit.getDefaultToolkit().getSystemClipboard(); + String transferData=""; + try { +// String trstring= (String)(system.getData(DataFlavor.allHtmlFlavor)); +// Clipboard system = Toolkit.getDefaultToolkit().getSystemClipboard(); + String trstring= (String)(system.getData(DataFlavor.allHtmlFlavor)); + +// System.out.println("String is:"+trstring);. + String[] split = trstring.split("")[2]); +// String[] values = trstring.split("\""); +// StringBuffer sb = new StringBuffer(); +// //替换Excel中的换行符 +// for (int i = 0; i < values.length; i++) { +// System.out.println(i+values[i]); +// if(i % 2 ==0 && values[i].indexOf("\n") >= 0) +// { +// sb.append(values[i].replace("\n", " $")); +// } +// else +// { +// sb.append(values[i]); +// } +// //System.out.println(i+s[i]); +// } +// System.out.println("sb======"+sb.toString()); +// String copyValue = sb.toString(); +// String[] st1=copyValue.split("\\$"); //new StringTokenizer(sb.toString(),"$".toString()); +// for(int ) + }catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + + } + +} diff --git a/src/com/connor/hs2/plm/PFMEA/design/DesignPFMEACommand.java b/src/com/connor/hs2/plm/PFMEA/design/DesignPFMEACommand.java new file mode 100644 index 0000000..2848a57 --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/design/DesignPFMEACommand.java @@ -0,0 +1,786 @@ +package com.connor.hs2.plm.PFMEA.design; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.UUID; + +import javax.swing.JFrame; +import javax.swing.JProgressBar; +import javax.swing.plaf.metal.MetalProgressBarUI; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.commands.reserve.ReserveOperation; +import com.teamcenter.rac.kernel.TCAccessControlService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentMEProcess; +import com.teamcenter.rac.kernel.TCComponentRole; +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.MessageBox; + +public class DesignPFMEACommand extends AbstractAIFCommand { + + private TCSession session; + private AbstractAIFApplication app; + private InterfaceAIFComponent comp; + private TCComponentItem meprocess; + private TCComponentItemRevision pfmeaRev; + private TCComponentItem item; + private boolean isOwning = false; + private JFrame frame = new JFrame("正在加载...");//进度条窗口 + private JProgressBar progressBar = new JProgressBar();//进度条 + private String[] properName = new String[] { + "hs2_companyName",//公司名称 + "hs2_project", // 项目 + "hs2_address",// 制造地址 + "hs2_pfmeaStart_date",// PFMEA开始日期 + "hs2_pfmeaUpdate_date",// PFMEA修订日期 + "hs2_processDuty",// 过程职责 + "hs2_customerName",// 顾客名称 + "hs2_pfmeaKey_date",// 保密级别 + "hs2_modelPlatform",// 车型/平台 + "hs2_functionalTeams" // 跨职能团队 + ,"hs2_productCode"};//产品零件号 + + private Map combineMap = new HashMap();// 存放合并单元格 + //private Map combineMap2 = new HashMap();// 存放合并单元格 +// private TCProperty[] properties; + private TCProperty[] itemProperties; + // private List> processRowList = new + // ArrayList>(); + private List processRows = new ArrayList(); + private TCComponentUser user;// 当前登录用户 + private List> dataList = new ArrayList>();// 表格PFMEA中的数据 + private List> dataList2 = new ArrayList>();// 表格PFMEA经验数据库中的数据 + + private List plmeidList = new ArrayList();// 工序对象的ItemId + private String UID; + private boolean isRelease=false; + private boolean isReimport; + public DesignPFMEACommand() { + super(); + } + + public DesignPFMEACommand(AbstractAIFApplication app, TCSession session,String UID, + TCComponentItem meprocess,boolean isReimport,TCComponent comp) { + this.session = session; + this.app = app; + this.comp = comp; + this.pfmeaRev = (TCComponentItemRevision)comp; + this.user = session.getUser(); + this.UID=UID; + this.meprocess = meprocess; + this.isReimport = isReimport; + } + /** + * 获取数据库中的数据 + */ + private void getData() { + // TODO Auto-generated method stub + ResultSet rs = null; + ResultSet rs2 = null; + ResultSet rs21 = null; + InputStream input = null; + try { + // 获取数据库连接 + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + if (meprocess != null) { + String sql = String.format(pro.getProperty("SETPFMEASELECT"), + meprocess.getUid(),comp.getUid()); + rs = SqlUtilT.read(sql); + String sql2 = String.format(pro.getProperty("PFMEALIBRARYSELECT2"), + comp.getUid()); + rs2 = SqlUtilT.read(sql2); + //表格1数据 + int num=rs.getFetchSize()/80; + int num1=1; + int num2=0; + while (rs.next()) { + //++++ + if(num2==num*num1) { + progressBar.setValue(num1+10); + num1++; + } + num2++; + //+++ + List rowList = new ArrayList(); + rowList.add(rs.getString("PLMEID")); + rowList.add(rs.getString("GYBH"));//GYBH放“问题”数据 + rowList.add(rs.getString("GCMC"));//GCMC放历史变更授权数据 + rowList.add(rs.getString("STATION")); + rowList.add(rs.getString("REQUIREMENT")); + rowList.add(rs.getString("QZSXMS")); + rowList.add(rs.getString("QZSXHG")); + rowList.add(rs.getString("YZD")); + rowList.add(rs.getString("JB")); + rowList.add(rs.getString("QZSXQY")); + rowList.add(rs.getString("XXGCKZYF")); + rowList.add(rs.getString("PDS")); + rowList.add(rs.getString("XXGCKZTC")); + rowList.add(rs.getString("TCD")); + rowList.add(rs.getString("RPN")); + rowList.add(rs.getString("JYCS")); + rowList.add(rs.getString("ZZR")); + rowList.add(rs.getString("JHWCRQ")); + rowList.add(rs.getString("CQDCS")); + rowList.add(rs.getString("NEW_SEV")); + rowList.add(rs.getString("NEW_OCC")); + rowList.add(rs.getString("NEW_DET")); + rowList.add(rs.getString("NEW_RPN")); + rowList.add(rs.getString("IDEAL_STATE")); + rowList.add(rs.getString("SPECIAL")); + rowList.add(rs.getInt("HH"));//25 + rowList.add(rs.getString("HBDYG"));//26 + rowList.add(rs.getInt("HHC"));//27 + rowList.add(rs.getString("OCCURRRENCE")); + rowList.add(rs.getString("DETECTION")); + rowList.add(rs.getString("PRIORITY")); + rowList.add(rs.getString("P1")); + rowList.add(rs.getString("P2")); + rowList.add(rs.getString("P3")); + rowList.add(rs.getString("P4")); + rowList.add(rs.getString("P5")); + rowList.add(rs.getString("NO")); + dataList.add(rowList); + } + + //表格2数据 + while(rs2.next()) { + List rowList2=new ArrayList(); + rowList2.add(rs2.getString("PLMID")); + rowList2.add(rs2.getString("NUM")); + rowList2.add(rs2.getString("P1")); + rowList2.add(rs2.getString("P2")); + rowList2.add(rs2.getString("P3")); + rowList2.add(rs2.getString("P4")); + rowList2.add(rs2.getString("P5")); + rowList2.add(rs2.getString("P6")); + rowList2.add(rs2.getString("P7")); + rowList2.add(""); + rowList2.add(""); +// rowList2.add(rs2.getString("HBDYG")); //9 +// Integer sscInteger=rs2.getInt("HHC"); +// rowList2.add(sscInteger.toString()); //10 + dataList2.add(rowList2); + } + System.out.println("dataList2.size()"+dataList2.size()); + if(dataList2.size()==0) { + Date now = new Date(); +// SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//可以方便地修改日期格式 + SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyyMMddHHmmss"); + String time = dateFormat1.format(now); + UUID uuid = UUID.randomUUID(); + String uid=uuid.toString().replace("-", ""); + //插入数据到数据库 + String insert = "insert into AHMC_PFMEALIBRARY values(?,?,?,?,?,?,?,?,?,?,?,?)"; + SqlUtilT.getTCConnection(); + SqlUtilT.write(new String[] {uid,comp.getUid(),null,null,null,null,null,null,null,null,null,time} + ,insert); + List rowList2=new ArrayList(); + rowList2.add(uid); + rowList2.add(time); + rowList2.add(""); + rowList2.add(""); + rowList2.add(""); + rowList2.add(""); + rowList2.add(""); + rowList2.add(""); + rowList2.add(""); + rowList2.add(""); + rowList2.add(""); + dataList2.add(rowList2); + } + // 将表中的行重新排序,并获取当前用户可修改的行号 + String userName = pfmeaRev.getReferenceProperty("owning_user") + .getStringProperty("user_id"); +// // 判断是否发布 +// boolean isRelease = item.getLatestItemRevision().getProperty( +// "release_status_list") != ""; + + //+++ + for (int i = 0; i < dataList.size(); i++) { + // 行号差 +// dataList.get(i).set(27,i- Integer.parseInt(dataList.get(i).get(25).toString())); + if(user.getGroups()[0].getGroupName().equals("dba")) + { + isOwning = true; + processRows.add(i); + plmeidList.add(dataList.get(i).get(0).toString()); + continue; + } + else if (isRelease && !user.getGroups()[0].getGroupName().equals("dba")) + { + continue; + } + if (user.getUserId().equals(userName)) { + isOwning = true; + processRows.add(i); + plmeidList.add((String) dataList.get(i).get(0)); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + + + public void getCombineMap() { + try { + if (dataList != null && dataList.size() > 0) { + for (int i = 0; i < dataList.size(); i++) { + if (dataList.get(i).get(26) != null + && !dataList.get(i).get(26).equals("")) { + String sombine = dataList.get(i).get(26).toString(); + int rowDif = Integer.parseInt(dataList.get(i).get(27) + .toString()); + String[] sombines; + if (sombine.indexOf("-") >= 0) { + sombines = sombine.split("-"); + } else { + sombines = new String[] { sombine }; + } + for (int j = 0; j < sombines.length; j++) { + if (sombines[j].indexOf("/") >= 0) { + int[] row; + int[] cloumn; + String[] cells = sombines[j].split("/"); + if (cells[0].indexOf(",") >= 0) { + String[] rows = cells[0].split(","); + row = new int[rows.length]; + for (int k = 0; k < rows.length; k++) { + row[k] = Integer.parseInt(rows[k]) + + rowDif; + } + } else { + row = new int[] { Integer + .parseInt(cells[0]) + rowDif }; + } + if (cells[1].indexOf(",") >= 0) { + String[] cloumns = cells[1].split(","); + cloumn = new int[cloumns.length]; + for (int k = 0; k < cloumns.length; k++) { + cloumn[k] = Integer + .parseInt(cloumns[k]); + } + } else { + cloumn = new int[] { Integer + .parseInt(cells[1]) }; + } + this.combineMap.put(row, cloumn); + } + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public void executeModal() throws Exception { + //+++++++判断是否发布 + isRelease= comp.getProperty( + "release_status_list") != ""; + //++++如果没发布isRelease为false就看是否有写的权限 + if(!isRelease) { + try { + TCComponentUser user = session.getUser(); + TCComponentGroup group = session.getCurrentGroup(); + TCComponentRole role = session.getCurrentRole(); + + TCComponent coms[] = { user, group, role }; + TCAccessControlService service = session + .getTCAccessControlService(); + boolean[] flags = service.checkAccessorsPrivileges(coms, (TCComponent) app.getTargetComponent(), + new String[] { "WRITE" }); + for (boolean b : flags) { + if (!b) { + //没有写的权限就让isRelease为true,就不让其编辑 + isRelease = true; + break; + } + } + } catch (TCException e) { + e.printStackTrace(); + } + } + if(!isRelease) { + //判断是否打开签出 + if(((TCComponent) comp).isCheckedOut()) { + MessageBox.post("PFMEA正在编辑!(已签出)", "错误", MessageBox.ERROR); + return; + } + //没签出则在打开时签出对象 + new ReserveOperation(new AIFComponentContext(comp, + comp, "context")).executeModeless(); + } + + + + // 获取版本表单的所有者 + try { + + + //+++添加进度条 + frame.setSize(300, 70); + frame.setLocationRelativeTo(null); + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + frame.setLayout(new BorderLayout()); + progressBar.setOrientation(JProgressBar.HORIZONTAL); + progressBar.setSize(300, 50); + progressBar.setMinimum(0); + progressBar.setMaximum(100); + progressBar.setBorderPainted(true); + progressBar.setUI(new MetalProgressBarUI()); + progressBar.setBackground(Color.white); + progressBar.setForeground(Color.green); + progressBar.setStringPainted(true); + frame.setAlwaysOnTop(true); + frame.add(progressBar); + frame.setVisible(true); + progressBar.setValue(1); + //+++ + // 获取数据库连接 + ResultSet rs0 = null; + ResultSet rs = null; +// InputStream input = null; + SqlUtilT.getTCConnection(); + InputStream input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + + String revisionID=app.getTargetComponent().getProperty("item_revision_id"); + TCComponent[] Revisions=(((TCComponent) comp).getReferenceListProperty("revision_list")); + + //查看选中目标是否是第一次打开,是新修订的版本就把最新版本的数据复制给他 + String sql0 = String.format(pro.getProperty("SETPFMEASELECT"), + meprocess.getUid(),comp.getUid()); + rs0 = SqlUtilT.read(sql0); + + int revs = ((TCComponentItemRevision)comp).getItem().getReferenceListProperty("revision_list").length; + if(!revisionID.equalsIgnoreCase("01")&&!rs0.next()&&revs>1) { + List> addData=new ArrayList>(); + try { + SqlUtilT.getTCConnection(); + String sql = String.format(pro.getProperty("SETPFMEASELECT"), + meprocess.getUid(),Revisions[Revisions.length-2].getUid()); + rs = SqlUtilT.read(sql); + while (rs.next()) { + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(rs.getString("PROCESSPUID")); + rowList.add(rs.getString("MEOPID")); + rowList.add(rs.getString("GYBH")); + rowList.add(rs.getString("GCMC")); + rowList.add(rs.getString("STATION")); + rowList.add(rs.getString("REQUIREMENT")); + rowList.add(rs.getString("QZSXMS")); + rowList.add(rs.getString("QZSXHG")); + rowList.add(rs.getString("YZD")); + rowList.add(rs.getString("JB")); + rowList.add(rs.getString("QZSXQY")); + rowList.add(rs.getString("XXGCKZYF")); + rowList.add(rs.getString("PDS")); + rowList.add(rs.getString("XXGCKZTC")); + rowList.add(rs.getString("TCD")); + rowList.add(rs.getString("RPN")); + rowList.add(rs.getString("JYCS")); + rowList.add(rs.getString("ZZR")); + rowList.add(rs.getString("JHWCRQ")); + rowList.add(rs.getString("CQDCS")); + rowList.add(rs.getString("NEW_SEV")); + rowList.add(rs.getString("NEW_OCC")); + rowList.add(rs.getString("NEW_DET")); + rowList.add(rs.getString("NEW_RPN")); + rowList.add(rs.getString("IDEAL_STATE")); +// Integer ssInteger=rs.getInt("HH"); + rowList.add(rs.getString("HH"));//rowList.add(rs.getInt("HH")); + rowList.add(rs.getString("HBDYG")); +// Integer sscInteger=rs.getInt("HHC"); + rowList.add(rs.getString("HHC"));//rowList.add(rs.getInt("HHC")); + rowList.add(rs.getString("SPECIAL")); + rowList.add(rs.getString("TYPE")); + rowList.add(rs.getString("BAK")); + rowList.add(rs.getString("OCCURRRENCE")); + rowList.add(rs.getString("DETECTION")); + rowList.add(rs.getString("PRIORITY")); + rowList.add(rs.getString("P1")); + rowList.add(rs.getString("P2")); + rowList.add(rs.getString("P3")); + rowList.add(rs.getString("P4")); + rowList.add(rs.getString("P5")); + rowList.add(comp.getUid());//选择的对象的puid放在数据库的REVISIONID中 + rowList.add(rs.getString("NO")); + addData.add(rowList); + } + }catch (Exception e) { + MessageBox.post(e.toString(), "错误", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + System.out.println(addData.toString()); + for(int i=0;i data=new ArrayList(); + data=addData.get(i); + String[] dataString=data.toArray(new String[]{}); + SqlUtilT.getTCConnection(); + String insertSQL = pro.getProperty("INSERTPFMEA"); + SqlUtilT.write(dataString, insertSQL); + } + + getPropertys(Revisions[Revisions.length-2].getUid(),comp.getUid()); + + } + progressBar.setValue(5); + //++++++++ + if(!isRevise) { + getPropertys(); + } + + progressBar.setValue(10); + + if(isReimport) { + Map MEOPIDToNO = new HashMap();//工序名称与ID + List meops = new ArrayList();// 数据库中的工序ID + List meopNos = new ArrayList();// 数据库中的工序ID + List meoplist = new ArrayList();// 数据库中的工序ID + String sql = String.format(pro.getProperty("SETPFMEASELECT"), + meprocess.getUid(),comp.getUid()); + ResultSet read = SqlUtilT.read(sql); + while (read.next()) { + + MEOPIDToNO.put(read.getString("P4"), read.getString("P5")); + meoplist.add(read.getString("P4")); + + } + if(read!=null) { + read.close(); + } + SqlUtilT.freeAll(); + List> properties = TMomMethodUtil.getPFMEABomPropertys(session, meprocess); + for(List propertie:properties) { + meops.add(propertie.get(propertie.size()-2)); + meopNos.add(propertie.get(1)); + } + + for(int i=0;i=0 ? properties.get(i).get(2).replace("/", "\n") : properties.get(i).get(2)),"", + "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "","", "", "", "", "", "","","","","","","",properties.get(i).get(properties.get(i).size()-2),properties.get(i).get(1) ,comp.getUid(),properties.get(i).get(4)}, + insertPFMEA); + + } + + } + + } + + + //未添加工序则无数据 + getData(); + if(dataList==null||dataList.size()==0) { + //没发布的版本要同步bom更新 + if(comp.getProperty("release_status_list")==null||((TCComponent)comp).getReferenceListProperty("release_status_list").length==0) { + System.out.println("未发布"); + SavePfmea savePfmea = new SavePfmea(session, meprocess,comp); + savePfmea.insertData(); + } + dataList2.clear(); + getData(); + } + //System.out.println("=========dataList为:"+dataList.toString()); + getCombineMap(); +// if (properties == null) { +// return; +// } + + //获取属性 + final PFMEABean pfmeaBean = new PFMEABean(); + pfmeaBean.setPfmeaNumber(pfmeaRev.getStringProperty("item_id")); + + progressBar.setValue(95); + + progressBar.setValue(96); +// 项目名称获取产品对象的客户项目号rb3_khxmh, + +// 编制日期对应第一个版本的编制日期rb3_bianzhiriqi, +// 更改日期对应最新发布版本的版本表单上的编制日期, + +// 编制对应PFMEA第一个版本表单的编制rb3_bianzhi, +// 增加产品型号,对应产品的item_id, +// 客户图号对应产品对象属性rb3_khth, +// PFMEA号对应PFMEA的item_id + //获取PFMEA版本 + + final List> changValueList = new ArrayList>(); + + progressBar.setValue(100); + new Thread() { + @Override + public void run() { + System.out.println("propertyList==>"+propertyList.toString()); + DesignPFMEADialog dialog = new DesignPFMEADialog( + app, session, processRows, + (TCComponentItemRevision) comp, meprocess, + propertyList,pfmeaBean,itemProperties,changValueList, combineMap, dataList,dataList2,plmeidList, + isOwning,UID,firstFlag); + frame.dispose(); + } + }.start(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + super.executeModal(); + } + private boolean isRevise = false; + private boolean firstFlag = false; + List propertyList = new ArrayList(); + private void getPropertys() { + // TODO Auto-generated method stub + +// "hs2_companyName",//公司名称 +// "hs2_project", // 项目 +// "hs2_address",// 制造地址 +// "hs2_pfmeaStart_date",// PFMEA开始日期 +// "hs2_pfmeaUpdate_date",// PFMEA修订日期 +// "hs2_processDuty",// 过程职责 +// "hs2_customerName",// 顾客名称 +// "hs2_pfmeaKey_date",// 保密级别 +// "hs2_modelPlatform",// 车型/平台 +// "hs2_functionalTeams" // 跨职能团队 +// ,"hs2_productCode"};//产品零件号 + + SqlUtilT.getTCConnection(); + ResultSet rs = null; + try { + String sqlString = "select * from AHMC_PROPERTY where COMPUID = '"+comp.getUid()+"'"; + + System.out.println("sqlString ==> "+sqlString); + + rs = SqlUtilT.read(sqlString); + + while (rs.next()) { + + propertyList.add(rs.getString("companyName")); + propertyList.add(rs.getString("project")); + propertyList.add(rs.getString("address")); + propertyList.add(rs.getString("pfmeaStart_date")); + propertyList.add(rs.getString("pfmeaUpdate_date")); + propertyList.add(rs.getString("processDuty")); + propertyList.add(rs.getString("customerName")); + propertyList.add(rs.getString("pfmeaKey_date")); + propertyList.add(rs.getString("modelPlatform")); + propertyList.add(rs.getString("functionalTeams")); + propertyList.add(rs.getString("productCode")); + +// addData.add(rowList); + } + + if(propertyList.size()==0) { + firstFlag = true; + for(int i=0;i<11;i++) { + propertyList.add(""); + } + + } + + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + + SqlUtilT.freeAll(); + } + + } + + private void getPropertys(String oldUid,String newUid) { + // TODO Auto-generated method stub + +// "hs2_companyName",//公司名称 +// "hs2_project", // 项目 +// "hs2_address",// 制造地址 +// "hs2_pfmeaStart_date",// PFMEA开始日期 +// "hs2_pfmeaUpdate_date",// PFMEA修订日期 +// "hs2_processDuty",// 过程职责 +// "hs2_customerName",// 顾客名称 +// "hs2_pfmeaKey_date",// 保密级别 +// "hs2_modelPlatform",// 车型/平台 +// "hs2_functionalTeams" // 跨职能团队 +// ,"hs2_productCode"};//产品零件号 + + SqlUtilT.getTCConnection(); + ResultSet rs = null; + try { + String sqlString = "select * from AHMC_PROPERTY where COMPUID = '"+oldUid+"'"; + + + + System.out.println("sqlString 22 ==> "+sqlString); + + rs = SqlUtilT.read(sqlString); + + while (rs.next()) { + + propertyList.add(rs.getString("companyName")); + propertyList.add(rs.getString("project")); + propertyList.add(rs.getString("address")); + propertyList.add(rs.getString("pfmeaStart_date")); + propertyList.add(rs.getString("pfmeaUpdate_date")); + propertyList.add(rs.getString("processDuty")); + propertyList.add(rs.getString("customerName")); + propertyList.add(rs.getString("pfmeaKey_date")); + propertyList.add(rs.getString("modelPlatform")); + propertyList.add(rs.getString("functionalTeams")); + propertyList.add(rs.getString("productCode")); + +// addData.add(rowList); + } + + if(propertyList.size()==0) { + firstFlag = true; + for(int i=0;i<11;i++) { + propertyList.add(""); + } + } + System.out.println(propertyList +" ==propertyList "); + System.out.println(newUid + "==newUid"); + isRevise =true; +// + + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + + SqlUtilT.freeAll(); + } + SqlUtilT.getTCConnection(); + + try { + +// if(firstFlag) { + + + String sqlString2 = "INSERT INTO AHMC_PROPERTY VALUES(?,?,?,?,?,?,?,?,?,?,?,?)"; + SqlUtilT.write2(new String[] {propertyList.get(0),propertyList.get(1),propertyList.get(2),propertyList.get(3) + ,propertyList.get(4),propertyList.get(5),propertyList.get(6),propertyList.get(7), + propertyList.get(8),propertyList.get(9), + "",newUid},sqlString2); +// } + + + + + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } finally { + try { + SqlUtilT.connection.commit(); + + SqlUtilT.freeAll(); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + } + + + } + +} diff --git a/src/com/connor/hs2/plm/PFMEA/design/DesignPFMEADialog.java b/src/com/connor/hs2/plm/PFMEA/design/DesignPFMEADialog.java new file mode 100644 index 0000000..0676c02 --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/design/DesignPFMEADialog.java @@ -0,0 +1,4939 @@ +package com.connor.hs2.plm.PFMEA.design; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.awt.datatransfer.UnsupportedFlavorException; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.image.BufferedImage; +import java.io.BufferedInputStream; +import java.io.BufferedReader; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.StringReader; +import java.sql.ResultSet; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Properties; +import java.util.ResourceBundle; +import java.util.Set; +import java.util.Timer; +import java.util.TimerTask; +import java.util.UUID; +import java.util.Vector; + +import javax.swing.table.TableColumn; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; +import javax.imageio.ImageIO; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.JTabbedPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.JTextPane; +import javax.swing.JViewport; +import javax.swing.ListCellRenderer; +import javax.swing.ListSelectionModel; +import javax.swing.RowFilter; +import javax.swing.UIManager; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import javax.swing.event.TableModelEvent; +import javax.swing.event.TableModelListener; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; + +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.CellStyle; +import org.apache.poi.ss.usermodel.ClientAnchor; +import org.apache.poi.ss.usermodel.Drawing; +import org.apache.poi.ss.usermodel.Picture; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFClientAnchor; +import org.apache.poi.xssf.usermodel.XSSFDrawing; +import org.apache.poi.xssf.usermodel.XSSFPicture; +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; +import org.jdesktop.swingx.renderer.DefaultTableRenderer; +import org.jdesktop.swingx.renderer.FormatStringValue; +import org.jdesktop.swingx.renderer.StringValue; +import org.jdesktop.swingx.table.DatePickerCellEditor; + +import com.connor.renben.process.plm.util.Adapter; +import com.connor.renben.process.plm.util.Adapter1; +import com.connor.renben.process.plm.util.CTMap; +import com.connor.renben.process.plm.util.CTMap2; +import com.connor.renben.process.plm.util.CTable; +import com.connor.renben.process.plm.util.CTextField; +import com.connor.renben.process.plm.util.ExcelUtil; +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.MultiComboBox; +import com.connor.renben.process.plm.util.MyTableModel; +import com.connor.renben.process.plm.util.TextAreaCellEditor; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCComponentType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +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.services.rac.core.ReservationService; + +public class DesignPFMEADialog extends JFrame implements ActionListener { + private AbstractAIFApplication app; + private InterfaceAIFComponent comp; + private TCSession session; +// private TCProperty[] properties; + private PFMEABean pfmeaBean; + private TCProperty[] itemProperties; + private List> changValueList; + private CTMap map; + private CTMap2 map2; + static JScrollPane scrollPane; + private Timer timer; + + //4 +// private String[] header = new String[] { "PLMEID", "问题", "历史/变更授\n权(适用时)", "1. 过程项系\n统、子系统、\n零件要素或过\n程名称", +// "2. 过程步骤\n工位编号和关\n注要素名称", "3. 过程工作\n要素 4M法", "1.过程项的\n功能系统、子\n系统、组件要\n素或过程的功\n能", "2.过程步骤\n的功能和产品\n特性(量值为\n可选项)", +// "3.过程工作\n要素的功能和\n过程特性", "1.对上一较\n高级别要和\n/或终端用户\n失效影响(F\nE)", "失效影响的严\n重度(S)", "2.关注要素\n的失效模式(\nFM)", "3.工作要素\n的失效起因\n(FC)", +// "对失效起因的\n当前预防控制\n(PC)", "失效起因的频\n度(O)", "对失效起因或\n失效模式的当\n前探测控制(\nDC)", "失效起因/失\n效模式的可探\n测度(D)", "PFMEA措\n施优先级", "产品特性", +// "筛选器代码(\n可选)", "预防措施", "探测措施", "负责人姓名", "目标完成日期", "状态", "采取基于证据\n的措施", "完成日期", "严重度(S)\nSeverity(S)", +// "频度(O)\nOccurrence\n(O)", "可探测度\n(D)\nDetection\n(D)", "产品特性", "PFMEA AP ", "备注","查找编号" }; + private String[] header = new String[] { "PLMEID", "过程名称", "过程步骤(工位编号和关注要素名称)", "过程工作要素4M", + "过程名称的功能", "过程步骤功能和产品特性", "过程工作要素的功能和过程特性", "对上一级系统失\n效影响或最终用\n户的影响(FE)", + "严重度s", "关注要素失效模式FM", "工作要素失效起因FC", "当前的对失效起因的预\n防措施", "失效模式的频度o", + "当前失效模起因/失效模式的探测措施", "探测度D", "PFMEA措施优先级", "特殊特性", "筛选器代码", "预防措施", + "探测措施", "负责人姓名", "目标完成\n日期", "状态", "采取基于证据\n的措施", "完成\n时间", "严重度", + "频度", "探测度","PFMEA措施优化AP", "特殊特性","备注","p","父节点id" }; + private String[] pfmeaHeader = new String[] { "PLMEID", "过程名称", "过程步骤(工位编号和关注要素名称)", "过程工作要素4M", + "过程名称的功能", "过程步骤功能和产品特性", "过程工作要素的功能和过程特性", "对上一级系统失\n效影响或最终用\n户的影响(FE)", + "严重度s", "关注要素失效模式FM", "工作要素失效起因FC", "当前的对失效起因的预\n防措施", "失效模式的频度o", + "当前失效模起因/失效模式的探测措施", "探测度D", "PFMEA措施优先级", "特殊特性", "筛选器代码", "预防措施", + "探测措施", "负责人姓名", "目标完成\n日期", "状态", "采取基于证据\n的措施", "完成\n时间", "严重度", + "频度", "探测度","PFMEA措施优化AP", "特殊特性","备注","p","父节点id"}; + private String[] pfmeaKuHeader = new String[] { "PLMEID", "选择", "过程名称", "过程步骤(工位编号和关注要素名称)", "过程工作要素4M", + "过程名称的功能", "过程步骤功能和产品特性", "过程工作要素的功能和过程特性", "对上一级系统失\n效影响或最终用\n户的影响(FE)", + "严重度s", "关注要素失效模式FM", "工作要素失效起因FC", "当前的对失效起因的预\n防措施", "失效模式的频度o", + "当前失效模起因/失效模式的探测措施", "探测度D", "PFMEA措施优先级", "特殊特性", "筛选器代码", "预防措施", + "探测措施", "负责人姓名", "目标完成\n日期", "状态", "采取基于证据\n的措施", "完成\n时间", "严重度", + "频度", "探测度","PFMEA措施优化AP", "特殊特性" ,"备注","p","父节点id" }; +// private String[] pfmeaHeader = new String[] { "PLMEID", "ID", "1. 过程项" + "系统、子系统、零件要素或过程名称", +// "2. 过程步骤" + "工位编号和关注要素名称", "3. 过程工作要素 4M法", "1.过程项的功能" + "系统、子系统、组件要素或过程的功能", "2.过程步骤的功能和产品特性" + "(量值为可选项)", +// "3.过程工作要素的功能和过程特性", "1.对上一较高级别要和/或终端用户失效影响(FE)", "失效影响的严重度(S)", "2.关注要素的失效模式(FM)", "3.工作要素的失效起因(FC)", +// "对失效起因的当前预防控制(PC)", "失效起因的频度(O)", "对失效起因或失效模式的当前探测控制(DC)", "失效起因/失效模式的可探测度(D)", "PFMEA措施优先级", "产品特性", +// "筛选器代码(可选)", "预防措施", "探测措施", "负责人姓名", "目标完成日期", "状态", "采取基于证据的措施", "完成日期", "严重度(S)Severity(S)", +// "频度(O)Occurrence(O)", "可探测度(D)Detection(D)", "产品特性", "PFMEA AP ", "备注", "父节点ID" }; +// private String[] pfmeaHeader = new String[] { "PLMEID","ID", "Station", "要求", +// "潜在失效模式", "潜在失效后果", "严重度S", "级别", "潜在失效起因/机理", "现行过程控制预防", "频度数O", +// "现行过程控制探测", "探测度D", "RPN", "建议措施", "责任人", "计划完成日期", "采取的措施", +// "New_SEV", "New_OCC", "New_DET", "New_RPN", "Ideal_State", "父节点ID", +// "特殊符号位置" };//,"发生频率","检测频率","优先级"}; + private String[] recordHeader = new String[] { "PLMID","序号","日期", "章节", "修订原因", "修订内容", "修订后版本", "制/修订人", "核准人" }; + private String[] leftHeader = new String[] { "PLMEID", "ID", "名称", "名称" }; + private Map combineMap;// 存放合并单元格 + //private Map combineMap2;// 存放合并单元格 + private Map excelCombineMap = new HashMap();// 存放合并单元格 + private TCComponentItemRevision itemRevision;// 选中对象的版本 + private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-M-dd"); + private TCComponentItem meprocess;// 选中所在的工艺 + // private List> processRowList;//当前用户可修改的行号 + private List processRows;// 当前用户可修改的行号 + private List> dataList; + private List> dataList2; + private List> excelDataList = new ArrayList>(); + private List itemList = new ArrayList(); + private List plmeidList; + private List deleteRows = new ArrayList(); + private SpecialDialog specialDialog; + private LibraryDialog libraryDialog; + private Properties pro = new Properties(); + private boolean isComplete = false; + private boolean isOwning; + private int selectRow = -1; + private int selectColumn = -1; + private int recordSelectRow = -1; + private int recordSelectColumn = -1; + + //表格2菜单 + private static JPopupMenu menu2; + private JMenuItem addItem2; + private JMenuItem remItem2; + private JMenuItem upItem2; + // 判断单元格显示框是否获取焦点 + private boolean isFocusOwner = false; + // 判断履历单元格显示框是否获取焦点 + private boolean recordIsFocusOwner = false; + + // 界面所需控件 + private JPanel titlePanel;// 标题 + private JLabel titleLabel; + + private JPanel mainPanel;// 属性填写 + + private JLabel companyNameLabel;// 公司名称 + private CTextField companyNameField; + private JLabel projectLabel;// 项目 + private CTextField projectField; + private JLabel pfmeaIdLabel;// PFMEA ID编号 + private CTextField pfmeaIdField; + private JLabel addressLabel;// 制造地址 + private CTextField addressField; + + private JLabel pfmeaStartLabel;// PFMEA开始日期 + private DateButton pfmeaStartButton; + private JLabel pfmeaUpdateLabel;// PFMEA修订日期 + private DateButton pfmeaUpdateButton; + private JLabel processDutyLabel;// 过程职责 + private CTextField processDutyField; + + private JLabel customerNameLabel;// 顾客名称 + private JTextField customerNameField; + private JLabel securityClassificationLabel;// 保密级别 + private CTextField securityClassificationField; + private JLabel modelPlatformLabel;// 车型/平台 + private CTextField modelPlatformField; + private JLabel functionalTeamsLabel;// 跨职能团队 + private CTextField functionalTeamsField; +// private JLabel expiryDateLabel; //逾期日期 +// private DateButton expiryDateButton; + + // 显示选中单元格内容 + private JTextPane showValuePane; + private JTextPane showRecordValuePane;// 履历 + + // 标签页 + private JTabbedPane tabbedPane; + // 第一页 + private JPanel firstPanel;// 表格控件 + private static CTable table; + // 第二页 + private int selectMainRow2=-1; + private JPanel secondPanel;// 表格控件 + private JTable table2; + + //设置frameSize + private JButton reSetSize;// 重置界面大小 + //设置frameSize +// private JButton refreshBtn;// 重置界面大小 + private int[] SizeLoca=new int[4]; + private int[] table1Size=new int[29]; + private int[] table2Size=new int[7]; + private int initRowHeight = 50; + private String userName=""; + private String type=""; + private boolean isFirstOpen=false;//判断是否是第一次打开,同时如果是第一次打开,当第一次保存后已向数据库插入了数据isFirstOpen会置false,再保存时就只会更新,不会重复插入 + private boolean isReSet=false; + + + + + // 右键菜单 + private static JPopupMenu menu; + // 右键菜单项 + private JMenuItem openLibarary; + private JMenuItem addRowItem; + private JMenuItem addRowsItem; + private JMenuItem addItem; + private JMenuItem addCombineRowsItem; + private JMenuItem remItem; + private JMenuItem comBineItem; + //private JMenuItem comBineItem2; + private JMenuItem splitItem; + private JMenuItem shrinkColumnItem; + private JMenuItem celShrinkColumnItem; + // private JMenuItem deleteSpecialItem; + private JPanel rootPanel;// 按钮 +// private JButton addButton;// 添加 +// private JButton remButton;// 移除 +// private JButton comBinebutton;// 合并 +// private JButton splitButton;// 拆分 + private JButton saveButton;// 保存 + private JButton completeButton;// 完成 + private JButton clearData;// 完成 + // private JButton addSpecialButton;// 添加特殊符号 +// private JButton deleteSpecialButton;// 移除特殊符号 + private JButton libraryButton;// 打开PFME库 + private JButton RefreshButton;// 删除所有数据后刷新按钮 + private JTextField setHeightTxt;// 删除所有数据后刷新按钮 + private JButton setHeightBtn;// 删除所有数据后刷新按钮 + private String UID; + private boolean firstFlag; + List tstxList = new ArrayList(); + List dsUidList = new ArrayList(); + // PFMEA库 + private List properties; + public DesignPFMEADialog(AbstractAIFApplication app, TCSession session, List processRows, + TCComponentItemRevision itemRevision, TCComponent meprocess, List propertyList, PFMEABean pfmeaBean, + TCProperty[] itemProperties, List> changValueList, Map combineMap, + List> dataList,List> dataList2, List plmeidList, boolean isOwning,String UID + ,boolean firstFlag) { + super(); + // this.processRowList = processRowList; + this.processRows = processRows; + this.dataList = dataList; + this.dataList2 = dataList2; + this.plmeidList = plmeidList; + this.combineMap = combineMap; + //this.combineMap2=combineMap2; + this.itemRevision = itemRevision; + this.meprocess = (TCComponentItem) meprocess; + this.properties = propertyList; + this.pfmeaBean = pfmeaBean; + this.itemProperties = itemProperties; + this.changValueList = changValueList; + this.app = app; + this.session = session; + this.userName=this.session.getUser().toString(); + this.type="PFMEADialog"; + this.isOwning = isOwning; + System.out.println("isOwning ==> "+isOwning); +// this.isOwning=true; + this.UID=UID; + this.firstFlag=firstFlag; + //获取选中对象 + this.comp = app.getTargetComponent(); + runTask(); + TCPreferenceService service = session.getPreferenceService(); + String[] strs = service.getStringValues("ZF6_PFMEA_TSTX"); + + tstxList.add(""); + + for(String str:strs) { + + if(str.contains(":")) { + String[] split = str.split(":"); + tstxList.add(split[0]); + try { + TCComponentDataset ds = (TCComponentDataset) session.stringToComponent(split[1]); + String[] fileNames = ds.getFileNames(""); + if (fileNames.length > 0) { + dsUidList.add(ds.getFile("", fileNames[0], System.getenv("TEMP"))); + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + } + init(); + this.processRows = processRows; + // setProcessRows(this.processRowList); + comBine(); + } + + + public void getFrameSize() { + // 获取数据库连接 + SqlUtilT.getTCConnection(); + ResultSet rs = null; + ResultSet rs0 = null; + InputStream input = null; + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + try { + pro.load(input); + String sql = String.format("select * from AHMC_PFMEAFRAME_SIZE WHERE USERNAME = '%s' AND TYPE = '%s'",userName,type); + rs = SqlUtilT.read(sql); + List rowList = new ArrayList(); + while (rs.next()) { + rowList.add(rs.getString("FRAMESIZE"));//界面大小、位置 + rowList.add(rs.getString("TABLE1SIZE"));//第一个表格的列宽数据 + rowList.add(rs.getString("TABLE2SIZE"));//第二格表格的列宽数据 + rowList.add(rs.getString("ROWHEIGHT"));//第1格表格的行高数据 + break; + } + if(rowList.size()==4) {//解析界面大小,位置,表格列宽数据 + analyticSize(rowList); + }else { + String sql0 = String.format("select * from AHMC_PFMEAFRAME_SIZE WHERE USERNAME = '%s' AND TYPE = '%s'","iniUser",type); + rs0 = SqlUtilT.read(sql0); + while (rs0.next()) { + rowList.add(rs0.getString("FRAMESIZE"));//界面大小、位置 + rowList.add(rs0.getString("TABLE1SIZE"));//第一个表格的列宽数据 + rowList.add(rs0.getString("TABLE2SIZE"));//第二格表格的列宽数据 + rowList.add(rs0.getString("ROWHEIGHT"));//第1格表格的行高数据 + break; + } + if(rowList.size()<=0) { + MessageBox.post("(数据库)未设置界面最初尺寸,请先配置!", "错误", MessageBox.ERROR); + return; + }else { + isFirstOpen=true; + analyticSize(rowList); + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if(rs0 != null) { + SqlUtilT.free(rs0); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } +} + + //解析界面数据 + public void analyticSize(List rowList) { + if(rowList.get(0).indexOf("/")>-1) {//获取界面大小位置 + String[] data=rowList.get(0).split("/"); + for(int i=0;i<4;i++) { + SizeLoca[i]=Integer.parseInt(data[i]); + } + } + if(rowList.get(1).indexOf("/")>-1) { + String[] data=rowList.get(1).split("/"); + for(int i=0;i<29;i++) { + table1Size[i]=Integer.parseInt(data[i]); + } + } + if(rowList.get(2).indexOf("/")>-1) { + String[] data=rowList.get(2).split("/"); + for(int i=0;i<7;i++) { + table2Size[i]=Integer.parseInt(data[i]); + } + } + + if(!rowList.get(3).equals("")) { + initRowHeight = Integer.valueOf(rowList.get(3)); + } + + + } + + + + + public void comBine() { + // TODO Auto-generated method stub + if (combineMap != null && combineMap.size() != 0) { + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + map.combine(entry.getKey(), entry.getValue()); + } + } + + } + +// private JLabel expiryDateLabel; +// private JTextField expiryTextField; + private void init() { + getFrameSize(); + //获取国际化语言 + Locale defaultLocale=Locale.getDefault(); + ResourceBundle rb=ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message",defaultLocale); + this.setTitle(rb.getString("txPFMEA10_display.TITLE")); + // this.setLocationRelativeTo(null); + // this.setUndecorated(true); + this.setPreferredSize(new Dimension(SizeLoca[0], SizeLoca[1])); + this.setLocation(SizeLoca[2], SizeLoca[3]); + this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); + this.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + if(!isOwning) { + DesignPFMEADialog.this.dispose(); + }else { + int i = JOptionPane.showConfirmDialog(null, "是否保存?", "保存", JOptionPane.YES_NO_OPTION); + if (i == JOptionPane.YES_OPTION) { + okEvent(true, true); + DesignPFMEADialog.this.dispose(); + } else if (i == JOptionPane.NO_OPTION) { + DesignPFMEADialog.this.dispose(); + } + } + } + }); + // 初始化标题部分控件 + this.titlePanel = new JPanel(); + this.titleLabel = new JLabel(rb.getString("qzsxmsjhgfx10_display.TITLE")); + this.titleLabel.setFont(new Font("宋体", 1, 18)); + this.titlePanel.add(titleLabel); + // 初始化菜单部分控件 + this.mainPanel = new JPanel(new PropertyLayout()); + this.companyNameLabel = new JLabel(rb.getString("gsmc10_display.TITLE")); + this.companyNameField = new CTextField(this.properties.get(0)); + + this.companyNameField.setPreferredSize(new Dimension(160, 20)); + this.projectLabel = new JLabel("项目"); + this.projectLabel.setPreferredSize(new Dimension(90, 20)); + this.projectField = new CTextField(this.properties.get(1)); + this.projectField.setPreferredSize(new Dimension(160, 20)); + this.pfmeaIdLabel = new JLabel("PFMEA编号");// PFMEA号 + this.pfmeaIdField = new CTextField(this.pfmeaBean.getPfmeaNumber()); + this.pfmeaIdField.setPreferredSize(new Dimension(160, 20)); + this.addressLabel = new JLabel("项目地点"); + this.addressField = new CTextField(this.properties.get(2)); + this.addressField.setPreferredSize(new Dimension(160, 20)); + + this.pfmeaStartLabel = new JLabel("PFMEA开始日期"); + + this.pfmeaStartButton = new DateButton(dateFormat); + this.pfmeaStartButton.setText(this.properties.get(3)); + this.pfmeaStartButton.setPreferredSize(new Dimension(160, 20)); + this.pfmeaUpdateLabel = new JLabel(rb.getString("PFMEAxdrq10_display.TITLE")); + this.pfmeaUpdateLabel.setPreferredSize(new Dimension(90, 20)); + this.pfmeaUpdateButton = new DateButton(dateFormat); + this.pfmeaUpdateButton.setText(this.properties.get(4)); + this.pfmeaUpdateButton.setPreferredSize(new Dimension(160, 20)); + this.processDutyLabel = new JLabel("设计责任"); + this.processDutyLabel.setPreferredSize(new Dimension(80, 20)); + this.processDutyField = new CTextField(this.properties.get(5)); + this.processDutyField.setPreferredSize(new Dimension(160, 20)); + + this.customerNameLabel = new JLabel("客户名称"); + this.customerNameField = new CTextField(this.properties.get(6)); + this.customerNameLabel.setPreferredSize(new Dimension(80, 20)); + this.customerNameField.setPreferredSize(new Dimension(160, 20)); + + this.securityClassificationLabel = new JLabel(rb.getString("bmjb10_display.TITLE")); + this.securityClassificationLabel.setPreferredSize(new Dimension(90, 20)); + this.securityClassificationField =new CTextField(this.properties.get(7)); +// this.securityClassificationField.setText(this.properties.get(7)); + this.securityClassificationField.setPreferredSize(new Dimension(160, 20)); + this.modelPlatformLabel = new JLabel("车型年/平台"); + this.modelPlatformLabel.setPreferredSize(new Dimension(90, 20)); + this.modelPlatformField = new CTextField(this.properties.get(8)); + this.modelPlatformField.setPreferredSize(new Dimension(160, 20)); + this.functionalTeamsLabel = new JLabel("跨功能团队"); + this.functionalTeamsLabel.setPreferredSize(new Dimension(80, 20)); + this.functionalTeamsField = new CTextField(this.properties.get(9)); + this.functionalTeamsField.setPreferredSize(new Dimension(160, 20)); + + this.mainPanel.add("1.1.left.top", this.companyNameLabel); + this.mainPanel.add("1.2.left.top", this.companyNameField); + this.mainPanel.add("1.3.left.top", this.projectLabel); + this.mainPanel.add("1.4.left.top", this.projectField); + this.mainPanel.add("1.5.left.top", this.pfmeaIdLabel); + this.mainPanel.add("1.6.left.top", this.pfmeaIdField); + this.mainPanel.add("1.7.left.top", this.addressLabel); + this.mainPanel.add("1.8.left.top", this.addressField); + + this.mainPanel.add("2.1.left.top", this.pfmeaStartLabel); + this.mainPanel.add("2.2.left.top", this.pfmeaStartButton); + this.mainPanel.add("2.3.left.top", this.pfmeaUpdateLabel); + this.mainPanel.add("2.4.left.top", this.pfmeaUpdateButton); + this.mainPanel.add("2.5.left.top", this.processDutyLabel); + this.mainPanel.add("2.6.left.top", this.processDutyField); + this.mainPanel.add("2.7.left.top", this.customerNameLabel); + this.mainPanel.add("2.8.left.top", this.customerNameField); + + this.mainPanel.add("3.1.left.top", this.securityClassificationLabel); + this.mainPanel.add("3.2.left.top", this.securityClassificationField); + this.mainPanel.add("3.3.left.top", this.modelPlatformLabel); + this.mainPanel.add("3.4.left.top", this.modelPlatformField); + this.mainPanel.add("3.5.left.top", this.functionalTeamsLabel); + this.mainPanel.add("3.6.left.top", this.functionalTeamsField); + + if(isOwning) { + mainPanel.setEnabled(false); + } + JPanel topPanel = new JPanel(new PropertyLayout()); + topPanel.add("1.1.left.top", this.mainPanel); + + this.firstPanel = new JPanel(new BorderLayout()); + this.table = getjTable(null, null, header, null); + for(int i=1;i<=table1Size.length;i++) { + this.table.getColumnModel().getColumn(i).setPreferredWidth(table1Size[i-1]);; + } + this.table.addMouseListener(new MouseAdapter() { + + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + selectMainRow2 = table.getSelectedRow(); + } + }); + TableCellEditor cellEditor = this.table.getColumnModel().getColumn(16).getCellEditor(); //16 29 + + // 添加键盘监听 + this.table.addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(KeyEvent arg0) { + // TODO Auto-generated method stub + //delete键清空 + + if (arg0.getKeyCode() == KeyEvent.VK_DELETE) { + int[] selectRows = table.getSelectedRows(); + int[] selectColumns = table.getSelectedColumns(); + for (int i = 0; i < selectRows.length; i++) { + if (processRows != null && processRows.size() != 0 && !(processRows.contains(selectRows[i]))) { + continue; + } + for (int j = 0; j < selectColumns.length; j++) { + if(selectColumns.length==table.getColumnCount()) {//Ctrl+A全选时 + if(j>0&&j-1) { + if(selectRows= 0) + { + sb.append(values[i].replace("\n", " $")); + } + else + { + sb.append(values[i]); + } + } + //System.out.println("sb++++++++"+sb.toString()); + + if(sb.indexOf("$")>-1) { + if(selectRows widMap = new HashMap< String,Integer>(); + String[] widString = transferData1.split(""+s[i]); + if(s[i].indexOf("rowspan")>0||s[i].indexOf("colspan")>0){ + //System.out.println("===>第"+i+"行:"); + String[] ss=s[i].split("0||ss[j].indexOf("colspan")>0){ + int combineRow=1; + int combineColumn=1; + if(getIndex(ss[j],"rowspan")>0){//如果有合并的行数有值则返回合并行数,如合并了两行就返回getIndex为2 + combineRow=getIndex(ss[j],"rowspan"); + // System.out.println("第"+j+"列:"); + //System.out.println("合并行数:"+getIndex(ss[j],"rowspan")); + } + if(getIndex(ss[j],"colspan")>0){ + combineColumn=getIndex(ss[j],"colspan"); + //System.out.println("合并列数:"+getIndex(ss[j],"colspan")); + } + //combineRow需要减1.因为例如当合并时2行时,combineRow为2,但是只要选中两行,所以要combineRow-1 + //当没有合并行或列时,1-1为0,相当于就只是选中一行或者一列 + String[] split = ss[j].split(" width="); + if(split.length==2) { + String[] split2 = split[1].split(" style="); +// if(spl) + Integer integer = 0; + if(widMap.containsKey(split2[0])) { + integer = widMap.get(split2[0]); + } + + table.setRowSelectionInterval(selectRow+i-1, selectRow+i-1+combineRow-1); + table.setColumnSelectionInterval(selectColumn-1+integer, selectColumn-1+integer+combineColumn-1); + System.out.println("rowselecttion"+(selectRow+i-1)+"end"+(selectRow+i-1+combineRow-1)); + System.out.println(integer +"column select"+(selectColumn+integer-1)+"end"+(selectColumn-1+integer+combineColumn-1)); + if(combineRow > 2) { + as = true; + } + comBineCell(); + } + + } + } +// if(as) { +// index = index+1; +// } + } + } + //最后要让选中的行和列回归初始状态以便插入数据 + table.setRowSelectionInterval(selectRow, selectRow+selectRows-1); + table.setColumnSelectionInterval(selectColumn, selectColumn+selectColumns-1); + } + //+++ + // System.out.println(transferData); + } catch (UnsupportedFlavorException | IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + super.keyPressed(arg0); + } + }); + + //++++切换单元格超出保存字数的添加监听 + this.table.getModel().addTableModelListener(new TableModelListener() { + @Override + public void tableChanged(TableModelEvent e) { + if (e.getType() == TableModelEvent.UPDATE){ + int row = table.getSelectedRow(); + int col = table.getSelectedColumn(); + if(row>-1&&col>-1) { + // String value=(String) table.getValueAt(row, col).toString(); + String value=String.valueOf(table.getValueAt(row, col));//可以将null转化 + // System.out.println("修改后=>" + value.getBytes().length); + if(value.getBytes().length>512) { + table.setValueAt(subStringByte(value,512), row, col); + MessageBox.post("第"+(row+1)+"行,"+col+"列数据"+"填写超出字数,已将超出字段删除,请重新检查。", "错误", MessageBox.ERROR); + } + } + + if(e.getColumn() == 16 || e.getColumn() == 29) { + String newvalue = table.getModel().getValueAt(e.getLastRow(),e.getColumn()).toString(); + if(!tstxList.contains(newvalue.trim()) && !newvalue.trim().equals("")){ + System.out.println(tstxList.toString()); + table.getModel().setValueAt("",e.getLastRow(),e.getColumn()); + MessageBox.post("下拉选择框未正确填写","提示",2); +// table.getModel().setValueAt(newvalue, row, col); + } + + } + } + } + }); + + + + // 添加滚动条 + JScrollPane scrollPane = new JScrollPane(this.table);// this.table + scrollPane.getVerticalScrollBar().setUnitIncrement(10); + this.firstPanel.add(scrollPane, BorderLayout.CENTER); + + this.secondPanel = new JPanel(new BorderLayout()); + this.table2 = getjTable2(null, null, recordHeader, null); + for(int i=2;i<=table2Size.length+1;i++) { + this.table2.getColumnModel().getColumn(i).setPreferredWidth(table2Size[i-2]);; + } +// if (changValueList.size() == 0) { +// this.table2 = getNewjTable(null, null, recordHeader, 1, true); +// } else { +// this.table2 = getNewjTable(null, null, recordHeader, itemProperties.length, true); +// } + // 添加监听 + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); + StringValue sv = new FormatStringValue(df); + TableCellRenderer r = new DefaultTableRenderer(sv); + + table2.getColumnModel().getColumn(2).setCellEditor(new DatePickerCellEditor(df)); + table2.getColumnModel().getColumn(2).setCellRenderer(r); + this.table2.addMouseListener(new MouseAdapter() { + + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + +// System.out.println("selectMainRow2"+"--------"+selectMainRow2); +// if (mouseevent.getClickCount() == 2) { +// if(table2.getSelectedColumn()==2) { +// int selectRow = table2.getSelectedRow(); +// if(selectRow!=-1) { +// Date now = new Date(); +//// SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//可以方便地修改日期格式 +// SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); +// String time = dateFormat1.format(now); +// table2.setValueAt(time, selectRow, 2); +// table2.invalidate(); +// } +// } +// } + if (mouseevent.getClickCount() == 1) { + ((CTMap2) table2.getModel()).setRow(table2.getSelectedRow()); + if(table2.getSelectedColumn()>=2) { + ((CTMap2) table2.getModel()).setColumn(table2.getSelectedColumn()); + } +// + if (recordIsFocusOwner && recordSelectRow != -1 && recordSelectColumn != -1) { + table2.setValueAt(showRecordValuePane.getText(), recordSelectRow, recordSelectRow); + } + + if (table2.getValueAt(table2.getSelectedRow(), table2.getSelectedColumn()) != null) { + showRecordValuePane.setText(""); + showRecordValuePane.setText( + table2.getValueAt(table2.getSelectedRow(), table2.getSelectedColumn()).toString()); + } else { + showRecordValuePane.setText(""); + } + + } + recordSelectRow = table2.getSelectedRow(); + recordSelectColumn = table2.getSelectedColumn(); + recordIsFocusOwner = false; + if (mouseevent.getButton() == MouseEvent.BUTTON3) { + if(isOwning) { + menu2.show(table2.getTableHeader(), mouseevent.getX(), mouseevent.getY()); + menu2.show(table2, mouseevent.getX(), mouseevent.getY()); + } + } + } + }); + table2.setRowHeight(40); + // 添加键盘监听 + this.table2.addKeyListener(new KeyAdapter() { + + @Override + public void keyPressed(KeyEvent arg0) { + // TODO Auto-generated method stub + //delete键清空 + if (arg0.getKeyChar() == KeyEvent.VK_DELETE) { + } + super.keyPressed(arg0); + } + }); + + +// 插入数据(之前的履历表格)+++++++++++++++++++ + this.secondPanel.add(new JScrollPane(this.table2), BorderLayout.CENTER); + + this.showValuePane = new JTextPane(); + this.showValuePane.addFocusListener(new FocusListener() { + @Override + public void focusLost(FocusEvent focusevent) { + // TODO Auto-generated method stub +// if(selectRow != -1 && selectColumn != -1) +// { +// table.setValueAt(showValuePane.getText(), selectRow, selectColumn); +// } + } + + @Override + public void focusGained(FocusEvent focusevent) { + // TODO Auto-generated method stub + isFocusOwner = true; + // this.row = table.getSelectedRow(); + // this.column = table.getSelectedColumn(); + } + }); + showValuePane.setPreferredSize(new Dimension(800, 40)); + // JScrollPane js = new JScrollPane(this.showValuePane); + // 履历显示选中单元格的值 + this.showRecordValuePane = new JTextPane(); + this.showRecordValuePane.addFocusListener(new FocusListener() { + // private int row; + // private int column; + @Override + public void focusLost(FocusEvent focusevent) { + // TODO Auto-generated method stub +// if(recordSelectRow != -1 && recordSelectColumn != -1) +// { +// table2.setValueAt(showRecordValuePane.getText(), recordSelectRow, recordSelectColumn); +// } + } + + @Override + public void focusGained(FocusEvent focusevent) { + // TODO Auto-generated method stub + recordIsFocusOwner = true; + // this.row = table2.getSelectedRow(); + // this.column = table2.getSelectedColumn(); + } + }); + showRecordValuePane.setPreferredSize(new Dimension(800, 40)); + + JSplitPane showSeleceCellValuePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT); + showSeleceCellValuePanel.setOneTouchExpandable(true);// 让分割线显示出箭头 + showSeleceCellValuePanel.setContinuousLayout(true);// 操作箭头,重绘图形 + showSeleceCellValuePanel.setTopComponent(new JScrollPane(showValuePane)); + showSeleceCellValuePanel.setBottomComponent(new JScrollPane(this.firstPanel)); + + JSplitPane showRecordSeleceCellValuePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT); + showRecordSeleceCellValuePanel.setOneTouchExpandable(true);// 让分割线显示出箭头 + showRecordSeleceCellValuePanel.setContinuousLayout(true);// 操作箭头,重绘图形 + showRecordSeleceCellValuePanel.setTopComponent(new JScrollPane(showRecordValuePane)); + showRecordSeleceCellValuePanel.setBottomComponent(new JScrollPane(this.secondPanel)); + + this.tabbedPane = new JTabbedPane(); + this.tabbedPane.add("PFMEA", showSeleceCellValuePanel); + this.tabbedPane.add("PFMEA更改履历", showRecordSeleceCellValuePanel); + + // 初始化右键菜单 + // 右键菜单 + menu = new JPopupMenu(); + addRowItem = new JMenuItem(rb.getString("tjh_display.TITLE")); + addRowsItem = new JMenuItem(rb.getString("tjdh_display.TITLE")); + addItem = new JMenuItem(rb.getString("tjhbh_display.TITLE")); + addCombineRowsItem = new JMenuItem(rb.getString("tjdghbh_display.TITLE")); + comBineItem = new JMenuItem(rb.getString("hbh_display.TITLE")); + splitItem = new JMenuItem(rb.getString("cfhbdyg_display.TITLE")); + remItem = new JMenuItem(rb.getString("yczh_display.TITLE")); + shrinkColumnItem = new JMenuItem(rb.getString("sxxzl_display.TITLE")); + celShrinkColumnItem = new JMenuItem(rb.getString("qxsxxzl_display.TITLE")); + openLibarary = new JMenuItem("打开PFMEA库"); + + //comBineItem2 = new JMenuItem(rb.getString("hbh_display.TITLE")); + // deleteSpecialItem = new JMenuItem("移除特殊符号"); + + // menu.add(deleteSpecialItem); + menu2 = new JPopupMenu(); + addItem2 = new JMenuItem("添加行"); + remItem2 = new JMenuItem("移除行"); + if(isOwning) { + menu.add(addRowItem); + menu.add(addRowsItem); + menu.add(addItem); + menu.add(addCombineRowsItem); + menu.add(remItem); + menu.add(comBineItem); + menu.add(splitItem); + menu.add(shrinkColumnItem); + menu.add(celShrinkColumnItem); + menu2.add(addItem2); + menu2.add(remItem2); + menu.add(openLibarary); + //menu2.add(comBineItem2); + } + + + this.rootPanel = new JPanel(new FlowLayout()); +// this.addButton = new JButton("添加"); +// this.remButton = new JButton("移除"); +// this.comBinebutton = new JButton("合并"); +// this.splitButton = new JButton("拆分"); + this.saveButton = new JButton(rb.getString("bc_display.TITLE")); + this.clearData = new JButton(rb.getString("qksj_display.TITLE")); + this.completeButton = new JButton(rb.getString("dcPFMEA10_display.TITLE")); + // this.addSpecialButton = new JButton("添加特殊符号"); +// this.deleteSpecialButton = new JButton("移除特殊符号"); + this.libraryButton = new JButton(rb.getString("PFMEAc10_display.TITLE")); + this.RefreshButton = new JButton("重新加载"); + this.setHeightTxt = new JTextField(); + this.setHeightTxt.setPreferredSize(new Dimension(160, 20)); + this.setHeightBtn = new JButton("调整行高"); +// this.refreshBtn = new JButton("刷新工序"); + this.reSetSize = new JButton("重置界面大小"); + // this.sendbutton = new JButton("导出"); + // this.sendbutton.addActionListener(this); +// this.rootPanel.add(addButton); +// this.rootPanel.add(remButton); +// this.rootPanel.add(comBinebutton); +// this.rootPanel.add(splitButton); + //++++ + if (isOwning) { + this.rootPanel.add(completeButton); + this.rootPanel.add(RefreshButton); + this.rootPanel.add(saveButton); + this.rootPanel.add(clearData); + this.rootPanel.add(completeButton); + this.rootPanel.add(libraryButton); + this.rootPanel.add(reSetSize); + this.rootPanel.add(setHeightTxt); + this.rootPanel.add(setHeightBtn); +// this.rootPanel.add(refreshBtn); + } else { + this.rootPanel.add(reSetSize); + this.rootPanel.add(completeButton); + setPanelEnabled(mainPanel,false); + } + //++++ + setHeightBtn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + String selectedText = setHeightTxt.getText(); + try { +// Double valueOf = Double.valueOf(selectedText); + Integer valueOf = Integer.valueOf(selectedText); + if(valueOf>10 || valueOf<1) { + MessageBox.post("调整行高建议在1-10倍之间","提示",2); + } + int rowCount = table.getRowCount(); + int rowHeight = 40; + System.out.println("valueOf"+valueOf+"rowHeight"+rowHeight); + rowHeight = (int) (rowHeight*valueOf); + System.out.println("new rowHeight"+rowHeight); + table.setRowHeight(rowHeight); +// mainTable.invalidate(); + } catch (Exception e2) { + // TODO: handle exception + e2.printStackTrace(); +// System.out.println("输入数字"); + } + + + } + }); + + JPanel centerPanel = new JPanel(new BorderLayout()); + centerPanel.add(titlePanel, BorderLayout.NORTH); + centerPanel.add(topPanel, BorderLayout.CENTER); + + JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); + splitPane.setOneTouchExpandable(true);// 让分割线显示出箭头 + splitPane.setContinuousLayout(true);// 操作箭头,重绘图形 + splitPane.setTopComponent(centerPanel); + splitPane.setBottomComponent(tabbedPane); + // JPanel centerPanel2 = new JPanel(new BorderLayout()); + // centerPanel2.add(centerPanel,BorderLayout.NORTH); + // centerPanel2.add(tabbedPane, BorderLayout.CENTER); + + // JSplitPane splitPane = new JSplitPane(); + // splitPane.setOneTouchExpandable(true);//让分割线显示出箭头 + // splitPane.setContinuousLayout(true);//操作箭头,重绘图形 + // splitPane.setLeftComponent(centerPanel2); + // splitPane.setRightComponent(treePanel); + + // 添加鼠标监听 + this.createActionEvent(); + this.setLayout(new BorderLayout()); + // this.add(centerPanel, BorderLayout.NORTH); + // this.add(centerPanel2, BorderLayout.CENTER); + this.add(splitPane, BorderLayout.CENTER); + // dialog.add(tablePanel, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + // this.add(utilPanel, BorderLayout.EAST); + this.pack(); + this.show(); + } + + //按照字节截取字符串 + public static String subStringByte(String source, int length) { + StringBuffer buffer = new StringBuffer(); + char[] chars = source.toCharArray(); + char c; + for (int i = 0;; i++) { + if (length <= 0) { + break; + } + c = source.charAt(i); + buffer.append(c); + length -= String.valueOf(c).getBytes().length; + if (i + 1 < chars.length) { + if (String.valueOf(chars[i + 1]).getBytes().length > length) { + break; + }; + } + } + return buffer.toString(); + } + + + + // 添加监听 + public void createActionEvent() { + this.addItem2.addActionListener(this); + this.remItem2.addActionListener(this); + this.openLibarary.addActionListener(this); + this.addRowItem.addActionListener(this); + this.addRowsItem.addActionListener(this); + this.addCombineRowsItem.addActionListener(this); + this.addItem.addActionListener(this); + this.remItem.addActionListener(this); + this.comBineItem.addActionListener(this); + //this.comBineItem2.addActionListener(this); + this.splitItem.addActionListener(this); + this.shrinkColumnItem.addActionListener(this); + this.celShrinkColumnItem.addActionListener(this); + this.saveButton.addActionListener(this); + this.reSetSize.addActionListener(this); + // this.addSpecialButton.addActionListener(this); + // this.deleteSpecialItem.addActionListener(this); + this.libraryButton.addActionListener(this); + this.RefreshButton.addActionListener(this); + this.clearData.addActionListener(this); + this.completeButton.addActionListener(this); + } + + //复制excel数据时检查是否有合并的行和列。"rowspan"是合并的行,"colspan"是合并的列。然后返回rowspan(colspan)=的值 + public static int getIndex(String tag1,String tag2){ + int loca=0; + if(tag1.indexOf(tag2)>0){ + int l=tag1.indexOf(tag2); + while(!tag1.substring(l,l+1).equals("=")){ + l++; + } + int start=++l; + while(!tag1.substring(l,l+1).equals(" ")){ + l++; + } + loca=Integer.valueOf(tag1.substring(start,l)); + } + return loca; + } + + + + //设置控件权限 + public void setPanelEnabled(JPanel panel, boolean enabled) { + for (int i = 0; i < panel.getComponentCount(); i++) { + if (panel.getComponent(i) instanceof JPanel) { + JPanel chidPanel = (JPanel) panel.getComponent(i); + for (int j = 0; j < chidPanel.getComponentCount(); j++) { + + chidPanel.getComponent(j).setEnabled(enabled);//一行 + if (chidPanel.getComponent(j) instanceof MultiComboBox) { + MultiComboBox multiComboBox = (MultiComboBox) chidPanel.getComponent(j); + multiComboBox.editor.enable(enabled); + if(enabled) {multiComboBox.popup.show();}else {multiComboBox.popup.hide();} + } + if (chidPanel.getComponent(j) instanceof JScrollPane) { + JScrollPane scrollPane = (JScrollPane) chidPanel.getComponent(j); + JViewport jViewport = scrollPane.getViewport(); + jViewport.getView().setEnabled(enabled); + } + } + } + panel.getComponent(i).setEnabled(enabled); + if (panel.getComponent(i) instanceof MultiComboBox) { + MultiComboBox multiComboBox = (MultiComboBox) panel.getComponent(i); + + multiComboBox.editor.enable(enabled); + if(enabled) {multiComboBox.popup.show();}else {multiComboBox.popup.hide();} + } + if (panel.getComponent(i) instanceof JScrollPane) { + JScrollPane scrollPane = (JScrollPane) panel.getComponent(i); + JViewport jViewport = scrollPane.getViewport(); + jViewport.getView().setEnabled(enabled); + } + } + } + + + /** + * 写入数据到Jtable中 + * 第一个表格 + */ + private void setJTable() { + for (int i = 0; i < dataList.size(); i++) { + List rowList = dataList.get(i); + int c = dataList.size(); + for (int j = 0; j < header.length; j++) { + if (j > 24) { + map.setValueAt(rowList.get(j + 3), i, j); + } else { + map.setValueAt(rowList.get(j), i, j); + } + } + } + } + /** + * 写入数据到Jtable中 + * 第二个表格 + */ + private void setJTable2() { + for (int i = 0; i < dataList2.size(); i++) { + List rowList = dataList2.get(i); + int c = dataList2.size(); + for (int j = 0; j < recordHeader.length; j++) { + map2.setValueAt(rowList.get(j), i, j); + } + } + } + public CTable getNewjTable(CTable partsTable, DefaultTableModel dtm, Object[] titleNames, int rows, + boolean isEditable) { + int simpleLen = 100; + int totleLen = 1000; + if (partsTable == null) { + final CTMap2 map = new CTMap2(rows, titleNames.length); + map.setColumnIdentifiers(titleNames); + map.setEditable(isEditable); + partsTable = new CTable(map,false,tstxList); + partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + partsTable.setRowHeight(50); + // 设置显示器渲染 + TableCellTextAreaRenderer2 renderer = new TableCellTextAreaRenderer2(); + partsTable.setDefaultRenderer(Object.class, renderer); + + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + // Jtable通用方法 +// public JTable getNewjTable(JTable partsTable, DefaultTableModel dtm, Object[] titleNames, int rows, +// boolean isEditable,int xxx) { +// int simpleLen = 100; +// int totleLen = 1000; +// if (partsTable == null) { +// final CTMap2 map = new CTMap2(rows, titleNames.length); +// map.setColumnIdentifiers(titleNames); +// map.setEditable(isEditable); +// partsTable = new JTable(map); +// partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); +// partsTable.setRowHeight(50); +// // 设置显示器渲染 +// TableCellTextAreaRenderer2 renderer = new TableCellTextAreaRenderer2(); +// partsTable.setDefaultRenderer(Object.class, renderer); +// +// if (simpleLen * titleNames.length >= totleLen) { +// for (int i = 0; i < titleNames.length; i++) { +// partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); +// } +// partsTable.setAutoResizeMode(0); +// } else { +// partsTable.setAutoResizeMode(1); +// } +// } +// return partsTable; +// } + + @Override + public void dispose() { + // TODO Auto-generated method stub + this.timer.cancel(); + super.dispose(); + //关闭权限修改 + closePermission(); + } + + // Jtable通用方法 + public CTable getjTable(CTable partsTable, DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + int simpleLen = 100; + int totleLen = 1000; + if (partsTable == null) { + this.map = new CTMap(dataList.size(), titleNames.length); + map.setColumnIdentifiers(titleNames); + this.map.setEditable(true); + if (processRows != null && processRows.size() > 0) { + this.map.setProcessRowList(processRows); + } +// partsTable = new CTable(map); +// partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); +// Adapter adapter = new Adapter(partsTable); + setJTable(); + + partsTable = new CTable(map,true,tstxList); +// { +// public boolean isCellEditable(int row,int column){ +// if(column == 0){ +// return false; +// }else{ +// return true; +// } +// } +// }; + partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + Adapter1 adapter = new Adapter1(partsTable); + + if(initRowHeight==0) { + partsTable.setRowHeight(50); + }else { + partsTable.setRowHeight(initRowHeight); + } + + // 隐藏列 + partsTable.HiddenCell(0); + partsTable.HiddenCell(titleNames.length-2); + partsTable.HiddenCell(titleNames.length-1); + // //设置显示器渲染 + TableCellTextAreaRenderer renderer = new TableCellTextAreaRenderer(); + renderer.setProcessRows(processRows); + // //设置居中 + partsTable.setDefaultRenderer(Object.class, renderer); + + + // 添加监听 + partsTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if (mouseevent.getClickCount() == 1) { + map.setRow(table.getSelectedRow()); + map.setColumn(table.getSelectedColumn()); + if (isFocusOwner && selectRow != -1 && selectColumn != -1) { + table.setValueAt(showValuePane.getText(), selectRow, selectColumn); + } + + if (table.getValueAt(table.getSelectedRow(), table.getSelectedColumn()) != null) { + showRecordValuePane.setText(""); + showValuePane.setText( + table.getValueAt(table.getSelectedRow(), table.getSelectedColumn()).toString()); + } else { + showValuePane.setText(""); + } + selectRow = table.getSelectedRow(); + selectColumn = table.getSelectedColumn(); + isFocusOwner = false; + } + if (mouseevent.getButton() == MouseEvent.BUTTON3) { + if(isOwning) { + menu.show(table, mouseevent.getX(), mouseevent.getY()); + } + } + } + }); + // //设置编辑器渲染 + // this.textAreaCellEditor = new TextAreaCellEditor(); + // partsTable.setDefaultEditor(Object.class, + // this.textAreaCellEditor); + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + if(!isOwning) { + partsTable.setEnabled(false); + } + + + //++ + MultiLineHeaderRenderer renderer = new MultiLineHeaderRenderer(); + Enumeration e = partsTable.getColumnModel().getColumns(); + while (e.hasMoreElements()) { + ( (TableColumn) e.nextElement()).setHeaderRenderer(renderer); + } + //++ + return partsTable; + } + + // Jtable通用方法 + public JTable getjTable2(JTable partsTable, DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + int simpleLen = 100; + int totleLen = 1000; + if (partsTable == null) { + System.out.println("-----init() map2 -------"+dataList2.toString()); + this.map2 = new CTMap2(dataList2.size(), titleNames.length); + map2.setColumnIdentifiers(titleNames); + this.map2.setEditable(true); + + partsTable = new JTable(map2); + partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + Adapter adapter = new Adapter(partsTable); + partsTable.setRowHeight(50); + setJTable2(); + + // 隐藏列 + HiddenCell(1,partsTable); + HiddenCell(0,partsTable); +// partsTable.HiddenCell(0); +// partsTable.HiddenCell(1); + // //设置显示器渲染 + TableCellTextAreaRenderer renderer = new TableCellTextAreaRenderer(); + if (processRows != null && processRows.size() > 0) { + List dataList2List = new ArrayList(); + for(int i2=0;i2= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + if(!isOwning) { + partsTable.setEnabled(false); + } +// partsTable.setEnabled(true); + //++ + MultiLineHeaderRenderer rendererM = new MultiLineHeaderRenderer(); + Enumeration e = partsTable.getColumnModel().getColumns(); + while (e.hasMoreElements()) { + ( (TableColumn) e.nextElement()).setHeaderRenderer(rendererM); + } +// partsTable.setRowHeight(40); + //++ + return partsTable; + + } + + private void HiddenCell(int column,JTable table) { + + TableColumn tc = table.getTableHeader().getColumnModel().getColumn(column); + tc.setMaxWidth(0); + tc.setPreferredWidth(0); + tc.setWidth(0); + tc.setMinWidth(0); + table.getTableHeader().getColumnModel().getColumn(column).setMaxWidth(0); + table.getTableHeader().getColumnModel().getColumn(column).setMinWidth(0); + + } + + + @Override + public void actionPerformed(ActionEvent arg0) { + Object source = arg0.getSource(); + if(source.equals(this.addItem2)) { + if (!isOwning) { + MessageBox.post("无权限添加行!", "错误", MessageBox.ERROR); + return; + } + JTable table = this.table2; + if (table.getSelectedRow() > -1) { + ((CTMap2) table.getModel()).insertRow(table2.getRowCount()); + Date now = new Date(); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//可以方便地修改日期格式 +// map2.setValueAt(dateFormat.format(now), table2.getRowCount()-1, 2); + SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyyMMddHHmmss"); + String time = dateFormat1.format(now); +// map2.setValueAt(Long.valueOf(time), table2.getRowCount()-1, 1); + UUID uuid = UUID.randomUUID(); + String uid=uuid.toString().replace("-", ""); + map2.setValueAt(uid, table2.getRowCount()-1, 0); + //插入数据到数据库 + SqlUtilT.getTCConnection(); + String insert = "insert into AHMC_PFMEALIBRARY values(?,?,?,?,?,?,?,?,?,?,?,?)"; + SqlUtilT.write(new String[] {uid,UID,null,null,null,null,null,null,null,null,null,time} + ,insert); + } + + }else if (source.equals(this.openLibarary)) { + + CTable table = this.table; +// int selectMainRow2 = table.getSelectedRow(); + System.out.println(selectMainRow2+"-------"); + if(selectMainRow2!=-1) { + System.out.println("当前选中的row"+selectMainRow2); + +// if (this.libraryDialog == null) { + System.out.println(table.getSelectedRow() + "===" + table.getSelectedColumn()); + String valueAt = (String) table.getValueAt(selectMainRow2, 4); + System.out.println(valueAt+"valueAt"); + this.libraryDialog = new LibraryDialog(valueAt); +// } +// else { +// System.out.println(table.getSelectedRow() + "===" + table.getSelectedColumn()); +// this.libraryDialog.show(); +// } + } + + + } + else if(source.equals(this.remItem2)) { + if (!isOwning) { + MessageBox.post("无权限删除行!", "错误", MessageBox.ERROR); + return; + } + int i=JOptionPane.showConfirmDialog(null, "是否删除选中行?", "删除", JOptionPane.YES_NO_OPTION); + if(i!=JOptionPane.YES_OPTION){ + return; + } + JTable table = this.table2; +// if(table.getRowCount() == 1) { +// +// } + if (table.getSelectedRow() >= 0 + && table.getSelectedColumn() > 1) { + (table.getCellEditor(table.getSelectedRow(), + table.getSelectedColumn())).stopCellEditing(); + if (((CTMap2) table.getModel()).getValueAt( + table.getSelectedRow(), 0) != null) { + //根据plmid删除数据库中选中行的信息 + String delete = String + .format("delete from AHMC_PFMEALIBRARY where PLMID = \'%s\'",table.getValueAt(table.getSelectedRow(), 0).toString()); + SqlUtilT.getTCConnection(); + SqlUtilT.delete(delete); + } + ((CTMap2) table.getModel()).removeRow(table + .getSelectedRow()); + table.revalidate(); + table.repaint(); + if(table.getRowCount()==0) { +// table.addR + ((CTMap2) table.getModel()).addRow(); + } + table.revalidate(); + table.repaint(); + //this.tabbedPane.updateUI(); + } + + }else if (source.equals(this.addRowItem)) { + if (!isOwning) { + MessageBox.post("无权限添加行!", "错误", MessageBox.ERROR); + return; + } + addRow(); + } else if (source.equals(this.addRowsItem)) { + if (!isOwning) { + MessageBox.post("无权限添加行!", "错误", MessageBox.ERROR); + return; + } + if (this.tabbedPane.getSelectedIndex() == 1) { + AddRowsDialog addRowsDialog = new AddRowsDialog(source); + } else { + int row = table.getSelectedRow(); + if (this.processRows != null && this.processRows.size() == 0 && !(this.processRows.contains(row))) { + MessageBox.post("无权限添加行!", "错误", MessageBox.ERROR); + return; + } + AddRowsDialog addRowsDialog = new AddRowsDialog(source); + } + } else if (source.equals(this.addCombineRowsItem)) { + if (!isOwning) { + MessageBox.post("无权限添加行!", "错误", MessageBox.ERROR); + return; + } + if (this.tabbedPane.getSelectedIndex() == 1) { + AddRowsDialog addRowsDialog = new AddRowsDialog(source); + } else { + int row = table.getSelectedRow(); + if (this.processRows != null && this.processRows.size() == 0 && !(this.processRows.contains(row))) { + MessageBox.post("无权限添加行!", "错误", MessageBox.ERROR); + return; + } + AddRowsDialog addRowsDialog = new AddRowsDialog(source); + } + } else if (source.equals(this.addItem)) { + if (!isOwning) { + MessageBox.post("无权限添加行!", "错误", MessageBox.ERROR); + return; + } + addCombineRow(); + } else if (source.equals(this.remItem)) { + if (!isOwning) { + MessageBox.post("无权限删除行!", "错误", MessageBox.ERROR); + return; + } + int i = JOptionPane.showConfirmDialog(null, "是否删除选中行?", "删除", JOptionPane.YES_NO_OPTION); + if (i != JOptionPane.YES_OPTION) { + return; + } + remRow(); + } else if (source.equals(this.comBineItem)) { + if (!isOwning) { + MessageBox.post("无权限合并行!", "错误", MessageBox.ERROR); + return; + } + comBineCell(); + } else if (source.equals(this.splitItem)) { + if (!isOwning) { + MessageBox.post("无权限操作行!", "错误", MessageBox.ERROR); + return; + } + splitCell(); + } else if (source.equals(this.saveButton)) { + if(isOwning) { + okEvent(true, true); + //this.dispose(); + }else { + MessageBox.post("无权限保存!", "错误", MessageBox.ERROR); + } + + } + else if (source.equals(this.clearData)) { + if (!isOwning) { + MessageBox.post("无权限!", "错误", MessageBox.ERROR); + return; + } + clearDatas(); + } + + else if (source.equals(shrinkColumnItem)) { + for (int i = 0; i < table.getSelectedColumns().length; i++) { + table.getColumnModel().getColumn(table.getSelectedColumns()[i]).setPreferredWidth(5); + } + table.revalidate(); + table.repaint(); + } else if (source.equals(celShrinkColumnItem)) { + for (int i = 0; i < table.getSelectedColumns().length; i++) { + table.getColumnModel().getColumn(table.getSelectedColumns()[i]).setPreferredWidth(100); + } + table.revalidate(); + table.repaint(); + } else if (source.equals(libraryButton)) { + if (!isOwning) { + MessageBox.post("无权限查看!", "错误", MessageBox.ERROR); + return; + } + + if (this.libraryDialog == null) { + System.out.println(table.getSelectedRow() + "===" + table.getSelectedColumn()); + this.libraryDialog = new LibraryDialog(); + } else { + System.out.println(table.getSelectedRow() + "===" + table.getSelectedColumn()); + this.libraryDialog.show(); + } + } else if (source.equals(completeButton)) { + isComplete = true; + if(isOwning) { + okEvent(false, true); + // this.disposeDialog(); + }else { + //MessageBox.post("无权限保存!", "错误", MessageBox.ERROR); + PFMEABean pfmeaBean = new PFMEABean(); + pfmeaBean.setCompanyName((String)this.companyNameField.getText()); + pfmeaBean.setProject(this.projectField.getText()); + pfmeaBean.setAddress(this.addressField.getText()); + pfmeaBean.setPfmeaStartDate(this.pfmeaStartButton.getText()); + pfmeaBean.setPfmeaUpdateDate(this.pfmeaUpdateButton.getText()); + pfmeaBean.setProcessDuty(this.processDutyField.getText()); + pfmeaBean.setCustomerName(this.customerNameField.getText()); + pfmeaBean.setSecurityClassification(this.securityClassificationField.getText()); + pfmeaBean.setModelPlatform(this.modelPlatformField.getText()); + pfmeaBean.setFunctionalTeams(this.functionalTeamsField.getText()); +// pfmeaBean.setProductCode(this.expiryTextField.getText()); + try { + pfmeaBean.setPfmeaNumber(itemRevision.getStringProperty("item_id")); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + getData(); + getCombineMap(); + //获取table2中数据保存 + String[][] dataValue = new String[this.table2.getRowCount()][8]; + for (int i = 0; i < this.table2.getRowCount(); i++) { + for (int j = 0; j < 8; j++) { + if(j==0) { + dataValue[i][j]=this.table2.getValueAt(i, 0).toString(); + }else { + dataValue[i][j] = this.table2.getValueAt(i, j+1) == null ? "" + : this.table2.getValueAt(i, j+1).toString(); + } + } + } + try { + String name = this.itemRevision.getStringProperty("object_name"); + new selectExportPath(pfmeaBean, this.excelDataList, dataValue,name); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + this.dispose(); + }else if (source.equals(reSetSize)) { + int i=JOptionPane.showConfirmDialog(null, "是否重置界面大小,点击“是”将在下次打开界面时生效!", "重置", JOptionPane.YES_NO_OPTION); + if(i==JOptionPane.YES_OPTION){ + SqlUtilT.getTCConnection(); + InputStream input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + try { + pro.load(input); + String deleteSQL = String.format( + "DELETE FROM AHMC_PFMEAFRAME_SIZE WHERE USERNAME = '%s' AND TYPE = '%s'",userName,type); + SqlUtilT.delete(deleteSQL); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + isReSet=true; + SqlUtilT.freeAll(); + } + } + else if (source.equals(RefreshButton)) { + + + this.dispose(); + DesignPFMEACommand command = new DesignPFMEACommand(app, + session,UID,meprocess,true,(TCComponent)itemRevision); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + else { + // this.disposeDialog(); + this.dispose(); + } + } + + private void okEvent(boolean isSave, boolean isAuto) { + // TODO Auto-generated method stub + //获取屏幕尺寸和位置+++++ + String list1=String.valueOf(((int)this.getSize().getWidth()))+"/"+String.valueOf((int)this.getSize().getHeight()) + +"/"+String.valueOf(((int)this.getLocation().getX()))+"/"+String.valueOf((((int)this.getLocation().getY()))); + + String list2=""; + for(int i=1;i"+this.userName); + System.out.println("this.type====>"+this.type); + System.out.println("list1====>"+list1.toString()); + System.out.println("list2====>"+list2.toString()); + System.out.println("list3====>"+list3.toString()); + if(isFirstOpen) { + String insertSQL = "INSERT INTO AHMC_PFMEAFRAME_SIZE VALUES(?,?,?,?,?,?,?)"; + SqlUtilT.write(new String[] { + UUID.randomUUID().toString().replace("-", ""), + this.userName,this.type,list1,list2,list3,String.valueOf(table.getRowHeight())}, insertSQL); + System.out.println("insertSQL====>"+insertSQL); + isFirstOpen=false; + }else if(!isReSet){ + String updateSQL = String.format( + "update AHMC_PFMEAFRAME_SIZE set FRAMESIZE = ?, TABLE1SIZE = ?, TABLE2SIZE = ?,ROWHEIGHT = ? WHERE USERNAME ='%s' AND TYPE = '%s'",userName,type); + SqlUtilT.update( + new String[] {list1,list2,list3,String.valueOf(table.getRowHeight())},updateSQL); + } + SqlUtilT.freeAll(); + ///++++++ + + + + + // 将数据保存到表单中 + try { +// if(table.getRowCount()!=0) { +// if(table.getValueAt(0,0)=="") { +// MessageBox.post("操作失误,请勿清除全部内容保存","错误",MessageBox.ERROR); +// return; +// }} + if (table.getSelectedRow() >= 0 && table.getSelectedColumn() >= 0) { + (table.getCellEditor(table.getSelectedRow(), table.getSelectedColumn())).stopCellEditing(); + } + if (table2.getSelectedRow() >= 0 && table2.getSelectedColumn() >= 0) { + (table2.getCellEditor(table2.getSelectedRow(), table2.getSelectedColumn())).stopCellEditing(); + } + PFMEABean pfmeaBean = new PFMEABean(); + + pfmeaBean.setCompanyName((String)this.companyNameField.getText()); + pfmeaBean.setProject(this.projectField.getText()); + pfmeaBean.setAddress(this.addressField.getText()); + pfmeaBean.setPfmeaStartDate(this.pfmeaStartButton.getText()); + pfmeaBean.setPfmeaUpdateDate(this.pfmeaUpdateButton.getText()); + pfmeaBean.setProcessDuty(this.processDutyField.getText()); + pfmeaBean.setCustomerName(this.customerNameField.getText()); + pfmeaBean.setSecurityClassification(this.securityClassificationField.getText()); + pfmeaBean.setModelPlatform(this.modelPlatformField.getText()); + pfmeaBean.setFunctionalTeams(this.functionalTeamsField.getText()); + pfmeaBean.setPfmeaNumber(itemRevision.getStringProperty("item_id")); +// pfmeaBean.setProductCode(this.expiryTextField.getText()); + + // 获取JTable中的数据 + List> dataValeList = getTableValue(); + + + System.out.println(dataValeList.toString()); + DesignPFMEAOperation operation = new DesignPFMEAOperation(this.itemRevision, this.meprocess, + this.session, null, this.itemProperties, pfmeaBean, dataValeList, plmeidList, + deleteRows, isOwning,comp,UID,firstFlag); + operation.executeOperation(); + for (int j = 0; j < processRows.size(); j++) { + plmeidList.add(table.getValueAt(processRows.get(j), 0).toString()); + } + //获取table2中数据保存 +// String[][] dataValue = new String[this.table2.getRowCount()][8]; +// for (int i = 0; i < this.table2.getRowCount(); i++) { +// for (int j = 0; j < 8; j++) { +// if(j==0) { +// dataValue[i][j]=this.table2.getValueAt(i, 0).toString(); +// } +// else if (j==1) { +// Object valueO = this.table2.getValueAt(i, j+1); +// if(valueO instanceof String) { +// dataValue[i][j] = (String) valueO; +// }else if (valueO instanceof Date) { +//// System.out.println(valueO + "String"+ (String) this.table2.getValueAt(i, j+2)); +// SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd"); +// String time = dateFormat1.format((Date)valueO); +// dataValue[i][j] = time; +// System.out.println(time); +// } +// } +// else { +// System.out.println(this.table2.getValueAt(i, j+1)); +// dataValue[i][j] = this.table2.getValueAt(i, j+1) == null ? "" +// : this.table2.getValueAt(i, j+1).toString(); +// } +// } +// } +//// System.out.println("dataValue ==========>"+dataValue); +// for(int i=0;i rowList = new ArrayList(); + rowList.add(rs.getString("PLMEID")); + rowList.add(rs.getString("GYBH")); + String string = rs.getString("GCMC"); + rowList.add(rs.getString("GCMC")); + itemList.add(string); + rowList.add(rs.getString("STATION")); + rowList.add(rs.getString("REQUIREMENT")); + rowList.add(rs.getString("QZSXMS")); + rowList.add(rs.getString("QZSXHG")); + rowList.add(rs.getString("YZD")); + rowList.add(rs.getString("JB")); + rowList.add(rs.getString("QZSXQY")); + rowList.add(rs.getString("XXGCKZYF")); + rowList.add(rs.getString("PDS")); + rowList.add(rs.getString("XXGCKZTC")); + rowList.add(rs.getString("TCD")); + rowList.add(rs.getString("RPN")); + rowList.add(rs.getString("JYCS")); + rowList.add(rs.getString("ZZR")); + rowList.add(rs.getString("JHWCRQ")); + rowList.add(rs.getString("CQDCS")); + rowList.add(rs.getString("NEW_SEV")); + rowList.add(rs.getString("NEW_OCC")); + rowList.add(rs.getString("NEW_DET")); + rowList.add(rs.getString("NEW_RPN")); + rowList.add(rs.getString("IDEAL_STATE")); + rowList.add(rs.getString("SPECIAL")); + rowList.add(rs.getInt("HH")); + rowList.add(rs.getString("HBDYG")); + rowList.add(rs.getInt("HHC")); + + rowList.add(rs.getString("OCCURRRENCE")); + rowList.add(rs.getString("DETECTION")); + rowList.add(rs.getString("PRIORITY"));//PRIORITY + rowList.add(rs.getString("P1")); + rowList.add(rs.getString("P2")); + rowList.add(rs.getString("P3")); + rowList.add(rs.getString("P4")); + rowList.add(rs.getString("P5")); + rowList.add(rs.getString("NO")); + excelDataList.add(rowList); + } +// for (int i = 0; i < excelDataList.size(); i++) { +// // 行号差 +// excelDataList.get(i).set(27, i - Integer.parseInt(excelDataList.get(i).get(25).toString())); +// } + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + + /** + * 获取合并单元格 + */ + public void getCombineMap() { + try { + if (excelDataList != null && excelDataList.size() > 0) { + for (int i = 0; i < excelDataList.size(); i++) { + if (excelDataList.get(i).get(26) != null && !excelDataList.get(i).get(26).equals("")) { + String sombine = excelDataList.get(i).get(26).toString(); + int rowDif = Integer.parseInt(excelDataList.get(i).get(27).toString()); + String[] sombines; + if (sombine.indexOf("-") >= 0) { + sombines = sombine.split("-"); + } else { + sombines = new String[] { sombine }; + } + for (int j = 0; j < sombines.length; j++) { + if (sombines[j].indexOf("/") >= 0) { + int[] row; + int[] cloumn; + String[] cells = sombines[j].split("/"); + if (cells[0].indexOf(",") >= 0) { + String[] rows = cells[0].split(","); + row = new int[rows.length]; + for (int k = 0; k < rows.length; k++) { + row[k] = Integer.parseInt(rows[k]) + rowDif; + } + } else { + row = new int[] { Integer.parseInt(cells[0]) + rowDif }; + } + if (cells[1].indexOf(",") >= 0) { + String[] cloumns = cells[1].split(","); + cloumn = new int[cloumns.length]; + for (int k = 0; k < cloumns.length; k++) { + cloumn[k] = Integer.parseInt(cloumns[k]); + } + } else { + cloumn = new int[] { Integer.parseInt(cells[1]) }; + } + this.excelCombineMap.put(row, cloumn); + } + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static void picture2(XSSFSheet sheet,XSSFWorkbook wb ,int col,int row,String fileUrl) { //, double scaleX, double scaleY + try { + + int row2=row; + ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream(); + BufferedImage bufferImg = ImageIO.read(new File(fileUrl)); + ImageIO.write(bufferImg, "png", byteArrayOut); + Drawing drawing = sheet.createDrawingPatriarch(); + XSSFClientAnchor anchor = new XSSFClientAnchor(); + int picHeight = 500; + int picWidth = 1050; + int rowHeight = 0; + for(int i =row;i<=row2;i++) { + rowHeight += sheet.getRow(i).getHeight(); + } + int strLength = sheet.getRow(row).getCell(col).getStringCellValue().length(); + int colWidth = sheet.getColumnWidth(col); + row2 +=1; + System.out.println("当前首行:"+row); + System.out.println("当前尾行:"+row2); + System.out.println("当前列:"+col); + System.out.println("行高:"+rowHeight); + System.out.println("当前列宽:"+colWidth); + + colWidth = sheet.getColumnWidth(col); + + int t3 = (int)(picHeight/15);//图片占单元格高度 + int t4 = (int)(picWidth/32);//图片占单元格宽度 + +// int t6 = (int)(strLength%t5!=0?strLength/t5+1:strLength/t5);//单元格文字行数 +// int t7 = (int)(t6*417/15);//文字占单元格高度 + int t8 = t3*2;//所需单元格高度 +// System.out.println("计算出文字行数:"+t6); +// System.out.println("计算出文字高度:"+t7); + System.out.println("当前单元格高度="+(int)(rowHeight/15)); + System.out.println("所需单元格高度="+t8); + if((int)(rowHeight/15)0) { + tempcolwid /= 2; + int t = (int)(rowHeight/15); + int t2 = (int)(tempcolwid/32); + System.out.println("t="+t); + System.out.println("t2="+t2); + anchor.setCol1(col); + anchor.setCol2(col); + anchor.setRow1(row); + anchor.setRow2(row2); + System.out.println("tw"+XSSFShape.EMU_PER_PIXEL); + System.out.println("tw"+t); + anchor.setDx1(XSSFShape.EMU_PER_PIXEL * t2); + anchor.setDx2(XSSFShape.EMU_PER_PIXEL * (t2+t4)); + if(row+1==row2) {//单行 + System.out.println("单行"); +// anchor.setDy1(XSSFShape.EMU_PER_PIXEL * 100); + anchor.setDy1(XSSFShape.EMU_PER_PIXEL * (t/5)); //-XSSFShape.EMU_PER_PIXEL*(t/3) +// anchor.setDy2(XSSFShape.EMU_PER_PIXEL * 1); + anchor.setDy2(XSSFShape.EMU_PER_PIXEL * (t3-4*t/5-2)); //-XSSFShape.EMU_PER_PIXEL*(t/3) + }else {//多行合并 + System.out.println("多行"); + int tempRow = row; + int row1Height = 0; + row1Height = sheet.getRow(tempRow).getHeight(); + int t9 = (int)(row1Height/15); + do { + if(t9>(t/2)||tempRow==row2)break; + tempRow++; + row1Height = sheet.getRow(tempRow).getHeight(); + t9 +=(int)(row1Height/15); + }while(true); + if(tempRow == row2)System.out.println("第"+row+"行,第"+col+"列未找到合适的行!"); + anchor.setRow1(tempRow); + anchor.setRow2(tempRow+1); + System.out.println("临时行:"+tempRow); + System.out.println("临时行高度:"+row1Height/15); +// anchor.setDy1(XSSFShape.EMU_PER_PIXEL * 150); +// anchor.setDy2(XSSFShape.EMU_PER_PIXEL * 500); + anchor.setDy1(XSSFShape.EMU_PER_PIXEL * (t9-t/2)); + anchor.setDy2(XSSFShape.EMU_PER_PIXEL * (t3+t9-t/2-row1Height/15)); + } +// anchor.setDy1(XSSFShape.EMU_PER_PIXEL * (t - t2/2)); +// anchor.setDy2(XSSFShape.EMU_PER_PIXEL * (-1*t + t2/2)); + } + System.out.println("y1="+anchor.getDy1()); + System.out.println("y2="+anchor.getDy2()); + + anchor.setAnchorType(ClientAnchor.MOVE_AND_RESIZE); + Picture picture = drawing.createPicture(anchor, wb.addPicture(byteArrayOut.toByteArray(), HSSFWorkbook.PICTURE_TYPE_JPEG)); +// picture.resize(1d); + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * 输出PFMEA + * + * @param pfmeaBean + * @param dataValeList + */ + private void outPutExcel(PFMEABean pfmeaBean, List> dataValeList, String[][] dataValue,String name) { + // TODO Auto-generated method stub + InputStream input = null; + try { + File pfmeaFile = TMomMethodUtil.getFile(session, "PFMEA设计", "MSExcel"); + if (pfmeaFile != null) { + System.out.println("pfmeaFile length ==> "+pfmeaFile.length()); + input = new FileInputStream(pfmeaFile); + } else { + MessageBox.post("未找到PFMEA模板!", "错误", MessageBox.ERROR); + return; + } + String outFilePath = System.getenv("TEMP") + "\\" + "PFMEA.xlsx"; + FileOutputStream output = new FileOutputStream(new File(outFilePath)); // +// HSSFWorkbook wb = new HSSFWorkbook(input);// ( +// outPutSheet1(wb, dataValue); +// HSSFSheet sheet = wb.getSheetAt(1); + XSSFWorkbook wb = new XSSFWorkbook(input); + XSSFSheet sheet = wb.getSheetAt(0); +// XSSFSheet sheet2 = wb.getSheetAt(2); + + + //第一页导出++++ + int startRow = 8; + XSSFRow row4 = sheet.getRow(2); + if(row4==null) { + row4=sheet.createRow(2); + } + setCellValue(row4,2,pfmeaBean.getCompanyName()); + //setCellValue(row,,pfmeaBean); + setCellValue(row4,9,pfmeaBean.getProject()); +// setCellValue(row4,15,pfmeaBean.getSecurityClassification()); +// 15 2 +// XSSFRow row1 = sheet.getRow(1); +// setCellValue(row1,15,pfmeaBean.getPfmeaNumber()); + XSSFRow row5 = sheet.getRow(3); + if(row5==null) { + row5=sheet.createRow(3); + } + setCellValue(row5,2,pfmeaBean.getAddress()); + setCellValue(row5,9,pfmeaBean.getPfmeaStartDate()); //零件版本好 + setCellValue(row5,26,pfmeaBean.getPfmeaNumber()); //零件版本好 +// setCellValue(row5,15,pfmeaBean.getPfmeaStartDate()); + XSSFRow row6 = sheet.getRow(4); + if(row6==null) { + row6=sheet.createRow(4); + } + setCellValue(row6,2,pfmeaBean.getCustomerName()); + setCellValue(row6,9,pfmeaBean.getPfmeaUpdateDate()); //processDutyField + setCellValue(row6,26,pfmeaBean.getProcessDuty()); //关键日期 + XSSFRow row7 = sheet.getRow(5); + if(row7==null) { + row5=sheet.createRow(5); + } + setCellValue(row7,2,pfmeaBean.getModelPlatform()); + setCellValue(row7,9,pfmeaBean.getFunctionalTeams()); + setCellValue(row7,26,pfmeaBean.getSecurityClassification()); + for (int i = 0; i < dataValeList.size(); i++) { + XSSFRow row = null; + Boolean isCreat = false; + row = sheet.getRow(i + startRow); + if(row==null) { + row = sheet.createRow(i+ startRow); + isCreat = true; + } +// if(i<17) { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// }else{ +// row = sheet.createRow(i+ startRow); +// isCreat = true; +// } + if (isCreat) { + XSSFRow oldRow = sheet.getRow(i + startRow - 1); + + if(oldRow==null) { + oldRow = sheet.createRow(i + startRow - 1); + } + for (int j = 0; j < 32; j++) { + XSSFCell oldCell = oldRow.getCell(j); + if(oldCell==null) { + oldCell=oldRow.createCell(j); + } + XSSFCell newCell = row.createCell(j); + newCell.setCellStyle(oldCell.getCellStyle()); + newCell.setCellType(oldCell.getCellType()); + } + } + //循环添加列 + for(int j=1;j<31;j++) { + if(j==16||j==29) { + String picMeString; + if(j>25) { + picMeString = (String)dataValeList.get(i).get(j+3); + }else { + picMeString = (String)dataValeList.get(i).get(j); + } + + System.out.println("picMeString ====> "+picMeString); + if(picMeString!=null&&!picMeString.equals("")) { + int indexOf = tstxList.indexOf(picMeString); + if(indexOf>=1) { + File file = dsUidList.get(indexOf-1); + String path = file.getPath(); + System.out.println("path==>"+path); + picture2(sheet, wb, j-1, i+ startRow, path); + } + + } + + }else { + XSSFCell cell = row.getCell(j-1); + if(cell==null) { + cell=row.createCell(j-1); + } + + if(j<25) { + cell.setCellValue((String)dataValeList.get(i).get(j)); + }else { + cell.setCellValue((String)dataValeList.get(i).get(j+3)); + } + } + } + } + //+++++++++++++ + +// //第二页导出++++++ +// int startRow2 = 3; +//// XSSFRow row21 = sheet2.getRow(2); +//// if(row21==null) { +//// row21=sheet2.createRow(2); +//// } +//// setCellValue(row21,0,"项目:"+pfmeaBean.getProject()); +//// setCellValue(row21,3,"设计职责:"+pfmeaBean.getProcessDuty()); +//// setCellValue(row21,7,"FMEA编号:"+pfmeaBean.getPfmeaNumber()); +// XSSFRow row22 = sheet2.getRow(3); +// if(row22==null) { +// row22=sheet2.createRow(3); +// } +//// setCellValue(row22,0,"FMEA日期(原始):"+pfmeaBean.getPfmeaStartDate()); +// +// for (int i = 0; i < dataValue.length; i++) { +// XSSFRow row = null; +// Boolean isCreat = false; +// +// row = sheet2.getRow(i + startRow2); +// if(row ==null) { +// row = sheet2.createRow(i+ startRow2); +// isCreat = true; +// }else { +// isCreat = false; +// } +// +//// if(i<15) { +//// row = sheet2.getRow(i + startRow2); +//// isCreat = false; +//// }else{ +//// row = sheet2.createRow(i+ startRow2); +//// isCreat = true; +//// } +// if (isCreat) { +// XSSFRow oldRow = sheet2.getRow(i + startRow2 - 1); +// if(oldRow==null) { +// oldRow = sheet2.createRow(i + startRow2 - 1); +// } +// for (int j = 0; j < 9; j++) { +// XSSFCell oldCell = oldRow.getCell(j); +// XSSFCell newCell = row.createCell(j); +// if(oldCell==null) { +// oldCell=oldRow.createCell(j); +// } +// newCell.setCellStyle(oldCell.getCellStyle()); +// newCell.setCellType(oldCell.getCellType()); +// } +// combine(sheet2, new int[] { i + startRow2 }, new int[] { 3, 5 }); +// } +// //循环添加列 +//// XSSFCell cell0 = row.getCell(0); +// setCellValue(row,0,String.valueOf(i+1)); //关键日期 +// setCellValue(row,1,dataValue[i][1]); +// setCellValue(row,2,itemRevision.getStringProperty("item_revision_id")); +// setCellValue(row,3,dataValue[i][3]); +// setCellValue(row,4,dataValue[i][4]); +// setCellValue(row,5,dataValue[i][5]); +// setCellValue(row,6,dataValue[i][6]); +//// for(int j=1;j<8;j++) { +//// +//// if(j<5) { +//// XSSFCell cell = row.getCell(j-1); +//// +//// if(cell==null) { +//// cell=row.createCell(j-1); +//// } +//// cell.setCellValue(dataValue[i][j]); +//// }else { +//// XSSFCell cell = row.getCell(j+1); +//// if(cell==null) { +//// cell=row.createCell(j+1); +//// } +//// cell.setCellValue(dataValue[i][j]); +//// } +//// } +// } + +// } + // 合并单元格 + if (excelCombineMap != null && excelCombineMap.size() > 0) { + Iterator> it = excelCombineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + int[] row = new int[entry.getKey().length]; + int[] column = new int[entry.getValue().length]; + for (int k = 0; k < entry.getKey().length; k++) { + //row[k] = entry.getKey()[k] + 17; + row[k] = entry.getKey()[k]+8 ; + } + for (int k = 0; k < entry.getValue().length; k++) { + if (entry.getValue()[k] == 1) { + //column[k] = entry.getValue()[k] + 1; + column[k] = entry.getValue()[k] -1; + } else { + //column[k] = entry.getValue()[k] + column[k] = entry.getValue()[k]-1; + } + } + ExcelUtil.combine_XSSF(sheet, row, column); + } + } + wb.write(output); + output.close(); + input.close(); + //ExcelUtil.setExcelToItem(session, itemRevision, outFilePath, "PFMEA", true); + if (ExcelUtil07.getExcelToItem(session, itemRevision, + "IMAN_specification", "MSExcelX") != null) { + ExcelUtil07.changeDataSet( + ExcelUtil07.getExcelToDataset(session, itemRevision, "IMAN_specification", "MSExcelX"), + "excel", "MSExcelX", outFilePath); + new File(outFilePath).delete(); + } else { + ExcelUtil07.setExcelToItem(session, itemRevision, outFilePath, name, "IMAN_specification", + "MSExcelX", true); + } + System.out.println("-------WRITE EXCEL OVER-------"); + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.toString(), "错误", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + } + + private void outPutSheet1(HSSFWorkbook wb, String[][] dataValue) { + // TODO Auto-generated method stub + HSSFSheet sheet = wb.getSheetAt(0); + for (int i = 0; i < dataValue[0].length; i++) { + HSSFRow row = null; + Boolean isCreat = false; + if ((i + 1) > sheet.getLastRowNum()) { + row = sheet.createRow(i + 1); + isCreat = true; + } else { + row = sheet.getRow(i + 1); + isCreat = false; + } + for (int j = 0; j < dataValue.length; j++) { + HSSFCell cell = null; + if (isCreat) { + cell = row.createCell(j); + } else { + cell = row.getCell(j); + } + + if (cell == null) { + cell = row.createCell(j); + } + cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 + cell.setCellValue(dataValue[j][i]); + } + } + + } + + private List> getTableValue() { + // TODO Auto-generated method stub + List> dataValeList = new ArrayList>(); + + for (int j = 0; j < processRows.size(); j++) { + List rowValue = new ArrayList(); + int a = this.map.getColumnCount(); + for (int j2 = 0; j2 < this.map.getColumnCount()-1; j2++) { +// if (j2 == 1) { +// //table.getValueAt(j, j2) != null && isStr2Num(table.getValueAt(j, j2).toString()) +// if (table.getValueAt(j, j2) != null ) { +// rowValue.add(table.getValueAt(j, j2).toString()); +// } else { +// rowValue.add(""); +// } +// } +// +// else { + if (j2 < 25) { + rowValue.add(table.getValueAt(j, j2) == null ? "" : table.getValueAt(j, j2).toString()); + } +// } +// // rowValue.add(getCellValue(processRows.get(j), j2)); + } + rowValue.add(processRows.get(j).toString());//25行号 + // rowValue.add("1"); + if (combineMap.size() > 0) { + rowValue.add(TMomMethodUtil.getCombineCell(combineMap, processRows.get(j)));//26合并单元格 + } else { + rowValue.add(""); + } +// if (rowValue.size() == 26) { +// rowValue.add(""); +// } +// if (isComplete) { +// rowValue.add("1"); +// } else { + rowValue.add("");//27行号差 +// } + rowValue.add("");//28 + rowValue.add("");//29 + + for (int j2 = 25; j2 < this.map.getColumnCount()-1; j2++) { + rowValue.add(table.getValueAt(j, j2) == null ? "" : table.getValueAt(j, j2).toString()); + } + + String cellValue = getCellValue(processRows.get(j),this.map.getColumnCount()-1 ); + System.out.println("processRows.get(j)==>"+processRows.get(j)+"map.getColumnCount()"+map.getColumnCount()); + System.out.println("cellValue==>"+cellValue); + rowValue.add(cellValue); + dataValeList.add(rowValue); + } + // for (int i = 0; i < processRowList.size(); i++) { + // List rows = processRowList.get(i); + // } + return dataValeList; + } + + private String getCellValue(int row, int cloumn) { + // TODO Auto-generated method stub + String resultValue = ""; + if (this.map.getValueAt(row, cloumn) != null) { + resultValue = this.map.getValueAt(row, cloumn).toString(); + } + if (combineMap != null && combineMap.size() > 0) { + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + List keysList = new ArrayList<>(); + List valuesList = new ArrayList<>(); + for (int k = 0; k < entry.getKey().length; k++) { + keysList.add(entry.getKey()[k]); + } + for (int k = 0; k < entry.getValue().length; k++) { + valuesList.add(entry.getValue()[k]); + } + if (keysList.contains(row) && valuesList.contains(cloumn)) { + return (String) this.map.getValueAt(Integer.parseInt(keysList.get(0).toString()), + Integer.parseInt(valuesList.get(0).toString())); + } + } + } else { + if (this.map.getValueAt(row, cloumn) != null) { + return this.map.getValueAt(row, cloumn).toString(); + } + + } + return resultValue; + } + + //修改描述信息,关闭权限 + private void closePermission() { + if(isOwning) { + //关闭权限修改 + if(((TCComponent) comp).isCheckedOut()) { + ReservationService service=ReservationService.getService((TCSession)app.getSession()); + service.checkin(new TCComponent[] {(TCComponent) this.comp});//签入 + } + } + } + + private String[] setCombineMap() { + String[] combines = new String[combineMap.size()]; + Iterator> it = combineMap.entrySet().iterator(); + int index = 0; + while (it.hasNext()) { + Map.Entry entry = it.next(); + StringBuffer rowSb = new StringBuffer(); + StringBuffer columnSb = new StringBuffer(); + for (int i = 0; i < entry.getKey().length; i++) { + rowSb.append(entry.getKey()[i]); + rowSb.append(","); + } + for (int i = 0; i < entry.getValue().length; i++) { + columnSb.append(entry.getValue()[i]); + columnSb.append(","); + } + combines[index] = rowSb.substring(0, rowSb.length() - 1) + "/" + + columnSb.substring(0, columnSb.length() - 1); + index++; + } + return combines; + } + + private int[] Union(int[] a1, int[] a2) { + List list1 = new ArrayList(); + List list2 = new ArrayList(); + for (int i : a1) { + list1.add(i); + } + for (int i : a2) { + list2.add(i); + } + list1.removeAll(list2); + list2.addAll(list1); + int[] result = new int[list2.size()]; + for (int i = 0; i < list2.size(); i++) { + result[i] = list2.get(i); + } + return result; + } + + /** + * 添加行 + */ + private void addRow() { + // TODO Auto-generated method stub + if (this.tabbedPane.getSelectedIndex() == 1) { + CTMap2 map = ((CTMap2) this.table2.getModel()); + map.insertRow(this.table2.getSelectedRow() + 1); + } else { + int row = table.getSelectedRow(); + if (this.processRows != null && this.processRows.size() == 0 && !(this.processRows.contains(row))) { + MessageBox.post("无权限添加行!", "错误", MessageBox.ERROR); + return; + } + Map cellMap = new HashMap(); + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + List keysList = new ArrayList<>(); + for (int j = 0; j < entry.getKey().length; j++) { + keysList.add(entry.getKey()[j]); + } + if (keysList.contains(row)) { + int[] newKey = new int[entry.getKey().length]; + for (int i = 0; i < entry.getKey().length; i++) { + for (int j = 0; j < entry.getValue().length; j++) { + map.split(entry.getKey()[i], entry.getValue()[j]); + } + newKey[i] = entry.getKey()[i]; + } + it.remove(); + // newKey[entry.getKey().length] = newKey[entry.getKey().length - 1] + 1; + cellMap.put(newKey, entry.getValue()); + } else if (!keysList.contains(row) && Integer.parseInt(keysList.get(0).toString()) > row) { + int[] newKey = new int[entry.getKey().length]; + for (int i = 0; i < entry.getKey().length; i++) { + newKey[i] = entry.getKey()[i] + 1; + } + it.remove(); + cellMap.put(newKey, entry.getValue()); + } + } + map.insertRow(table.getSelectedRow() + 1); + table.setValueAt(UUID.randomUUID().toString().replace("-", ""), table.getSelectedRow() + 1, 0); + table.setValueAt(table.getValueAt(table.getSelectedRow(), 2), table.getSelectedRow() + 1, 2); + table.setValueAt(table.getValueAt(table.getSelectedRow(), table.getColumnCount() - 1), table.getSelectedRow() + 1, table.getColumnCount() - 1); + //this.processRows = map.getProcessRowList(); + Iterator> cellIt = cellMap.entrySet().iterator(); + while (cellIt.hasNext()) { + Map.Entry entry = cellIt.next(); + map.combine(entry.getKey(), entry.getValue()); + combineMap.put(entry.getKey(), entry.getValue()); + } + table.revalidate(); + table.repaint(); + } + } + + /** + * 添加合并行 + */ + private void addCombineRow() { + // TODO Auto-generated method stub + if (this.tabbedPane.getSelectedIndex() == 1) { + CTMap2 map = ((CTMap2) this.table2.getModel()); + map.insertRow(this.table2.getSelectedRow() + 1); + } else { + int row = table.getSelectedRow(); + if (this.processRows != null && this.processRows.size() == 0 && !(this.processRows.contains(row))) { + MessageBox.post("无权限添加行!", "错误", MessageBox.ERROR); + return; + } + Map cellMap = new HashMap(); + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + List keysList = new ArrayList<>(); + for (int j = 0; j < entry.getKey().length; j++) { + keysList.add(entry.getKey()[j]); + } + if (keysList.contains(row)) { + int[] newKey = new int[entry.getKey().length + 1]; + for (int i = 0; i < entry.getKey().length; i++) { + for (int j = 0; j < entry.getValue().length; j++) { + map.split(entry.getKey()[i], entry.getValue()[j]); + } + newKey[i] = entry.getKey()[i]; + } + it.remove(); + newKey[entry.getKey().length] = newKey[entry.getKey().length - 1] + 1; + cellMap.put(newKey, entry.getValue()); + } else if (!keysList.contains(row) && Integer.parseInt(keysList.get(0).toString()) > row) { + int[] newKey = new int[entry.getKey().length]; + for (int i = 0; i < entry.getKey().length; i++) { + newKey[i] = entry.getKey()[i] + 1; + } + it.remove(); + cellMap.put(newKey, entry.getValue()); + } + } + map.insertRow(table.getSelectedRow() + 1); + table.setValueAt(UUID.randomUUID().toString().replace("-", ""), table.getSelectedRow() + 1, 0); + table.setValueAt(table.getValueAt(table.getSelectedRow(), 4), table.getSelectedRow() + 1, 4); + table.setValueAt(table.getValueAt(table.getSelectedRow(), table.getColumnCount() - 1), table.getSelectedRow() + 1, table.getColumnCount() - 1); + // this.processRows = map.getProcessRowList(); + Iterator> cellIt = cellMap.entrySet().iterator(); + while (cellIt.hasNext()) { + Map.Entry entry = cellIt.next(); + map.combine(entry.getKey(), entry.getValue()); + combineMap.put(entry.getKey(), entry.getValue()); + } + table.revalidate(); + table.repaint(); + } + } + + /** + * 移除行 + */ + private void remRow() { + // TODO Auto-generated method stub + if (this.tabbedPane.getSelectedIndex() == 1) { + if (table2.getSelectedRow() > 0 && table2.getSelectedColumn() > 0) { + (table2.getCellEditor(table2.getSelectedRow(), table2.getSelectedColumn())).stopCellEditing(); + } + int[] rows = table2.getSelectedRows(); + CTMap map = ((CTMap) this.table2.getModel()); + for (int i = 0; i < rows.length; i++) { + map.removeRow(table2.getSelectedRow()); + } + } else { + if (table.getSelectedRow() > 0 && table.getSelectedColumn() > 0) { + (table.getCellEditor(table.getSelectedRow(), table.getSelectedColumn())).stopCellEditing(); + } + int[] rows = table.getSelectedRows(); + for (int i1 = 0; i1 < rows.length; i1++) { + if (this.processRows != null && this.processRows.size() > 0 + && !(this.processRows.contains(table.getSelectedRow()))) { + MessageBox.post("无权限删除行!", "错误", MessageBox.ERROR); + return; + } + Map cellMap = new HashMap(); + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + List keysList = new ArrayList<>(); + for (int j = 0; j < entry.getKey().length; j++) { + keysList.add(entry.getKey()[j]); + } + if (keysList.contains(table.getSelectedRow())) { + int[] newKey = new int[entry.getKey().length - 1]; + for (int i = 0; i < entry.getKey().length; i++) { + for (int j = 0; j < entry.getValue().length; j++) { + map.split(entry.getKey()[i], entry.getValue()[j]); + } + if (i < newKey.length) { + newKey[i] = entry.getKey()[i]; + } + } + it.remove(); + cellMap.put(newKey, entry.getValue()); + } else if (!keysList.contains(table.getSelectedRow()) + && Integer.parseInt(keysList.get(0).toString()) > table.getSelectedRow()) { + int[] newKey = new int[entry.getKey().length]; + for (int i = 0; i < entry.getKey().length; i++) { + for (int j = 0; j < entry.getValue().length; j++) { + map.split(entry.getKey()[i], entry.getValue()[j]); + } + newKey[i] = entry.getKey()[i] - 1; + } + it.remove(); + cellMap.put(newKey, entry.getValue()); + } + } + if (map.getValueAt(table.getSelectedRow(), 0) != null + && plmeidList.contains(map.getValueAt(table.getSelectedRow(), 0))) { + deleteRows.add(map.getValueAt(table.getSelectedRow(), 0).toString()); + } + map.removeRow(table.getSelectedRow()); + // this.processRows = map.getProcessRowList(); + Iterator> cellIt = cellMap.entrySet().iterator(); + while (cellIt.hasNext()) { + Map.Entry entry = cellIt.next(); + if (entry.getKey().length > 0 && entry.getValue().length > 0) { + map.combine(entry.getKey(), entry.getValue()); + combineMap.put(entry.getKey(), entry.getValue()); + } + } + table.revalidate(); + table.repaint(); + } + } + } + +// /** +// * 合并单元格 +// */ +// private void comBineCell2() { +// // TODO Auto-generated method stub +// // table.setRowHeight(2, 50); +// int[] rows = table2.getSelectedRows(); +// int[] columns = table2.getSelectedColumns(); +// if (rows.length <= 0) { +// MessageBox.post("请选择要合并的单元格!", "错误", MessageBox.ERROR); +// return; +// } +//// for (int i = 0; i < rows.length; i++) { +//// if (this.processRows != null && this.processRows.size() > 0 && !(this.processRows.contains(rows[i]))) { +//// MessageBox.post("无权限合并单元格", "错误", MessageBox.ERROR); +//// return; +//// } +//// } +// if (combineMap2 != null && combineMap2.size() != 0) { +// for (int i = 0; i < rows.length; i++) { +// Iterator> it = combineMap2.entrySet().iterator(); +// while (it.hasNext()) { +// Map.Entry entry = it.next(); +// List keysList = new ArrayList<>(); +// for (int j = 0; j < entry.getKey().length; j++) { +// keysList.add(entry.getKey()[j]); +// } +// if (keysList.contains(rows[i])) { +// for (int j = 0; j < columns.length; j++) { +// List valueList = new ArrayList<>(); +// for (int k = 0; k < entry.getValue().length; k++) { +// valueList.add(entry.getValue()[k]); +// } +// if (valueList.contains(columns[j])) { +// columns = Union(columns, entry.getValue()); +// rows = Union(rows, entry.getKey()); +// if (combineMap2.get(entry.getKey()) != null) { +// it.remove(); +// } +// } +// } +// } +// } +// } +// combineMap2.put(rows, columns); +// } else { +// combineMap2.put(rows, columns); +// } +// for (int i = 0; i < rows.length; i++) { +// for (int j = 0; j < columns.length; j++) { +// map2.split(rows[i], columns[j]); +// } +// } +// Arrays.sort(rows); +// Arrays.sort(columns); +// map2.combine(rows, columns); +// // map.removeRow(table.getSelectedRow()); +// table2.revalidate(); +// table2.repaint(); +// } + + /** + * 合并单元格 + */ + private void comBineCell() { + // TODO Auto-generated method stub + // table.setRowHeight(2, 50); + int[] rows = table.getSelectedRows(); + int[] columns = table.getSelectedColumns(); +// if(rows.length<=1&&columns.length<=1) { +// return; +// } + if (rows.length <= 0) { + MessageBox.post("请选择要合并的单元格!", "错误", MessageBox.ERROR); + return; + } + for (int i = 0; i < rows.length; i++) { + if (this.processRows != null && this.processRows.size() > 0 && !(this.processRows.contains(rows[i]))) { + MessageBox.post("无权限合并单元格", "错误", MessageBox.ERROR); + return; + } + } + if (combineMap != null && combineMap.size() != 0) { + for (int i = 0; i < rows.length; i++) { + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + List keysList = new ArrayList<>(); + for (int j = 0; j < entry.getKey().length; j++) { + keysList.add(entry.getKey()[j]); + } + if (keysList.contains(rows[i])) { + for (int j = 0; j < columns.length; j++) { + List valueList = new ArrayList<>(); + for (int k = 0; k < entry.getValue().length; k++) { + valueList.add(entry.getValue()[k]); + } + if (valueList.contains(columns[j])) { + columns = Union(columns, entry.getValue()); + rows = Union(rows, entry.getKey()); + if (combineMap.get(entry.getKey()) != null) { + it.remove(); + } + } + } + } + } + } +// combineMap + combineMap.put(rows, columns); + } else { + combineMap.put(rows, columns); + } + for (int i = 0; i < rows.length; i++) { + for (int j = 0; j < columns.length; j++) { + map.split(rows[i], columns[j]); + } + } + Arrays.sort(rows); + Arrays.sort(columns); + System.out.println("rows"+rows.length+"columns"+columns.length); + map.combine(rows, columns); + // map.removeRow(table.getSelectedRow()); + table.invalidate(); + table.revalidate(); + table.repaint(); + } + + /** + * 拆分单元格 + */ + private void splitCell() { + // TODO Auto-generated method stub + int row = table.getSelectedRow(); + int colmn = table.getSelectedColumn(); + if (row < 0) { + MessageBox.post("请选择要拆分的单元格!", "错误", MessageBox.ERROR); + return; + } +// if (this.processRows != null && this.processRows.size() > 0 +// && !(this.processRows.contains(row))) { +// MessageBox.post("无权限拆分单元格!", "错误", MessageBox.ERROR); +// return; +// } + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + List keysList = new ArrayList<>(); + List valuesList = new ArrayList<>(); + for (int j = 0; j < entry.getKey().length; j++) { + keysList.add(entry.getKey()[j]); + } + for (int j = 0; j < entry.getValue().length; j++) { + valuesList.add(entry.getValue()[j]); + } + if (keysList.contains(row) && valuesList.contains(colmn)) { + for (int i = 0; i < entry.getKey().length; i++) { + for (int j = 0; j < entry.getValue().length; j++) { + map.split(entry.getKey()[i], entry.getValue()[j]); + } + } + it.remove(); + } + } + + table.revalidate(); + table.repaint(); + } + + /** + * 查看一个字符串是否可以转换为数字 + * + * @param str 字符串 + * @return true 可以; false 不可以 + */ + public boolean isStr2Num(String str) { + try { + Integer.parseInt(str); + return true; + } catch (NumberFormatException e) { + return false; + } + } + + /** + * 定时保存 + */ + public void runTask() { + timer = new Timer(); + timer.schedule(new TimerTask() { + + @Override + public void run() { + // TODO Auto-generated method stub + System.out.println("....."); +// if(isOwning) { +// okEvent(true, false); +// } + } + }, 300 * 1000, 300 * 1000); + +// final long timeInterval = 120000;// 两分钟运行一次 +// Runnable runnable = new Runnable() { +// public void run() { +// while (true) { +// // ------- code for task to run +// okEvent(true); +// // ------- ends here +// //System.out.println(123); +// try { +// Thread.sleep(timeInterval); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// } +// } +// } +// }; +// Thread thread = new Thread(runnable); +// thread.start(); + } + + private class selectExportPath extends AbstractAIFDialog implements ActionListener { + // 界面控件 + private JPanel mainPanel; + private JFileChooser jfc; + private JButton okButton; + private JButton celButton; + private JButton fileButton; + private JTextField pathText; + private JTextField fleName; + private PFMEABean pfmeaBean; + private List> dataValeList; + private String[][] dataValue; + private String name; + public selectExportPath(PFMEABean pfmeaBean, List> dataValeList, String[][] dataValue,String name) { + this.pfmeaBean=pfmeaBean; + this.dataValeList=dataValeList; + this.dataValue=dataValue; + this.name = name; + init(); + } + + private void init() { + //获取国际化语言 + Locale defaultLocale=Locale.getDefault(); + ResourceBundle rb=ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message",defaultLocale); + // TODO Auto-generated method stub + this.setTitle(rb.getString("xzdclj31_display.TITLE")); + this.setPreferredSize(new Dimension(480, 200)); + jfc = new JFileChooser(); + jfc.setCurrentDirectory(new File("c:\\"));// 文件选择器的初始目录定为d盘 + this.okButton = new JButton(rb.getString("dc_display.TITLE")); + this.celButton = new JButton(rb.getString("qx_display.TITLE")); + this.fileButton = new JButton("..."); + this.okButton.addActionListener(this); + this.celButton.addActionListener(this); + this.fileButton.addActionListener(this); + this.fileButton.setPreferredSize(new Dimension(50, 30)); + this.pathText = new JTextField(); + pathText.setText("C:"); + this.pathText.setPreferredSize(new Dimension(300, 30)); + fleName = new JTextField(); + fleName.setText("PFMEA"); + this.fleName.setPreferredSize(new Dimension(300, 30)); + + JLabel label = new JLabel(rb.getString("wjmc31_display.TITLE")); + label.setPreferredSize(new Dimension(100, 30)); + JLabel label2 = new JLabel(rb.getString("xzwjj_display.TITLE")); + label2.setPreferredSize(new Dimension(100, 30)); + + JPanel panel1 = new JPanel(new FlowLayout()); + panel1.add(label); + panel1.add(fleName); + JPanel panel2 = new JPanel(new FlowLayout()); + panel2.add(label2); + panel2.add(pathText); + panel2.add(fileButton); + + this.mainPanel = new JPanel(new PropertyLayout()); + + this.mainPanel.add("1.1.left.top", panel1); + this.mainPanel.add("2.1.left.top", panel2); + + JPanel rootPanel = new JPanel(new FlowLayout()); + rootPanel.add(new JLabel(" ")); + rootPanel.add(new JLabel(" ")); + rootPanel.add(this.okButton); + rootPanel.add(new JLabel(" ")); + rootPanel.add(this.celButton); + + + this.setLayout(new BorderLayout()); + this.add(mainPanel, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + this.pack(); + // this.centerToScreen(); + this.showDialog(); + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + if (source.equals(this.fileButton)) { + selectFileButtonEvent(e); + } else if (source.equals(this.okButton)) { + // 获取导出模板 + String outFilePath = this.pathText.getText() + "\\"+this.name.replace("/", "-")+".xlsx"; +//+++++++ + + InputStream input = null; + try { + File pfmeaFile = TMomMethodUtil.getFile(session, "PFMEA设计", "MSExcel"); + if (pfmeaFile != null) { + input = new FileInputStream(pfmeaFile); + } else { + MessageBox.post("未找到PFMEA模板!", "错误", MessageBox.ERROR); + return; + } + FileOutputStream output = new FileOutputStream(new File(outFilePath)); + XSSFWorkbook wb = new XSSFWorkbook(input); + XSSFSheet sheet = wb.getSheetAt(1); + XSSFSheet sheet2 = wb.getSheetAt(2); + //第一页导出++++ + int startRow = 10; + XSSFRow row4 = sheet.getRow(3); + setCellValue(row4,4,pfmeaBean.getCompanyName()); + //setCellValue(row,,pfmeaBean); + setCellValue(row4,7,pfmeaBean.getProject()); + setCellValue(row4,9,pfmeaBean.getPfmeaNumber()); + XSSFRow row5 = sheet.getRow(4); + setCellValue(row5,4,pfmeaBean.getAddress()); + setCellValue(row5,7,pfmeaBean.getPfmeaStartDate()); + setCellValue(row5,9,pfmeaBean.getProcessDuty()); + XSSFRow row6 = sheet.getRow(5); + setCellValue(row6,4,pfmeaBean.getCustomerName()); + setCellValue(row6,7,pfmeaBean.getPfmeaUpdateDate()); + setCellValue(row6,9,pfmeaBean.getSecurityClassification()); + XSSFRow row7 = sheet.getRow(6); + setCellValue(row7,4,pfmeaBean.getModelPlatform()); + setCellValue(row7,7,pfmeaBean.getFunctionalTeams()); + + for (int i = 0; i < dataValeList.size(); i++) { + XSSFRow row = null; + Boolean isCreat = false; + row = sheet.getRow(i + startRow); + if(row==null) { + row = sheet.createRow(i+ startRow); + isCreat = true; + } + +// if(i<17) { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// }else{ +// row = sheet.createRow(i+ startRow); +// isCreat = true; +// } + if (isCreat) { + XSSFRow oldRow = sheet.getRow(i + startRow - 1); + if(oldRow==null) { + oldRow = sheet.createRow(i + startRow - 1); + } + for (int j = 0; j < 32; j++) { + XSSFCell oldCell = oldRow.getCell(j); + XSSFCell newCell = row.createCell(j); + if(oldCell==null) { + oldCell=oldRow.createCell(j); + } + newCell.setCellStyle(oldCell.getCellStyle()); + newCell.setCellType(oldCell.getCellType()); + } + } + //循环添加列 + for(int j=1;j<31;j++) { + XSSFCell cell = row.getCell(j-1); + if(j<25) { + cell.setCellValue((String)dataValeList.get(i).get(j)); + }else { + cell.setCellValue((String)dataValeList.get(i).get(j+3)); + } + } + } + //+++++++++++++ + + //第二页导出++++++ + int startRow2 = 6; + XSSFRow row21 = sheet2.getRow(2); + setCellValue(row21,0,"项目:"+pfmeaBean.getProject()); + setCellValue(row21,3,"设计职责:"+pfmeaBean.getProcessDuty()); + setCellValue(row21,7,"FMEA编号:"+pfmeaBean.getPfmeaNumber()); + XSSFRow row22 = sheet2.getRow(3); + setCellValue(row22,0,"FMEA日期(原始):"+pfmeaBean.getPfmeaStartDate()); + + for (int i = 0; i < dataValue.length; i++) { + XSSFRow row = null; + Boolean isCreat = false; + + if(row==null) { + row = sheet2.createRow(i+ startRow2); + isCreat = true; + } +// if(i<15) { +// row = sheet2.getRow(i + startRow2); +// isCreat = false; +// }else{ +// row = sheet2.createRow(i+ startRow2); +// isCreat = true; +// } + if (isCreat) { + XSSFRow oldRow = sheet2.getRow(i + startRow2 - 1); + if(oldRow==null) { + oldRow = sheet2.createRow(i + startRow2 - 1); + } + for (int j = 0; j < 9; j++) { + XSSFCell oldCell = oldRow.getCell(j); + if(oldCell==null) { + oldCell=oldRow.createCell(j); + } + XSSFCell newCell = row.createCell(j); + newCell.setCellStyle(oldCell.getCellStyle()); + newCell.setCellType(oldCell.getCellType()); + } + combine(sheet2, new int[] { i + startRow2 }, new int[] { 3, 5 }); + } + //循环添加列 + for(int j=1;j<8;j++) { + if(j<5) { + XSSFCell cell = row.getCell(j-1); + cell.setCellValue(dataValue[i][j]); + }else { + XSSFCell cell = row.getCell(j+1); + cell.setCellValue(dataValue[i][j]); + } + } + } + + // 合并单元格 + if (excelCombineMap != null && excelCombineMap.size() > 0) { + Iterator> it = excelCombineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + int[] row = new int[entry.getKey().length]; + int[] column = new int[entry.getValue().length]; + for (int k = 0; k < entry.getKey().length; k++) { + //row[k] = entry.getKey()[k] + 17; + row[k] = entry.getKey()[k]+10 ; + } + for (int k = 0; k < entry.getValue().length; k++) { + if (entry.getValue()[k] == 1) { + //column[k] = entry.getValue()[k] + 1; + column[k] = entry.getValue()[k] -1; + } else { + //column[k] = entry.getValue()[k] + column[k] = entry.getValue()[k]-1; + } + } + ExcelUtil.combine_XSSF(sheet, row, column); + } + } + wb.write(output); + output.close(); + input.close(); + } catch (Exception e1) { + // TODO: handle exception + MessageBox.post(e1.toString(), "错误", MessageBox.ERROR); + e1.printStackTrace(); + } finally { + if (input != null) { + try { + input.close(); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } +//+++++++ + MessageBox.post("导出Excel成功!", "成功", MessageBox.INFORMATION); + this.dispose(); + } else if (source.equals(this.celButton)) { + this.dispose(); + } + } + + /** + * 文件夹选择按钮事件 + * + * @param e + */ + public void selectFileButtonEvent(ActionEvent e) { + jfc.setFileSelectionMode(1);// 设定只能选择到文件夹 + int state = jfc.showOpenDialog(null);// 此句是打开文件选择器界面的触发语句 + if (state == 1) { + return; + } else { + File f = jfc.getSelectedFile();// f为选择到的目录 + pathText.setText(f.getAbsolutePath()); + } + } + } + + + + + private class SpecialDialog extends JFrame implements ActionListener { + private JPanel tablePanel;// 表格控件 + private JTable table; + + private JPanel rootPanel;// 按钮 + private JButton okButton;// 确定 + private JButton celButton;// 取消 + + public SpecialDialog() { + // TODO Auto-generated constructor stub + super(); + init(); + } + + private void init() { + //获取国际化语言 + Locale defaultLocale=Locale.getDefault(); + ResourceBundle rb=ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message",defaultLocale); + // TODO Auto-generated method stub + this.setTitle(rb.getString("xztsfh10_display.TITLE")); + this.table = getjTable(this.table, null, new Object[] { 1, 2, 3, 4, 5, 6, 7, 8 }, + new Object[][] { { 1, 2, 3, 4, 5, 6, 7, 8 }, { 9, 0, "q", "w", "e", "r", "t", "y" } }); + this.setLocationRelativeTo(this); + this.table.setRowHeight(30); + this.table.getTableHeader().setVisible(false); + this.table.setFont(new Font("Y14.5M", 0, 15)); + this.tablePanel = new JPanel(new BorderLayout()); + this.tablePanel.add(this.table); + + this.okButton = new JButton(rb.getString("qd_display.TITLE")); + this.okButton.addActionListener(this); + this.celButton = new JButton(rb.getString("qx_display.TITLE")); + this.celButton.addActionListener(this); + this.rootPanel = new JPanel(new FlowLayout()); + this.rootPanel.add(this.okButton); + this.rootPanel.add(this.celButton); + + this.add(this.tablePanel, BorderLayout.CENTER); + this.add(this.rootPanel, BorderLayout.SOUTH); + this.pack(); + this.show(); + } + + // Jtable通用方法 + public JTable getjTable(JTable partsTable, DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + int simpleLen = 100; + int totleLen = 1000; + if (partsTable == null) { + partsTable = new JTable(this.getTableModel(dtm, titleNames, values)); + partsTable.setCellSelectionEnabled(true); + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + + public DefaultTableModel getTableModel(DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + MyTableModel tableModel = null; + if (dtm == null) { + tableModel = new MyTableModel(values, titleNames); + } + return tableModel; + } + + @Override + public void actionPerformed(ActionEvent actionevent) { + // TODO Auto-generated method stub + Object source = actionevent.getSource(); + if (source.equals(this.okButton)) { + int row = DesignPFMEADialog.table.getSelectedRow(); + int column = DesignPFMEADialog.table.getSelectedColumn(); + // 保存特殊符号位置 + String columnName = DesignPFMEADialog.table + .getColumnName(DesignPFMEADialog.table.getSelectedColumn()); + + int cursorIndex = ((TextAreaCellEditor) (DesignPFMEADialog.table.getCellEditor(row, column))) + .getIndex(); + System.out.println("index+" + cursorIndex); + (DesignPFMEADialog.table.getCellEditor(row, column)).stopCellEditing(); + // DesignPFMEADialog.table.getDefaultEditor(Object.class).stopCellEditing(); + StringBuilder sb = new StringBuilder(DesignPFMEADialog.table.getValueAt(row, column).toString()); + + // 定义循环,如果index的位置不是-1,就一直查找 + Integer index = 0; + while ((index = sb.toString().indexOf("\n", index)) != -1) { + + // 每循环一次就要明确下一次查找的位置 + index = index + "\n".length(); + // 每查找一次计数器自增 + cursorIndex++; + } + // 特殊符号 + Object special = DesignPFMEADialog.table.getValueAt(row, + DesignPFMEADialog.table.getColumnCount() - 1); + if (special == null || special.toString() == "") { + DesignPFMEADialog.table.setValueAt(columnName + "-" + cursorIndex, row, + DesignPFMEADialog.table.getColumnCount() - 1); + } else { + DesignPFMEADialog.table.setValueAt(special + "|" + columnName + "-" + cursorIndex, row, + DesignPFMEADialog.table.getColumnCount() - 1); + } + System.out.println(sb.length()); + String s = sb + .insert(cursorIndex, this.table + .getValueAt(this.table.getSelectedRow(), this.table.getSelectedColumn()).toString()) + .toString(); + DesignPFMEADialog.table.setValueAt(s, DesignPFMEADialog.table.getSelectedRow(), + DesignPFMEADialog.table.getSelectedColumn()); + System.out.println(DesignPFMEADialog.table.getValueAt(row, column).toString()); + } else { + this.dispose(); + } + } + } + + private class LibraryDialog extends JFrame { + private List beans = new ArrayList(); + private int index = -1; + private List dontMove = new ArrayList(); + private TableRowSorter mainSorter; + // 查询框 + private JTextField findLeftField; + private JButton findLeftButton; + // 查询框 + private JTextField findMainField; + private JTextField findColumnField; + private JButton findMainButton; + + private JTextField heightField; + private JButton heightButton; + private JButton saveBtnSize; + private JButton findColumnButton; + // 界面所需控件 + private JTextPane selectCellValuePane; + private JPanel titlePanel;// 标题 + private JLabel titleLabel; + // 导航栏 + private CTable leftTable; + private JTable mainTable; + private int setRowHeight = 0; + private int selectMainRow = -1; + private int selectMainCol = -1; + private Map combineMap=new HashMap();// 存放合并单元格 + +// private Map combineMap2=new HashMap();// 存放合并单元格 + private CTMap2 map; + + // 右键菜单 + private JPopupMenu libraryMenu; + // 右键菜单项 + private JMenuItem copyRowItem;// 复制多行 + + private String gcbz; + // 标签控件 + // private JTabbedPane tabbedPane; + public LibraryDialog(String string) { + // TODO Auto-generated constructor stub + super(); + // getData(); + this.gcbz=string; + getPFMEAData(); + init(); + } + public LibraryDialog() { + // TODO Auto-generated constructor stub + super(); + // getData(); + getPFMEAData(); + init(); + } + public void HiddenCell(int column,JTable table) { + TableColumn tc = table.getTableHeader().getColumnModel().getColumn(column); + tc.setMaxWidth(0); + tc.setPreferredWidth(0); + tc.setWidth(0); + tc.setMinWidth(0); + table.getTableHeader().getColumnModel().getColumn(column).setMaxWidth(0); + table.getTableHeader().getColumnModel().getColumn(column).setMinWidth(0); + } + public void HiddenRow(int row,JTable table) { +// TableColumn tc = table.getTableHeader().getColumnModel().getColumn(column); +// table.getRow + table.setRowHeight(row, 1); +// table.getModel() +// tc.setMaxWidth(0); +// tc.setPreferredWidth(0); +// tc.setWidth(0); +// tc.setMinWidth(0); +// table.getTableHeader().getColumnModel().getColumn(column).setMaxWidth(0); +// table.getTableHeader().getColumnModel().getColumn(column).setMinWidth(0); + } + public void analyticSize2(List rowList) { + if(rowList.get(0).indexOf("/")>-1) {//获取界面大小位置 + String[] data=rowList.get(0).split("/"); + for(int i=0;i<4;i++) { + SizeLoca2[i]=Integer.parseInt(data[i]); + } + } + if(rowList.get(1).indexOf("/")>-1) { + String[] data=rowList.get(1).split("/"); + for(int i=0;i<3;i++) { + table1Size2[i]=Integer.parseInt(data[i]); + } + } + if(rowList.get(2).indexOf("/")>-1) { + String[] data=rowList.get(2).split("/"); + for(int i=0;i<29;i++) { + table2Size2[i]=Integer.parseInt(data[i]); + } + } + + if(!rowList.get(3).equals("")) { + initRowHeight2 = Integer.valueOf(rowList.get(3)); + } + + + } + private boolean isFirstOpen2=false; + public void getFrameSize2() { + // 获取数据库连接 + SqlUtilT.getTCConnection(); + ResultSet rs = null; + ResultSet rs0 = null; + InputStream input = null; + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + try { + pro.load(input); + String sql = String.format("select * from AHMC_PFMEAFRAME_SIZE WHERE USERNAME = '%s' AND TYPE = '%s'",userName,"PFMEAlibraryDialog"); + rs = SqlUtilT.read(sql); + List rowList = new ArrayList(); + while (rs.next()) { + rowList.add(rs.getString("FRAMESIZE"));//界面大小、位置 + rowList.add(rs.getString("TABLE1SIZE"));//第一个表格的列宽数据 + rowList.add(rs.getString("TABLE2SIZE"));//第二格表格的列宽数据 + rowList.add(rs.getString("ROWHEIGHT"));//第1格表格的行高数据 + break; + } + if(rowList.size()==4) {//解析界面大小,位置,表格列宽数据 + analyticSize2(rowList); + }else { + String sql0 = String.format("select * from AHMC_PFMEAFRAME_SIZE WHERE USERNAME = '%s' AND TYPE = '%s'","iniUser","PFMEAlibraryDialog"); + rs0 = SqlUtilT.read(sql0); + while (rs0.next()) { + rowList.add(rs0.getString("FRAMESIZE"));//界面大小、位置 + rowList.add(rs0.getString("TABLE1SIZE"));//第一个表格的列宽数据 + rowList.add(rs0.getString("TABLE2SIZE"));//第二格表格的列宽数据 + + rowList.add(rs0.getString("ROWHEIGHT"));//第1格表格的行高数据 + break; + } + if(rowList.size()<=0) { + MessageBox.post("(数据库)未设置界面最初尺寸,请先配置!", "错误", MessageBox.ERROR); + return; + }else { + isFirstOpen=true; + analyticSize2(rowList); + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if(rs0 != null) { + SqlUtilT.free(rs0); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + private int[] SizeLoca2=new int[4]; + private int[] table1Size2=new int[3]; + private int[] table2Size2=new int[29]; + private int initRowHeight2 = 50; + private TableRowSorter sorter; + private void init() { + getFrameSize2(); + //获取国际化语言 + Locale defaultLocale=Locale.getDefault(); + ResourceBundle rb=ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message",defaultLocale); + // TODO Auto-generated method stub + this.setTitle(rb.getString("PFMEAc10_display.TITLE")); +// this.setPreferredSize(new Dimension(850, 600)); + this.setPreferredSize(new Dimension(SizeLoca2[0], SizeLoca2[1])); + System.out.println(SizeLoca2[0]+"sizes"+ SizeLoca2[1]); + this.setLocation(SizeLoca2[2], SizeLoca2[3]); + // 初始化标题部分控件 + this.titlePanel = new JPanel(); + this.titleLabel = new JLabel(rb.getString("qzsxmsjhgfx10_display.TITLE")); + this.titleLabel.setFont(new Font("宋体", 1, 18)); + this.titlePanel.add(this.titleLabel); + + JPanel centerPanel = new JPanel(new BorderLayout()); + centerPanel.add(titlePanel, BorderLayout.NORTH); + + JPanel findLeftPanel = new JPanel(new PropertyLayout()); + this.findLeftField = new JTextField(); + this.findLeftField.setPreferredSize(new Dimension(100, 20)); + this.findLeftButton = new JButton(rb.getString("cz10_display.TITLE")); + findLeftPanel.add("1.1.left.top", this.findLeftField); + findLeftPanel.add("1.2.left.top", this.findLeftButton); + + this.leftTable = getNewjTable(null, null, leftHeader, beans.size(), false); + // 隐藏列 + leftTable.HiddenCell(0); + leftTable.HiddenCell(3); + leftTable.setRowHeight(30); + int ind = -1; + for (int i = 0; i < beans.size(); i++) { +// this.leftTable.setValueAt(beans.get(i).getPlmeid(), i, 0); + this.leftTable.setValueAt(beans.get(i).getId(), i, 1); + if(gcbz!=null) { + System.out.println("beans.get(i).getName() " + beans.get(i).getName() + " gcbz"+gcbz); + if(gcbz.contains(beans.get(i).getName())) { + ind = i; + } + } + + this.leftTable.setValueAt(beans.get(i).getName(), i, 2); +// this.leftTable.setValueAt(beans.get(i).getParentId(), i, 3); + } + CTMap2 cmodel = (CTMap2) this.leftTable.getModel(); + sorter = new TableRowSorter(cmodel); + this.leftTable.setRowSorter(sorter); // 为JTable设置排序器 + for(int i=1;i<=2;i++) { + leftTable.getColumnModel().getColumn(i).setPreferredWidth(table1Size[i-1]);; + } + this.findLeftButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if (findLeftField.getText().length() == 0) { + sorter.setRowFilter(null); + } else { + sorter.setRowFilter(RowFilter.regexFilter(findLeftField.getText()));// 为JTable设置基于正则表达式的过滤条件 + } + } + }); + leftTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { + @Override + public void valueChanged(ListSelectionEvent arg0) { + // TODO Auto-generated method stub + if (index == -1) { + refreshPFMEATable(); + index = leftTable.getSelectedRow(); + } else if (index != -1 && index != leftTable.getSelectedRow()) { + refreshPFMEATable(); + index = leftTable.getSelectedRow(); + } + } + }); + JPanel findMainPanel = new JPanel(new PropertyLayout()); + this.findMainField = new JTextField(); + this.findMainField.setPreferredSize(new Dimension(100, 20)); + this.findMainButton = new JButton(rb.getString("cz10_display.TITLE")); + + this.findColumnField = new JTextField(); + this.findColumnField.setPreferredSize(new Dimension(100, 20)); + this.findColumnButton = new JButton("列查询"); + + this.heightField = new JTextField(); + this.heightField.setPreferredSize(new Dimension(100, 20)); + this.heightButton = new JButton("行高调整"); + + this.saveBtnSize = new JButton("界面保存"); + + findMainPanel.add("1.1.left.top", this.findMainField); + findMainPanel.add("1.2.left.top", this.findMainButton); + + findMainPanel.add("1.3.left.top", this.findColumnField); + findMainPanel.add("1.4.left.top", this.findColumnButton); + + findMainPanel.add("1.5.left.top", this.heightField); + findMainPanel.add("1.6.left.top", this.heightButton); + findMainPanel.add("1.7.left.top", this.saveBtnSize); + + this.mainTable = getNewjTable(null, null, pfmeaKuHeader, 0, false); + // 隐藏列 + HiddenCell(0,mainTable); + HiddenCell(1,mainTable); +// mainTable.HiddenCell(pfmeaKuHeader.length - 1); + HiddenCell(pfmeaKuHeader.length - 1,mainTable); + HiddenCell(pfmeaKuHeader.length - 2,mainTable); + if(initRowHeight2==0) { + mainTable.setRowHeight(40); + }else { + mainTable.setRowHeight(initRowHeight2); + } + + for(int i=2;i<=table2Size2.length+1;i++) { + this.mainTable.getColumnModel().getColumn(i).setPreferredWidth(table2Size2[i-2]);; + } +// mainSorter = new TableRowSorter(this.mainTable.getModel()); +// this.mainTable.setRowSorter(mainSorter); // 为JTable设置排序器 + this.saveBtnSize.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + try { + try { + String list1=String.valueOf(((int)getSize().getWidth()))+"/"+String.valueOf((int)getSize().getHeight()) + +"/"+String.valueOf(((int)getLocation().getX()))+"/"+String.valueOf((((int)getLocation().getY()))); + +// String list2=""; +// for(int i=1;i"+userName); + System.out.println("this.type====>"+"DesignToLib"); + System.out.println("list1====>"+list1.toString()); +// System.out.println("list2====>"+list2.toString()); + System.out.println("list3====>"+list3.toString()); + if(isFirstOpen) { +// String insertSQL = "INSERT INTO AHMC_PFMEAFRAME_SIZE VALUES(?,?,?,?,?,?,?)"; +// SqlUtilT.write(new String[] { +// UUID.randomUUID().toString().replace("-", ""), +// userName,"PFMEAlibraryDialog",list1,list2,list3,String.valueOf(mainTable.getRowHeight())}, insertSQL); +// System.out.println("insertSQL====>"+insertSQL); +// isFirstOpen=false; + System.out.println("first?"); + }else { + String updateSQL = String.format( + "update AHMC_PFMEAFRAME_SIZE set FRAMESIZE = ?, TABLE2SIZE = ?,ROWHEIGHT = ? WHERE USERNAME ='%s' AND TYPE = '%s'",userName,"PFMEAlibraryDialog"); + SqlUtilT.update( + new String[] {list1,list3,String.valueOf(mainTable.getRowHeight())},updateSQL); + } + SqlUtilT.freeAll(); + ///++++++ + } catch (Exception e3) { + // TODO: handle exception + } +// +// mainTable.invalidate(); + } catch (Exception e2) { + // TODO: handle exception + e2.printStackTrace(); +// System.out.println("输入数字"); + } + } + }); + this.heightButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + String selectedText = heightField.getText(); + try { +// Double valueOf = Double.valueOf(selectedText); + int rowCount = mainTable.getRowCount(); + int rowHeight = 40; + Integer valueOf = Integer.valueOf(selectedText); + if(valueOf>10 || valueOf<1) { + MessageBox.post("调整行高建议在1-10倍之间","提示",2); + } + System.out.println("valueOf"+valueOf+"rowHeight"+rowHeight); + rowHeight = (int) (rowHeight*valueOf); + System.out.println("new rowHeight"+rowHeight); + setRowHeight = rowHeight; + mainTable.setRowHeight(rowHeight); +// mainTable.invalidate(); + } catch (Exception e2) { + // TODO: handle exception + e2.printStackTrace(); +// System.out.println("输入数字"); + } + + + } + }); + this.findColumnButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + +// leftTable.setRowSelectionInterval(lastSelectedRow,lastSelectedRow); + try { + + dontMove.clear(); + System.out.println(lastSelectedRow+"lastSelectedRow"); + refreshPFMEATable((String)leftTable.getValueAt(lastSelectedRow, 1)); + JTable jTable = mainTable; + CTMap2 model = (CTMap2) jTable.getModel(); + System.out.println(jTable.getRowCount()); +// int columnSelect = jTable.getSelectedColumnCount(); +// int rowSelect = jTable.getSelectedRow(); + System.out.println("jTable"+selectMainRow+"columnSelect"+selectMainCol); + if(selectMainRow ==-1 || selectMainCol==-1) { + System.out.println("未选中某一列"); + }else { + List removeRows = new ArrayList(); +// combineMap.get(0); +// int index + String text = findColumnField.getText(); + System.out.println("查询的内容"+text); + int rowCount = jTable.getRowCount(); + if(!text.trim().equals("")) { + int removes = 0; +// int + combineMap.clear(); + for(int t=0;t list = rememberRow.get(t); + String object = (String) list.get(35); +// System.out.println(rememberRow.get(index)); + String valueAt =(String)rememberRow.get(t).get(selectMainCol); //(String) jTable.getValueAt(t, selectMainCol); + System.out.println("valueAt =====> "+valueAt); +// index = index + 1; + if(valueAt ==null || !valueAt.contains(text)) { + System.out.println( "remove ======> "+t); + removeRows.add(t); + removes = removes + 1; + }else { + comBine(object,removes); + } + } + System.out.println(dontMove.toString()+"---------"); + for(int t = removeRows.size()-1;t>=0;t--) { +// ta + if(!dontMove.contains(removeRows.get(t))) { + model.removeRow(removeRows.get(t)); + } + } +// map.in +// map = new CTMap2(model.getRowCount(),pfmeaKuHeader.length); + map.setNumRows(model.getRowCount()); + map.setSize(new Dimension(pfmeaKuHeader.length, model.getRowCount())); + System.out.println("combineMap2"+combineMap.size()); + if (combineMap != null && combineMap.size() != 0) { + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); +// for() + int[] key = entry.getKey(); + for(int xx=0;xx= 0) { + if(mainTable.getSelectedColumn()==2) { + DesignPFMEADialog.table.getCellEditor(DesignPFMEADialog.table.getSelectedRow(), + DesignPFMEADialog.table.getSelectedColumn()).stopCellEditing(); + for (int i = 2; i < mainTable.getColumnCount(); i++) { + if (i == mainTable.getColumnCount() - 1 || i== 3) {//最后一个父节点不能复制 + continue; + } + else { + DesignPFMEADialog.table.setValueAt( + mainTable.getValueAt(mainTable.getSelectedRow(), i), + DesignPFMEADialog.table.getSelectedRow(), i-1); + } + } +// for (int j = 2; j < mainTable.getColumnCount(); j++) { +// //+++ +// if(j == mainTable.getColumnCount() - 1 || j== 5) {//最后一个父节点不能复制 +// continue; +// }else { +// if((DesignPFMEADialog.table.getSelectedRow()) selectRowAll = new ArrayList(); +// for(int t=0;t0) { + int z = selectRowAll.get(k) - selectRows[k-1]; + if(z>1) { + low = low + z -1; + } + } + } + DesignPFMEADialog.table.revalidate(); + DesignPFMEADialog.table.repaint(); + + //用于通过在PFMEA库中的行定位到PFMEA中的行 + int Dvalue=DesignPFMEADialog.table.getSelectedRow()-firstRow; + + Set combinRows=combineMap.keySet(); + //检查选中的行里面是否包含合并的行 + for(int[] combinRow:combinRows) { + if(iscontain(selectRows, combinRow)!=null) { + System.out.println("------找到要合并的单元格"); + int[] hbh=iscontain(selectRows, combinRow); + System.out.println("------合并"+hbh[hbh.length-1]+Dvalue); + int[] hbl=combineMap.get(combinRow); + int start = hbh[0] - firstRow; + System.out.println("------合并"+start+"xxxxx" +Dvalue +"hbl[0]"+hbl[0] +"hbl[hbl.length-1]"+hbl[hbl.length-1]); + //System.out.println("合并行号====>:"+Arrays.toString(hbh)); + //通过Dvalue转化合并行在PFMEA和PFMEA库中相对选中行的的位置 + + DesignPFMEADialog.table.setRowSelectionInterval( hbh[0] + Dvalue - low, hbh[hbh.length-1]+Dvalue - low); + //因为PFMEA中有前面三行(0,1,2)没存储数据而PFMEA库只有两行(0,1)。故处理行时要加1 + DesignPFMEADialog.table.setColumnSelectionInterval(hbl[0]-1, hbl[hbl.length-1]-1); + comBineCell(); + } + } + //合并行结束需要将选中行回到初始位置,用于插入数据 + DesignPFMEADialog.table.setRowSelectionInterval(PFMEADialogSelectrow, PFMEADialogSelectrow+PFMEADialogSelectrows-1); + DesignPFMEADialog.table.setColumnSelectionInterval(PFMEADialogSelectColumn, PFMEADialogSelectColumn+PFMEADialogSelectColumns-1); + + + + for (int i = 0; i < selectRowAll.size() ; i++) { + if (DesignPFMEADialog.table.getSelectedRow() >= 0) { + DesignPFMEADialog.table.getCellEditor(DesignPFMEADialog.table.getSelectedRow(), + DesignPFMEADialog.table.getSelectedColumn()).stopCellEditing(); + for (int j = 2; j < jtable.getColumnCount(); j++) { + //+++ + if(j == mainTable.getColumnCount() - 1 || j== 3) {//最后一个父节点不能复制 + continue; + }else { + if((DesignPFMEADialog.table.getSelectedRow() + i)-1) { + lastSelectedRow = ind; + System.out.println("ind"+ind); + leftTable.setRowSelectionInterval(ind,ind); + leftTable.invalidate(); + refreshPFMEATable((String)leftTable.getValueAt(ind, 1)); + + } + } + + /** + * 获取数据库中的数据 + */ + private void getPFMEAData() { + // TODO Auto-generated method stub + ResultSet rs = null; + InputStream input = null; + try { + // 获取数据库连接 + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + pro.load(input); + String sql = String.format(pro.getProperty("TM2PFMEATREESELECT")); + rs = SqlUtilT.read(sql); + while (rs.next()) { + TreeBean bean = new TreeBean(); + bean.setPlmeid(rs.getString("PLMEID")); + bean.setId(rs.getString("ID")); + bean.setName(rs.getString("NAME")); + bean.setParentId(rs.getString("PARENT_ID")); + beans.add(bean); + } + // createTabbedPane(beans); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + + } + private List> rememberRow; + private int lastSelectedRow; + private void refreshPFMEATable(String valueAt) { + // TODO Auto-generated method stub + + + try { + String list1=String.valueOf(((int)this.getSize().getWidth()))+"/"+String.valueOf((int)this.getSize().getHeight()) + +"/"+String.valueOf(((int)this.getLocation().getX()))+"/"+String.valueOf((((int)this.getLocation().getY()))); + +// String list2=""; +// for(int i=1;i"+userName); + System.out.println("this.type====>"+"DesignToLib"); + System.out.println("list1====>"+list1.toString()); +// System.out.println("list2====>"+list2.toString()); + System.out.println("list3====>"+list3.toString()); + if(isFirstOpen) { +// String insertSQL = "INSERT INTO AHMC_PFMEAFRAME_SIZE VALUES(?,?,?,?,?,?,?)"; +// SqlUtilT.write(new String[] { +// UUID.randomUUID().toString().replace("-", ""), +// userName,"PFMEAlibraryDialog",list1,list2,list3,String.valueOf(mainTable.getRowHeight())}, insertSQL); +// System.out.println("insertSQL====>"+insertSQL); +// isFirstOpen=false; + System.out.println("first?"); + }else { + String updateSQL = String.format( + "update AHMC_PFMEAFRAME_SIZE set FRAMESIZE = ?, TABLE2SIZE = ?,ROWHEIGHT = ? WHERE USERNAME ='%s' AND TYPE = '%s'",userName,"PFMEAlibraryDialog"); + SqlUtilT.update( + new String[] {list1,list3,String.valueOf(mainTable.getRowHeight())},updateSQL); + } + SqlUtilT.freeAll(); + ///++++++ + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + + ResultSet rs = null; + InputStream input = null; + try { + + SqlUtilT.getTCConnection(); + // 获取SQL语句 + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); +// lastSelectedRow = leftTable.getSelectedRow(); + String sql = String.format(pro.getProperty("PFMEALIBRARYSELECT"), + valueAt); + rs = SqlUtilT.read(sql); + List> rowList = new ArrayList>(); + List> rowList2 = new ArrayList>(); + while (rs.next()) { + List list = new ArrayList(); + List list2 = new ArrayList(); + + list2.add(rs.getString("PLMEID")); + list2.add(false); + list2.add(rs.getString("ID")); + list2.add(rs.getString("LSBG")); + list2.add(rs.getString("STATION")); + list2.add(rs.getString("REQUIREMENT")); + list2.add(rs.getString("QZSXMS")); + list2.add(rs.getString("QZSXHG")); + list2.add(rs.getString("YZD")); + list2.add(rs.getString("JB")); + list2.add(rs.getString("QZSXQY")); + list2.add(rs.getString("XXGCKZYF")); + list2.add(rs.getString("PDS")); + list2.add(rs.getString("XXGCKZTC")); + list2.add(rs.getString("TCD")); + list2.add(rs.getString("RPN")); + list2.add(rs.getString("JYCS")); + list2.add(rs.getString("ZZR")); + list2.add(rs.getString("JHWCRQ")); + list2.add(rs.getString("CQDCS")); + list2.add(rs.getString("NEW_SEV")); + list2.add(rs.getString("NEW_OCC")); + list2.add(rs.getString("NEW_DET")); + list2.add(rs.getString("NEW_RPN")); + list2.add(rs.getString("IDEAL_STATE")); + list2.add(rs.getString("SPECIAL")); + list2.add(rs.getString("P1")); + list2.add(rs.getString("P2")); + list2.add(rs.getString("P3")); + list2.add(rs.getString("P4")); + list2.add(rs.getString("P5")); + list2.add(rs.getString("P6")); + list2.add(rs.getString("P7")); + list2.add(rs.getString("P8")); + list2.add(rs.getString("PARENT_ID")); + list2.add(rs.getString("HBDYG")); + rowList2.add(list2); + // + list.add(rs.getString("PLMEID")); + list.add(rs.getString("ID")); + list.add(rs.getString("LSBG")); + list.add(rs.getString("STATION")); + list.add(rs.getString("REQUIREMENT")); + list.add(rs.getString("QZSXMS")); + list.add(rs.getString("QZSXHG")); + list.add(rs.getString("YZD")); + list.add(rs.getString("JB")); + list.add(rs.getString("QZSXQY")); + list.add(rs.getString("XXGCKZYF")); + list.add(rs.getString("PDS")); + list.add(rs.getString("XXGCKZTC")); + list.add(rs.getString("TCD")); + list.add(rs.getString("RPN")); + list.add(rs.getString("JYCS")); + list.add(rs.getString("ZZR")); + list.add(rs.getString("JHWCRQ")); + list.add(rs.getString("CQDCS")); + list.add(rs.getString("NEW_SEV")); + list.add(rs.getString("NEW_OCC")); + list.add(rs.getString("NEW_DET")); + list.add(rs.getString("NEW_RPN")); + list.add(rs.getString("IDEAL_STATE")); + list.add(rs.getString("SPECIAL")); + list.add(rs.getString("P1")); + list.add(rs.getString("P2")); + list.add(rs.getString("P3")); + list.add(rs.getString("P4")); + list.add(rs.getString("P5")); + list.add(rs.getString("P6")); + list.add(rs.getString("P7")); + list.add(rs.getString("P8")); + list.add(rs.getString("PARENT_ID")); + list.add(rs.getString("HBDYG")); + rowList.add(list); + } + if (rowList.size() > 0) { + rememberRow = rowList2; + map = new CTMap2(rowList.size(), pfmeaKuHeader.length); + System.out.println(map.getColumnClass(1)+"---------"); + map.setColumnIdentifiers(pfmeaKuHeader); + map.setEditable(true); + mainTable.setModel(map); + try { + map.setRowCount(0); + mainTable.removeAll(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + + mainSorter = new TableRowSorter(map); + this.mainTable.setRowSorter(mainSorter); // 为JTable设置排序器 +// map.getCo +// TableColumn tcm1 = mainTable.getColumnModel().getColumn(1); +// tcm1.setCellEditor(mainTable.getDefaultEditor(Boolean.class)); +// tcm1.setCellRenderer(mainTable.getDefaultRenderer(Boolean.class)); + for (int j = 0; j < rowList.size(); j++) { + map.addRow(rowList.get(j).toArray()); + } + comBine(rowList2); + + } else { + map = new CTMap2(1, pfmeaHeader.length); + map.setColumnIdentifiers(pfmeaHeader); + mainTable.setModel(map); + mainSorter = new TableRowSorter(map); + this.mainTable.setRowSorter(mainSorter); // 为JTable设置排序器 + map.setValueAt(leftTable.getValueAt(leftTable.getSelectedRow(), 1), 0, + mainTable.getColumnCount() - 1); + } + getFrameSize2(); + for(int i=1;i<30;i++) { + mainTable.getColumnModel().getColumn(i+1).setPreferredWidth(table2Size2[i-1]);; + } + for(int i=1;i<=2;i++) { + leftTable.getColumnModel().getColumn(i).setPreferredWidth(table1Size2[i-1]);; + } + if(initRowHeight2!=0) { + mainTable.setRowHeight(initRowHeight2); + } + if(setRowHeight!=0) { + mainTable.setRowHeight(setRowHeight); + } + leftTable.setRowHeight(30); + + mainTable.invalidate(); + } catch (Exception e) { + // TODO: handle exception + + e.printStackTrace(); + + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + HiddenCell(0,mainTable); + HiddenCell(1,mainTable); +// mainTable.HiddenCell(pfmeaKuHeader.length - 1); + HiddenCell(pfmeaKuHeader.length - 1,mainTable); + HiddenCell(pfmeaKuHeader.length - 2,mainTable); + } + } + private void refreshPFMEATable() { + // TODO Auto-generated method stub + // 刷新右侧数据 + try { + String list1=String.valueOf(((int)this.getSize().getWidth()))+"/"+String.valueOf((int)this.getSize().getHeight()) + +"/"+String.valueOf(((int)this.getLocation().getX()))+"/"+String.valueOf((((int)this.getLocation().getY()))); + +// String list2=""; +// for(int i=1;i"+userName); + System.out.println("this.type====>"+"DesignToLib"); + System.out.println("list1====>"+list1.toString()); +// System.out.println("list2====>"+list2.toString()); + System.out.println("list3====>"+list3.toString()); + if(isFirstOpen) { +// String insertSQL = "INSERT INTO AHMC_PFMEAFRAME_SIZE VALUES(?,?,?,?,?,?,?)"; +// SqlUtilT.write(new String[] { +// UUID.randomUUID().toString().replace("-", ""), +// userName,"PFMEAlibraryDialog",list1,list2,list3,String.valueOf(mainTable.getRowHeight())}, insertSQL); +// System.out.println("insertSQL====>"+insertSQL); +// isFirstOpen=false; + System.out.println("?"); + }else { + String updateSQL = String.format( + "update AHMC_PFMEAFRAME_SIZE set FRAMESIZE = ?, TABLE2SIZE = ?,ROWHEIGHT = ? WHERE USERNAME ='%s' AND TYPE = '%s'",userName,"PFMEAlibraryDialog"); + SqlUtilT.update( + new String[] {list1,list3,String.valueOf(mainTable.getRowHeight())},updateSQL); + } + SqlUtilT.freeAll(); + ///++++++ + } catch (Exception e) { + // TODO: handle exception + } + ResultSet rs = null; + InputStream input = null; + try { + + SqlUtilT.getTCConnection(); + // 获取SQL语句 + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + lastSelectedRow = leftTable.getSelectedRow(); + String sql = String.format(pro.getProperty("PFMEALIBRARYSELECT"), + leftTable.getValueAt(leftTable.getSelectedRow(), 1)); + rs = SqlUtilT.read(sql); + List> rowList = new ArrayList>(); + List> rowList2 = new ArrayList>(); + while (rs.next()) { + List list = new ArrayList(); + List list2 = new ArrayList(); + + list2.add(rs.getString("PLMEID")); + list2.add(false); + list2.add(rs.getString("ID")); + list2.add(rs.getString("LSBG")); + list2.add(rs.getString("STATION")); + list2.add(rs.getString("REQUIREMENT")); + list2.add(rs.getString("QZSXMS")); + list2.add(rs.getString("QZSXHG")); + list2.add(rs.getString("YZD")); + list2.add(rs.getString("JB")); + list2.add(rs.getString("QZSXQY")); + list2.add(rs.getString("XXGCKZYF")); + list2.add(rs.getString("PDS")); + list2.add(rs.getString("XXGCKZTC")); + list2.add(rs.getString("TCD")); + list2.add(rs.getString("RPN")); + list2.add(rs.getString("JYCS")); + list2.add(rs.getString("ZZR")); + list2.add(rs.getString("JHWCRQ")); + list2.add(rs.getString("CQDCS")); + list2.add(rs.getString("NEW_SEV")); + list2.add(rs.getString("NEW_OCC")); + list2.add(rs.getString("NEW_DET")); + list2.add(rs.getString("NEW_RPN")); + list2.add(rs.getString("IDEAL_STATE")); + list2.add(rs.getString("SPECIAL")); + list2.add(rs.getString("P1")); + list2.add(rs.getString("P2")); + list2.add(rs.getString("P3")); + list2.add(rs.getString("P4")); + list2.add(rs.getString("P5")); + list2.add(rs.getString("P6")); + list2.add(rs.getString("P7")); + list2.add(rs.getString("P8")); + list2.add(rs.getString("PARENT_ID")); + list2.add(rs.getString("HBDYG")); + rowList2.add(list2); + // + list.add(rs.getString("PLMEID")); + list.add(rs.getString("ID")); + list.add(rs.getString("LSBG")); + list.add(rs.getString("STATION")); + list.add(rs.getString("REQUIREMENT")); + list.add(rs.getString("QZSXMS")); + list.add(rs.getString("QZSXHG")); + list.add(rs.getString("YZD")); + list.add(rs.getString("JB")); + list.add(rs.getString("QZSXQY")); + list.add(rs.getString("XXGCKZYF")); + list.add(rs.getString("PDS")); + list.add(rs.getString("XXGCKZTC")); + list.add(rs.getString("TCD")); + list.add(rs.getString("RPN")); + list.add(rs.getString("JYCS")); + list.add(rs.getString("ZZR")); + list.add(rs.getString("JHWCRQ")); + list.add(rs.getString("CQDCS")); + list.add(rs.getString("NEW_SEV")); + list.add(rs.getString("NEW_OCC")); + list.add(rs.getString("NEW_DET")); + list.add(rs.getString("NEW_RPN")); + list.add(rs.getString("IDEAL_STATE")); + list.add(rs.getString("SPECIAL")); + list.add(rs.getString("P1")); + list.add(rs.getString("P2")); + list.add(rs.getString("P3")); + list.add(rs.getString("P4")); + list.add(rs.getString("P5")); + list.add(rs.getString("P6")); + list.add(rs.getString("P7")); + list.add(rs.getString("P8")); + list.add(rs.getString("PARENT_ID")); + list.add(rs.getString("HBDYG")); + rowList.add(list); + } + if (rowList.size() > 0) { + map = new CTMap2(rowList.size(), pfmeaKuHeader.length); + System.out.println(map.getColumnClass(1)+"---------"); + map.setColumnIdentifiers(pfmeaKuHeader); + map.setEditable(true); + mainTable.setModel(map); + try { + map.setRowCount(0); + mainTable.removeAll(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + + mainSorter = new TableRowSorter(map); + this.mainTable.setRowSorter(mainSorter); // 为JTable设置排序器 +// map.getCo +// TableColumn tcm1 = mainTable.getColumnModel().getColumn(1); +// tcm1.setCellEditor(mainTable.getDefaultEditor(Boolean.class)); +// tcm1.setCellRenderer(mainTable.getDefaultRenderer(Boolean.class)); + for (int j = 0; j < rowList.size(); j++) { + map.addRow(rowList.get(j).toArray()); + } + comBine(rowList2); + + } else { + map = new CTMap2(1, pfmeaHeader.length); + map.setColumnIdentifiers(pfmeaHeader); + mainTable.setModel(map); + mainSorter = new TableRowSorter(map); + this.mainTable.setRowSorter(mainSorter); // 为JTable设置排序器 + map.setValueAt(leftTable.getValueAt(leftTable.getSelectedRow(), 1), 0, + mainTable.getColumnCount() - 1); + } + getFrameSize2(); + for(int i=1;i<29;i++) { + mainTable.getColumnModel().getColumn(i+1).setPreferredWidth(table2Size2[i-1]);; + } + for(int i=1;i<=2;i++) { + leftTable.getColumnModel().getColumn(i).setPreferredWidth(table1Size2[i-1]);; + } + if(initRowHeight2!=0) { + mainTable.setRowHeight(initRowHeight2); + } +// if(rowHeightAll!=0) { +// mainTable.setRowHeight(rowHeightAll); +// } + if(setRowHeight!=0) { + mainTable.setRowHeight(setRowHeight); + } + leftTable.setRowHeight(30); + HiddenCell(0,mainTable); + HiddenCell(1,mainTable); +// mainTable.HiddenCell(pfmeaKuHeader.length - 1); + HiddenCell(pfmeaKuHeader.length - 1,mainTable); + HiddenCell(pfmeaKuHeader.length - 2,mainTable); + mainTable.invalidate(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + + + //检查数组a是否包含数组b + public int[] iscontain( int[] a, int[] b){ + + for (int i = 0; i < a.length; i++) { + for (int j = 0; j < b.length&&j<(a.length-i); j++) { + if(a[i+j]==b[j]){ + if(j==b.length-1){ + return b; + }else if(j==a.length-1-i) { + return Arrays.copyOfRange(a,i,a.length);//截取a数组从i到最后的数组数据 + } + continue; + }else{ + break; + } + } + } + return null; + } + + + public void comBine(String combs,int moved) { + System.out.println("String.valueOf(selectMainCol-1)"+String.valueOf(selectMainCol-1)); + + if (combs!= null && !combs.equals("")) { + System.out.println(moved); + System.out.println(combs); + String sombine = combs; + String[] sombines; + if (sombine.indexOf("-") >= 0) { + sombines = sombine.split("-"); + } else { + sombines = new String[] { sombine }; + } + for (int j = 0; j < sombines.length; j++) { + if (sombines[j].indexOf("/") >= 0) { + int[] row; + int[] cloumn; + String[] cells = sombines[j].split("/"); + if (cells[0].indexOf(",") >= 0) { + String[] rows = cells[0].split(","); + row = new int[rows.length]; + for (int k = 0; k < rows.length; k++) { + row[k] = Integer.parseInt(rows[k]) - moved; + if(cells[1].contains(String.valueOf(selectMainCol-1))) { + dontMove.add(Integer.parseInt(rows[k])); + } + } + } else { + row = new int[] { Integer + .parseInt(cells[0]) - moved}; + if(cells[1].contains(String.valueOf(selectMainCol-1))) { + dontMove.add(Integer.parseInt(cells[0])); + } + + } + if (cells[1].indexOf(",") >= 0) { + String[] cloumns = cells[1].split(","); + cloumn = new int[cloumns.length]; + for (int k = 0; k < cloumns.length; k++) { + cloumn[k] = Integer + .parseInt(cloumns[k])+1; + } + } else { + cloumn = new int[1]; //cells[1]+1 + cloumn[0] = Integer.parseInt(cells[1])+1; + } + this.combineMap.put(row, cloumn); + } + } + } + } + //加载合并单元格 + public void comBine(List> rowList) { + + + combineMap.clear(); + if (rowList != null && rowList.size() > 0) { + for (int i = 0; i < rowList.size(); i++) { + if (rowList.get(i).get(35)!= null + && !rowList.get(i).get(35).equals("")) { + String sombine = rowList.get(i).get(35).toString(); +// int rowDif = 0; + String[] sombines; + if (sombine.indexOf("-") >= 0) { + sombines = sombine.split("-"); + } else { + sombines = new String[] { sombine }; + } + for (int j = 0; j < sombines.length; j++) { + if (sombines[j].indexOf("/") >= 0) { + int[] row; + int[] cloumn; + String[] cells = sombines[j].split("/"); + if (cells[0].indexOf(",") >= 0) { + String[] rows = cells[0].split(","); + row = new int[rows.length]; + for (int k = 0; k < rows.length; k++) { + row[k] = Integer.parseInt(rows[k]); + } + } else { + row = new int[] { Integer.parseInt(cells[0])}; + } + if (cells[1].indexOf(",") >= 0) { + String[] cloumns = cells[1].split(","); + cloumn = new int[cloumns.length]; + for (int k = 0; k < cloumns.length; k++) { + cloumn[k] = Integer + .parseInt(cloumns[k])+1; + } + } else { + cloumn = new int[1]; //cells[1]+1 + cloumn[0] = Integer.parseInt(cells[1])+1; + } + this.combineMap.put(row, cloumn); + } + } + } + } + } + + try { + if (combineMap != null && combineMap.size() != 0) { + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + map.combine(entry.getKey(), entry.getValue()); + } + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + // TODO Auto-generated method stub + + } + + + } + + public class AddRowsDialog extends AbstractAIFDialog implements ActionListener { + + private JPanel panel; + private JLabel label; + private JTextField textField; + private JButton button; + + private Object source; + + public AddRowsDialog(Object source) { + // TODO Auto-generated constructor stub + super(); + this.source = source; + init(); + } + + private void init() { + //获取国际化语言 + Locale defaultLocale=Locale.getDefault(); + ResourceBundle rb=ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message",defaultLocale); + // TODO Auto-generated method stub + this.panel = new JPanel(new PropertyLayout()); + this.label = new JLabel(rb.getString("crhs10_display.TITLE")); + this.textField = new JTextField(20); + this.textField.addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(KeyEvent arg0) { + if (arg0.getKeyCode() == KeyEvent.VK_ENTER) { + okEvent(); + } else { + super.keyPressed(arg0); + } + } + }); + this.button = new JButton(rb.getString("qd_display.TITLE")); + this.button.addActionListener(this); + this.panel.add("1.1.left.top", label); + this.panel.add("1.2.left.top", textField); + this.panel.add("1.3.left.top", button); + + this.add(this.panel, BorderLayout.CENTER); + this.pack(); + this.showDialog(); + } + + @Override + public void actionPerformed(ActionEvent actionevent) { + // TODO Auto-generated method stub + Object source = actionevent.getSource(); + if (source.equals(this.button)) { + okEvent(); + } + } + + private void okEvent() { + // TODO Auto-generated method stub + if (this.source.equals(addRowsItem)) { + if (!isStr2Num(textField.getText())) { + MessageBox.post("请输入正确的数字!", "错误!", MessageBox.ERROR); + return; + } + for (int i1 = 0; i1 < Integer.parseInt(textField.getText()); i1++) { + addRow(); + } + this.disposeDialog(); + this.dispose(); + } else if (this.source.equals(addCombineRowsItem)) { + if (!isStr2Num(textField.getText())) { + MessageBox.post("请输入正确的数字!", "错误!", MessageBox.ERROR); + return; + } + for (int i1 = 0; i1 < Integer.parseInt(textField.getText()); i1++) { + addCombineRow(); + } + this.disposeDialog(); + this.dispose(); + } + } + } + /** + * 设置单元格 + * + * @param row1 + * @param index + * @param str + */ + public static void setCellValue(XSSFRow row1, int index, String str) { + XSSFCell cell = row1.getCell(index); + if(cell==null) { + cell=row1.createCell(index); + } + cell.setCellType(XSSFCell.CELL_TYPE_STRING); + cell.setCellValue(str); + } + + /** + * 设置单元格 + * + * @param row1 + * @param index + * @param str + */ + public static void setCellValue(Row row1, int index, String str) { + Cell cell = row1.getCell(index); + cell.setCellType(XSSFCell.CELL_TYPE_STRING); + cell.setCellValue(str); + } + public static boolean combine(XSSFSheet sheet, int[] rows, int[] columns) { + boolean isOK = false; + if (rows.length <=1 && columns.length <=1) {//对单个单元格合并则跳过 + }else { + sheet.addMergedRegion(new CellRangeAddress(rows[0], + rows[rows.length - 1], columns[0], + columns[columns.length - 1])); + isOK = true; + } + return isOK; + } +} + +//++++ + class MultiLineHeaderRenderer extends JList implements TableCellRenderer { + public MultiLineHeaderRenderer() { + setOpaque(true); + setForeground(UIManager.getColor("TableHeader.foreground")); + setBackground(UIManager.getColor("TableHeader.background")); + setBorder(UIManager.getBorder("TableHeader.cellBorder")); + ListCellRenderer renderer = getCellRenderer(); + ((JLabel) renderer).setHorizontalAlignment(JLabel.CENTER); + setCellRenderer(renderer); + } + + + + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + setFont(table.getFont()); + String str = (value == null) ? "" : value.toString(); + BufferedReader br = new BufferedReader(new StringReader(str)); + String line; + Vector v = new Vector(); + try { + while ((line = br.readLine()) != null) { + v.addElement(line); + } + } catch (IOException ex) { + ex.printStackTrace(); + } + setListData(v); + return this; + } + + } + + //++++ diff --git a/src/com/connor/hs2/plm/PFMEA/design/DesignPFMEAHandler.java b/src/com/connor/hs2/plm/PFMEA/design/DesignPFMEAHandler.java new file mode 100644 index 0000000..08ed1cd --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/design/DesignPFMEAHandler.java @@ -0,0 +1,99 @@ +package com.connor.hs2.plm.PFMEA.design; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +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.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class DesignPFMEAHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + +// InputStream input = new BufferedInputStream(getClass().getResourceAsStream( +// "/sql.properties")); +// Properties pro = new Properties(); +// +// try { +// pro.load(input); +// } catch (IOException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } + if(app.getTargetComponent()==null + ||!(app.getTargetComponent() instanceof TCComponentItemRevision) + || !(app.getTargetComponent().getType().equals("ZF6_PFMEARevision"))) { + MessageBox.post("请选中PFMEA版本对象,请重新选择!", "错误", MessageBox.ERROR); + return null; + } + String UID; + UID=app.getTargetComponent().getUid(); + TCComponentItem meprocess = null; + TCComponentItemRevision pfmeaRev = (TCComponentItemRevision) app.getTargetComponent(); + int i=0; + try { + AIFComponentContext[] whereReferenced = pfmeaRev.whereReferenced(); + + for(AIFComponentContext context:whereReferenced) { + + InterfaceAIFComponent component = context.getComponent(); + if(component instanceof TCComponentItemRevision) { + + String type = component.getType(); + if(type.equals("ZF6_GYLXRevision")) { + meprocess = ((TCComponentItemRevision)component).getItem(); + i = i+1; + } + + } + + } + if(i==0) { + MessageBox.post("无关联工艺路线.", "错误", MessageBox.INFORMATION); + return null; + }else if(i>1) { + MessageBox.post("请指定关联工艺路线.", "错误", MessageBox.INFORMATION); + return null; + } + + + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + DesignPFMEACommand command = new DesignPFMEACommand(app, + session,UID,meprocess,false,(TCComponentItemRevision)app.getTargetComponent()); + if(UID==null) { + MessageBox.post("请选择对象!", "错误", MessageBox.ERROR); + return null; + } + //MessageBox.post("dakaizhong ", "错误", MessageBox.ERROR); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("填写PFNEA失败!", "错误", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/hs2/plm/PFMEA/design/DesignPFMEAOperation.java b/src/com/connor/hs2/plm/PFMEA/design/DesignPFMEAOperation.java new file mode 100644 index 0000000..ec542e1 --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/design/DesignPFMEAOperation.java @@ -0,0 +1,267 @@ +package com.connor.hs2.plm.PFMEA.design; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import javax.swing.JFrame; +import javax.swing.JProgressBar; +import javax.swing.plaf.metal.MetalProgressBarUI; + +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.soaictstubs.booleanSeq_tHolder; + +public class DesignPFMEAOperation extends AbstractAIFOperation { + +// private TCProperty[] properties; + private TCProperty[] itemProperties; + private InterfaceAIFComponent comp; + private PFMEABean pfmeaBean; + private String[][] dataValue; + private List> dataValueList; + private List plmeidList; + private TCSession session; + private TCComponentItemRevision itemRevision; + private TCComponent meprocess; + private List deleteRows; + private boolean isOwning; + private String UID; + private boolean firstFlag; + public DesignPFMEAOperation(TCComponentItemRevision itemRevision, + TCComponent meprocess, TCSession session, TCProperty[] properties, + TCProperty[] itemProperties, PFMEABean pfmeaBean, + List> dataValueList,List plmeidList, + List deleteRows, boolean isOwning,InterfaceAIFComponent comp,String UID,boolean firstFlag) { + this.itemRevision = itemRevision; + this.meprocess = meprocess; + this.session = session; +// this.properties = properties; + this.itemProperties = itemProperties; + this.pfmeaBean = pfmeaBean; +// this.dataValue = dataValue; + this.dataValueList = dataValueList; + this.plmeidList = plmeidList; + this.deleteRows = deleteRows; + this.isOwning = isOwning; + this.comp=comp; + this.UID=UID; + this.firstFlag=firstFlag; + } + + @Override + public void executeOperation() throws Exception { + //+++添加进度条 + JFrame frame = new JFrame("正在保存..."); + //frame.setUndecorated(true); // 没有标题栏 + frame.setSize(300, 70); + frame.setLocationRelativeTo(null); + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + frame.setLayout(new BorderLayout()); + JProgressBar progressBar = new JProgressBar(); + progressBar.setOrientation(JProgressBar.HORIZONTAL); + progressBar.setSize(300, 50); + progressBar.setMinimum(0); + progressBar.setMaximum(100); + progressBar.setBorderPainted(true); + progressBar.setUI(new MetalProgressBarUI()); + progressBar.setBackground(Color.white); + progressBar.setForeground(Color.green); + progressBar.setStringPainted(true); + frame.setAlwaysOnTop(true); + frame.add(progressBar); + frame.setVisible(true); + //+++ + ResultSet rs = null; + InputStream input = null; + try { + + + PropertyToSQL(); + + progressBar.setValue(1);//++++ + // 获取SQL语句 + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + // 获取数据库连接 + // 查询工序编号和ID + String selectSQL = String.format( + pro.getProperty("SETPFMEASELECT2"), meprocess.getUid()); + SqlUtilT.getTCConnection(); + rs = SqlUtilT.read(selectSQL); + Map itemIdMap = new HashMap(); + while (rs.next()) { + itemIdMap.put(rs.getString("REQUIREMENT"), + rs.getString("MEOPID")); + } + //System.out.println("opdeleteRows====>"+deleteRows.toString()); + //System.out.println("opdataValueList====>"+dataValueList.toString()); + // 删除行 +// SqlUtilT.getTCConnection(); + for (int i = 0; i < deleteRows.size(); i++) { + String deleteSQL = String.format( + pro.getProperty("SETPFMEADELETE"), deleteRows.get(i)); +// SqlUtilT.getTCConnection(); + SqlUtilT.delete(deleteSQL); + } + progressBar.setValue(10);//++++ + // 获取数据库连接 + //SqlUtilT.getTCConnection(); + // 往数据库中写入数据 + int Speed=1; + System.out.println(dataValueList.toString()); + int num2=dataValueList.size()/90; + for (int i = 0; i < dataValueList.size(); i++) { + List rowList = dataValueList.get(i); + if (rowList.get(0) != null && !rowList.get(0).equals("") && plmeidList.contains(rowList.get(0))) { + // 获取数据库连接 + String updateSQL = String.format( + pro.getProperty("SETPFMEAUPDATE"), rowList.get(0),UID); +// SqlUtilT.getTCConnection(); + SqlUtilT.update( + new String[] { rowList.get(1), rowList.get(2), + rowList.get(3), rowList.get(4), + rowList.get(5), rowList.get(6), + rowList.get(7), rowList.get(8), + rowList.get(9), rowList.get(10), + rowList.get(11), rowList.get(12), + rowList.get(13), rowList.get(14), + rowList.get(15), rowList.get(16), + rowList.get(17), rowList.get(18), + rowList.get(19), rowList.get(20), + rowList.get(21), rowList.get(22), + rowList.get(23), rowList.get(24), + rowList.get(25), rowList.get(26), + rowList.get(30), rowList.get(31), + rowList.get(32), rowList.get(33), + rowList.get(34), rowList.get(35), + rowList.get(36), rowList.get(37)},updateSQL); +// SqlUtilT.freeAll(); + } else if(rowList.get(0) != null && !rowList.get(0).equals("")){ + String insertSQL = pro.getProperty("INSERTPFMEA"); + + SqlUtilT.write2(new String[] { + rowList.get(0), + meprocess.getUid(), itemIdMap.get(rowList.get(4)), + rowList.get(1), rowList.get(2), rowList.get(3), + rowList.get(4), rowList.get(5), rowList.get(6), + rowList.get(7), rowList.get(8), rowList.get(9), + rowList.get(10), rowList.get(11), rowList.get(12), + rowList.get(13), rowList.get(14), rowList.get(15), + rowList.get(16), rowList.get(17), rowList.get(18), + rowList.get(19), rowList.get(20), rowList.get(21), + rowList.get(22), rowList.get(23), rowList.get(25), + rowList.get(26), rowList.get(27), rowList.get(24), + rowList.get(28), rowList.get(29), rowList.get(30), + rowList.get(31), rowList.get(32), rowList.get(33), + rowList.get(34), rowList.get(35), rowList.get(36), + rowList.get(37),UID,rowList.get(rowList.size()-1)}, insertSQL); + System.out.println("++++++++"+insertSQL); +// SqlUtilT.freeAll(); + } + if(i==num2*(Speed-9)) { + Speed++; + progressBar.setValue(Speed);//++++ + } + } + progressBar.setValue(100); + frame.setTitle("保存完成"); + frame.dispose(); + SqlUtilT.connection.commit(); + //MessageBox.post("保存成功!", "成功", MessageBox.WARNING); + } catch (Exception e) { + MessageBox.post(e.toString(), "错误", MessageBox.ERROR); + e.printStackTrace(); + throw e; + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + + private void PropertyToSQL() { + // TODO Auto-generated method stub +// +// propertyList.add(rs.getString("companyName")); +// propertyList.add(rs.getString("project")); +// propertyList.add(rs.getString("address")); +// propertyList.add(rs.getString("pfmeaStart_date")); +// propertyList.add(rs.getString("pfmeaUpdate_date")); +// propertyList.add(rs.getString("processDuty")); +// propertyList.add(rs.getString("customerName")); +// propertyList.add(rs.getString("pfmeaKey_date")); +// propertyList.add(rs.getString("modelPlatform")); +// propertyList.add(rs.getString("functionalTeams")); +// propertyList.add(rs.getString("productCode")); +// +// INSERT INTO AHMC_PFMEA_NODE VALUES(?,?,?,?,?,?,?,?,?,?,?) + SqlUtilT.getTCConnection(); + + try { + + if(firstFlag) { + + String sqlString = "INSERT INTO AHMC_PROPERTY VALUES(?,?,?,?,?,?,?,?,?,?,?,?)"; + + SqlUtilT.write2(new String[] {pfmeaBean.getCompanyName(),pfmeaBean.getProject(),pfmeaBean.getAddress(),pfmeaBean.getPfmeaStartDate() + ,pfmeaBean.getPfmeaUpdateDate(),pfmeaBean.getProcessDuty(),pfmeaBean.getCustomerName(),pfmeaBean.getSecurityClassification(),pfmeaBean.getModelPlatform(),pfmeaBean.getFunctionalTeams(), + "",UID},sqlString); + }else { + + String sqlString = "UPDATE AHMC_PROPERTY set companyName=? , project = ? ,address=?,pfmeaStart_date=?,pfmeaUpdate_date=?," + + "processDuty=?,customerName=?,pfmeaKey_date=?,modelPlatform=?,functionalTeams=?,productCode=? where COMPUID = '"+UID+"'"; + SqlUtilT.update(sqlString, new String[] {pfmeaBean.getCompanyName(),pfmeaBean.getProject(),pfmeaBean.getAddress(),pfmeaBean.getPfmeaStartDate() + ,pfmeaBean.getPfmeaUpdateDate(),pfmeaBean.getProcessDuty(),pfmeaBean.getCustomerName(),pfmeaBean.getSecurityClassification(),pfmeaBean.getModelPlatform(),pfmeaBean.getFunctionalTeams(), + ""}); + + } + + + + + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } finally { + try { + SqlUtilT.connection.commit(); + + SqlUtilT.freeAll(); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + } + + + + } + +} diff --git a/src/com/connor/hs2/plm/PFMEA/design/InsertPictureToExcelTest.java b/src/com/connor/hs2/plm/PFMEA/design/InsertPictureToExcelTest.java new file mode 100644 index 0000000..f06b875 --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/design/InsertPictureToExcelTest.java @@ -0,0 +1,240 @@ +package com.connor.hs2.plm.PFMEA.design; + +import java.awt.image.BufferedImage; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStream; + +import javax.imageio.ImageIO; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.ClientAnchor; +import org.apache.poi.ss.usermodel.Drawing; +import org.apache.poi.ss.usermodel.Picture; +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.CellRangeAddress; +import org.apache.poi.xssf.usermodel.XSSFClientAnchor; +import org.apache.poi.xssf.usermodel.XSSFShape; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + + + +public class InsertPictureToExcelTest { + + public static void main(String[] args) { + String oldFile = "D:\\移植\\特殊特性\\兆丰PFMEA第五版模板(1).xlsx"; +// String newFile = "C:\\Users\\blue\\Desktop\\原excel.xlsx"; + String pictureUrl = "D:\\移植\\特殊特性\\过重.png"; + InputStream inputStream = null; + FileOutputStream fileOut = null; + int [] columns = {6,7,17,29}; + int col = 15; + int currentRow = 18; + int row1 = currentRow; + int row2 = currentRow; + int startrow = 10; + try { + System.out.println("正在插入图片。。。"); + inputStream = new FileInputStream(oldFile); + XSSFWorkbook workbook = new XSSFWorkbook(inputStream); + if (inputStream != null) { + try { + inputStream.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + XSSFSheet sheet = workbook.getSheetAt(0); +// reSetRowHeight(workbook,sheet,startrow,sheet.getLastRowNum(),columns); +// Result result = isMergedRegion(sheet,currentRow,col); +// if(result.isBool()) { +// row1 = result.getRow1(); +// row2 = result.getRow2(); +// } + + insertTitlePicture2(workbook,sheet, pictureUrl,"png", col, row1,row2); + fileOut = new FileOutputStream(new File(oldFile)); + workbook.write(fileOut); + System.out.println("完成"); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + if (inputStream != null) { + try { + inputStream.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + if (fileOut != null) { + try { + fileOut.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + + public static void reSetRowHeight(Workbook wb,Sheet sheet,int startRow,int endRow,int[] columnNum) { + int picWidth = 1856 * 2;//图片宽度 + int picHeight = 710; + int t3 = (int)(picHeight/15);//图片占单元格高度 + + for(int i = startRow;i0) { + tempcolwid /= 2; + int t = (int)(rowHeight/15); + int t2 = (int)(tempcolwid/32); + System.out.println("t="+t); + System.out.println("t2="+t2); + anchor.setCol1(col); + anchor.setCol2(col); + anchor.setRow1(row); + anchor.setRow2(row2); + System.out.println("tw"+XSSFShape.EMU_PER_PIXEL); + System.out.println("tw"+t); + anchor.setDx1(XSSFShape.EMU_PER_PIXEL * t2); + anchor.setDx2(XSSFShape.EMU_PER_PIXEL * (t2+t4)); + if(row+1==row2) {//单行 + System.out.println("单行"); +// anchor.setDy1(XSSFShape.EMU_PER_PIXEL * 100); + anchor.setDy1(XSSFShape.EMU_PER_PIXEL * (t/5)); //-XSSFShape.EMU_PER_PIXEL*(t/3) +// anchor.setDy2(XSSFShape.EMU_PER_PIXEL * 1); + anchor.setDy2(XSSFShape.EMU_PER_PIXEL * (t3-4*t/5-2)); //-XSSFShape.EMU_PER_PIXEL*(t/3) + }else {//多行合并 + System.out.println("多行"); + int tempRow = row; + int row1Height = 0; + row1Height = sheet.getRow(tempRow).getHeight(); + int t9 = (int)(row1Height/15); + do { + if(t9>(t/2)||tempRow==row2)break; + tempRow++; + row1Height = sheet.getRow(tempRow).getHeight(); + t9 +=(int)(row1Height/15); + }while(true); + if(tempRow == row2)System.out.println("第"+row+"行,第"+col+"列未找到合适的行!"); + anchor.setRow1(tempRow); + anchor.setRow2(tempRow+1); + System.out.println("临时行:"+tempRow); + System.out.println("临时行高度:"+row1Height/15); +// anchor.setDy1(XSSFShape.EMU_PER_PIXEL * 150); +// anchor.setDy2(XSSFShape.EMU_PER_PIXEL * 500); + anchor.setDy1(XSSFShape.EMU_PER_PIXEL * (t9-t/2)); + anchor.setDy2(XSSFShape.EMU_PER_PIXEL * (t3+t9-t/2-row1Height/15)); + } +// anchor.setDy1(XSSFShape.EMU_PER_PIXEL * (t - t2/2)); +// anchor.setDy2(XSSFShape.EMU_PER_PIXEL * (-1*t + t2/2)); + } + System.out.println("y1="+anchor.getDy1()); + System.out.println("y2="+anchor.getDy2()); + + anchor.setAnchorType(ClientAnchor.MOVE_AND_RESIZE); + Picture picture = drawing.createPicture(anchor, wb.addPicture(byteArrayOut.toByteArray(), HSSFWorkbook.PICTURE_TYPE_JPEG)); +// picture.resize(1d); + } + public static Result isMergedRegion(Sheet sheet,int row,int column){ + int sheetMergeCount=sheet.getNumMergedRegions(); + for(int i=0;i=firstRow&&row<=lastRow){ + if(column>=firstColumn&&column<=lastColumn){ + return new Result(true, firstRow, firstColumn, lastRow, lastColumn); + } + } + } + return new Result(false, 0, 0, 0, 0); + + } +} diff --git a/src/com/connor/hs2/plm/PFMEA/design/PFMEABean.java b/src/com/connor/hs2/plm/PFMEA/design/PFMEABean.java new file mode 100644 index 0000000..8d34a2d --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/design/PFMEABean.java @@ -0,0 +1,92 @@ +package com.connor.hs2.plm.PFMEA.design; + +public class PFMEABean { + + private String companyName; // 公司名称 + private String project; // 项目 + private String address;//制造地址 + private String pfmeaNumber;//pfmea号 + private String pfmeaStartDate;// PFMEA开始日期 + private String pfmeaUpdateDate; // PFMEA修订日期 + private String processDuty; // 过程职责 + private String customerName; // 顾客名称 + private String securityClassification;// 保密级别 + private String modelPlatform;// 车型/平台 + private String functionalTeams;// 跨职能团队 + +// private String productCode; + +// public String getProductCode() { +// return productCode; +// } +// public void setProductCode(String productCode) { +// this.productCode = productCode; +// } + public String getPfmeaNumber() { + return pfmeaNumber; + } + public void setPfmeaNumber(String pfmeaNumber) { + this.pfmeaNumber = pfmeaNumber; + } + public String getCompanyName() { + return companyName; + } + public void setCompanyName(String companyName) { + this.companyName = companyName; + } + public String getProject() { + return project; + } + public void setProject(String project) { + this.project = project; + } + public String getAddress() { + return address; + } + public void setAddress(String address) { + this.address = address; + } + public String getPfmeaStartDate() { + return pfmeaStartDate; + } + public void setPfmeaStartDate(String pfmeaStartDate) { + this.pfmeaStartDate = pfmeaStartDate; + } + public String getPfmeaUpdateDate() { + return pfmeaUpdateDate; + } + public void setPfmeaUpdateDate(String pfmeaUpdateDate) { + this.pfmeaUpdateDate = pfmeaUpdateDate; + } + public String getProcessDuty() { + return processDuty; + } + public void setProcessDuty(String processDuty) { + this.processDuty = processDuty; + } + public String getCustomerName() { + return customerName; + } + public void setCustomerName(String customerName) { + this.customerName = customerName; + } + public String getSecurityClassification() { + return securityClassification; + } + public void setSecurityClassification(String securityClassification) { + this.securityClassification = securityClassification; + } + public String getModelPlatform() { + return modelPlatform; + } + public void setModelPlatform(String modelPlatform) { + this.modelPlatform = modelPlatform; + } + public String getFunctionalTeams() { + return functionalTeams; + } + public void setFunctionalTeams(String functionalTeams) { + this.functionalTeams = functionalTeams; + } + +} diff --git a/src/com/connor/hs2/plm/PFMEA/design/Result.java b/src/com/connor/hs2/plm/PFMEA/design/Result.java new file mode 100644 index 0000000..7429ecd --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/design/Result.java @@ -0,0 +1,61 @@ +package com.connor.hs2.plm.PFMEA.design; + + +public class Result { + + private int row1; + private int row2; + private int col1; + private int col2; + private boolean bool = false; + + public Result(boolean bool,int row1,int col1,int row2,int col2) { + this.bool = bool; + this.row1 = row1; + this.col1 = col1; + this.row2 = row2; + this.col2 = col2; + } + + public boolean isBool() { + return bool; + } + + public void setBool(boolean bool) { + this.bool = bool; + } + + public int getRow1() { + return row1; + } + + public void setRow1(int row1) { + this.row1 = row1; + } + + public int getRow2() { + return row2; + } + + public void setRow2(int row2) { + this.row2 = row2; + } + + public int getCol1() { + return col1; + } + + public void setCol1(int col1) { + this.col1 = col1; + } + + public int getCol2() { + return col2; + } + + public void setCol2(int col2) { + this.col2 = col2; + } + + +} diff --git a/src/com/connor/hs2/plm/PFMEA/design/SavePfmea.java b/src/com/connor/hs2/plm/PFMEA/design/SavePfmea.java new file mode 100644 index 0000000..c8e0283 --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/design/SavePfmea.java @@ -0,0 +1,181 @@ +package com.connor.hs2.plm.PFMEA.design; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; +import java.util.UUID; + +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCSession; + +/** + * 保存数据到PFMEA表 + * @author Administrator + * + */ +public class SavePfmea { + + private TCSession session; + private TCComponentItem item; + private InterfaceAIFComponent comp; + private List> properties = new ArrayList>(); + private List> dataList = new ArrayList>();// 表格中的数据 + + public SavePfmea(TCSession session,TCComponentItem item,InterfaceAIFComponent comp) { + // TODO Auto-generated constructor stub + this.session = session; + this.item = item; + this.comp=comp; + } + + public void insertData() { + // TODO Auto-generated method stub + ResultSet rs = null; + ResultSet result = null; + ResultSet resultSet = null; + InputStream input = null; + try { + properties = TMomMethodUtil.getPFMEABomPropertys(session, item); + System.out.println("========>获取到的工序数量为:"+properties.size()+";打印:"+properties.toString()); + String itemUid = item.getUid(); + //获取工艺下的控制计划对象 +// TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); +// List kzjhList = new ArrayList(); +// for (int i = 0; i < kzjh.length; i++) { +// if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) +// { +// kzjhList.add((TCComponentItem)kzjh[i]); +// } +// } + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + // 查询数据库中的数据 + SqlUtilT.getTCConnection(); + String sql = String.format(pro.getProperty("BOMCHECKSAVESELECTPFMEA"), + itemUid, comp.getUid()); + //System.out.println("sql+++++:"+sql); + rs = SqlUtilT.read(sql); + while (rs.next()) { + List rowList = new ArrayList(); + rowList.add(rs.getString("MEOPID") == null ? "" : rs.getString("MEOPID")); + rowList.add(rs.getString("STATION")); + dataList.add(rowList); + } + //System.out.println("sql获取的数据dataList为:"+dataList.toString()); + if (dataList == null || dataList.size() == 0) { + for (int j = 0; j < properties.size(); j++) { + // 插入到PFMEA表 + System.out.println("--------->插入数据"+j+"条"); + SqlUtilT.getTCConnection(); + String insertPFMEA = pro.getProperty("INSERTPFMEA"); + // 插入PFMEA表 + SqlUtilT.getTCConnection(); + SqlUtilT.write(new String[] { + UUID.randomUUID().toString().replace("-", ""), + itemUid, properties.get(j).get(0), "",(properties.get(j).get(2).indexOf("/") >=0 ? properties.get(j).get(2).replace("/", "\n") : properties.get(j).get(2)),"", + "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "","","","","","","",properties.get(j).get(properties.get(j).size()-2),properties.get(j).get(1) ,comp.getUid(),properties.get(j).get(4)}, + insertPFMEA); + //+++ + } + }else { + + // 添加工序 + // 查询数据库中的数据 + result = SqlUtilT.read(sql); + List indexList = new ArrayList(); + while (result.next()) { + indexList.add(result.getString("MEOPID")); + } + for (int i = 0; i < properties.size(); i++) { + if (!indexList.contains(properties.get(i).get(0))) { + // 插入到PFMEA表 + String insertPFMEA = pro.getProperty("INSERTPFMEA"); + // 插入PFMEA表 +// SqlUtilT.write(new String[] { +// UUID.randomUUID().toString().replace("-", ""), +// itemUid, properties.get(i).get(0), +// properties.get(i).get(1), +// properties.get(i).get(2).indexOf("/") >=0 ? properties.get(i).get(2).replace("/", "\n") : properties.get(i).get(2), "", "", "", "", "", +// "", "", "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", "", "", "", "", "","","","","","","","","",comp.getUid() }, +// insertPFMEA); + //+++ + SqlUtilT.getTCConnection(); + SqlUtilT.write(new String[] { + UUID.randomUUID().toString().replace("-", ""), + itemUid, properties.get(i).get(0), "","", "", + properties.get(i).get(1)+(properties.get(i).get(2).indexOf("/") >=0 ? properties.get(i).get(2).replace("/", "\n") : properties.get(i).get(2)), "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "","","","","","","","","",comp.getUid(),properties.get(i).get(4) }, + insertPFMEA); + //+++ + + } + } + // 删除表中相应的工序 + StringBuffer sb = new StringBuffer(); + sb.append("("); + if(properties.size()>0) { + for (int i = 0; i < properties.size(); i++) { + sb.append("\'" + properties.get(i).get(0) + "\',"); + } + }else { + sb.append("\'" +"0"+ "\',");//如果没一个工序类,就直接全清空 + } + // 获取数据库连接 + SqlUtilT.getTCConnection(); + String selectSql = String + .format(pro.getProperty("BOMCHECKSAVESELECTPFMEA2"), + itemUid, + sb.toString().substring(0, sb.length() - 1) + + ")"); + resultSet = SqlUtilT.read(selectSql); + List deleteList = new ArrayList(); + while (resultSet.next()) { + deleteList.add(resultSet.getString("MEOPID")); + } + if (deleteList != null && deleteList.size() > 0) { + for (int i = 0; i < deleteList.size(); i++) { + SqlUtilT.getTCConnection(); + String deleteSQL = String.format( + pro.getProperty("DELETEPFMEA"), deleteList.get(i), + itemUid); + SqlUtilT.delete(deleteSQL); + } + } + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (result != null) { + SqlUtilT.free(result); + } + if (resultSet != null) { + SqlUtilT.free(resultSet); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } +} diff --git a/src/com/connor/hs2/plm/PFMEA/design/SqlUtilT.java b/src/com/connor/hs2/plm/PFMEA/design/SqlUtilT.java new file mode 100644 index 0000000..0a14129 --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/design/SqlUtilT.java @@ -0,0 +1,576 @@ +package com.connor.hs2.plm.PFMEA.design; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +//import cn.net.connor.ml.plm.sendBomSap.DbPool; + +/** + * 防止误继承因此是final类,防止误建对象因此用私有构造方法,为方便使用类名短小, PreparedStatement对象名和ResultSet对象名短小 + * + * @author hub 2015-02-06 + */ +public final class SqlUtilT { + public static Connection connection = null; + public static PreparedStatement ps = null; + public static ResultSet rs = null; + + // private static Registry reg = Registry.getRegistry(SqlUtilT.class); + /** + * 私有构造器不能new对象,防止误用对象 + */ + private SqlUtilT() { + + } + +// static { +// String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; // Util.getProperties("DRIVER"); +// +// System.out.println("driver " + driver); +// try { +// Class.forName(driver); +// } catch (ClassNotFoundException e) { +// System.out.println("ORACEL DRIVER IS EXCEPTION"); +// e.printStackTrace(); +// } +// } + + /** + * 链接数据库 + */ + public static Connection getTCConnection() { + try { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + TCPreferenceService service = session.getPreferenceService(); + String[] array = service.getStringArray( + TCPreferenceService.TC_preference_site, "connor_zf_db"); +// String driver_temp = null; + String url = null; + String dbName = null; + String dbPassword = null; + + if(array!=null && array.length==3) { + + url ="jdbc:sqlserver://"+array[0]; + + dbName = array[1]; + + dbPassword = array[2]; + } + String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; // Util.getProperties("DRIVER"); + + System.out.println("driver " + driver); + try { + Class.forName(driver); + } catch (ClassNotFoundException e) { + System.out.println("ORACEL DRIVER IS EXCEPTION"); + e.printStackTrace(); + } + // String driver_temp = reg.getString("ORACEL_DRIVER"); + // String url = reg.getString("ORACEL_URL");// getProperties("URL"); + // String dbName = reg.getString("ORACEL_NAME");// + // Util.getProperties("dbName"); + // String dbPassword = reg.getString("ORACEL_PASSWORD");// + // Util.getProperties("dbPassword"); + + if ( url == null || dbName == null + || dbPassword == null) { + + MessageBox.post("请检查数据库首选项是否配置正确", "错误提示", MessageBox.ERROR); + + } + // else{ + // MessageBox.post(driver_temp+" | "+url+" | "+dbName+" | "+dbPassword,"错误提示",MessageBox.ERROR); + // + // } + System.out.println(url + dbName + dbPassword); + connection = DriverManager.getConnection(url, dbName, dbPassword); + connection.setAutoCommit(false); + } catch (SQLException e) { + System.out.println("ORACEL CONNECT EXCEPTION"); + e.printStackTrace(); + return null; + // MessageBox.post("ORACEL CONNECT EXCEPTION \n"+e.getMessage(),"ERROR",MessageBox.ERROR); + } + return connection; + } + + + /** + * 拼接SELECT 语句 + * + * @param tableName + * @param selectElement + * @param args + * @return + */ + public static String getSelectSql(String tableName, String[] selectElement, + String... args) { + StringBuffer valuesSB = new StringBuffer("SELECT "); + if (selectElement != null) { + for (String element : selectElement) { + valuesSB.append(element).append(","); + } + valuesSB.delete(valuesSB.length() - 1, valuesSB.length()); + } + valuesSB.append(" FROM "); + valuesSB.append(tableName); + valuesSB.append(" WHERE"); + for (int i = 0; i < args.length; i++) { + valuesSB.append(" "); + valuesSB.append(args[i]); + valuesSB.append("=? "); + valuesSB.append("AND"); + } + + valuesSB.delete(valuesSB.length() - 3, valuesSB.length()); + return valuesSB.toString(); + } + + /** + * 拼接SELECT 语句 + * + * @param tableName + * @param args + * @return + */ + public static String getSelectSql(String tableName, String... args) { + StringBuffer valuesSB = new StringBuffer("SELECT * FROM "); + valuesSB.append(tableName); + valuesSB.append(" WHERE"); + for (int i = 0; i < args.length; i++) { + valuesSB.append(" "); + valuesSB.append(args[i]); + valuesSB.append("=? "); + valuesSB.append("AND"); + } + + valuesSB.delete(valuesSB.length() - 3, valuesSB.length()); + return valuesSB.toString(); + } + + /** + * 拼接更新语句 + * + * @param tableName + * @param args + * @param args2 + * @return + */ + public static String getUpdataSQL(String tableName, String[] args, + String[] args2) { + StringBuffer updateSB = new StringBuffer("UPDATE "); + updateSB.append(tableName); + updateSB.append(" SET "); + // 拼接更新语句 + for (int i = 0; i < args.length; i++) { + if (args[i].toUpperCase().equals("CREATED_DATE") + || args[i].toUpperCase().equals("LAST_UPDATE_DATE")) { + updateSB.append(args[i]).append( + "=to_date(?,'yyyy-MM-dd HH24:mi:ss') ,"); + } else { + updateSB.append(args[i]).append("=? ,"); + } + } + updateSB.delete(updateSB.length() - 2, updateSB.length()); + ; + updateSB.append(" WHERE "); + for (int i = 0; i < args2.length; i++) { + updateSB.append(args2[i]).append("=? AND "); + } + updateSB.delete(updateSB.length() - 4, updateSB.length()); + return updateSB.toString(); + } + + /** + * 拼接SQL的insert语句 + * + * @param tableName + * @param args + * @return + */ + public static String getInsertSql(String tableName, String... args) { + StringBuffer insertSql = new StringBuffer("insert into "); + StringBuffer values = new StringBuffer("values("); + + if (tableName != null && args != null && args.length > 0) { + insertSql.append(tableName); + insertSql.append("("); + for (int i = 0; i < args.length; i++) { + insertSql.append(args[i]); + insertSql.append(", "); + if (args[i].toUpperCase().equals("LAST_UPDATE_DATE") + || args[i].toUpperCase().equals("CREATED_DATE")) { + values.append("to_date(?,'yyyy-MM-dd HH24:mi:ss'), "); + } else { + values.append("?, "); + } + + } + } else { + return null; + } + insertSql.delete(insertSql.length() - 2, insertSql.length()); + values.delete(values.length() - 2, values.length()); + insertSql.append(") ").append(values).append(")"); + return insertSql.toString(); + } + + /** + * 得到创建表格数据库语句 + * + * @param tableName + * @param args + * 参数的名称 + * @param args2 + * 参数的类型 + * @return 拼接后的创建数据库的语句 + */ + public final static String GetCreateTableSQL(String tableName, + String[] args, String[] args2) { + + if (args == null || args2 == null || args.length != args2.length) { + System.out.println("THE INPUT PRAGREMS IS ERROR"); + return null; + } + StringBuffer createSQL = new StringBuffer("create table "); + createSQL.append(tableName); + createSQL.append("("); + for (int i = 0; i < args.length; i++) { + createSQL.append(args[i] + " "); + createSQL.append(args2[i] + ", "); + } + createSQL.delete(createSQL.length() - 2, createSQL.length()); + createSQL.append(")"); + return createSQL.toString(); + } + + /** + * 得到Statement + */ + public final static PreparedStatement getPs(String sql) throws SQLException { + return getPs(sql, null); + } + + /** + * 得到Statement + */ + public final static PreparedStatement getPs(Object[] argments, String sql) + throws SQLException { + return getPs(sql, argments); + } + + /** + * 得到Statement + */ + public final static PreparedStatement getPs(String sql, Object[] argments) + throws SQLException { + SqlUtilT.ps = SqlUtilT.connection.prepareStatement(sql,ResultSet.TYPE_FORWARD_ONLY,ResultSet.CONCUR_READ_ONLY); + SqlUtilT.ps.setFetchSize(1000); +// SqlUtilT.ps.setFetchDirection(ResultSet.FETCH_REVERSE); + + if (argments != null) { + for (int i = 0; i < argments.length; i++) { + SqlUtilT.ps.setObject(i + 1, argments[i]); + } + } + return SqlUtilT.ps; + } + + /** + * 增加 + */ + public final static int write(String sql) { + return write(sql, null); + } + + /** + * 增加 + */ + public final static int write(Object[] argments, String sql) { + return write(sql, argments); + } + + /** + * 增加 + */ + public final static int write2(Object[] argments, String sql) { + return write2(sql, argments); + } + + /** + * 增加 + */ + public final static int write(String sql, Object[] argments) { + + return update(sql, argments); + } + + /** + * 增加 + */ + public final static int write2(String sql, Object[] argments) { + + return update2(sql, argments); + } + + /** + * 删除 + */ + public final static int delete(String sql) { + return delete(sql, null); + } + + /** + * 删除 + */ + public final static int delete(Object[] argments, String sql) { + return delete(sql, argments); + } + + /** + * 删除 + */ + public final static int delete(String sql, Object[] argments) { + return update(sql, argments); + } + + /** + * 删除 + */ + public final static int delete2(String sql) { + int i = -1; + try { + i = SqlUtilT.getPs(null,sql).executeUpdate(); + SqlUtilT.connection.commit(); + } catch (SQLException e) { + e.printStackTrace(); + } + return i; + } + + /** + * 修改 + */ + public final static int update(String sql) { + return update(sql, null); + } + + /** + * 修改 + */ + public final static int update(String[] argments, String sql) { + return update(sql, argments); + } + + /** + * 修改(增删改最终都要调用此方法,此处进行异常处理,关闭除Connection以外的对象),不提交事务 + */ + public final static int update2(String sql, Object[] argments) { + int i = -1; + try { + PreparedStatement statement=null; + while(statement==null) { + statement=SqlUtilT.getPs(argments, sql); + if(statement==null) { + getTCConnection(); + System.out.println("+++++++++++++++++statement为空"); + } + } + i = statement.executeUpdate(); + //i = SqlUtilT.getPs(argments, sql).executeUpdate(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + free(SqlUtilT.rs, SqlUtilT.ps); + } + return i; + } + + /** + * 修改(增删改最终都要调用此方法,此处进行异常处理,关闭除Connection以为的对象) + */ + public final static int update(String sql, Object[] argments) { + int i = -1; + try { + PreparedStatement statement=null; + while(statement==null) { + statement=SqlUtilT.getPs(argments, sql); + if(statement==null) { + getTCConnection(); + System.out.println("+++++++++++++++++statement为空"); + } + } + i = statement.executeUpdate(); + //i = SqlUtilT.getPs(argments, sql).executeUpdate(); + SqlUtilT.connection.commit(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + free(SqlUtilT.rs, SqlUtilT.ps); + } + return i; + } + + /** + * 查询 + */ + public final static ResultSet read(String sql) throws SQLException { + return read(sql, null); + } + + /** + * 查询 + */ + public final static ResultSet read(Object[] argments, String sql) + throws SQLException { + return read(sql, argments); + } + + /** + * 查询(所有查询最终都要调用此方法,方法里面不处理异常,抛出后由调用者处理,方便在finally语句中释放资源) + * + * @throws SQLException + */ + public final static ResultSet read(String sql, Object[] argments) + throws SQLException { + return SqlUtilT.rs = SqlUtilT.getPs(argments, sql).executeQuery(); + } + + /** + * 创建表 + */ + public final static boolean createTable(String sql) { + return go(sql, null); + } + + /** + * 删除表 + */ + public final static boolean dropTable(String sql) { + return go(sql, null); + } + + /** + * 修改表 + */ + public final static boolean alterTable(String sql) { + return go(sql, null); + } + + /** + * 此方法用来执行DDL语句(创建表,修改表,删除表) + */ + private final static boolean go(String sql, Object[] argments) { + boolean flag = false; + try { + flag = SqlUtilT.getPs(sql, argments).execute(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + free(SqlUtilT.rs, SqlUtilT.ps); + } + if (flag) { + try { + SqlUtilT.connection.commit(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + return flag; + } + + /** + * 释放资源 + */ + public final static void free(ResultSet resultSet) { + free(resultSet, null, null); + } + + /** + * 释放资源 + */ + public final static void free(Statement statement) { + free(null, statement, null); + } + + /** + * 释放资源 + */ + public final static void free(Connection connection) { + free(null, null, connection); + } + + /** + * 释放资源 + */ + public final static void free(ResultSet resultSet, Statement statement) { + free(resultSet, statement, null); + } + + /** + * 释放资源 + */ + public final static void free(Statement statement, Connection connection) { + free(null, statement, connection); + } + + /** + * 释放资源(不传参数默认部分) + */ + public final static void free() { + free(SqlUtilT.rs, SqlUtilT.ps); + } + + /** + * 释放资源(全部释放) + */ + public final static void freeAll() { + free(SqlUtilT.rs, SqlUtilT.ps, SqlUtilT.connection); + } + + /** + * 释放资源(传满参数也要全部释放) + */ + public final static void free(ResultSet resultSet, Statement statement, + Connection connection) { + try { + if (resultSet != null) { + try { + resultSet.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } finally { + try { + if (statement != null) { + try { + statement.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } finally { + if (connection != null) { + try { + connection.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + } + } +} diff --git a/src/com/connor/hs2/plm/PFMEA/design/TMomMethodUtil.java b/src/com/connor/hs2/plm/PFMEA/design/TMomMethodUtil.java new file mode 100644 index 0000000..982b91a --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/design/TMomMethodUtil.java @@ -0,0 +1,1182 @@ +package com.connor.hs2.plm.PFMEA.design; + +import java.io.File; +import java.io.IOException; +import java.text.DecimalFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.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.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentMEProcess; +import com.teamcenter.rac.kernel.TCComponentProcess; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCComponentType; +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.TCQueryClause; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTextService; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.util.FileUtility; +import com.teamcenter.rac.util.MessageBox; + +public class TMomMethodUtil { + + private static List> bomPropertyList = new ArrayList>(); + + public static void main(String[] args) { + String str = "123|1234|123124"; + System.out.println(str.split("\\|").length); + } + + /** + * 判断获取的对象是否全部为ITEM + * + * @param comps + * 需要判断的目标对象 + * @param isNotIgor + * 是否需要忽略,如果TRUE 则不能忽略,如果FALSE 则可以忽略 + * + * @param isSameType + * 是否要求是相同的类型,如果TRUE 要求必须是相同的类型 + * @return + */ + public static List getItemList( + InterfaceAIFComponent[] comps, Boolean isNotIgor, Boolean isSameType) { + if (comps == null) { + + return null; + } + List itemList = new ArrayList(); + String type = null; + for (int i = 0; i < comps.length; i++) { + if (comps[i] instanceof TCComponentItem) { + if (isSameType) { + if (type == null) { + type = comps[i].getType(); + } else if (!type.equals(comps[i].getType())) { + return null; + } + } + itemList.add((TCComponentItem) comps[i]); + } else if (isNotIgor) { + return null; + } + } + return itemList; + } + +// /** +// * 获取模板文件 +// * @param session session +// * @param fileName 文件名 +// * @param Filetype 文件类型 +// * @return +// */ + public static File getFile(TCSession session,String fileName,String Filetype) { + // TODO Auto-generated method stub + try { + TCPreferenceService service = session.getPreferenceService(); + String[] modelFiles = service.getStringValues("ZF6-GYGL-Template"); + if (modelFiles == null) + { + System.out.println("未找到首选项"); + return null; + } + String puid = ""; + for (int i = 0; i < modelFiles.length; i++) { + if(modelFiles[i].split(":")[0].equals(fileName)) + { + puid = modelFiles[i].split(":")[1]; + } + } + TCComponentDataset dat = (TCComponentDataset)session + .stringToComponent(puid); + TCComponentTcFile[] tcFile = dat.getTcFiles(); + if(tcFile != null && tcFile.length == 0) + { + System.out.println("未找到配置文件"); + } + else + { + return tcFile[0].getFmsFile(); + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return null; + } + /** + * 获取最新的已发布的版本 + * @param item + * @return + */ +// public static TCComponentItemRevision getLastItemRevision(TCComponentItem item) { +// // TODO Auto-generated method stub +// try { +// TCComponentItemRevision[] items = item.getReleasedItemRevisions(); +// int revId = 0; +// TCComponentItemRevision itemRevision = null; +// for (int i = 0; i < items.length; i++) { +// String revisionId = items[i].getStringProperty("item_revision_id"); +// if(letterToNumber(revisionId) >= revId ) +// { +// itemRevision = items[i]; +// revId = letterToNumber(revisionId); +// } +// } +// return itemRevision; +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// return null; +// } + + public static int letterToNumber(String letter) { + int length = letter.length(); + int num = 0; + int number = 0; + for(int i = 0; i < length; i++) { + char ch = letter.charAt(length - i - 1); + num = (int)(ch - 'A' + 1) ; + num *= Math.pow(26, i); + number += num; + } + return number; + } + + /** + * 获取版本对象 + * + * @param comps + * 需要判断的目标对象 + * @param isNotIgor + * 是否需要忽略,如果TRUE 则不能忽略,如果FALSE 则可以忽略 + * + * @param isSameType + * 是否要求是相同的类型,如果TRUE 要求必须是相同的类型 + * @return + */ + public static List getItemRevList( + InterfaceAIFComponent[] comps, Boolean isNotIgor, Boolean isSameType) { + if (comps == null) { + + return null; + } + List itemList = new ArrayList(); + + String type = null; + for (int i = 0; i < comps.length; i++) { + if (comps[i] instanceof TCComponentItemRevision) { + + if (isSameType) { + if (type == null) { + type = comps[i].getType(); + } else if (!type.equals(comps[i].getType())) { + return null; + } + } + itemList.add((TCComponentItemRevision) comps[i]); + } else if (isNotIgor) { + return null; + } + } + return itemList; + } + + /** + * 获取存放的文件夹 + * + * @param item + * @param name + * @return + */ + public static TCComponentFolder getParentFolder(TCComponentItem item, + String name) { + TCComponentFolder folder = null; + try { + AIFComponentContext[] comtexts = item.whereReferenced(); + if (comtexts != null) { + for (int i = 0; i < comtexts.length; i++) { + if (comtexts[i].getComponent() instanceof TCComponentFolder) { + String nameT = ((TCComponentFolder) comtexts[i] + .getComponent()) + .getStringProperty("object_name"); + if (name.equals("工艺图纸") && nameT.equals("工艺图纸")) { + folder = (TCComponentFolder) comtexts[i] + .getComponent(); + } + else if(nameT.equals(name)) + { + folder = (TCComponentFolder) comtexts[i] + .getComponent(); + } + } + } + } + } catch (TCException e) { + e.printStackTrace(); + } + return folder; + } + + /** + * 获取存在的ITEM的个数 + * + * @param session + * 会话 + * @param oldItemID + * 旧编码 + * @return + */ + public static Integer getItemCount(TCSession session, String oldItemID) { + Integer count = 0; + InterfaceAIFComponent[] comps = searchComponentsCollection(session, + "Connor_TMom_Query_Item", new String[] { "item_id" }, + new String[] { oldItemID }); + if (comps == null) { + return null; + } + count = comps.length; + return count; + } + + /** + * 工艺生成新的ID + * + * @param oldItemID + * @return + */ + public static String getGyRuleID(TCSession session, String oldItemID) { + DecimalFormat df = new DecimalFormat("000"); + String newID = oldItemID + "_P001"; + Integer count = 0; + // String idTemp = + TCComponentItemType tccomponentitemtype; + try { + tccomponentitemtype = (TCComponentItemType) (session + .getTypeComponent("Item")); + + tccomponentitemtype.getNewID(); + int i = 1; + //setByPass(session,true); + while (tccomponentitemtype.find(newID) != null) { + i++; + newID = oldItemID + "_P" + df.format(i); + } + // setByPass(session,false); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return newID; + } + + + /** + * 工序生成新ID + * + * @param oldItemID + * @return + */ + public static String getGxRuleID(TCSession session, String oldItemID) { + TCComponentItemType tccomponentitemtype; + try { + tccomponentitemtype = (TCComponentItemType) (session + .getTypeComponent("MEOP")); + + return tccomponentitemtype.getNewID(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return ""; + } + + /** + * 通过查询,查找符合条件的版本 + * + * @param session + * 会话 + * @param searchName + * 查询名称 + * @param keys + * 查询关键字 + * @param values + * 查询值 + * @return + */ + public static InterfaceAIFComponent[] searchComponentsCollection( + TCSession session, String searchName, String[] keys, String[] values) { + // 信息输出 + InterfaceAIFComponent[] result = new InterfaceAIFComponent[0]; + + try { + TCTextService textService = session.getTextService(); + TCComponentQueryType querytype = (TCComponentQueryType) session + .getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) querytype + .find(searchName); + if (query == null) { + MessageBox.post("通过查询构建器" + searchName + "不存在", "错误", 1); + return null; + } + querytype.clearCache(); + String[] as = new String[keys.length]; + for (int i = 0; i < keys.length; i++) { + as[i] = textService.getTextValue(keys[i]); + } + + String[] as1 = new String[values.length]; + for (int i = 0; i < values.length; i++) { + as1[i] = textService.getTextValue(values[i]); + + } + + query.clearCache(); + TCQueryClause[] clauses = query.describe(); + TCComponentContextList list = query.getExecuteResultsList(as, as1); + + if (list != null) { + int count = list.getListCount(); + result = new InterfaceAIFComponent[count]; + + for (int i = 0; i < count; i++) { + result[i] = list.get(i).getComponent(); + } + } + } catch (TCException e) { + e.printStackTrace(); + MessageBox.post("通过查询构建器" + searchName + "查询发生错误.", "错误", 1); + } + + return result; + } + /** + * 自定义文件名下载文件 + * + * @param comps + * @return + * @throws TCException + * @throws IOException + */ + + public static String downLoadFiles(TCComponent comp,String Titles,String URL,Boolean flag) { + if (comp == null) { + return ""; + } + String value = ""; + String tempPath = System.getenv("TEMP"); + // MessageBox.post(" tempPath = + // "+tempPath,"INFO",MessageBox.INFORMATION); + if (tempPath == null) { + tempPath = ""; + } else if (!tempPath.endsWith("\\")) { + tempPath = tempPath + "\\"; + } + + // MessageBox.post(" tempPath = "+tempPath,"INFO",MessageBox.INFORMATION); + // MessageBox.post(" URL = "+URL,"INFO",MessageBox.INFORMATION); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); + // for(TCComponent comp : comps){ + try { + if (comp instanceof TCComponentDataset) { + TCComponentTcFile[] tcFiles = ((TCComponentDataset) comp) + .getTcFiles(); + File file = null; + if (tcFiles != null && tcFiles.length != 0) { + file = tcFiles[0].getFmsFile(); + String fileName = file.getName(); + String fileDix = fileName.substring( + fileName.lastIndexOf("."), fileName.length()); + if (flag == true) + { + if ((URL != "")&&(URL != " ")&&(URL != null)) + { + fileName = URL + Titles + fileDix; + } + else + { + fileName = tempPath + Titles + fileDix; + } + } + else + { + fileName = tempPath + sdf.format(new Date()) + fileDix; + } + File dirFile = new File(fileName); + FileUtility.copyFile(file, dirFile); + + return fileName; + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // } + return value; + } + + + + + + /** + * 下载文件 + * + * @param comps + * @return + * @throws TCException + * @throws IOException + */ + public static String downLoadFile(TCComponent comp) { + if (comp == null) { + return ""; + } + String value = ""; + String tempPath = System.getenv("TEMP"); + // MessageBox.post(" tempPath = + // "+tempPath,"INFO",MessageBox.INFORMATION); + if (tempPath == null) { + tempPath = ""; + } else if (!tempPath.endsWith("\\")) { + tempPath = tempPath + "\\"; + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); + // for(TCComponent comp : comps){ + try { + if (comp instanceof TCComponentDataset) { + TCComponentTcFile[] tcFiles = ((TCComponentDataset) comp) + .getTcFiles(); + File file = null; + if (tcFiles != null && tcFiles.length != 0) { + file = tcFiles[0].getFmsFile(); + String fileName = file.getName(); + String fileDix = fileName.substring( + fileName.lastIndexOf("."), fileName.length()); + fileName = tempPath + sdf.format(new Date()) + fileDix; + File dirFile = new File(fileName); + FileUtility.copyFile(file, dirFile); + + return fileName; + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // } + return value; + } + + /*** + * 获取首选项 + * + * @param session + * 会话 + * @param preferenceName + * 首选项名称 + * @return + */ + public static String[] getPreferenceValues(String preferenceName) { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + if (preferenceName == null || session == null) { + System.out.println(""); + return null; + } + String[] values = null; + TCPreferenceService service = session.getPreferenceService(); + values = service.getStringArray(TCPreferenceService.TC_preference_site, + preferenceName); + String[] resultValues = new String[values.length]; + for (int i = 0; i < values.length; i++) { + if(values[i].indexOf("\\n") >= 0) + { + resultValues[i] = values[i].replace("\\n", "\n"); + } + else + { + resultValues[i] = values[i]; + } + } + return resultValues; + } + + /** + * 删除文件 + * + * @param filePathList + * 文件地址 + */ + public static void deleteFile(List filePathList) { + for (int i = 0; i < filePathList.size(); i++) { + File file = new File(filePathList.get(i)); + if (file.exists() && file.isFile()) { + if (file.delete()) { + System.out.println("文件" + filePathList.get(i) + "已删除!"); + } + } + } + } + + /** + * 旁路 + * + * @param session + * @param val + * @throws TCException + */ + public static void setByPass(TCSession session, boolean val) + throws TCException { + + TCUserService userservice = session.getUserService(); + + Object[] obj = new Object[1]; + obj[0] = ""; + if (val) { + userservice.call("Connor_set_bypass", obj); + } else { + userservice.call("Connor_close_bypass", obj); + } + } + /** + * 转换合并单元格 + * @param regionCell + * @param row + * @return + */ + public static String getCombineCell(Map regionCell, int row) { + Iterator> it = regionCell.entrySet().iterator(); + StringBuffer sb = new StringBuffer(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + StringBuffer rowSb = new StringBuffer(); + StringBuffer columnSb = new StringBuffer(); + for (int k = 0; k < entry.getKey().length; k++) { + rowSb.append(entry.getKey()[k]); + rowSb.append(","); + } + for (int k = 0; k < entry.getValue().length; k++) { + columnSb.append(entry.getValue()[k]); + columnSb.append(","); + } + if (entry.getKey()[0] == row) { + sb.append(rowSb.substring(0, rowSb.length() - 1)+ "/"+ columnSb.substring(0,columnSb.length() - 1)+"-"); + } + } + if(sb.length() > 0) + { + return sb.toString().substring(0, sb.length()-1); + } + else + { + return ""; + } + } + + /** + * 通知流程 + * + * @param session + * @param val + * @throws TCException + */ + public static void setProcess(TCSession session, + TCComponentProcess process, TCComponentUser user) + throws TCException { + + TCUserService userservice = session.getUserService(); + + Object[] obj = new Object[2]; + obj[0] = process; + obj[1] = user; + userservice.call("TMOM_meop_tongzhi", obj); + } + + /** + * 获取PFMEA BOM属性 + */ + public static List> getPFMEABomPropertys(TCSession session, TCComponentItem item) { + // TODO Auto-generated method stub + //获取BOM + TCComponentBOMWindow bomWindow = null; + bomPropertyList.clear(); + try { + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topBomLine = bomWindow.setWindowTopLine(item, + item.getLatestItemRevision(), null, null); + //获取工艺下的控制计划对象 +// TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); +// List itme = new ArrayList(); +// for (int i = 0; i < kzjh.length; i++) { +// if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) +// { +// itme.add((TCComponentItem)kzjh[i]); +// } +// } + getBomPropertys(topBomLine, true); + return bomPropertyList; + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return null; + } +// public static List> getPFMEABomPropertys(TCSession session, TCComponentItem item) { +// // TODO Auto-generated method stub +// //获取BOM +// TCComponentBOMWindow bomWindow = null; +// try { +// TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session +// .getTypeComponent("BOMWindow"); +// bomWindow = bomWindowType.create(null); +// TCComponentBOMLine topBomLine = bomWindow.setWindowTopLine(item, +// item.getLatestItemRevision(), null, null); +// //获取工艺下的控制计划对象 +// TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); +// List itme = new ArrayList(); +// for (int i = 0; i < kzjh.length; i++) { +// if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) +// { +// itme.add((TCComponentItem)kzjh[i]); +// } +// } +// // 获取工序对象 +// AIFComponentContext aif[] = topBomLine.getChildren(); +// List> properties = new ArrayList>(); +// for (int i = 0; i < aif.length; i++) { +// TCComponentBOMLine subline = (TCComponentBOMLine) aif[i] +// .getComponent(); +// if(subline.getStringProperty("RB3_is_hide") != null && subline.getStringProperty("RB3_is_hide").equals("true")) +// { +// continue; +// } +// List propertie = new ArrayList(); +// propertie +// .add(subline.getStringProperty("bl_indented_title") +// .split("/")[0]); +// propertie.add(subline.getStringProperty("bl_sequence_no")); +// propertie +// .add(subline +// .getStringProperty("bl_item_object_name") == null ? "" +// : subline +// .getStringProperty("bl_item_object_name")); +// //获取工序下的BOM +// List equipmentNameList = new ArrayList(); +// if(subline.getChildren().length>0) +// { +// for (int j = 0; j < subline.getChildren().length; j++) { +// TCComponentBOMLine subChildrenline = (TCComponentBOMLine) subline.getChildren()[j] +// .getComponent(); +// System.out.println(subChildrenline.getType()); +// if(subChildrenline.getType().indexOf("Equipment") >= 0) +// { +// TCComponentICO[] icos = subChildrenline.getItem().getLatestItemRevision() +// .getClassificationObjects(); +// if (icos.length > 0) { +// ICSProperty[] descriptions = icos[0] +// .getICSProperties(true); +// for (int k = 0; k < descriptions.length; k++) { +// if (descriptions[k].getId() == 1004 && descriptions[k].getValue() != null +// && !descriptions[k].getValue().equals("")) { +// System.out.println(equipmentNameList.toString()); +// if(!equipmentNameList.contains(descriptions[k].getValue())) +// { +// equipmentNameList.add(descriptions[k].getValue()); +// } +// System.out.println(equipmentNameList.toString()); +// //sb.append(descriptions[k].getValue()+","); +// +// } +// } +// } +// } +// } +// } +// if(equipmentNameList.size() > 0) +// { +// propertie.add(equipmentNameList.toString().substring(1, equipmentNameList.toString().length()-1)); +// } +// else +// { +// propertie.add(""); +// } +// properties.add(propertie); +// } +// return properties; +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// return null; +// } + + /** + * 获取BOM属性 + */ + public static List> getBomPropertys(TCSession session, TCComponentItem item) { + // TODO Auto-generated method stub + bomPropertyList.clear(); + //获取BOM + TCComponentBOMWindow bomWindow = null; + try { + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topBomLine = bomWindow.setWindowTopLine(item, + item.getLatestItemRevision(), null, null); + //获取工艺下的控制计划对象 + TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); + List itme = new ArrayList(); + for (int i = 0; i < kzjh.length; i++) { + if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) + { + itme.add((TCComponentItem)kzjh[i]); + } + } + getBomPropertys(topBomLine, false); + return bomPropertyList; + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return null; + } +// public static List> getBomPropertys(TCSession session, TCComponentItem item) { +// // TODO Auto-generated method stub +// //获取BOM +// TCComponentBOMWindow bomWindow = null; +// try { +// TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session +// .getTypeComponent("BOMWindow"); +// bomWindow = bomWindowType.create(null); +// TCComponentBOMLine topBomLine = bomWindow.setWindowTopLine(item, +// item.getLatestItemRevision(), null, null); +// //获取工艺下的控制计划对象 +// TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); +// List itme = new ArrayList(); +// for (int i = 0; i < kzjh.length; i++) { +// if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) +// { +// itme.add((TCComponentItem)kzjh[i]); +// } +// } +// // 获取工序对象 +// AIFComponentContext aif[] = topBomLine.getChildren(); +// List> properties = new ArrayList>(); +// for (int i = 0; i < aif.length; i++) { +// TCComponentBOMLine subline = (TCComponentBOMLine) aif[i] +// .getComponent(); +// List propertie = new ArrayList(); +// propertie +// .add(subline.getStringProperty("bl_indented_title") +// .split("/")[0]); +// propertie.add(subline.getStringProperty("bl_sequence_no")); +// propertie +// .add(subline +// .getStringProperty("bl_item_object_name") == null ? "" +// : subline +// .getStringProperty("bl_item_object_name")); +// //获取工序下的BOM +// List equipmentNameList = new ArrayList(); +// if(subline.getChildren().length>0) +// { +// for (int j = 0; j < subline.getChildren().length; j++) { +// TCComponentBOMLine subChildrenline = (TCComponentBOMLine) subline.getChildren()[j] +// .getComponent(); +// System.out.println(subChildrenline.getType()); +// if(subChildrenline.getType().indexOf("Equipment") >= 0) +// { +// TCComponentICO[] icos = subChildrenline.getItem().getLatestItemRevision() +// .getClassificationObjects(); +// if (icos.length > 0) { +// ICSProperty[] descriptions = icos[0] +// .getICSProperties(true); +// for (int k = 0; k < descriptions.length; k++) { +// if (descriptions[k].getId() == 1004 && descriptions[k].getValue() != null +// && !descriptions[k].getValue().equals("")) { +// System.out.println(equipmentNameList.toString()); +// if(!equipmentNameList.contains(descriptions[k].getValue())) +// { +// equipmentNameList.add(descriptions[k].getValue()); +// } +// System.out.println(equipmentNameList.toString()); +// //sb.append(descriptions[k].getValue()+","); +// +// } +// } +// } +// } +// } +// } +// if(equipmentNameList.size() > 0) +// { +// propertie.add(equipmentNameList.toString().substring(1, equipmentNameList.toString().length()-1)); +// } +// else +// { +// propertie.add(""); +// } +// properties.add(propertie); +// } +// return properties; +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// return null; +// } + /** + * 获取插入到权限表的BOM行 + * @param session + * @param item + * @return + */ + public static List> getPermissionsBomPropertys(TCSession session, TCComponentItem item) { + // TODO Auto-generated method stub + //获取BOM + TCComponentBOMWindow bomWindow = null; + + try { + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topBomLine = bomWindow.setWindowTopLine(item, + item.getLatestItemRevision(), null, null); + //获取工艺下的控制计划对象 + TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); + List itme = new ArrayList(); + for (int i = 0; i < kzjh.length; i++) { + if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) + { + itme.add((TCComponentItem)kzjh[i]); + } + } + // 获取工序对象 + AIFComponentContext aif[] = topBomLine.getChildren(); + List> properties = new ArrayList>(); + for (int i = 0; i < aif.length; i++) { + if(((TCComponentBOMLine)aif[i].getComponent()).getItem().getType().equals("MEProcess")) + { + continue; + } + TCComponentBOMLine subline = (TCComponentBOMLine) aif[i] + .getComponent(); + List propertie = new ArrayList(); + propertie + .add(subline.getStringProperty("bl_indented_title") + .split("/")[0]); + propertie.add(subline.getStringProperty("bl_sequence_no")); + + String objectName = subline.getStringProperty("bl_item_object_name") == null ? "" + : subline.getStringProperty("bl_item_object_name"); + if(objectName.indexOf("/") >= 0) + { + propertie.add(objectName.split("/")[0]); + } + else + { + propertie.add(objectName); + } + //+++获取工序号 + propertie.add(subline.getStringProperty("RB3_GXH")); + //+++ + //获取工序下的BOM + List equipmentNameList = new ArrayList(); + if(subline.getChildren().length>0) + { + for (int j = 0; j < subline.getChildren().length; j++) { + TCComponentBOMLine subChildrenline = (TCComponentBOMLine) subline.getChildren()[j] + .getComponent(); + System.out.println(subChildrenline.getType()); + //if(subChildrenline.getType().indexOf("Equipment") >= 0) + //{ + equipmentNameList.add(subChildrenline.getItem().getStringProperty("item_id")); +// TCComponentICO[] icos = subChildrenline.getItem().getLatestItemRevision() +// .getClassificationObjects(); +// +// if (icos.length > 0) { +// ICSProperty[] descriptions = icos[0] +// .getICSProperties(true); +// for (int k = 0; k < descriptions.length; k++) { +// if (descriptions[k].getId() == 1004 && descriptions[k].getValue() != null +// && !descriptions[k].getValue().equals("")) { +// System.out.println(equipmentNameList.toString()); +// if(!equipmentNameList.contains(descriptions[k].getValue())) +// { +// equipmentNameList.add(descriptions[k].getValue()); +// } +// System.out.println(equipmentNameList.toString()); +// //sb.append(descriptions[k].getValue()+","); +// +// } +// } +// } + //} + } + } + if(equipmentNameList.size() > 0) + { + propertie.add(equipmentNameList.toString().substring(1, equipmentNameList.toString().length()-1)); + } + else + { + propertie.add(""); + } + properties.add(propertie); + } + return properties; + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return null; + } + + /** + * 获取BOM信息 + * @param meprocess 工艺BOMLINE + * @param isMeop 是否是PFEMA + * + */ + public static void getBomPropertys(TCComponentBOMLine meprocessBomLine, boolean isPFEMA) + { + try { + //获取工艺下的BOM + AIFComponentContext aif[] = meprocessBomLine.getChildren(); + for (int i = 0; i < aif.length; i++) { + if(aif[i]==null) {//防止 + continue; + } + TCComponentBOMLine subline = (TCComponentBOMLine) aif[i] + .getComponent(); + if(subline==null) { + continue; + } + + TCComponentItem item = subline.getItem(); + + System.out.println("type ==> "+item.getType()); + + //判断是否是工艺 + if(item.getType().equals("ZF6_GYLXRevision")) //.getType().equals("MEProcess") + { + getBomPropertys(subline, isPFEMA); + } + else // if(item.getType().equals("HS2_MEOP")) + { + List propertie = new ArrayList(); + //String ss = subline.getStringProperty("bl_indented_title"); + propertie.add(subline.getStringProperty("bl_indented_title") + .split("/")[0]); + //控制计划中的零件/工艺编号改为工序号 + //propertie.add(subline.getStringProperty("bl_sequence_no")); + propertie.add(subline.getStringProperty("bl_sequence_no")==null ? "": + subline.getStringProperty("bl_sequence_no")); + String bzString = subline.getStringProperty("bl_item_object_name") == null ? "": subline.getStringProperty("bl_item_object_name"); + String processNo = subline.getItemRevision().getStringProperty("zf6_ywfy") == null ? "": subline.getItemRevision().getStringProperty("zf6_ywfy"); + propertie.add(bzString+processNo); + + //获取工序下的BOM的资源,机器设备。PFMEA跳过 + if(isPFEMA) + { + propertie.add(""); + }else { + List equipmentNameList = new ArrayList(); + if(subline.getChildren().length>0) + { + for (int j = 0; j < subline.getChildren().length; j++) { + TCComponentBOMLine subChildrenline = (TCComponentBOMLine) subline.getChildren()[j] + .getComponent(); + if(subChildrenline.toString().equals("<<无法读取>>")&&subChildrenline!=null) {//防止工艺资源出错,无权限读取 + continue; + } + System.out.println(subChildrenline.getType()); + String ClassID=subChildrenline.getItemRevision().getClassificationClass(); + if(ClassID!=null&&!ClassID.equals("")&&ClassID.length()>2) { + if(ClassID.substring(0,2).equals("15")) { + equipmentNameList.add(subChildrenline.getItem().getStringProperty("object_name")); + } + } + + } + } + if(equipmentNameList.size() > 0) + { + propertie.add(equipmentNameList.toString().substring(1, equipmentNameList.toString().length()-1)); + } + else + { + propertie.add(""); + } + } + propertie.add(subline.getItemRevision().getUid()); + propertie.add(String.valueOf(bomPropertyList.size()+1)); + bomPropertyList.add(propertie); + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + /*** + * 根据正则表达式提取括号中的内容 + * @param value + * @return + */ + public static List getListByRegular(String value) + { + List resultList = new ArrayList(); + Pattern p = Pattern.compile("(\\[[^\\]]*\\])"); + Matcher m = p.matcher(value); + while(m.find()) + { + resultList.add(m.group().substring(1, m.group().length() - 1)); + } + return resultList; + } + + public static int getDays(String dateStr1, String dateStr2, String dateFormat) { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormat); + Date date1 = null; + Date date2 = null; + try { + date1 = simpleDateFormat.parse(dateStr1); + date2 = simpleDateFormat.parse(dateStr2); + } catch (ParseException e) { + e.printStackTrace(); + } + + String year1 = String.format("%tY", date1); + String mon1 = String.format("%tm", date1); + String day1 = String.format("%td", date1); + int y1 = Integer.valueOf(year1); + int m1 = Integer.valueOf(mon1); + int d1 = Integer.valueOf(day1); + int days1 = getRecentYearDays(y1, m1, d1); + System.out.println(days1); + + String year2 = String.format("%tY", date2); + String mon2 = String.format("%tm", date2); + String day2 = String.format("%td", date2); + int y2 = Integer.valueOf(year2); + int m2 = Integer.valueOf(mon2); + int d2 = Integer.valueOf(day2); + int days2 = getRecentYearDays(y2, m2, d2); + System.out.println(days2); + + int count = 0; + for (int i = y1; i < y2; i++) { + if ((i % 4 == 0 && i % 100 != 0) || i % 400 == 0) { + count += 366; + } else { + count += 365; + } + } + count = count + days2 - days1; + + return count; + } + + public static int getRecentYearDays(int y, int m, int d) { + + int count = 0; + + switch (m - 1) { + case 1: + count += 31; + break; + case 2: + count += 31 + 28; + break; + case 3: + count += 31 + 28 + 31; + break; + case 4: + count += 31 + 28 + 31 + 30; + break; + case 5: + count += 31 + 28 + 31 + 30 + 31; + break; + case 6: + count += 31 + 28 + 31 + 30 + 31 + 30; + break; + case 7: + count += 31 + 28 + 31 + 30 + 31 + 30 + 31; + break; + case 8: + count += 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31; + break; + case 9: + count += 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30; + break; + case 10: + count += 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31; + break; + case 11: + count += 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30; + break; + } + if (((y % 4 == 0 && y % 100 != 0) || y % 400 == 0) && m > 2) + count++; + return count + d; + } + +// public static ControlPlanComboBoxBean[] getComboxItem(TCSession session,String pernaem) +// { +// ControlPlanComboBoxBean[] comboBoxBeans = null; +// TCPreferenceService pref = session.getPreferenceService(); +// String[] items = pref.getStringValues(pernaem);// 首选项查puid +// comboBoxBeans = new ControlPlanComboBoxBean[items.length]; +// for (int i = 0; i < items.length; i++) { +// if(items[i].indexOf("-")>0) +// { +// ControlPlanComboBoxBean bean = new ControlPlanComboBoxBean(); +// bean.setItemId(items[i].split("-")[0]); +// bean.setItemName(items[i].split("-")[1]); +// comboBoxBeans[i] = bean; +// } +// } +// return comboBoxBeans; +// } + +} diff --git a/src/com/connor/hs2/plm/PFMEA/design/TableCellTextAreaRenderer.java b/src/com/connor/hs2/plm/PFMEA/design/TableCellTextAreaRenderer.java new file mode 100644 index 0000000..b713e7e --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/design/TableCellTextAreaRenderer.java @@ -0,0 +1,220 @@ +package com.connor.hs2.plm.PFMEA.design; + +import java.awt.Color; +import java.awt.Component; +import java.util.List; +import java.util.Map; + +import javax.swing.JTable; +import javax.swing.JTextPane; +import javax.swing.table.TableCellRenderer; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.StyleConstants; + +public class TableCellTextAreaRenderer extends JTextPane implements + TableCellRenderer { + private List processRows; + private Map> labelRows;//标注行 + public List getProcessRows() { + return processRows; + } + + public void setProcessRows(List processRows) { + this.processRows = processRows; + } + + public Map> getLabelRows() { + return labelRows; + } + + public void setLabelRows(Map> labelRows) { + this.labelRows = labelRows; + } + + public TableCellTextAreaRenderer() { + // setLineWrap(true);//自动换行 + // setWrapStyleWord(true); + + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + // TODO Auto-generated method stub + int maxPreferredHeight = 0; + if (table.getColumnName(column).equals("RPN")) { + // 5,9,11 + String yzd = table.getValueAt(row, 6) == null ? "0" : table + .getValueAt(row, 6).toString(); + String pds = table.getValueAt(row, 10) == null ? "0" : table + .getValueAt(row, 10).toString(); + String tcd = table.getValueAt(row, 12) == null ? "0" : table + .getValueAt(row, 12).toString(); + int rpn = Integer.parseInt(yzd) * Integer.parseInt(pds) + * Integer.parseInt(tcd); + if (rpn == 0) { + table.setValueAt("", row, column); + setText(""); + } else { + table.setValueAt(String.valueOf(rpn), row, column); + setText(String.valueOf(rpn)); + } + } else { + setText(value == null ? "" : value.toString()); + } + // //特殊符号 + // if(table.getValueAt(row, table.getColumnCount()-1) != null) + // { + // String special = table.getValueAt(row, + // table.getColumnCount()-1).toString(); + // if(special.indexOf("|") >= 0) + // { + // String[] specials = special.split("\\|"); + // for (int i = 0; i < specials.length; i++) { + // if(specials[i].indexOf("-") >= 0) + // { + // String[] columnName = specials[i].split("-"); + // if(table.getColumnName(column).equals(columnName[0])) + // { + // setTextFont(value.toString(),Integer.parseInt(columnName[1]) + // ,"Y14.5M"); + // } + // } + // } + // } + // else if(special.indexOf("-") >= 0) + // { + // String[] columnName = special.split("-"); + // if(table.getColumnName(column).equals(columnName[0])) + // { + // setTextFont(value.toString(),Integer.parseInt(columnName[1]) + // ,"Y14.5M"); + // } + // } + // } + + for (int i = 0; i < table.getColumnCount(); i++) { + setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + maxPreferredHeight = Math.max(maxPreferredHeight, + getPreferredSize().height); + } + if (table.getColumnName(column).equals("RPN") && value != null + && !value.equals("") + && Integer.parseInt(value.toString()) >= 100) { + setBackground(Color.RED); + setForeground(Color.black); + } + else if (processRows == null || processRows.size() <= 0 + || !processRows.contains(row)) { + setBackground(new Color(220,220,220)); + setForeground(Color.black); + + } + else { + setBackground(Color.white); + setForeground(Color.black); + } + if (labelRows != null && labelRows.keySet().contains(row)) { + if(labelRows.get(row).contains(((Integer)column).toString())) + { + setBackground(Color.RED); + setForeground(Color.black); + } + } +// else if (row == table.getSelectedRow()) { +// setBackground(Color.GRAY); +// setForeground(Color.black); +// } else if (column == table.getSelectedColumn()) { +// setBackground(Color.GRAY); +// setForeground(Color.black); +// } + + //判断单元格选中并且为可修改状态 + if (isSelected) { + // setBackground(new Color(0, 120, 215)); + setBackground(new Color(184,184,184)); + setForeground(Color.black); + } + if (table.getRowHeight(row) != maxPreferredHeight)// 少了这行则处理器瞎忙 + { + table.setRowHeight(row, maxPreferredHeight); + } + return this; + } + + // 设置字体,如一个字符串中需要包含多个字体样式,可创建多个SimpleAttributeSet,并将字符串拆分开,按顺序使用Document的insertString方法插入 + private void setTextFont(String value, int index, String font) { + // TODO Auto-generated method stub + SimpleAttributeSet set = new SimpleAttributeSet(); + // StyleConstants.setForeground(set, Color.red);//设置文字颜色 + StyleConstants.setFontFamily(set, font);// 设置字体样式 + SimpleAttributeSet set2 = new SimpleAttributeSet(); + // StyleConstants.setForeground(set, Color.red);//设置文字颜色 + StyleConstants.setFontFamily(set2, "Courier New");// 设置字体样式 + // StyleConstants.setFontSize(set2, 10); + Document doc = this.getStyledDocument(); + try { + // 插入前需要先删除 + doc.remove(0, value.toString().length()); + value = value.replaceAll(" ", ""); + doc.insertString(doc.getLength(), + value.toString().substring(0, index), set2); + doc.insertString(doc.getLength(), + value.toString().substring(index, index + 1), set); + doc.insertString( + doc.getLength(), + value.toString().substring(index + 1, + value.toString().length()), set2); + if (value.toString() + .substring(index + 1, value.toString().length()) == null + || value.toString() + .substring(index + 1, value.toString().length()) + .equals("")) { + doc.insertString(doc.getLength(), " ", set2); + } + } catch (BadLocationException e) { + e.printStackTrace(); + } finally { + set = null; + doc = null; + System.gc(); + } + } + // + // @Override + // public Component getTableCellRendererComponent(JTable table, Object + // value, boolean isSelected, boolean hasFocus, + // int row, int column) { + // // TODO Auto-generated method stub + // int maxPreferredHeight = 0; + // for (int i = 0; i < table.getColumnCount(); i++) { + // setText("" + table.getValueAt(row, i)); + // setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + // maxPreferredHeight = Math.max(maxPreferredHeight, + // getPreferredSize().height); + // } + // setBorder(BorderFactory.createLineBorder(Color.white)); + // setBackground(Color.white); + // setForeground(Color.black); + // if(isSelected){ + // setBackground(new Color(0, 120, 215)); + // setForeground(Color.white); + // } + // String val=(String) table.getValueAt(row, column); + // int w=0; + // if(val!=null){ + // w=val.length()*6/table.getColumn(table.getColumnName(column)).getWidth(); + // } + // if(w!=0){ + // //System.out.println("height:"+table.getRowHeight()*(w+1)); + // table.setRowHeight(row,table.getRowHeight()*(w+1)); + // } + // + // + // setText(value == null ? "" : value.toString()); + // return this; + // } + +} diff --git a/src/com/connor/hs2/plm/PFMEA/design/TableCellTextAreaRenderer2.java b/src/com/connor/hs2/plm/PFMEA/design/TableCellTextAreaRenderer2.java new file mode 100644 index 0000000..6a11ec6 --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/design/TableCellTextAreaRenderer2.java @@ -0,0 +1,159 @@ +package com.connor.hs2.plm.PFMEA.design; + +import java.awt.Color; +import java.awt.Component; +import java.util.List; + +import javax.swing.JTable; +import javax.swing.JTextPane; +import javax.swing.table.TableCellRenderer; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.StyleConstants; + +import com.teamcenter.rac.util.MessageBox; + +public class TableCellTextAreaRenderer2 extends JTextPane implements + TableCellRenderer { + private List processRows; + + public List getProcessRows() { + return processRows; + } + + public void setProcessRows(List processRows) { + this.processRows = processRows; + } + + public TableCellTextAreaRenderer2() { + // setLineWrap(true);//自动换行 + // setWrapStyleWord(true); + + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + // TODO Auto-generated method stub + int maxPreferredHeight = 0; + if (row > 0 && table.getColumnName(column).equals("RPN")) { + // 5,9,11 + String yzd = table.getValueAt(row, 6) == null ? "0" : table + .getValueAt(row, 6).toString(); + String pds = table.getValueAt(row, 10) == null ? "0" : table + .getValueAt(row, 10).toString(); + String tcd = table.getValueAt(row, 12) == null ? "0" : table + .getValueAt(row, 12).toString(); + int rpn = Integer.parseInt(yzd) * Integer.parseInt(pds) + * Integer.parseInt(tcd); + if (rpn == 0) { + table.setValueAt("", row, column); + setText(""); + } else { + table.setValueAt(String.valueOf(rpn), row, column); + setText(String.valueOf(rpn)); + } + } else { + setText(value == null ? "" : value.toString()); + } + + for (int i = 0; i < table.getColumnCount(); i++) { + setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + maxPreferredHeight = Math.max(maxPreferredHeight, + getPreferredSize().height); + } + if (row > 0 && table.getColumnName(column).equals("RPN") + && value != null && !value.equals("") + && Integer.parseInt(value.toString()) >= 100) { + setBackground(Color.RED); + setForeground(Color.black); + } + else if (isSelected) { + setBackground(Color.GRAY); + setForeground(Color.black); + } else { + setBackground(Color.white); + setForeground(Color.black); + } + if (table.getRowHeight(row) != maxPreferredHeight)// 少了这行则处理器瞎忙 + { + table.setRowHeight(row, maxPreferredHeight); + } + return this; + } + + // 设置字体,如一个字符串中需要包含多个字体样式,可创建多个SimpleAttributeSet,并将字符串拆分开,按顺序使用Document的insertString方法插入 + private void setTextFont(String value, int index, String font) { + // TODO Auto-generated method stub + SimpleAttributeSet set = new SimpleAttributeSet(); + // StyleConstants.setForeground(set, Color.red);//设置文字颜色 + StyleConstants.setFontFamily(set, font);// 设置字体样式 + SimpleAttributeSet set2 = new SimpleAttributeSet(); + // StyleConstants.setForeground(set, Color.red);//设置文字颜色 + StyleConstants.setFontFamily(set2, "Courier New");// 设置字体样式 + // StyleConstants.setFontSize(set2, 10); + Document doc = this.getStyledDocument(); + try { + // 插入前需要先删除 + doc.remove(0, value.toString().length()); + value = value.replaceAll(" ", ""); + doc.insertString(doc.getLength(), + value.toString().substring(0, index), set2); + doc.insertString(doc.getLength(), + value.toString().substring(index, index + 1), set); + doc.insertString( + doc.getLength(), + value.toString().substring(index + 1, + value.toString().length()), set2); + if (value.toString() + .substring(index + 1, value.toString().length()) == null + || value.toString() + .substring(index + 1, value.toString().length()) + .equals("")) { + doc.insertString(doc.getLength(), " ", set2); + } + } catch (BadLocationException e) { + MessageBox.post(e.toString(), "错误", MessageBox.ERROR); + e.printStackTrace(); + } finally { + set = null; + doc = null; + System.gc(); + } + } + // + // @Override + // public Component getTableCellRendererComponent(JTable table, Object + // value, boolean isSelected, boolean hasFocus, + // int row, int column) { + // // TODO Auto-generated method stub + // int maxPreferredHeight = 0; + // for (int i = 0; i < table.getColumnCount(); i++) { + // setText("" + table.getValueAt(row, i)); + // setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + // maxPreferredHeight = Math.max(maxPreferredHeight, + // getPreferredSize().height); + // } + // setBorder(BorderFactory.createLineBorder(Color.white)); + // setBackground(Color.white); + // setForeground(Color.black); + // if(isSelected){ + // setBackground(new Color(0, 120, 215)); + // setForeground(Color.white); + // } + // String val=(String) table.getValueAt(row, column); + // int w=0; + // if(val!=null){ + // w=val.length()*6/table.getColumn(table.getColumnName(column)).getWidth(); + // } + // if(w!=0){ + // //System.out.println("height:"+table.getRowHeight()*(w+1)); + // table.setRowHeight(row,table.getRowHeight()*(w+1)); + // } + // + // + // setText(value == null ? "" : value.toString()); + // return this; + // } +} \ No newline at end of file diff --git a/src/com/connor/hs2/plm/PFMEA/design/Test.java b/src/com/connor/hs2/plm/PFMEA/design/Test.java new file mode 100644 index 0000000..bc96349 --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/design/Test.java @@ -0,0 +1,26 @@ +package com.connor.hs2.plm.PFMEA.design; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; + +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +public class Test { + + public static void main(String[] args) { + + + try { + InputStream input = new FileInputStream(new File("D:\\excel模板\\MBOM明细表(电气) - 改.xlsx")); + XSSFWorkbook wb = new XSSFWorkbook(input); + wb.getSheetAt(0); + System.out.println(1); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} diff --git a/src/com/connor/hs2/plm/PFMEA/design/TreeBean.java b/src/com/connor/hs2/plm/PFMEA/design/TreeBean.java new file mode 100644 index 0000000..7ae0223 --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/design/TreeBean.java @@ -0,0 +1,77 @@ +package com.connor.hs2.plm.PFMEA.design; +import java.util.List; + + +public class TreeBean { + private String plmeid; + private String id; + private String P1; + private String P2; + private String P3; + private String P4; + private String P5; + private String name; + private String parentId; + private List chidrenBeans; + public String getPlmeid() { + return plmeid; + } + public void setPlmeid(String plmeid) { + this.plmeid = plmeid; + } + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + public String getP1() { + return P1; + } + public void setP1(String P1) { + this.P1 = P1; + } + public String getP2() { + return P2; + } + public void setP2(String P2) { + this.P2 = P2; + } + public String getP3() { + return P3; + } + public void setP3(String P3) { + this.P3 = P3; + } + public String getP4() { + return P4; + } + public void setP4(String P4) { + this.P4 = P4; + } + public String getP5() { + return P5; + } + public void setP5(String P5) { + this.P5 = P5; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public String getParentId() { + return parentId; + } + public void setParentId(String parentId) { + this.parentId = parentId; + } + public List getChidrenBeans() { + return chidrenBeans; + } + public void setChidrenBeans(List chidrenBeans) { + this.chidrenBeans = chidrenBeans; + } + +} diff --git a/src/com/connor/hs2/plm/PFMEA/design/sql.properties b/src/com/connor/hs2/plm/PFMEA/design/sql.properties new file mode 100644 index 0000000..bda2428 --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/design/sql.properties @@ -0,0 +1,37 @@ +SETPFMEASELECT=SELECT * FROM AHMC_PFMEA WHERE PROCESSPUID = \'%s\' AND REVISIONID=\'%s\' ORDER BY to_number(NO),to_number(HH) +PFMEALIBRARYSELECT2=SELECT * FROM AHMC_PFMEALIBRARY WHERE PUID = \'%s\' order by NUM + +BOMCHECKSAVESELECTPFMEA=select MEOPID,STATION,gybh,GCMC from AHMC_PFMEA where PROCESSPUID = \'%s\'REVISIONID=\'%s\' + +BOMCHECKSAVESELECTPFMEA2=select * from AHMC_PFMEA where PROCESSPUID = \'%s\' and MEOPID not in %s + +DELETEPFMEA=delete from AHMC_PFMEA where MEOPID = \'%s\' and PROCESSPUID = \'%s\' + +INSERTPFMEA=INSERT INTO AHMC_PFMEA VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) + +PFMEALIBRARYSELECT=SELECT * FROM AHMC_PFMEA_NODE WHERE PARENT_ID = \'%s\' order BY ID +SETPFMEASELECT2=SELECT MEOPID,REQUIREMENT from AHMC_PFMEA where PROCESSPUID = \'%s\' group by MEOPID,REQUIREMENT +SETPFMEADELETE=delete from AHMC_PFMEA where PLMEID = \'%s\' + +SETPFMEAUPDATE=update AHMC_PFMEA set GYBH = ?,GCMC = ?,STATION = ?,REQUIREMENT = ?,QZSXMS = ?,QZSXHG = ?,YZD = ?,JB = ?,QZSXQY = ?,XXGCKZYF = ?,PDS = ?,XXGCKZTC = ?,TCD = ?,RPN = ?,JYCS = ?,ZZR = ?,JHWCRQ = ?,CQDCS = ?,NEW_SEV = ?,NEW_OCC = ?,NEW_DET = ?,NEW_RPN = ?,IDEAL_STATE = ?,SPECIAL = ?,HH = ?,HBDYG = ? ,OCCURRRENCE = ?,DETECTION = ?,PRIORITY = ?,P1 = ?,P2 = ?,P3 = ?,P4 = ?,P5 = ? where plmeid = \'%s\' AND revisionid=\'%s\' +TM2PFMEATREESELECT=select * from AHMC_PFMEA_TREE ORDER BY PARENT_ID,ID + +CONTROLPLANLIBRARYSELECT=SELECT * FROM AHMC_CONTROLPLAN_NODE WHERE PARENT_ID = \'%s\' order BY ID + +TM2CONTROLPLANTREESELECT=select * from AHMC_CONTROLPLAN_TREE ORDER BY TO_NUMBER(PARENT_ID) + +TM2THESAURUSTREESELECT=select * from AHMC_THESAURUS_TREE ORDER BY TO_NUMBER(PARENT_ID) + +TM2THESAURUSNODESELECT=SELECT * FROM AHMC_THESAURUS_NODE WHERE PARENT_ID = \'%s\' order BY ID + +PFMEALIBRARYUPDATE=update AHMC_PFMEA_NODE set ID = ?, STATION = ?,REQUIREMENT = ?,QZSXMS = ?,QZSXHG = ?,YZD = ?,JB = ?,QZSXQY = ?,XXGCKZYF = ?,PDS = ?,XXGCKZTC = ?,TCD = ?,RPN = ?,JYCS = ?,ZZR = ?,JHWCRQ = ?,CQDCS = ?,NEW_SEV = ?,NEW_OCC = ?,NEW_DET = ?,NEW_RPN = ?,IDEAL_STATE = ?,SPECIAL = ?,P1 = ?,P2 = ?,P3 = ?,P4 = ?,P5 = ?,P6 = ?,P7 = ?,P8 = ? where plmeid = \'%s\' + +PFMEALIBRARYDELETE=delete from AHMC_PFMEA_NODE where PLMEID = \'%s\' + +PFMEALIBRARYINSERT=INSERT INTO AHMC_PFMEA_NODE VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) + + +SELECTFRAMESIZE=select * from AHMC_PFMEAFRAME_SIZE WHERE USERNAME = \'%s\' AND TYPE = \'%s\' +FRAMESIZEINSERT=INSERT INTO AHMC_PFMEAFRAME_SIZE VALUES(?,?,?,?,?,?) +FRAMESIZEDELETE=DELETE FROM AHMC_PFMEAFRAME_SIZE WHERE USERNAME = \'%s\' AND TYPE = \'%s\' +FRAMESIZEUPDATE=update AHMC_PFMEAFRAME_SIZE set FRAMESIZE = ?, TABLE1SIZE = ?, TABLE2SIZE = ? WHERE USERNAME = \'%s\' AND TYPE = \'%s\' \ No newline at end of file diff --git a/src/com/connor/hs2/plm/PFMEA/design/utils.java b/src/com/connor/hs2/plm/PFMEA/design/utils.java new file mode 100644 index 0000000..2e3bc44 --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/design/utils.java @@ -0,0 +1,138 @@ +package com.connor.hs2.plm.PFMEA.design; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import javax.swing.JComboBox; + +import com.teamcenter.rac.common.lov.LOVComboBox; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.services.rac.core.LOVService; +import com.teamcenter.services.rac.core._2013_05.LOV.InitialLovData; +import com.teamcenter.services.rac.core._2013_05.LOV.LOVSearchResults; +import com.teamcenter.services.rac.core._2013_05.LOV.LOVValueRow; +import com.teamcenter.services.rac.core._2013_05.LOV.LovFilterData; +public class utils { + + public static void main(String[] args) { + String value = "12345"; + Integer valueOf = Integer.valueOf(value)*10; + String newName = String.format("%04d", valueOf); + String substring = newName.substring(0,4); + System.out.println(substring); + } + + public static void dymanicLov(TCSession session,TCComponentListOfValues lov,JComboBox lovComboBox) { +// System.out.println("动态lovName=" + lovName); + + LOVService lovService = LOVService.getService(session); + InitialLovData input = new InitialLovData(); + LovFilterData filter = new LovFilterData(); + filter.sortPropertyName = ""; // lov的后台值 + filter.order = 1; + filter.numberToReturn = 10000; + filter.maxResults = 10000; + + input.lov = lov; + input.filterData = filter; + LOVSearchResults result = lovService.getInitialLOVValues(input); +// LOVSearchResults + System.out.println("动态lov数量" + result.lovValues.length); + for (LOVValueRow row : result.lovValues) { + Map map = row.propDisplayValues; + String disval = ""; + String xsVal = ""; + String key1 = "r9_WLZ";// 显示值第一列 + for(String key : map.keySet()) { + lovComboBox.addItem(map.get(key)[0]); +// System.out.println(""); + } + } + } + public static String TCGetPropertyValue(TCComponentBOMLine bomLine,String type,String propertyName,String propertyValue) throws TCException + { + //判断是否包含.号 + if (propertyName.contains(".")) + { + //根据等号拆分条件和值 +// char ** itemPropertyChar = new char *[64]; +// //分割字符串 +// split(propertyName, ".", itemPropertyChar, &itemPropertyCount); + + String[] split = propertyName.split("\\."); + String itemAddress = split[0]; +// char * itemAddress = itemPropertyChar[0]; + + if (type.equals("Bomline")) + { +// tag_t revisions = NULLTAG; + TCComponent item=null; +// AOM_ask_value_tag(item, "bl_line_object", &revisions); + //传进来的是对象 + if (itemAddress.equals("item")) + { +// ITEM_ask_item_of_rev(revisions, &item); + item = bomLine.getItem(); + } + else if (itemAddress.equals("rev")) + { + item = bomLine.getItemRevision(); + } + else if (itemAddress.equals("revMaster")) + { + TCComponentItemRevision revision= bomLine.getItemRevision(); + TCComponent revMaster = revision.getRelatedComponent("IMAN_master_form_rev"); + if(revMaster!=null) { + item=revMaster; + } + }else { + item=bomLine; + } + //判断拆分出的数量是否大于2 + if (split.length > 2) + { + //遍历查找关系对象 + for (int i = 1; i < split.length - 1; i++) + { +// item.get +// AOM_ask_value_tag(item, itemPropertyChar[i], &item); + } + } + if (item == null) + { + propertyValue = ""; + } + else + { + try { + propertyValue = item.getStringProperty(split[split.length-1]); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + } + else + { + propertyValue = propertyName; + } + + return propertyValue; + } + + + +} diff --git a/src/com/connor/hs2/plm/PFMEA/library/LibraryCommand.java b/src/com/connor/hs2/plm/PFMEA/library/LibraryCommand.java new file mode 100644 index 0000000..8b05e2d --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/library/LibraryCommand.java @@ -0,0 +1,295 @@ +package com.connor.hs2.plm.PFMEA.library; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Properties; + +import javax.swing.table.DefaultTableModel; + +import com.connor.hs2.plm.PFMEA.design.SqlUtilT; +import com.connor.hs2.plm.PFMEA.design.TreeBean; +import com.connor.renben.process.plm.util.CTMap; +import com.connor.renben.process.plm.util.CTable; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCSession; +public class LibraryCommand extends AbstractAIFCommand { + + private TCSession session; + private AbstractAIFApplication app; + private String commandId; + private String titleName = "PFMEA库"; + private String titleLabel = "潜在失效模式及后果分析"; + private InterfaceAIFComponent comp; + private TCComponent form; + private boolean isOwning = false; + // private List> processRowList = new + // ArrayList>(); + private TCComponentUser user;// 当前登录用户 + private List> dataList = new ArrayList>();// 表格中的数据 + private List beans = new ArrayList(); + private TreeBean bean; + private Properties pro = new Properties(); +// private String[] header = new String[] {"PLMEID","序号", +// "1. 过程项" +// + "系统、子系统、零件要素或过程名称", +// "2. 过程步骤" +// + "工位编号和关注要素名称", +// "3. 过程工作要素 4M法", +// "1.过程项的功能" +// + "系统、子系统、组件要素或过程的功能", +// "2.过程步骤的功能和产品特性" +// + "(量值为可选项)", +// "3.过程工作要素的功能和过程特性", +// "1.对上一较高级别要和/或终端用户失效影响(FE)", +// "失效影响的严重度(S)", +// "2.关注要素的失效模式(FM)", +// "3.工作要素的失效起因(FC)", +// "对失效起因的当前预防控制(PC)", +// "失效起因的频度(O)", +// "对失效起因或失效模式的当前探测控制(DC)", +// "失效起因/失效模式的可探测度(D)", +// "PFMEA措施优先级", +// "产品特性", +// "筛选器代码(可选)", +// "预防措施", +// "探测措施", +// "负责人姓名", +// "目标完成日期", +// "状态", +// "采取基于证据的措施" , +// "完成日期", +// "严重度(S)Severity(S)", +// "频度(O)Occurrence(O)", +// "可探测度(D)Detection(D)", +// "产品特性", +// "PFMEA AP ", +// "备注", "父节点ID"}; + private String[] header = new String[] {"PLMEID","问题" + , "过程名称", "过程步骤(工位编号和关注要素名称)", "过程工作要素4M", + "过程名称的功能", "过程步骤功能和产品特性", "过程工作要素的功能和过程特性", "对上一级系统失\n效影响或最终用\n户的影响(FE)", + "严重度s", "关注要素失效模式FM", "工作要素失效起因FC", "当前的对失效起因的预\n防措施", "失效模式的频度o", + "当前失效模起因/失效模式的探测措施", "探测度D", "PFMEA措施优先级", "特殊特性", "筛选器代码", "预防措施", + "探测措施", "负责人姓名", "目标完成\n日期", "状态", "采取基于证据\n的措施", "完成\n时间", "严重度", + "频度", "探测度","PFMEA措施优化AP", "特殊特性","备注","p","父节点ID"}; + + public LibraryCommand() { + super(); + } + + public LibraryCommand(AbstractAIFApplication app, + TCSession session, String commandId) { + this.session = session; + this.app = app; + this.commandId = commandId; + this.comp = app.getTargetComponent(); + this.user = session.getUser(); + } + + /** + * 获取数据库中的数据 + */ + private void getData() { + // TODO Auto-generated method stub + ResultSet rs = null; + try { + // 获取数据库连接 + SqlUtilT.getTCConnection(); + String sql = String.format(pro + .getProperty("TM2PFMEATREESELECT")); + rs = SqlUtilT.read(sql); + while (rs.next()) { + TreeBean bean = new TreeBean(); + bean.setPlmeid(rs.getString("PLMEID")); + bean.setId(rs.getString("ID")); + bean.setName(rs.getString("NAME")); + bean.setParentId(rs.getString("PARENT_ID")); + beans.add(bean); + } + + Collections.sort(beans, new NaturalOrderComparator<>(true)); + beans.forEach(item -> System.out.println(item)); + //createTabbedPane(beans); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + } + + } + + class NaturalOrderComparator implements Comparator { + + private final boolean caseInsensitive; + + public NaturalOrderComparator(boolean caseInsensitive) { + this.caseInsensitive = caseInsensitive; + } + + private int compareRight(String a, String b) { + int bias = 0; + int ia = 0; + int ib = 0; + for (; ; ia++, ib++) { + char ca = charAt(a, ia); + char cb = charAt(b, ib); + + if (!Character.isDigit(ca) && !Character.isDigit(cb)) { + return bias; + } else if (!Character.isDigit(ca)) { + return -1; + } else if (!Character.isDigit(cb)) { + return +1; + } else if (ca < cb) { + if (bias == 0) { + bias = -1; + } + } else if (ca > cb) { + if (bias == 0) { + bias = +1; + } + } else if (ca == 0 && cb == 0) { + return bias; + } + } + } + + @Override + public int compare(T o1, T o2) { + + TreeBean bean1 = (TreeBean)o1; + TreeBean bean2 = (TreeBean)o2; + + String a = bean1.getId(); + String b = bean2.getId(); + int ia = 0, ib = 0; + int nza = 0, nzb = 0; + char ca, cb; + int result; + while (true) { + nza = nzb = 0; + ca = charAt(a, ia); + cb = charAt(b, ib); + + while (ca == '0') { + nza++; + if (!Character.isDigit(charAt(a, ia + 1))) { + break; + } + ca = charAt(a, ++ia); + } + while (cb == '0') { + nzb++; + if (!Character.isDigit(charAt(b, ib + 1))) { + break; + } + cb = charAt(b, ++ib); + } + + if (Character.isDigit(ca) && Character.isDigit(cb)) { + if ((result = compareRight(a.substring(ia), b.substring(ib))) != 0) { + return result; + } + } + if (ca == 0 && cb == 0) { + return nza - nzb; + } + if (ca < cb) { + return -1; + } else if (ca > cb) { + return +1; + } + ++ia; + ++ib; + } + } + + private char charAt(String s, int i) { + if (i >= s.length()) { + return 0; + } else { + return caseInsensitive ? Character.toUpperCase(s.charAt(i)) : s.charAt(i); + } + } + } + +// // Jtable通用方法 +// public CTable getNewjTable(CTable partsTable, DefaultTableModel dtm, +// Object[] titleNames, int rows) { +// int simpleLen = 100; +// int totleLen = 1000; +// if (partsTable == null) { +// CTMap map = new CTMap(rows, titleNames.length); +// map.setColumnIdentifiers(titleNames); +// map.setEditable(true); +// partsTable = new CTable(map); +// partsTable.setRowHeight(50); +// partsTable.HiddenCell(0); +// // 隐藏列 +// partsTable.HiddenCell(titleNames.length - 1); +// partsTable.HiddenCell(titleNames.length - 2); +// // 设置显示器渲染 +// // TableCellTextAreaRenderer renderer = new +// // TableCellTextAreaRenderer(); +// // partsTable.setDefaultRenderer(Object.class, renderer); +// // partsTable.setRowHeight(1, 50); +// if (simpleLen * titleNames.length >= totleLen) { +// for (int i = 0; i < titleNames.length; i++) { +// partsTable.getColumnModel().getColumn(i) +// .setPreferredWidth(simpleLen); +// } +// partsTable.setAutoResizeMode(0); +// } else { +// partsTable.setAutoResizeMode(1); +// } +// } +// return partsTable; +// } + + @Override + public void executeModal() throws Exception { + // 获取版本表单的所有者 + InputStream input = null; + try { + // 获取SQL语句 + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + pro.load(input); + // 获取树形结构节点 + getData(); + new Thread() { + @Override + public void run() { + LibraryDialog dialog = new LibraryDialog( + app, session, commandId, form, beans, header, + isOwning, titleName, titleLabel); + } + }.start(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } finally { + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + super.executeModal(); + } + +} diff --git a/src/com/connor/hs2/plm/PFMEA/library/LibraryDialog.java b/src/com/connor/hs2/plm/PFMEA/library/LibraryDialog.java new file mode 100644 index 0000000..11907eb --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/library/LibraryDialog.java @@ -0,0 +1,2753 @@ +package com.connor.hs2.plm.PFMEA.library; + + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.awt.datatransfer.UnsupportedFlavorException; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Properties; +import java.util.ResourceBundle; +import java.util.UUID; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.JTextPane; +import javax.swing.ListSelectionModel; +import javax.swing.RowSorter; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import javax.swing.event.TableModelEvent; +import javax.swing.event.TableModelListener; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; + + +import com.connor.hs2.plm.PFMEA.design.SqlUtilT; +import com.connor.hs2.plm.PFMEA.design.TableCellTextAreaRenderer2; +import com.connor.hs2.plm.PFMEA.design.TreeBean; +import com.connor.hs2.plm.PFMEA.library.LibraryCommand.NaturalOrderComparator; +import com.connor.hs2.plm.PFMEA.library.LibraryDialog.AddRowsDialog; +import com.connor.renben.process.plm.util.CTable; +import com.connor.renben.process.plm.util.Adapter; +import com.connor.renben.process.plm.util.CTMap; +import com.connor.renben.process.plm.util.MyTableModel; +import com.connor.hs2.plm.PFMEA.design.TMomMethodUtil; +import com.connor.renben.process.plm.util.TextAreaCellEditor; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class LibraryDialog extends JFrame implements ActionListener { + +private AbstractAIFApplication app; +private TCSession session; +private String titleName; +private String title; +private String commandId; +private String[] header2 = new String[]{"PLMEID","ID","名称","名称"}; +private String[] header; +private List deleteRows = new ArrayList(); +private List beans; +private int index = -1; +private boolean isMeopSave = false; +private SpecialDialog specialDialog; +private String nodeName;// 节点名称 +private String nodeID;// 节点名称 +private int selectRow = -1; +private int selectColumn = -1; +//判断单元格显示框是否获取焦点 +private boolean isFocusOwner = false; +// 界面所需控件 +private JPanel titlePanel;// 标题 +private JLabel titleLabel; +private JTextPane selectCellValuePane; +//单行栏 +private CTable leftTable; +private CTable mainTable; + +private int rowHeightAll = 0; + +//设置frameSize +private int[] SizeLoca=new int[4]; +private int[] table1Size=new int[3]; +private int[] table2Size=new int[30]; +private int initRowHeight = 0; +private String userName=""; +private String type=""; +private boolean isFirstOpen=false;//判断是否是第一次打开,同时如果是第一次打开,当第一次保存后已向数据库插入了数据isFirstOpen会置false,再保存时就只会更新,不会重复插入 +private boolean isReSet=false; +private JScrollPane scrollPane2 ; +private JButton reSetSize;// 重置界面大小 +private JButton setRowHeightBtn;// 调整行高 +private JTextField setRowHeightTxt;// 调整行高 + +//右键菜单 +private static JPopupMenu mainMenu; +private JMenuItem addItem; +private JMenuItem addItems; +private JMenuItem remItem; +private JMenuItem comBineItem; +private JMenuItem splitItem; +private static JPopupMenu leftMenu; +private JMenuItem addNodeItem; +private JMenuItem remNodeItem; +private JMenuItem updateNodItem; +private JMenuItem shrinkColumnItem; +private JMenuItem celShrinkColumnItem; +private CTMap map; +private Map combineMap=new HashMap();// 存放合并单元格 + + + +private JPanel rootPanel;// 按钮 +private JButton saveButton;// 保存 +//private JButton addSpecialButton;// 添加特殊符号 + +List tstxList = new ArrayList(); +List dsUidList = new ArrayList(); +public LibraryDialog(AbstractAIFApplication app, + TCSession session, String commandId, TCComponent form, + List beans, String[] header, boolean isOwning, + String titleName, String title) { + super(); + this.beans = beans; + this.app = app; + this.session = session; + this.userName=this.session.getUser().toString(); + this.type="PFMEAlibraryDialog"; + this.commandId = commandId; + this.titleName = titleName; + this.title = title; + this.header = header; + TCPreferenceService service = session.getPreferenceService(); + String[] strs = service.getStringValues("ZF6_PFMEA_TSTX"); + + for(String str:strs) { + + if(str.contains(":")) { + String[] split = str.split(":"); + tstxList.add(split[0]); + dsUidList.add(split[1]); + } + + } + init(); +} + +public void getFrameSize() { + // 获取数据库连接 + SqlUtilT.getTCConnection(); + ResultSet rs = null; + ResultSet rs0 = null; + InputStream input = null; + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + try { + pro.load(input); + String sql = String.format("select * from AHMC_PFMEAFRAME_SIZE WHERE USERNAME = '%s' AND TYPE = '%s'",userName,type); + rs = SqlUtilT.read(sql); + List rowList = new ArrayList(); + while (rs.next()) { + rowList.add(rs.getString("FRAMESIZE"));//界面大小、位置 + rowList.add(rs.getString("TABLE1SIZE"));//第一个表格的列宽数据 + rowList.add(rs.getString("TABLE2SIZE"));//第二格表格的列宽数据 + rowList.add(rs.getString("ROWHEIGHT"));//第1格表格的行高数据 + break; + } + if(rowList.size()==4) {//解析界面大小,位置,表格列宽数据 + analyticSize(rowList); + }else { + String sql0 = String.format("select * from AHMC_PFMEAFRAME_SIZE WHERE USERNAME = '%s' AND TYPE = '%s'","iniUser",type); + rs0 = SqlUtilT.read(sql0); + while (rs0.next()) { + rowList.add(rs0.getString("FRAMESIZE"));//界面大小、位置 + rowList.add(rs0.getString("TABLE1SIZE"));//第一个表格的列宽数据 + rowList.add(rs0.getString("TABLE2SIZE"));//第二格表格的列宽数据 + + rowList.add(rs0.getString("ROWHEIGHT"));//第1格表格的行高数据 + break; + } + if(rowList.size()<=0) { + MessageBox.post("(数据库)未设置界面最初尺寸,请先配置!", "错误", MessageBox.ERROR); + return; + }else { + isFirstOpen=true; + analyticSize(rowList); + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if(rs0 != null) { + SqlUtilT.free(rs0); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } +} + +//解析界面数据 +public void analyticSize(List rowList) { + if(rowList.get(0).indexOf("/")>-1) {//获取界面大小位置 + String[] data=rowList.get(0).split("/"); + for(int i=0;i<4;i++) { + SizeLoca[i]=Integer.parseInt(data[i]); + } + } + if(rowList.get(1).indexOf("/")>-1) { + String[] data=rowList.get(1).split("/"); + for(int i=0;i<3;i++) { + table1Size[i]=Integer.parseInt(data[i]); + } + } + if(rowList.get(2).indexOf("/")>-1) { + String[] data=rowList.get(2).split("/"); + for(int i=0;i<30;i++) { + table2Size[i]=Integer.parseInt(data[i]); + } + } + + if(!rowList.get(3).equals("")) { + initRowHeight = Integer.valueOf(rowList.get(3)); + } + +} + + +public class AddRowsDialog extends AbstractAIFDialog implements ActionListener { + + private JPanel panel; + private JLabel label; + private JTextField textField; + private JButton button; + + private Object source; + + public AddRowsDialog(Object source) { + // TODO Auto-generated constructor stub + super(); + this.source = source; + init(); + } + + private void init() { + //获取国际化语言 + Locale defaultLocale=Locale.getDefault(); + ResourceBundle rb=ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message",defaultLocale); + // TODO Auto-generated method stub + this.panel = new JPanel(new PropertyLayout()); + this.label = new JLabel(rb.getString("crhs10_display.TITLE")); + this.textField = new JTextField(20); + this.textField.addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(KeyEvent arg0) { + if (arg0.getKeyCode() == KeyEvent.VK_ENTER) { + okEvent(); + } else { + super.keyPressed(arg0); + } + } + }); + this.button = new JButton(rb.getString("qd_display.TITLE")); + this.button.addActionListener(this); + this.panel.add("1.1.left.top", label); + this.panel.add("1.2.left.top", textField); + this.panel.add("1.3.left.top", button); + + this.add(this.panel, BorderLayout.CENTER); + this.pack(); + this.showDialog(); + } + + @Override + public void actionPerformed(ActionEvent actionevent) { + // TODO Auto-generated method stub + Object source = actionevent.getSource(); + if (source.equals(this.button)) { + okEvent(); + } + } + + private void okEvent() { + // TODO Auto-generated method stub + if (this.source.equals(addItems)) { + if (!isStr2Num(textField.getText())) { + MessageBox.post("请输入正确的数字!", "错误!", MessageBox.ERROR); + return; + } + for (int i1 = 0; i1 < Integer.parseInt(textField.getText()); i1++) { +// addRow(); + CTable table = mainTable; + if (table.getSelectedRow() > -1) { +// ((CTMap) table.getModel()).insertRow(table +// .getSelectedRow() + 1); + int selectedRow = table.getSelectedRow(); + Object valueAt = table.getValueAt(table.getSelectedRow(), + table.getColumnCount() - 1); + int selectedColumn = table.getSelectedColumn(); + if(selectedColumn>-1) + if (combineMap != null && combineMap.size() != 0) { + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + int[] key = entry.getKey(); + int[] value = entry.getValue(); + if(value[0]==selectedColumn && key[0]==selectedRow) { + selectedRow = key[key.length-1]; + } +// combine(entry.getKey(), entry.getValue()); + } + } + + combineMap = map.insertRowComb(selectedRow + 1,combineMap); + + + System.out.println("valueAt=======>"+valueAt); +// + table.setValueAt( + valueAt, + selectedRow + 1, + table.getColumnCount() - 1); + table.revalidate(); + table.repaint(); + //this.tabbedPane.updateUI(); + } + + } + this.disposeDialog(); + this.dispose(); + } + } +} + +private void init() { + getFrameSize(); + this.setTitle(this.titleName); + this.setPreferredSize(new Dimension(SizeLoca[0], SizeLoca[1])); + this.setLocation(SizeLoca[2], SizeLoca[3]); + //获取国际化语言 + Locale defaultLocale=Locale.getDefault(); + ResourceBundle rb=ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message",defaultLocale); + // 初始化标题部分控件 + this.titlePanel = new JPanel(); + this.titleLabel = new JLabel(this.title); + this.titleLabel.setFont(new Font("宋体", 1, 18)); + this.titlePanel.add(titleLabel); + + this.leftTable = getNewjTable(null, null, header2, beans.size()); + + // 隐藏列 + leftTable.HiddenCell(0); + leftTable.HiddenCell(3); + leftTable.setRowHeight(30); + //设置列宽 + leftTable.getColumnModel().getColumn(2) + .setPreferredWidth(200); + // 添加鼠标监听 + leftTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if(mouseevent.getButton() == MouseEvent.BUTTON3) + { + leftMenu.show(leftTable, mouseevent.getX(), mouseevent.getY()); + } + } + }); + for (int i = 0; i < beans.size(); i++) { + this.leftTable.setValueAt(beans.get(i).getPlmeid(), i, 0); + this.leftTable.setValueAt(beans.get(i).getId(), i, 1); + this.leftTable.setValueAt(beans.get(i).getName(), i, 2); + this.leftTable.setValueAt(beans.get(i).getParentId(), i, 3); + } + leftTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { + @Override + public void valueChanged(ListSelectionEvent arg0) { + // TODO Auto-generated method stub + System.out.println("======"+addSelected+"isMeopSave"+isMeopSave); + if(index == -1) + { + if(addSelected != -1 && isMeopSave) { + System.out.println("okEvent"); + + okEvent(true); + + addSelected = -1; + }else if(!isMeopSave){ + String list1=String.valueOf(((int)getSize().getWidth()))+"/"+String.valueOf((int)getSize().getHeight()) + +"/"+String.valueOf(((int)getLocation().getX()))+"/"+String.valueOf((((int)getLocation().getY()))); + + String list2=""; + for(int i=1;i<4;i++) { + if(i==3) { + list2+=String.valueOf(((int)scrollPane2.getWidth())); + }else { + list2+=(String.valueOf(((int)leftTable.getColumnModel().getColumn(i).getWidth()))+"/"); + } + } + String list3=""; + for(int i=1;i<31;i++) { + if(i==30) { + list3+=String.valueOf(((int)mainTable.getColumnModel().getColumn(i).getWidth())); + }else { + list3+=(String.valueOf(((int)mainTable.getColumnModel().getColumn(i).getWidth()))+"/"); + } + } + SqlUtilT.getTCConnection(); + InputStream input = null; + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + try { + pro.load(input); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + System.out.println(type+"tyye=====>"); + if(isFirstOpen) { + String insertSQL = "INSERT INTO AHMC_PFMEAFRAME_SIZE VALUES(?,?,?,?,?,?,?)"; + SqlUtilT.write(new String[] { + UUID.randomUUID().toString().replace("-", ""), + userName,type,list1,list2,list3,String.valueOf(mainTable.getRowHeight())}, insertSQL); + isFirstOpen=false; + }else if(!isReSet){ + String updateSQL = String.format( + "update AHMC_PFMEAFRAME_SIZE set FRAMESIZE = ?, TABLE1SIZE = ?, TABLE2SIZE = ?,ROWHEIGHT = ? WHERE USERNAME ='%s' AND TYPE = '%s'",userName,type); + SqlUtilT.update( + new String[] {list1,list2,list3,String.valueOf(mainTable.getRowHeight())},updateSQL); + } + SqlUtilT.freeAll(); + } + refreshPFMEATable(); + index = leftTable.getSelectedRow(); + + } + else if(index != -1 && index != leftTable.getSelectedRow()) + { + if (mainTable.getSelectedRow() >= 0 + && mainTable.getSelectedColumn() >= 0) { + (mainTable.getCellEditor(mainTable.getSelectedRow(), + mainTable.getSelectedColumn())).stopCellEditing(); + } + if(isMeopSave) + { + okEvent(true); + } + refreshPFMEATable(); + index = leftTable.getSelectedRow(); + } + } + }); + this.mainTable = getNewjTable(null, null, header, 0); +// 隐藏列 +//switch (commandId) { +//case "com.connor.renben.process.plm.commands.ControlPlanLibrary": +// mainTable.HiddenCell(0); +// mainTable.HiddenCell(header.length - 1); +// mainTable.HiddenCell(header.length - 2); +// break; +//case "com.connor.renben.process.plm.commands.PFMEALibrary": + mainTable.HiddenCell(0); + mainTable.HiddenCell(1); + mainTable.HiddenCell(header.length - 1); + mainTable.HiddenCell(header.length - 2); +// break; +//case "com.connor.renben.process.plm.commands.Thesaurus": +// mainTable.HiddenCell(0); +// mainTable.HiddenCell(header.length - 1); +// //设置列宽 +// mainTable.getColumnModel().getColumn(2) +// .setPreferredWidth(300); +// break; +//default: +// break; +//} +// 添加鼠标监听 +mainTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if (mouseevent.getClickCount() ==1) { + ((CTMap)mainTable.getModel()).setRow(mainTable.getSelectedRow()); + ((CTMap)mainTable.getModel()).setColumn(mainTable.getSelectedColumn()); + + if(isFocusOwner && selectRow != -1 && selectColumn != -1) + { + mainTable.setValueAt(selectCellValuePane.getText(), selectRow, selectColumn); + } + + if(mainTable.getValueAt(mainTable.getSelectedRow(), mainTable.getSelectedColumn()) != null) + { + selectCellValuePane.setText(""); + selectCellValuePane.setText(mainTable.getValueAt(mainTable.getSelectedRow(), mainTable.getSelectedColumn()).toString()); + } + else + { + selectCellValuePane.setText(""); + } + } + selectRow = mainTable.getSelectedRow(); + selectColumn = mainTable.getSelectedColumn(); + isFocusOwner = false; + if(mouseevent.getButton() == MouseEvent.BUTTON3) + { + mainMenu.show(mainTable, mouseevent.getX(), mouseevent.getY()); + } + } +}); + +//添加键盘监听 +this.mainTable.addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(KeyEvent arg0) { + // TODO Auto-generated method stub + + if (arg0.getKeyCode()==16) {//shift键码16,添加监听 + comBineCell(); + } + if (arg0.getKeyCode()==20) {//caps_lock键码20,添加监听 + splitCell(); + } + if (arg0.getKeyCode() == KeyEvent.VK_V) { // Copy + System.out.println("here"); + Clipboard localAIFClipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + Transferable localTransferable = localAIFClipboard.getContents(null); + // localTransferable. + String transferData; + try { + transferData = (String)localTransferable.getTransferData(DataFlavor.stringFlavor); + int selectRow=mainTable.getSelectedRow();//最初选中的行 + int selectRows=mainTable.getSelectedRowCount();//最初选中的总行数 + int selectColumn=mainTable.getSelectedColumn();//最初选中的行 + int selectColumns=mainTable.getSelectedColumnCount();//最初选中的总行数 + + + //+++根据复制内容自动增加行 + mainTable.setRowSelectionInterval(selectRow+selectRows-1, selectRow+selectRows-1);//定位到选中的最后一行 + if(transferData.indexOf("$")>-1) { + if(selectRows= 0) + { + sb.append(values[i].replace("\n", " $")); + } + else + { + sb.append(values[i]); + } + } + //System.out.println("sb++++++++"+sb.toString()); + + if(sb.indexOf("$")>-1) { + if(selectRows widMap = new HashMap< String,Integer>(); + String[] widString = transferData1.split(""+s[i]); + if(s[i].indexOf("rowspan")>0||s[i].indexOf("colspan")>0){ + //System.out.println("===>第"+i+"行:"); + String[] ss=s[i].split("0||ss[j].indexOf("colspan")>0){ + int combineRow=1; + int combineColumn=1; + if(getIndex(ss[j],"rowspan")>0){//如果有合并的行数有值则返回合并行数,如合并了两行就返回getIndex为2 + combineRow=getIndex(ss[j],"rowspan"); + // System.out.println("第"+j+"列:"); + //System.out.println("合并行数:"+getIndex(ss[j],"rowspan")); + } + if(getIndex(ss[j],"colspan")>0){ + combineColumn=getIndex(ss[j],"colspan"); + //System.out.println("合并列数:"+getIndex(ss[j],"colspan")); + } + //combineRow需要减1.因为例如当合并时2行时,combineRow为2,但是只要选中两行,所以要combineRow-1 + //当没有合并行或列时,1-1为0,相当于就只是选中一行或者一列 + String[] split = ss[j].split(" width="); + if(split.length==2) { + String[] split2 = split[1].split(" style="); +// if(spl) + Integer integer = 0; + if(widMap.containsKey(split2[0])) { + integer = widMap.get(split2[0]); + } + + mainTable.setRowSelectionInterval(selectRow+i-1, selectRow+i-1+combineRow-1); + mainTable.setColumnSelectionInterval(selectColumn-1+integer, selectColumn-1+integer+combineColumn-1); + System.out.println("rowselecttion"+(selectRow+i-1)+"end"+(selectRow+i-1+combineRow-1)); + System.out.println(integer +"column select"+(selectColumn+integer-1)+"end"+(selectColumn-1+integer+combineColumn-1)); + if(combineRow > 2) { + as = true; + } + comBineCell(); + } + + } + } +// if(as) { +// index = index+1; +// } + } + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + //最后要让选中的行和列回归初始状态以便插入数据 + mainTable.setRowSelectionInterval(selectRow, selectRow+selectRows-1); + mainTable.setColumnSelectionInterval(selectColumn, selectColumn+selectColumns-1); + } +// if(localTransferable.isDataFlavorSupported(DataFlavor.fragmentHtmlFlavor)) {//判断是否是excel的复制内容,是的话则可以打印出xml内容供解析合并信息 +// String transferData1 = (String)localTransferable.getTransferData(DataFlavor.fragmentHtmlFlavor); +// //System.out.println("打印excel属性:"+transferData1); +// String[] s=transferData1.split(""+s[i]); +// if(s[i].indexOf("rowspan")>0||s[i].indexOf("colspan")>0){ +// //System.out.println("===>第"+i+"行:"); +// String[] ss=s[i].split("0||ss[j].indexOf("colspan")>0){ +// int combineRow=1; +// int combineColumn=1; +// if(getIndex(ss[j],"rowspan")>0){//如果有合并的行数有值则返回合并行数,如合并了两行就返回getIndex为2 +// combineRow=getIndex(ss[j],"rowspan"); +// // System.out.println("第"+j+"列:"); +// //System.out.println("合并行数:"+getIndex(ss[j],"rowspan")); +// } +// if(getIndex(ss[j],"colspan")>0){ +// combineColumn=getIndex(ss[j],"colspan"); +// //System.out.println("合并列数:"+getIndex(ss[j],"colspan")); +// } +// //combineRow需要减1.因为例如当合并时2行时,combineRow为2,但是只要选中两行,所以要combineRow-1 +// //当没有合并行或列时,1-1为0,相当于就只是选中一行或者一列 +// mainTable.setRowSelectionInterval(selectRow+i-1, selectRow+i-1+combineRow-1); +// mainTable.setColumnSelectionInterval(selectColumn+j-1, selectColumn+j-1+combineColumn-1); +// +// comBineCell(); +// } +// } +// } +// } +// //最后要让选中的行和列回归初始状态以便插入数据 +// mainTable.setRowSelectionInterval(selectRow, selectRow+selectRows-1); +// mainTable.setColumnSelectionInterval(selectColumn, selectColumn+selectColumns-1); +// } + //+++ + // System.out.println(transferData); + } catch (UnsupportedFlavorException | IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + super.keyPressed(arg0); + } +}); + + + +mainTable.getModel().addTableModelListener(new TableModelListener() { + + @Override + public void tableChanged(TableModelEvent tablemodelevent) { + // TODO Auto-generated method stub + if(tablemodelevent.getType() == TableModelEvent.UPDATE){ + isMeopSave = true; + } + } +}); + +this.selectCellValuePane = new JTextPane(); +this.selectCellValuePane.addFocusListener(new FocusListener() { + //private int row; + //private int column; + @Override + public void focusLost(FocusEvent focusevent) { + // TODO Auto-generated method stub +// if(selectRow != -1 && selectColumn != -1) +// { +// mainTable.setValueAt(selectCellValuePane.getText(), selectRow, selectColumn); +// } + } + + @Override + public void focusGained(FocusEvent focusevent) { + // TODO Auto-generated method stub + isFocusOwner = true; + //this.row = mainTable.getSelectedRow(); + //this.column = mainTable.getSelectedColumn(); + } +}); +selectCellValuePane.setPreferredSize(new Dimension(700, 40)); + +Adapter adapter = new Adapter(mainTable); +JScrollPane scrollPane = new JScrollPane(mainTable); +scrollPane.getVerticalScrollBar().setUnitIncrement(2); +scrollPane2 = new JScrollPane(leftTable); +scrollPane2.setPreferredSize(new Dimension(table1Size[2], 600)); +scrollPane2.getVerticalScrollBar().setUnitIncrement(2); + +//JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); +//splitPane.setOneTouchExpandable(true);// 让分割线显示出箭头 +//splitPane.setContinuousLayout(true);// 操作箭头,重绘图形 +//splitPane.setTopComponent(new JScrollPane(selectCellValuePane)); +//splitPane.setBottomComponent(scrollPane); + +JSplitPane splitPane2 = new JSplitPane(); +splitPane2.setOneTouchExpandable(true);// 让分割线显示出箭头 +splitPane2.setContinuousLayout(true);// 操作箭头,重绘图形 +splitPane2.setLeftComponent(scrollPane2); +splitPane2.setRightComponent(scrollPane); + +this.mainMenu = new JPopupMenu(); +this.addItem = new JMenuItem(rb.getString("tjh_display.TITLE")); +this.addItems = new JMenuItem(rb.getString("tjdh_display.TITLE")); +this.remItem = new JMenuItem(rb.getString("ych12_display.TITLE")); +this.shrinkColumnItem = new JMenuItem(rb.getString("sxxzl_display.TITLE")); +this.celShrinkColumnItem = new JMenuItem(rb.getString("qxsxxzl_display.TITLE")); +this.comBineItem = new JMenuItem("合并单元格"); +this.splitItem = new JMenuItem("拆分单元格"); +this.mainMenu.add(this.addItem); +this.mainMenu.add(this.addItems); +this.mainMenu.add(this.remItem); +this.mainMenu.add(this.shrinkColumnItem); +this.mainMenu.add(this.celShrinkColumnItem); +this.mainMenu.add(this.comBineItem); +this.mainMenu.add(this.splitItem); + +this.leftMenu = new JPopupMenu(); +this.addNodeItem = new JMenuItem(rb.getString("tjjd12_display.TITLE")); +this.remNodeItem = new JMenuItem(rb.getString("ycjd12_display.TITLE")); +this.updateNodItem = new JMenuItem(rb.getString("gxjd12_display.TITLE")); +this.leftMenu.add(this.addNodeItem); +this.leftMenu.add(this.remNodeItem); +this.leftMenu.add(this.updateNodItem); + +this.rootPanel = new JPanel(new FlowLayout()); +//this.addNodeButton = new JButton("添加节点"); +//this.addButton = new JButton("添加行"); +//this.remButton = new JButton("移除行"); +//this.remNodeButton = new JButton("移除节点"); +this.saveButton = new JButton(rb.getString("bc_display.TITLE")); +this.reSetSize = new JButton("重置界面大小"); +this.setRowHeightBtn = new JButton("设置行高"); +this.setRowHeightTxt = new JTextField(); +this.setRowHeightTxt.setPreferredSize(new Dimension(160, 20)); +//this.addSpecialButton = new JButton("添加特殊符号"); +//this.rootPanel.add(addNodeButton); +//this.rootPanel.add(addButton); +//this.rootPanel.add(remButton); +//this.rootPanel.add(remNodeButton); +this.rootPanel.add(new JScrollPane(selectCellValuePane)); +this.rootPanel.add(saveButton); +this.rootPanel.add(this.reSetSize); +this.rootPanel.add(this.setRowHeightTxt); +this.rootPanel.add(this.setRowHeightBtn); +//this.rootPanel.add(addSpecialButton); + +JPanel centerPanel = new JPanel(new BorderLayout()); +centerPanel.add(titlePanel, BorderLayout.NORTH); + +// 添加鼠标监听 +this.createActionEvent(); +this.setLayout(new BorderLayout()); +this.add(centerPanel, BorderLayout.NORTH); +this.add(splitPane2, BorderLayout.CENTER); +this.add(rootPanel, BorderLayout.SOUTH); +this.pack(); +this.show(); + +} + + +//复制excel数据时检查是否有合并的行和列。"rowspan"是合并的行,"colspan"是合并的列。然后返回rowspan(colspan)=的值 + public static int getIndex(String tag1,String tag2){ + int loca=0; + if(tag1.indexOf(tag2)>0){ + int l=tag1.indexOf(tag2); + while(!tag1.substring(l,l+1).equals("=")){ + l++; + } + int start=++l; + while(!tag1.substring(l,l+1).equals(" ")){ + l++; + } + loca=Integer.valueOf(tag1.substring(start,l)); + } + return loca; + } + + + +//private void refreshTable() { +//// TODO Auto-generated method stub +////刷新右侧数据 +//ResultSet rs = null; +//InputStream input = null; +//try { +// +// SqlUtilT.getTCConnection(); +// // 获取SQL语句 +// input = new BufferedInputStream(getClass().getResourceAsStream( +// "/sql.properties")); +// Properties pro = new Properties(); +// pro.load(input); +// String sql = String.format(pro.getProperty("CONTROLPLANLIBRARYSELECT"), leftTable.getValueAt(leftTable.getSelectedRow(), 1)); +// rs = SqlUtilT.read(sql); +// List> rowList = new ArrayList>(); +// while (rs.next()) { +// List list = new ArrayList(); +// list.add(rs.getString("PLMEID")); +// list.add(rs.getString("ID")); +// list.add(rs.getString("JQSB")); +// list.add(rs.getString("SMJY")); +// list.add(rs.getString("QPTBH")); +// //list.add(rs.getString("CC")); +// //list.add(rs.getString("NO")); +// list.add(rs.getString("CP")); +// list.add(rs.getString("GC")); +// list.add(rs.getString("TSTX")); +// list.add(rs.getString("CPGC")); +// list.add(rs.getString("CLFF")); +// list.add(rs.getString("RL")); +// list.add(rs.getString("PL")); +// //list.add(rs.getString("FZR")); +// list.add(rs.getString("KZFF")); +// //list.add(rs.getString("CZGF")); +// list.add(rs.getString("FYJH")); +// //list.add(rs.getString("SJSJ")); +// //list.add(rs.getString("GCSJ")); +// //list.add(rs.getString("MJSJ")); +// list.add(rs.getString("PARENT_ID")); +// list.add(rs.getString("SPECIAL")); +// rowList.add(list); +// } +// if (rowList.size() > 0) { +// CTMap map = new CTMap(rowList.size(),header.length); +// map.setColumnIdentifiers(header); +// map.setEditable(true); +// mainTable.setModel(map); +// mainTable.getColumnModel().getColumn(2) +// .setPreferredWidth(300); +// for (int j = 0; j < rowList.size(); j++) { +// for (int k = 0; k < rowList.get(j).size(); k++) { +// mainTable.setValueAt(rowList.get(j).get(k), j, k); +// } +// } +// map.addTableModelListener(new TableModelListener() { +// +// @Override +// public void tableChanged(TableModelEvent tablemodelevent) { +// // TODO Auto-generated method stub +// if(tablemodelevent.getType() == TableModelEvent.UPDATE){ +// isMeopSave = true; +// } +// } +// }); +// } else { +// CTMap map = new CTMap(1,header.length); +// map.setColumnIdentifiers(header); +// map.setEditable(true); +// mainTable.setModel(map); +// mainTable.getColumnModel().getColumn(2) +// .setPreferredWidth(300); +// map.setValueAt(leftTable.getValueAt(leftTable.getSelectedRow(), 1), 0, +// mainTable.getColumnCount() - 2); +// map.addTableModelListener(new TableModelListener() { +// +// @Override +// public void tableChanged(TableModelEvent tablemodelevent) { +// // TODO Auto-generated method stub +// if(tablemodelevent.getType() == TableModelEvent.UPDATE){ +// isMeopSave = true; +// } +// } +// }); +// } +// mainTable.HiddenCell(0); +// mainTable.HiddenCell(header.length - 1); +// mainTable.HiddenCell(header.length - 2); +// mainTable.invalidate(); +//} catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +//} finally { +// if (rs != null) { +// SqlUtilT.free(rs); +// } +// if (input != null) { +// try { +// input.close(); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// SqlUtilT.freeAll(); +//} +//} +private int addSelected = -1; +private void refreshPFMEATable(String valueAt) { + // TODO Auto-generated method stub + //刷新右侧数据 + ResultSet rs = null; + InputStream input = null; + try { + + System.out.println("refresh22"); + SqlUtilT.getTCConnection(); + // 获取SQL语句 + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("PFMEALIBRARYSELECT"), valueAt); //leftTable.getValueAt(leftTable.getSelectedRow(), 1) + rs = SqlUtilT.read(sql); + List> rowList = new ArrayList>(); + while (rs.next()) { + List list = new ArrayList(); + list.add(rs.getString("PLMEID")); + list.add(rs.getString("ID")); + list.add(rs.getString("LSBG")); + list.add(rs.getString("STATION")); + list.add(rs.getString("REQUIREMENT")); + list.add(rs.getString("QZSXMS")); + list.add(rs.getString("QZSXHG")); + list.add(rs.getString("YZD")); + list.add(rs.getString("JB")); + list.add(rs.getString("QZSXQY")); + list.add(rs.getString("XXGCKZYF")); + list.add(rs.getString("PDS")); + list.add(rs.getString("XXGCKZTC")); + list.add(rs.getString("TCD")); + list.add(rs.getString("RPN")); + list.add(rs.getString("JYCS")); + list.add(rs.getString("ZZR")); + list.add(rs.getString("JHWCRQ")); + list.add(rs.getString("CQDCS")); + list.add(rs.getString("NEW_SEV")); + list.add(rs.getString("NEW_OCC")); + list.add(rs.getString("NEW_DET")); + list.add(rs.getString("NEW_RPN")); + list.add(rs.getString("IDEAL_STATE")); + list.add(rs.getString("SPECIAL")); + list.add(rs.getString("P1")); + list.add(rs.getString("P2")); + list.add(rs.getString("P3")); + list.add(rs.getString("P4")); + list.add(rs.getString("P5")); + list.add(rs.getString("P6")); + list.add(rs.getString("P7")); + list.add(rs.getString("P8")); + list.add(rs.getString("PARENT_ID")); + list.add(rs.getString("HBDYG")); + rowList.add(list); + } + if (rowList.size() > 0) { + map = new CTMap(rowList.size(),header.length); + map.setColumnIdentifiers(header); + map.setEditable(true); + mainTable.setModel(map); + // mainTable.getColumnModel().getColumn(2) + // .setPreferredWidth(300); + for (int j = 0; j < rowList.size(); j++) { + for (int k = 0; k < rowList.get(j).size()-1; k++) { + mainTable.setValueAt(rowList.get(j).get(k), j, k); + } + } + map.addTableModelListener(new TableModelListener() { + + @Override + public void tableChanged(TableModelEvent tablemodelevent) { + // TODO Auto-generated method stub + if(tablemodelevent.getType() == TableModelEvent.UPDATE){ + isMeopSave = true; + } + } + }); + comBine(rowList); + } else { + map = new CTMap(1,header.length); + map.setColumnIdentifiers(header); + map.setEditable(true); + mainTable.setModel(map); + mainTable.getColumnModel().getColumn(2) + .setPreferredWidth(300); + map.setValueAt(valueAt, 0 , mainTable.getColumnCount() - 1); + map.addTableModelListener(new TableModelListener() { + + @Override + public void tableChanged(TableModelEvent tablemodelevent) { + // TODO Auto-generated method stub + if(tablemodelevent.getType() == TableModelEvent.UPDATE){ + isMeopSave = true; + } + } + }); + } + getFrameSize(); + for(int i=1;i<=30;i++) { + mainTable.getColumnModel().getColumn(i).setPreferredWidth(table2Size[i-1]); + } + for(int i=1;i<=2;i++) { + leftTable.getColumnModel().getColumn(i).setPreferredWidth(table1Size[i-1]); + } + if(rowHeightAll!=0) { + mainTable.setRowHeight(rowHeightAll); + } + mainTable.HiddenCell(0); + mainTable.HiddenCell(1); + mainTable.HiddenCell(header.length - 1); + mainTable.HiddenCell(header.length - 2); + leftTable.setRowHeight(30); + mainTable.invalidate(); + mainTable.revalidate(); + mainTable.repaint(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + +private void refreshPFMEATable() { +// TODO Auto-generated method stub +//刷新右侧数据 + ResultSet rs = null; + InputStream input = null; + try { + + System.out.println("refresh11"); + SqlUtilT.getTCConnection(); + // 获取SQL语句 + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("PFMEALIBRARYSELECT"), leftTable.getValueAt(leftTable.getSelectedRow(), 1)); + rs = SqlUtilT.read(sql); + List> rowList = new ArrayList>(); + while (rs.next()) { + List list = new ArrayList(); + list.add(rs.getString("PLMEID")); + list.add(rs.getString("ID")); + list.add(rs.getString("LSBG")); + list.add(rs.getString("STATION")); + list.add(rs.getString("REQUIREMENT")); + list.add(rs.getString("QZSXMS")); + list.add(rs.getString("QZSXHG")); + list.add(rs.getString("YZD")); + list.add(rs.getString("JB")); + list.add(rs.getString("QZSXQY")); + list.add(rs.getString("XXGCKZYF")); + list.add(rs.getString("PDS")); + list.add(rs.getString("XXGCKZTC")); + list.add(rs.getString("TCD")); + list.add(rs.getString("RPN")); + list.add(rs.getString("JYCS")); + list.add(rs.getString("ZZR")); + list.add(rs.getString("JHWCRQ")); + list.add(rs.getString("CQDCS")); + list.add(rs.getString("NEW_SEV")); + list.add(rs.getString("NEW_OCC")); + list.add(rs.getString("NEW_DET")); + list.add(rs.getString("NEW_RPN")); + list.add(rs.getString("IDEAL_STATE")); + list.add(rs.getString("SPECIAL")); + list.add(rs.getString("P1")); + list.add(rs.getString("P2")); + list.add(rs.getString("P3")); + list.add(rs.getString("P4")); + list.add(rs.getString("P5")); + list.add(rs.getString("P6")); + list.add(rs.getString("P7")); + list.add(rs.getString("P8")); + list.add(rs.getString("PARENT_ID")); + list.add(rs.getString("HBDYG")); + rowList.add(list); + } + System.out.println(rowList.toString()); + if (rowList.size() > 0) { + map = new CTMap(rowList.size(),header.length); + map.setColumnIdentifiers(header); + map.setEditable(true); + mainTable.setModel(map); + // mainTable.getColumnModel().getColumn(2) + // .setPreferredWidth(300); + for (int j = 0; j < rowList.size(); j++) { + for (int k = 0; k < rowList.get(j).size()-1; k++) { + mainTable.setValueAt(rowList.get(j).get(k), j, k); + } + } + map.addTableModelListener(new TableModelListener() { + + @Override + public void tableChanged(TableModelEvent tablemodelevent) { + // TODO Auto-generated method stub + if(tablemodelevent.getType() == TableModelEvent.UPDATE){ + isMeopSave = true; + } + } + }); + comBine(rowList); + } else { + map = new CTMap(1,header.length); + map.setColumnIdentifiers(header); + map.setEditable(true); + mainTable.setModel(map); + mainTable.getColumnModel().getColumn(2) + .setPreferredWidth(300); + map.setValueAt(leftTable.getValueAt(leftTable.getSelectedRow(), 1), 0, + mainTable.getColumnCount() - 1); + map.addTableModelListener(new TableModelListener() { + + @Override + public void tableChanged(TableModelEvent tablemodelevent) { + // TODO Auto-generated method stub + if(tablemodelevent.getType() == TableModelEvent.UPDATE){ + System.out.println("isMeopSave"+isMeopSave); + isMeopSave = true; + } + } + }); + } + getFrameSize(); + for(int i=1;i<=30;i++) { + mainTable.getColumnModel().getColumn(i).setPreferredWidth(table2Size[i-1]);; + } + for(int i=1;i<=2;i++) { + leftTable.getColumnModel().getColumn(i).setPreferredWidth(table1Size[i-1]);; + } + if(rowHeightAll!=0) { + mainTable.setRowHeight(rowHeightAll); + } + mainTable.HiddenCell(0); + mainTable.HiddenCell(1); + mainTable.HiddenCell(header.length - 1); + mainTable.HiddenCell(header.length - 2); +// leftTable.setRowHeight(30); + mainTable.invalidate(); + mainTable.revalidate(); + mainTable.repaint(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } +} + +/** +* 更新左侧数据 +*/ +private void refreshLeftTable() { +// TODO Auto-generated method stub +//刷新右侧数据 +ResultSet rs = null; +InputStream input = null; +try { + + SqlUtilT.getTCConnection(); + // 获取SQL语句 + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro + .getProperty("TM2CONTROLPLANTREESELECT")); + rs = SqlUtilT.read(sql); + List bneanList = new ArrayList(); + while (rs.next()) { + TreeBean bean = new TreeBean(); + bean.setPlmeid(rs.getString("PLMEID")); + bean.setId(rs.getString("ID")); + bean.setName(rs.getString("NAME")); + bean.setParentId(rs.getString("PARENT_ID")); + bneanList.add(bean); + } + if (bneanList.size() > 0) { + CTMap map = new CTMap(bneanList.size(),header2.length); + map.setColumnIdentifiers(header2); + //map.setEditable(true); + leftTable.setModel(map); + leftTable.getColumnModel().getColumn(2) + .setPreferredWidth(200); + for (int i = 0; i < bneanList.size(); i++) { + this.leftTable.setValueAt(bneanList.get(i).getPlmeid(), i, 0); + this.leftTable.setValueAt(bneanList.get(i).getId(), i, 1); + this.leftTable.setValueAt(bneanList.get(i).getName(), i, 2); + this.leftTable.setValueAt(bneanList.get(i).getParentId(), i, 3); + } + } + leftTable.HiddenCell(0); + leftTable.HiddenCell(3); + leftTable.invalidate(); +} catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); +} finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); +} +} + +/** +* 更新左侧数据 +*/ +private void refreshPFMEALeftTable() { +// TODO Auto-generated method stub +//刷新右侧数据 +ResultSet rs = null; +InputStream input = null; +try { + + SqlUtilT.getTCConnection(); + // 获取SQL语句 + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro + .getProperty("TM2PFMEATREESELECT")); + rs = SqlUtilT.read(sql); + List bneanList = new ArrayList(); + while (rs.next()) { + TreeBean bean = new TreeBean(); + bean.setPlmeid(rs.getString("PLMEID")); + bean.setId(rs.getString("ID")); + bean.setName(rs.getString("NAME")); + bean.setParentId(rs.getString("PARENT_ID")); + bneanList.add(bean); + } + + + Collections.sort(bneanList, new NaturalOrderComparator<>(true)); + bneanList.forEach(item -> System.out.println(item)); + if (bneanList.size() > 0) { + CTMap map = new CTMap(bneanList.size(),header2.length); + map.setColumnIdentifiers(header2); + //map.setEditable(true); + leftTable.setModel(map); + leftTable.getColumnModel().getColumn(2) + .setPreferredWidth(200); + for (int i = 0; i < bneanList.size(); i++) { + this.leftTable.setValueAt(bneanList.get(i).getPlmeid(), i, 0); + this.leftTable.setValueAt(bneanList.get(i).getId(), i, 1); + this.leftTable.setValueAt(bneanList.get(i).getName(), i, 2); + this.leftTable.setValueAt(bneanList.get(i).getParentId(), i, 3); + } + } + leftTable.HiddenCell(0); + leftTable.HiddenCell(3); + leftTable.invalidate(); + leftTable.revalidate(); +} catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); +} finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); +} +} + +class NaturalOrderComparator implements Comparator { + + private final boolean caseInsensitive; + + public NaturalOrderComparator(boolean caseInsensitive) { + this.caseInsensitive = caseInsensitive; + } + + private int compareRight(String a, String b) { + int bias = 0; + int ia = 0; + int ib = 0; + for (; ; ia++, ib++) { + char ca = charAt(a, ia); + char cb = charAt(b, ib); + + if (!Character.isDigit(ca) && !Character.isDigit(cb)) { + return bias; + } else if (!Character.isDigit(ca)) { + return -1; + } else if (!Character.isDigit(cb)) { + return +1; + } else if (ca < cb) { + if (bias == 0) { + bias = -1; + } + } else if (ca > cb) { + if (bias == 0) { + bias = +1; + } + } else if (ca == 0 && cb == 0) { + return bias; + } + } + } + + @Override + public int compare(T o1, T o2) { + + TreeBean bean1 = (TreeBean)o1; + TreeBean bean2 = (TreeBean)o2; + + String a = bean1.getId(); + String b = bean2.getId(); + int ia = 0, ib = 0; + int nza = 0, nzb = 0; + char ca, cb; + int result; + while (true) { + nza = nzb = 0; + ca = charAt(a, ia); + cb = charAt(b, ib); + + while (ca == '0') { + nza++; + if (!Character.isDigit(charAt(a, ia + 1))) { + break; + } + ca = charAt(a, ++ia); + } + while (cb == '0') { + nzb++; + if (!Character.isDigit(charAt(b, ib + 1))) { + break; + } + cb = charAt(b, ++ib); + } + + if (Character.isDigit(ca) && Character.isDigit(cb)) { + if ((result = compareRight(a.substring(ia), b.substring(ib))) != 0) { + return result; + } + } + if (ca == 0 && cb == 0) { + return nza - nzb; + } + if (ca < cb) { + return -1; + } else if (ca > cb) { + return +1; + } + ++ia; + ++ib; + } + } + + private char charAt(String s, int i) { + if (i >= s.length()) { + return 0; + } else { + return caseInsensitive ? Character.toUpperCase(s.charAt(i)) : s.charAt(i); + } + } +} + + +private void refreshThesaurusLeftTable() { +// TODO Auto-generated method stub +//刷新右侧数据 +ResultSet rs = null; +InputStream input = null; +try { + + SqlUtilT.getTCConnection(); + // 获取SQL语句 + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro + .getProperty("TM2THESAURUSTREESELECT")); + rs = SqlUtilT.read(sql); + List bneanList = new ArrayList(); + while (rs.next()) { + TreeBean bean = new TreeBean(); + bean.setPlmeid(rs.getString("PLMEID")); + bean.setId(rs.getString("ID")); + bean.setName(rs.getString("NAME")); + bean.setParentId(rs.getString("PARENT_ID")); + bneanList.add(bean); + } + if (bneanList.size() > 0) { + CTMap map = new CTMap(bneanList.size(),header2.length); + map.setColumnIdentifiers(header2); + //map.setEditable(true); + leftTable.setModel(map); + leftTable.getColumnModel().getColumn(2) + .setPreferredWidth(200); + for (int i = 0; i < bneanList.size(); i++) { + this.leftTable.setValueAt(bneanList.get(i).getPlmeid(), i, 0); + this.leftTable.setValueAt(bneanList.get(i).getId(), i, 1); + this.leftTable.setValueAt(bneanList.get(i).getName(), i, 2); + this.leftTable.setValueAt(bneanList.get(i).getParentId(), i, 3); + } + } + leftTable.HiddenCell(0); + leftTable.HiddenCell(3); + leftTable.invalidate(); +} catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); +} finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); +} +} + +private void refreshThesaurusTable() { +// TODO Auto-generated method stub +//刷新右侧数据 +ResultSet rs = null; +InputStream input = null; +try { + + SqlUtilT.getTCConnection(); + // 获取SQL语句 + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("TM2THESAURUSNODESELECT"), leftTable.getValueAt(leftTable.getSelectedRow(), 1)); + rs = SqlUtilT.read(sql); + List> rowList = new ArrayList>(); + while (rs.next()) { + List list = new ArrayList(); + list.add(rs.getString("PLMEID")); + list.add(rs.getString("ID")); + list.add(rs.getString("VALUE")); + //list.add(rs.getString("VALUE2")); + //list.add(rs.getString("EXAMPLE")); + list.add(rs.getString("PARENT_ID")); + rowList.add(list); + } + if (rowList.size() > 0) { + CTMap map = new CTMap(rowList.size(),header.length); + map.setColumnIdentifiers(header); + map.setEditable(true); + mainTable.setModel(map); + mainTable.getColumnModel().getColumn(2) + .setPreferredWidth(300); + for (int j = 0; j < rowList.size(); j++) { + for (int k = 0; k < rowList.get(j).size(); k++) { + if(k == rowList.get(j).size()-2){ + mainTable.setValueAt(rowList.get(j).get(k+1), j, k+1); + } + else if(k == rowList.get(j).size()-1){ + mainTable.setValueAt(rowList.get(j).get(k-1), j, k-1); + } + else{ + mainTable.setValueAt(rowList.get(j).get(k), j, k); + } + } + } + map.addTableModelListener(new TableModelListener() { + @Override + public void tableChanged(TableModelEvent tablemodelevent) { + // TODO Auto-generated method stub + if(tablemodelevent.getType() == TableModelEvent.UPDATE){ + isMeopSave = true; + } + } + }); + } else { + CTMap map = new CTMap(20,header.length); + map.setColumnIdentifiers(header); + map.setEditable(true); + mainTable.setModel(map); + mainTable.getColumnModel().getColumn(2) + .setPreferredWidth(300); + map.setValueAt(leftTable.getValueAt(leftTable.getSelectedRow(), 1), 0, + mainTable.getColumnCount() - 1); + map.addTableModelListener(new TableModelListener() { + + @Override + public void tableChanged(TableModelEvent tablemodelevent) { + // TODO Auto-generated method stub + if(tablemodelevent.getType() == TableModelEvent.UPDATE){ + isMeopSave = true; + } + } + }); + } + mainTable.HiddenCell(0); + mainTable.HiddenCell(header.length - 1); + leftTable.setRowHeight(30); + mainTable.invalidate(); +} catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); +} finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); +} +} +// 添加监听 +public void createActionEvent() { +this.addItem.addActionListener(this); +this.addItems.addActionListener(this); +this.addNodeItem.addActionListener(this); +this.updateNodItem.addActionListener(this); +this.shrinkColumnItem.addActionListener(this); +this.celShrinkColumnItem.addActionListener(this); +this.remItem.addActionListener(this); +this.remNodeItem.addActionListener(this); +this.saveButton.addActionListener(this); +this.comBineItem.addActionListener(this); +this.splitItem.addActionListener(this); +this.reSetSize.addActionListener(this); +this.setRowHeightBtn.addActionListener(this); +//this.addSpecialButton.addActionListener(this); +} + + +//加载合并单元格 +public void comBine(List> rowList) { + combineMap.clear(); + if (rowList != null && rowList.size() > 0) { + for (int i = 0; i < rowList.size(); i++) { + if (rowList.get(i).get(34)!= null + && !rowList.get(i).get(34).equals("")) { + String sombine = rowList.get(i).get(34).toString(); + int rowDif = 0; + String[] sombines; + if (sombine.indexOf("-") >= 0) { + sombines = sombine.split("-"); + } else { + sombines = new String[] { sombine }; + } + for (int j = 0; j < sombines.length; j++) { + if (sombines[j].indexOf("/") >= 0) { + int[] row; + int[] cloumn; + String[] cells = sombines[j].split("/"); + if (cells[0].indexOf(",") >= 0) { + String[] rows = cells[0].split(","); + row = new int[rows.length]; + for (int k = 0; k < rows.length; k++) { + row[k] = Integer.parseInt(rows[k]) + + rowDif; + } + } else { + row = new int[] { Integer + .parseInt(cells[0]) + rowDif }; + } + if (cells[1].indexOf(",") >= 0) { + String[] cloumns = cells[1].split(","); + cloumn = new int[cloumns.length]; + for (int k = 0; k < cloumns.length; k++) { + cloumn[k] = Integer + .parseInt(cloumns[k]); + } + } else { + cloumn = new int[] { Integer + .parseInt(cells[1]) }; + } + this.combineMap.put(row, cloumn); + } + } + } + } + } + // TODO Auto-generated method stub + if (combineMap != null && combineMap.size() != 0) { + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + try { + map.combine(entry.getKey(), entry.getValue()); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + } + } +} + +String selectId; +/** + * 合并单元格 + */ +private void comBineCell() { + isMeopSave=true; + // TODO Auto-generated method stub + // table.setRowHeight(2, 50); + int[] rows = mainTable.getSelectedRows(); + int[] columns = mainTable.getSelectedColumns(); + if (rows.length <= 0) { + MessageBox.post("请选择要合并的单元格!", "错误", MessageBox.ERROR); + return; + } +// for (int i = 0; i < rows.length; i++) { +// if (this.processRows != null && this.processRows.size() > 0 && !(this.processRows.contains(rows[i]))) { +// MessageBox.post("无权限合并单元格", "错误", MessageBox.ERROR); +// return; +// } +// } + if (combineMap != null && combineMap.size() != 0) { + for (int i = 0; i < rows.length; i++) { + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + List keysList = new ArrayList<>(); + for (int j = 0; j < entry.getKey().length; j++) { + keysList.add(entry.getKey()[j]); + } + if (keysList.contains(rows[i])) { + for (int j = 0; j < columns.length; j++) { + List valueList = new ArrayList<>(); + for (int k = 0; k < entry.getValue().length; k++) { + valueList.add(entry.getValue()[k]); + } + if (valueList.contains(columns[j])) { + columns = Union(columns, entry.getValue()); + rows = Union(rows, entry.getKey()); + if (combineMap.get(entry.getKey()) != null) { + it.remove(); + } + } + } + } + } + } + combineMap.put(rows, columns); + } else { + combineMap.put(rows, columns); + } + for (int i = 0; i < rows.length; i++) { + for (int j = 0; j < columns.length; j++) { + map.split(rows[i], columns[j]); + } + } + Arrays.sort(rows); + Arrays.sort(columns); + map.combine(rows, columns); + // map.removeRow(table.getSelectedRow()); + mainTable.revalidate(); + mainTable.repaint(); +} + + +/** + * 拆分单元格 + */ +private void splitCell() { + isMeopSave=true; + // TODO Auto-generated method stub + int row = mainTable.getSelectedRow(); + int colmn = mainTable.getSelectedColumn(); + if (row < 0) { + MessageBox.post("请选择要拆分的单元格!", "错误", MessageBox.ERROR); + return; + } +// if (this.processRows != null && this.processRows.size() > 0 +// && !(this.processRows.contains(row))) { +// MessageBox.post("无权限拆分单元格!", "错误", MessageBox.ERROR); +// return; +// } + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + List keysList = new ArrayList<>(); + List valuesList = new ArrayList<>(); + for (int j = 0; j < entry.getKey().length; j++) { + keysList.add(entry.getKey()[j]); + } + for (int j = 0; j < entry.getValue().length; j++) { + valuesList.add(entry.getValue()[j]); + } + if (keysList.contains(row) && valuesList.contains(colmn)) { + for (int i = 0; i < entry.getKey().length; i++) { + for (int j = 0; j < entry.getValue().length; j++) { + map.split(entry.getKey()[i], entry.getValue()[j]); + } + } + it.remove(); + } + } + + mainTable.revalidate(); + mainTable.repaint(); +} + + + + + + +// Jtable通用方法 +public CTable getNewjTable(CTable partsTable, DefaultTableModel dtm, + Object[] titleNames, int rows) { +int simpleLen = 100; +int totleLen = 100; +if (partsTable == null) { + + if(rows==0) { + map = new CTMap(rows+1, titleNames.length); + }else { + map = new CTMap(rows, titleNames.length); + } + + //CTMap map = new CTMap(rows, titleNames.length); + map.setColumnIdentifiers(titleNames); + map.setEditable(false); + partsTable = new CTable(map,true,tstxList); + + if(initRowHeight==0) { + partsTable.setRowHeight(50); + }else { + partsTable.setRowHeight(initRowHeight); + } + + //partsTable.HiddenCell(0); + // 隐藏列 + //partsTable.HiddenCell(titleNames.length - 1); + // partsTable.HiddenCell(titleNames.length-2); + // partsTable.setRowHeight(1, 50); + TableCellTextAreaRenderer2 renderer = new TableCellTextAreaRenderer2(); + partsTable.setDefaultRenderer(Object.class, renderer); + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i) + .setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } +} +return partsTable; +} + +@Override +public void actionPerformed(ActionEvent arg0) { +Object source = arg0.getSource(); +if (source.equals(this.addItem)) { +// Component component = tabbedPane.getSelectedComponent(); +// if (component instanceof JScrollPane) { +// JScrollPane scrollPane = (JScrollPane) component; +// Component tableComponent = scrollPane.getViewport().getView(); +// if (tableComponent instanceof CTable) { + CTable table = this.mainTable; + if (table.getSelectedRow() > -1) { +// ((CTMap) table.getModel()).insertRow(table +// .getSelectedRow() + 1); + int selectedRow = table.getSelectedRow(); + Object valueAt = table.getValueAt(table.getSelectedRow(), + table.getColumnCount() - 1); + int selectedColumn = table.getSelectedColumn(); + if(selectedColumn>-1) + if (combineMap != null && combineMap.size() != 0) { + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + int[] key = entry.getKey(); + int[] value = entry.getValue(); + if(value[0]==selectedColumn && key[0]==selectedRow) { + selectedRow = key[key.length-1]; + } +// combine(entry.getKey(), entry.getValue()); + } + } + + combineMap = map.insertRowComb(selectedRow + 1,combineMap); + + + System.out.println("valueAt=======>"+valueAt); +// + table.setValueAt( + valueAt, + selectedRow + 1, + table.getColumnCount() - 1); + table.revalidate(); + table.repaint(); + //this.tabbedPane.updateUI(); + } +// } +// } +}else if (source.equals(this.addItems)) { +// Component component = tabbedPane.getSelectedComponent(); +// if (component instanceof JScrollPane) { +// JScrollPane scrollPane = (JScrollPane) component; +// Component tableComponent = scrollPane.getViewport().getView(); +// if (tableComponent instanceof CTable) { + + AddRowsDialog dialog = new AddRowsDialog(source); + +// } +// } +} +else if (source.equals(this.addNodeItem)) { + //获取国际化语言 + Locale defaultLocale=Locale.getDefault(); + ResourceBundle rb=ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message",defaultLocale); + + final JFrame frame = new JFrame(); + frame.setLocationRelativeTo(this); + frame.setSize(new Dimension(400, 200)); + JLabel label = new JLabel(rb.getString("jdmc12_display.TITLE")); + final JTextField field = new JTextField(20); + JLabel idlabel = new JLabel(rb.getString("jdID12_display.TITLE")); + final JTextField idfield = new JTextField(20); + JButton okButton = new JButton(rb.getString("qd_display.TITLE")); + okButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + nodeName = field.getText(); + nodeID = idfield.getText(); + // node.add(new DefaultMutableTreeNode("烧结")); + String selectSql = ""; + String insterSql = ""; + insterSql = "insert into AHMC_PFMEA_TREE values(?,?,?,?)"; +// } + //String id = ""; + try { + UUID uid = UUID.randomUUID(); + TreeBean bean = new TreeBean(); + bean.setPlmeid(uid.toString().replace("-", "")); + bean.setId(nodeID); + bean.setName(nodeName); + bean.setParentId(""); + // tabbedPane.add(nodeName, new JScrollPane(table)); + // 获取数据库连接 + SqlUtilT.getTCConnection(); + SqlUtilT.write( + new String[] { uid.toString().replace("-", ""), + nodeID, nodeName, "" }, + insterSql); + refreshPFMEALeftTable(); + frame.dispose(); + int rowCount = leftTable.getRowCount(); + for(int t=0;t= 0 +// && table.getSelectedColumn() > 0) { +// (table.getCellEditor(table.getSelectedRow(), +// table.getSelectedColumn())).stopCellEditing(); +// if (((CTMap) table.getModel()).getValueAt( +// table.getSelectedRow(), 0) != null) { +// deleteRows.add(((CTMap) table.getModel()) +// .getValueAt(table.getSelectedRow(), 0) +// .toString()); +// } +//// ((CTMap) table.getModel()).removeRow(table +//// .getSelectedRow()); +// map.removeRow(table.getSelectedRow()); +// table.revalidate(); +// table.repaint(); +// } +// } +// } +} else if (source.equals(this.remNodeItem)) { +// Component component = tabbedPane.getSelectedComponent(); +// if (component instanceof JScrollPane) { +// JScrollPane scrollPane = (JScrollPane) component; +// Component tableComponent = scrollPane.getViewport().getView(); +// if (tableComponent instanceof CTable) { + CTable table = this.mainTable; + String deleteNodeSql = ""; + String deleteTreeSql = ""; +// switch (commandId) { +// case "com.connor.renben.process.plm.commands.ControlPlanLibrary": +// deleteTreeSql = String +// .format("delete from RB3_CONTROLPLAN_TREE where PLMEID = \'%s\'", +// leftTable.getValueAt(leftTable.getSelectedRow(), 0).toString()); +// deleteNodeSql = String +// .format("delete from RB3_CONTROLPLAN_NODE where PARENT_ID = \'%s\'", +// leftTable.getValueAt(leftTable.getSelectedRow(), 1).toString()); +// break; +// case "com.connor.renben.process.plm.commands.PFMEALibrary": + Object nameVal = leftTable.getValueAt(leftTable.getSelectedRow(), 0); + String nameString = ""; + if(nameVal!=null) { + nameString = nameVal.toString(); + } + + deleteTreeSql = String + .format("delete from AHMC_PFMEA_TREE where PLMEID = \'%s\'", + nameString==null?"":nameString); + Object valueAt = leftTable.getValueAt(leftTable.getSelectedRow(), 1); + String idString = ""; + if(valueAt!=null) { + idString = valueAt.toString(); + } + + deleteNodeSql = String + .format("delete from AHMC_PFMEA_NODE where PARENT_ID = \'%s\'", + idString==null?"":idString); +// break; +// case "com.connor.renben.process.plm.commands.Thesaurus": +// deleteTreeSql = String +// .format("delete from RB3_THESAURUS_TREE where PLMEID = \'%s\'", +// leftTable.getValueAt(leftTable.getSelectedRow(), 0).toString()); +// deleteNodeSql = String +// .format("delete from RB3_THESAURUS_NODE where PARENT_ID = \'%s\'", +// leftTable.getValueAt(leftTable.getSelectedRow(), 1).toString()); +// break; +// default: +// break; +// } + SqlUtilT.getTCConnection(); + SqlUtilT.delete(deleteTreeSql); + SqlUtilT.freeAll(); + SqlUtilT.getTCConnection(); + SqlUtilT.delete(deleteNodeSql); + SqlUtilT.freeAll(); +// switch (commandId) { +// case "com.connor.renben.process.plm.commands.ControlPlanLibrary": +// refreshLeftTable(); +// break; +// case "com.connor.renben.process.plm.commands.PFMEALibrary": + refreshPFMEALeftTable(); +// break; +// case "com.connor.renben.process.plm.commands.Thesaurus": +// refreshThesaurusLeftTable(); +// break; +// default: +// break; +// } + //this.tabbedPane.remove(scrollPane); + //this.tabbedPane.updateUI(); +// } +// } +} else if (source.equals(this.saveButton)) { + okEvent(true); + //this.disposeDialog(); + +// this.dispose(); +} +else if (source.equals(shrinkColumnItem)) { + for (int i = 0; i < mainTable.getSelectedColumns().length; i++) { + mainTable.getColumnModel().getColumn(mainTable.getSelectedColumns()[i]).setPreferredWidth(5); + } + mainTable.revalidate(); + mainTable.repaint(); +} +else if (source.equals(celShrinkColumnItem)) { + for (int i = 0; i < mainTable.getSelectedColumns().length; i++) { + mainTable.getColumnModel().getColumn(mainTable.getSelectedColumns()[i]).setPreferredWidth(100); + } + mainTable.revalidate(); + mainTable.repaint(); +}else if(source.equals(splitItem)) { + splitCell(); +}else if(source.equals(comBineItem) ){ + comBineCell(); +} +else if(source.equals(this.reSetSize)){ + int i=JOptionPane.showConfirmDialog(null, "是否重置界面大小,点击“是”将在下次打开界面时生效!", "重置", JOptionPane.YES_NO_OPTION); + if(i==JOptionPane.YES_OPTION){ + SqlUtilT.getTCConnection(); + InputStream input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + try { + pro.load(input); + String deleteSQL = String.format( + "DELETE FROM AHMC_PFMEAFRAME_SIZE WHERE USERNAME = '%s' AND TYPE = '%s'",userName,type); + SqlUtilT.delete(deleteSQL); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + isReSet=true; + SqlUtilT.freeAll(); + } +} +else if (source.equals(setRowHeightBtn)) { + if (!this.setRowHeightTxt.getText().equals("")) { + String text = setRowHeightTxt.getText(); + + Integer valueOf = Integer.valueOf(text); + if(valueOf>10 || valueOf<1) { + MessageBox.post("调整行高建议在1-10倍之间","提示",2); + } + + mainTable.setRowHeight(valueOf*40); + rowHeightAll = valueOf*40; + } else { + + } +} +else { + //this.disposeDialog(); + this.dispose(); + // this.setVisible(false); +} +} + + +private void remRow(CTable table) { + // TODO Auto-generated method stub +// if (this.tabbedPane.getSelectedIndex() == 1) { +// if (table2.getSelectedRow() > 0 && table2.getSelectedColumn() > 0) { +// (table2.getCellEditor(table2.getSelectedRow(), table2.getSelectedColumn())).stopCellEditing(); +// } +// int[] rows = table2.getSelectedRows(); +// CTMap map = ((CTMap) this.table2.getModel()); +// for (int i = 0; i < rows.length; i++) { +// map.removeRow(table2.getSelectedRow()); +// } +// } else { + if (table.getSelectedRow() > 0 && table.getSelectedColumn() > 0) { + (table.getCellEditor(table.getSelectedRow(), table.getSelectedColumn())).stopCellEditing(); + } + int[] rows = table.getSelectedRows(); + for (int i1 = 0; i1 < rows.length; i1++) { +// if (this.processRows != null && this.processRows.size() > 0 +// && !(this.processRows.contains(table.getSelectedRow()))) { +// MessageBox.post("无权限删除行!", "错误", MessageBox.ERROR); +// return; +// } + Map cellMap = new HashMap(); + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + List keysList = new ArrayList<>(); + for (int j = 0; j < entry.getKey().length; j++) { + keysList.add(entry.getKey()[j]); + } + if (keysList.contains(table.getSelectedRow())) { + int[] newKey = new int[entry.getKey().length - 1]; + for (int i = 0; i < entry.getKey().length; i++) { + for (int j = 0; j < entry.getValue().length; j++) { + map.split(entry.getKey()[i], entry.getValue()[j]); + } + if (i < newKey.length) { + newKey[i] = entry.getKey()[i]; + } + } + it.remove(); + cellMap.put(newKey, entry.getValue()); + } else if (!keysList.contains(table.getSelectedRow()) + && Integer.parseInt(keysList.get(0).toString()) > table.getSelectedRow()) { + int[] newKey = new int[entry.getKey().length]; + for (int i = 0; i < entry.getKey().length; i++) { + for (int j = 0; j < entry.getValue().length; j++) { + map.split(entry.getKey()[i], entry.getValue()[j]); + } + newKey[i] = entry.getKey()[i] - 1; + } + it.remove(); + cellMap.put(newKey, entry.getValue()); + } + } + if (map.getValueAt(table.getSelectedRow(), 0) != null) { + deleteRows.add(map.getValueAt(table.getSelectedRow(), 0).toString()); + } + map.removeRow(table.getSelectedRow()); + // this.processRows = map.getProcessRowList(); + Iterator> cellIt = cellMap.entrySet().iterator(); + while (cellIt.hasNext()) { + Map.Entry entry = cellIt.next(); + if (entry.getKey().length > 0 && entry.getValue().length > 0) { + map.combine(entry.getKey(), entry.getValue()); + combineMap.put(entry.getKey(), entry.getValue()); + } + } + table.revalidate(); + table.repaint(); + } +// } +} + +private void okEvent(boolean isSave) { + //获取屏幕尺寸和位置+++++ + String list1=String.valueOf(((int)this.getSize().getWidth()))+"/"+String.valueOf((int)this.getSize().getHeight()) + +"/"+String.valueOf(((int)this.getLocation().getX()))+"/"+String.valueOf((((int)this.getLocation().getY()))); + + String list2=""; + for(int i=1;i<4;i++) { + if(i==3) { + list2+=String.valueOf(((int)scrollPane2.getWidth())); + }else { + list2+=(String.valueOf(((int)this.leftTable.getColumnModel().getColumn(i).getWidth()))+"/"); + } + } + String list3=""; + for(int i=1;i<31;i++) { + if(i==30) { + list3+=String.valueOf(((int)this.mainTable.getColumnModel().getColumn(i).getWidth())); + }else { + list3+=(String.valueOf(((int)this.mainTable.getColumnModel().getColumn(i).getWidth()))+"/"); + } + } + SqlUtilT.getTCConnection(); + InputStream input = null; + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + try { + pro.load(input); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + if(isFirstOpen) { + String insertSQL = "INSERT INTO AHMC_PFMEAFRAME_SIZE VALUES(?,?,?,?,?,?,?)"; + SqlUtilT.write(new String[] { + UUID.randomUUID().toString().replace("-", ""), + this.userName,this.type,list1,list2,list3,String.valueOf(mainTable.getRowHeight())}, insertSQL); + isFirstOpen=false; + }else if(!isReSet){ + String updateSQL = String.format( + "update AHMC_PFMEAFRAME_SIZE set FRAMESIZE = ?, TABLE1SIZE = ?, TABLE2SIZE = ?,ROWHEIGHT = ? WHERE USERNAME ='%s' AND TYPE = '%s'",userName,type); + SqlUtilT.update( + new String[] {list1,list2,list3,String.valueOf(mainTable.getRowHeight())},updateSQL); + } + SqlUtilT.freeAll(); + ///++++++ + + + + isMeopSave = false; + // TODO Auto-generated method stub + // 将数据保存到表单中 + try { + // 获取JTable中的数据 + List> dataValeList = getTableValue(); + System.out.println(dataValeList.size()+"dataValeList ======>"); + this.rootPanel.setBackground(Color.GREEN); + new Thread() { + @Override + public void run() { + try { + + ResultSet rs = null; + InputStream input = null; + try { + // 获取SQL语句 + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + // 删除行 + for (int i = 0; i < deleteRows.size(); i++) { + // 获取数据库连接 + SqlUtilT.getTCConnection(); + String deleteSQL = String.format( + pro.getProperty("PFMEALIBRARYDELETE"), + deleteRows.get(i)); + SqlUtilT.delete(deleteSQL); + SqlUtilT.freeAll(); + } + // 查询工序编号和ID + // 往数据库中写入数据 + + for (int i = 0; i < dataValeList.size(); i++) { + // 获取数据库连接 + SqlUtilT.getTCConnection(); + List rowList = dataValeList.get(i); + if (rowList.get(0) != null && !rowList.get(0).equals("")) { + // 获取数据库连接 + String updateSQL = String.format( + pro.getProperty("PFMEALIBRARYUPDATE"), + rowList.get(0)); + SqlUtilT.update( + new String[] { + rowList.get(1),rowList.get(2),rowList.get(3), + rowList.get(4),rowList.get(5), rowList.get(6), + rowList.get(7),rowList.get(8),rowList.get(9), + rowList.get(10),rowList.get(11), rowList.get(12), + rowList.get(13),rowList.get(14),rowList.get(15), + rowList.get(16),rowList.get(17), rowList.get(18), + rowList.get(19),rowList.get(20),rowList.get(21), + rowList.get(22),rowList.get(23),rowList.get(24), + rowList.get(25),rowList.get(26),rowList.get(27), + rowList.get(28),rowList.get(29),rowList.get(30), + rowList.get(31),rowList.get(32),rowList.get(34),rowList.get(35)}, + updateSQL); + } else { + + String insertSQL = pro.getProperty("PFMEALIBRARYINSERT"); + SqlUtilT.write(new String[] { + UUID.randomUUID().toString().replace("-", ""), + rowList.get(3),rowList.get(4), + rowList.get(5), rowList.get(6),rowList.get(7), + rowList.get(8), rowList.get(9),rowList.get(10), + rowList.get(11), rowList.get(12),rowList.get(13), + rowList.get(14), rowList.get(15),rowList.get(16), + rowList.get(17), rowList.get(18),rowList.get(19), + rowList.get(20), rowList.get(21),rowList.get(22), + rowList.get(23) ,rowList.get(33) ,rowList.get(24),rowList.get(1), + rowList.get(25),rowList.get(26),rowList.get(27),rowList.get(28),rowList.get(29), + rowList.get(30),rowList.get(31),rowList.get(32),rowList.get(34), rowList.get(2),rowList.get(35)}, + insertSQL); + } + SqlUtilT.freeAll(); + } + if(leftTable.getSelectedRow()>-1) { + System.out.println(leftTable.getSelectedRow()+"leftTable.getSelectedRow()"); + refreshPFMEATable(); + }else if(selectId!=null && !selectId.equals("")){ + System.out.println("selectId == >"+selectId); + refreshPFMEATable(selectId); + } + //MessageBox.post("保存成功!", "成功", MessageBox.WARNING); + } catch (Exception e) { + MessageBox.post(e.toString(), "错误", MessageBox.ERROR); + e.printStackTrace(); +// throw e; + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + + + this.sleep(1000); + rootPanel.setBackground(Color.WHITE); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + }.start(); + } catch (Exception e) { + // TODO Auto-generated catch block + this.rootPanel.setBackground(Color.RED); + MessageBox.post(e.toString(), "错误", MessageBox.ERROR); + e.printStackTrace(); + } +} + +private List> getTableValue() { +// TODO Auto-generated method stub +List> dataList = new ArrayList>(); +//Component[] components = tabbedPane.getComponents(); +//for (int i = 0; i < components.length; i++) { +// if (components[i] instanceof JScrollPane) { +// JScrollPane scrollPane = (JScrollPane) components[i]; +// Component tableComponent = scrollPane.getViewport().getView(); +// if (tableComponent instanceof CTable) { + CTable table = this.mainTable; + //移除焦点 + if (table.getSelectedRow() >= 0 && table.getSelectedColumn() >= 0) { + (table.getCellEditor(table.getSelectedRow(), + table.getSelectedColumn())).stopCellEditing(); + } + System.out.println("table.getRowCount() ====>"+table.getRowCount()); + for (int j = 0; j < table.getRowCount(); j++) { + List rowValue = new ArrayList(); + for (int j2 = 0; j2 < table.getColumnCount(); j2++) { + if(j2 == 1) + { + if(table.getValueAt(j, j2) != null )//isStr2Num(table.getValueAt(j, j2).toString()) + { + rowValue.add(table.getValueAt(j, j2).toString()); + + } + else + { + rowValue.add(""); + } + + + } + else + { + rowValue.add(table.getValueAt(j, j2) == null ? "" + : table.getValueAt(j, j2).toString()); + } + } + rowValue.add(TMomMethodUtil.getCombineCell(combineMap,j) ); + System.out.println("j======>行"+j+"rowValue"+rowValue.toString()); + + rowValue.add(String.valueOf(j+2)); + dataList.add(rowValue); + } + return dataList; +} + +private int[] Union(int[] a1, int[] a2) { +List list1 = new ArrayList(); +List list2 = new ArrayList(); +for (int i : a1) { + list1.add(i); +} +for (int i : a2) { + list2.add(i); +} +list1.removeAll(list2); +list2.addAll(list1); +int[] result = new int[list2.size()]; +for (int i = 0; i < list2.size(); i++) { + result[i] = list2.get(i); +} +return result; +} + +/** +* 查看一个字符串是否可以转换为数字 +* @param str 字符串 +* @return true 可以; false 不可以 +*/ +public boolean isStr2Num(String str) { +try { + Integer.parseInt(str); + return true; +} catch (NumberFormatException e) { + return false; +} +} + +private class SpecialDialog extends AbstractAIFDialog implements + ActionListener { +private JPanel tablePanel;// 表格控件 +private JTable table; + +private JPanel rootPanel;// 按钮 +private JButton okButton;// 确定 +private JButton celButton;// 取消 + +public SpecialDialog() { + // TODO Auto-generated constructor stub + super(); + init(); +} + +private void init() { + //获取国际化语言 + Locale defaultLocale=Locale.getDefault(); + ResourceBundle rb=ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message",defaultLocale); + // TODO Auto-generated method stub + this.setTitle(rb.getString("xztsfh12_display.TITLE")); + this.table = getjTable(this.table, null, new Object[] { 1, 2, 3, 4, + 5, 6, 7, 8 }, new Object[][] { { 1, 2, 3, 4, 5, 6, 7, 8 }, + { 9, 0, "q", "w", "e", "r", "t", "y" } }); + this.setLocationRelativeTo(this); + this.table.setRowHeight(30); + this.table.getTableHeader().setVisible(false); + this.table.setFont(new Font("Y14.5M", 0, 15)); + this.tablePanel = new JPanel(new BorderLayout()); + this.tablePanel.add(this.table); + + this.okButton = new JButton(rb.getString("qd_display.TITLE")); + this.okButton.addActionListener(this); + this.celButton = new JButton(rb.getString("qx_display.TITLE")); + this.celButton.addActionListener(this); + this.rootPanel = new JPanel(new FlowLayout()); + this.rootPanel.add(this.okButton); + this.rootPanel.add(this.celButton); + + this.add(this.tablePanel, BorderLayout.CENTER); + this.add(this.rootPanel, BorderLayout.SOUTH); + this.pack(); + this.show(); +} + +// Jtable通用方法 +public JTable getjTable(JTable partsTable, DefaultTableModel dtm, + Object[] titleNames, Object[][] values) { + int simpleLen = 100; + int totleLen = 1000; + if (partsTable == null) { + partsTable = new JTable(this.getTableModel(dtm, titleNames, + values)); + partsTable.setCellSelectionEnabled(true); + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i) + .setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; +} + +public DefaultTableModel getTableModel(DefaultTableModel dtm, + Object[] titleNames, Object[][] values) { + MyTableModel tableModel = null; + if (dtm == null) { + tableModel = new MyTableModel(values, titleNames); + } + return tableModel; +} + +@Override +public void actionPerformed(ActionEvent actionevent) { + // TODO Auto-generated method stub + Object source = actionevent.getSource(); + if (source.equals(this.okButton)) { + // DefaultMutableTreeNode node = (DefaultMutableTreeNode) + // TMom012ControlPlanLibraryDialog.tree.getSelectionPath().getLastPathComponent(); + // node.add(new DefaultMutableTreeNode("烧结")); +// Component component = tabbedPane.getSelectedComponent(); +// if (component instanceof JScrollPane) { +// JScrollPane scrollPane = (JScrollPane) component; +// Component tableComponent = scrollPane.getViewport() +// .getView(); +// if (tableComponent instanceof CTable) { + CTable table = mainTable; + int row = table.getSelectedRow(); + int column = table.getSelectedColumn(); + // 保存特殊符号位置 + String columnName = table.getColumnName(table + .getSelectedColumn()); + + int cursorIndex = ((TextAreaCellEditor) (table + .getCellEditor(row, column))).getIndex(); + System.out.println("index+" + cursorIndex); + (table.getCellEditor(row, column)).stopCellEditing(); + // TMom010SetPFMEADialog.table.getDefaultEditor(Object.class).stopCellEditing(); + StringBuilder sb = new StringBuilder(table.getValueAt( + row, column).toString()); + + // 定义循环,如果index的位置不是-1,就一直查找 + Integer index = 0; + while ((index = sb.toString().indexOf("\n", index)) != -1) { + + // 每循环一次就要明确下一次查找的位置 + index = index + "\n".length(); + // 每查找一次计数器自增 + cursorIndex++; + } + // 特殊符号 + Object special = table.getValueAt(row, + table.getColumnCount() - 1); + if (special == null || special.toString() == "") { + table.setValueAt(columnName + "-" + cursorIndex, + row, table.getColumnCount() - 1); + } else { + table.setValueAt(special + "|" + columnName + "-" + + cursorIndex, row, + table.getColumnCount() - 1); + } + System.out.println(sb.length()); + String s = sb.insert( + cursorIndex, + this.table.getValueAt( + this.table.getSelectedRow(), + this.table.getSelectedColumn()) + .toString()).toString(); + table.setValueAt(s, table.getSelectedRow(), + table.getSelectedColumn()); + System.out.println(table.getValueAt(row, column) + .toString()); +// } +// } + } else { + this.dispose(); + } +} +} +} diff --git a/src/com/connor/hs2/plm/PFMEA/library/LibraryHandler.java b/src/com/connor/hs2/plm/PFMEA/library/LibraryHandler.java new file mode 100644 index 0000000..089b3e7 --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/library/LibraryHandler.java @@ -0,0 +1,43 @@ +package com.connor.hs2.plm.PFMEA.library; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class LibraryHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + String commandId = arg0.getCommand().getId(); + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + LibraryCommand command = new LibraryCommand( + app, session, commandId); + try { + TCPreferenceService service = session.getPreferenceService(); + String[] options = service.getStringArray(TCPreferenceService.TC_preference_site, "Cust_PFMEALibrary_Privilege"); + boolean hasPrivilege = false; + for(String option : options){ + if(option.equals(session.getUserName())){ + command.executeModal(); + hasPrivilege = true; + } + } + if(!hasPrivilege){ + MessageBox.post("无管理权限!请联系系统管理员。", "错误", MessageBox.ERROR); + } + //command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("填写PFMEA库失败!", "错误", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/hs2/plm/PFMEA/library/sql.properties b/src/com/connor/hs2/plm/PFMEA/library/sql.properties new file mode 100644 index 0000000..f88d458 --- /dev/null +++ b/src/com/connor/hs2/plm/PFMEA/library/sql.properties @@ -0,0 +1,37 @@ +SETPFMEASELECT=SELECT * FROM AHMC_PFMEA WHERE PROCESSPUID = \'%s\' AND REVISIONID=\'%s\' ORDER BY to_number(NO),to_number(HH) +PFMEALIBRARYSELECT2=SELECT * FROM AHMC_PFMEALIBRARY WHERE PUID = \'%s\' order by NUM + +BOMCHECKSAVESELECTPFMEA=select MEOPID,STATION,gybh,GCMC from AHMC_PFMEA where PROCESSPUID = \'%s\' + +BOMCHECKSAVESELECTPFMEA2=select * from AHMC_PFMEA where PROCESSPUID = \'%s\' and MEOPID not in %s + +DELETEPFMEA=delete from AHMC_PFMEA where MEOPID = \'%s\' and PROCESSPUID = \'%s\' + +INSERTPFMEA=INSERT INTO AHMC_PFMEA VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) + +PFMEALIBRARYSELECT=SELECT * FROM AHMC_PFMEA_NODE WHERE PARENT_ID = \'%s\' order BY ID +SETPFMEASELECT2=SELECT MEOPID,REQUIREMENT from AHMC_PFMEA where PROCESSPUID = \'%s\' group by MEOPID,REQUIREMENT +SETPFMEADELETE=delete from AHMC_PFMEA where PLMEID = \'%s\' + +SETPFMEAUPDATE=update AHMC_PFMEA set GYBH = ?,GCMC = ?,STATION = ?,REQUIREMENT = ?,QZSXMS = ?,QZSXHG = ?,YZD = ?,JB = ?,QZSXQY = ?,XXGCKZYF = ?,PDS = ?,XXGCKZTC = ?,TCD = ?,RPN = ?,JYCS = ?,ZZR = ?,JHWCRQ = ?,CQDCS = ?,NEW_SEV = ?,NEW_OCC = ?,NEW_DET = ?,NEW_RPN = ?,IDEAL_STATE = ?,SPECIAL = ?,HH = ?,HBDYG = ? ,OCCURRRENCE = ?,DETECTION = ?,PRIORITY = ?,P1 = ?,P2 = ?,P3 = ?,P4 = ?,P5 = ? where plmeid = \'%s\' AND revisionid=\'%s\' +TM2PFMEATREESELECT=select * from AHMC_PFMEA_TREE ORDER BY PARENT_ID,ID + +CONTROLPLANLIBRARYSELECT=SELECT * FROM AHMC_CONTROLPLAN_NODE WHERE PARENT_ID = \'%s\' order BY ID + +TM2CONTROLPLANTREESELECT=select * from AHMC_CONTROLPLAN_TREE ORDER BY TO_NUMBER(PARENT_ID) + +TM2THESAURUSTREESELECT=select * from AHMC_THESAURUS_TREE ORDER BY TO_NUMBER(PARENT_ID) + +TM2THESAURUSNODESELECT=SELECT * FROM AHMC_THESAURUS_NODE WHERE PARENT_ID = \'%s\' order BY ID + +PFMEALIBRARYUPDATE=update AHMC_PFMEA_NODE set ID = ?, STATION = ?,REQUIREMENT = ?,QZSXMS = ?,QZSXHG = ?,YZD = ?,JB = ?,QZSXQY = ?,XXGCKZYF = ?,PDS = ?,XXGCKZTC = ?,TCD = ?,RPN = ?,JYCS = ?,ZZR = ?,JHWCRQ = ?,CQDCS = ?,NEW_SEV = ?,NEW_OCC = ?,NEW_DET = ?,NEW_RPN = ?,IDEAL_STATE = ?,SPECIAL = ?,P1 = ?,P2 = ?,P3 = ?,P4 = ?,P5 = ?,P6 = ?,P7 = ?,P8 = ? where plmeid = \'%s\' + +PFMEALIBRARYDELETE=delete from AHMC_PFMEA_NODE where PLMEID = \'%s\' + +PFMEALIBRARYINSERT=INSERT INTO AHMC_PFMEA_NODE VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) + + +SELECTFRAMESIZE=select * from AHMC_PFMEAFRAME_SIZE WHERE USERNAME = \'%s\' AND TYPE = \'%s\' +FRAMESIZEINSERT=INSERT INTO AHMC_PFMEAFRAME_SIZE VALUES(?,?,?,?,?,?) +FRAMESIZEDELETE=DELETE FROM AHMC_PFMEAFRAME_SIZE WHERE USERNAME = \'%s\' AND TYPE = \'%s\' +FRAMESIZEUPDATE=update AHMC_PFMEAFRAME_SIZE set FRAMESIZE = ?, TABLE1SIZE = ?, TABLE2SIZE = ? WHERE USERNAME = \'%s\' AND TYPE = \'%s\' \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/message/Message.properties b/src/com/connor/renben/process/plm/message/Message.properties new file mode 100644 index 0000000..f2fdd2f --- /dev/null +++ b/src/com/connor/renben/process/plm/message/Message.properties @@ -0,0 +1,1594 @@ +xljid_display.TITLE=New Item ID +bbid_display.TITLE=Revision ID +mc_display.TITLE=Name +jlzjid_display.TITLE=Old Item ID +qd_display.TITLE=Sure +qx_display.TITLE=Cancel +cxdr_display.TITLE=Re-import +hbgykdc_display.TITLE=Export horizontal plate process card +sbgykdc_display.TITLE=Export vertical process card +zpgykdc_display.TITLE=Export of assembly process card +zyjzsdc_display.TITLE=Operation reference book export +xzdctp_display.TITLE=Select export picture +sc08_display.TITLE=Delete +lx_display.TITLE=Type +dw_display.TITLE=Unit +scgc_display.TITLE=Production plant +xljxx_display.TITLE=New Item Information +jy_display.TITLE=Based_on +lzjxx_display.TITLE=Item Information +sx_display.TITLE=Attribute +sxsj_display.TITLE=Refresh +ssckzjh_display.TITLE=Pilot production control plan +sckzjh_display.TITLE=Production control plan +dc_display.TITLE=Export +xzlj_display.TITLE=Select path +xzwjj_display.TITLE=Select Folder: +pldctz_display.TITLE=Batch export drawings +dcd_display.TITLE=Export to: +ll_display.TITLE=Browse... +txkzjh_display.TITLE=Fill in control plan +bc_display.TITLE=Save +CP/kzjh_display.TITLE=CONTROL PLAN/Control plan +yj_display.TITLE=Sample +ssc_display.TITLE=Trial production +sc_display.TITLE=Production +kzjhbh_display.TITLE=Control plan number +zylxrbzr_display.TITLE=Main contact / Preparer +zylxrdhbzrdh_display.TITLE=Main contact telephone number / Preparer telephone number +rq(bz)_display.TITLE=Date (Preparation) +rq(xd)_display.TITLE=Date (Revised) +SORhmmc_display.TITLE=SOR Number / Name +ljhzzbb_display.TITLE=Part number / Final version +hxxz_display.TITLE=Core group +gkgcpzrq_display.TITLE=Customer engineering approval / Date +khtzbh_display.TITLE=Customer drawing number +ljmcms_display.TITLE=Item name / Description +gfgcpzrq_display.TITLE=Supplier / Factory approval / Date +gkzlpzrq_display.TITLE=Customer quality approval / Date +gfgc_display.TITLE=Supplier / Factory +gfdh_display.TITLE=Supplier code +gkpzrq_display.TITLE=Customer approval / Date +qtpzrq_display.TITLE=Other approval / Date +tjh_display.TITLE=Add rows +tjdh_display.TITLE=Add multiple lines +tjhbh_display.TITLE=Add merge row +tjdghbh_display.TITLE=Add multiple merged rows +tjgx_display.TITLE=Add procedure +hbh_display.TITLE=Merge lines +cfhbdyg_display.TITLE=Split and merge cells +yczh_display.TITLE=Remove entire row +sxxzl_display.TITLE=Zoom out the selected column +qxsxxzl_display.TITLE=Cancel narrowing selected column +txbz_display.TITLE=Filling standard +dcnbkzjh_display.TITLE=Export internal control plan +fqsh_display.TITLE=Initiate audit +kzjhk_display.TITLE=Control plan library +ck_display.TITLE=Lexicon +cxjz_display.TITLE=Reload +qksj_display.TITLE=Clear all data +cjgy_display.TITLE=Create technology +xh_display.TITLE=Model +cpmc_display.TITLE=Product name +cxyj_display.TITLE=Forming press +khmc_display.TITLE=Customer name +khth_display.TITLE=Customer drawing number +zxyj_display.TITLE=Integral press +khxmh_display.TITLE=Customer project number +clbz_display.TITLE=Material standard +sjry_display.TITLE=Designers +cjrq_display.TITLE=Creation date +cx06_display.TITLE=Query +cph06_display.TITLE=Product ID +gybh06_display.TITLE=Process number +mc06_display.TITLE=Name +gyfg08_display.TITLE=Process division +xzz08_display.TITLE=Selection value: +yhm08_display.TITLE=User name: +ss08_display.TITLE=Search +txPFMEA10_display.TITLE=Fill in PFMEA +qzsxmsjhgfx10_display.TITLE=Potential failure mode and consequence analysis +gsmc10_display.TITLE=Corporate name +xm10_display.TITLE=Project +PFMEAIDbh10_display.TITLE=PFMEA ID number +zzdz10_display.TITLE=Manufacturing address +PFMEAksrq10_display.TITLE=PFMEA start date +PFMEAxdrq10_display.TITLE=PFMEA revision date +gczz10_display.TITLE=Process responsibilities +gkmc10_display.TITLE=Customer name +bmjb10_display.TITLE=Security level +cxpt10_display.TITLE=Model / Platform +kzntd10_display.TITLE=Cross functional team +ll10_display.TITLE=PFMEA experience database +wc10_display.TITLE=Complete +dcPFMEA10_display.TITLE=Export PFMEA +PFMEAc10_display.TITLE=PFMEA Library +xztsfh10_display.TITLE=Select special symbol +cz10_display.TITLE=Search +fzdh10_display.TITLE=Copy multiple lines +crhs10_display.TITLE=Insert rows +ych12_display.TITLE=Remove row +tjjd12_display.TITLE=Add node +ycjd12_display.TITLE=Remove node +gxjd12_display.TITLE=Update node +jdmc12_display.TITLE=Node name +jdID12_display.TITLE=Node ID +xztsfh12_display.TITLE=Select special symbol +bzgy17_display.TITLE=Packaging technology +cpdh17_display.TITLE=Product code +cpmc17_display.TITLE=Product name +yhth17_display.TITLE=User drawing number +chmc17_display.TITLE=Customer name +jszg17_display.TITLE=Technical director +sjxzljtp17_display.TITLE=Double click to select the part image +bzfs17_display.TITLE=Packing method +jyfs17_display.TITLE=Oil immersion method +mxsl17_display.TITLE=Quantity per case +jx17_display.TITLE=Pieces / case +wzxm17_display.TITLE=Name of outer carton +bzde17_display.TITLE=Packaging quota +xs17_display.TITLE=Case / hour +nldm17_display.TITLE=Name of nylon bag +cpdz17_display.TITLE=Unit weight of finished product +xsm17_display.TITLE=Blister name +zxmz17_display.TITLE=Gross weight of full container +wxbq17_display.TITLE=Outer box label +rktp17_display.TITLE=Storage tray +xc17_display.TITLE=Box / layer +ct17_display.TITLE=Floor / tray +sjxztp17_display.TITLE=Double click to select Picture +bzsm17_display.TITLE=Step description +zysx17_display.TITLE=Matters needing attention +bzry17_display.TITLE=Staffing +pzry17_display.TITLE=Approved personnel +xgrq17_display.TITLE=Modification date +bz17_display.TITLE=Remarks +ysbzlx17_display.TITLE=Type of transport package +dbfs17_display.TITLE=Packing method +tpgg17_display.TITLE=Tray specification +jgfs17_display.TITLE=Reinforcement method +sjxzdbt17_display.TITLE=Double click to select packing map +dybzxx17_display.TITLE=Unit packaging information +ysbzxx17_display.TITLE=Transport package information +dh17_display.TITLE=Code-named +cckcg17_display.TITLE=Length * width * height (CM) +hd17_display.TITLE=Thickness (MM) +cl17_display.TITLE=Material +gg17_display.TITLE=Specifications +ks17_display.TITLE=Number of holes +cp17_display.TITLE=Product +xgdj18_display.TITLE=Revision level +cxnd18_display.TITLE=Model / year +bz18_display.TITLE=Tagging +ycbz18_display.TITLE=Remove dimension +kzjhdc19_display.TITLE=Control plan export +gx19_display.TITLE=Procedure +cx19_display.TITLE=Query +kzjhwjmc19_display.TITLE=Name of control plan document +drkzjh20_display.TITLE=Import control plan +xzkzjhwj20_display.TITLE=Select control plan file +qcwcbj21_display.TITLE=Clear completion flag +xzgytz23_display.TITLE=Select process drawings +gytz23_display.TITLE=Process drawings: +xz24_display.TITLE=Select +kzjh24_display.TITLE=Control plan +yqrq25_display.TITLE=Overdue date +PDMEAtj25_display.TITLE=PFMEA statistics +dcbb25_display.TITLE=Export report +gb25_display.TITLE=Close +jcfxwtd27_display.TITLE=Inspection and analysis order +wtdbh27_display.TITLE=Relegated bill number +jclx27_display.TITLE=Testing type +jcbm27_display.TITLE=Testing department +wtdw27_display.TITLE=Entrusted unit +wtr27_display.TITLE=Entrusted person +wtdz27_display.TITLE=Entrusted address +wtrlxfs27_display.TITLE=Contact information of client +wtrq27_display.TITLE=Date of commission +xwwcsj27_display.TITLE=Expected completion time +jcyt27_display.TITLE=Testing purpose +jcjg27_display.TITLE=Testing result +xmdj27_display.TITLE=Project level +khdj27_display.TITLE=Customer level +xmbh27_display.TITLE=Project number +yyly27_display.TITLE=Application area +xmmc27_display.TITLE=Project name +cph27_display.TITLE=Product ID +wlh27_display.TITLE=Material number +cplx27_display.TITLE=Product type +scdw27_display.TITLE=Production unit +ypsl27_display.TITLE=Number of samples +ypzt27_display.TITLE=Sample status +wldh27_display.TITLE=Logistics order No +ypbh27_display.TITLE=Sample number +ypclfs27_display.TITLE=Sample handling method +sybw27_display.TITLE=Application site +syhj27_display.TITLE=Use environment +gzzh27_display.TITLE=Working load +zhlx27_display.TITLE=Load type +xzfs27_display.TITLE=Rotation way +xzsd27_display.TITLE=Rotation speed +gzwd27_display.TITLE=Working temperature +xzwtnr27_display.TITLE=Select delegation content +bz27_display.TITLE=Remarks +ypydxc27_display.TITLE=The sample has arrived at the scene +sysj27_display.TITLE=Sample receiving time +syr27_display.TITLE=Sample receiver +ypshjg27_display.TITLE=Sample audit results +yqwcsj27_display.TITLE=Expected completion time +thyy27_display.TITLE=Reason for return +jcrwzb27_display.TITLE=Host of testing task +jcrwxb27_display.TITLE=Testing task jointly +jhkssj27_display.TITLE=Planned start time +jhwcsj27_display.TITLE=Planned completion time +djdywtd27_display.TITLE=Click Print Order +djdyypbs27_display.TITLE=Click to print sample identification +sjwcsj27_display.TITLE=Actual completion time +jcjgsm27_display.TITLE=Description of test results +ypcz27_display.TITLE=Sample disposal +cywz27_display.TITLE=Sample storage location +shsj27_display.TITLE=Audit time +shy27_display.TITLE=Auditor +shjg27_display.TITLE=Audit results +wtxx27_display.TITLE=Delegation information +clfx27_display.TITLE=Material analysis +jljc27_display.TITLE=Metrological testing +wtnr27_display.TITLE=Content of entrustment +zygyk28_display.TITLE=Operation process card +gsmc28_display.TITLE=Corporate name +ljdh28_display.TITLE=Part number +sbxh28_display.TITLE=Product name +bgx28_display.TITLE=This process +sbmc28_display.TITLE=Equipment name +gzmx28_display.TITLE=Tooling details +jgcs28_display.TITLE=Processing parameters +cptxkzyq28_display.TITLE=Product characteristic control requirements +zpgyk29_display.TITLE=Assembly process card +gsmc29_display.TITLE=Corporate name +ljdh29_display.TITLE=Part code +sbxh29_display.TITLE=Equipment model +zyjzs30_display.TITLE=Operation standard +xzdclj31_display.TITLE=Select export path +wjmc31_display.TITLE=File name +jyjzs33_display.TITLE=Inspection standard +bzbz34_display.TITLE=Packaging standard +ljh34_display.TITLE=Part number +ljmc34_display.TITLE=Part name +gys34_display.TITLE=Supplier +gysdh34_display.TITLE=Supplier Code +syzcdmmc34_display.TITLE=Applicable assembly code / name +ljdw(tg)34_display.TITLE=Parts unit (set / piece) +ljgg34_display.TITLE=Part specification (mm) +ljzl34_display.TITLE=Weight of parts (kg) +bzbzclfhdjyms34_display.TITLE=Brief description of packaging, packaging materials, protection, etc +bqgshwz34_display.TITLE=Label format and location +zt35_display.TITLE=Status +wtdsh35_display.TITLE=Authorization form approval +gzfp35_display.TITLE=Assignment of work +scjl35_display.TITLE=Upload record +wtrq35_display.TITLE=Date of commission +wtdh35_display.TITLE=Odd Numbers of commission +wtdw35_display.TITLE=entrusted unit +jclx35_display.TITLE=Test type +xmdj35_display.TITLE=Project level +ycwcrq35_display.TITLE=Expected completion date +jhwcrq35_display.TITLE=Planned completion date +zbry35_display.TITLE=Sponsor +lcjs35_display.TITLE=Process monitoring +dqzt35_display.TITLE=Current status +wtdhypsh35_display.TITLE=Order and sample audit +gzfp35_display.TITLE=Assignment of work +scjg35_display.TITLE=Upload results +sywtd41_display.TITLE=Test order +wtdbh41_display.TITLE=Order No: +scdw41_display.TITLE=Production unit +ccxh41_display.TITLE=Bearing model +sych41_display.TITLE=Use occasion +xmmc41_display.TITLE=entry name +xmbh41_display.TITLE=Project number +xmdj41_display.TITLE=Project level +wtsylx41_display.TITLE=Type of commission test +yzsy41_display.TITLE=Verification test +tzxxsy41_display.TITLE=Special new type test +khyq41_display.TITLE=Customer requirements +sybj41_display.TITLE=Background of the experiment +symd41_display.TITLE=Purpose of the experiment +sygfsjry41_display.TITLE=Test specification (designer) +yjgsyry41_display.TITLE=handed over to the tester +qtsyyq41_display.TITLE=Other test requirements +wtr41_display.TITLE=client +lxfs41_display.TITLE=contact information +gsdz41_display.TITLE=Company address +gscz41_display.TITLE=Company fax +shr41_display.TITLE=Reviewer +shrq41_display.TITLE=Audit date +zjlpz41_display.TITLE=Approved by general manager +sywtftx41_display.TITLE=Fill in by test client +psjl41_display.TITLE=Review record +jhkssj41_display.TITLE=Planned start time +jhjssj41_display.TITLE=Planned end time +syfzr41_display.TITLE=Person in charge of the test +lxdh41_display.TITLE=contact number +psrq41_display.TITLE=Review / date +pzrq41_display.TITLE=Approval / date +swtftx41_display.TITLE=Fill in by client +bz41_display.TITLE=Remarks +gzsjtd41_display.TITLE=Tooling design team +xzscgztz41_display.TITLE=Select upload tooling drawing +qxzyscdwj41_display.TITLE=Please select the file to upload +qd41_display.TITLE=determine +gzsjwcrq141_display.TITLE=Tooling design completion date +gzsj141_display.TITLE=Tooling design +gzdhrq41_display.TITLE=Tooling arrival date +gzsjrq41_display.TITLE=Tooling inspection date +gzsjwcrq41_display.TITLE=Tooling inspection completion date +gzjcbgbh41_display.TITLE=Tooling test report (record) No +gzsj41_display.TITLE=Tooling inspection +ypdyrq41_display.TITLE=Sample arrival date +syqypjcwcrq41_display.TITLE=Sample test completion date before test +syqypjcbgbh41_display.TITLE=Sample test report (record) No. before test +syksrq41_display.TITLE=Test start date +sywcrq41_display.TITLE=Test completion date +syss41_display.TITLE=Test implementation +syhypjcwcrq41_display.TITLE=Completion date of sample test after test +syhypjcbg41_display.TITLE=Sample test report (record) No. after test +ypjc41_display.TITLE=Sample testing +xzscsybg41_display.TITLE=Select upload test report +sywcrq241_display.TITLE=Test completion date +sybgbh41_display.TITLE=Test report no +sybg241_display.TITLE=Test report +sywtd241_display.TITLE=Test order +sykxljap41_display.TITLE=The test is feasible,and arrange immediately +sybkx41_display.TITLE=The test is not feasible +zybcfjywwsy41_display.TITLE=The resources are not enough, suggest to subcontract the test +qijy241_display.TITLE=Other suggestions +btxxbnwk41_display.TITLE=Required item cannot be empty! +gzcg41_display.TITLE=Tooling procurement +xqsp41_display.TITLE=Requirement approval +fxwtd40_display.TITLE=Analysis order +CEAwtd40_display.TITLE=CAE order +wtdbh40_display.TITLE=Order No: +kemc40_display.TITLE=Customer name +xmsstd40_display.TITLE=Project team +xmmc40_display.TITLE=Project name +xmjl40_display.TITLE=Project manager +xmdj40_display.TITLE=Project level +sjbsstd40_display.TITLE=Team of design department +xmbh40_display.TITLE=Project number +sjfzr40_display.TITLE=Design director +xmlx40_display.TITLE=Project type +qwwcsj40_display.TITLE=Expected completion time +jbxx40_display.TITLE=1.Basic Information +scfxry40_display.TITLE=Last analyst +scbgsj40_display.TITLE=Last report time +ggd40_display.TITLE=Change point +ggyy40_display.TITLE=Reason for change +srzl40_display.TITLE=2.Input information +cjtd40_display.TITLE=Undertaking team +xmwtsj40_display.TITLE=Project entrustment time +cjr40_display.TITLE=Undertaker +xmggcs40_display.TITLE=Number of project changes +xbr40_display.TITLE=Co sponsor +jhkssj40_display.TITLE=Planned start time +Romaxjf40_display.TITLE=Romax integral +jsxqts40_display.TITLE=Calculate demand days +yxyjf40_display.TITLE=Finite element integration +jswcsj40_display.TITLE=Calculate completion time +xmcjxx40_display.TITLE=3. Project undertaking information +bghjgmc40_display.TITLE=Report or result name +bgbh40_display.TITLE=Report no +bghjgscsj40_display.TITLE=Report or result upload time +bghjgfk40_display.TITLE=4.Report or result feedback +jdr40_display.TITLE=Check reader +jdsj40_display.TITLE=Check reading time +jdjg40_display.TITLE=Check reading results +thyy40_display.TITLE=Reason for return +bghjgjd40_display.TITLE=5.Report or result check +khmc40_display.TITLE=Customer name +xmbssty40_display.TITLE=Team of project department +sybw40_display.TITLE=Application site +srzl40_display.TITLE=2.Input information +bxqrbgxxx40_display.TITLE=Information must be confirmed and checked +jsscxm40_display.TITLE=Calculate output items +kgxxx40_display.TITLE=Checkable information +ydndqjddjgzwd40_display.TITLE=Kinematic viscosity, cleanliness grade, working temperature +EPtjj40_display.TITLE=EP additive +ysr40_display.TITLE=Pre judge +yssj40_display.TITLE=Preliminary hearing time +ysjg40_display.TITLE=Preliminary results +zbdzys40_display.TITLE=1.Pre-review by team leader +wtdbh240_display.TITLE=Order No +jhwcsj40_display.TITLE=Planned completion time +xmcjxx240_display.TITLE=2.Project undertaking information +jsfxjm40_display.TITLE=Computational analysis modeling +bczlsj40_display.TITLE=Supplementary information time +zyss40_display.TITLE=3.Work implementation +bghjgfk240_display.TITLE=4.Report or result feedback +bghjgjd240_display.TITLE=5.Report or result check +CAEfxxqwtd40_display.TITLE=CAE analysis demand order +jsfxtdcjd40_display.TITLE=Calculation and analysis team acceptance order +ggxmwtd40_display.TITLE=Change project order +tk_display.TITLE=Picture library + + +ljgybh04_display.TITLE=Part / process number +gcmc04_display.TITLE=Process name +jqsbgzjj04_display.TITLE=Machine, equipment, tooling, fixture +smjyzyzb04_display.TITLE=Initial and final inspection / operation preparation +bh04_display.TITLE=Number +cp04_display.TITLE=product +gc04_display.TITLE=process +tstxfl04_display.TITLE=Classification of special characteristics +cpgcgfgc04_display.TITLE=Product / process / specification / tolerance +pgclff04_display.TITLE=Evaluation / measurement method +rl04_display.TITLE=capacity +pl04_display.TITLE=frequency +kzff04_display.TITLE=Control method +fyjh04_display.TITLE=Response plan +tsfhwz04_display.TITLE=Special symbol location +sfwc04_display.TITLE=Complete +fjdID04_display.TITLE=Parent node ID +tszfszwz04_display.TITLE=Location of special characters +xh04_display.TITLE=Serial number +z04_display.TITLE=value +mc04_display.TITLE=name +gysjfdygc34_display.TITLE=Composition of supplier delivery unit +yjbz34_display.TITLE=Primary packaging +ejbz34_display.TITLE=Secondary packaging +sjbz34_display.TITLE=Tertiary packaging + + +wxzcpdxqcxxz02_display.TITLE=Product object is not selected, please Reselect! +qxzzcdxhcj02_display.TITLE=Please select the assembly object and create it +gy02_display.TITLE=Technology +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= +.TITLE= + diff --git a/src/com/connor/renben/process/plm/message/Message_zh_CN.properties b/src/com/connor/renben/process/plm/message/Message_zh_CN.properties new file mode 100644 index 0000000..5c01029 --- /dev/null +++ b/src/com/connor/renben/process/plm/message/Message_zh_CN.properties @@ -0,0 +1,1172 @@ +xljid_display.TITLE=\u5DE5\u5E8FID +bbid_display.TITLE=\u7248\u672c\u0049\u0044 +mc_display.TITLE=\u540d\u79f0 +jlzjid_display.TITLE=\u65e7\u96f6\u7ec4\u4ef6\u0049\u0044 +qd_display.TITLE=\u786e\u5b9a +qx_display.TITLE=\u53d6\u6d88 +bc_display.TITLE=\u4FDD\u5B58 +cxdr_display.TITLE=\u91CD\u65B0\u5BFC\u5165 +hbgykdc_display.TITLE=\u6A2A\u7248\u5DE5\u827A\u5361\u5BFC\u51FA +sbgykdc_display.TITLE=\u7AD6\u7248\u5DE5\u827A\u5361\u5BFC\u51FA +zpgykdc_display.TITLE=\u88C5\u914D\u5DE5\u827A\u5361\u5BFC\u51FA +zyjzsdc_display.TITLE=\u4F5C\u4E1A\u57FA\u51C6\u4E66\u5BFC\u51FA +xzdctp_display.TITLE=\u9009\u62E9\u5BFC\u51FA\u56FE\u7247 +sc08_display.TITLE=\u5220\u9664 +lx_display.TITLE=\u7c7b\u578b +dw_display.TITLE=\u5355\u4f4d +scgc_display.TITLE=\u751F\u4EA7\u5DE5\u5382 +xljxx_display.TITLE=\u65b0\u96f6\u4ef6\u4fe1\u606f +jy_display.TITLE=\u57fa\u4e8e +lzjxx_display.TITLE=\u96f6\u7ec4\u4ef6\u4fe1\u606f +sx_display.TITLE=\u5c5e\u6027 +sxsj_display.TITLE=\u5237\u65B0 +ssckzjh_display.TITLE=\u8bd5\u751f\u4ea7\u63a7\u5236\u8ba1\u5212 +sckzjh_display.TITLE=\u751f\u4ea7\u63a7\u5236\u8ba1\u5212 +dc_display.TITLE=\u5bfc\u51fa +xzlj_display.TITLE=\u9009\u62E9\u8DEF\u5F84 +xzwjj_display.TITLE=\u9009\u62e9\u6587\u4ef6\u5939\u003a +pldctz_display.TITLE=\u6279\u91cf\u5bfc\u51fa\u56fe\u7eb8 +dcd_display.TITLE=\u5BFC\u51FA\u5230\uFF1A +ll_display.TITLE=\u6D4F\u89C8... +txkzjh_display.TITLE=\u586B\u5199\u63A7\u5236\u8BA1\u5212 +CP/kzjh_display.TITLE=\u0043\u004f\u004e\u0054\u0052\u004f\u004c\u0020\u0050\u004c\u0041\u004e\u002f\u63a7\u5236\u8ba1\u5212 +yj_display.TITLE=\u6837\u4EF6 +ssc_display.TITLE=\u8BD5\u751F\u4EA7 +sc_display.TITLE=\u751F\u4EA7 +kzjhbh_display.TITLE=\u63A7\u5236\u8BA1\u5212\u7F16\u53F7 +zylxrbzr_display.TITLE=\u4E3B\u8981\u8054\u7CFB\u4EBA/\u7F16\u5236\u4EBA +zylxrdhbzrdh_display.TITLE=\u4E3B\u8981\u8054\u7CFB\u4EBA\u7535\u8BDD/\u7F16\u5236\u4EBA\u7535\u8BDD +rq(bz)_display.TITLE=\u65E5\u671F\uFF08\u7F16\u5236\uFF09 +rq(xd)_display.TITLE=\u65E5\u671F\uFF08\u4FEE\u8BA2\uFF09 +SORhmmc_display.TITLE=SOR\u53F7\u7801/\u540D\u79F0 +ljhzzbb_display.TITLE=\u96F6\u4EF6\u53F7/\u6700\u7EC8\u7248\u672C +hxxz_display.TITLE=\u6838\u5FC3\u5C0F\u7EC4 +gkgcpzrq_display.TITLE=\u987E\u5BA2\u5DE5\u7A0B\u6279\u51C6/\u65E5\u671F +khtzbh_display.TITLE=\u5BA2\u6237\u56FE\u7EB8\u7F16\u53F7 +ljmcms_display.TITLE=\u96F6\u4EF6\u540D\u79F0/\u63CF\u8FF0 +gfgcpzrq_display.TITLE=\u4F9B\u65B9/\u5DE5\u5382\u6279\u51C6/\u65E5\u671F +gkzlpzrq_display.TITLE=\u987E\u5BA2\u8D28\u91CF\u6279\u51C6/\u65E5\u671F +gfgc_display.TITLE=\u4F9B\u65B9/\u5DE5\u5382 +gfdh_display.TITLE=\u4F9B\u65B9\u4EE3\u53F7 +gkpzrq_display.TITLE=\u987E\u5BA2\u6279\u51C6/\u65E5\u671F +qtpzrq_display.TITLE=\u5176\u4ED6\u6279\u51C6/\u65E5\u671F +tjh_display.TITLE=\u6DFB\u52A0\u884C +tjdh_display.TITLE=\u6DFB\u52A0\u591A\u884C +tjhbh_display.TITLE=\u6DFB\u52A0\u5408\u5E76\u884C +tjdghbh_display.TITLE=\u6DFB\u52A0\u591A\u4E2A\u5408\u5E76\u884C +tjgx_display.TITLE=\u6DFB\u52A0\u5DE5\u5E8F +hbh_display.TITLE=\u5408\u5E76\u884C +cfhbdyg_display.TITLE=\u62C6\u5206\u5408\u5E76\u5355\u5143\u683C +yczh_display.TITLE=\u79FB\u9664\u6574\u884C +sxxzl_display.TITLE=\u7F29\u5C0F\u9009\u4E2D\u5217 +qxsxxzl_display.TITLE=\u53D6\u6D88\u7F29\u5C0F\u9009\u4E2D\u5217 +txbz_display.TITLE=\u586B\u5199\u6807\u51C6 +dcnbkzjh_display.TITLE=\u5BFC\u51FA\u63A7\u5236\u8BA1\u5212 +fqsh_display.TITLE=\u53D1\u8D77\u5BA1\u6838 +kzjhk_display.TITLE=\u63A7\u5236\u8BA1\u5212\u5E93 +ck_display.TITLE=\u8BCD\u5E93 +cxjz_display.TITLE=\u91CD\u65B0\u52A0\u8F7D +qksj_display.TITLE=\u6E05\u7A7A\u6570\u636E +cjgy_display.TITLE=\u521B\u5EFA\u5DE5\u827A +xh_display.TITLE=\u578B\u53F7 +cpmc_display.TITLE=\u4EA7\u54C1\u540D\u79F0 +cxyj_display.TITLE=\u6210\u5F62\u538B\u673A +khmc_display.TITLE=\u5BA2\u6237\u540D\u79F0 +khth_display.TITLE=\u5BA2\u6237\u56FE\u53F7 +zxyj_display.TITLE=\u6574\u578B\u538B\u673A +khxmh_display.TITLE=\u5BA2\u6237\u9879\u76EE\u53F7 +clbz_display.TITLE=\u6750\u6599\u6807\u51C6 +sjry_display.TITLE=\u8BBE\u8BA1\u4EBA\u5458 +cjrq_display.TITLE=\u521B\u5EFA\u65E5\u671F +cx06_display.TITLE=\u67E5\u8BE2 +cph06_display.TITLE=\u4EA7\u54C1\u53F7 +gybh06_display.TITLE=\u5DE5\u827A\u7F16\u53F7 +mc06_display.TITLE=\u540D\u79F0 +gyfg08_display.TITLE=\u5DE5\u827A\u5206\u5DE5 +xzz08_display.TITLE=\u9009\u62E9\u503C\uFF1A +yhm08_display.TITLE=\u7528\u6237\u540D\uFF1A +ss08_display.TITLE=\u641C\u7D22 +txPFMEA10_display.TITLE=\u586B\u5199PFMEA +qzsxmsjhgfx10_display.TITLE=\u6F5C\u5728\u5931\u6548\u6A21\u5F0F\u53CA\u540E\u679C\u5206\u6790 +gsmc10_display.TITLE=\u516C\u53F8\u540D\u79F0 +xm10_display.TITLE=\u9879\u76EE +PFMEAIDbh10_display.TITLE=PFMEA ID\u7F16\u53F7 +zzdz10_display.TITLE=\u5236\u9020\u5730\u5740 +PFMEAksrq_display.TITLE=PFMEA\u5F00\u59CB\u65E5\u671F +PFMEAxdrq10_display.TITLE=PFMEA\u4FEE\u8BA2\u65E5\u671F +gczz10_display.TITLE=\u8FC7\u7A0B\u804C\u8D23 +gkmc10_display.TITLE=\u987E\u5BA2\u540D\u79F0 +bmjb10_display.TITLE=\u4FDD\u5BC6\u7EA7\u522B +cxpt10_display.TITLE=\u8F66\u578B/\u5E73\u53F0 +kzntd10_display.TITLE=\u8DE8\u804C\u80FD\u56E2\u961F +ll10_display.TITLE=PFMEA\u7ECF\u9A8C\u6570\u636E\u5E93 +wc10_display.TITLE=\u5B8C\u6210 +dcPFMEA10_display.TITLE=\u5BFC\u51FAPFMEA +PFMEAc10_display.TITLE=PFMEA\u5E93 +xztsfh10_display.TITLE=\u9009\u62E9\u7279\u6B8A\u7B26\u53F7 +cz10_display.TITLE=\u67E5\u627E +fzdh10_display.TITLE=\u590D\u5236\u591A\u884C +crhs10_display.TITLE=\u63D2\u5165\u884C\u6570 +ych12_display.TITLE=\u79FB\u9664\u884C +tjjd12_display.TITLE=\u6DFB\u52A0\u8282\u70B9 +ycjd12_display.TITLE=\u79FB\u9664\u8282\u70B9 +gxjd12_display.TITLE=\u66F4\u65B0\u8282\u70B9 +jdmc12_display.TITLE=\u8282\u70B9\u540D\u79F0 +jdID12_display.TITLE=\u8282\u70B9ID +xztsfh12_display.TITLE=\u9009\u62E9\u7279\u6B8A\u7B26\u53F7 +bzgy17_display.TITLE=\u5305\u88C5\u5DE5\u827A +cpdh17_display.TITLE=\u4EA7\u54C1\u4EE3\u53F7 +cpmc17_display.TITLE=\u4EA7\u54C1\u540D\u79F0 +yhth17_display.TITLE=\u7528\u6237\u56FE\u53F7 +chmc17_display.TITLE=\u5BA2\u6237\u540D\u79F0 +jszg17_display.TITLE=\u6280\u672F\u4E3B\u7BA1 +sjxzljtp17_display.TITLE=\u53CC\u51FB\u9009\u62E9\u96F6\u4EF6\u56FE\u7247 +bzfs17_display.TITLE=\u5305\u88C5\u65B9\u5F0F +jyfs17_display.TITLE=\u6D78\u6CB9\u65B9\u5F0F +mxsl17_display.TITLE=\u6BCF\u7BB1\u6570\u91CF +jx17_display.TITLE=\u4EF6/\u7BB1 +wzxm17_display.TITLE=\u5916\u7EB8\u7BB1\u540D +bzde17_display.TITLE=\u5305\u88C5\u5B9A\u989D +xs17_display.TITLE=\u7BB1/\u65F6 +nldm17_display.TITLE=\u5C3C\u9F99\u888B\u540D +cpdz17_display.TITLE=\u6210\u54C1\u5355\u91CD +xsm17_display.TITLE= \u5438\u5851\u540D +zxmz17_display.TITLE=\u6574\u7BB1\u6BDB\u91CD +wxbq17_display.TITLE=\u5916\u7BB1\u6807\u7B7E +rktp17_display.TITLE=\u5165\u5E93\u6258\u76D8 +xc17_display.TITLE=\u7BB1/\u5C42 +ct17_display.TITLE=\u5C42/\u6258 +sjxztp17_display.TITLE=\u53CC\u51FB\u9009\u62E9\u56FE\u7247 +bzsm17_display.TITLE=\u6B65\u9AA4\u8BF4\u660E +zysx17_display.TITLE=\u6CE8\u610F\u4E8B\u9879 +bzry17_display.TITLE=\u7F16\u5236\u4EBA\u5458 +pzry17_display.TITLE=\u6279\u51C6\u4EBA\u5458 +xgrq17_display.TITLE=\u4FEE\u6539\u65E5\u671F +bz17_display.TITLE=\u5907 \u6CE8 +ysbzlx17_display.TITLE=\u8FD0\u8F93\u5305\u88C5\u7C7B\u578B +dbfs17_display.TITLE=\u6253\u5305\u65B9\u5F0F +tpgg17_display.TITLE=\u6258\u76D8\u89C4\u683C +jgfs17_display.TITLE=\u52A0\u56FA\u65B9\u5F0F +sjxzdbt17_display.TITLE=\u53CC\u51FB\u9009\u62E9\u6253\u5305\u56FE +dybzxx17_display.TITLE=\u5355\u5143\u5305\u88C5\u4FE1\u606F +ysbzxx17_display.TITLE=\u8FD0\u8F93\u5305\u88C5\u4FE1\u606F +dh17_display.TITLE=\u4EE3\u53F7 +cckcg17_display.TITLE=\u957F*\u5BBD*\u9AD8\uFF08cm\uFF09 +hd17_display.TITLE=\u539A\u5EA6\uFF08mm\uFF09 +cl17_display.TITLE=\u6750\u6599 +gg17_display.TITLE=\u89C4\u683C +ks17_display.TITLE=\u5B54\u6570 +cp17_display.TITLE=\u4EA7\u54C1 +xgdj18_display.TITLE=\u4FEE\u6539\u7B49\u7EA7 +cxnd18_display.TITLE=\u8F66\u578B/\u5E74\u5EA6 +bz18_display.TITLE=\u6807\u6CE8 +ycbz18_display.TITLE=\u79FB\u9664\u6807\u6CE8 +kzjhdc19_display.TITLE=\u63A7\u5236\u8BA1\u5212\u5BFC\u51FA +gx19_display.TITLE=\u5DE5\u5E8F: +cx19_display.TITLE=\u67E5\u8BE2 +kzjhwjmc19_display.TITLE=\u63A7\u5236\u8BA1\u5212\u6587\u4EF6\u540D\u79F0 +drkzjh20_display.TITLE=\u5BFC\u5165\u63A7\u5236\u8BA1\u5212 +xzkzjhwj20_display.TITLE=\u9009\u62E9\u63A7\u5236\u8BA1\u5212\u6587\u4EF6 +qcwcbj21_display.TITLE=\u6E05\u9664\u5B8C\u6210\u6807\u8BB0 +xzgytz23_display.TITLE=\u9009\u62E9\u5DE5\u827A\u56FE\u7EB8 +gytz23_display.TITLE=\u5DE5\u827A\u56FE\u7EB8\uFF1A +xz24_display.TITLE=\u9009\u62E9 +kzjh24_display.TITLE=\u63A7\u5236\u8BA1\u5212 +yqrq25_display.TITLE=\u903E\u671F\u65E5\u671F +PDMEAtj25_display.TITLE=PFMEA\u7EDF\u8BA1 +dcbb25_display.TITLE=\u5BFC\u51FA\u62A5\u8868 +gb25_display.TITLE=\u5173\u95ED +jcfxwtd27_display.TITLE=\u68C0\u6D4B\u5206\u6790\u59D4\u6258\u5355 +wtdbh27_display.TITLE=\u59D4\u6258\u5355\u7F16\u53F7\uFF1A +jclx27_display.TITLE=\u68C0\u6D4B\u7C7B\u578B +jcbm27_display.TITLE=\u68C0\u6D4B\u90E8\u95E8 +wtdw27_display.TITLE=\u59D4\u6258\u5355\u4F4D +wtr27_display.TITLE=\u59D4\u6258\u4EBA +wtdz27_display.TITLE=\u59D4\u6258\u5730\u5740 +wtrlxfs27_display.TITLE=\u59D4\u6258\u4EBA\u8054\u7CFB\u65B9\u5F0F +wtrq27_display.TITLE=\u59D4\u6258\u65E5\u671F +xwwcsj27_display.TITLE=\u5E0C\u671B\u5B8C\u6210\u65F6\u95F4 +jcyt27_display.TITLE=\u68C0\u6D4B\u7528\u9014 +jcjg27_display.TITLE=\u68C0\u6D4B\u7ED3\u679C +xmdj27_display.TITLE=\u9879\u76EE\u7B49\u7EA7 +khdj27_display.TITLE=\u5BA2\u6237\u7B49\u7EA7 +xmbh27_display.TITLE=\u9879\u76EE\u7F16\u53F7 +yyly27_display.TITLE=\u5E94\u7528\u9886\u57DF +xmmc27_display.TITLE=\u9879\u76EE\u540D\u79F0 +cph27_display.TITLE=\u4EA7\u54C1\u53F7 +wlh27_display.TITLE=\u7269\u6599\u53F7 +cplx27_display.TITLE=\u4EA7\u54C1\u7C7B\u578B +scdw27_display.TITLE=\u751F\u4EA7\u5355\u4F4D +ypsl27_display.TITLE=\u6837\u54C1\u6570\u91CF +ypzt27_display.TITLE=\u6837\u54C1\u72B6\u6001 +wldh27_display.TITLE=\u7269\u6D41\u5355\u53F7 +ypbh27_display.TITLE=\u6837\u54C1\u7F16\u53F7 +ypclfs27_display.TITLE=\u6837\u54C1\u5904\u7406\u65B9\u5F0F +sybw27_display.TITLE=\u4F7F\u7528\u90E8\u4F4D +syhj27_display.TITLE=\u4F7F\u7528\u73AF\u5883 +gzzh27_display.TITLE=\u5DE5\u4F5C\u8F7D\u8377 +zhlx27_display.TITLE=\u8F7D\u8377\u7C7B\u578B +xzfs27_display.TITLE=\u65CB\u8F6C\u65B9\u5F0F +xzsd27_display.TITLE=\u65CB\u8F6C\u901F\u5EA6 +gzwd27_display.TITLE=\u5DE5\u4F5C\u6E29\u5EA6 +xzwtnr27_display.TITLE=\u9009\u62E9\u59D4\u6258\u5185\u5BB9 +bz27_display.TITLE=\u5907\u6CE8 +ypydxc27_display.TITLE=\u6837\u54C1\u5DF2\u5230\u8FBE\u73B0\u573A +sysj27_display.TITLE=\u6536\u6837\u65F6\u95F4 +syr27_display.TITLE=\u6536\u6837\u4EBA +ypshjg27_display.TITLE=\u6837\u54C1\u5BA1\u6838\u7ED3\u679C +yqwcsj27_display.TITLE=\u9884\u671F\u5B8C\u6210\u65F6\u95F4 +thyy27_display.TITLE=\u9000\u56DE\u539F\u56E0 +jcrwzb27_display.TITLE=\u68C0\u6D4B\u4EFB\u52A1\u4E3B\u529E +jcrwxb27_display.TITLE=\u68C0\u6D4B\u4EFB\u52A1\u534F\u529E +jhkssj27_display.TITLE=\u8BA1\u5212\u5F00\u59CB\u65F6\u95F4 +jhwcsj27_display.TITLE=\u8BA1\u5212\u5B8C\u6210\u65F6\u95F4 +djdywtd27_display.TITLE=\u70B9\u51FB\u6253\u5370\u59D4\u6258\u5355 +djdyypbs27_display.TITLE=\u70B9\u51FB\u6253\u5370\u6837\u54C1\u6807\u8BC6 +sjwcsj27_display.TITLE=\u5B9E\u9645\u5B8C\u6210\u65F6\u95F4 +jcjgsm27_display.TITLE=\u68C0\u6D4B\u7ED3\u679C\u8BF4\u660E +ypcz27_display.TITLE=\u6837\u54C1\u5904\u7F6E +cywz27_display.TITLE=\u5B58\u6837\u4F4D\u7F6E +shsj27_display.TITLE=\u5BA1\u6838\u65F6\u95F4 +shy27_display.TITLE=\u5BA1\u6838\u5458 +shjg27_display.TITLE=\u5BA1\u6838\u7ED3\u679C +wtxx27_display.TITLE=\u59D4\u6258\u4FE1\u606F +clfx27_display.TITLE=\u6750\u6599\u5206\u6790 +jljc27_display.TITLE=\u8BA1\u91CF\u68C0\u6D4B +wtnr27_display.TITLE=\u59D4\u6258\u5185\u5BB9 +zygyk28_display.TITLE=\u4F5C\u4E1A\u5DE5\u827A\u5361 +gsmc28_display.TITLE=\u516C\u53F8\u540D\u79F0 +ljdh28_display.TITLE=\u96F6\u4EF6\u4EE3\u53F7 +sbxh28_display.TITLE=\u4EA7\u54C1\u540D\u79F0 +bgx28_display.TITLE=\u672C\u5DE5\u5E8F +sbmc28_display.TITLE=\u8BBE\u5907\u540D\u79F0 +gzmx28_display.TITLE=\u5DE5\u88C5\u660E\u7EC6 +jgcs28_display.TITLE=\u52A0\u5DE5\u53C2\u6570 +cptxkzyq28_display.TITLE=\u4EA7\u54C1\u7279\u6027\u63A7\u5236\u8981\u6C42 +zpgyk29_display.TITLE=\u88C5\u914D\u5DE5\u827A\u5361 +gsmc29_display.TITLE=\u516C\u53F8\u540D\u79F0 +ljdh29_display.TITLE=\u96F6\u4EF6\u4EE3\u53F7 +sbxh29_display.TITLE=\u8BBE\u5907\u578B\u53F7 +zyjzs30_display.TITLE=\u4F5C\u4E1A\u57FA\u51C6\u4E66 +xzdclj31_display.TITLE=\u9009\u62E9\u5BFC\u51FA\u8DEF\u5F84 +wjmc31_display.TITLE=\u6587\u4EF6\u540D\u79F0 +jyjzs33_display.TITLE=\u68C0\u9A8C\u57FA\u51C6\u4E66 +bzbz34_display.TITLE=\u5305\u88C5\u6807\u51C6 +ljh34_display.TITLE=\u96F6\u4EF6\u53F7 +ljmc34_display.TITLE=\u96F6\u4EF6\u540D\u79F0 +gys34_display.TITLE=\u4F9B\u5E94\u5546 +gysdh34_display.TITLE=\u4F9B\u5E94\u5546\u4EE3\u53F7 +syzcdmmc34_display.TITLE=\u9002\u7528\u603B\u6210\u4EE3\u7801/\u540D\u79F0 +ljdw(tg)34_display.TITLE=\u96F6\u4EF6\u5355\u4F4D\uFF08\u5957/\u4E2A\uFF09 +ljgg34_display.TITLE=\u96F6\u4EF6\u89C4\u683C\uFF08mm\uFF09 +ljzl34_display.TITLE=\u96F6\u4EF6\u91CD\u91CF\uFF08kg\uFF09 +bzbzclfhdjyms34_display.TITLE=\u5305\u88C5\u3001\u5305\u88C5\u6750\u6599\u3001\u9632\u62A4\u7B49\u7B80\u8981\u63CF\u8FF0 +bqgshwz34_display.TITLE=\u6807\u7B7E\u683C\u5F0F\u548C\u4F4D\u7F6E +zt35_display.TITLE=\u72B6\u6001 +wtdsh35_display.TITLE=\u59D4\u6258\u5355\u5BA1\u6838 +gzfp35_display.TITLE=\u5DE5\u4F5C\u5206\u914D +scjl35_display.TITLE=\u4E0A\u4F20\u8BB0\u5F55 +wtrq35_display.TITLE=\u59D4\u6258\u65E5\u671F +wtdh35_display.TITLE=\u59D4\u6258\u5355\u53F7 +wtdw35_display.TITLE=\u59D4\u6258\u5355\u4F4D +jclx35_display.TITLE=\u68C0\u6D4B\u7C7B\u578B +xmdj35_display.TITLE=\u9879\u76EE\u7B49\u7EA7 +ycwcrq35_display.TITLE=\u9884\u671F\u5B8C\u6210\u65E5\u671F +jhwcrq35_display.TITLE=\u8BA1\u5212\u5B8C\u6210\u65E5\u671F +zbry35_display.TITLE=\u4E3B\u529E\u4EBA\u5458 +lcjs35_display.TITLE=\u6D41\u7A0B\u76D1\u89C6 +dqzt35_display.TITLE=\u5F53\u524D\u72B6\u6001 +wtdhypsh35_display.TITLE=\u59D4\u6258\u5355\u548C\u6837\u54C1\u5BA1\u6838 +gzfp35_display.TITLE=\u5DE5\u4F5C\u5206\u914D +scjg35_display.TITLE=\u4E0A\u4F20\u7ED3\u679C +sywtd41_display.TITLE=\u8BD5\u9A8C\u59D4\u6258\u5355 +wtdbh41_display.TITLE=\u59D4\u6258\u5355\u7F16\u53F7\uFF1A +scdw41_display.TITLE=\u751F\u4EA7\u5355\u4F4D +ccxh41_display.TITLE=\u8F74\u627F\u578B\u53F7 +sych41_display.TITLE=\u4F7F\u7528\u573A\u5408 +xmmc41_display.TITLE=\u9879\u76EE\u540D\u79F0 +xmbh41_display.TITLE=\u9879\u76EE\u7F16\u53F7 +xmdj41_display.TITLE=\u9879\u76EE\u7B49\u7EA7 +wtsylx41_display.TITLE=\u59D4\u6258\u8BD5\u9A8C\u7C7B\u578B +yzsy41_display.TITLE=\u9A8C\u8BC1\u8BD5\u9A8C +tzxxsy41_display.TITLE=\u7279\u79CD\u65B0\u578B\u8BD5\u9A8C +khyq41_display.TITLE=\u5BA2\u6237\u8981\u6C42 +sybj41_display.TITLE=\u8BD5\u9A8C\u80CC\u666F +symd41_display.TITLE=\u8BD5\u9A8C\u76EE\u7684 +sygfsjry41_display.TITLE=\u8BD5\u9A8C\u89C4\u8303\uFF08\u8BBE\u8BA1\u4EBA\u5458\uFF09 +yjgsyry41_display.TITLE=\u5DF2\u4EA4\u7ED9\u8BD5\u9A8C\u4EBA\u5458 +qtsyyq41_display.TITLE=\u5176\u4ED6\u8BD5\u9A8C\u8981\u6C42 +wtr41_display.TITLE=\u59D4\u6258\u4EBA +lxfs41_display.TITLE=\u8054\u7CFB\u65B9\u5F0F +gsdz41_display.TITLE=\u516C\u53F8\u5730\u5740 +gscz41_display.TITLE=\u516C\u53F8\u4F20\u771F +shr41_display.TITLE=\u5BA1\u6838\u4EBA +shrq41_display.TITLE=\u5BA1\u6838\u65E5\u671F +zjlpz41_display.TITLE=\u603B\u7ECF\u7406\u6279\u51C6 +sywtftx41_display.TITLE=\u8BD5\u9A8C\u59D4\u6258\u65B9\u586B\u5199 +psjl41_display.TITLE=\u8BC4\u5BA1\u8BB0\u5F55 +jhkssj41_display.TITLE=\u8BA1\u5212\u5F00\u59CB\u65F6\u95F4 +jhjssj41_display.TITLE=\u8BA1\u5212\u7ED3\u675F\u65F6\u95F4 +syfzr41_display.TITLE=\u8BD5\u9A8C\u8D1F\u8D23\u4EBA +lxdh41_display.TITLE=\u8054\u7CFB\u7535\u8BDD +psrq41_display.TITLE=\u8BC4\u5BA1/\u65E5\u671F +pzrq41_display.TITLE=\u6279\u51C6/\u65E5\u671F +swtftx41_display.TITLE=\u53D7\u59D4\u6258\u65B9\u586B\u5199 +bz41_display.TITLE=\u5907\u6CE8 +gzsjtd41_display.TITLE=\u5DE5\u88C5\u8BBE\u8BA1\u56E2\u961F +xzscgztz41_display.TITLE=\u9009\u62E9\u4E0A\u4F20\u5DE5\u88C5\u56FE\u7EB8 +qxzyscdwj41_display.TITLE=\u8BF7\u9009\u62E9\u8981\u4E0A\u4F20\u7684\u6587\u4EF6... +qd41_display.TITLE=\u786E\u5B9A +gzsjwcrq141_display.TITLE=\u5DE5\u88C5\u8BBE\u8BA1\u5B8C\u6210\u65E5\u671F +gzsj141_display.TITLE=\u5DE5\u88C5\u8BBE\u8BA1 +gzdhrq41_display.TITLE=\u5DE5\u88C5\u5230\u8D27\u65E5\u671F +gzsjrq41_display.TITLE=\u5DE5\u88C5\u9001\u68C0\u65E5\u671F +gzsjwcrq41_display.TITLE=\u5DE5\u88C5\u9001\u68C0\u5B8C\u6210\u65E5\u671F +gzjcbgbh41_display.TITLE=\u5DE5\u88C5\u68C0\u6D4B\u62A5\u544A\uFF08\u8BB0\u5F55\uFF09\u7F16\u53F7 +gzsj41_display.TITLE=\u5DE5\u88C5\u9001\u68C0 +ypdyrq41_display.TITLE=\u6837\u54C1\u5230\u6837\u65E5\u671F +syqypjcwcrq41_display.TITLE=\u8BD5\u9A8C\u524D\u6837\u54C1\u68C0\u6D4B\u5B8C\u6210\u65E5\u671F +syqypjcbgbh41_display.TITLE=\u8BD5\u9A8C\u524D\u6837\u54C1\u68C0\u6D4B\u62A5\u544A\uFF08\u8BB0\u5F55\uFF09\u7F16\u53F7 +syksrq41_display.TITLE=\u8BD5\u9A8C\u5F00\u59CB\u65E5\u671F +sywcrq41_display.TITLE=\u8BD5\u9A8C\u5B8C\u6210\u65E5\u671F +syss41_display.TITLE=\u8BD5\u9A8C\u5B9E\u65BD +syhypjcwcrq41_display.TITLE=\u8BD5\u9A8C\u540E\u6837\u54C1\u68C0\u6D4B\u5B8C\u6210\u65E5\u671F +syhypjcbg41_display.TITLE=\u8BD5\u9A8C\u540E\u6837\u54C1\u68C0\u6D4B\u62A5\u544A\uFF08\u8BB0\u5F55\uFF09\u7F16\u53F7 +ypjc41_display.TITLE=\u6837\u54C1\u68C0\u6D4B +xzscsybg41_display.TITLE=\u9009\u62E9\u4E0A\u4F20\u8BD5\u9A8C\u62A5\u544A +sywcrq241_display.TITLE=\u8BD5\u9A8C\u5B8C\u6210\u65E5\u671F +sybgbh41_display.TITLE=\u8BD5\u9A8C\u62A5\u544A\u7F16\u53F7 +sybg241_display.TITLE=\u8BD5\u9A8C\u62A5\u544A +sywtd241_display.TITLE=\u8BD5\u9A8C\u59D4\u6258\u5355 +sykxljap41_display.TITLE=\u8BD5\u9A8C\u53EF\u884C\uFF0C\u7ACB\u5373\u5B89\u6392 +sybkx41_display.TITLE=\u8BD5\u9A8C\u4E0D\u53EF\u884C +zybcfjywwsy41_display.TITLE=\u8D44\u6E90\u4E0D\u5145\u5206\uFF0C\u5EFA\u8BAE\u59D4\u5916\u8BD5\u9A8C +qijy241_display.TITLE=\u5176\u4ED6\u5EFA\u8BAE +btxxbnwk41_display.TITLE=\u5FC5\u586B\u9879\u4E0D\u80FD\u4E3A\u7A7A\uFF01 +gzcg41_display.TITLE=\u5DE5\u88C5\u91C7\u8D2D +xqsp41_display.TITLE=\u9700\u6C42\u5BA1\u6279 + + + +fxwtd40_display.TITLE=\u5206\u6790\u59D4\u6258\u5355 +CEAwtd40_display.TITLE=CAE\u59D4\u6258\u5355 +wtdbh40_display.TITLE=\u59D4\u6258\u5355\u7F16\u53F7\uFF1A +kemc40_display.TITLE=\u5BA2\u6237\u540D\u79F0 +xmsstd40_display.TITLE=\u9879\u76EE\u6240\u5C5E\u56E2\u961F +xmmc40_display.TITLE=\u9879\u76EE\u540D\u79F0 +xmjl40_display.TITLE=\u9879\u76EE\u7ECF\u7406 +xmdj40_display.TITLE=\u9879\u76EE\u7B49\u7EA7 +sjbsstd40_display.TITLE=\u8BBE\u8BA1\u90E8\u6240\u5C5E\u56E2\u961F +xmbh40_display.TITLE=\u9879\u76EE\u7F16\u53F7 +sjfzr40_display.TITLE=\u8BBE\u8BA1\u8D1F\u8D23\u4EBA +xmlx40_display.TITLE=\u9879\u76EE\u7C7B\u578B +qwwcsj40_display.TITLE=\u671F\u671B\u5B8C\u6210\u65F6\u95F4 +jbxx40_display.TITLE=1.\u57FA\u672C\u4FE1\u606F +scfxry40_display.TITLE=\u4E0A\u6B21\u5206\u6790\u4EBA\u5458 +scbgsj40_display.TITLE=\u4E0A\u6B21\u62A5\u544A\u65F6\u95F4 +ggd40_display.TITLE=\u66F4\u6539\u70B9 +ggyy40_display.TITLE=\u66F4\u6539\u539F\u56E0 +srzl40_display.TITLE=2.\u8F93\u5165\u8D44\u6599 +cjtd40_display.TITLE=\u627F\u63A5\u56E2\u961F +xmwtsj40_display.TITLE=\u9879\u76EE\u59D4\u6258\u65F6\u95F4 +cjr40_display.TITLE=\u627F\u63A5\u4EBA +xmggcs40_display.TITLE=\u9879\u76EE\u66F4\u6539\u6B21\u6570 +xbr40_display.TITLE=\u534F\u529E\u4EBA +jhkssj40_display.TITLE=\u8BA1\u5212\u5F00\u59CB\u65F6\u95F4 +Romaxjf40_display.TITLE=Romax\u79EF\u5206 +jsxqts40_display.TITLE=\u8BA1\u7B97\u9700\u6C42\u5929\u6570 +yxyjf40_display.TITLE=\u6709\u9650\u5143\u79EF\u5206 +jswcsj40_display.TITLE=\u8BA1\u7B97\u5B8C\u6210\u65F6\u95F4 +xmcjxx40_display.TITLE=3.\u9879\u76EE\u627F\u63A5\u4FE1\u606F +bghjgmc40_display.TITLE=\u62A5\u544A\u6216\u7ED3\u679C\u540D\u79F0 +bgbh40_display.TITLE=\u62A5\u544A\u7F16\u53F7 +bghjgscsj40_display.TITLE=\u62A5\u544A\u6216\u7ED3\u679C\u4E0A\u4F20\u65F6\u95F4 +bghjgfk40_display.TITLE=4.\u62A5\u544A\u6216\u7ED3\u679C\u53CD\u9988 +jdr40_display.TITLE=\u6821\u5BF9\u4EBA +jdsj40_display.TITLE=\u6821\u5BF9\u65F6\u95F4 +jdjg40_display.TITLE=\u6821\u5BF9\u7ED3\u679C +thyy40_display.TITLE=\u9000\u56DE\u539F\u56E0 +bghjgjd40_display.TITLE=5.\u62A5\u544A\u6216\u7ED3\u679C\u6821\u5BF9 +khmc40_display.TITLE=\u5BA2\u6237\u540D\u79F0 +xmbssty40_display.TITLE=\u9879\u76EE\u90E8\u6240\u5C5E\u56E2\u961F +sybw40_display.TITLE=\u4F7F\u7528\u90E8\u4F4D +srzl40_display.TITLE=2.\u8F93\u5165\u8D44\u6599 +bxqrbgxxx40_display.TITLE=\u5FC5\u987B\u786E\u8BA4\u5E76\u52FE\u9009\u4FE1\u606F +jsscxm40_display.TITLE=\u8BA1\u7B97\u8F93\u51FA\u9879\u76EE +kgxxx40_display.TITLE=\u53EF\u52FE\u9009\u4FE1\u606F +ydndqjddjgzwd40_display.TITLE=\u8FD0\u52A8\u7C98\u5EA6\u3001\u6E05\u6D01\u5EA6\u7B49\u7EA7\u3001\u5DE5\u4F5C\u6E29\u5EA6 +EPtjj40_display.TITLE=EP\u6DFB\u52A0\u5242 +ysr40_display.TITLE=\u9884\u5BA1\u4EBA +yssj40_display.TITLE=\u9884\u5BA1\u65F6\u95F4 +ysjg40_display.TITLE=\u9884\u5BA1\u7ED3\u679C +zbdzys40_display.TITLE=1.\u503C\u73ED\u56E2\u961F\u957F\u9884\u5BA1 +wtdbh240_display.TITLE=\u59D4\u6258\u5355\u7F16\u53F7 +jhwcsj40_display.TITLE=\u8BA1\u5212\u5B8C\u6210\u65F6\u95F4 +xmcjxx240_display.TITLE=2.\u9879\u76EE\u627F\u63A5\u4FE1\u606F +jsfxjm40_display.TITLE=\u8BA1\u7B97\u5206\u6790\u5EFA\u6A21 +bczlsj40_display.TITLE=\u8865\u5145\u8D44\u6599\u65F6\u95F4 +zyss40_display.TITLE=3.\u4F5C\u4E1A\u5B9E\u65BD +bghjgfk240_display.TITLE=4.\u62A5\u544A\u6216\u7ED3\u679C\u53CD\u9988 +bghjgjd240_display.TITLE=5.\u62A5\u544A\u6216\u7ED3\u679C\u6821\u5BF9 +CAEfxxqwtd40_display.TITLE=CAE\u5206\u6790\u9700\u6C42\u59D4\u6258\u5355 +jsfxtdcjd40_display.TITLE=\u8BA1\u7B97\u5206\u6790\u56E2\u961F\u627F\u63A5\u5355 +ggxmwtd40_display.TITLE=\u66F4\u6539\u9879\u76EE\u59D4\u6258\u5355 +tk_display.TITLE=\u56FE\u5E93 + + +ljgybh04_display.TITLE=\u96F6\u4EF6/\u5DE5\u827A\u7F16\u53F7 +gcmc04_display.TITLE=\u8FC7\u7A0B\u540D\u79F0 +jqsbgzjj04_display.TITLE=\u673A\u5668,\u8BBE\u5907,\u5DE5\u88C5\uFF0C\u5939\u5177 +smjyzyzb04_display.TITLE=\u9996\u672B\u68C0\u9A8C/\u4F5C\u4E1A\u51C6\u5907 +bh04_display.TITLE=\u7F16\u53F7 +cp04_display.TITLE=\u4EA7\u54C1 +gc04_display.TITLE=\u8FC7\u7A0B +tstxfl04_display.TITLE=\u7279\u6B8A\u7279\u6027\u5206\u7C7B +cpgcgfgc04_display.TITLE=\u4EA7\u54C1/\u8FC7\u7A0B/\u89C4\u683C/\u516C\u5DEE +pgclff04_display.TITLE=\u8BC4\u4F30/\u6D4B\u91CF\u65B9\u6CD5 +rl04_display.TITLE=\u5BB9\u91CF +pl04_display.TITLE=\u9891\u7387 +kzff04_display.TITLE=\u63A7\u5236\u65B9\u6CD5 +fyjh04_display.TITLE=\u53CD\u5E94\u8BA1\u5212 +tsfhwz04_display.TITLE=\u7279\u6B8A\u7B26\u53F7\u4F4D\u7F6E +sfwc04_display.TITLE=\u662F\u5426\u5B8C\u6210 +fjdID04_display.TITLE=\u7236\u8282\u70B9ID +tszfszwz04_display.TITLE=\u7279\u6B8A\u5B57\u7B26\u6240\u5728\u4F4D\u7F6E +xh04_display.TITLE=\u5E8F\u53F7 +z04_display.TITLE=\u503C +mc04_display.TITLE=\u540D\u79F0 +gysjfdygc34_display.TITLE=\u4F9B\u5E94\u5546\u4EA4\u4ED8\u5355\u5143\u6784\u6210 +yjbz34_display.TITLE=\u4E00\u7EA7\u5305\u88C5 +ejbz34_display.TITLE=\u4E8C\u7EA7\u5305\u88C5 +sjbz34_display.TITLE=\u4E09\u7EA7\u5305\u88C5 + + + +wxzcpdxqcxxz02_display.TITLE=\u672A\u9009\u4E2D\u4EA7\u54C1\u5BF9\u8C61\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\uFF01 +qxzzcdxhcj02_display.TITLE=\u8BF7\u9009\u62E9\u603B\u6210\u5BF9\u8C61\u540E\u521B\u5EFA +gy02_display.TITLE=\u5DE5\u827A +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/util/Adapter.java b/src/com/connor/renben/process/plm/util/Adapter.java new file mode 100644 index 0000000..00576ef --- /dev/null +++ b/src/com/connor/renben/process/plm/util/Adapter.java @@ -0,0 +1,299 @@ +package com.connor.renben.process.plm.util; + +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.StringSelection; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.util.ArrayList; +import java.util.List; +import java.util.StringTokenizer; + +import javax.swing.JComponent; +import javax.swing.JOptionPane; +import javax.swing.JTable; +import javax.swing.KeyStroke; + +/** + * Adapter 实现 JTables 中的复制粘贴 剪贴板功能。 适配器所用的剪贴板数据格式 与 Excel 所用的剪贴板格式兼容。这提供了 + * 支持的 JTables 和 Excel 间的互操作。 + */ +public class Adapter implements ActionListener { + private String rowstring, value; + private Clipboard system; + private StringSelection stsel; + private JTable jTable1; + private List> selectValue = new ArrayList>(); + + /** + * Excel 适配器由 JTable 构成, 它实现了 JTable 上的复制粘贴 功能,并充当剪贴板监听程序。 + */ + + public Adapter(JTable myJTable) { + jTable1 = myJTable; + KeyStroke copy = KeyStroke.getKeyStroke(KeyEvent.VK_C, + ActionEvent.CTRL_MASK, false); + + // 确定复制按键用户可以对其进行修改 + // 以实现其它按键组合的复制功能。 + KeyStroke paste = KeyStroke.getKeyStroke(KeyEvent.VK_V, + ActionEvent.CTRL_MASK, false); + + // 确定粘贴按键用户可以对其进行修改 + // 以实现其它按键组合的复制功能。 + + jTable1.registerKeyboardAction(this, "Copy", copy, + JComponent.WHEN_FOCUSED); + + jTable1.registerKeyboardAction(this, "Paste", paste, + JComponent.WHEN_FOCUSED); + + system = Toolkit.getDefaultToolkit().getSystemClipboard(); + } + + /** + * 此适配器运行图表的公共读方法。 + */ + public JTable getJTable() { + return jTable1; + } + + public void setJTable(JTable jTable1) { + this.jTable1 = jTable1; + } + + /** + * 在我们监听此实现的按键上激活这种方法。 此处,它监听复制和粘贴 ActionCommands。 包含不相邻单元格的选择导致选择无效, + * 而且此后复制动作无法执行。 粘贴的方法是将选定内容的左上角与 JTable 的当前选定内容的第一个元素对齐。 + */ + public void actionPerformed(ActionEvent e) { + if (e.getActionCommand().compareTo("Copy") == 0) { + StringBuffer sbf = new StringBuffer(); + + selectValue.clear(); + // 检查以确保我们仅选择了单元格的 + // 相邻块 + int numcols = jTable1.getSelectedColumnCount(); + int numrows = jTable1.getSelectedRowCount(); + int[] rowsselected = jTable1.getSelectedRows(); + int[] colsselected = jTable1.getSelectedColumns(); + +// if (!((numrows - 1 == rowsselected[rowsselected.length - 1] +// - rowsselected[0] && numrows == rowsselected.length) && (numcols - 1 == colsselected[colsselected.length - 1] +// - colsselected[0] && numcols == colsselected.length))) { +// JOptionPane.showMessageDialog(null, "Invalid Copy Selection", +// "Invalid Copy Selection", JOptionPane.ERROR_MESSAGE); +// +// return; +// } + + for (int i=0;i= 0) + { + sbf.append("\""); + sbf.append(jTable1.getValueAt(rowsselected[i],colsselected[j])); + sbf.append("\""); + } + else if(jTable1.getValueAt(rowsselected[i],colsselected[j]) == null) + { + sbf.append(""); + } + else + { + sbf.append(jTable1.getValueAt(rowsselected[i],colsselected[j])); + } + if (j= 0) + { + sb.append(values[i].replace("\n", " $")); + } + else + { + sb.append(values[i]); + } + //System.out.println(i+s[i]); + } + System.out.println("sb======"+sb.toString()); + String copyValue = sb.toString(); + String[] st1=copyValue.split("\\$"); //new StringTokenizer(sb.toString(),"$".toString()); + + + + int[] rows = jTable1.getSelectedRows(); + int[] columns = jTable1.getSelectedColumns(); + int startRow = rows[0]; + int startCol = columns[0]; + if(rows.length ==1 ) + { + for(int i=0;i= 0) + { + String[] cellValue = rowstring.split("\t"); + for(int j=0;j= 0) + { + String[] cellValue = rowstring.split("\t"); + for (int k = 0; k < cellValue.length; k++) { + value=(String)cellValue[k]; + System.out.println("value============"+value); + jTable1.setValueAt(value.trim(),rows[i],startCol+k); + System.out.println("Putting "+ value+"atrow="+startRow+i+"column="+startCol+k); + } + } + else + { + jTable1.setValueAt(rowstring.trim(),rows[i],startCol); + } + //} + //} + } + } + else //写入选中行内容 + { + for(int i=0;i= 0) + { + String[] cellValue = rowstring.split("\t"); + for(int j=0;j st1.length) + { + for (int i = 0; i < rows.length; i++) { + for (int j = 0; j < columns.length; j++) { + rowstring=st1[(i+st1.length)%st1.length]; + System.out.println("rowstring============"+rowstring); + if(rowstring.indexOf("\t") >= 0) + { + String[] cellValue = rowstring.split("\t"); + for (int k = 0; k < cellValue.length; k++) { + value=(String)cellValue[(j+cellValue.length)%cellValue.length]; + System.out.println("value============"+value); + jTable1.setValueAt(value.trim(),rows[i],columns[j]); + System.out.println("Putting "+ value+"atrow="+startRow+i+"column="+startCol+k); + } + } + else + { + jTable1.setValueAt(rowstring.trim(),rows[i],columns[j]); + } + } + } + } + else + { + for (int i = 0; i < st1.length; i++) { + for (int j = 0; j < columns.length; j++) { + rowstring=st1[(i+st1.length)%st1.length]; + System.out.println("rowstring============"+rowstring); + if(rowstring.indexOf("\t") >= 0) + { + String[] cellValue = rowstring.split("\t"); + for (int k = 0; k < cellValue.length; k++) { + value=(String)cellValue[(j+cellValue.length)%cellValue.length]; + System.out.println("value============"+value); + jTable1.setValueAt(value.trim(),startRow+i,columns[j]); + System.out.println("Putting "+ value+"atrow="+startRow+i+"column="+startCol+k); + } + } + else + { + jTable1.setValueAt(rowstring.trim(),startRow+i,columns[j]); + } + } + } + } + } + } catch (Exception ex) { + ex.printStackTrace(); + } + + } + } +} \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/util/Adapter1.java b/src/com/connor/renben/process/plm/util/Adapter1.java new file mode 100644 index 0000000..b87f851 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/Adapter1.java @@ -0,0 +1,302 @@ +package com.connor.renben.process.plm.util; + +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.StringSelection; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.util.ArrayList; +import java.util.List; +import java.util.StringTokenizer; + +import javax.swing.JComponent; +import javax.swing.JOptionPane; +import javax.swing.JTable; +import javax.swing.KeyStroke; + +/** + * Adapter 实现 JTables 中的复制粘贴 剪贴板功能。 适配器所用的剪贴板数据格式 与 Excel 所用的剪贴板格式兼容。这提供了 + * 支持的 JTables 和 Excel 间的互操作。 + */ +public class Adapter1 implements ActionListener { + private String rowstring, value; + private Clipboard system; + private StringSelection stsel; + private JTable jTable1; + private List> selectValue = new ArrayList>(); + + /** + * Excel 适配器由 JTable 构成, 它实现了 JTable 上的复制粘贴 功能,并充当剪贴板监听程序。 + */ + + public Adapter1(JTable myJTable) { + jTable1 = myJTable; + KeyStroke copy = KeyStroke.getKeyStroke(KeyEvent.VK_C, + ActionEvent.CTRL_MASK, false); + + // 确定复制按键用户可以对其进行修改 + // 以实现其它按键组合的复制功能。 + KeyStroke paste = KeyStroke.getKeyStroke(KeyEvent.VK_V, + ActionEvent.CTRL_MASK, false); + + // 确定粘贴按键用户可以对其进行修改 + // 以实现其它按键组合的复制功能。 + + jTable1.registerKeyboardAction(this, "Copy", copy, + JComponent.WHEN_FOCUSED); + + jTable1.registerKeyboardAction(this, "Paste", paste, + JComponent.WHEN_FOCUSED); + + system = Toolkit.getDefaultToolkit().getSystemClipboard(); + } + + /** + * 此适配器运行图表的公共读方法。 + */ + public JTable getJTable() { + return jTable1; + } + + public void setJTable(JTable jTable1) { + this.jTable1 = jTable1; + } + + /** + * 在我们监听此实现的按键上激活这种方法。 此处,它监听复制和粘贴 ActionCommands。 包含不相邻单元格的选择导致选择无效, + * 而且此后复制动作无法执行。 粘贴的方法是将选定内容的左上角与 JTable 的当前选定内容的第一个元素对齐。 + */ + public void actionPerformed(ActionEvent e) { + if (e.getActionCommand().compareTo("Copy") == 0) { + StringBuffer sbf = new StringBuffer(); + + selectValue.clear(); + // 检查以确保我们仅选择了单元格的 + // 相邻块 + int numcols = jTable1.getSelectedColumnCount(); + int numrows = jTable1.getSelectedRowCount(); + int[] rowsselected = jTable1.getSelectedRows(); + int[] colsselected = jTable1.getSelectedColumns(); + +// if (!((numrows - 1 == rowsselected[rowsselected.length - 1] +// - rowsselected[0] && numrows == rowsselected.length) && (numcols - 1 == colsselected[colsselected.length - 1] +// - colsselected[0] && numcols == colsselected.length))) { +// JOptionPane.showMessageDialog(null, "Invalid Copy Selection", +// "Invalid Copy Selection", JOptionPane.ERROR_MESSAGE); +// +// return; +// } + + for (int i=0;i= 0) + { + sbf.append("\""); + sbf.append(jTable1.getValueAt(rowsselected[i],colsselected[j])); + sbf.append("\""); + } + else if(jTable1.getValueAt(rowsselected[i],colsselected[j]) == null) + { + sbf.append(""); + } + else + { + sbf.append(jTable1.getValueAt(rowsselected[i],colsselected[j])); + } + if (j= 0) + { + sb.append(values[i].replace("\n", " $")); + } + else + { + sb.append(values[i]); + } + //System.out.println(i+s[i]); + } + System.out.println("sb======"+sb.toString()); + String copyValue = sb.toString(); + String[] st1=copyValue.split("\\$"); //new StringTokenizer(sb.toString(),"$".toString()); + + + + int[] rows = jTable1.getSelectedRows(); + int[] columns = jTable1.getSelectedColumns(); + int startRow = rows[0]; + int startCol = columns[0]; + if(rows.length ==1 ) + { + for(int i=0;i= 0) + { + String[] cellValue = rowstring.split("\t"); + for(int j=0;j= 0) + { + String[] cellValue = rowstring.split("\t"); + for (int k = 0; k < cellValue.length; k++) { + value=(String)cellValue[k]; + System.out.println("value============"+value); + jTable1.setValueAt(value.trim(),rows[i],startCol+k); + System.out.println("Putting "+ value+"atrow="+startRow+i+"column="+startCol+k); + } + } + else + { + jTable1.setValueAt(rowstring.trim(),rows[i],startCol); + } + //} + //} + } + } + else //写入选中行内容 + { + for(int i=0;i= 0) + { + String[] cellValue = rowstring.split("\t"); + for(int j=0;j st1.length) + { + for (int i = 0; i < rows.length; i++) { + for (int j = 0; j < columns.length; j++) { + rowstring=st1[(i+st1.length)%st1.length]; + System.out.println("rowstring============"+rowstring); + if(rowstring.indexOf("\t") >= 0) + { + String[] cellValue = rowstring.split("\t"); + for (int k = 0; k < cellValue.length; k++) { + value=(String)cellValue[(j+cellValue.length)%cellValue.length]; + System.out.println("value============"+value); + jTable1.setValueAt(value.trim(),rows[i],columns[j]); + System.out.println("Putting "+ value+"atrow="+startRow+i+"column="+startCol+k); + } + } + else + { + jTable1.setValueAt(rowstring.trim(),rows[i],columns[j]); + } + } + } + } + else + { + for (int i = 0; i < st1.length; i++) { + for (int j = 0; j < columns.length; j++) { + rowstring=st1[(i+st1.length)%st1.length]; + System.out.println("rowstring============"+rowstring); + if(rowstring.indexOf("\t") >= 0) + { + String[] cellValue = rowstring.split("\t"); + for (int k = 0; k < cellValue.length; k++) { + value=(String)cellValue[(j+cellValue.length)%cellValue.length]; + System.out.println("value============"+value); + jTable1.setValueAt(value.trim(),startRow+i,columns[j]); + System.out.println("Putting "+ value+"atrow="+startRow+i+"column="+startCol+k); + } + } + else + { + jTable1.setValueAt(rowstring.trim(),startRow+i,columns[j]); + } + } + } + } + } + } catch (Exception ex) { + ex.printStackTrace(); + } + + } + } +} \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/util/CTMap.java b/src/com/connor/renben/process/plm/util/CTMap.java new file mode 100644 index 0000000..acd13de --- /dev/null +++ b/src/com/connor/renben/process/plm/util/CTMap.java @@ -0,0 +1,396 @@ +package com.connor.renben.process.plm.util; + +import java.awt.Dimension; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Vector; + +import javax.swing.JOptionPane; +import javax.swing.event.TableModelEvent; +import javax.swing.table.DefaultTableModel; + + +//import com.connor.hs.plm.GCLCT.JTableDemo; +import com.teamcenter.rac.util.MessageBox; + +public class CTMap extends DefaultTableModel implements CellSpan { + protected int rowSize; + protected int columnSize; + protected int[][][] span; // CellSpan + protected boolean isEditable = true; + + private int row = -1; + private int column = -1; + + public int getRow() { + return row; + } + + public void setRow(int row) { + this.row = row; + } + + public int getColumn() { + return column; + } + + public void setColumn(int column) { + this.column = column; + } + + public void setEditable(boolean isEditable) { + this.isEditable = isEditable; + } + + private List processRowList; + + public List getProcessRowList() { + return processRowList; + } + + public void setProcessRowList(List processRowList) { + this.processRowList = processRowList; + } + +// Class[] columnTypes = new Class[]{ +// Object.class, Boolean.class +// }; +// +// @Override +// public Class getColumnClass(int columnIndex) { +// if(columnIndex>=2) { +// return columnTypes[0]; +// }else { +// return columnTypes[columnIndex]; +// } +// +// } + + @Override + public void removeRow(int row) { + // 将可修改的行-1 + if (processRowList != null && processRowList.size() > 0) { + for (int i = processRowList.size() - 1; i >= 0; i--) { + if (processRowList.get(i) != null + && processRowList.get(i) == row) { + processRowList.remove(i); + } else if (processRowList.get(i) != null + && processRowList.get(i) > row) { + processRowList.set(i, processRowList.get(i) - 1); + } + } + } + super.removeRow(row); + } + + @Override + public int[] getSpan(int row, int column) { + // TODO Auto-generated method stub + if (isOutOfBounds(row, column)) { + int[] ret_code = { 1, 1 }; + return ret_code; + } + return span[row][column]; + } + + @Override + public void setSpan(int[] span, int row, int column) { + // TODO Auto-generated method stub + if (isOutOfBounds(row, column)) + return; + this.span[row][column] = span; + } + + @Override + public boolean isVisible(int row, int column) { + // TODO Auto-generated method stub + if (isOutOfBounds(row, column)) + return false; + if ((span[row][column][CellSpan.COLUMN] < 1) + || (span[row][column][CellSpan.ROW] < 1)) + return false; + return true; + } + + @Override + public boolean isCellEditable(int arg0, int arg1) { + if ((arg0 == row && arg1 == column) || arg1 ==1) { + return this.isEditable; + } else { + return false; + } + } + + public void setSize(Dimension size) { + columnSize = size.width; + rowSize = size.height; + span = new int[rowSize][columnSize][2]; // 2: COLUMN,ROW + initValue(); + } + + protected boolean isOutOfBounds(int row, int column) { + if ((row < 0) || (rowSize <= row) || (column < 0) + || (columnSize <= column)) { + return true; + } + return false; + } + + public void addRow() { + + Vector newData = new Vector(getColumnCount()); + dataVector.add(newData); + + // + newRowsAdded(new TableModelEvent(this, getRowCount() - 1, + getRowCount() - 1, TableModelEvent.ALL_COLUMNS, + TableModelEvent.INSERT)); + int[][][] oldSpan = span; + int numRows = oldSpan.length; + int numColumns = oldSpan[0].length; + span = new int[numRows + 1][numColumns][2]; + System.arraycopy(oldSpan, 0, span, 0, numRows); + for (int i = 0; i < numColumns; i++) { + span[numRows][i][CellSpan.COLUMN] = 1; + span[numRows][i][CellSpan.ROW] = 1; + } + rowSize = span.length; + } + + public void addColumn(Object columnName) { + + int[][][] oldSpan = span; + int numRows = oldSpan.length; + int numColumns = oldSpan[0].length; + span = new int[numRows][numColumns + 1][2]; + for (int i = 0; i < span.length; i++) { + for (int j = 0; j < span[0].length; j++) { + span[i][j][CellSpan.COLUMN] = 1; + span[i][j][CellSpan.ROW] = 1; + } + } + + columnSize = span[0].length; + addColumn(columnName, (Vector) null); + } + + @Override + public void combine(int[] rows, int[] columns) { + // TODO Auto-generated method stub + + int rowSpan = rows.length; + int columnSpan = columns.length; + int startRow = rows[0]; + int startColumn = columns[0]; + for (int i = 0; i < rowSpan; i++) { + for (int j = 0; j < columnSpan; j++) { + if ((span[startRow + i][startColumn + j][CellSpan.COLUMN] != 1) + || (span[startRow + i][startColumn + j][CellSpan.ROW] != 1)) { + // System.out.println("can't combine"); + return; + } + } + } + for (int i = 0, ii = 0; i < rowSpan; i++, ii--) { + for (int j = 0, jj = 0; j < columnSpan; j++, jj--) { + span[startRow + i][startColumn + j][CellSpan.COLUMN] = jj; + span[startRow + i][startColumn + j][CellSpan.ROW] = ii; + // System.out.println("r " +ii +" c " +jj); + } + } + span[startRow][startColumn][CellSpan.COLUMN] = columnSpan; + span[startRow][startColumn][CellSpan.ROW] = rowSpan; + } + public Map insertRowComb(int row, Map combineMap) { + Vector rowData = new Vector(getColumnCount()); + int index = 0; + + dataVector.insertElementAt(rowData, row); + System.out.println("size: and combine" + dataVector.size()); + newRowsAdded(new TableModelEvent(this, row, row, + TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT)); + int[][][] newSpan = new int[span.length + 1][span[0].length][2]; + + int numRows = span.length; + int numColumns = span[0].length; + for (int i = 0; i < newSpan.length; i++) { + if (i < row) { + for (int j = 0; j < numColumns; j++) { + newSpan[i][j][0] = 1; // span[i][j][0]; + newSpan[i][j][1] = 1; // span[i][j][1]; + // newSpan[i][j][0] = 1; + // newSpan[i][j][1] = 1; + } + } else if (i == row) { + for (int j = 0; j < numColumns; j++) { + newSpan[i][j][0] = 1; + newSpan[i][j][1] = 1; + } + } else { + for (int j = 0; j < numColumns; j++) { + newSpan[i][j][0] = 1; //span[i - 1][j][0]; + newSpan[i][j][1] = 1; //span[i - 1][j][1]; + } + } + } + span = newSpan; + rowSize = newSpan.length;// 将可修改的行+1 + + Map combineNewMap = new HashMap(); + addNewCombine(combineMap,row,combineNewMap); + System.out.println("size: and combine new" + combineNewMap.toString()); + combineMap = combineNewMap; + if (combineMap != null && combineMap.size() != 0) { + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + combine(entry.getKey(), entry.getValue()); + } + } + + return combineNewMap; + } + private void addNewCombine(Map combineMap,int row,Map combineNewMap) { + // TODO Auto-generated method stub + if (combineMap != null && combineMap.size() != 0) { + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + int[] key = entry.getKey(); + int[] value = entry.getValue(); + if(key[0]>=row) { + + int[] keyN = new int[key.length]; + for(int t = 0; trow && key[0] 0) { + + for (int i = processRowList.size() - 1; i >= 0; i--) { + if (!processRowList.contains(row) + && processRowList.get(i) != null + && processRowList.get(i) == row - 1) { + index = i + 1; + processRowList.add(i + 1, row); + } else if (processRowList.get(i) != null + && processRowList.get(i) == row) { + index = i + 1; + processRowList.add(i + 1, row + 1); + } else if (processRowList.get(i) != null && i > index + && processRowList.get(i) >= row) { + processRowList.set(i, processRowList.get(i) + 1); + } + } + } + + } + + public CTMap(int numRows, int numColumns) { + Vector names = new Vector(numColumns); + names.setSize(numColumns); + setColumnIdentifiers(names); + dataVector = new Vector(); + setNumRows(numRows); + setSize(new Dimension(numColumns, numRows)); + + + } + + protected void initValue() { + System.out.println(span.length); + for (int i = 0; i < span.length; i++) { + for (int j = 0; j < span[i].length; j++) { + span[i][j][CellSpan.COLUMN] = 1; + span[i][j][CellSpan.ROW] = 1; + } + } + } + + public void split(int row, int column) { + if (isOutOfBounds(row, column)) + return; + int columnSpan = span[row][column][CellSpan.COLUMN]; + int rowSpan = span[row][column][CellSpan.ROW]; + for (int i = 0; i < rowSpan; i++) { + for (int j = 0; j < columnSpan; j++) { + span[row + i][column + j][CellSpan.COLUMN] = 1; + span[row + i][column + j][CellSpan.ROW] = 1; + } + } + } + + public void removeCol() { + + columnIdentifiers.removeElementAt(columnIdentifiers.size() - 1); + dataVector.setSize(getRowCount()); + + for (int i = 0; i < getRowCount() - 1; i++) { + + ((Vector) dataVector.elementAt(i)).setSize(getColumnCount()); + } + fireTableStructureChanged(); + } +} diff --git a/src/com/connor/renben/process/plm/util/CTMap2.java b/src/com/connor/renben/process/plm/util/CTMap2.java new file mode 100644 index 0000000..e3fa8d5 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/CTMap2.java @@ -0,0 +1,356 @@ +package com.connor.renben.process.plm.util; + +import java.awt.Dimension; +import java.util.List; +import java.util.Vector; + +import javax.swing.event.TableModelEvent; + +import java.awt.Dimension; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.util.List; +import java.util.Vector; + +import javax.swing.JOptionPane; +import javax.swing.event.TableModelEvent; +import javax.swing.table.DefaultTableModel; + +//import com.connor.hs.plm.GCLCT.JTableDemo; +import com.teamcenter.rac.util.MessageBox; + +public class CTMap2 extends DefaultTableModel implements CellSpan{ + protected int rowSize; + protected int columnSize; + protected int[][][] span; // CellSpan + protected boolean isEditable = true; + + private int row = -1; + private int column = -1; + + public int getRow() { + return row; + } + + public void setRow(int row) { + this.row = row; + } + + public int getColumn() { + return column; + } + + public void setColumn(int column) { + this.column = column; + } + + public void setEditable(boolean isEditable) { + this.isEditable = isEditable; + } + + private List processRowList; + + public List getProcessRowList() { + return processRowList; + } + + public void setProcessRowList(List processRowList) { + this.processRowList = processRowList; + } + +// Class[] columnTypes = new Class[]{ +// Object.class, Boolean.class +// }; +// +// @Override +// public Class getColumnClass(int columnIndex) { +// if(columnIndex==1) { +// return columnTypes[1]; +// }else { +// return columnTypes[0]; +// } +// +// } + + @Override + public void removeRow(int row) { + // 将可修改的行-1 + if (processRowList != null && processRowList.size() > 0) { + for (int i = processRowList.size() - 1; i >= 0; i--) { + if (processRowList.get(i) != null + && processRowList.get(i) == row) { + processRowList.remove(i); + } else if (processRowList.get(i) != null + && processRowList.get(i) > row) { + processRowList.set(i, processRowList.get(i) - 1); + } + } + } + super.removeRow(row); + } + + @Override + public int[] getSpan(int row, int column) { + // TODO Auto-generated method stub + if (isOutOfBounds(row, column)) { + int[] ret_code = { 1, 1 }; + return ret_code; + } + return span[row][column]; + } + + @Override + public void setSpan(int[] span, int row, int column) { + // TODO Auto-generated method stub + if (isOutOfBounds(row, column)) + return; + this.span[row][column] = span; + } + + @Override + public boolean isVisible(int row, int column) { + // TODO Auto-generated method stub + if (isOutOfBounds(row, column)) + return false; + if ((span[row][column][CellSpan.COLUMN] < 1) + || (span[row][column][CellSpan.ROW] < 1)) + return false; + return true; + } + public void combine(int[] rows, int[] columns,int t) { + // TODO Auto-generated method stub + + int rowSpan = rows.length; + int columnSpan = columns.length; + int startRow = rows[0]; + int startColumn = columns[0]; + System.out.println("startColumn " +startColumn); +// for (int i = 0; i < rowSpan; i++) { +// for (int j = 0; j < columnSpan; j++) { +// int[][] js = span[startRow + i]; +// int[] ks = js[startColumn + j]; +// if ((ks[CellSpan.COLUMN] != 1) +// || (ks[CellSpan.ROW] != 1)) { +// // System.out.println("can't combine"); +// return; +// } +// } +// } + int removedRow = 0; + for (int i = 0, ii = 0; i < rowSpan; i++, ii--) { + if(startRow + i >= t) { + System.out.println(startRow + rowSpan +"-------"); + removedRow = removedRow +1; + continue; + } + for (int j = 0, jj = 0; j < columnSpan; j++, jj--) { + int[][] ks = span[startRow + i]; + int[] ks2 = ks[startColumn + j]; + span[startRow + i][startColumn + j][CellSpan.COLUMN] = jj; + span[startRow + i][startColumn + j][CellSpan.ROW] = ii; + // System.out.println("r " +ii +" c " +jj); + } + } + span[startRow][startColumn][CellSpan.COLUMN] = columnSpan; + span[startRow][startColumn][CellSpan.ROW] = rowSpan - removedRow; + System.out.println("over"); + } + @Override + public void combine(int[] rows, int[] columns) { + // TODO Auto-generated method stub + + int rowSpan = rows.length; + int columnSpan = columns.length; + int startRow = rows[0]; + int startColumn = columns[0]; + System.out.println("startColumn " +startColumn); + for (int i = 0; i < rowSpan; i++) { + for (int j = 0; j < columnSpan; j++) { + int[][] js = span[startRow + i]; + int[] ks = js[startColumn + j]; + if ((ks[CellSpan.COLUMN] != 1) + || (ks[CellSpan.ROW] != 1)) { + // System.out.println("can't combine"); + return; + } + } + } + for (int i = 0, ii = 0; i < rowSpan; i++, ii--) { + for (int j = 0, jj = 0; j < columnSpan; j++, jj--) { + span[startRow + i][startColumn + j][CellSpan.COLUMN] = jj; + span[startRow + i][startColumn + j][CellSpan.ROW] = ii; + // System.out.println("r " +ii +" c " +jj); + } + } + span[startRow][startColumn][CellSpan.COLUMN] = columnSpan; + span[startRow][startColumn][CellSpan.ROW] = rowSpan; + } + + @Override + public boolean isCellEditable(int arg0, int arg1) { + if ((arg0 == row && arg1 == column) || arg1 ==1) { + return this.isEditable; + } else { + return false; + } + } + + public void setSize(Dimension size) { + columnSize = size.width; + rowSize = size.height; + span = new int[rowSize][columnSize][2]; // 2: COLUMN,ROW + initValue(); + } + + protected boolean isOutOfBounds(int row, int column) { + if ((row < 0) || (rowSize <= row) || (column < 0) + || (columnSize <= column)) { + return true; + } + return false; + } + + public void addRow() { + + Vector newData = new Vector(getColumnCount()); + dataVector.add(newData); + + // + newRowsAdded(new TableModelEvent(this, getRowCount() - 1, + getRowCount() - 1, TableModelEvent.ALL_COLUMNS, + TableModelEvent.INSERT)); + int[][][] oldSpan = span; + int numRows = oldSpan.length; + int numColumns = oldSpan[0].length; + span = new int[numRows + 1][numColumns][2]; + System.arraycopy(oldSpan, 0, span, 0, numRows); + for (int i = 0; i < numColumns; i++) { + span[numRows][i][CellSpan.COLUMN] = 1; + span[numRows][i][CellSpan.ROW] = 1; + } + rowSize = span.length; + } + + public void addColumn(Object columnName) { + + int[][][] oldSpan = span; + int numRows = oldSpan.length; + int numColumns = oldSpan[0].length; + span = new int[numRows][numColumns + 1][2]; + for (int i = 0; i < span.length; i++) { + for (int j = 0; j < span[0].length; j++) { + span[i][j][CellSpan.COLUMN] = 1; + span[i][j][CellSpan.ROW] = 1; + } + } + + columnSize = span[0].length; + addColumn(columnName, (Vector) null); + } + + public void insertRow(int row) { + Vector rowData = new Vector(getColumnCount()); + int index = 0; + + dataVector.insertElementAt(rowData, row); + System.out.println("size:" + dataVector.size()); + + // + newRowsAdded(new TableModelEvent(this, row, row, + TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT)); + int[][][] newSpan = new int[span.length + 1][span[0].length][2]; + + int numRows = span.length; + int numColumns = span[0].length; + for (int i = 0; i < newSpan.length; i++) { + if (i < row) { + for (int j = 0; j < numColumns; j++) { + newSpan[i][j][0] = span[i][j][0]; + newSpan[i][j][1] = span[i][j][1]; + // newSpan[i][j][0] = 1; + // newSpan[i][j][1] = 1; + } + } else if (i == row) { + for (int j = 0; j < numColumns; j++) { + newSpan[i][j][0] = 1; + newSpan[i][j][1] = 1; + } + } else { + for (int j = 0; j < numColumns; j++) { + newSpan[i][j][0] = span[i - 1][j][0]; + newSpan[i][j][1] = span[i - 1][j][1]; + // newSpan[i][j][0] = 1; + // newSpan[i][j][1] = 1; + } + } + } + span = newSpan; + rowSize = span.length;// 将可修改的行+1 + if (processRowList != null && processRowList.size() > 0) { + + for (int i = processRowList.size() - 1; i >= 0; i--) { + if (!processRowList.contains(row) + && processRowList.get(i) != null + && processRowList.get(i) == row - 1) { + index = i + 1; + processRowList.add(i + 1, row); + } else if (processRowList.get(i) != null + && processRowList.get(i) == row) { + index = i + 1; + processRowList.add(i + 1, row + 1); + } else if (processRowList.get(i) != null && i > index + && processRowList.get(i) >= row) { + processRowList.set(i, processRowList.get(i) + 1); + } + } + + + } + + } + + public CTMap2(int numRows, int numColumns) { + Vector names = new Vector(numColumns); + names.setSize(numColumns); + setColumnIdentifiers(names); + dataVector = new Vector(); + setNumRows(numRows); + setSize(new Dimension(numColumns, numRows)); + + } + + protected void initValue() { + System.out.println(span.length+"-------"); + for (int i = 0; i < span.length; i++) { + for (int j = 0; j < span[i].length; j++) { + span[i][j][CellSpan.COLUMN] = 1; + span[i][j][CellSpan.ROW] = 1; + } + } + } + + public void split(int row, int column) { + if (isOutOfBounds(row, column)) + return; + int columnSpan = span[row][column][CellSpan.COLUMN]; + int rowSpan = span[row][column][CellSpan.ROW]; + for (int i = 0; i < rowSpan; i++) { + for (int j = 0; j < columnSpan; j++) { + span[row + i][column + j][CellSpan.COLUMN] = 1; + span[row + i][column + j][CellSpan.ROW] = 1; + } + } + } + + public void removeCol() { + + columnIdentifiers.removeElementAt(columnIdentifiers.size() - 1); + dataVector.setSize(getRowCount()); + + for (int i = 0; i < getRowCount() - 1; i++) { + + ((Vector) dataVector.elementAt(i)).setSize(getColumnCount()); + } + fireTableStructureChanged(); + } +} diff --git a/src/com/connor/renben/process/plm/util/CTUI.java b/src/com/connor/renben/process/plm/util/CTUI.java new file mode 100644 index 0000000..88f5661 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/CTUI.java @@ -0,0 +1,107 @@ +package com.connor.renben.process.plm.util; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Point; +import java.awt.Rectangle; + +import javax.swing.JComponent; +import javax.swing.plaf.basic.BasicTableUI; +import javax.swing.table.TableCellRenderer; + +public class CTUI extends BasicTableUI { + + public void paint(Graphics g, JComponent c) { + Rectangle oldClipBounds = g.getClipBounds(); + Rectangle clipBounds = new Rectangle(oldClipBounds); + int tableWidth = ((CTable) table).getColumnModel() + .getTotalColumnWidth(); + clipBounds.width = Math.min(clipBounds.width, tableWidth); + g.setClip(clipBounds); + + int firstIndex = ((CTable) table) + .rowAtPoint(new Point(0, clipBounds.y)); + int lastIndex = ((CTable) table).getRowCount() - 1; + Rectangle rowRect = new Rectangle(0, 0, tableWidth, + ((CTable) table).getRowHeight() + + ((CTable) table).getRowMargin()); + rowRect.y = firstIndex * rowRect.height; + for (int index = firstIndex; index <= lastIndex; index++) { + if (rowRect.intersects(clipBounds)) { + // System.out.println(); // debug + // System.out.print("" + index +": "); // row + paintRow(g, index); + } + rowRect.y += rowRect.height; + } + g.setClip(oldClipBounds); + } + + private void paintRow(Graphics g, int row) { + Rectangle rect = g.getClipBounds(); + boolean drawn = false; + CellSpan cellAtt = (CellSpan) ((CTable) table).getModel(); + int numColumns = ((CTable) table).getColumnCount(); + + for (int column = 0; column < numColumns; column++) { + Rectangle cellRect = ((CTable) table) + .getCellRect(row, column, true); + + int cellRow, cellColumn; + if (cellAtt.isVisible(row, column)) { + cellRow = row; + cellColumn = column; + // System.out.print(" "+column+" "); // debug + } else { + cellRow = row + cellAtt.getSpan(row, column)[CellSpan.ROW]; + cellColumn = column + + cellAtt.getSpan(row, column)[CellSpan.COLUMN]; + // System.out.print(" ("+column+")"); // debug + } + if (cellRect.intersects(rect)) { + drawn = true; + paintCell(g, cellRect, cellRow, cellColumn); + } else { + if (drawn) + break; + } + } + + } + + private void paintCell(Graphics g, Rectangle cellRect, int row, int column) { + int spacingHeight = ((CTable) table).getRowMargin(); + int spacingWidth = ((CTable) table).getColumnModel().getColumnMargin(); + // System.out.println("X:"+cellRect.x+"Y:"+cellRect.y); + Color c = g.getColor(); + g.setColor(((CTable) table).getGridColor()); + g.drawRect(cellRect.x, cellRect.y, cellRect.width - 1, + cellRect.height - 1); + g.setColor(c); + + cellRect.setBounds(cellRect.x + spacingWidth / 2, cellRect.y + + spacingHeight / 2, cellRect.width - spacingWidth, + cellRect.height - spacingHeight); + + if (((CTable) table).isEditing() + && ((CTable) table).getEditingRow() == row + && ((CTable) table).getEditingColumn() == column) { + Component component = ((CTable) table).getEditorComponent(); + component.setBounds(cellRect); + component.validate(); + } else { + TableCellRenderer renderer = ((CTable) table).getCellRenderer(row, + column); + Component component = ((CTable) table).prepareRenderer(renderer, + row, column); + + if (component.getParent() == null) { + rendererPane.add(component); + } + rendererPane.paintComponent(g, component, ((CTable) table), + cellRect.x, cellRect.y, cellRect.width, cellRect.height, + true); + } + } +} \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/util/CTable.java b/src/com/connor/renben/process/plm/util/CTable.java new file mode 100644 index 0000000..034afea --- /dev/null +++ b/src/com/connor/renben/process/plm/util/CTable.java @@ -0,0 +1,249 @@ +package com.connor.renben.process.plm.util; + +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.event.MouseEvent; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.DefaultCellEditor; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JTable; +import javax.swing.ListSelectionModel; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.TableModelListener; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableModel; + +public class CTable extends JTable implements TableModelListener{ + Map map; + TableCellTextAreaRenderer renderer = new TableCellTextAreaRenderer(); + TextAreaCellEditor cellEditor = new TextAreaCellEditor(); +// ComboBoxCellEditor comboBoxCellEditor = new ComboBoxCellEditor(new Object[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }); + Boolean edit; + List tstxList; + TableCellCheckboxRenderer checkboxRenderer = new TableCellCheckboxRenderer(this); +// CheckBoxCellEditor checkBoxCellEditor = new CheckBoxCellEditor(this); +// TableCellCheckboxRenderer checkboxRenderer = new TableCellCheckboxRenderer(this); + +// @Override +// public java.awt.Component prepareRenderer(javax.swing.table.TableCellRenderer renderer, int row, int column) { +// int modelRow = convertRowIndexToModel(row); +// int modelColumn = convertColumnIndexToModel(column); +// java.awt.Component comp = super.prepareRenderer(renderer, row, column); +// if (!isRowSelected(modelRow)) { +// if (modelRow == 1 && modelColumn == 1) //此处加入条件判断 +// comp.setBackground(Color.GRAY); +// else //不符合条件的保持原表格样式 +// comp.setBackground(Color.WHITE); +// } +// return comp; +// } + public CTable(TableModel model,Boolean edit,List tstxList) { + super(model); + setUI(new CTUI()); + this.edit=edit; + System.out.println("edit ==> "+edit); + this.tstxList=tstxList; + getTableHeader().setReorderingAllowed(false); + setCellSelectionEnabled(true); + setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); + + map = new HashMap(); + } + + public String getToolTipText(MouseEvent e) { + int row = this.rowAtPoint(e.getPoint()); + int col = this.columnAtPoint(e.getPoint()); + String tiptextString = null; + if (row > -1 && col > -1) { + Object value = this.getValueAt(row, col); + if (null != value && !"".equals(value)) + tiptextString = value.toString();// 悬浮显示单元格内容 + } + return tiptextString; + } + + // @Override + // protected void processKeyEvent(KeyEvent keyevent) { + // // TODO Auto-generated method stub + // if(keyevent.getKeyCode()==KeyEvent.VK_ENTER){ + // if(keyevent.isControlDown()) + // { + // System.out.println(1); + // } + // this.editCellAt(this.getSelectedRow(),this.getSelectedColumn()); + // } + // } + + public Rectangle getCellRect(int row, int column, boolean includeSpacing) { + Rectangle sRect = super.getCellRect(row, column, includeSpacing); + if ((row < 0) || (column < 0) || (getRowCount() <= row) || (getColumnCount() <= column)) { + return sRect; + } + CellSpan cellAtt = (CellSpan) getModel(); + if (!cellAtt.isVisible(row, column)) { + int temp_row = row; + int temp_column = column; + row += cellAtt.getSpan(temp_row, temp_column)[CellSpan.ROW]; + column += cellAtt.getSpan(temp_row, temp_column)[CellSpan.COLUMN]; + } + int[] n = cellAtt.getSpan(row, column); + + int index = 0; + int columnMargin = getColumnModel().getColumnMargin(); + Rectangle cellFrame = new Rectangle(); + int aCellHeight = rowHeight + rowMargin; + cellFrame.y = row * aCellHeight; + cellFrame.height = n[CellSpan.ROW] * aCellHeight; + + Enumeration eeration = getColumnModel().getColumns(); + while (eeration.hasMoreElements()) { + TableColumn aColumn = (TableColumn) eeration.nextElement(); + cellFrame.width = aColumn.getWidth(); + if (index == column) + break; + cellFrame.x += cellFrame.width; + index++; + } + for (int i = 0; i < n[CellSpan.COLUMN] - 1; i++) { + TableColumn aColumn = (TableColumn) eeration.nextElement(); + cellFrame.width += aColumn.getWidth() + columnMargin; + } + + if (!includeSpacing) { + Dimension spacing = getIntercellSpacing(); + cellFrame.setBounds(cellFrame.x + spacing.width / 2, cellFrame.y + spacing.height / 2, + cellFrame.width - spacing.width, cellFrame.height - spacing.height); + } + return cellFrame; + } + + // 隐藏列 + public void HiddenCell(int column) { + TableColumn tc = this.getTableHeader().getColumnModel().getColumn(column); + tc.setMaxWidth(0); + tc.setPreferredWidth(0); + tc.setWidth(0); + tc.setMinWidth(0); + this.getTableHeader().getColumnModel().getColumn(column).setMaxWidth(0); + this.getTableHeader().getColumnModel().getColumn(column).setMinWidth(0); + } + + private int[] rowColumnAtPoint(Point point) { + int[] retValue = { -1, -1 }; + int row = point.y / (rowHeight + rowMargin); + if ((row < 0) || (getRowCount() <= row)) + return retValue; + int column = getColumnModel().getColumnIndexAtX(point.x); + + CellSpan cellAtt = (CellSpan) getModel(); + + if (cellAtt.isVisible(row, column)) { + retValue[CellSpan.COLUMN] = column; + retValue[CellSpan.ROW] = row; + return retValue; + } + retValue[CellSpan.COLUMN] = column + cellAtt.getSpan(row, column)[CellSpan.COLUMN]; + retValue[CellSpan.ROW] = row + cellAtt.getSpan(row, column)[CellSpan.ROW]; + return retValue; + } + + public int rowAtPoint(Point point) { + return rowColumnAtPoint(point)[CellSpan.ROW]; + } + + public int columnAtPoint(Point point) { + return rowColumnAtPoint(point)[CellSpan.COLUMN]; + } + + public void columnSelectionChanged(ListSelectionEvent e) { + repaint(); + } + + public void valueChanged(ListSelectionEvent e) { + int firstIndex = e.getFirstIndex(); + int lastIndex = e.getLastIndex(); + if (firstIndex == -1 && lastIndex == -1) { // Selection cleared. + repaint(); + } + Rectangle dirtyRegion = getCellRect(firstIndex, 0, false); + int numCoumns = getColumnCount(); + int index = firstIndex; + for (int i = 0; i < numCoumns; i++) { + dirtyRegion.add(getCellRect(index, i, false)); + } + index = lastIndex; + for (int i = 0; i < numCoumns; i++) { + dirtyRegion.add(getCellRect(index, i, false)); + } + repaint(dirtyRegion.x, dirtyRegion.y, dirtyRegion.width, dirtyRegion.height); + } + + public void setCombo(int row, int col, TableCellEditor ce) { + map.put(new Point(row, col), ce); + } + +// @Override +// public boolean isCellEditable(int row,int column){ +// if(column == 2){ +// return false; +// }else if(!edit){ +// return false; +// } +// return true; +// } + + @Override + public TableCellEditor getCellEditor(int row, int column) { + if (this.getColumnName(column).equals("特殊特性")) { + JComboBox tubePurposeBox = new JComboBox(); + for(String string : tstxList) { + tubePurposeBox.addItem(string); + } +// tubePurposeBox.addItem("主干"); +// tubePurposeBox.addItem("引上"); +// tubePurposeBox.addItem("分支"); +// tubePurposeBox.addItem("沟通"); +// tubePurposeBox.addItem("预留"); + //声明单元格编辑器,传入下拉框 + TableCellEditor tubePurposeCellEditor = new DefaultCellEditor(tubePurposeBox); + return tubePurposeCellEditor; + } else { +// return cellEditor; + } + return cellEditor; + } + + + public void setRowHeight(int row, int rowHeight) { + super.setRowHeight(row, rowHeight); + } + + public void selectAllOrNull(String value) { + // Select All. The last column + for (int index = 0; index < getRowCount(); index++) { + this.setValueAt(value, index, this.getColumnCount() - 3); + } + } + + // @Override + // public boolean isCellSelected(int i, int j) { + // if( i == 1 || i == 3) + // { + // //this.clearSelection(); + // return false; + // } + // else + // { + // return super.isCellSelected(i, j); + // } + // } + +} \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/util/CTextField.java b/src/com/connor/renben/process/plm/util/CTextField.java new file mode 100644 index 0000000..5e22e87 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/CTextField.java @@ -0,0 +1,39 @@ +package com.connor.renben.process.plm.util; + +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; + +import javax.swing.JTextField; + +import com.teamcenter.rac.util.MessageBox; + +public class CTextField extends JTextField implements FocusListener { + + public CTextField() { + // TODO Auto-generated constructor stub + this.addFocusListener(this); + } + + public CTextField(String s) { + super(s); + this.setToolTipText(this.getText()); + this.addFocusListener(this); + } + + @Override + public void focusGained(FocusEvent focusevent) { + // TODO Auto-generated method stub + // System.out.println(1); + + } + + @Override + public void focusLost(FocusEvent focusevent) { + // TODO Auto-generated method stub + // System.out.println(2); + this.setToolTipText(this.getText()); + } + +} diff --git a/src/com/connor/renben/process/plm/util/CTextFieldButton.java b/src/com/connor/renben/process/plm/util/CTextFieldButton.java new file mode 100644 index 0000000..a34e234 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/CTextFieldButton.java @@ -0,0 +1,73 @@ +package com.connor.renben.process.plm.util; + +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Graphics; +import java.awt.Rectangle; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JButton; +import javax.swing.JTextField; + +public class CTextFieldButton extends JTextField { + + private JButton choose = new JButton() { + // 打印容器 + @Override + public void paint(Graphics g) { + super.paint(g); + int width = 3; + int height = 3; + Rectangle rect = g.getClipBounds();// 返回当前剪贴区域边界矩形 + int x = rect.width / 3; + int y = rect.height / 2; + for (int i = 0; i < 3;) { + g.fillOval(++i * x, y, width, height);// 使用当前颜色填充外接指定矩形框的椭圆 + } + } + + // 容器首选大小 + @Override + public Dimension getPreferredSize() { + Dimension dimension = CTextFieldButton.super.getPreferredSize(); + dimension.height -= 6; + dimension.width = dimension.height; + return dimension; + } + }; + + private CTextFieldButton self = this; + + public CTextFieldButton(int column) { + super(column); + initButtonTest(); + } + + public CTextFieldButton() { + super(); + initButtonTest(); + } + + private void initButtonTest() { + choose.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent actionevent) { + // System.out.println(1); + CTextFieldButton.this.handleClick(self); + } + }); + // 如果没有这句话,按钮无法显示,原因是默认覆盖 + this.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0)); + } + + // JComponent通知此组件它现在已有了一个父组件 + @Override + public void addNotify() { + super.addNotify(); + add(choose);// Container中方法将指定组件追加到此容器的尾部 + } + + public void handleClick(CTextFieldButton jbuttonTest) { + } +} diff --git a/src/com/connor/renben/process/plm/util/CTreeNode.java b/src/com/connor/renben/process/plm/util/CTreeNode.java new file mode 100644 index 0000000..4af1d61 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/CTreeNode.java @@ -0,0 +1,21 @@ +//package com.connor.renben.process.plm.util; +// +//import javax.swing.tree.DefaultMutableTreeNode; +// +// +//public class CTreeNode extends DefaultMutableTreeNode { +// +// public CTreeNode(Object arg0) { +// // TODO Auto-generated constructor stub +// super(arg0); +// } +// +// @Override +// public String toString() { +// // TODO Auto-generated method stub +// if (this.getUserObject() instanceof TreeBean) { +// return ((TreeBean) this.getUserObject()).getName(); +// } +// return super.toString(); +// } +//} diff --git a/src/com/connor/renben/process/plm/util/CellSpan.java b/src/com/connor/renben/process/plm/util/CellSpan.java new file mode 100644 index 0000000..0259381 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/CellSpan.java @@ -0,0 +1,15 @@ +package com.connor.renben.process.plm.util; + +interface CellSpan { + public final int ROW = 0; + public final int COLUMN = 1; + + public int[] getSpan(int row, int column); + + public void setSpan(int[] span, int row, int column); + + public boolean isVisible(int row, int column); + + public void combine(int[] rows, int[] columns); + +} \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/util/ChangeCharset.java b/src/com/connor/renben/process/plm/util/ChangeCharset.java new file mode 100644 index 0000000..0c471f4 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/ChangeCharset.java @@ -0,0 +1,107 @@ +package com.connor.renben.process.plm.util; + +import java.io.UnsupportedEncodingException; + +/** + * 转换字符串的编码 + * + * @author joe + * + */ + +public class ChangeCharset { + /** 7位ASCII字符,也叫作ISO646-US、Unicode字符集的基本拉丁块 */ + public static final String US_ASCII = "US-ASCII"; + /** ISO拉丁字母表 No.1,也叫做ISO-LATIN-1 */ + public static final String ISO_8859_1 = "ISO-8859-1"; + /** 8 位 UCS 转换格式 */ + public static final String UTF_8 = "UTF-8"; + /** 16 位 UCS 转换格式,Big Endian(最低地址存放高位字节)字节顺序 */ + public static final String UTF_16BE = "UTF-16BE"; + /** 16 位 UCS 转换格式,Litter Endian(最高地址存放地位字节)字节顺序 */ + public static final String UTF_16LE = "UTF-16LE"; + /** 16 位 UCS 转换格式,字节顺序由可选的字节顺序标记来标识 */ + public static final String UTF_16 = "UTF-16"; + /** 中文超大字符集 **/ + public static final String GBK = "GBK"; + + public static final String GB2312 = "GB2312"; + + /** 将字符编码转换成US-ASCII码 */ + public String toASCII(String str) throws UnsupportedEncodingException { + return this.changeCharset(str, US_ASCII); + } + + /** 将字符编码转换成ISO-8859-1 */ + public String toISO_8859_1(String str) throws UnsupportedEncodingException { + return this.changeCharset(str, ISO_8859_1); + } + + /** 将字符编码转换成UTF-8 */ + public String toUTF_8(String str) throws UnsupportedEncodingException { + return this.changeCharset(str, UTF_8); + } + + /** 将字符编码转换成UTF-16BE */ + public String toUTF_16BE(String str) throws UnsupportedEncodingException { + return this.changeCharset(str, UTF_16BE); + } + + /** 将字符编码转换成UTF-16LE */ + public String toUTF_16LE(String str) throws UnsupportedEncodingException { + return this.changeCharset(str, UTF_16LE); + } + + /** 将字符编码转换成UTF-16 */ + public String toUTF_16(String str) throws UnsupportedEncodingException { + return this.changeCharset(str, UTF_16); + } + + /** 将字符编码转换成GBK */ + public String toGBK(String str) throws UnsupportedEncodingException { + return this.changeCharset(str, GBK); + } + + /** 将字符编码转换成GB2312 */ + public String toGB2312(String str) throws UnsupportedEncodingException { + return this.changeCharset(str, GB2312); + } + + /** + * 字符串编码转换的实现方法 + * + * @param str + * 待转换的字符串 + * @param newCharset + * 目标编码 + */ + public String changeCharset(String str, String newCharset) + throws UnsupportedEncodingException { + if (str != null) { + // 用默认字符编码解码字符串。与系统相关,中文windows默认为GB2312 + byte[] bs = str.getBytes(); + return new String(bs, newCharset); // 用新的字符编码生成字符串 + } + return null; + } + + /** + * 字符串编码转换的实现方法 + * + * @param str + * 待转换的字符串 + * @param oldCharset + * 源字符集 + * @param newCharset + * 目标字符集 + */ + public String changeCharset(String str, String oldCharset, String newCharset) + throws UnsupportedEncodingException { + if (str != null) { + // 用源字符编码解码字符串 + byte[] bs = str.getBytes(oldCharset); + return new String(bs, newCharset); + } + return null; + } +} \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/util/CheckBoxCellEditor.java b/src/com/connor/renben/process/plm/util/CheckBoxCellEditor.java new file mode 100644 index 0000000..93c857d --- /dev/null +++ b/src/com/connor/renben/process/plm/util/CheckBoxCellEditor.java @@ -0,0 +1,118 @@ +package com.connor.renben.process.plm.util; + +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.EventObject; + +import javax.swing.JCheckBox; +import javax.swing.JTable; +import javax.swing.SwingConstants; +import javax.swing.event.CellEditorListener; +import javax.swing.event.ChangeEvent; +import javax.swing.event.EventListenerList; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableCellEditor; + +public class CheckBoxCellEditor extends JCheckBox implements TableCellEditor { + + protected EventListenerList listenerList = new EventListenerList(); + protected ChangeEvent changeEvent = new ChangeEvent(this); + private JTableHeader tableHeader; + private DefaultTableModel tableModel; + + public CheckBoxCellEditor(final CTable table) { + super(); + this.tableModel = (DefaultTableModel) table.getModel(); + this.tableHeader = table.getTableHeader(); + this.setName("4"); + // selectBox = new JCheckBox(tableModel.getColumnName(1)); + this.setSelected(false); + tableHeader.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() > 0) { + // 获得选中列 + int selectColumn = tableHeader.columnAtPoint(e.getPoint()); + if (table.getColumnName(selectColumn).equals("4")) { + boolean value = !CheckBoxCellEditor.this.isSelected(); + CheckBoxCellEditor.this.setSelected(value); + table.selectAllOrNull(value ? "1" : "0"); + tableHeader.repaint(); + } + } + } + }); + addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent event) { + fireEditingStopped(); + } + }); + } + + public void addCellEditorListener(CellEditorListener listener) { + listenerList.add(CellEditorListener.class, listener); + } + + public void removeCellEditorListener(CellEditorListener listener) { + listenerList.remove(CellEditorListener.class, listener); + } + + protected void fireEditingStopped() { + System.out.println(this.isSelected() ? "1" : "0"); + CellEditorListener listener; + Object[] listeners = listenerList.getListenerList(); + for (int i = 0; i < listeners.length; i++) { + if (listeners[i] == CellEditorListener.class) { + listener = (CellEditorListener) listeners[i + 1]; + listener.editingStopped(changeEvent); + } + } + } + + protected void fireEditingCanceled() { + CellEditorListener listener; + Object[] listeners = listenerList.getListenerList(); + for (int i = 0; i < listeners.length; i++) { + if (listeners[i] == CellEditorListener.class) { + listener = (CellEditorListener) listeners[i + 1]; + listener.editingCanceled(changeEvent); + } + } + } + + public void cancelCellEditing() { + fireEditingCanceled(); + } + + public boolean stopCellEditing() { + // this.addItem(this.getSelectedItem()); + fireEditingStopped(); + return true; + } + + public boolean isCellEditable(EventObject event) { + return true; + } + + public boolean shouldSelectCell(EventObject event) { + return true; + } + + public Object getCellEditorValue() { + return this.isSelected() ? "1" : "0"; + } + + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + +// String valueStr = (String) value; +// JLabel label = new JLabel(valueStr); +// label.setHorizontalAlignment(SwingConstants.CENTER); // 表头标签剧中 + this.setHorizontalAlignment(SwingConstants.CENTER);// 表头标签剧中 + this.setBorderPainted(true); + this.setSelected(value.toString().equals("1")); + return this; + } +} \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/util/CheckListCellRenderer.java b/src/com/connor/renben/process/plm/util/CheckListCellRenderer.java new file mode 100644 index 0000000..97041fb --- /dev/null +++ b/src/com/connor/renben/process/plm/util/CheckListCellRenderer.java @@ -0,0 +1,47 @@ +package com.connor.renben.process.plm.util; + +import java.awt.Component; +import java.io.Serializable; + +import javax.swing.JCheckBox; +import javax.swing.JList; +import javax.swing.ListCellRenderer; +import javax.swing.UIManager; +import javax.swing.border.Border; +import javax.swing.border.EmptyBorder; + +public class CheckListCellRenderer extends JCheckBox implements ListCellRenderer,Serializable{ + + protected static Border noFocusBorder; + + + public CheckListCellRenderer() { + super(); + if(noFocusBorder == null) { + noFocusBorder = new EmptyBorder(1,1,1,1); + } + setOpaque(true); + setBorder(noFocusBorder); + } + @Override + public Component getListCellRendererComponent(JList list, Object value, + int index, boolean isSelected, boolean cellHasFocus) { + setComponentOrientation(list.getComponentOrientation()); + if(isSelected) { + setBackground(list.getSelectionBackground()); + setForeground(list.getSelectionForeground()); + } else { + setBackground(list.getBackground()); + setForeground(list.getForeground()); + } + if (value instanceof CheckValue) { + CheckValue ckValue = (CheckValue) value; + this.setText(ckValue.value == null ? "" : ckValue.value); + this.setSelected(ckValue.bolValue); + } + setEnabled(list.isEnabled()); + setFont(list.getFont()); + setBorder((cellHasFocus) ? UIManager.getBorder("List.focusCellHighlightBorder") : noFocusBorder); + return this; + } +} \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/util/CheckValue.java b/src/com/connor/renben/process/plm/util/CheckValue.java new file mode 100644 index 0000000..d463bfc --- /dev/null +++ b/src/com/connor/renben/process/plm/util/CheckValue.java @@ -0,0 +1,12 @@ +package com.connor.renben.process.plm.util; + +public class CheckValue { + public boolean bolValue = false; + public String value = null; + public CheckValue() { + } + public CheckValue(boolean bolValue, String value) { + this.bolValue = bolValue; + this.value = value; + } +} diff --git a/src/com/connor/renben/process/plm/util/CollectControlPlan.java b/src/com/connor/renben/process/plm/util/CollectControlPlan.java new file mode 100644 index 0000000..44956ce --- /dev/null +++ b/src/com/connor/renben/process/plm/util/CollectControlPlan.java @@ -0,0 +1,185 @@ +package com.connor.renben.process.plm.util; + +import java.io.BufferedInputStream; +import java.io.InputStream; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; +import java.util.UUID; + +import com.connor.hs2.plm.PFMEA.design.SqlUtilT; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + +public class CollectControlPlan { + private TCSession session; + private String kzjhType; + private TCComponentItem meprocessItem; + + + public CollectControlPlan(TCSession session, String kzjhType,TCComponentItem meprocessItem) { + // TODO Auto-generated constructor stub + this.session = session; + this.kzjhType = kzjhType; + this.meprocessItem = meprocessItem; + CollectData(meprocessItem); + } + + public void CollectData(TCComponentItem item) { + // TODO Auto-generated method stub + SqlUtilT.getTCConnection(); + ResultSet rs = null; + ResultSet rs2 = null; + InputStream input = null; + try { + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + //获取BOM下的所有的子BOM对象 + TCComponent[] components = item.getLatestItemRevision().getRelatedComponents("ps_children"); + for (int i = 0; i < components.length; i++) { + System.out.println(components[i].getType()); + //如果是工艺对象 + if(components[i].getType().indexOf("MEProcess") >= 0) + { + //判断生产控制计划是否有数据 + String meprocessUid = components[i].getUid(); + if(components[i] instanceof TCComponentItemRevision) + { + meprocessUid = ((TCComponentItemRevision) components[i]).getItem().getUid(); + } + String scSql = String.format("select * from RB3_CONTROLPLAN where PROCESSPUID = \'%s\' and type = \'RB3_SCKZJH\'", meprocessUid); + rs = SqlUtilT.read(scSql); + //如果生产控制计划下有数据 + if(rs.next()) + { + //根据查找编号将总工艺中包含子工艺的工序移除 + String deleteSql = String.format("delete from rb3_controlplan " + + "where PROCESSPUID = \'%s\' and TYPE = \'%s\' and RB3_GYBH in (" + + "select RB3_GYBH from rb3_controlplan where PROCESSPUID = \'%s\' and TYPE = \'RB3_SCKZJH\' group by RB3_GYBH)", + meprocessItem.getUid(),kzjhType, meprocessUid); + System.out.println(deleteSql+"==========="); + SqlUtilT.delete2(deleteSql); + List> dataList = new ArrayList>(); + do { + List rowList = new ArrayList(); + rowList.add(rs.getString(2)); + rowList.add(rs.getString(3));rowList.add(rs.getString(4)); + rowList.add(rs.getString(5));rowList.add(rs.getString(6)); + rowList.add(rs.getString(7));rowList.add(rs.getString(8)); + rowList.add(rs.getString(9));rowList.add(rs.getString(10)); + rowList.add(rs.getString(11));rowList.add(rs.getString(12)); + rowList.add(rs.getString(13));rowList.add(rs.getString(14)); + rowList.add(rs.getString(15));rowList.add(rs.getString(16)); + rowList.add(rs.getString(17));rowList.add(rs.getString(18)); + rowList.add(rs.getString(19));rowList.add(rs.getString(20)); + rowList.add(rs.getString(21));rowList.add(rs.getString(22)); + rowList.add(rs.getString(23));rowList.add(rs.getString(24)); + rowList.add(rs.getString(25));rowList.add(rs.getString(26)); + rowList.add(rs.getString(27));rowList.add(rs.getString(28)); + dataList.add(rowList); + } while (rs.next()); + for (int j = 0; j < dataList.size(); j++) { + UUID scckzjhUid = UUID.randomUUID(); +// // 将数据插入到控制计划 + String insertSQL = pro.getProperty("INSERTSQL"); +// // 插入生产控制计划工序 + SqlUtilT.write( + new String[] { + scckzjhUid.toString().replace("-", ""), + meprocessItem.getUid(),dataList.get(j).get(1), + dataList.get(j).get(2),dataList.get(j).get(3), + dataList.get(j).get(4),dataList.get(j).get(5), + dataList.get(j).get(6),dataList.get(j).get(7), + dataList.get(j).get(8),dataList.get(j).get(9), + dataList.get(j).get(10),dataList.get(j).get(11), + dataList.get(j).get(12),dataList.get(j).get(13), + dataList.get(j).get(14),dataList.get(j).get(15), + dataList.get(j).get(16),dataList.get(j).get(17), + dataList.get(j).get(18),dataList.get(j).get(19), + dataList.get(j).get(20),dataList.get(j).get(21), + dataList.get(j).get(22),dataList.get(j).get(23), + dataList.get(j).get(24),dataList.get(j).get(25), + dataList.get(i).get(26),kzjhType,"0","0","","0" }, + insertSQL); + } + } + else + { + //根据查找编号将总工艺中包含子工艺的工序移除 + String deleteSql = String.format("delete from rb3_controlplan " + + "where PROCESSPUID = \'%s\' and TYPE = \'%s\' and RB3_GYBH in (" + + "select RB3_GYBH from rb3_controlplan where PROCESSPUID = \'%s\' and TYPE = \'RB3_SSCKZJH\' group by RB3_GYBH)", + meprocessItem.getUid(),kzjhType, meprocessUid); + System.out.println(deleteSql+"==========="); + SqlUtilT.delete2(deleteSql); + //判断试生产控制计划是否有数据 + String sscSql = String.format("select * from RB3_CONTROLPLAN where PROCESSPUID = \'%s\' and type = \'RB3_SSCKZJH\'", meprocessUid); + rs2 = SqlUtilT.read(sscSql); + List> dataList = new ArrayList>(); + while (rs2.next()) { + List rowList = new ArrayList(); + rowList.add(rs2.getString(2)); + rowList.add(rs2.getString(3));rowList.add(rs2.getString(4)); + rowList.add(rs2.getString(5));rowList.add(rs2.getString(6)); + rowList.add(rs2.getString(7));rowList.add(rs2.getString(8)); + rowList.add(rs2.getString(9));rowList.add(rs2.getString(10)); + rowList.add(rs2.getString(11));rowList.add(rs2.getString(12)); + rowList.add(rs2.getString(13));rowList.add(rs2.getString(14)); + rowList.add(rs2.getString(15));rowList.add(rs2.getString(16)); + rowList.add(rs2.getString(17));rowList.add(rs2.getString(18)); + rowList.add(rs2.getString(19));rowList.add(rs2.getString(20)); + rowList.add(rs2.getString(21));rowList.add(rs2.getString(22)); + rowList.add(rs2.getString(23));rowList.add(rs2.getString(24)); + rowList.add(rs2.getString(25));rowList.add(rs2.getString(26)); + rowList.add(rs2.getString(27));rowList.add(rs2.getString(28)); + dataList.add(rowList); + } + for (int j = 0; j < dataList.size(); j++) { + UUID scckzjhUid = UUID.randomUUID(); +// // 将数据插入到控制计划 + String insertSQL = pro.getProperty("INSERTSQL"); +// // 插入生产控制计划工序 + SqlUtilT.write( + new String[] { + scckzjhUid.toString().replace("-", ""), + meprocessItem.getUid(),dataList.get(j).get(1), + dataList.get(j).get(2),dataList.get(j).get(3), + dataList.get(j).get(4),dataList.get(j).get(5), + dataList.get(j).get(6),dataList.get(j).get(7), + dataList.get(j).get(8),dataList.get(j).get(9), + dataList.get(j).get(10),dataList.get(j).get(11), + dataList.get(j).get(12),dataList.get(j).get(13), + dataList.get(j).get(14),dataList.get(j).get(15), + dataList.get(j).get(16),dataList.get(j).get(17), + dataList.get(j).get(18),dataList.get(j).get(19), + dataList.get(j).get(20),dataList.get(j).get(21), + dataList.get(j).get(22),dataList.get(j).get(23), + dataList.get(j).get(24),dataList.get(j).get(25), + dataList.get(i).get(26),kzjhType,"0","0","","0" }, + insertSQL); + } + } + if(components[i] instanceof TCComponentItemRevision) + { + CollectData(((TCComponentItemRevision)components[i]).getItem()); + } + else + { + CollectData((TCComponentItem)components[i]); + } + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} diff --git a/src/com/connor/renben/process/plm/util/CollectPfmea.java b/src/com/connor/renben/process/plm/util/CollectPfmea.java new file mode 100644 index 0000000..5a4ea87 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/CollectPfmea.java @@ -0,0 +1,5 @@ +package com.connor.renben.process.plm.util; + +public class CollectPfmea { + +} diff --git a/src/com/connor/renben/process/plm/util/ComboBoxCellEditor.java b/src/com/connor/renben/process/plm/util/ComboBoxCellEditor.java new file mode 100644 index 0000000..e8a895e --- /dev/null +++ b/src/com/connor/renben/process/plm/util/ComboBoxCellEditor.java @@ -0,0 +1,88 @@ +package com.connor.renben.process.plm.util; + +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.EventObject; + +import javax.swing.JComboBox; +import javax.swing.JTable; +import javax.swing.event.CellEditorListener; +import javax.swing.event.ChangeEvent; +import javax.swing.event.EventListenerList; +import javax.swing.table.TableCellEditor; + +public class ComboBoxCellEditor extends JComboBox implements TableCellEditor { + + protected EventListenerList listenerList = new EventListenerList(); + protected ChangeEvent changeEvent = new ChangeEvent(this); + + public ComboBoxCellEditor(Object[] itmes) { + super(); + for (int i = 0; i < itmes.length; i++) { + addItem(itmes[i]); + } + addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent event) { + fireEditingStopped(); + } + }); + } + + public void addCellEditorListener(CellEditorListener listener) { + listenerList.add(CellEditorListener.class, listener); + } + + public void removeCellEditorListener(CellEditorListener listener) { + listenerList.remove(CellEditorListener.class, listener); + } + + protected void fireEditingStopped() { + CellEditorListener listener; + Object[] listeners = listenerList.getListenerList(); + for (int i = 0; i < listeners.length; i++) { + if (listeners[i] == CellEditorListener.class) { + listener = (CellEditorListener) listeners[i + 1]; + listener.editingStopped(changeEvent); + } + } + } + + protected void fireEditingCanceled() { + CellEditorListener listener; + Object[] listeners = listenerList.getListenerList(); + for (int i = 0; i < listeners.length; i++) { + if (listeners[i] == CellEditorListener.class) { + listener = (CellEditorListener) listeners[i + 1]; + listener.editingCanceled(changeEvent); + } + } + } + + public void cancelCellEditing() { + fireEditingCanceled(); + } + + public boolean stopCellEditing() { + fireEditingStopped(); + return true; + } + + public boolean isCellEditable(EventObject event) { + return true; + } + + public boolean shouldSelectCell(EventObject event) { + return true; + } + + public Object getCellEditorValue() { + return getSelectedItem(); + } + + public Component getTableCellEditorComponent(JTable table, Object value, + boolean isSelected, int row, int column) { + this.setSelectedItem(value); + return this; + } +} \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/util/CopyOfSaveControlPlan.java b/src/com/connor/renben/process/plm/util/CopyOfSaveControlPlan.java new file mode 100644 index 0000000..d52ebff --- /dev/null +++ b/src/com/connor/renben/process/plm/util/CopyOfSaveControlPlan.java @@ -0,0 +1,368 @@ +//package com.connor.renben.process.plm.util; +// +//import java.io.BufferedInputStream; +//import java.io.IOException; +//import java.io.InputStream; +//import java.sql.ResultSet; +//import java.util.ArrayList; +//import java.util.Arrays; +//import java.util.List; +//import java.util.Properties; +//import java.util.UUID; +// +//import com.connor.hs2.plm.PFMEA.design.SqlUtilT; +//import com.teamcenter.rac.kernel.TCComponent; +//import com.teamcenter.rac.kernel.TCComponentItem; +//import com.teamcenter.rac.kernel.TCPreferenceService; +//import com.teamcenter.rac.kernel.TCSession; +//import com.teamcenter.rac.util.MessageBox; +// +///** +// * 保存数据到控制计划表 +// * @author Administrator +// * +// */ +//public class CopyOfSaveControlPlan { +// private TCSession session; +// private TCComponentItem item; +// private List> properties = new ArrayList>(); +// private List> dataList = new ArrayList>();// 表格中的数据 +// +// public CopyOfSaveControlPlan(TCSession session,TCComponentItem item) { +// // TODO Auto-generated constructor stub +// this.session = session; +// this.item = item; +// } +// /** +// * 获取没有检验项的工序 +// * @param name 首选项名称 +// * @return 没有检验项的工序名称 +// */ +// private List getMeopNames(String name) { +// // TODO Auto-generated method stub +// String[] values = null; +// if(name != null) +// { +// TCPreferenceService service = this.session.getPreferenceService(); +// String[] props = service.getStringArray(TCPreferenceService.TC_preference_site, name); +// if(props != null || props.length>0) +// { +// values = props; +// } +// } +// else +// { +// MessageBox.post("未找首选项!", "错误!", MessageBox.ERROR); +// } +// return Arrays.asList(values); +// } +// public void insertData() { +// // TODO Auto-generated method stub +// ResultSet rs = null; +// ResultSet result = null; +// ResultSet resultSet = null; +// InputStream input = null; +// try { +// properties = TMomMethodUtil.getBomPropertys(session, item); +// List meopNameList = getMeopNames("RB3_CONCEAL_MEOP_NAME"); +// String itemUid = item.getUid(); +// //获取工艺下的控制计划对象 +// TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); +// List kzjhList = new ArrayList(); +// for (int i = 0; i < kzjh.length; i++) { +// if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) +// { +// kzjhList.add((TCComponentItem)kzjh[i]); +// } +// } +// SqlUtilT.getTCConnection(); +// input = new BufferedInputStream(getClass().getResourceAsStream( +// "/sql.properties")); +// Properties pro = new Properties(); +// pro.load(input); +// // 查询数据库中的数据 +// String sql = String.format(pro.getProperty("BOMCHECKSAVESELECT"), +// itemUid, "检验(%"); +// rs = SqlUtilT.read(sql); +// while (rs.next()) { +// List rowList = new ArrayList(); +// rowList.add(rs.getString("RB3_MEOPID") == null ? "" : rs.getString("RB3_MEOPID")); +// //rowList.add(rs.getString("RB3_MEOPID")); +// rowList.add(rs.getString("RB3_GYBH")); +// rowList.add(rs.getString("RB3_GCMC")); +// rowList.add(rs.getString("RB3_JQSB") == null ? "" : rs.getString("RB3_JQSB")); +// dataList.add(rowList); +// } +// if (dataList == null && dataList.size() == 0) { +// for (int j = 0; j < properties.size(); j++) { +// if(kzjhList.size() == 0) +// { +// UUID kzjhUid = UUID.randomUUID(); +//// UUID ssckzjhUid = UUID.randomUUID(); +//// UUID yjkzjhUid = UUID.randomUUID(); +// // 将数据插入到控制计划 +// String insertSQL = pro.getProperty("INSERTSQL"); +// Integer number = Integer.parseInt(properties.get(j).get(1) +// .toString()) % 10 == 0 ? Integer +// .parseInt(properties.get(j).get(1).toString()) + 5 +// : Integer.parseInt(properties.get(j).get(1) +// .toString()) + 1; +// String name = "检验(" + properties.get(j).get(2).toString() +// + ")"; +// // 插入生产控制计划工序 +// SqlUtilT.write( +// new String[] { +// kzjhUid.toString().replace("-", ""), +// itemUid, properties.get(j).get(0), +// properties.get(j).get(1), +// properties.get(j).get(2), +// properties.get(j).get(3), "", "", "", "", +// "", "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", "", "", "RB3_YJKZJH","0","0","","0" }, +// insertSQL); +// if(!meopNameList.contains(properties.get(j).get(2).toString())) +// { +// // 插入生产控制计划巡检项 +// SqlUtilT.write( +// new String[] { +// UUID.randomUUID().toString() +// .replace("-", ""), itemUid, +// properties.get(j).get(0), +// number.toString(), name, +// "", "", "", "", "", +// "", "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", "", "", "RB3_YJKZJH","0","0","","0" }, +// insertSQL); +// } +// } +// else +// { +// for (int i = 0; i < kzjhList.size(); i++) { +// UUID kzjhUid = UUID.randomUUID(); +//// UUID ssckzjhUid = UUID.randomUUID(); +//// UUID yjkzjhUid = UUID.randomUUID(); +// // 将数据插入到控制计划 +// String insertSQL = pro.getProperty("INSERTSQL"); +// Integer number = Integer.parseInt(properties.get(j).get(1) +// .toString()) % 10 == 0 ? Integer +// .parseInt(properties.get(j).get(1).toString()) + 5 +// : Integer.parseInt(properties.get(j).get(1) +// .toString()) + 1; +// String name = "检验(" + properties.get(j).get(2).toString() +// + ")"; +// // 插入生产控制计划工序 +// SqlUtilT.write( +// new String[] { +// kzjhUid.toString().replace("-", ""), +// itemUid, properties.get(j).get(0), +// properties.get(j).get(1), +// properties.get(j).get(2), +// properties.get(j).get(3), "", "", "", "", +// "", "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", "", "", kzjhList.get(i).getType().toUpperCase(),"0","","0" }, +// insertSQL); +// if(!meopNameList.contains(properties.get(j).get(2).toString())) +// { +// // 插入生产控制计划巡检项 +// SqlUtilT.write( +// new String[] { +// UUID.randomUUID().toString() +// .replace("-", ""), itemUid, +// properties.get(j).get(0), +// number.toString(), name, +// properties.get(j).get(3), "", "", "", "", +// "", "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", "", "", kzjhList.get(i).getType().toUpperCase(),"0","","0" }, +// insertSQL); +// } +// } +// } +// } +// } else { +// // 修改表中相应的工序名称 +// for (int i = 0; i < dataList.size(); i++) { +// for (int j = 0; j < properties.size(); j++) { +// if (dataList.get(i).get(0) +// .equals(properties.get(j).get(0)) +// && (!dataList.get(i).get(1) +// .equals(properties.get(j).get(1)) +// || !dataList +// .get(i) +// .get(2) +// .equals(properties.get(j) +// .get(2)) || !dataList +// .get(i).get(3) +// .equals(properties.get(j).get(3)))) { +// Integer number = Integer.parseInt(properties.get(j) +// .get(1).toString()) % 10 == 0 ? Integer +// .parseInt(properties.get(j).get(1) +// .toString()) + 5 : Integer +// .parseInt(properties.get(j).get(1) +// .toString()) + 1; +// String name = "检验(" +// + properties.get(j).get(2).toString() + ")"; +// // 获取数据库连接 +// // 更新自检 +// String updateSQL = String.format( +// pro.getProperty("BOMCHECKSAVEUPDATE"), +// itemUid, dataList.get(i).get(0), "检验(%"); +// // 更新巡检 +// String updateSQL1 = String.format( +// pro.getProperty("BOMCHECKSAVEUPDATE2"), +// itemUid, dataList.get(i).get(0), "检验(%"); +// SqlUtilT.update(new String[] { +// properties.get(j).get(1), +// properties.get(j).get(2), +// properties.get(j).get(3) }, updateSQL); +// SqlUtilT.update(new String[] { number.toString(), +// name, +// ""}, updateSQL1); +// } +// // if(dataList.get(i).get(1).equals(properties[j][1].getStringValue()) +// // && !dataList.get(i).get(0).equals(properties[j][0])) +// // { +// // //获取数据库连接 +// // String updateSQL = +// // String.format("update CONTROLPLAN set RB3_GYBH = ? where PROCESSPUID = \'%s\' and RB3_GCMC = \'%s\'",itemUid,dataList.get(i).get(1)) +// // ; +// // SqlUtilT.update(new String[]{ +// // properties[j][0].getStringValue() },updateSQL); +// // } +// } +// } +// // 添加工序 +// // 查询数据库中的数据 +// result = SqlUtilT.read(sql); +// List indexList = new ArrayList(); +// while (result.next()) { +// indexList.add(result.getString("RB3_MEOPID")); +// } +// for (int i = 0; i < properties.size(); i++) { +// if (!indexList.contains(properties.get(i).get(0))) { +// if(kzjhList.size() == 0) +// { +// UUID kzjhUid = UUID.randomUUID(); +// // 将数据插入到表中 +// String insertSQL = pro.getProperty("INSERTSQL"); +// Integer number = Integer.parseInt(properties.get(i) +// .get(1).toString()) % 10 == 0 ? Integer +// .parseInt(properties.get(i).get(1).toString()) + 5 +// : Integer.parseInt(properties.get(i).get(1) +// .toString()) + 1; +// String name = "检验(" +// + properties.get(i).get(2).toString() + ")"; +// // 插入控制计划工序 +// SqlUtilT.write(new String[] { +// kzjhUid.toString().replace("-", ""), itemUid, +// properties.get(i).get(0), +// properties.get(i).get(1), +// properties.get(i).get(2), +// properties.get(i).get(3), "", "", "", "", "", +// "", "", "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", "RB3_YJKZJH","0","0","","0" },insertSQL); +// if(!meopNameList.contains(properties.get(i).get(2).toString())) +// { +// // 插入控制计划巡检项 +// SqlUtilT.write( +// new String[] { +// UUID.randomUUID().toString() +// .replace("-", ""), itemUid, +// properties.get(i).get(0), +// number.toString(), name, +// "", "", "", "", +// "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", "", "", "", "", +// "RB3_YJKZJH","0","0","","0" },insertSQL); +// } +// } +// else +// { +// for (int k = 0; k < kzjhList.size(); k++) { +// UUID kzjhUid = UUID.randomUUID(); +// // 将数据插入到表中 +// String insertSQL = pro.getProperty("INSERTSQL"); +// Integer number = Integer.parseInt(properties.get(i) +// .get(1).toString()) % 10 == 0 ? Integer +// .parseInt(properties.get(i).get(1).toString()) + 5 +// : Integer.parseInt(properties.get(i).get(1) +// .toString()) + 1; +// String name = "检验(" +// + properties.get(i).get(2).toString() + ")"; +// // 插入控制计划工序 +// SqlUtilT.write(new String[] { +// kzjhUid.toString().replace("-", ""), itemUid, +// properties.get(i).get(0), +// properties.get(i).get(1), +// properties.get(i).get(2), +// properties.get(i).get(3), "", "", "", "", "", +// "", "", "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", kzjhList.get(k).getType().toUpperCase(),"0","0","","0" }, insertSQL); +// if(!meopNameList.contains(properties.get(i).get(2).toString())) +// { +// // 插入控制计划巡检项 +// SqlUtilT.write( +// new String[] { +// UUID.randomUUID().toString() +// .replace("-", ""), itemUid, +// properties.get(i).get(0), +// number.toString(), name, +// "", "", "", "", +// "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", "", "", "", "", +// kzjhList.get(k).getType().toUpperCase(),"0","0","","0" }, insertSQL); +// } +// } +// } +// } +// } +// // 删除表中相应的工序 +// StringBuffer sb = new StringBuffer(); +// sb.append("("); +// for (int i = 0; i < properties.size(); i++) { +// sb.append("\'" + properties.get(i).get(0) + "\',"); +// } +// // 获取数据库连接 +// String selectSql = String +// .format(pro.getProperty("BOMCHECKSAVESELECT2"), +// itemUid, +// sb.toString().substring(0, sb.length() - 1) +// + ")"); +// resultSet = SqlUtilT.read(selectSql); +// List deleteList = new ArrayList(); +// while (resultSet.next()) { +// deleteList.add(resultSet.getString("RB3_MEOPID")); +// } +// if (deleteList != null && deleteList.size() > 0) { +// for (int i = 0; i < deleteList.size(); i++) { +// String deleteSQL = String.format( +// pro.getProperty("DELETE"), deleteList.get(i), +// itemUid); +// SqlUtilT.delete(deleteSQL); +// } +// } +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } finally { +// if (rs != null) { +// SqlUtilT.free(rs); +// } +// if (result != null) { +// SqlUtilT.free(result); +// } +// if (resultSet != null) { +// SqlUtilT.free(resultSet); +// } +// if (input != null) { +// try { +// input.close(); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// SqlUtilT.freeAll(); +// } +// } +//} diff --git a/src/com/connor/renben/process/plm/util/CreateItemHandler.java b/src/com/connor/renben/process/plm/util/CreateItemHandler.java new file mode 100644 index 0000000..a34ecd5 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/CreateItemHandler.java @@ -0,0 +1,18 @@ +package com.connor.renben.process.plm.util; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +public class CreateItemHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + String commandId = arg0.getCommand().getId(); + CreateNewBOHandler handler = new CreateNewBOHandler(commandId); + handler.execute(arg0); + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/util/CreateNewBOHandler.java b/src/com/connor/renben/process/plm/util/CreateNewBOHandler.java new file mode 100644 index 0000000..6cd7c6e --- /dev/null +++ b/src/com/connor/renben/process/plm/util/CreateNewBOHandler.java @@ -0,0 +1,209 @@ +package com.connor.renben.process.plm.util; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExecutableExtension; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.handlers.HandlerUtil; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.jface.wizard.WizardDialog; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.aifrcp.SelectionHelper; +import com.teamcenter.rac.kernel.TCSession; + +import com.teamcenter.rac.ui.commands.Messages; +import com.teamcenter.rac.ui.commands.RACUICommandsActivator; +import com.teamcenter.rac.ui.commands.create.bo.NewBOModel; +import com.teamcenter.rac.ui.commands.create.bo.NewBOWizard; +import com.teamcenter.rac.ui.commands.handlers.NewBOHandler; + +import com.teamcenter.rac.util.SWTUIUtilities; +import com.teamcenter.rac.util.UIUtilities; +import com.teamcenter.rac.util.wizard.extension.BaseExternalWizardDialog; +import com.teamcenter.rac.util.wizard.extension.WizardExtensionHelper; + +/** + * Our sample handler extends AbstractHandler, an IHandler base class. + * + * @see org.eclipse.core.commands.IHandler + * @see org.eclipse.core.commands.AbstractHandler + */ +public class CreateNewBOHandler extends AbstractHandler implements +IExecutableExtension { +private String itemtype; + +public CreateNewBOHandler(String itemtype) { +this.itemtype = itemtype; +} + +private class CreateNewBOSWTDialog implements Runnable { + +public void run() { + NewBOWizard newbowizard = (NewBOWizard) getWizard(); + if (newbowizard == null) + newbowizard = new NewBOWizard(wizardId); + m_boModel.setSession(session); + m_boModel.reInitializeTransientData(); + newbowizard.setBOModel(m_boModel); + newbowizard.setShell(m_shell); + newbowizard.setParentFrame(AIFUtility.getActiveDesktop()); + newbowizard.setTargetArray(selectedCmps); + newbowizard.setCurrentSelection(m_currentSelection); + newbowizard.setWindowTitle(getWizardTitle()); + newbowizard.setRevisionFlag(m_revisionFlag); + newbowizard.setDefaultType(m_type); + m_boModel.setRevisionFlag(m_revisionFlag); + // newbowizard.setWizardId("123"); + Shell shell = UIUtilities.getCurrentModalShell(); + dialog = new BaseExternalWizardDialog(m_shell, newbowizard); + dialog.create(); + +// dialog. + newbowizard.retrievePersistedDialogSettings(dialog); + newbowizard.setWizardDialog(dialog); + UIUtilities.setCurrentModalShell(dialog.getShell()); + dialog.open(); +// InterfaceAIFComponent[] aifComponent = m_boModel.getTargetArray(); +// if(aifComponent != null && aifComponent.length > 0) +// { +// com.teamcenter.rac.common.Activator.getDefault() +// .openPerspective("com.teamcenter.rac.cme.mpp.MSEPerspective"); +// com.teamcenter.rac.common.Activator.getDefault().openComponents( +// "com.teamcenter.rac.cme.mpp.MSEPerspective", +// aifComponent); +// } + dialog = null; + m_boModel = null; + UIUtilities.setCurrentModalShell(shell); + System.out.println("关闭"); +} + +private final Shell m_shell; +private boolean m_revisionFlag = false; +private final String m_type; +final CreateNewBOHandler this$0; + +private CreateNewBOSWTDialog(Shell shell, boolean flag, String s) { + super(); + this$0 = CreateNewBOHandler.this; + m_shell = shell; + m_revisionFlag = flag; + m_type = s; +} + +CreateNewBOSWTDialog(Shell shell, boolean flag, String s, + CreateNewBOSWTDialog createnewboswtdialog) { + this(shell, flag, s); +} +} + +public Object execute(ExecutionEvent executionevent) + throws ExecutionException { + + + +if (executionevent == null) + throw new IllegalArgumentException("Event can't be null"); +boolean flag = false; +if (executionevent.getParameters() != null + && executionevent.getParameters().containsKey("selection")) { + Object obj = executionevent.getParameters().get("selection"); + if (obj instanceof InterfaceAIFComponent[]) { + selectedCmps = (InterfaceAIFComponent[]) obj; + m_currentSelection = new StructuredSelection(selectedCmps); + flag = true; + } +} +if (!flag) { + m_currentSelection = HandlerUtil + .getCurrentSelection(executionevent); + selectedCmps = SelectionHelper + .getTargetComponents(m_currentSelection); +} +m_boModel = getBOModel(); +try { + session = (TCSession) RACUICommandsActivator.getDefault() + .getSession(); +} catch (Exception _ex) { + session = (TCSession) AIFUtility.getDefaultSession(); +} +launchWizard(executionevent); +return null; +} + +public void setInitializationData( + IConfigurationElement iconfigurationelement, String s, Object obj) + throws CoreException { +} + +protected NewBOModel getBOModel() { +if (m_boModel == null) + m_boModel = new NewBOModel(this); +return m_boModel; +} + +public Wizard getWizard() { +if (wizardId == null || wizardId.length() == 0) + wizardId = "com.teamcenter.rac.ui.commands.create.bo.NewBOWizard"; +return WizardExtensionHelper.getWizard(wizardId); +} + +public String getWizardTitle() { +return Messages.getString("wizard.TITLE"); +} + +public void launchWizard() { +launchWizard(null); +} + +public void launchWizard(ExecutionEvent executionevent) { +boolean flag = false; +// String s = "RT4Item"; +if (executionevent != null && executionevent.getParameters() != null) { + if (executionevent.getParameters().containsKey("revisionFlag")) + flag = ((Boolean) executionevent.getParameters().get( + "revisionFlag")).booleanValue(); + // s = (String)executionevent.getParameters().get("objectType"); + if (executionevent.getParameters().containsKey("pasteRelation")) { + String s1 = (String) executionevent.getParameters().get( + "pasteRelation"); + if (s1 != null) { + String as[] = null; + as = s1.split(","); + m_boModel.setRelType(as[0]); + m_boModel.setPreAssignedRelType(as); + } + } +} + + +AIFDesktop aifdesktop = AIFUtility.getActiveDesktop(); +Shell shell = aifdesktop.getShell(); +if (shell != null) + // if(itemtype!=null) + SWTUIUtilities.asyncExec(new CreateNewBOSWTDialog(shell, flag, + itemtype, null)); +} + +protected void readDisplayParameters(NewBOWizard newbowizard, + WizardDialog wizarddialog) { +newbowizard.retrievePersistedDialogSettings(wizarddialog); +} + +protected InterfaceAIFComponent selectedCmps[]; +protected ISelection m_currentSelection; +protected String wizardId; +protected BaseExternalWizardDialog dialog; +protected TCSession session; +protected NewBOModel m_boModel; +} diff --git a/src/com/connor/renben/process/plm/util/DDInClassDialog.java b/src/com/connor/renben/process/plm/util/DDInClassDialog.java new file mode 100644 index 0000000..de1b504 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/DDInClassDialog.java @@ -0,0 +1,528 @@ +//package com.connor.renben.process.plm.util; +// +//import java.awt.BorderLayout; +//import java.awt.event.ActionEvent; +//import java.awt.event.ActionListener; +//import java.util.ArrayList; +//import java.util.List; +// +//import javax.swing.DefaultListModel; +//import javax.swing.JButton; +//import javax.swing.JList; +//import javax.swing.JPanel; +//import javax.swing.JScrollPane; +//import javax.swing.JTabbedPane; +// +//import com.connor.renben.process.plm.tmom005.TMom005CreateOPByModuleOperation; +//import com.connor.renben.process.plm.tmom006.TMom006CreateProcessByProcessOperation; +//import com.connor.renben.process.plm.tmom007.TMom007ResourcesAssignedOperation; +//import com.teamcenter.rac.aif.AbstractAIFUIApplication; +//import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +//import com.teamcenter.rac.classification.common.G4MInClassDialog; +//import com.teamcenter.rac.classification.common.table.G4MTable; +//import com.teamcenter.rac.classification.common.table.G4MTableModel; +//import com.teamcenter.rac.classification.common.tree.G4MTree; +//import com.teamcenter.rac.commands.paste.PasteCommand; +//import com.teamcenter.rac.kernel.TCClassificationService; +//import com.teamcenter.rac.kernel.TCComponent; +//import com.teamcenter.rac.kernel.TCComponentItem; +//import com.teamcenter.rac.kernel.TCComponentItemRevision; +//import com.teamcenter.rac.kernel.TCException; +//import com.teamcenter.rac.kernel.TCPreferenceService; +//import com.teamcenter.rac.kernel.TCSession; +//import com.teamcenter.rac.kernel.ics.ICSHierarchyNodeDescriptor; +//import com.teamcenter.rac.util.ButtonLayout; +//import com.teamcenter.rac.util.HorizontalLayout; +//import com.teamcenter.rac.util.MessageBox; +//import com.teamcenter.rac.util.Registry; +//import com.teamcenter.rac.util.SplitPane; +//import com.teamcenter.rac.util.Utilities; +//import com.teamcenter.rac.util.VerticalLayout; +// +////import org.apache.log4j.Logger; +// +//public class DDInClassDialog extends G4MInClassDialog { +// private Registry m_reg; +// private TCSession m_session; +// protected InterfaceAIFComponent targets; +// private ArrayList listComps; +// private TCClassificationService m_ics; +// private JButton addButton; +// private JButton removeButton; +// private ArrayList objectsToBePasted = new ArrayList(); +// private ArrayList childrenList = new ArrayList(); +// private DefaultListModel selectedDictionaryListModel; +// private JList selectedDictionaryList; +// private TCPreferenceService m_filterPrefService; +// private String[] m_filterValues; +// private static final long serialVersionUID = 1L; +// private String commandId; +// +// // private static final Logger logger = +// // Logger.getLogger(DDInClassDialog.class); +// +// public DDInClassDialog( +// AbstractAIFUIApplication paramAbstractAIFUIApplication, +// InterfaceAIFComponent paramTCComponentBOMLine, int paramInt) { +// super(paramAbstractAIFUIApplication, paramInt); +// this.m_reg = Registry.getRegistry(DDInClassDialog.class); +// this.targets = paramTCComponentBOMLine; +// this.m_session = ((TCSession) paramAbstractAIFUIApplication +// .getSession()); +// this.m_ics = this.m_session.getClassificationService(); +// buildInitialization(); +// } +// +// public DDInClassDialog( +// AbstractAIFUIApplication paramAbstractAIFUIApplication, +// InterfaceAIFComponent paramTCComponentBOMLine, int paramInt, +// String commandId) { +// super(paramAbstractAIFUIApplication, paramInt); +// this.m_reg = Registry.getRegistry(DDInClassDialog.class); +// this.targets = paramTCComponentBOMLine; +// this.m_session = ((TCSession) paramAbstractAIFUIApplication +// .getSession()); +// this.m_ics = this.m_session.getClassificationService(); +// this.commandId = commandId; +// buildInitialization(); +// } +// +// public DDInClassDialog( +// AbstractAIFUIApplication paramAbstractAIFUIApplication, +// int paramInt, boolean paramBoolean) { +// super(paramAbstractAIFUIApplication, paramInt, paramBoolean); +// } +// +// public DDInClassDialog( +// AbstractAIFUIApplication paramAbstractAIFUIApplication, int paramInt) { +// super(paramAbstractAIFUIApplication, paramInt); +// } +// +// public DDInClassDialog( +// AbstractAIFUIApplication paramAbstractAIFUIApplication) { +// super(paramAbstractAIFUIApplication); +// } +// +// private void buildInitialization() { +// setTitle(this.m_reg.getString("DDInClassDialog.TITLE")); +// super.setTitleText(this.m_reg.getString("DDInClassDialog.TITLE")); +// JPanel localJPanel1 = new JPanel(new BorderLayout()); +// JPanel localJPanel2 = tableListPanel(); +// SplitPane localSplitPane = new SplitPane(1); +// localSplitPane.setTopComponent(localJPanel2); +// localSplitPane.setDividerLocation(0.95D); +// JPanel localJPanel3 = createButtonPanel(); +// localJPanel1.add("Center", localSplitPane); +// localJPanel1.add("South", localJPanel3); +// setContentPane(localJPanel1); +// } +// +// protected void initializeDialogBasedOnCookie() { +// setPersistentDisplayCookieFileName(G4MInClassDialog.COOKIE_FILENAME); +// setPersistentDisplay(true); +// setLocation(100, 100); +// pack(); +// setSize(700, 400); +// readDisplayParameters(); +// } +// +// private JPanel tableListPanel() { +// JPanel localJPanel1 = new JPanel(new HorizontalLayout(10, 10, 10, 10, +// 10)); +// JPanel localJPanel2 = treeTablePanel(); +// JPanel localJPanel3 = buildAddandRemoveButtonPanel(); +// JPanel localJPanel4 = new JPanel(new BorderLayout()); +// localJPanel4.add(localJPanel2, "Center"); +// localJPanel1.add("unbound.bind", localJPanel4); +// localJPanel1.add("right.bind.center.center", localJPanel3); +// JPanel localJPanel5 = buildSelectedDictionaryPanel(this.m_session, +// this.m_reg); +// SplitPane localSplitPane = new SplitPane(0); +// localSplitPane.setLeftComponent(localJPanel1); +// localSplitPane.setRightComponent(new JScrollPane(localJPanel5)); +// localSplitPane.setDividerLocation(0.85D); +// JPanel localJPanel6 = new JPanel(new BorderLayout()); +// localJPanel6.add(localSplitPane, "Center"); +// return localJPanel6; +// } +// +// protected JPanel buildAddandRemoveButtonPanel() { +// JPanel localJPanel = new JPanel(); +// localJPanel.setLayout(new ButtonLayout(2)); +// this.addButton = new JButton( +// this.m_reg.getImageIcon("quickAddButton.ICON")); +// this.listComps = new ArrayList(); +// this.addButton.addActionListener(new ActionListener() { +// public void actionPerformed(ActionEvent paramAnonymousActionEvent) { +// DDInClassDialog.this.addSelectedNodeAction(); +// } +// }); +// this.listComps.clear(); +// localJPanel.add(this.addButton); +// this.removeButton = new JButton(this.m_reg.getImageIcon("minus.ICON")); +// this.removeButton.addActionListener(new ActionListener() { +// public void actionPerformed(ActionEvent paramAnonymousActionEvent) { +// DDInClassDialog.this.removeSelectedNodeAction(); +// } +// }); +// localJPanel.add(this.removeButton); +// return localJPanel; +// } +// +// protected JPanel createButtonPanel() { +// JPanel localJPanel = new JPanel(); +// JButton localJButton = new JButton(this.m_reg.getString("cancel.NAME")); +// this.m_okButton = new JButton(this.m_reg.getString("oK.NAME")); +// this.m_okButton.addActionListener(this); +// if (this.selectedDictionaryListModel.getSize() > 0) { +// this.m_okButton.setEnabled(true); +// } +// localJButton.addActionListener(new ActionListener() { +// public void actionPerformed(ActionEvent paramAnonymousActionEvent) { +// DDInClassDialog.this.closeDialogs(); +// } +// }); +// localJPanel.add(this.m_okButton); +// localJPanel.add(localJButton); +// return localJPanel; +// } +// +// private JPanel treeTablePanel() { +// setLayout(new BorderLayout()); +// JTabbedPane localJTabbedPane = createMainTabbedPane(); +// this.m_filterPrefService = this.m_session.getPreferenceService(); +// this.m_filterValues = this.m_filterPrefService +// .getStringValues("ICS_FilterBy_Library_types"); +// if (this.m_filterValues == null) { +// this.m_filterValues = new String[0]; +// } +// String[] arrayOfString = getAssoicateToProjectClassID(); +// if ((arrayOfString != null) && (arrayOfString.length > 0)) { +// this.m_tree = new G4MTree(this.m_context, true, +// this.m_filterValues, "Library"); +// this.m_tree.addG4MTreeListener(this); +// this.m_tree.setReducedClassList(arrayOfString); +// this.m_tree.refresh("ICM", true, false); +// } else { +// this.m_tree = new G4MTree(this.m_context, true, +// this.m_filterValues, "Library"); +// this.m_tree.addG4MTreeListener(this); +// } +// SplitPane localSplitPane = new SplitPane(0); +// localSplitPane.setDividerSize(2); +// localSplitPane.setDividerLocation(0.4D); +// localSplitPane.setLeftComponent(this.m_tree); +// localSplitPane.getLeftComponent().validate(); +// localSplitPane.setRightComponent(localJTabbedPane); +// localSplitPane.getRightComponent().validate(); +// JPanel localJPanel = new JPanel(new BorderLayout()); +// localJPanel.add(localSplitPane, "Center"); +// return localJPanel; +// } +// +// private String[] getAssoicateToProjectClassID() { +// String[] arrayOfString1 = null; +// ArrayList localArrayList1 = new ArrayList(); +// TCComponent[] arrayOfTCComponent1 = null; +// try { +// TCComponentItem localTCComponentItem = ((TCComponentItemRevision) this.targets) +// .getItem(); +// arrayOfTCComponent1 = localTCComponentItem +// .getReferenceListProperty("project_list"); +// TCClassificationService localTCClassificationService = this.m_session +// .getClassificationService(); +// int i; +// if ((arrayOfTCComponent1 != null) +// && (arrayOfTCComponent1.length > 0)) { +// for (i = 0; i < arrayOfTCComponent1.length; i++) { +// TCComponent[] arrayOfTCComponent2 = arrayOfTCComponent1[i] +// .getRelatedComponents("Fnd0LibraryForProject"); +// if (arrayOfTCComponent2.length > 0) { +// for (int j = 0; j < arrayOfTCComponent2.length; j++) { +// ICSHierarchyNodeDescriptor localICSHierarchyNodeDescriptor = localTCClassificationService +// .describeNode(arrayOfTCComponent2[j] +// .getProperty("cid"), 0); +// ICSHierarchyNodeDescriptor[] arrayOfICSHierarchyNodeDescriptor = this.m_context +// .getChildren( +// localICSHierarchyNodeDescriptor +// .getId(), +// localICSHierarchyNodeDescriptor +// .getClassChildrenCount()); +// String[] arrayOfString2 = this.m_context +// .getParents(arrayOfTCComponent2[j] +// .getProperty("cid")); +// if (arrayOfString2.length > 0) { +// for (int k = 0; k < arrayOfString2.length; k++) { +// localArrayList1.add(arrayOfString2[k]); +// } +// if (arrayOfICSHierarchyNodeDescriptor != null) { +// ArrayList localArrayList2 = new ArrayList(); +// localArrayList2 = getAssociateChildrensClassID(localICSHierarchyNodeDescriptor); +// for (int m = 0; m < localArrayList2.size(); m++) { +// localArrayList1.add(localArrayList2 +// .get(m)); +// } +// } +// localArrayList1.add(arrayOfTCComponent2[j] +// .getProperty("cid")); +// } +// } +// } +// } +// } +// if (localArrayList1 != null) { +// arrayOfString1 = new String[localArrayList1.size()]; +// for (i = 0; i < localArrayList1.size(); i++) { +// arrayOfString1[i] = ((String) localArrayList1.get(i)); +// } +// } +// } catch (Exception localException) { +// } +// return arrayOfString1; +// } +// +// private ArrayList getAssociateChildrensClassID( +// ICSHierarchyNodeDescriptor paramICSHierarchyNodeDescriptor) { +// ICSHierarchyNodeDescriptor[] arrayOfICSHierarchyNodeDescriptor = this.m_context +// .getChildren(paramICSHierarchyNodeDescriptor.getId(), +// paramICSHierarchyNodeDescriptor.getClassChildrenCount()); +// if (arrayOfICSHierarchyNodeDescriptor != null) { +// for (int i = 0; i < arrayOfICSHierarchyNodeDescriptor.length; i++) { +// getAssociateChildrensClassID(arrayOfICSHierarchyNodeDescriptor[i]); +// this.childrenList.add(arrayOfICSHierarchyNodeDescriptor[i] +// .getId()); +// } +// } +// return this.childrenList; +// } +// +// private void performOKAction() { +// this.selectedDictionaryListModel = ((DefaultListModel) this.selectedDictionaryList +// .getModel()); +// if (this.selectedDictionaryListModel.getSize() > 0) { +// Object[] arrayOfObject = this.selectedDictionaryListModel.toArray(); +// int i = arrayOfObject.length; +// for (int j = 0; j < i; j++) { +// TCComponent localTCComponent = (TCComponent) this.selectedDictionaryListModel +// .get(j); +// this.objectsToBePasted.add(localTCComponent); +// } +// } +// try { +// if (this.objectsToBePasted.size() > 0) { +// callPasteObjects(this.objectsToBePasted); +// } +// this.listComps.clear(); +// disposeDialog(); +// } catch (Exception localException) { +// // logger.error(localException.getClass().getName(), +// // localException); +// } +// } +// +// private void callPasteObjects(ArrayList paramArrayList) throws Exception { +// InterfaceAIFComponent[] arrayOfInterfaceAIFComponent = { this.targets }; +// TCComponent[] arrayOfTCComponent = null; +// PasteCommand localPasteCommand = null; +// arrayOfTCComponent = new TCComponent[paramArrayList.size()]; +// arrayOfTCComponent = (TCComponent[]) paramArrayList +// .toArray(arrayOfTCComponent); +// localPasteCommand = new PasteCommand(arrayOfTCComponent, +// arrayOfInterfaceAIFComponent, Boolean.TRUE); +// localPasteCommand.setFailBackFlag(true); +// localPasteCommand.executeModal(); +// } +// +// public void actionPerformed(ActionEvent paramActionEvent) { +// if (paramActionEvent.getSource() == this.m_clearButton.getButton()) { +// this.m_OIDtextField.setText(""); +// this.m_compTextField.setText(""); +// } else if (paramActionEvent.getSource() == this.m_okButton) { +// // String s = this.m_OIDtextField.getText(); +// // String s1 = this.m_compTextField.getText(); +// // MessageBox.post("确定按钮!", "错误!", 1); +// // performOKAction(); +// switch (commandId) { +// case "com.connor.renben.process.plm.commands.CreateOPByModule": +// TMom005CreateOPByModuleOperation createOPOperation = new TMom005CreateOPByModuleOperation( +// this.m_session, this.targets, +// this.m_compTextField.getText()); +// this.m_session.queueOperation(createOPOperation); +// break; +// case "com.connor.renben.process.plm.commands.CreateProcessByModule": +// TMom006CreateProcessByProcessOperation createProcessOperation = new TMom006CreateProcessByProcessOperation( +// targets, this.m_compTextField.getText(), this.m_session); +// this.m_session.queueOperation(createProcessOperation); +// break; +// case "com.connor.renben.process.plm.commands.ResourcesAssigned": +// TMom007ResourcesAssignedOperation resourcesAssignedOperation = new TMom007ResourcesAssignedOperation( +// targets, this.m_compTextField.getText(), this.m_session); +// this.m_session.queueOperation(resourcesAssignedOperation); +// break; +// +// default: +// break; +// } +// } else if (paramActionEvent.getSource() == this.m_searchButton) { +// performAttributeSearch(); +// } else { +// performObjectIDSearch(); +// } +// } +// +// private void addSelectedNodeAction() { +// int i = 1; +// ArrayList localArrayList = new ArrayList(); +// DefaultListModel localDefaultListModel = (DefaultListModel) this.selectedDictionaryList +// .getModel(); +// int j = this.m_tabbedPane.getSelectedIndex(); +// TCComponent localTCComponent = null; +// Object localObject1; +// Object localObject2; +// Object localObject3; +// if (j == 1) { +// localObject1 = this.m_context.getICSApplicationObject() +// .getClassifiedObjectUid(); +// try { +// localTCComponent = this.m_ics +// .getTCComponent((String) localObject1); +// if (!this.listComps.contains(localTCComponent)) { +// localDefaultListModel.addElement(localTCComponent); +// this.listComps.add(localTCComponent); +// this.selectedDictionaryList.setModel(localDefaultListModel); +// } else { +// localArrayList.add(localTCComponent); +// i = 0; +// } +// } catch (TCException localTCException1) { +// // logger.error(localTCException1.getClass().getName(), +// // localTCException1); +// } +// } else if (j == 2) { +// localObject1 = this.m_tablePane.getG4MTable(); +// if (localObject1 != null) { +// G4MTableModel localG4MTableModel = ((G4MTable) localObject1) +// .getG4MTableModel(); +// localObject2 = null; +// localObject3 = ((G4MTable) localObject1).getSelectedRows(); +// if (((int[]) localObject3).length == 0) { +// return; +// } +// for (int m = 0; m < ((int[]) localObject3).length; m++) { +// String str2 = localG4MTableModel.getValueAt( +// ((int[]) localObject3)[m], +// localG4MTableModel.getWSOColumnNo()).toString(); +// if ((str2 != null) && (str2.length() > 0)) { +// try { +// localObject2 = this.m_ics.getTCComponent(str2); +// if (!this.listComps.contains(localObject2)) { +// localDefaultListModel.addElement(localObject2); +// this.listComps.add((TCComponent) localObject2); +// this.selectedDictionaryList +// .setModel(localDefaultListModel); +// } else { +// localArrayList.add(localObject2); +// i = 0; +// } +// } catch (TCException localTCException2) { +// // logger.error(localTCException2.getClass().getName(), +// // localTCException2); +// } +// } else { +// MessageBox +// .post(Utilities.getCurrentFrame(), +// this.m_reg +// .getString("invalidSelectedObject.MESSAGE"), +// this.m_reg +// .getString("absOccIllegalSelection.TITLE"), +// 1); +// } +// if (this.m_tree != null) { +// this.m_tree.getTree().getSelectionModel() +// .clearSelection(); +// } +// } +// } +// } +// if (i == 0) { +// localObject1 = new StringBuffer(); +// if (localArrayList.size() > 0) { +// for (int k = 0; k < localArrayList.size(); k++) { +// if (((StringBuffer) localObject1).length() > 0) { +// ((StringBuffer) localObject1).append(","); +// } +// ((StringBuffer) localObject1).append(localArrayList.get(k)); +// } +// } +// if (((StringBuffer) localObject1).length() > 0) { +// Registry localRegistry = Registry.getRegistry(this); +// localObject2 = localRegistry +// .getString("duplicateAdded.MESSAGE"); +// localObject3 = ((String) localObject2).substring(0, +// ((String) localObject2).indexOf("%1")); +// String str1 = ((String) localObject2) +// .substring(((String) localObject2).indexOf("%1") + 2); +// MessageBox.post( +// Utilities.getCurrentFrame(), +// localObject3 + "[" +// + ((StringBuffer) localObject1).toString() +// + "]" + str1, +// localRegistry.getString("duplicateAdded.TITLE"), 1); +// } +// } +// } +// +// private void removeSelectedNodeAction() { +// List localList = this.selectedDictionaryList.getSelectedValuesList(); +// if ((localList != null) && (localList.size() > 0)) { +// for (int i = 0; i < localList.size(); i++) { +// this.selectedDictionaryListModel +// .removeElement(localList.get(i)); +// this.listComps.remove(localList.get(i)); +// } +// } +// if (this.selectedDictionaryList.getSelectedValue() != null) { +// this.selectedDictionaryListModel +// .removeElement(this.selectedDictionaryList +// .getSelectedValue()); +// this.listComps.remove(this.selectedDictionaryList +// .getSelectedValue()); +// } +// } +// +// protected JPanel buildSelectedDictionaryPanel(TCSession paramTCSession, +// Registry paramRegistry) { +// this.selectedDictionaryListModel = new DefaultListModel(); +// this.selectedDictionaryList = new JList( +// this.selectedDictionaryListModel); +// this.selectedDictionaryList.setSelectionMode(2); +// JScrollPane localJScrollPane = new JScrollPane( +// this.selectedDictionaryList, 20, 30); +// JPanel localJPanel1 = new JPanel(new VerticalLayout(3, 3, 3, 3, 3)); +// localJPanel1.add("unbound", localJScrollPane); +// JPanel localJPanel2 = new JPanel(new BorderLayout()); +// localJPanel2.add(localJPanel1, "Center"); +// JPanel localJPanel3 = new JPanel(new HorizontalLayout(3, 3, 3, 3, 3)); +// localJPanel3.add("unbound.bind", localJPanel2); +// return localJPanel3; +// } +// +// public ArrayList getObjectsToBePasted() { +// if ((this.objectsToBePasted == null) +// || (this.objectsToBePasted.size() == 0)) { +// this.selectedDictionaryListModel = ((DefaultListModel) this.selectedDictionaryList +// .getModel()); +// if (this.selectedDictionaryListModel.getSize() > 0) { +// Object[] arrayOfObject = this.selectedDictionaryListModel +// .toArray(); +// int i = arrayOfObject.length; +// for (int j = 0; j < i; j++) { +// TCComponent localTCComponent = (TCComponent) this.selectedDictionaryListModel +// .get(j); +// this.objectsToBePasted.add(localTCComponent); +// } +// } +// } +// return this.objectsToBePasted; +// } +//} diff --git a/src/com/connor/renben/process/plm/util/DraggableTabbedPane.java b/src/com/connor/renben/process/plm/util/DraggableTabbedPane.java new file mode 100644 index 0000000..969e917 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/DraggableTabbedPane.java @@ -0,0 +1,76 @@ +package com.connor.renben.process.plm.util; + +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseMotionAdapter; +import java.awt.image.BufferedImage; + +import javax.swing.JTabbedPane; + +public class DraggableTabbedPane extends JTabbedPane { + private boolean dragging = false; + private Image tabImage = null; + private Point currentMouseLocation = null; + private int draggedTabIndex = 0; + public DraggableTabbedPane() { + super(); + addMouseMotionListener(new MouseMotionAdapter() { + public void mouseDragged(MouseEvent e) { + if(!dragging) { + //Gets the tab index based on the mouse position + int tabNumber = getUI().tabForCoordinate(DraggableTabbedPane.this, e.getX(), e.getY()); + if(tabNumber >= 0) { + draggedTabIndex = tabNumber; + Rectangle bounds = getUI().getTabBounds(DraggableTabbedPane.this, tabNumber); + //Paint the tabbed pane to a buffer + Image totalImage = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB); + Graphics totalGraphics = totalImage.getGraphics(); + totalGraphics.setClip(bounds); + //Don't be double buffered when painting to a static image. + setDoubleBuffered(false); + paintComponent(totalGraphics); + //Paint just the dragged tab to the buffer + tabImage = new BufferedImage(bounds.width, bounds.height, BufferedImage.TYPE_INT_ARGB); + Graphics graphics = tabImage.getGraphics(); + graphics.drawImage(totalImage, 0, 0, bounds.width, bounds.height, bounds.x, bounds.y, bounds.x + bounds.width, bounds.y+bounds.height, DraggableTabbedPane.this); + dragging = true; + repaint(); + } + } else { + currentMouseLocation = e.getPoint(); + //Need to repaint + repaint(); + } + super.mouseDragged(e); + } + }); + addMouseListener(new MouseAdapter() { + public void mouseReleased(MouseEvent e) { + if(dragging) { + int tabNumber = getUI().tabForCoordinate(DraggableTabbedPane.this, e.getX(), 10); + if(tabNumber >= 0) { + Component comp = getComponentAt(draggedTabIndex); + String title = getTitleAt(draggedTabIndex); + removeTabAt(draggedTabIndex); + insertTab(title, null, comp, null, tabNumber); + } + } + dragging = false; + tabImage = null; + } + }); + } + protected void paintComponent(Graphics g) { + super.paintComponent(g); + //Are we dragging? + if(dragging && currentMouseLocation!= null && tabImage!= null) { + //Draw the dragged tab + g.drawImage(tabImage, currentMouseLocation.x, currentMouseLocation.y, this); + } + } +} diff --git a/src/com/connor/renben/process/plm/util/ExcelFilter.java b/src/com/connor/renben/process/plm/util/ExcelFilter.java new file mode 100644 index 0000000..51d0bbd --- /dev/null +++ b/src/com/connor/renben/process/plm/util/ExcelFilter.java @@ -0,0 +1,33 @@ +package com.connor.renben.process.plm.util; + +import java.io.File; + +import javax.swing.filechooser.FileFilter; + +public class ExcelFilter extends FileFilter { + public boolean accept(File f) { + if (f.isDirectory()) { + return true; + } + String fileName = f.getName(); + int index = fileName.lastIndexOf('.'); + String extension = ""; + if (index > 0 && index < fileName.length() - 1) { + extension = fileName.substring(index + 1).toLowerCase(); + } + if (extension != null) { + if (extension.equals("xls") || extension.equals("xlsx") + || extension.equals("xlt") || extension.equals("xlsm")) { + return true; + } else { + return false; + } + } + return false; + } + + public String getDescription() { + return "Excel文件(*.xls, *.xlsx, *.xlt, *.xlsm)"; + } + +} diff --git a/src/com/connor/renben/process/plm/util/ExcelUtil.java b/src/com/connor/renben/process/plm/util/ExcelUtil.java new file mode 100644 index 0000000..479903a --- /dev/null +++ b/src/com/connor/renben/process/plm/util/ExcelUtil.java @@ -0,0 +1,1213 @@ +package com.connor.renben.process.plm.util; + +import java.awt.image.BufferedImage; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Vector; + +import javax.imageio.ImageIO; + + +import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.hssf.usermodel.HSSFCellStyle; +import org.apache.poi.hssf.usermodel.HSSFClientAnchor; +import org.apache.poi.hssf.usermodel.HSSFFont; +import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator; +import org.apache.poi.hssf.usermodel.HSSFName; +import org.apache.poi.hssf.usermodel.HSSFPatriarch; +import org.apache.poi.hssf.usermodel.HSSFRichTextString; +import org.apache.poi.hssf.usermodel.HSSFRow; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.SpreadsheetVersion; +import org.apache.poi.ss.usermodel.BorderStyle; +//import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.ss.usermodel.CellValue; +//import org.apache.poi.ss.usermodel.ClientAnchor.AnchorType; +import org.apache.poi.ss.usermodel.IndexedColors; +import org.apache.poi.ss.util.AreaReference; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.ss.util.CellReference; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFFont; +import org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator; +import org.apache.poi.xssf.usermodel.XSSFName; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; + +/** + * Excel 签名 + * + * @author hub 2015-09-06 + */ +public class ExcelUtil { + // private static Registry reg = Registry.getRegistry(this); + // private static HSSFSheet sheet; + // private static final int MY_ROWS = 46; + private SimpleDateFormat dateFormat = new SimpleDateFormat( + "yyyy-M-dd HH:mm"); + + /** + * 读取EXCEL表 + * + * @param File + * excel_file + * @return List> 返回的信息 + * @throws IOException + * @throws FileNotFoundException + */ +// public static List> readExcel(File excel_file) +// throws FileNotFoundException, IOException { +// if (excel_file == null || !excel_file.exists()) { +// return null; +// } +// // 用来返回的所有的行的信息 +// List> lines_msg = new ArrayList>(); +// HSSFWorkbook workBook = new HSSFWorkbook( +// new FileInputStream(excel_file)); +// HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(workBook); +// HSSFSheet sheet = workBook.getSheetAt(0); +// HSSFRow title_row = sheet.getRow(0); +// // 得到列的数目 +// int col_count = title_row.getPhysicalNumberOfCells(); +// System.out.println(" SHEET COL COUNT " + col_count); +// // 得到行的数目 +// int row_count = sheet.getLastRowNum(); +// +// System.out.println(" SHEET ROW COUNT " + row_count); +// for (int j = 0; j < row_count + 1; j++) { +// // 用来返回单行的信息 +// HSSFRow row = sheet.getRow(j); +// List line_msg = new ArrayList(); +// for (int i = 0; i < col_count; i++) { +// String value = getStringCellValue(evaluator, +// row.getCell((short) i)); +// line_msg.add(value); +// } +// lines_msg.add(line_msg); +// } +// // insertRow(sheet,4,1); +// return lines_msg; +// } +// +// public void writeSignName(String intExcelFilePath, String outExcelFilePath, +// String signName, String msgValue, int sheetIndex, int rowIndex, +// int cellIndex) throws IOException { +// // 输出文件的路径 +// FileOutputStream outPut = new FileOutputStream(new File( +// outExcelFilePath)); +// // 输入文件的路径 +// FileInputStream inPut = new FileInputStream(new File(intExcelFilePath)); +// HSSFWorkbook wb = new HSSFWorkbook(inPut); +// wb.getName(""); +// +//// AreaReference.generateContiguous(null, msgValue) +// AreaReference[] areaR2 = AreaReference.generateContiguous( SpreadsheetVersion.EXCEL2007,wb +// .getName("").getRefersToFormula()); +// AreaReference areaR = null; +// CellReference[] cellR = areaR.getAllReferencedCells(); +// cellR[0].getSheetName();// s +// cellR[0].getCol();// +// cellR[0].getRow();// +// HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(wb); +// HSSFSheet sheet = wb.getSheetAt(sheetIndex); +// HSSFRow row = sheet.getRow(rowIndex); +// +// HSSFCell cell = row.getCell(cellIndex); +// String value = getStringCellValue(evaluator, cell); +// if (value.startsWith(signName)) { +// value = value.substring(0, signName.length()); +// } +// +// cell.setCellValue(value + msgValue); +// wb.write(outPut); +// inPut.close(); +// outPut.close(); +// } + + /** + * 设置单元格中指定字体的样式 + * + * @param wb + * @param s + * 内容 + * @param firstIndex + * 起始位置 + * @param lastIndex + * 结束位置 + * @param fontSize + * 字体大小 + * @param FontName + * 字体样式 + * @return + */ + public static HSSFRichTextString setCellFont(HSSFWorkbook wb, String s, + int firstIndex, int lastIndex, int fontSize, String FontName) { + HSSFRichTextString ts = new HSSFRichTextString(s); + HSSFFont font1 = (HSSFFont) wb.createFont(); + font1.setFontHeightInPoints((short) 8); // 字体高度 + font1.setFontName("宋体"); // 字体 + // font1.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); // 宽度 + HSSFFont font = (HSSFFont) wb.createFont(); + font.setFontHeightInPoints((short) fontSize); // 字体高度 + font.setFontName(FontName); // 字体 + // font.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); // 宽度 + ts.applyFont(firstIndex, lastIndex, font); + ts.applyFont(lastIndex, ts.length(), font1); + return ts; + } + /** + * 设置单元格中指定字体的样式 + * + * @param wb + * @param s + * 内容 + * @param firstIndex + * 起始位置 + * @param lastIndex + * 结束位置 + * @param fontSize + * 字体大小 + * @param FontName + * 字体样式 + * @return + */ + public static HSSFRichTextString setCellFont_XSSF(XSSFWorkbook wb, String s, + int firstIndex, int lastIndex, int fontSize, String FontName) { + HSSFRichTextString ts = new HSSFRichTextString(s); + XSSFFont font1 = (XSSFFont) wb.createFont(); + font1.setFontHeightInPoints((short) 8); // 字体高度 + font1.setFontName("宋体"); // 字体 + // font1.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); // 宽度 + XSSFFont font = (XSSFFont) wb.createFont(); + font.setFontHeightInPoints((short) fontSize); // 字体高度 + font.setFontName(FontName); // 字体 + // font.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); // 宽度 + ts.applyFont(firstIndex, lastIndex, font); + ts.applyFont(lastIndex, ts.length(), font1); + return ts; + } + + /** + * 合并单元格sheet.addMergedRegion(new CellRangeAddress(check_index-1, + * check_index+12+check_rows, 0, 0)); + * + * @param startRow + * @param endRow + * @return + */ + public static boolean combine(HSSFSheet sheet, int[] rows, int[] columns) { + boolean isOK = false; + if (rows.length > 0 && columns.length > 0) { + sheet.addMergedRegion(new CellRangeAddress(rows[0], + rows[rows.length - 1], columns[0], + columns[columns.length - 1])); + isOK = true; + } + return isOK; + } + /** + * 合并单元格sheet.addMergedRegion(new CellRangeAddress(check_index-1, + * check_index+12+check_rows, 0, 0)); + * + * @param startRow + * @param endRow + * @return + */ + public static boolean combine_XSSF(XSSFSheet sheet, int[] rows, int[] columns) { + boolean isOK = false; + + try { + + for(int t=0;t "+rows[t]); + } + + if ((rows.length > 0 && columns.length > 0 ) && (rows.length > 1 || columns.length > 1 )) { + sheet.addMergedRegion(new CellRangeAddress(rows[0], + rows[rows.length - 1], columns[0], + columns[columns.length - 1])); + isOK = true; + } + } catch (Exception e) { + // TODO: handle exception + System.out.println(e.getMessage()); + } + + + return isOK; + } + + /** + * 获取单个的命名单元格的列 + * + * @param wb + * @param cellName + * @return + * @throws IOException + */ +// public static int getNamedColumnIndex(HSSFWorkbook wb, String cellName) +// throws IOException { +// int index = -1; +// HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(wb); +// HSSFName name = wb.getName(cellName); +// if (name == null) { +// return -1; +// } +// AreaReference[] areaRs = AreaReference.generateContiguous(SpreadsheetVersion.EXCEL2007,name +// .getRefersToFormula()); +// if (areaRs != null) +// for (AreaReference areaR : areaRs) { +// CellReference[] cellRs = areaR.getAllReferencedCells(); +// if (cellRs != null) { +// for (CellReference cellR : cellRs) { +// String sheetName = cellR.getSheetName(); +// short colIndex = cellR.getCol(); +// int rowIndex = cellR.getRow(); +// HSSFSheet sheet = wb.getSheet(sheetName); +// HSSFRow row = sheet.getRow(rowIndex); +// return colIndex; +// } +// } +// } +// return index; +// } +// /** +// * 获取单个的命名单元格的列 +// * +// * @param wb +// * @param cellName +// * @return +// * @throws IOException +// */ +// public static int getNamedColumnIndex_XSSF(XSSFWorkbook wb, String cellName) +// throws IOException { +// int index = -1; +// XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(wb); +// XSSFName name = wb.getName(cellName); +// if (name == null) { +// return -1; +// } +// AreaReference[] areaRs = AreaReference.generateContiguous(SpreadsheetVersion.EXCEL2007,name +// .getRefersToFormula()); +// if (areaRs != null) +// for (AreaReference areaR : areaRs) { +// CellReference[] cellRs = areaR.getAllReferencedCells(); +// if (cellRs != null) { +// for (CellReference cellR : cellRs) { +// String sheetName = cellR.getSheetName(); +// short colIndex = cellR.getCol(); +// int rowIndex = cellR.getRow(); +// XSSFSheet sheet = wb.getSheet(sheetName); +// XSSFRow row = sheet.getRow(rowIndex); +// return colIndex; +// } +// } +// } +// return index; +// } + + /** + * 添加命名的引用 + * + * @param session + * @param item + * 对象的版本 + * @param tcResource + * 文件的物理路径 + * @param relationName + * 关系名称 + */ + public static void setExcelToItem(TCSession session, + TCComponentItemRevision item, String tcResource, String fileName, + boolean isDelete) { + try { + String as1[] = { tcResource };// 文件的物理路径 + String as2[] = { "excel" }; + String as3[] = { "MSExcel" }; + String as4[] = { "Plain" }; + TCComponentDatasetType tccomponentDatasetType = (TCComponentDatasetType) session + .getTypeComponent("Dataset"); + TCComponentDataset tccomponentDataset = tccomponentDatasetType + .create(fileName, "excel", "MSExcel"); + tccomponentDataset.setFiles(as1, as3, as4, as2); + AIFComponentContext[] zyzdsChildrens = item.getChildren(); + TCComponentItemRevision zyzdsRev = item; + for (AIFComponentContext zyzdsChildren : zyzdsChildrens) { + if ("MSExcel".equals(zyzdsChildren.getComponent().getType())) { + TCComponentDataset dateSet = (TCComponentDataset) zyzdsChildren + .getComponent(); + zyzdsRev.remove("TC_Attaches", dateSet); + dateSet.delete(); + } + } + item.add("TC_Attaches", tccomponentDataset); + if (isDelete) { + new File(tcResource).delete(); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * 获取单个的命名单元格的内容 + * + * @param wb + * @param cellName + * @return + * @throws IOException + */ +// public static String getNamedCellValue(HSSFWorkbook wb, String cellName) +// throws IOException { +// String value = null; +// HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(wb); +// HSSFName name = wb.getName(cellName); +// AreaReference[] areaRs = AreaReference.generateContiguous(SpreadsheetVersion.EXCEL2007,name +// .getRefersToFormula()); +// if (areaRs != null) +// for (AreaReference areaR : areaRs) { +// CellReference[] cellRs = areaR.getAllReferencedCells(); +// if (cellRs != null) { +// for (CellReference cellR : cellRs) { +// String sheetName = cellR.getSheetName(); +// short colIndex = cellR.getCol(); +// int rowIndex = cellR.getRow(); +// HSSFSheet sheet = wb.getSheet(sheetName); +// HSSFRow row = sheet.getRow(rowIndex); +// HSSFCell cell = row.getCell(colIndex); +// value = getStringCellValue(evaluator, cell); +// } +// } +// } +// return value; +// } + + // 导出Excel + public void writeExcel(String xls_write_Address, InputStream stream, + Vector> ls, String[] sheetnames) { + FileOutputStream outStream; + try { + outStream = new FileOutputStream(new File(xls_write_Address)); + /* + * HSSFWorkbook workbook=new HSSFWorkbook(); HSSFSheet + * sheet=workbook.getSheetAt(0); for (int i = 0; i < + * this.resuList.size(); i++) { HSSFRow row = sheet.createRow(i); + * String[] s=this.resuList.get(i); for (int j = 0; j < s.length; + * j++) { HSSFCell cell=row.createCell(i); + * cell.setCellType(XSSFCell.CELL_TYPE_STRING); + * cell.setCellValue(s[i]); } } + */ + XSSFWorkbook workbook = new XSSFWorkbook(stream); + XSSFCellStyle style = workbook.createCellStyle(); + style.setBorderBottom(BorderStyle.THIN); + style.setBorderTop(BorderStyle.THIN); + style.setBorderRight(BorderStyle.THIN); + style.setBorderLeft(BorderStyle.THIN); + for (int sn = 0; sn < sheetnames.length; sn++) { + XSSFSheet sheet = workbook.getSheetAt(0); + for (int i = 0; i < ls.size(); i++) { + XSSFRow row = sheet.createRow(i + 1); + Vector ls2 = ls.get(i); + for (int cols = 0; cols < ls2.size(); cols++) { + XSSFCell cell = row.createCell(cols); + cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 + cell.setCellStyle(style);// 添加边框 + if (ls2.get(cols) instanceof Date) { + String date = ls2.get(cols) == null ? "" + : dateFormat.format(ls2.get(cols)); + cell.setCellValue(date);// 写入内容 + } else { + cell.setCellValue(ls2.get(cols) == null ? "" : ls2 + .get(cols).toString());// 写入内容 + } + } + } + } + workbook.write(outStream); + outStream.close(); + System.out.println("成功!"); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public void writeExcel(String xls_write_Address, InputStream stream, + ArrayList> ls, String[] sheetnames) { + FileOutputStream outStream; + try { + outStream = new FileOutputStream(new File(xls_write_Address)); + /* + * HSSFWorkbook workbook=new HSSFWorkbook(); HSSFSheet + * sheet=workbook.getSheetAt(0); for (int i = 0; i < + * this.resuList.size(); i++) { HSSFRow row = sheet.createRow(i); + * String[] s=this.resuList.get(i); for (int j = 0; j < s.length; + * j++) { HSSFCell cell=row.createCell(i); + * cell.setCellType(XSSFCell.CELL_TYPE_STRING); + * cell.setCellValue(s[i]); } } + */ + XSSFWorkbook workbook = new XSSFWorkbook(stream); + XSSFCellStyle style = workbook.createCellStyle(); + style.setBorderBottom(BorderStyle.THIN); + style.setBorderTop(BorderStyle.THIN); + style.setBorderRight(BorderStyle.THIN); + style.setBorderLeft(BorderStyle.THIN); + for (int sn = 0; sn < sheetnames.length; sn++) { + XSSFSheet sheet = workbook.getSheetAt(0); + for (int i = 0; i < ls.size(); i++) { + XSSFRow row = sheet.createRow(i + 1); + ArrayList ls2 = ls.get(i); + for (int cols = 0; cols < ls2.size(); cols++) { + XSSFCell cell = row.createCell(cols); + cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 + cell.setCellStyle(style);// 添加边框 + cell.setCellValue(ls2.get(cols));// 写入内容 + } + } + } + workbook.write(outStream); + outStream.close(); + System.out.println("成功!"); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +// /*** +// * 写入到EXCEL数据 (写入单种数据) +// * +// * @param xls_write_Address +// * @param ls +// * @param sheetnames +// * @throws IOException +// */ +// public void writeExcel5(String xls_write_Address, InputStream stream, +// ArrayList> ls, String[] sheetnames) +// throws IOException { +// FileOutputStream output = new FileOutputStream(new File( +// xls_write_Address)); // 读取的文件路径 +// HSSFWorkbook wb = new HSSFWorkbook(stream);// (new +// // BufferedInputStream(output)); +// HSSFCellStyle style = wb.createCellStyle(); +// style.setBorderBottom(BorderStyle.THIN); +// style.setBorderTop(BorderStyle.THIN); +// style.setBorderRight(BorderStyle.THIN); +// style.setBorderLeft(BorderStyle.THIN); +// for (int sn = 0; sn < sheetnames.length; sn++) { +// HSSFSheet sheet = wb.getSheetAt(0); +// for (int i = 0; i < ls.size(); i++) { +// HSSFRow row = sheet.createRow(i + 1); +// ArrayList ls2 = ls.get(i); +// for (int cols = 0; cols < ls2.size(); cols++) { +// HSSFCell cell = row.createCell(cols); +// cell.setCellType(CellType.STRING);// 文本格式 +// cell.setCellStyle(style);// 添加边框 +// cell.setCellValue(ls2.get(cols));// 写入内容 +// } +// } +// } +// wb.write(output); +// output.close(); +// System.out.println("-------WRITE EXCEL OVER-------"); +// } + + /*** + * 写入到EXCEL数据 (写入单种数据) + * + * @param xls_write_Address + * @param ls + * @param sheetnames + * @throws IOException + */ + public void writeExcel(String xls_write_Address, ArrayList ls, + String[] sheetnames) throws IOException { + FileOutputStream output = new FileOutputStream(new File( + xls_write_Address)); // 读取的文件路径 + HSSFWorkbook wb = new HSSFWorkbook();// (new + // BufferedInputStream(output)); + for (int sn = 0; sn < ls.size(); sn++) { + HSSFSheet sheet = wb.createSheet(String.valueOf(sn)); + wb.setSheetName(sn, sheetnames[sn]); + ArrayList ls2 = ls.get(sn); + for (int i = 0; i < ls2.size(); i++) { + HSSFRow row = sheet.createRow(i); + String[] s = ls2.get(i); + for (int cols = 0; cols < s.length; cols++) { + HSSFCell cell = row.createCell(cols); + cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 + cell.setCellValue(s[cols]);// 写入内容 + } + } + } + wb.write(output); + output.close(); + System.out.println("-------WRITE EXCEL OVER-------"); + } + +// /** +// * 根据单元格的名字来找到单元格的内容 +// * +// * @param inputFilePath +// * @param cellName +// * @return +// */ +// public static List getExcelNamedCellValue(String inputFilePath, +// String[] cellNames) { +// List valueList = new ArrayList(); +// try { +// FileInputStream is = new FileInputStream(new File(inputFilePath)); +// HSSFWorkbook wb = new HSSFWorkbook(is); +// for (String name : cellNames) +// valueList.add(getNamedCellValue(wb, name)); +// is.close(); +// } catch (FileNotFoundException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// return valueList; +// } + + /** + * 针对工程变更的信息写入 + * + * @param xls_write_Address + * @param ls + * @throws IOException + */ + /* + * public static void writeExcel(String outPath, InputStream input, + * List beanListAll) throws IOException { int + * rowsCount = 5; + * + * // insertRow(); + * + * FileOutputStream output = new FileOutputStream(new File(outPath)); // + * 读取的文件路径 // FileInputStream input= new FileInputStream(); HSSFWorkbook wb + * = new HSSFWorkbook(input);// (new HSSFSheet sheet = wb.getSheetAt(0); for + * (int i = 0; i < (beanListAll.size() - rowsCount); i++) insertRow(sheet, + * 4, 1); int startRow = 2; for (int i = 0; i < beanListAll.size(); i++) { + * JFomProjectChangeBean bean = beanListAll.get(i); HSSFRow row = null; + * Boolean isCreat = false; if ((i + startRow) > sheet.getLastRowNum()) { + * row = sheet.createRow(i + startRow); isCreat = true; } else { row = + * sheet.getRow(i + startRow); isCreat = false; } + * + * for (int cols = 0; cols < 12; cols++) { HSSFCell cell = null; if + * (isCreat) { cell = row.createCell(cols); } else { cell = + * row.getCell(cols); } if (cell == null) cell = row.createCell(cols); + * cell.setCellType(HSSFCell.CELL_TYPE_STRING);// 文本格式 switch (cols) { + * + * case 0: cell.setCellValue(bean.getIndexStr());// 写入内容 break; case 1: + * cell.setCellValue(bean.getECRCode());// 写入内容 break; case 2: + * cell.setCellValue(bean.getInternalCode());// 写入内容 break; case 3: + * cell.setCellValue(bean.getDrawingNo());// 写入内容 break; case 4: + * cell.setCellValue(bean.getPartStatus());// 写入内容 break; case 5: + * cell.setCellValue(bean.getInitiator());// 写入内容 break; case 6: + * cell.setCellValue(bean.getSureDate());// 写入内容 break; case 7: + * cell.setCellValue(bean.getChangeMsgBef());// 写入内容 break; case 8: + * cell.setCellValue(bean.getChangeMsg());// 写入内容 break; case 9: + * cell.setCellValue(bean.getChargePerson());// 写入内容 break; case 10: + * cell.setCellValue("");// 写入内容 break; case 11: cell.setCellValue("");// + * 写入内容 break; } } } + * + * // } wb.write(output); output.close(); input.close(); + * System.out.println("-------WRITE EXCEL OVER-------"); } + */ +// public void insertPicture(HSSFWorkbook wb, HSSFSheet sheet1, +// String picPath, short colIndex, int rowIndex) { +// +// // FileOutputStream fileOut = null; +// BufferedImage bufferImg = null; +// // 先把读进来的图片放到一个ByteArrayOutputStream中,以便产生ByteArray +// try { +// if (!new File(picPath).exists()) { +// return; +// } +// String dexStr = picPath.substring(picPath.lastIndexOf(".") + 1, +// picPath.length()); +// +// ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream(); +// System.out.println(picPath); +// bufferImg = ImageIO.read(new File(picPath)); +// ImageIO.write(bufferImg, dexStr, byteArrayOut); +// // HSSFWorkbook wb = new HSSFWorkbook(); +// // HSSFSheet sheet1 = wb.createSheet("test picture"); +// // 画图的顶级管理器,一个sheet只能获取一个(一定要注意这点) +// HSSFPatriarch patriarch = sheet1.createDrawingPatriarch(); +// // anchor主要用于设置图片的属性 +// HSSFClientAnchor anchor = new HSSFClientAnchor(13, 13, 0, 0, +// (short) colIndex, rowIndex, (short) (colIndex + 1), +// rowIndex + 1); +// anchor.setAnchorType(AnchorType.DONT_MOVE_AND_RESIZE); +// // 插入图片 +// patriarch +// .createPicture(anchor, wb.addPicture( +// byteArrayOut.toByteArray(), +// HSSFWorkbook.PICTURE_TYPE_JPEG)); +// +// } catch (Exception e) { +// e.printStackTrace(); +// } +// +// } +// + /** + * 设置单个的命名单元格的内容 + * + * @param wb + * @param cellName + * @return + * @throws IOException + */ +// public static void setNamedCellValue(HSSFWorkbook wb, String cellName, +// String cellValue) throws IOException { +// String value = null; +// HSSFName name = wb.getName(cellName); +// if (name == null) { +// return; +// } +// AreaReference[] areaRs = AreaReference.generateContiguous(SpreadsheetVersion.EXCEL2007 ,name +// .getRefersToFormula()); +// if (areaRs != null) { +// for (AreaReference areaR : areaRs) { +// CellReference[] cellRs = areaR.getAllReferencedCells(); +// if (cellRs != null) { +// for (CellReference cellR : cellRs) { +// String sheetName = cellR.getSheetName(); +// short colIndex = cellR.getCol(); +// int rowIndex = cellR.getRow(); +// HSSFSheet sheet = wb.getSheet(sheetName); +// HSSFRow row = sheet.getRow(rowIndex); +// HSSFCell cell = row.getCell(colIndex); +// cell.setCellValue(cellValue); +// } +// } +// } +// } +// } + /** + * 设置单个的命名单元格的内容 + * + * @param wb + * @param cellName + * @return + * @throws IOException + */ +// public static void setNamedCellValue_XSSF(XSSFWorkbook wb, String cellName, +// String cellValue) throws IOException { +// String value = null; +// XSSFName name = wb.getName(cellName); +// if (name == null) { +// return; +// } +// AreaReference[] areaRs = AreaReference.generateContiguous(SpreadsheetVersion.EXCEL2007 ,name +// .getRefersToFormula()); +// if (areaRs != null) { +// for (AreaReference areaR : areaRs) { +// CellReference[] cellRs = areaR.getAllReferencedCells(); +// if (cellRs != null) { +// for (CellReference cellR : cellRs) { +// String sheetName = cellR.getSheetName(); +// short colIndex = cellR.getCol(); +// int rowIndex = cellR.getRow(); +// XSSFSheet sheet = wb.getSheet(sheetName); +// XSSFRow row = sheet.getRow(rowIndex); +// XSSFCell cell = row.getCell(colIndex); +// cell.setCellValue(cellValue); +// } +// } +// } +// } +// } + + /** + * 移除合并的单元格 + * + * @param startRow + * @param endRow + * @return + */ + public static boolean removeMergen(HSSFSheet sheet, int startRow, int endRow) { + boolean isOK = false; + int count = sheet.getNumMergedRegions(); + for (int i = 0; i < count; i++) { + CellRangeAddress address = sheet.getMergedRegion(i); + System.out.println(address.getFirstRow() + "|" + + address.getLastRow()); + if (address.getFirstRow() == startRow + && address.getLastRow() == endRow) { + sheet.removeMergedRegion(i); + isOK = true; + break; + } + } + return isOK; + } + + //插入图片;isProportion:false是将图片嵌入到全部单元格。true是将原图比例放入区域内 + //sheet:操作的excel;picturePath:图片路径;Rows:插入图片区域的行(从1开始);colunms插入图片区域的列(从1开始) + //RowHeightCM是厘米制的行高;ColumnWidthCM是厘米制的列宽 +// public static void InsertTitlePicture(File file,String outFilePath,String picturePath,int[] Rows,int[] colunms,boolean isProportion, +// double RowHeightCM,double ColumnWidthCM,int ii,int jj) throws IOException { +//// //获取系统分辨率 +//// int screenWidth=((int)java.awt.Toolkit.getDefaultToolkit().getScreenSize().width); +//// int screenHeight = ((int)java.awt.Toolkit.getDefaultToolkit().getScreenSize().height); +// Workbook wb = new Workbook(); +// wb.loadFromHtml(new FileInputStream(file)); +// Worksheet sheet = wb.getWorksheets().get(0); +// +// double ColumnWidth=0.0;//列宽单元格像素 +// double RowHeight=0.0;//行高像素 +//// double ColumnWidthCM=0.0;//列宽单元格CM +//// double RowHeightCM=0.0;//行高CM +// +// for(int i=0;iRH) { +// w=W/CW; +// h=(H/CW)*w1/h1;//w1是放图片区域列宽占的厘米数除以像素(0.18);h1是行高的占的厘米数除以像素(0.23) +// }else { +// h=H/RH; +// w=(W/RH)*h1/w1; +// } +// pic1.setWidth((int) (w)); +// pic1.setHeight((int) (h)); +// }else { +// pic1.setWidth((int) ColumnWidth); +// pic1.setHeight((int) RowHeight); +// } +// +// wb.saveToFile(outFilePath); +// input.close(); +// pic1.dispose(); +// sourceImg.flush(); +// new File(picturePath).delete(); +// +//// //消除水印 +//// File file1=new File(outFilePath); +//// FileInputStream input1 = new FileInputStream(file1); +//// XSSFWorkbook wb1 = new XSSFWorkbook(input1); +//// wb1.removeSheetAt(wb1.getActiveSheetIndex()); +//// FileOutputStream output = new FileOutputStream(new File(outFilePath)); +//// wb1.write(output); +//// input.close(); +//// output.close(); +// } +// + + +// //插入图片WorkBook +// public static void InsertPicture(File file,int row,int colunm,String outFilePath,String outFilePathp) throws IOException { +// //FileInputStream file = new FileInputStream(new File(outFilePath)); +// Workbook wb = new Workbook(); +// wb.loadFromHtml(new FileInputStream(file)); +// Worksheet sheet = wb.getWorksheets().get(0); +// //获取图片 +// InputStream input = new FileInputStream(outFilePathp); +// BufferedImage sourceImg = ImageIO.read(input); +// ExcelPicture pic1 = sheet.getPictures().add(row, colunm,sourceImg); +// +// double ColumnWidth=sheet.getColumnWidthPixels(colunm)+sheet.getColumnWidthPixels(colunm+1)+sheet.getColumnWidthPixels(colunm+2) +// +sheet.getColumnWidthPixels(colunm+3)+sheet.getColumnWidthPixels(colunm+4)+sheet.getColumnWidthPixels(colunm+5) +// +sheet.getColumnWidthPixels(colunm+6)+sheet.getColumnWidthPixels(colunm+7); +// double RowHeight=sheet.getRowHeightPixels(row)+sheet.getRowHeightPixels(row+1)+sheet.getRowHeightPixels(row+2)+sheet.getRowHeightPixels(row+3) +// +sheet.getRowHeightPixels(row+4)+sheet.getRowHeightPixels(row+5)+sheet.getRowHeightPixels(row+6) +// +sheet.getRowHeightPixels(row+7)+sheet.getRowHeightPixels(row+8)+sheet.getRowHeightPixels(row+9); +// System.out.println("图片单元格宽:"+ColumnWidth); +// System.out.println("图片单元格宽:"+RowHeight); +// //宽比、高比 +// double aaa=sourceImg.getWidth(); +// double bbbb=sourceImg.getHeight(); +// double WidthProportion=ColumnWidth/aaa; +// double HeightProportion=RowHeight/bbbb; +// if(WidthProportion>HeightProportion) { +// WidthProportion=HeightProportion; +// } +// //System.out.println("图片单元格高:"+sheet.getCellRange("K6:K6").getp.getRowHeight()); +// pic1.setWidth((int) (sourceImg.getWidth()*WidthProportion)); +// pic1.setHeight((int) (sourceImg.getHeight()*WidthProportion)); +// +// wb.saveToFile(outFilePath); +// wb.dispose(); +// input.close(); +// pic1.dispose(); +// sourceImg.flush(); +// new File(outFilePathp).delete(); +// +// +//// //消除水印 +//// File file1=new File(outFilePath); +//// FileInputStream input = new FileInputStream(file1); +//// XSSFWorkbook wb1 = new XSSFWorkbook(input); +//// wb1.removeSheetAt(1); +//// FileOutputStream output = new FileOutputStream(new File(outFilePath)); +//// wb1.write(output); +//// input.close(); +//// output.close(); +// +// } +// + + /** + * 截取字符串 + * + * @param inStr + * @return + */ + public static String changeStringToInt(String inStr) { + int index = inStr.indexOf("."); + System.out.println(index); + String outStr = null; + if (index != -1) { + + outStr = inStr.substring(0, index); + } else { + outStr = inStr; + + } + // System.out.println(outStr); + return outStr; + } + + /** + * 截取一定长度的字符串 + * + * @param inStr + * @param inLen + * @return + */ + public static String changeStringToInt(String inStr, int inLen) { + int index = inStr.indexOf("."); + inLen++; + System.out.println(index); + String outStr = null; + if (index != -1 && (inStr.length() - index) >= inLen) { + + outStr = inStr.substring(0, index + inLen); + } else { + outStr = inStr; + + } + // System.out.println(outStr); + return outStr; + } + + /** + * 将float转换成保留两位的字符串 + * + * @param f + * 需要转换的float数 + * @return + */ + public static String changeFloatToStr(float f) { + DecimalFormat decimalFormat = new DecimalFormat(".0");// 构造方法的字符格式这里如果小数不足2位,会以0补足. + String str = decimalFormat.format(f);// format 返回的是字符串 + return str; + } + + /** + * 将字符串转换成int + * + * @param str + * @return + */ + public static float changeStrToFloat(String str) { + float temp_int = 0; + try { + temp_int = Float.parseFloat(str.trim()); + return temp_int; + } catch (NumberFormatException e) { + System.out.println(e.getMessage()); + return -1; + } + } + + /** + * 设置formual的时候用来替换原有的单元格号到新的单元格号 + * + * @param originStr + * @param subStr + * @param index + * @param index2 + * @return + */ + public static String replaceSubString(String originStr, String subStr, + int index, int index2) { + StringBuffer sbO = new StringBuffer(); + sbO.append(subStr); + sbO.append(index); + StringBuffer sbR = new StringBuffer(); + sbR.append(subStr); + sbR.append(index2); + String resultStr = originStr.replace(sbO.toString(), sbR.toString()); + return resultStr; + } + + /** + * 读取EXCEL信息 + * + * @param String + * excel_file + * @return List> 返回信息 + * @throws IOException + * @throws FileNotFoundException + */ +// public static List> readExcel(String excel_file) +// throws FileNotFoundException, IOException { +// if (excel_file == null) { +// return null; +// } +// File file = new File(excel_file); +// return readExcel(file); +// } + + /** + * 获取单元格数据内容为字符串类型的数据 + * + * @param cell + * Excel单元格 + * @return String 单元格数据内容 + */ +// private static String getStringCellValue(HSSFFormulaEvaluator evaluator, +// HSSFCell cell) { +// if (cell == null) { +// return ""; +// } +// String strCell = ""; +// +// switch (cell.getCellType()) { +// case STRING: +// strCell = cell.getStringCellValue(); +// break; +// case NUMERIC: +// strCell = "" + cell.getNumericCellValue(); +// if (strCell.endsWith(".0")) { +// strCell = strCell.substring(0, strCell.indexOf(".0")); +// } +// break; +// case BOOLEAN: +// strCell = String.valueOf(cell.getBooleanCellValue()); +// break; +// case BLANK: +// strCell = ""; +// break; +// case ERROR: +// strCell = String.valueOf(cell.getErrorCellValue()); +// break; +// case FORMULA: +// CellValue value = evaluator.evaluate(cell); +// try { +// strCell = value.getStringValue(); +// if (strCell == null) { +// strCell = "" + value.getNumberValue(); +// if (strCell.endsWith(".0")) { +// strCell = strCell.substring(0, strCell.indexOf(".0")); +// } +// } +// } catch (Exception e) { +// +// strCell = "" + value.getNumberValue(); +// if (strCell.endsWith(".0")) { +// strCell = strCell.substring(0, strCell.indexOf(".0")); +// } +// } +// break; +// default: +// strCell = ""; +// break; +// } +// if (strCell.equals("") || strCell == null) { +// return ""; +// } +// return strCell; +// } + + // public static void insertRow(HSSFSheet sheet, int starRow, int rows) { + // HSSFRow sourceRow = sheet.getRow(starRow); + // sheet.shiftRows(starRow + 1, sheet.getLastRowNum(), rows, true, false); + // // starRow = starRow -1; + // for (int i = 0; i < rows; i++) { + // // sheet.shiftRows(starRow + i, sheet.getLastRowNum(), 1, true, + // // false); + // HSSFRow targetRow = null; + // HSSFCell sourceCell = null; + // HSSFCell targetCell = null; + // short m; + // targetRow = sheet.createRow(starRow + 1); + // targetRow.setHeight(sourceRow.getHeight()); + // System.out.println(sourceRow.getLastCellNum()); + // for (m = sourceRow.getFirstCellNum(); m < sourceRow + // .getLastCellNum(); m++) { + // System.out.println(m); + // sourceCell = sourceRow.getCell(m); + // targetCell = targetRow.createCell(m); + // // System.out.println(" ===== " + sourceCell + " " + + // // targetCell); + // // targetCell.setEncoding(sourceCell.get); + // targetCell.setCellStyle(sourceCell.getCellStyle()); + // targetCell.setCellType(sourceCell.getCellType()); + // // targetCell.setCellValue("11111"); + // } + // } + // } + + /** + * 插入行数 + * + * @param starRow + * @param rows + */ + public static void insertRow(HSSFSheet sheet, int starRow, int rows) { + HSSFRow sourceRow = sheet.getRow(starRow); + sheet.shiftRows(starRow + 1, sheet.getLastRowNum(), rows, true, false); + for (int i = 0; i < rows; i++) { + HSSFRow targetRow = null; + HSSFCell sourceCell = null; + HSSFCell targetCell = null; + short m; + targetRow = sheet.createRow(starRow + 1); + targetRow.setHeight(sourceRow.getHeight()); + System.out.println(sourceRow.getLastCellNum()); + for (m = sourceRow.getFirstCellNum(); m < sourceRow + .getLastCellNum(); m++) { + System.out.println(m); + sourceCell = sourceRow.getCell(m); + targetCell = targetRow.createCell(m); + targetCell.setCellStyle(sourceCell.getCellStyle()); + targetCell.setCellType(sourceCell.getCellType()); + } + } + } + + /*** + * 向sheet中插入一行 + * + * @param sheet + * @param startRow + * @param rows + * @return + */ + public static HSSFSheet insertRows(HSSFSheet sheet, int startRow, int rows) { + HSSFRow sourceRow = sheet.getRow(startRow); + sheet.shiftRows(startRow + 1, sheet.getLastRowNum(), rows, true, false); + for (int i = 0; i < rows; i++) { + HSSFRow targetRow = null; + HSSFCell sourceCell = null; + HSSFCell targetCell = null; + short m; + targetRow = sheet.createRow(startRow + 1); + targetRow.setHeight(sourceRow.getHeight()); + System.out.println(sourceRow.getLastCellNum()); + for (m = sourceRow.getFirstCellNum(); m < sourceRow + .getLastCellNum(); m++) { + System.out.println(m); + sourceCell = sourceRow.getCell(m); + targetCell = targetRow.createCell(m); + targetCell.setCellStyle(sourceCell.getCellStyle()); + targetCell.setCellType(sourceCell.getCellType()); + } + } + return sheet; + } + + /** + * 检查单元格内容是否是数字 + * + * @param value + * @return + */ + public static boolean CheckCellValueIsNumber(String value) { + boolean is_ok = false; + if (value.equals("")) { + return false; + } + try { + Float.parseFloat(value); + } catch (NumberFormatException e) { + e.printStackTrace(); + System.out.println("===>" + value); + is_ok = true; + } + return is_ok; + } + +// public static void setFlowChart(Map valueMap, File file) { +// // TODO Auto-generated method stub +// file.setWritable(true); +// try { +// InputStream is = new FileInputStream(file); +// HSSFWorkbook wb = new HSSFWorkbook(is);// ( +// //HSSFSheet sheet = wb.getSheetAt(0); +// +// Iterator> it = valueMap.entrySet() +// .iterator(); +// while (it.hasNext()) { +// Map.Entry entry = it.next(); +// setNamedCellValue(wb, entry.getKey(), entry.getValue()); +// } +// FileOutputStream output = new FileOutputStream(file); +// wb.write(output); +// output.close(); +// is.close(); +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// //file.setReadOnly(); +// System.out.println("-------WRITE EXCEL OVER-------"); +// } +} diff --git a/src/com/connor/renben/process/plm/util/ExcelUtil07.java b/src/com/connor/renben/process/plm/util/ExcelUtil07.java new file mode 100644 index 0000000..bbfb6c1 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/ExcelUtil07.java @@ -0,0 +1,6559 @@ +package com.connor.renben.process.plm.util; + +import java.awt.Graphics; + +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; +import java.awt.HeadlessException; +import java.awt.Image; +import java.awt.Transparency; +import java.awt.image.BufferedImage; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import javax.imageio.ImageIO; +import javax.swing.ImageIcon; +import javax.swing.tree.DefaultMutableTreeNode; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.SpreadsheetVersion; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellValue; +import org.apache.poi.ss.usermodel.DateUtil; +import org.apache.poi.ss.usermodel.Name; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.util.AreaReference; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.ss.util.CellReference; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFClientAnchor; +import org.apache.poi.xssf.usermodel.XSSFDrawing; +import org.apache.poi.xssf.usermodel.XSSFFont; +import org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator; +import org.apache.poi.xssf.usermodel.XSSFName; +import org.apache.poi.xssf.usermodel.XSSFRichTextString; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.FileUtility; +import com.teamcenter.rac.util.MessageBox; + +/** + * Excel Toolling + * + * @author hub 2015-09-06 + */ +public class ExcelUtil07 { + // private static Registry reg = Registry.getRegistry(this); + // private static XSSFSheet sheet; + // private static final int MY_ROWS = 46; + private static Map map = new HashMap(); + private static final String EXCEL_XLS = "xls"; + private static final String EXCEL_XLSX = "xlsx"; + + + public static String getID(String ID) { + if(ID.indexOf("-")>-1) { + String[] iDs=ID.split("-"); + String id=""; + for(int i=0;i> 返回的信息 + * @throws IOException + * @throws FileNotFoundException + */ +// public static List> readExcel(File excel_file) throws FileNotFoundException, IOException { +// if (excel_file == null || !excel_file.exists()) { +// return null; +// } +// // 用来返回的所有的行的信息 +// List> lines_msg = new ArrayList>(); +// XSSFWorkbook workBook = new XSSFWorkbook(new FileInputStream(excel_file)); +// XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(workBook); +// XSSFSheet sheet = workBook.getSheetAt(0); +// XSSFRow title_row = sheet.getRow(0); +// +// // 得到列的数目 +// int col_count = title_row.getPhysicalNumberOfCells(); +// System.out.println(" SHEET COL COUNT " + col_count); +// // 得到行的数目 +// int row_count = sheet.getLastRowNum(); +// System.out.println(" SHEET ROW COUNT " + row_count); +// for (int j = 0; j < row_count + 1; j++) { +// // 用来返回单行的信息 +// XSSFRow row = sheet.getRow(j); +// List line_msg = new ArrayList(); +// for (int i = 0; i < col_count; i++) { +// String value = getStringCellValue(evaluator, row.getCell((short) i)); +// line_msg.add(value); +// } +// lines_msg.add(line_msg); +// } +// // insertRow(sheet,4,1); +// return lines_msg; +// } +// +// /** +// * 读取控制计划EXCEL表 +// * +// * @param File excel_file +// * @return List> 返回的信息 +// * @throws IOException +// * @throws FileNotFoundException +// */ +// public static List> readControlPlanExcel(File excel_file) throws FileNotFoundException, IOException { +// if (excel_file == null || !excel_file.exists()) { +// return null; +// } +// // 用来返回的所有的行的信息 +// List> lines_msg = new ArrayList>(); +// XSSFWorkbook workBook = new XSSFWorkbook(new FileInputStream(excel_file)); +// XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(workBook); +// XSSFSheet sheet = workBook.getSheetAt(0); +// XSSFRow title_row = sheet.getRow(0); +// int startRow = 9; +// // 获取合并单元格 +// Map regionCellMap = getRegionCell(sheet); +// +// // 得到列的数目 +// int col_count = title_row.getPhysicalNumberOfCells(); +// System.out.println(" SHEET COL COUNT " + col_count); +// // 得到行的数目 +// int row_count = sheet.getLastRowNum(); +// System.out.println(" SHEET ROW COUNT " + row_count); +// for (int j = startRow; j < row_count + 1; j++) { +// // 用来返回单行的信息 +// XSSFRow row = sheet.getRow(j); +// List line_msg = new ArrayList(); +// for (int i = 0; i < 15; i++) { +// if(i== 5 || i == 10) +// { +// continue; +// } +// String value = getStringCellValue(evaluator, row.getCell((short) i)); +// if (value == null || value.equals("")) { +// line_msg.add(getRegionValue(workBook, sheet, j, i)); +// } else { +// line_msg.add(value); +// } +// } +// // 行号 +// line_msg.add(((Integer) (j - startRow)).toString()); +// // 合并单元格 +// line_msg.add(toControlPlanRegionCell(regionCellMap, j)); +// if (line_msg.get(0) != null) { +// lines_msg.add(line_msg); +// } +// } +// // insertRow(sheet,4,1); +// return lines_msg; +// } +// +// /** +// * 读取委托内容EXCEL表 +// * +// * @param File excel_file +// * @return List> 返回的信息 +// * @throws IOException +// * @throws FileNotFoundException +// */ +// public static List> readEntrustingContentExcel(File excel_file) +// throws FileNotFoundException, IOException { +// if (excel_file == null || !excel_file.exists()) { +// return null; +// } +// // 用来返回的所有的行的信息 +// List> lines_msg = new ArrayList>(); +// XSSFWorkbook workBook = new XSSFWorkbook(new FileInputStream(excel_file)); +// XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(workBook); +// XSSFSheet sheet = workBook.getSheetAt(0); +// XSSFRow title_row = sheet.getRow(0); +// int startRow = 0; +// // 获取合并单元格 +// Map regionCellMap = getEntrustingContentRegionCell(sheet); +// +// // 得到列的数目 +// int col_count = title_row.getPhysicalNumberOfCells(); +// System.out.println(" SHEET COL COUNT " + col_count); +// // 得到行的数目 +// int row_count = sheet.getLastRowNum(); +// System.out.println(" SHEET ROW COUNT " + row_count); +// for (int j = startRow; j < row_count + 1; j++) { +// // 用来返回单行的信息 +// XSSFRow row = sheet.getRow(j); +// List line_msg = new ArrayList(); +// for (int i = 0; i < 3; i++) { +// String value = getStringCellValue(evaluator, row.getCell((short) i)); +// if (value == null || value.equals("")) { +// line_msg.add(getRegionValue(workBook, sheet, j, i)); +// } else { +// line_msg.add(value); +// } +// } +// // 合并单元格 +// line_msg.add(toEntrustingContentRegionCell(regionCellMap, j)); +// if (line_msg.get(0) != null) { +// lines_msg.add(line_msg); +// } +// } +// // insertRow(sheet,4,1); +// return lines_msg; +// } +// +// public static void main(String[] args) { +// try { +// List> strList = readExcel(new File("F:\\Connor(项目管理)\\东睦项目\\东睦系统\\控制计划\\生产控制计划模板3.xlsx")); +// for (List list : strList) { +// for (String str : list) { +// System.out.print(str + "|"); +// } +// System.out.println(); +// } +// +// } catch (FileNotFoundException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// +// public void writeSignName(String intExcelFilePath, String outExcelFilePath, String signName, String msgValue, +// int sheetIndex, int rowIndex, int cellIndex) throws IOException { +// // 输出文件的路径 +// FileOutputStream outPut = new FileOutputStream(new File(outExcelFilePath)); +// // 输入文件的路径 +// FileInputStream inPut = new FileInputStream(new File(intExcelFilePath)); +// XSSFWorkbook wb = new XSSFWorkbook(inPut); +// wb.getName(""); +// AreaReference[] areaR2 = AreaReference.generateContiguous(SpreadsheetVersion.EXCEL2007 ,wb.getName("").getRefersToFormula()); +// AreaReference areaR = null; +// CellReference[] cellR = areaR.getAllReferencedCells(); +// cellR[0].getSheetName();// s +// cellR[0].getCol();// +// cellR[0].getRow();// +// XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(wb); +// XSSFSheet sheet = wb.getSheetAt(sheetIndex); +// XSSFRow row = sheet.getRow(rowIndex); +// XSSFCell cell = row.getCell(cellIndex); +// String value = getStringCellValue(evaluator, cell); +// if (value.startsWith(signName)) { +// value = value.substring(0, signName.length()); +// } +// cell.setCellValue(value + msgValue); +// wb.write(outPut); +// inPut.close(); +// outPut.close(); +// } + + /*** + * 写入到EXCEL数据 (写入单种数据) + * + * @param xls_write_Address + * @param beanListAll + * @param sheetnames + * @throws IOException + */ + /* + * public void writeExcel(String xls_write_Address, String path, + * List beanListAll, int index) throws IOException { + * FileOutputStream output = new FileOutputStream(new File(path)); // 读取的文件路径 + * FileInputStream input = new FileInputStream(new File(xls_write_Address)); + * XSSFWorkbook wb = new XSSFWorkbook(input);// (new XSSFSheet sheet = + * wb.getSheetAt(0); for (int i = 0; i < beanListAll.size(); i++) { + * JFomPasteBean bean = beanListAll.get(i); XSSFRow row = null; Boolean isCreat + * = false; if ((i + 3) > sheet.getLastRowNum()) { row = sheet.createRow(i + 3); + * isCreat = true; } else { row = sheet.getRow(i + 3); isCreat = false; } + * + * for (int cols = 0; cols < 7; cols++) { XSSFCell cell = null; if (isCreat) { + * cell = row.createCell(cols); } else { cell = row.getCell(cols); } + * cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 switch (cols) { + * + * case 0: cell.setCellValue(bean.getIndexStr());// 写入内容 break; case 1: + * cell.setCellValue(bean.getProductName());// 写入内容 break; case 2: // + * cell.setCellValue(bean.getPicturePath());// 写入内容 insertPicture(wb, sheet, + * bean.getPicturePath(), (short) 2, (i + 3)); break; case 3: + * cell.setCellValue(bean.getDatasetName());// 写入内容 break; case 4: + * cell.setCellValue(bean.getItemRevisionId());// 写入内容 break; case 5: + * cell.setCellValue("");// 写入内容 + * + * break; case 6: // cell.setCellType(XSSFCell.CELL_TYPE_);// 文本格式 + * cell.setCellValue(bean.getReleaseDateStr());// 写入内容 break; + * + * } } } // } wb.write(output); output.close(); input.close(); + * System.out.println("-------WRITE EXCEL OVER-------"); } + */ + /** + * 获取单个的命名单元格的内容 + * + * @param wb + * @param cellName + * @return + * @throws IOException + */ +// public static String getNamedCellValue(XSSFWorkbook wb, String cellName) throws IOException { +// String value = null; +// XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(wb); +// XSSFName name = wb.getName(cellName); +// if (name == null) { +// return ""; +// } +// AreaReference[] areaRs = AreaReference.generateContiguous(SpreadsheetVersion.EXCEL2007 ,name.getRefersToFormula()); +// if (areaRs != null) +// for (AreaReference areaR : areaRs) { +// CellReference[] cellRs = areaR.getAllReferencedCells(); +// if (cellRs != null) { +// for (CellReference cellR : cellRs) { +// String sheetName = cellR.getSheetName(); +// short colIndex = cellR.getCol(); +// int rowIndex = cellR.getRow(); +// XSSFSheet sheet = wb.getSheet(sheetName); +// XSSFRow row = sheet.getRow(rowIndex); +// XSSFCell cell = row.getCell(colIndex); +// value = getStringCellValue(evaluator, cell); +// } +// } +// } +// return value; +// } + +// /** +// * 设置单个的命名单元格的内容 +// * +// * @param wb +// * @param cellName +// * @return +// * @throws IOException +// */ +// public static void setNamedCellValue(XSSFWorkbook wb, String cellName, String cellValue) throws IOException { +// XSSFName name = wb.getName(cellName); +// if (name == null) { +// return; +// } +// AreaReference[] areaRs = AreaReference.generateContiguous(SpreadsheetVersion.EXCEL2007 ,name.getRefersToFormula()); +// if (areaRs != null) { +// for (AreaReference areaR : areaRs) { +// CellReference[] cellRs = areaR.getAllReferencedCells(); +// if (cellRs != null) { +// for (CellReference cellR : cellRs) { +// String sheetName = cellR.getSheetName(); +// short colIndex = cellR.getCol(); +// int rowIndex = cellR.getRow(); +// XSSFSheet sheet = wb.getSheet(sheetName); +// XSSFRow row = sheet.getRow(rowIndex); +// XSSFCell cell = row.getCell(colIndex); +// cell.setCellValue(cellValue); +// } +// } +// } +// } +// } + + /** + * 插入图片到指定的单元格中 + * + * @param wb + * @param sheet1 + * @param picPath + * @param colIndex + * @param rowIndex + */ +// public static void insertPicture(XSSFWorkbook wb, XSSFSheet sheet1, ImageIcon imageIcon, String cellName, +// double columns, int rows) { +// +// // 先把读进来的图片放到一个ByteArrayOutputStream中,以便产生ByteArray +// try { +// if (imageIcon == null) { +// return; +// } +// ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream(); +// ImageIO.write(toBufferedImage(imageIcon.getImage()), "jpg", byteArrayOut); +// // 画图的顶级管理器,一个sheet只能获取一个(一定要注意这点) +// XSSFDrawing patriarch = sheet1.createDrawingPatriarch(); +// // anchor主要用于设置图片的属性 +// XSSFName name = wb.getName(cellName); +// if (name == null) { +// return; +// } +// AreaReference[] areaRs = AreaReference.generateContiguous(SpreadsheetVersion.EXCEL2007 ,name.getRefersToFormula()); +// if (areaRs != null) { +// for (AreaReference areaR : areaRs) { +// CellReference[] cellRs = areaR.getAllReferencedCells(); +// if (cellRs != null) { +// for (CellReference cellR : cellRs) { +// String sheetName = cellR.getSheetName(); +// short colIndex = cellR.getCol(); +// int rowIndex = cellR.getRow(); +// XSSFSheet sheet = wb.getSheet(sheetName); +// XSSFRow row = sheet.getRow(rowIndex); +// XSSFClientAnchor anchor = new XSSFClientAnchor(13, 13, 0, 0, (short) colIndex, rowIndex, +// (short) (colIndex + columns), rowIndex + rows); +// anchor.setAnchorType(3); +// // 插入图片 +// patriarch.createPicture(anchor, +// wb.addPicture(byteArrayOut.toByteArray(), XSSFWorkbook.PICTURE_TYPE_JPEG)); +// } +// } +// } +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } +// +// /** +// * 将Image转BufferedImage +// * +// * @param image +// * @return +// */ +// public static BufferedImage toBufferedImage(Image image) { +// if (image instanceof BufferedImage) { +// return (BufferedImage) image; +// } +// +// // This code ensures that all the pixels in the image are loaded +// image = new ImageIcon(image).getImage(); +// +// // Determine if the image has transparent pixels; for this method's +// // implementation, see e661 Determining If an Image Has Transparent Pixels +// // boolean hasAlpha = hasAlpha(image); +// +// // Create a buffered image with a format that's compatible with the screen +// BufferedImage bimage = null; +// GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); +// try { +// // Determine the type of transparency of the new buffered image +// int transparency = Transparency.OPAQUE; +// /* +// * if (hasAlpha) { transparency = Transparency.BITMASK; } +// */ +// +// // Create the buffered image +// GraphicsDevice gs = ge.getDefaultScreenDevice(); +// GraphicsConfiguration gc = gs.getDefaultConfiguration(); +// bimage = gc.createCompatibleImage(image.getWidth(null), image.getHeight(null), transparency); +// } catch (HeadlessException e) { +// // The system does not have a screen +// } +// +// if (bimage == null) { +// // Create a buffered image using the default color model +// int type = BufferedImage.TYPE_INT_RGB; +// // int type = BufferedImage.TYPE_3BYTE_BGR;//by wang +// /* +// * if (hasAlpha) { type = BufferedImage.TYPE_INT_ARGB; } +// */ +// bimage = new BufferedImage(image.getWidth(null), image.getHeight(null), type); +// } +// +// // Copy image to buffered image +// Graphics g = bimage.createGraphics(); +// +// // Paint the image onto the buffered image +// g.drawImage(image, 0, 0, null); +// g.dispose(); +// +// return bimage; +// } +// +// /*** +// * 写入到EXCEL数据 (写入单种数据) +// * +// * @param xls_write_Address +// * @param ls +// * @param sheetnames +// * @throws IOException +// */ +// public void writeExcel(String xls_write_Address, ArrayList ls, String[] sheetnames) throws IOException { +// FileOutputStream output = new FileOutputStream(new File(xls_write_Address)); // 读取的文件路径 +// XSSFWorkbook wb = new XSSFWorkbook();// (new +// // BufferedInputStream(output)); +// for (int sn = 0; sn < ls.size(); sn++) { +// XSSFSheet sheet = wb.createSheet(String.valueOf(sn)); +// wb.setSheetName(sn, sheetnames[sn]); +// ArrayList ls2 = ls.get(sn); +// for (int i = 0; i < ls2.size(); i++) { +// XSSFRow row = sheet.createRow(i); +// String[] s = ls2.get(i); +// for (int cols = 0; cols < s.length; cols++) { +// XSSFCell cell = row.createCell(cols); +// cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 +// cell.setCellValue(s[cols]);// 写入内容 +// } +// } +// } +// wb.write(output); +// output.close(); +// System.out.println("-------WRITE EXCEL OVER-------"); +// } +// +// /** +// * 根据单元格的名字来找到单元格的内容 +// * +// * @param inputFilePath +// * @param cellName +// * @return +// */ +// public static List getExcelNamedCellValue(String inputFilePath, String[] cellNames) { +// List valueList = new ArrayList(); +// if (!new File(inputFilePath).exists()) { +// for (int i = 0; i < cellNames.length; i++) +// valueList.add(""); +// return valueList; +// } +// try { +// FileInputStream is = new FileInputStream(new File(inputFilePath)); +// XSSFWorkbook wb = new XSSFWorkbook(is); +// for (String name : cellNames) +// valueList.add(getNamedCellValue(wb, name)); +// is.close(); +// } catch (FileNotFoundException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// return valueList; +// } +// +// /** +// * 针对工程变更的信息写入 +// * +// * @param xls_write_Address +// * @param ls +// * @throws IOException +// */ +// /* +// * public static void writeExcel(String outPath, InputStream input, +// * List beanListAll) throws IOException { +// * +// * FileOutputStream output = new FileOutputStream(new File(outPath)); // 读取的文件路径 +// * // FileInputStream input= new FileInputStream(); XSSFWorkbook wb = new +// * XSSFWorkbook(input);// (new XSSFSheet sheet = wb.getSheetAt(0); int startRow +// * = 2; for (int i = 0; i < beanListAll.size(); i++) { JFomProjectChangeBean +// * bean = beanListAll.get(i); XSSFRow row = null; Boolean isCreat = false; if +// * ((i + startRow) > sheet.getLastRowNum()) { row = sheet.createRow(i + +// * startRow); isCreat = true; } else { row = sheet.getRow(i + startRow); isCreat +// * = false; } +// * +// * for (int cols = 0; cols < 12; cols++) { XSSFCell cell = null; if (isCreat) { +// * cell = row.createCell(cols); } else { cell = row.getCell(cols); } +// * cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 switch (cols) { +// * +// * case 0: cell.setCellValue(bean.getIndexStr());// 写入内容 break; case 1: +// * cell.setCellValue(bean.getECRCode());// 写入内容 break; case 2: +// * cell.setCellValue(bean.getInternalCode());// 写入内容 break; case 3: +// * cell.setCellValue(bean.getDrawingNo());// 写入内容 break; case 4: +// * cell.setCellValue(bean.getPartStatus());// 写入内容 break; case 5: +// * cell.setCellValue(bean.getInitiator());// 写入内容 break; case 6: +// * cell.setCellValue(bean.getSureDate());// 写入内容 break; case 7: +// * cell.setCellValue(bean.getChangeMsgBef());// 写入内容 break; case 8: +// * cell.setCellValue(bean.getChangeMsg());// 写入内容 break; case 9: +// * cell.setCellValue(bean.getChargePerson());// 写入内容 break; case 10: +// * cell.setCellValue("");// 写入内容 break; case 11: cell.setCellValue("");// 写入内容 +// * break; } } } // } wb.write(output); output.close(); input.close(); +// * System.out.println("-------WRITE EXCEL OVER-------"); } +// */ +// /** +// * 设置单元格 +// * +// * @param row1 +// * @param index +// * @param str +// */ +// public static void setCellValue(XSSFRow row1, int index, String str) { +// XSSFCell cell = row1.getCell(index); +// cell.setCellType(XSSFCell.CELL_TYPE_STRING); +// cell.setCellValue(str); +// } +// +// /** +// * 设置单元格 +// * +// * @param row1 +// * @param index +// * @param str +// */ +// public static void setCellValue(Row row1, int index, String str) { +// Cell cell = row1.getCell(index); +// cell.setCellType(XSSFCell.CELL_TYPE_STRING); +// cell.setCellValue(str); +// } +// +// /** +// * 针对工程变更的信息写入 +// * +// * @param xls_write_Address +// * @param ls +// * @throws IOException +// */ +// /* +// * public static void writeExcelBomExport(String outPath, InputStream input, +// * List beanListAll, JFomBomExportProjBean projBean) throws +// * IOException { +// * +// * FileOutputStream output = new FileOutputStream(new File(outPath)); // 读取的文件路径 +// * // FileInputStream input= new FileInputStream(); XSSFWorkbook wb = new +// * XSSFWorkbook(input);// (new XSSFSheet sheet = wb.getSheetAt(0); int startRow +// * = 4; if (projBean != null) { XSSFRow row1 = sheet.getRow(0); +// * setCellValue(row1, 11, projBean.getPROJ_NAME()); setCellValue(row1, 14, +// * projBean.getPROJ_MODE()); setCellValue(row1, 16, projBean.getPRODUCT_LIFE()); +// * row1 = sheet.getRow(1); setCellValue(row1, 11, projBean.getPROJ_CUSTOMER()); +// * setCellValue(row1, 14, projBean.getPROJ_MEMBER()); } for (int i = 0; i < +// * beanListAll.size(); i++) { JFomBomExportBean bean = beanListAll.get(i); +// * XSSFRow row = null; Boolean isCreat = false; if ((i + startRow) > +// * sheet.getLastRowNum()) { row = sheet.createRow(i + startRow); isCreat = true; +// * } else { row = sheet.getRow(i + startRow); isCreat = false; } +// * +// * for (int cols = 0; cols < 22; cols++) { XSSFCell cell = null; if (isCreat) { +// * cell = row.createCell(cols); } else { cell = row.getCell(cols); } +// * cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 int indexStr = +// * bean.getIndexStr(); if (cols == (indexStr + 1)) { +// * cell.setCellValue(JFomUtil.JF3_INDEX_STR);// 写入内容 } +// * +// * switch (cols) { +// * +// * case 0: cell.setCellValue(bean.getIndexExt());// 写入内容 break; case 7: +// * cell.setCellValue(bean.getWlNumber());// 写入内容 break; case 8: +// * cell.setCellValue(bean.getMPS()); break; case 9: +// * cell.setCellValue(bean.getCustomerNo()); break; case 10: +// * cell.setCellValue(bean.getWlName()); break; case 11: +// * cell.setCellValue(bean.getK3code()); break; case 12: insertPicture(wb, sheet, +// * bean.getPicturePath(), (short) 14, i + startRow); break; case 13: +// * cell.setCellValue(bean.getMaterialName()); break; case 14: +// * cell.setCellValue(bean.getMaterialSize()); break; case 15: +// * cell.setCellValue(bean.getMaterialStander()); break; case 16: +// * cell.setCellValue(bean.getMaterialPark()); break; case 17: +// * cell.setCellValue(bean.getJingzhong()); break; case 18: +// * cell.setCellValue(bean.getMaozhong()); break; case 19: +// * cell.setCellValue(bean.getGongyi()); break; case 20: +// * cell.setCellValue(bean.getGongyingshang()); break; default: break; } } } // } +// * wb.write(output); output.close(); input.close(); +// * System.out.println("-------WRITE EXCEL OVER-------"); } +// */ +// public static void insertPicture(XSSFWorkbook wb, XSSFSheet sheet1, String picPath, short colIndex, int rowIndex) { +// +// // FileOutputStream fileOut = null; +// BufferedImage bufferImg = null; +// // 先把读进来的图片放到一个ByteArrayOutputStream中,以便产生ByteArray +// try { +// if (!new File(picPath).exists()) { +// return; +// } +// String dexStr = picPath.substring(picPath.lastIndexOf(".") + 1, picPath.length()); +// ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream(); +// System.out.println(picPath); +// bufferImg = ImageIO.read(new File(picPath)); +// ImageIO.write(bufferImg, dexStr, byteArrayOut); +// // XSSFWorkbook wb = new XSSFWorkbook(); +// // XSSFSheet sheet1 = wb.createSheet("test picture"); +// // 画图的顶级管理器,一个sheet只能获取一个(一定要注意这点) +// XSSFDrawing patriarch = sheet1.createDrawingPatriarch(); +// // anchor主要用于设置图片的属性 +// XSSFClientAnchor anchor = new XSSFClientAnchor(13, 13, 0, 0, (short) colIndex, rowIndex, +// (short) (colIndex + 1), rowIndex + 1); +// anchor.setAnchorType(3); +// // 插入图片 +// patriarch.createPicture(anchor, wb.addPicture(byteArrayOut.toByteArray(), XSSFWorkbook.PICTURE_TYPE_JPEG)); +// +// } catch (Exception e) { +// e.printStackTrace(); +// } +// +// } +// //复制图片 +// public static void CopyPic(File path1,String path2) { +// // 创建文件字节输入流对象 +// FileInputStream fis = null; +// // 创建文件字节输出流对象 +// FileOutputStream fos = null; +// +// try { +// // 连接文件字节输入流 +// fis = new FileInputStream(path1); +// // 连接文件字节输出流 +// fos = new FileOutputStream(path2); +// +// //准备一个byte[]数组,存储字节码,大小为1024字节,即1KB +// byte[] bytes = new byte[1024]; +// +// int readCount = 0; +// // 开始读和写 +// while ((readCount = fis.read(bytes)) != -1) { +// // 将数组中读到的字节码写入 +// fos.write(bytes, 0, readCount); +// } +// +// // 最后刷新管道,强制输出完数据 +// fos.flush(); +// +// } catch (FileNotFoundException e) { +// e.printStackTrace(); +// } catch (IOException e) { +// e.printStackTrace(); +// } finally { +// if (fis != null) { +// try { +// fis.close(); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// } +// if (fos != null) { +// try { +// fos.close(); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// } +// } +// } +// +// // +// +// +// +// /** +// * 移除合并的单元格 合并单元格sheet.addMergedRegion(new CellRangeAddress(check_index-1, +// * check_index+12+check_rows, 0, 0)); +// * +// * @param startRow +// * @param endRow +// * @return +// */ +// public static boolean removeMergen(XSSFSheet sheet, int startRow, int endRow) { +// boolean isOK = false; +// int count = sheet.getNumMergedRegions(); +// for (int i = 0; i < count; i++) { +// CellRangeAddress address = sheet.getMergedRegion(i); +// System.out.println(address.getFirstRow() + "|" + address.getLastRow()); +// if (address.getFirstRow() == startRow && address.getLastRow() == endRow) { +// sheet.removeMergedRegion(i); +// isOK = true; +// break; +// } +// } +// return isOK; +// } +// +// /** +// * 合并单元格sheet.addMergedRegion(new CellRangeAddress(check_index-1, +// * check_index+12+check_rows, 0, 0)); +// * +// * @param startRow +// * @param endRow +// * @return +// */ +// public static boolean combine(XSSFSheet sheet, int[] rows, int[] columns) { +// boolean isOK = false; +// if (rows.length > 0 && columns.length > 0) { +// sheet.addMergedRegion( +// new CellRangeAddress(rows[0], rows[rows.length - 1], columns[0], columns[columns.length - 1])); +// isOK = true; +// } +// return isOK; +// } +// +// /** +// * 截取字符串 +// * +// * @param inStr +// * @return +// */ +// public static String changeStringToInt(String inStr) { +// int index = inStr.indexOf("."); +// System.out.println(index); +// String outStr = null; +// if (index != -1) { +// +// outStr = inStr.substring(0, index); +// } else { +// outStr = inStr; +// +// } +// // System.out.println(outStr); +// return outStr; +// } +// +// /** +// * 截取一定长度的字符串 +// * +// * @param inStr +// * @param inLen +// * @return +// */ +// public static String changeStringToInt(String inStr, int inLen) { +// int index = inStr.indexOf("."); +// inLen++; +// System.out.println(index); +// String outStr = null; +// if (index != -1 && (inStr.length() - index) >= inLen) { +// +// outStr = inStr.substring(0, index + inLen); +// } else { +// outStr = inStr; +// +// } +// // System.out.println(outStr); +// return outStr; +// } +// +// /** +// * 将float转换成保留两位的字符串 +// * +// * @param f 需要转换的float数 +// * @return +// */ +// public static String changeFloatToStr(float f) { +// DecimalFormat decimalFormat = new DecimalFormat(".0");// 构造方法的字符格式这里如果小数不足2位,会以0补足. +// String str = decimalFormat.format(f);// format 返回的是字符串 +// return str; +// } +// +// /** +// * 将字符串转换成int +// * +// * @param str +// * @return +// */ +// public static float changeStrToFloat(String str) { +// float temp_int = 0; +// try { +// temp_int = Float.parseFloat(str.trim()); +// return temp_int; +// } catch (NumberFormatException e) { +// System.out.println(e.getMessage()); +// return -1; +// } +// } +// +// /** +// * 设置formual的时候用来替换原有的单元格号到新的单元格号 +// * +// * @param originStr +// * @param subStr +// * @param index +// * @param index2 +// * @return +// */ +// public static String replaceSubString(String originStr, String subStr, int index, int index2) { +// StringBuffer sbO = new StringBuffer(); +// sbO.append(subStr); +// sbO.append(index); +// StringBuffer sbR = new StringBuffer(); +// sbR.append(subStr); +// sbR.append(index2); +// String resultStr = originStr.replace(sbO.toString(), sbR.toString()); +// return resultStr; +// } +// +// /** +// * 读取EXCEL信息 +// * +// * @param String excel_file +// * @return List> 返回信息 +// * @throws IOException +// * @throws FileNotFoundException +// */ +// public static List> readExcel(String excel_file) throws FileNotFoundException, IOException { +// if (excel_file == null) { +// return null; +// } +// File file = new File(excel_file); +// // 获取EXCEL数据的具体逻辑的函数 +// return readExcel(file); +// } +// +// /** +// * 获取作业指导书Bean +// * +// * @param result +// * @return +// */ +// public static List getCXBean(Map> result) { +// List cxBeans = new ArrayList(); +// for (Integer key : result.keySet()) { +// CXBean cxBean = new CXBean(); +// cxBean.setNo((int) Float.parseFloat(result.get(key).get(3))); +// cxBean.setJcxm((result.get(key).get(6))); +// cxBean.setJsyq(result.get(key).get(9)); +// cxBean.setClqj((result.get(key).get(10))); +// cxBean.setZjpc(result.get(key).get(11) + "&" + result.get(key).get(12)); +// if (result.get(key).contains("xj")) { +// cxBean.setZjpc(""); +// cxBean.setXjpc(result.get(key).get(11) + "&" + result.get(key).get(12)); +// } else { +// cxBean.setXjpc(result.get(key).get(result.get(key).size() - 2) + "&" +// + result.get(key).get(result.get(key).size() - 1)); +// } +// cxBean.setTstx(result.get(key).get(8)); +// cxBean.setSj(true); +// if (result.get(key).get(12).indexOf("末件") > -1) { +// cxBean.setMj(true); +// } +// cxBeans.add(cxBean); +// } +// return cxBeans; +// } +// +// public static String combinationString(String s) { +// String result = ""; +// List sList = new ArrayList(); +// List sList2 = new ArrayList(); +// if (s.indexOf("&") > -1) { +// String[] ss = s.split("&"); +// if (ss[0].indexOf("/") > -1) { +// String[] sss = ss[0].split("/"); +// for (int i = 0; i < sss.length; i++) { +// sList.add(sss[i]); +// } +// } else { +// sList.add(ss[0]); +// } +// if (ss[1].indexOf("/") > -1) { +// String[] sss = ss[1].split("/"); +// for (int i = 0; i < sss.length; i++) { +// sList2.add(sss[i]); +// } +// } else { +// sList2.add(ss[1]); +// } +// +// if (sList.size() == sList2.size()) { +// StringBuffer sb = new StringBuffer(); +// for (int i = 0; i < sList.size(); i++) { +// sb.append(sList.get(i) + "/" + sList2.get(i) + "&"); +// } +// if (sb != null && sb.length() != 0) { +// result = sb.substring(0, sb.length() - 1); +// } +// } +// } +// return result; +// +// } +// +// /** +// * 读取控制计划信息 +// * +// * @param String excel_file +// * @return List> 返回信息 +// * @throws IOException +// * @throws FileNotFoundException +// */ +// public static Map> readExcel(String excel_file, String cellName) +// throws FileNotFoundException, IOException { +// if (excel_file == null) { +// return null; +// } +// File file = new File(excel_file); +// XSSFWorkbook xwb = new XSSFWorkbook(new FileInputStream(file)); +// Map> result = new LinkedHashMap>(); +// XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(xwb); +// XSSFSheet sheet = xwb.getSheetAt(0); +// XSSFRow row; +// String cell; +// for (int i = sheet.getFirstRowNum(); i < sheet.getPhysicalNumberOfRows(); i = i + 2) { +// +// row = sheet.getRow(i); +// if (getRegionValue(xwb, sheet, i, 1).toString().equals(cellName)) { +// List rowValue = new ArrayList(); +// int lastRow = getRegionIndex(sheet, i, 1, cellName); +// for (int j = row.getFirstCellNum(); j < row.getLastCellNum(); j++) { +// if (j == 10) { +// continue; +// } +// if ((row.getCell(j) == null || row.getCell(j).toString().equals("")) && i <= lastRow) { +// String s = getRegionValue(xwb, sheet, i, j); +// if (s == null) { +// cell = ""; +// } else { +// if (j == 9) { +// if (row.getCell(10) != null && !row.getCell(10).toString().equals("")) { +// s = s + "/" + sheet.getRow(i - 1).getCell(10).toString() + "/" +// + row.getCell(10).toString(); +// } +// } +// cell = s; +// } +// } else { +// cell = getStringCellValue(evaluator, row.getCell(j)); +// } +// System.out.print(cell + ","); +// rowValue.add(cell); +// } +// result.put((int) Float.parseFloat(rowValue.get(3)), rowValue); +// } +// System.out.println("**********************"); +// } +// return result; +// } +// +// /** +// * 获取单个的命名单元格的位置 +// * +// * @param wb +// * @param cellName +// * @return +// * @throws IOException +// */ +// public static int[] getNamedCellIndex(XSSFWorkbook wb, String cellName) throws IOException { +// int[] index = new int[2]; +// XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(wb); +// XSSFName name = wb.getName(cellName); +// if (name == null) { +// return null; +// } +// AreaReference[] areaRs = AreaReference.generateContiguous(name.getRefersToFormula()); +// if (areaRs != null) { +// for (AreaReference areaR : areaRs) { +// CellReference[] cellRs = areaR.getAllReferencedCells(); +// if (cellRs != null) { +// for (CellReference cellR : cellRs) { +// String sheetName = cellR.getSheetName(); +// index[0] = cellR.getCol(); +// index[1] = cellR.getRow(); +// // colIndex = cellR.getCol(); +// // rowIndex = cellR.getRow(); +// } +// } +// } +// } +// return index; +// } +// +// /** +// * 获取单个的命名单元格的列 +// * +// * @param wb +// * @param cellName +// * @return +// * @throws IOException +// */ +// public static int getNamedColumnIndex(XSSFWorkbook wb, String cellName) throws IOException { +// int index = -1; +// XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(wb); +// XSSFName name = wb.getName(cellName); +// if (name == null) { +// return -1; +// } +// AreaReference[] areaRs = AreaReference.generateContiguous(name.getRefersToFormula()); +// if (areaRs != null) +// for (AreaReference areaR : areaRs) { +// CellReference[] cellRs = areaR.getAllReferencedCells(); +// if (cellRs != null) { +// for (CellReference cellR : cellRs) { +// String sheetName = cellR.getSheetName(); +// short colIndex = cellR.getCol(); +// int rowIndex = cellR.getRow(); +// XSSFSheet sheet = wb.getSheet(sheetName); +// XSSFRow row = sheet.getRow(rowIndex); +// return colIndex; +// } +// } +// } +// return index; +// } +// +// /** +// * 获取合并单元格内容 +// * +// * @param sheet +// * @param rowIndex +// * @param cellIndex +// * @return +// */ +// public static String getRegionValue(XSSFWorkbook workbook, XSSFSheet sheet, int rowIndex, int cellIndex) { +// XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(workbook); +// for (int i = 0; i < sheet.getNumMergedRegions(); i++) { +// CellRangeAddress region = sheet.getMergedRegion(i); +// int colIndex = region.getFirstColumn(); +// int lastColIndex = region.getLastColumn(); +// int rowNum = region.getFirstRow(); +// int lastRowNum = region.getLastRow(); +// // System.out.println(rowNum+"+++++++"+colIndex+"++++++++++"+lastRowNum+"++++++++++++"+lastColIndex); +// if (rowIndex <= lastRowNum && rowIndex >= rowNum && cellIndex <= lastColIndex && cellIndex >= colIndex) { +// return getStringCellValue(evaluator, sheet.getRow(rowNum).getCell((short) colIndex)); +// } +// } +// return null; +// } +// +// /** +// * 获取EXCEL合并单元格 +// * +// * @param sheet +// * @param rowIndex +// * @param cellIndex +// * @return +// */ +// public static Map getRegionCell(XSSFSheet sheet) { +// Map regionCellMap = new HashMap(); +// for (int i = 0; i < sheet.getNumMergedRegions(); i++) { +// CellRangeAddress region = sheet.getMergedRegion(i); +// int colIndex = region.getFirstColumn(); +// int lastColIndex = region.getLastColumn(); +// int rowNum = region.getFirstRow(); +// int lastRowNum = region.getLastRow(); +// if (rowNum >= 13) { +// // System.out.println(rowNum+"+++++++"+colIndex+"++++++++++"+lastRowNum+"++++++++++++"+lastColIndex); +// // 行集合 +// int[] rows = new int[lastRowNum - (rowNum - 1)]; +// // 列集合 +// for (int j = 0; j < rows.length; j++) { +// rows[j] = rowNum + j; +// } +// int[] columns = new int[lastColIndex - (colIndex - 1)]; +// for (int j = 0; j < columns.length; j++) { +// columns[j] = colIndex + j + 1; +// } +// regionCellMap.put(rows, columns); +// } +// } +// return regionCellMap; +// } +// +// /** +// * 获取EXCEL合并单元格 +// * +// * @param sheet +// * @param rowIndex +// * @param cellIndex +// * @return +// */ +// public static Map getEntrustingContentRegionCell(XSSFSheet sheet) { +// Map regionCellMap = new HashMap(); +// for (int i = 0; i < sheet.getNumMergedRegions(); i++) { +// CellRangeAddress region = sheet.getMergedRegion(i); +// int colIndex = region.getFirstColumn(); +// int lastColIndex = region.getLastColumn(); +// int rowNum = region.getFirstRow(); +// int lastRowNum = region.getLastRow(); +// if (rowNum >= 0) { +// // System.out.println(rowNum+"+++++++"+colIndex+"++++++++++"+lastRowNum+"++++++++++++"+lastColIndex); +// // 行集合 +// int[] rows = new int[lastRowNum - (rowNum - 1)]; +// // 列集合 +// for (int j = 0; j < rows.length; j++) { +// rows[j] = rowNum + j; +// } +// int[] columns = new int[lastColIndex - (colIndex - 1)]; +// for (int j = 0; j < columns.length; j++) { +// columns[j] = colIndex + j + 1; +// } +// regionCellMap.put(rows, columns); +// } +// } +// return regionCellMap; +// } +// +// /** +// * 转换为控制计划合并单元格 +// * +// * @param sheet +// * @param rowIndex +// * @param cellIndex +// * @return +// */ +// public static String toControlPlanRegionCell(Map regionCell, int row) { +// Iterator> it = regionCell.entrySet().iterator(); +// StringBuffer sb = new StringBuffer(); +// while (it.hasNext()) { +// Map.Entry entry = it.next(); +// StringBuffer rowSb = new StringBuffer(); +// StringBuffer columnSb = new StringBuffer(); +// for (int k = 0; k < entry.getKey().length; k++) { +// rowSb.append(entry.getKey()[k] - 13); +// rowSb.append(","); +// } +// for (int k = 0; k < entry.getValue().length; k++) { +// columnSb.append(entry.getValue()[k]); +// columnSb.append(","); +// } +// if (entry.getKey()[0] == row) { +// sb.append(rowSb.substring(0, rowSb.length() - 1) + "/" + columnSb.substring(0, columnSb.length() - 1) +// + "-"); +// } +// } +// if (sb.length() > 0) { +// return sb.toString().substring(0, sb.length() - 1); +// } else { +// return ""; +// } +// } +// +// /** +// * 转换为委托内容合并单元格 +// * +// * @param sheet +// * @param rowIndex +// * @param cellIndex +// * @return +// */ +// public static String toEntrustingContentRegionCell(Map regionCell, int row) { +// Iterator> it = regionCell.entrySet().iterator(); +// StringBuffer sb = new StringBuffer(); +// while (it.hasNext()) { +// Map.Entry entry = it.next(); +// StringBuffer rowSb = new StringBuffer(); +// StringBuffer columnSb = new StringBuffer(); +// for (int k = 0; k < entry.getKey().length; k++) { +// rowSb.append(entry.getKey()[k]); +// rowSb.append(","); +// } +// for (int k = 0; k < entry.getValue().length; k++) { +// columnSb.append(entry.getValue()[k] - 1); +// columnSb.append(","); +// } +// if (entry.getKey()[0] == row) { +// sb.append(rowSb.substring(0, rowSb.length() - 1) + "/" + columnSb.substring(0, columnSb.length() - 1) +// + "-"); +// } +// } +// if (sb.length() > 0) { +// return sb.toString().substring(0, sb.length() - 1); +// } else { +// return ""; +// } +// } +// +// /** +// * 设置单元格中指定字体的样式 +// * +// * @param wb +// * @param s 内容 +// * @param firstIndex 起始位置 +// * @param lastIndex 结束位置 +// * @param fontSize 字体大小 +// * @param FontName 字体样式 +// * @return +// */ +// public static XSSFRichTextString setCellFont(XSSFWorkbook wb, String s, int firstIndex, int lastIndex, int fontSize, +// String FontName) { +// XSSFRichTextString ts = new XSSFRichTextString(s); +// XSSFFont font1 = (XSSFFont) wb.createFont(); +// font1.setFontHeightInPoints((short) 8); // 字体高度 +// font1.setFontName("宋体"); // 字体 +// // font1.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); // 宽度 +// XSSFFont font = (XSSFFont) wb.createFont(); +// font.setFontHeightInPoints((short) fontSize); // 字体高度 +// font.setFontName(FontName); // 字体 +// // font.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); // 宽度 +// ts.applyFont(firstIndex, lastIndex, font); +// ts.applyFont(lastIndex, ts.length(), font1); +// return ts; +// } +// +// /** +// * 获取单元格大小 +// * +// * @param sheet +// * @param rowIndex +// * @param cellIndex +// * @param cellValue +// */ +// public static int getRegionIndex(XSSFSheet sheet, int rowIndex, int cellIndex, String cellValue) { +// int lastRow = 0; +// for (int i = 0; i < sheet.getNumMergedRegions(); i++) { +// CellRangeAddress region = sheet.getMergedRegion(i); +// int colIndex = region.getFirstColumn(); +// int lastColIndex = region.getLastColumn(); +// int rowNum = region.getFirstRow(); +// int lastRowNum = region.getLastRow(); +// if (sheet.getRow(rowNum).getCell(colIndex).toString().equals(cellValue)) { +// lastRow = lastRowNum; +// } +// } +// return lastRow; +// } +// +// /** +// * 获取单元格数据内容为字符串类型的数据 +// * +// * @param cell Excel单元格 +// * @return String 单元格数据内容 +// */ +// private static String getStringCellValue(XSSFFormulaEvaluator evaluator, XSSFCell cell) { +// if (cell == null) { +// return ""; +// } +// String strCell = ""; +// switch (cell.getCellType()) { +// case XSSFCell.CELL_TYPE_STRING: +// strCell = cell.getStringCellValue(); +// break; +// case XSSFCell.CELL_TYPE_NUMERIC: +// // strCell = cell.getStringCellValue(); +// if (DateUtil.isCellDateFormatted(cell)) { +// SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd"); +// Date date = cell.getDateCellValue(); +// if (date != null) +// strCell = sdf.format(date); +// } else { +// +// strCell = "" + cell.getNumericCellValue(); +// if (strCell.endsWith(".0")) { +// strCell = strCell.substring(0, strCell.indexOf(".0")); +// } +// } +// break; +// case XSSFCell.CELL_TYPE_BOOLEAN: +// strCell = String.valueOf(cell.getBooleanCellValue()); +// break; +// case XSSFCell.CELL_TYPE_BLANK: +// strCell = ""; +// break; +// case XSSFCell.CELL_TYPE_ERROR: +// strCell = String.valueOf(cell.getErrorCellValue()); +// break; +// case XSSFCell.CELL_TYPE_FORMULA: +// CellValue value = evaluator.evaluate(cell); +// try { +// strCell = value.getStringValue(); +// if (strCell == null) { +// strCell = "" + value.getNumberValue(); +// if (strCell.endsWith(".0")) { +// strCell = strCell.substring(0, strCell.indexOf(".0")); +// } +// } +// } catch (Exception e) { +// +// strCell = "" + value.getNumberValue(); +// if (strCell.endsWith(".0")) { +// strCell = strCell.substring(0, strCell.indexOf(".0")); +// } +// } +// break; +// +// default: +// strCell = ""; +// break; +// } +// if (strCell.equals("") || strCell == null) { +// return ""; +// } +// // System.out.println(" === Type =" + cell.getCellType() + " Value =" + +// // strCell); +// return strCell; +// } +// +// /** +// * 插入行数 +// * +// * @param starRow +// * @param rows +// */ +// public static void insertRow(XSSFSheet sheet, int starRow, int rows) { +// XSSFRow sourceRow = sheet.getRow(starRow); +// sheet.shiftRows(starRow + 1, sheet.getLastRowNum(), rows, true, false); +// for (int i = 0; i < rows; i++) { +// XSSFRow targetRow = null; +// XSSFCell sourceCell = null; +// XSSFCell targetCell = null; +// short m; +// targetRow = sheet.createRow(starRow + 1); +// targetRow.setHeight(sourceRow.getHeight()); +// System.out.println(sourceRow.getLastCellNum()); +// for (m = sourceRow.getFirstCellNum(); m < sourceRow.getLastCellNum(); m++) { +// System.out.println(m); +// sourceCell = sourceRow.getCell(m); +// targetCell = targetRow.createCell(m); +// targetCell.setCellStyle(sourceCell.getCellStyle()); +// targetCell.setCellType(sourceCell.getCellType()); +// } +// } +// } +// +// /*** +// * 向sheet中插入一行 +// * +// * @param sheet +// * @param startRow +// * @param rows +// * @return +// */ +// public static XSSFSheet insertRows(XSSFSheet sheet, int startRow, int rows) { +// XSSFRow sourceRow = sheet.getRow(startRow); +// sheet.shiftRows(startRow + 1, sheet.getLastRowNum(), rows, true, false); +// for (int i = 0; i < rows; i++) { +// XSSFRow targetRow = null; +// XSSFCell sourceCell = null; +// XSSFCell targetCell = null; +// short m; +// targetRow = sheet.createRow(startRow + 1); +// targetRow.setHeight(sourceRow.getHeight()); +// System.out.println(sourceRow.getLastCellNum()); +// for (m = sourceRow.getFirstCellNum(); m < sourceRow.getLastCellNum(); m++) { +// System.out.println(m); +// sourceCell = sourceRow.getCell(m); +// targetCell = targetRow.createCell(m); +// targetCell.setCellStyle(sourceCell.getCellStyle()); +// targetCell.setCellType(sourceCell.getCellType()); +// } +// } +// return sheet; +// } +// +// /** +// * 检查单元格内容是否是数字 +// * +// * @param value +// * @return +// */ +// public static boolean CheckCellValueIsNumber(String value) { +// boolean is_ok = false; +// if (value.equals("")) { +// return false; +// } +// try { +// Float.parseFloat(value); +// } catch (NumberFormatException e) { +// e.printStackTrace(); +// System.out.println("===>" + value); +// is_ok = true; +// } +// return is_ok; +// } +// +//// /** +//// * 拼接麦格纳的联系人和联系电话 +//// * +//// * @param persion +//// * @param phone +//// * @return +//// */ +//// public static String connectPhoneAndPersion(String persion, String phone) { +//// StringBuffer persionPhoneSb = new StringBuffer(); +//// if (persion != null && phone != null) { +//// +//// String[] persions = null; +//// String[] phones = null; +//// if (persion.contains("、")) { +//// persions = persion.split("、"); +//// } else if (persion.contains("\\/")) { +//// persions = persion.split("\\/"); +//// } else if (persion.contains(",")) { +//// persions = persion.split(","); +//// } else { +//// persions = new String[] { persion }; +//// } +//// +//// if (phone.contains("、")) { +//// phones = phone.split("、"); +//// } else if (phone.contains("\\/")) { +//// phones = phone.split("\\/"); +//// } else if (phone.contains(",")) { +//// phones = phone.split(","); +//// } else { +//// phones = new String[] { phone }; +//// } +//// +//// if (persions != null && phones != null) { +//// int persionCount = persions.length; +//// int phonesCount = phones.length; +//// if (persionCount == phonesCount) { +//// for (int i = 0; i < persionCount; i++) { +//// persionPhoneSb.append(persions[i]).append("/") +//// .append(phones[i]).append(" "); +//// +//// } +//// } +//// } +//// } +//// +//// return persionPhoneSb.toString(); +//// } +// +// /*** +// * 输出成形作业指导书 +// * +// * @param xls_write_Address +// * @param ls +// * @param sheetnames +// * @param row_num +// * @param col_num +// * @throws IOException +// * +// */ +// public static void writeExcelForCX(String xls_write_Address, File file, ArrayList> ls, +// int row_num, int col_num) throws IOException { +// InputStream is = new FileInputStream(file); +// XSSFWorkbook wb = new XSSFWorkbook(is);// (new +// is.close(); +// FileOutputStream output = new FileOutputStream(new File(xls_write_Address)); // 读取的文件路径 +// XSSFCellStyle style = wb.createCellStyle(); +//// style.setBorderBottom(XSSFCellStyle.BORDER_THIN); +//// style.setBorderTop(XSSFCellStyle.BORDER_THIN); +//// style.setBorderRight(XSSFCellStyle.BORDER_THIN); +//// style.setAlignment(XSSFCellStyle.ALIGN_CENTER); +// XSSFFont font = wb.createFont(); +// font.setFontHeightInPoints((short) 8); +// style.setFont(font); +// XSSFSheet sheet = wb.getSheetAt(0); +// sheet.setForceFormulaRecalculation(true); +// if (ls != null) +// for (int i = 0; i < ls.size(); i++) { +// if (i % 27 == 0 && i != 0) { +// row_num += 11; +// } +// XSSFRow row = sheet.getRow(i + row_num - 1); +// ArrayList ls2 = ls.get(i); +// for (int cols = 0; cols < ls2.size(); cols++) { +// XSSFCell cell = row.getCell(cols + col_num - 1); +// if (cell == null) { +// cell = row.createCell(cols + col_num - 1); +// } +//// cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 +//// cell.setCellStyle(style);// 添加边框 +// if (cols + col_num == 9) { +// String cpgc = ls2.get(cols); +// System.out.println(cpgc); +// String[] strs = cpgc.split("special"); +// System.out.println("strs.length=>" + strs.length); +// if (cpgc != null && cpgc != "") { +// if (!" ".equals(strs[1])) { +// String special = strs[1]; +// if (special.indexOf("|") <= 0) { +// if ("产品/过程/规格/公差".equals(special.split("-")[0])) { +// int index = Integer.valueOf(special.split("-")[1]); +// if (strs[0] != null && strs[0] != "") { +// cell.setCellValue(setCellFont(wb, strs[0], index, index + 1, 8, "Y14.5M")); +// } +// } +// +// } else { +// String[] tstxs = special.split("\\|"); +// for (String str : tstxs) { +// if ("产品/过程/规格/公差".equals(str.split("-")[0])) { +// int index = Integer.valueOf(str.split("-")[1]); +// if (strs[0] != null && strs[0] != "") { +// cell.setCellValue( +// setCellFont(wb, strs[0], index, index + 1, 8, "Y14.5M")); +// } +// } +// } +// } +// } else { +// // 直接写入strs[0] +// cell.setCellValue(strs[0]); +// } +// } +// } else +// cell.setCellValue(ls2.get(cols));// 写入内容 +// } +// +// } +// else +// MessageBox.post("请完善控制计划!", "警告", MessageBox.WARNING); +// wb.write(output); +// output.close(); +// System.out.println("-------WRITE EXCEL OVER-------"); +// } +// +// /** +// * 输出整形作业指导书 +// * +// * @param string +// * @param is +// * @param zx +// * @param strings +// * @param i +// * @param j +// */ +// public static void writeExcelForZX(String xls_write_Address, File file, ArrayList> ls, +// int row_num, int col_num) throws IOException { +// InputStream is = new FileInputStream(file); +// XSSFWorkbook wb = new XSSFWorkbook(is);// (new +// is.close(); +// FileOutputStream output = new FileOutputStream(new File(xls_write_Address)); // 读取的文件路径 +// XSSFCellStyle style = wb.createCellStyle(); +// style.setBorderBottom(XSSFCellStyle.BORDER_THIN); +// style.setBorderTop(XSSFCellStyle.BORDER_THIN); +// style.setBorderRight(XSSFCellStyle.BORDER_THIN); +// style.setBorderLeft(XSSFCellStyle.BORDER_THIN); +// style.setAlignment(XSSFCellStyle.ALIGN_CENTER); +// XSSFFont font = wb.createFont(); +// font.setFontHeightInPoints((short) 8); +// style.setFont(font); +// XSSFSheet sheet = wb.getSheetAt(0); +// for (int i = 0; i < ls.size(); i++) { +// if (i % 30 == 0 && i != 0) { +// row_num += 10; +// } +// XSSFRow row = sheet.getRow(i + row_num - 1); +// ArrayList ls2 = ls.get(i); +// for (int cols = 0; cols < ls2.size(); cols++) { +// XSSFCell cell = null; +// if (cols == ls2.size() - 1) +// cell = row.getCell(cols + col_num - 1); +// else +// cell = row.getCell(cols + col_num - 1); +// cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 +//// cell.setCellStyle(style);// 添加边框 +// if (cols + col_num == 11) { +// String cpgc = ls2.get(cols); +// System.out.println(cpgc); +// String[] strs = cpgc.split("special"); +// System.out.println("strs.length=>" + strs.length); +// if (cpgc != null && cpgc != "") { +// if (!" ".equals(strs[1])) { +// String special = strs[1]; +// if (special.indexOf("|") <= 0) { +// if ("产品/过程/规格/公差".equals(special.split("-")[0])) { +// int index = Integer.valueOf(special.split("-")[1]); +// if (strs[0] != null && strs[0] != "") { +// cell.setCellValue(setCellFont(wb, strs[0], index, index + 1, 8, "Y14.5M")); +// } +// } +// +// } else { +// String[] tstxs = special.split("\\|"); +// for (String str : tstxs) { +// if ("产品/过程/规格/公差".equals(str.split("-")[0])) { +// int index = Integer.valueOf(str.split("-")[1]); +// if (strs[0] != null && strs[0] != "") { +// cell.setCellValue(setCellFont(wb, strs[0], index, index + 1, 8, "Y14.5M")); +// } +// } +// } +// } +// } else { +// // 直接写入strs[0] +// cell.setCellValue(strs[0]); +// } +// } +// } else +// cell.setCellValue(ls2.get(cols));// 写入内容 +// } +// +// } +// wb.write(output); +// output.close(); +// System.out.println("-------WRITE EXCEL OVER-------"); +// +// } +// +// /** +// * 输出烧结作业指导书 +// * +// * @param string +// * @param is +// * @param zx +// * @param strings +// * @param i +// * @param j +// */ +// public static void writeExcelForSJ(String xls_write_Address, File file, ArrayList> ls, +// List productNameList24, List productNameList18) throws IOException { +// InputStream is = new FileInputStream(file); +// XSSFWorkbook wb = new XSSFWorkbook(is);// (new +// is.close(); +// FileOutputStream output = new FileOutputStream(new File(xls_write_Address)); // 读取的文件路径 +//// writeExcelWithOneCellName(wb, "生产设备", rb3_jqsb); +// XSSFCellStyle style = wb.createCellStyle(); +// style.setBorderBottom(XSSFCellStyle.BORDER_THIN); +// style.setBorderTop(XSSFCellStyle.BORDER_THIN); +// style.setBorderRight(XSSFCellStyle.BORDER_THIN); +// style.setBorderLeft(XSSFCellStyle.BORDER_THIN); +// style.setAlignment(XSSFCellStyle.ALIGN_CENTER); +// XSSFFont font = wb.createFont(); +// font.setFontHeightInPoints((short) 8); +// style.setFont(font); +// XSSFSheet s = wb.getSheetAt(0); +// s.setForceFormulaRecalculation(true); +// if (productNameList24 != null) { +// setNamedCellValue(wb, "二十四寸", +// productNameList24.toString().substring(1, productNameList24.toString().length() - 1)); +// } +// if (productNameList18 != null) { +// setNamedCellValue(wb, "十八寸", +// productNameList18.toString().substring(1, productNameList18.toString().length() - 1)); +// } +// int[] indexs = getNamedCellIndex(wb, "设备"); +// int startRow = indexs[1] + 1; +// int startColumn = indexs[0]; +// for (int i = 0; i < productNameList24.size(); i++) { +// +// Row r = s.getRow(startRow + i); +// setCellValue(r, startColumn, productNameList24.get(i)); +// } +// for (int i = 0; i < productNameList18.size(); i++) { +// Row r = s.getRow(startRow + productNameList24.size() + i); +// setCellValue(r, startColumn, productNameList18.get(i)); +// } +// +// int row_num = 0; +// int t = 0; +// for (int i = 0; i < ls.size(); i++) { +// if (t % 12 == 0 && i != 0) { +// t = 0; +// row_num += 29; +// } +// +// ArrayList ls2 = ls.get(i); +// System.out.println("SJ_data.size===============>" + ls2.size()); +// System.out.println("SJ_data====================>" + ls2.toString()); +// for (int j = 0; j < ls2.size() + 1; j++) { +// int namedCellIdx = wb.getNameIndex("head" + String.valueOf(j + 1)); +// if (namedCellIdx != -1) { +// Name aNamedCell = wb.getNameAt(namedCellIdx); +// AreaReference[] arefs = AreaReference.generateContiguous(aNamedCell.getRefersToFormula()); +// CellReference[] crefs = arefs[0].getAllReferencedCells(); +// for (int k = 0; k < crefs.length; k++) { +// Row r = s.getRow(crefs[k].getRow() + row_num + 1); +// Cell c = r.getCell(crefs[k].getCol()); +// if (j == 2) { +// toSpecial(j, wb, c, ls2); +// } else if (namedCellIdx != wb.getNameIndex("head7")) +// c.setCellValue(ls2.get(j)); +// else +// c.setCellValue("√"); +// } +// } +// +// } +// t++; +// row_num++; +// } +// wb.write(output); +// output.close(); +// System.out.println("-------WRITE EXCEL OVER-------"); +// +// } + + // 20181220-ReinhartEdit + /*** + * 输出热处理作业指导书 + * + * @param xls_write_Address + * @param ls + * @param sheetnames + * @param row_num + * @param col_num + * @throws IOException + * + */ +// public static void writeExcelForRCL(String xls_write_Address, File file, ArrayList> ls, +// int row_num, int col_num) throws IOException { +// // InputStream is = new FileInputStream(file); +// // XSSFWorkbook wb = new XSSFWorkbook(is);// (new +// // is.close(); +// // FileOutputStream output = new FileOutputStream(new File( +// // xls_write_Address)); // 读取的文件路径 +// +// // XSSFCellStyle style = wb.createCellStyle(); +// // MessageBox.post("In Processing", "Step", MessageBox.WARNING); +// +// // MessageBox.post(xls_write_Address, "Step", MessageBox.WARNING); +// +// // 读取Excel文档 +// // File finalXlsxFile = new File("D:/NBTM热处理工艺指导书.xlsx"); +// File finalXlsxFile = new File(xls_write_Address); +// Workbook workBook = getWorkbok(finalXlsxFile); +// // sheet 对应一个工作页 +// Sheet getSheet = workBook.getSheetAt(0); +// +//// style.setBorderBottom(XSSFCellStyle.BORDER_THIN); +//// style.setBorderTop(XSSFCellStyle.BORDER_THIN); +//// style.setBorderRight(XSSFCellStyle.BORDER_THIN); +//// style.setAlignment(XSSFCellStyle.ALIGN_CENTER); +// // XSSFFont font = wb.createFont(); +// /// font.setFontHeightInPoints((short) 8); +// // style.setFont(font); +// +// if (ls != null) { +// +// int rowNumber = getSheet.getLastRowNum(); // 第一行从0开始算 +// System.out.println("原始数据总行数:" + ls.size()); +// +// // 先把模板文件内容清空了 +// for (int i = 0; i < 10; i++) { +// Row row = getSheet.getRow(i + 26); +// +// if (row == null) { +// row = getSheet.createRow(i + 26); +// } +// try { +// Cell Itemcell = row.getCell(2); +// if (Itemcell == null) { +// Itemcell = row.createCell(2); +// } +// Itemcell.setCellValue("");// 写入内容 +// +// Cell Valuecell = row.getCell(6); +// if (Valuecell == null) { +// Valuecell = row.createCell(6); +// } +// Valuecell.setCellValue("");// 写入内容 +// +// Cell Processcell = row.getCell(10); +// if (Processcell == null) { +// Processcell = row.createCell(10); +// } +// Processcell.setCellValue("");// 写入内容 +// +// Cell Doublecell = row.getCell(14); +// if (Doublecell == null) { +// Doublecell = row.createCell(14); +// } +// Doublecell.setCellValue("");// 写入内容 +// +// } catch (Exception ex) { +// System.out.println(ex.toString()); +// MessageBox.post(ex.toString(), "Error", MessageBox.ERROR); +// +// return; +// } +// +// } +// // System.out.println("先把模板文件内容清空了" ); +// +// // 先把模板文件内容清空了 +// // 写入参数数据 +// // System.out.println(ls.size()); +// for (int i = 0; i < ls.size(); i++) { +// +// System.out.println("写入实际数据!"); +// Row row = getSheet.getRow(i + 26); +// +// if (row == null) { +// row = getSheet.createRow(i + 26); +// } +// +// ArrayList ls2 = ls.get(i); +// // System.out.println(ls2.get(i)); +// // MessageBox.post(ls2.get(0), "Step", MessageBox.WARNING); +// +// try { +// +// Cell Itemcell = row.getCell(2); +// if (Itemcell == null) { +// Itemcell = row.createCell(2); +// } +// System.out.println(ls2.get(1)); +// Itemcell.setCellValue(ls2.get(1));// 写入内容 +// +// Cell Valuecell = row.getCell(6); +// if (Valuecell == null) { +// Valuecell = row.createCell(6); +// } +// System.out.println(ls2.get(2)); +// Valuecell.setCellValue(ls2.get(2));// 写入内容 +// +// Cell Processcell = row.getCell(10); +// if (Processcell == null) { +// Processcell = row.createCell(10); +// } +// System.out.println(ls2.get(3)); +// Processcell.setCellValue(ls2.get(3));// 写入内容 +// +// Cell Doublecell = row.getCell(14); +// if (Doublecell == null) { +// Doublecell = row.createCell(14); +// } +// System.out.println(ls2.get(4)); +// Doublecell.setCellValue(ls2.get(4));// 写入内容 +// +// } catch (Exception ex) { +// System.out.println(ex.toString()); +// MessageBox.post(ex.toString(), "Error", MessageBox.ERROR); +// +// return; +// } +// +// } +// // 写入参数数据 +// +// // FileOutputStream output = new FileOutputStream("D:/MY热处理工艺指导书.xlsx"); // +// // 读取的文件路径 +// FileOutputStream output = new FileOutputStream(xls_write_Address); // 读取的文件路径 +// +// workBook.write(output); +// // wb.write(output); +// +// if (output != null) { +// output.flush(); +// output.close(); +// } +// +// // System.out.println("Start output data to Excel end!!!!!"); +// // MessageBox.post(" output data to Excel end!!!!!", "Step", +// // MessageBox.WARNING); +// +// } else { +// MessageBox.post("请完善控制计划!", "警告", MessageBox.WARNING); +// } +// +// System.out.println("-------WRITE EXCEL OVER-------"); +// } +// +// public static void toSpecial(int cols, XSSFWorkbook wb, Cell cell, ArrayList cell_Date) { +// String cpgc = cell_Date.get(cols); +//// System.out.println(cpgc); +// String[] strs = cpgc.split("special"); +//// System.out.println(strs.length); +// if (cpgc != null || cpgc != "") { +// if (!"null".equals(strs[1]) && !" ".equals(strs[1])) { +// String special = strs[1]; +// if (special.indexOf("|") <= 0) { +// if ("产品/过程/规格/公差".equals(special.split("-")[0])) { +// int index = Integer.valueOf(special.split("-")[1]); +// if (strs[0] != null && strs[0] != "") { +// cell.setCellValue(setCellFont(wb, strs[0], index, index + 1, 8, "Y14.5M")); +// } +// } +// +// } else { +// String[] tstxs = special.split("\\|"); +// for (String str : tstxs) { +// if ("产品/过程/规格/公差".equals(str.split("-")[0])) { +// int index = Integer.valueOf(str.split("-")[1]); +// if (strs[0] != null && strs[0] != "") { +// cell.setCellValue(setCellFont(wb, strs[0], index, index + 1, 8, "Y14.5M")); +// } +// } +// } +// } +// } else { +// // 直接写入strs[0] +// cell.setCellValue(strs[0]); +// } +// } +// +// } +// +// public static void writeExcelWithOneCellName(XSSFWorkbook wb, String cellName, String value) { +// +// int namedCellIdx = wb.getNameIndex(cellName); +// if (namedCellIdx != -1) { +// Name aNamedCell = wb.getNameAt(namedCellIdx); +// AreaReference[] arefs = AreaReference.generateContiguous(aNamedCell.getRefersToFormula()); +// for (int i = 0; i < arefs.length; i++) { +// CellReference[] crefs = arefs[i].getAllReferencedCells(); +// for (int j = 0; j < crefs.length; j++) { +// Sheet s = wb.getSheet(crefs[j].getSheetName()); +// Row r = s.getRow(crefs[j].getRow()); +// Cell c = r.getCell(crefs[j].getCol()); +// c.setCellValue(value); +// } +// } +// } +// } +// +// /** +// * 将对象属性值写入到Excel中 +// * +// * @param output +// * @param file +// * @param cellName +// * @param cellValue +// */ +// public static void writeExcelWithCellName(File file, String fileOutUrl, Map map, int code, +// String meop_name) { +// try { +// InputStream is = new FileInputStream(file); +// Workbook wb = new XSSFWorkbook(is);// retrieve workbook +// is.close(); +// FileOutputStream output = new FileOutputStream(new File(fileOutUrl)); +// boolean is_first = true; +// for (String key : map.keySet()) { +// if (is_first && "产品代号".equals(key) && (code == 3 || code == 4 || code == 5)) { +// int a1CellIndex = wb.getNameIndex("head"); +// if (a1CellIndex != -1) { +// Name a1NameCell = wb.getNameAt(a1CellIndex); +// AreaReference[] a1ARF = AreaReference.generateContiguous(a1NameCell.getRefersToFormula()); +// CellReference[] a1CRF = a1ARF[0].getAllReferencedCells(); +// Sheet s = wb.getSheet(a1CRF[0].getSheetName()); +// Row r = s.getRow(a1CRF[0].getRow()); +// Cell c = r.getCell(a1CRF[0].getCol()); +// System.out.println(key + ":" + c.getStringCellValue()); +// c.setCellValue(c.getStringCellValue() + map.get(key)); +// is_first = false; +// } +// } +// +// if ("工艺流程".equals(key)) { +// SetFont(wb, map.get(key), meop_name); +// } +// +// else { +// +// int namedCellIdx = wb.getNameIndex(key); +// if (namedCellIdx != -1) { +// Name aNamedCell = wb.getNameAt(namedCellIdx); +// AreaReference[] arefs = AreaReference.generateContiguous(aNamedCell.getRefersToFormula()); +// for (int i = 0; i < arefs.length; i++) { +// CellReference[] crefs = arefs[i].getAllReferencedCells(); +// +// for (int j = 0; j < crefs.length; j++) { +// +// Sheet s = wb.getSheet(crefs[j].getSheetName()); +// Row r = s.getRow(crefs[j].getRow()); +// Cell c = r.getCell(crefs[j].getCol()); +// if (code == 2) { +// c.setCellValue(map.get(key).split("/")[0]); +// } else +// c.setCellValue(map.get(key)); +// } +// } +// } +// } +// } +// wb.write(output); +// output.close(); +// +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// +// /** +// * 设置str1中str2的字体 +// * +// * @param wb +// * @param str1 +// * @param str2 +// * @throws IOException +// */ +// private static void SetFont(Workbook wb, String str1, String str2) throws IOException { +// int index = 0; +// int start_index = 0; +// int end_index = str1.length(); +// String meop_name = str2.split("/")[0]; +// if (str1.indexOf("成形") != -1) +// start_index = str1.indexOf("成形"); +// if (str1.lastIndexOf("包装") != -1) +// end_index = str1.lastIndexOf("包装") + 2; +// str1 = str1.substring(start_index, end_index); +// while ((index = str1.indexOf(meop_name, index)) != -1) { +// int next_index = index + meop_name.length(); +// boolean begin = index - 1 < 0 || str1.charAt(index - 1) == '-'; +// boolean end = next_index > str1.length() || next_index + 1 > str1.length() ? true +// : str1.charAt(next_index) == '-'; +// if (begin && end) +// break; +// else +// index = index + meop_name.length(); +// } +// XSSFRichTextString ts = new XSSFRichTextString(str1); +// XSSFFont font1 = (XSSFFont) wb.createFont(); +// font1.setFontHeightInPoints((short) 10); // 字体高度 +// font1.setFontName("仿宋"); // 字体 +// XSSFFont font = (XSSFFont) wb.createFont(); +// font.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); +// font.setFontHeightInPoints((short) 12); // 字体高度 +// font.setFontName("仿宋"); +// ts.applyFont(index, index + meop_name.length(), font); +// ts.applyFont(index + meop_name.length(), ts.length(), font1); +//// XSSFFont font = (XSSFFont) wb.createFont(); +//// +//// font.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); +//// ts.applyFont(index, index+str2.length(), font); +// int namedCellIdx = wb.getNameIndex("工艺流程"); +// if (namedCellIdx != -1) { +// Name aNamedCell = wb.getNameAt(namedCellIdx); +// AreaReference[] arefs = AreaReference.generateContiguous(aNamedCell.getRefersToFormula()); +// for (int i = 0; i < arefs.length; i++) { +// CellReference[] crefs = arefs[i].getAllReferencedCells(); +// for (int j = 0; j < crefs.length; j++) { +// Sheet s = wb.getSheet(crefs[j].getSheetName()); +// Row r = s.getRow(crefs[j].getRow()); +// Cell c = r.getCell(crefs[j].getCol()); +// c.setCellValue(ts); +// } +// } +// } +// } + + /** + * 添加命名的引用 + * + * @param session + * @param item 对象的版本 + * @param tcResource 文件的物理路径 + * @param relationType 关系名称 + * @param fileName 文件名 + */ + public static void setExcelToItem(TCSession session, TCComponentItemRevision item, String tcResource, + String fileName, String relationType, String excelType, boolean isDelete) { + try { + String as1[] = { tcResource };// 文件的物理路径 + String as2[] = { "excel" }; + String as3[] = { excelType }; + String as4[] = { "Plain" }; + TCComponentDatasetType tccomponentDatasetType = (TCComponentDatasetType) session + .getTypeComponent("Dataset"); + TCComponentDataset tccomponentDataset = tccomponentDatasetType.create(fileName, "excel", excelType); + tccomponentDataset.setFiles(as1, as3, as4, as2); + AIFComponentContext[] zyzdsChildrens = item.getChildren(); + TCComponentItemRevision zyzdsRev = item; + for (AIFComponentContext zyzdsChildren : zyzdsChildrens) { + if (excelType.equals(zyzdsChildren.getComponent().getType())) { + TCComponentDataset dateSet = (TCComponentDataset) zyzdsChildren.getComponent(); + if (dateSet.getStringProperty("object_name").equals(fileName)) { + dateSet.delete(); + zyzdsRev.remove(relationType, dateSet); + } + } + } + item.add(relationType, tccomponentDataset); + if (isDelete) { + new File(tcResource).delete(); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * 获取命名的引用返回所有对象 + * + * @param session + * @param item 对象的版本 + * @param relationType 关系名称 + */ + public static TCComponentDataset[] getComponentToDatasets(TCSession session, TCComponentItemRevision item, + String relationType) { + try { + TCComponent[] zyzdsChildrens = item.getRelatedComponents(relationType); + TCComponentDataset[] Childrens = new TCComponentDataset[zyzdsChildrens.length]; + if (zyzdsChildrens == null || zyzdsChildrens.length < 1) { + return null; + } + for (int ii = 0; ii < zyzdsChildrens.length; ii++) { + + if (zyzdsChildrens[ii] instanceof TCComponentDataset) { + // + + Childrens[ii] = (TCComponentDataset) zyzdsChildrens[ii]; + + // + } + +// + + } + + return Childrens; + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + /** + * 获取命名的引用 + * + * @param session + * @param item 对象的版本 + * @param relationType 关系名称 + */ + + public static TCComponentDataset getComponentToDataset(TCSession session, TCComponentItemRevision item, + String relationType) { + try { + TCComponent[] zyzdsChildrens = item.getRelatedComponents(relationType); + if (zyzdsChildrens == null || zyzdsChildrens.length < 1) { + return null; + } + for (TCComponent zyzdsChildren : zyzdsChildrens) { + + return (TCComponentDataset) zyzdsChildren; +// + + } + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + /** + * 获取命名的引用 + * + * @param session + * @param item 对象的版本 + * @param relationType 关系名称 + */ + public static TCComponentDataset getExcelToDataset(TCSession session, TCComponentItemRevision item, + String relationType, String fileType) { + try { + TCComponent[] zyzdsChildrens = item.getRelatedComponents(relationType); + if (zyzdsChildrens == null || zyzdsChildrens.length < 1) { + return null; + } + for (TCComponent zyzdsChildren : zyzdsChildrens) { + if (fileType.equals(zyzdsChildren.getType())) { + return (TCComponentDataset) zyzdsChildren; +// TCComponentTcFile[] tcFile = dateSet.getTcFiles(); +// return tcFile[0].getFmsFile(); + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + /** + * 获取命名的引用 + * + * @param session + * @param item 对象的版本 + * @param relationType 关系名称 + */ + public static File getExcelToItem(TCSession session, TCComponentItemRevision item, String relationType, + String fileType) { + try { + TCComponent[] zyzdsChildrens = item.getRelatedComponents(relationType); + if (zyzdsChildrens == null || zyzdsChildrens.length < 1) { + return null; + } + for (TCComponent zyzdsChildren : zyzdsChildrens) { + if (fileType.equals(zyzdsChildren.getType())) { + TCComponentDataset dateSet = (TCComponentDataset) zyzdsChildren; + TCComponentTcFile[] tcFile = dateSet.getTcFiles(); + return tcFile[0].getFmsFile(); + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + /** + * 获取合并单元格 + * + * @param value 值 + * @param startIndex 起始行 + * @return + */ + public static void getCombineRow(String value, int startIndex) { + // TODO Auto-generated method stub + String[] sombines = null; + if (value != null && !value.equals("")) { + if (value.indexOf("-") >= 0) { + sombines = value.split("-"); + } else { + sombines = new String[] { value }; + } + } + for (int j = 0; j < sombines.length; j++) { + if (sombines[j].indexOf("/") >= 0) { + int[] row; + int[] cloumn; + String[] cells = sombines[j].split("/"); + if (cells[0].indexOf(",") >= 0) { + String[] rows = cells[0].split(","); + row = new int[rows.length]; + for (int k = 0; k < rows.length; k++) { + row[k] = Integer.parseInt(rows[k]) + startIndex; + } + } else { + row = new int[] { Integer.parseInt(cells[0]) + startIndex }; + } + if (cells[1].indexOf(",") >= 0) { + String[] cloumns = cells[1].split(","); + cloumn = new int[cloumns.length]; + for (int k = 0; k < cloumns.length; k++) { + cloumn[k] = Integer.parseInt(cloumns[k]) - 1; + } + } else { + cloumn = new int[] { Integer.parseInt(cells[1]) - 1 }; + } + map.put(row, cloumn); + } + } + } + + /** + * 获取单个的命名单元格的列 + * + * @param wb + * @param cellName + * @return + * @throws IOException + */ +// public static int getOneNamedCellIndex(XSSFWorkbook wb, String cellName) throws IOException { +// int index = -1; +// XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(wb); +// XSSFName name = wb.getName(cellName); +// if (name == null) { +// return -1; +// } +// AreaReference[] areaRs = AreaReference.generateContiguous(name.getRefersToFormula()); +// if (areaRs != null) +// for (AreaReference areaR : areaRs) { +// CellReference[] cellRs = areaR.getAllReferencedCells(); +// if (cellRs != null) { +// for (CellReference cellR : cellRs) { +// String sheetName = cellR.getSheetName(); +// short colIndex = cellR.getCol(); +// int rowIndex = cellR.getRow(); +// XSSFSheet sheet = wb.getSheet(sheetName); +// XSSFRow row = sheet.getRow(rowIndex); +// return colIndex; +// } +// } +// } +// return index; +// } + + /** + * 爱信--输出控制计划到EXCEL表格中 + * + * @param controlPlanBean 控制计划信息 + * @param input 模版文件流 + * @param outputFilePath 需要输出的全路径 + * @throws IOException + */ +// public static int writeAixinControlPlanToExcel(TMomControlPlanBean controlPlanBean, InputStream input, +// String outputFilePath, String type) throws IOException { +// +// FileOutputStream output = new FileOutputStream(new File(outputFilePath)); // +// XSSFWorkbook wb = new XSSFWorkbook(input);// ( +// XSSFSheet sheet = wb.getSheetAt(0); +// map.clear(); +// int startRow = 14; +// List simpleBeanList = null; +// if (controlPlanBean != null) { +// // 添加单属性信息到excel表中 +// simpleBeanList = controlPlanBean.getSimpleBeanList(); +// +// for (int i = 0; i < (simpleBeanList.size()); i++) +// insertRow(sheet, 14, 1);// 插入表格行数 +// XSSFRow row1 = sheet.getRow(5); +// setCellValue(row1, 10, controlPlanBean.getSorName()); +// setCellValue(row1, 13, controlPlanBean.getControlPlanNo()); +// XSSFRow row2 = sheet.getRow(8); +// setCellValue(row2, 0, controlPlanBean.getCustromPartNumber()); +// setCellValue(row2, 4, controlPlanBean.getPartNameDesc()); +// setCellValue(row2, 6, controlPlanBean.getMode()); +// setCellValue(row2, 8, controlPlanBean.getSupplier()); +// setCellValue(row2, 10, controlPlanBean.getKeyPersion());// 此处可能需要修改 +// setCellValue(row2, 13, controlPlanBean.getKeyPhone());// 此处可能需要修改 +// XSSFRow row3 = sheet.getRow(9); +// setCellValue(row3, 7, controlPlanBean.getSupplierApprovalDateStr()); +// setCellValue(row3, 9, controlPlanBean.getCustromApprovalDateStr()); +// XSSFRow row4 = sheet.getRow(10); +// setCellValue(row4, 0, controlPlanBean.getCoreTeam()); +// setCellValue(row4, 10, controlPlanBean.getCreateDateStr()); +// setCellValue(row4, 13, controlPlanBean.getUpdateDateStr()); +// } else { +// return -1; +// } +// if (simpleBeanList == null) { +// return -1; +// } +// for (int i = 0; i < simpleBeanList.size(); i++) { +// TMomControlPlanSimpleBean bean = simpleBeanList.get(i); +// if (bean.getHbdyg() != null && !bean.getHbdyg().equals("")) { +// getCombineRow(bean.getHbdyg(), startRow); +// } +// XSSFRow row = null; +// Boolean isCreat = false; +// if ((i + startRow) > sheet.getLastRowNum()) { +// row = sheet.createRow(i + startRow); +// isCreat = true; +// } else { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } +// // 获取特殊字符所在位置 +// String[] columnNames = null; +// Map indexMap = new HashMap(); +// if (bean.getSpecial() != null && !bean.getSpecial().equals("")) { +// try { +// if (bean.getSpecial().indexOf("|") >= 0) { +// columnNames = bean.getSpecial().split("\\|"); +// } else { +// columnNames = new String[] { bean.getSpecial() }; +// } +// if (columnNames != null && columnNames.length > 0) { +// for (int i1 = 0; i1 < columnNames.length; i1++) { +// if (columnNames[i1].indexOf("-") >= 0) { +// String[] columnName = columnNames[i1].split("-"); +// // 通过列名称获取列 +// int cellindex = -1; +// if (columnName[0].indexOf(",") >= 0) { +// cellindex = getOneNamedCellIndex(wb, columnName[0].replaceAll(",", "")); +// } else if (columnName[0].indexOf("/") >= 0) { +// cellindex = getOneNamedCellIndex(wb, columnName[0].replaceAll("/", "")); +// } else { +// cellindex = getOneNamedCellIndex(wb, columnName[0]); +// } +// if (cellindex > -1) { +// indexMap.put(cellindex, Integer.parseInt(columnName[1])); +// } +// } +// } +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// } +// for (int cols = 0; cols <= 15; cols++) { +// XSSFCell cell = null; +// if (isCreat) { +// cell = row.createCell(cols); +// } else { +// cell = row.getCell(cols); +// } +// cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 +// +// switch (cols) { +// +// case 0: +// if (bean.getPartProcessNumber() != null && bean.getPartProcessNumber().indexOf("\n") >= 0 +// && bean.getPartProcessNumber().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getPartProcessNumber().split("\n")[1]); +// } else if (bean.getPartProcessNumber() != null && bean.getPartProcessNumber().indexOf("\n") >= 0 +// && bean.getPartProcessNumber().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getPartProcessNumber().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getPartProcessNumber(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getPartProcessNumber()); +// } +// break; +// case 1: +// if (bean.getProcessName() != null && bean.getProcessName().indexOf("\n") >= 0 +// && bean.getProcessName().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getProcessName().split("\n")[1]); +// } else if (bean.getProcessName() != null && bean.getProcessName().indexOf("\n") >= 0 +// && bean.getProcessName().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getProcessName().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProcessName(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProcessName()); +// } +// break; +// case 2: +// if (bean.getMachineDevice() != null && bean.getMachineDevice().indexOf("\n") >= 0 +// && bean.getMachineDevice().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getMachineDevice().split("\n")[1]); +// } else if (bean.getMachineDevice() != null && bean.getMachineDevice().indexOf("\n") >= 0 +// && bean.getMachineDevice().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getMachineDevice().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getMachineDevice(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getMachineDevice()); +// } +// break; +// case 3: +// if (bean.getSmjy() != null && bean.getSmjy().indexOf("\n") >= 0 +// && bean.getSmjy().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getSmjy().split("\n")[1]); +// } else if (bean.getSmjy() != null && bean.getSmjy().indexOf("\n") >= 0 +// && bean.getSmjy().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getSmjy().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSmjy(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSmjy()); +// } +// break; +// case 4: +// // String noo = bean.(); +// if (bean.getBubbledPrintNo() != null && bean.getBubbledPrintNo().indexOf("\n") >= 0 +// && bean.getBubbledPrintNo().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getBubbledPrintNo().split("\n")[1]); +// } else if (bean.getBubbledPrintNo() != null && bean.getBubbledPrintNo().indexOf("\n") >= 0 +// && bean.getBubbledPrintNo().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getBubbledPrintNo().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getBubbledPrintNo(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getBubbledPrintNo()); +// } +// break; +// case 5: +// if (bean.getProduct() != null && bean.getProduct().indexOf("\n") >= 0 +// && bean.getProduct().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getProduct().split("\n")[1]); +// } else if (bean.getProduct() != null && bean.getProduct().indexOf("\n") >= 0 +// && bean.getProduct().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getProduct().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProduct(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProduct()); +// } +// break; +// case 6: +// if (bean.getProcess() != null && bean.getProcess().indexOf("\n") >= 0 +// && bean.getProcess().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getProcess().split("\n")[1]); +// } else if (bean.getProcess() != null && bean.getProcess().indexOf("\n") >= 0 +// && bean.getProcess().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getProcess().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProcess(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProcess()); +// } +// break; +// case 7: +// if (bean.getSpecialClass() != null && bean.getSpecialClass().indexOf("\n") >= 0 +// && bean.getSpecialClass().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getSpecialClass().split("\n")[1]); +// } else if (bean.getSpecialClass() != null && bean.getSpecialClass().indexOf("\n") >= 0 +// && bean.getSpecialClass().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getSpecialClass().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSpecialClass(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSpecialClass()); +// } +// break; +// case 8: +// if (bean.getConceal().equals("1")) { +// String processName = bean.getProcessName();// .split("\n")[1]; +// String productId = bean.getMeopId().split("_")[0]; +// StringBuffer value = new StringBuffer(); +// System.out.println(value.length()); +// if (type.indexOf("CHINESE") != -1) { +// String name = processName.split("\n")[0]; +// if (bean.getProcessName() != null && bean.getProcessName().indexOf("检验(") >= 0) { +// name = name.substring(3, name.length() - 1); +// } +// value.append("详见" + name + "作业指导书/" + productId); +// // cell.setCellValue("详见"+processName+"作业指导书/"+productId); +// } +// if (type.indexOf("ENGLISH") != -1) { +// String name = processName.split("\n")[1]; +// if (bean.getProcessName() != null && bean.getProcessName().indexOf("检验(") >= 0) { +// name = name.substring(8, name.length() - 1); +// } +// if (value.length() != 0) +// value.append("\n"); +// value.append("In " + name + " OP INS/" + productId); +// +// } +// cell.setCellValue(value.toString()); +// } else { +// if (bean.getProductProcessSpecificationTolerance() != null +// && bean.getProductProcessSpecificationTolerance().indexOf("\n") >= 0 +// && bean.getProductProcessSpecificationTolerance().split("\n").length == 2 +// && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getProductProcessSpecificationTolerance().split("\n")[1]); +// } else if (bean.getProductProcessSpecificationTolerance() != null +// && bean.getProductProcessSpecificationTolerance().indexOf("\n") >= 0 +// && bean.getProductProcessSpecificationTolerance().split("\n").length == 2 +// && type.equals("CHINESE")) { +// cell.setCellValue(bean.getProductProcessSpecificationTolerance().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProductProcessSpecificationTolerance(), +// indexMap.get(cols), indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProductProcessSpecificationTolerance()); +// } +// } +//// if (bean.getUpProductProcessSpecificationTolerance() == null) { +//// cell.setCellValue(""); +//// } else if (!bean +//// .getUpProductProcessSpecificationTolerance().trim() +//// .isEmpty() +//// && !bean.getDownProductProcessSpecificationTolerance() +//// .trim().isEmpty()) +//// cell.setCellValue(bean +//// .getProductProcessSpecificationTolerance() +//// + " " +//// + bean.getUpProductProcessSpecificationTolerance() +//// + "/" +//// + bean.getDownProductProcessSpecificationTolerance()); +//// else { +//// +//// } +// break; +// case 9: +// if (bean.getEvaluationMeasurementTechnique() != null +// && bean.getEvaluationMeasurementTechnique().indexOf("\n") >= 0 +// && bean.getEvaluationMeasurementTechnique().split("\n").length == 2 +// && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getEvaluationMeasurementTechnique().split("\n")[1]); +// } else if (bean.getEvaluationMeasurementTechnique() != null +// && bean.getEvaluationMeasurementTechnique().indexOf("\n") >= 0 +// && bean.getEvaluationMeasurementTechnique().split("\n").length == 2 +// && type.equals("CHINESE")) { +// cell.setCellValue(bean.getEvaluationMeasurementTechnique().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getEvaluationMeasurementTechnique(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getEvaluationMeasurementTechnique()); +// } +// break; +// case 10: +// if (bean.getSampleSize() != null && bean.getSampleSize().indexOf("\n") >= 0 +// && bean.getSampleSize().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getSampleSize().split("\n")[1]); +// } else if (bean.getSampleSize() != null && bean.getSampleSize().indexOf("\n") >= 0 +// && bean.getSampleSize().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getSampleSize().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSampleSize(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSampleSize()); +// } +// break; +// case 11: +// if (bean.getSampleFreq() != null && bean.getSampleFreq().indexOf("\n") >= 0 +// && bean.getSampleFreq().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getSampleFreq().split("\n")[1]); +// } else if (bean.getSampleFreq() != null && bean.getSampleFreq().indexOf("\n") >= 0 +// && bean.getSampleFreq().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getSampleFreq().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSampleFreq(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSampleFreq()); +// } +// break; +// case 12: +// if (bean.getResp() != null && bean.getResp().indexOf("\n") >= 0 +// && bean.getResp().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getResp().split("\n")[1]); +// } else if (bean.getResp() != null && bean.getResp().indexOf("\n") >= 0 +// && bean.getResp().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getResp().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getResp(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getResp()); +// } +// break; +// case 13: +// if (bean.getControlMethod() != null && bean.getControlMethod().indexOf("\n") >= 0 +// && bean.getControlMethod().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getControlMethod().split("\n")[1]); +// } else if (bean.getControlMethod() != null && bean.getControlMethod().indexOf("\n") >= 0 +// && bean.getControlMethod().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getControlMethod().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getControlMethod(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getControlMethod()); +// } +// break; +// case 14: +// if (bean.getOperationCriteria() != null && bean.getOperationCriteria().indexOf("\n") >= 0 +// && bean.getOperationCriteria().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getOperationCriteria().split("\n")[1]); +// } else if (bean.getOperationCriteria() != null && bean.getOperationCriteria().indexOf("\n") >= 0 +// && bean.getOperationCriteria().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getOperationCriteria().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getOperationCriteria(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getOperationCriteria()); +// } +// break; +// case 15: +// if (bean.getReactionPlan() != null && bean.getReactionPlan().indexOf("\n") >= 0 +// && bean.getReactionPlan().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getReactionPlan().split("\n")[1]); +// } else if (bean.getReactionPlan() != null && bean.getReactionPlan().indexOf("\n") >= 0 +// && bean.getReactionPlan().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getReactionPlan().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getReactionPlan(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getReactionPlan()); +// } +// break; +// +// default: +// break; +// +// } +// } +// } +// if (map != null && map.size() != 0) { +// Iterator> it = map.entrySet().iterator(); +// while (it.hasNext()) { +// Map.Entry entry = it.next(); +// List columnIndex = new ArrayList(); +// for (int i = 0; i < entry.getValue().length; i++) { +// if (entry.getValue()[i] == 3 || entry.getValue()[i] == 5 +// || (entry.getValue()[i] >= 18 && entry.getValue()[i] <= 20)) { +// continue; +// } else if (entry.getValue()[i] == 4) { +// columnIndex.add(entry.getValue()[i] - 1); +// } else if (entry.getValue()[i] >= 7 && entry.getValue()[i] <= 17) { +// columnIndex.add(entry.getValue()[i] - 3); +// } else { +// columnIndex.add(entry.getValue()[i]); +// } +// } +// int[] column = new int[columnIndex.size()]; +// for (int i = 0; i < columnIndex.size(); i++) { +// column[i] = columnIndex.get(i); +// } +// if (column.length > 0) { +// combine(sheet, entry.getKey(), column); +// } +// } +// } +// wb.write(output); +// output.close(); +// input.close(); +// System.out.println("-------WRITE EXCEL OVERax-------"); +// +// return 0; +// } +// +// /** +// * 拼接麦格纳的联系人和联系电话 +// * +// * @param persion +// * @param phone +// * @return +// */ +// public static String connectPhoneAndPersion(String persion, String phone) { +// StringBuffer persionPhoneSb = new StringBuffer(); +// if (persion != null && phone != null) { +// +// String[] persions = null; +// String[] phones = null; +// if (persion.contains("、")) { +// persions = persion.split("、"); +// } else if (persion.contains("\\/")) { +// persions = persion.split("\\/"); +// } else if (persion.contains(",")) { +// persions = persion.split(","); +// } else { +// persions = new String[] { persion }; +// } +// +// if (phone.contains("、")) { +// phones = phone.split("、"); +// } else if (phone.contains("\\/")) { +// phones = phone.split("\\/"); +// } else if (phone.contains(",")) { +// phones = phone.split(","); +// } else { +// phones = new String[] { phone }; +// } +// +// if (persions != null && phones != null) { +// int persionCount = persions.length; +// int phonesCount = phones.length; +// if (persionCount == phonesCount) { +// for (int i = 0; i < persionCount; i++) { +// persionPhoneSb.append(persions[i]).append("/").append(phones[i]).append(" "); +// +// } +// } +// } +// } +// +// return persionPhoneSb.toString(); +// } +// +// /** +// * 麦格纳--输出控制计划到EXCEL表格中 +// * +// * @param controlPlanBean 控制计划信息 +// * @param input 模版文件流 +// * @param outputFilePath 需要输出的全路径 +// * @throws IOException +// */ +// public static int writeMaigelaControlPlanToExcel(TMomControlPlanBean controlPlanBean, InputStream input, +// String outputFilePath, String type) throws IOException { +// +// FileOutputStream output = new FileOutputStream(new File(outputFilePath)); // +// XSSFWorkbook wb = new XSSFWorkbook(input);// ( +// XSSFSheet sheet = wb.getSheetAt(0); +// int startRow = 14; +// map.clear(); +// List simpleBeanList = null; +// if (controlPlanBean != null) { +// // 添加单属性信息到excel表中 +// simpleBeanList = controlPlanBean.getSimpleBeanList(); +// +// // for (int i = 0; i < (simpleBeanList.size()); i++) +// // insertRow(sheet, 15, 1);// 插入表格行数 +// XSSFRow row0 = sheet.getRow(1); +// setCellValue(row0, 11, row0.getCell(11).getStringCellValue() + controlPlanBean.getControlPlanNo()); +// XSSFRow row1 = sheet.getRow(3); +// setCellValue(row1, 0, controlPlanBean.getPartNumber()); +// setCellValue(row1, 6, +// connectPhoneAndPersion(controlPlanBean.getKeyPersion(), controlPlanBean.getKeyPhone())); +// setCellValue(row1, 12, controlPlanBean.getCreateDateStr()); +// setCellValue(row1, 14, controlPlanBean.getUpdateDateStr()); +// setCellValue(row1, 15, controlPlanBean.getChangeLev()); +// XSSFRow row2 = sheet.getRow(5); +// setCellValue(row2, 0, controlPlanBean.getCustromPartNumber()); +// setCellValue(row2, 7, controlPlanBean.getCoreTeam()); +// setCellValue(row2, 12, controlPlanBean.getCustromEngineeringApprovalDateStr()); +// +// XSSFRow row3 = sheet.getRow(7); +// setCellValue(row3, 0, controlPlanBean.getPartNameDesc()); +// setCellValue(row3, 7, controlPlanBean.getSupplierApprovalDateStr()); +// setCellValue(row3, 12, controlPlanBean.getCustromQuantyApprovalDateStr()); +// XSSFRow row4 = sheet.getRow(9); +// setCellValue(row4, 0, controlPlanBean.getSupplier()); +// setCellValue(row4, 3, controlPlanBean.getSupplierCode()); +// setCellValue(row4, 7, controlPlanBean.getOtherApprovalDateStr()); +// setCellValue(row4, 12, controlPlanBean.getOtherApprovalIfDateStr()); +// +// } else { +// return -1; +// } +// if (simpleBeanList == null) { +// return -1; +// } +// for (int i = 0; i < simpleBeanList.size(); i++) { +// TMomControlPlanSimpleBean bean = simpleBeanList.get(i); +// if (bean.getHbdyg() != null && !bean.getHbdyg().equals("")) { +// getCombineRow(bean.getHbdyg(), startRow); +// } +// XSSFRow row = null; +// Boolean isCreat = false; +// if ((i + startRow) > sheet.getLastRowNum()) { +// row = sheet.createRow(i + startRow); +// isCreat = true; +// } else { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } +// // 获取特殊字符所在位置 +// String[] columnNames = null; +// Map indexMap = new HashMap(); +// if (bean.getSpecial() != null && !bean.getSpecial().equals("")) { +// try { +// if (bean.getSpecial().indexOf("|") >= 0) { +// columnNames = bean.getSpecial().split("\\|"); +// } else { +// columnNames = new String[] { bean.getSpecial() }; +// } +// if (columnNames != null && columnNames.length > 0) { +// for (int i1 = 0; i1 < columnNames.length; i1++) { +// if (columnNames[i1].indexOf("-") >= 0) { +// String[] columnName = columnNames[i1].split("-"); +// // 通过列名称获取列 +// int cellindex = -1; +// if (columnName[0].indexOf(",") >= 0) { +// cellindex = getOneNamedCellIndex(wb, columnName[0].replaceAll(",", "")); +// } else if (columnName[0].indexOf("/") >= 0) { +// cellindex = getOneNamedCellIndex(wb, columnName[0].replaceAll("/", "")); +// } else { +// cellindex = getOneNamedCellIndex(wb, columnName[0]); +// } +// if (cellindex > -1) { +// indexMap.put(cellindex, Integer.parseInt(columnName[1])); +// } +// } +// } +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// } +// for (int cols = 0; cols <= 15; cols++) { +// XSSFCell cell = null; +// if (isCreat) { +// cell = row.createCell(cols); +// } else { +// cell = row.getCell(cols); +// } +// cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 +// +// switch (cols) { +// +// case 0: +// if (bean.getPartProcessNumber() != null && bean.getPartProcessNumber().indexOf("\n") >= 0 +// && bean.getPartProcessNumber().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getPartProcessNumber().split("\n")[1]); +// } else if (bean.getPartProcessNumber() != null && bean.getPartProcessNumber().indexOf("\n") >= 0 +// && bean.getPartProcessNumber().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getPartProcessNumber().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getPartProcessNumber(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getPartProcessNumber()); +// } +//// cell.setCellValue(bean.getPartProcessNumber()); +// break; +// case 1: +// if (bean.getProcessName() != null && bean.getProcessName().indexOf("\n") >= 0 +// && bean.getProcessName().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getProcessName().split("\n")[1]); +// } else if (bean.getProcessName() != null && bean.getProcessName().indexOf("\n") >= 0 +// && bean.getProcessName().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getProcessName().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProcessName(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProcessName()); +// } +//// cell.setCellValue(bean.getProcessName()); +// break; +// case 2: +// if (bean.getMachineDevice() != null && bean.getMachineDevice().indexOf("\n") >= 0 +// && bean.getMachineDevice().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getMachineDevice().split("\n")[1]); +// } else if (bean.getMachineDevice() != null && bean.getMachineDevice().indexOf("\n") >= 0 +// && bean.getMachineDevice().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getMachineDevice().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getMachineDevice(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getMachineDevice()); +// } +//// cell.setCellValue(bean.getMachineDevice()); +// break; +// case 3: +// if (bean.getSmjy() != null && bean.getSmjy().indexOf("\n") >= 0 +// && bean.getSmjy().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getSmjy().split("\n")[1]); +// } else if (bean.getSmjy() != null && bean.getSmjy().indexOf("\n") >= 0 +// && bean.getSmjy().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getSmjy().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSmjy(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSmjy()); +// } +//// cell.setCellValue(bean.getMachineDevice()); +// break; +// case 4: +// if (bean.getBubbledPrintNo() != null && bean.getBubbledPrintNo().indexOf("\n") >= 0 +// && bean.getBubbledPrintNo().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getBubbledPrintNo().split("\n")[1]); +// } else if (bean.getBubbledPrintNo() != null && bean.getBubbledPrintNo().indexOf("\n") >= 0 +// && bean.getBubbledPrintNo().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getBubbledPrintNo().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getBubbledPrintNo(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getBubbledPrintNo()); +// } +//// cell.setCellValue(bean.getBubbledPrintNo()); +// break; +// case 5: +// if (bean.getSize() != null && bean.getSize().indexOf("\n") >= 0 +// && bean.getSize().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getSize().split("\n")[1]); +// } else if (bean.getSize() != null && bean.getSize().indexOf("\n") >= 0 +// && bean.getSize().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getSize().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSize(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSize()); +// } +//// cell.setCellValue(bean.getSize()); +// break; +// case 6: +// if (bean.getNo() != null && bean.getNo().indexOf("\n") >= 0 && bean.getNo().split("\n").length == 2 +// && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getNo().split("\n")[1]); +// } else if (bean.getNo() != null && bean.getNo().indexOf("\n") >= 0 +// && bean.getNo().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getNo().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getNo(), indexMap.get(cols), indexMap.get(cols) + 1, 10, +// "Y14.5M")); +// } else { +// cell.setCellValue(bean.getNo()); +// } +//// cell.setCellValue(bean.getNo()); +// break; +// +// case 7: +// if (bean.getProduct() != null && bean.getProduct().indexOf("\n") >= 0 +// && bean.getProduct().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getProduct().split("\n")[1]); +// } else if (bean.getProduct() != null && bean.getProduct().indexOf("\n") >= 0 +// && bean.getProduct().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getProduct().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProduct(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProduct()); +// } +//// cell.setCellValue(bean.getProduct()); +// break; +// case 8: +// if (bean.getProcess() != null && bean.getProcess().indexOf("\n") >= 0 +// && bean.getProcess().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getProcess().split("\n")[1]); +// } else if (bean.getProcess() != null && bean.getProcess().indexOf("\n") >= 0 +// && bean.getProcess().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getProcess().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProcess(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProcess()); +// } +//// cell.setCellValue(bean.getProcess()); +// break; +// case 9: +// if (bean.getSpecialClass() != null && bean.getSpecialClass().indexOf("\n") >= 0 +// && bean.getSpecialClass().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getSpecialClass().split("\n")[1]); +// } else if (bean.getSpecialClass() != null && bean.getSpecialClass().indexOf("\n") >= 0 +// && bean.getSpecialClass().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getSpecialClass().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSpecialClass(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSpecialClass()); +// } +//// cell.setCellValue(bean.getSpecialClass()); +// break; +// case 10: +// if (bean.getConceal().equals("1")) { +// String processName = bean.getProcessName();// .split("\n")[1]; +// String productId = bean.getMeopId().split("_")[0]; +// StringBuffer value = new StringBuffer(); +// System.out.println(value.length()); +// if (type.indexOf("CHINESE") != -1) { +// String name = processName.split("\n")[0]; +// if (bean.getProcessName() != null && bean.getProcessName().indexOf("检验(") >= 0) { +// name = name.substring(3, name.length() - 1); +// } +// value.append("详见" + name + "作业指导书/" + productId); +// // cell.setCellValue("详见"+processName+"作业指导书/"+productId); +// } +// if (type.indexOf("ENGLISH") != -1) { +// String name = processName.split("\n")[1]; +// if (bean.getProcessName() != null && bean.getProcessName().indexOf("检验(") >= 0) { +// name = name.substring(8, name.length() - 1); +// } +// if (value.length() != 0) +// value.append("\n"); +// value.append("In " + name + " OP INS/" + productId); +// +// } +// cell.setCellValue(value.toString()); +// } else { +// if (bean.getProductProcessSpecificationTolerance() != null +// && bean.getProductProcessSpecificationTolerance().indexOf("\n") >= 0 +// && bean.getProductProcessSpecificationTolerance().split("\n").length == 2 +// && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getProductProcessSpecificationTolerance().split("\n")[1]); +// } else if (bean.getProductProcessSpecificationTolerance() != null +// && bean.getProductProcessSpecificationTolerance().indexOf("\n") >= 0 +// && bean.getProductProcessSpecificationTolerance().split("\n").length == 2 +// && type.equals("CHINESE")) { +// cell.setCellValue(bean.getProductProcessSpecificationTolerance().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProductProcessSpecificationTolerance(), +// indexMap.get(cols), indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProductProcessSpecificationTolerance()); +// } +// } +//// if (bean.getUpProductProcessSpecificationTolerance() == null) { +//// cell.setCellValue(""); +//// } else if (!bean +//// .getUpProductProcessSpecificationTolerance().trim() +//// .isEmpty() +//// && !bean.getDownProductProcessSpecificationTolerance() +//// .trim().isEmpty()) +//// cell.setCellValue(bean +//// .getProductProcessSpecificationTolerance() +//// + " " +//// + bean.getUpProductProcessSpecificationTolerance() +//// + "/" +//// + bean.getDownProductProcessSpecificationTolerance()); +//// else { +//// cell.setCellValue(bean +//// .getProductProcessSpecificationTolerance()); +//// } +// break; +// case 11: +// if (bean.getEvaluationMeasurementTechnique() != null +// && bean.getEvaluationMeasurementTechnique().indexOf("\n") >= 0 +// && bean.getEvaluationMeasurementTechnique().split("\n").length == 2 +// && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getEvaluationMeasurementTechnique().split("\n")[1]); +// } else if (bean.getEvaluationMeasurementTechnique() != null +// && bean.getEvaluationMeasurementTechnique().indexOf("\n") >= 0 +// && bean.getEvaluationMeasurementTechnique().split("\n").length == 2 +// && type.equals("CHINESE")) { +// cell.setCellValue(bean.getEvaluationMeasurementTechnique().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getEvaluationMeasurementTechnique(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getEvaluationMeasurementTechnique()); +// } +// break; +// case 12: +// if (bean.getSampleSize() != null && bean.getSampleSize().indexOf("\n") >= 0 +// && bean.getSampleSize().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getSampleSize().split("\n")[1]); +// } else if (bean.getSampleSize() != null && bean.getSampleSize().indexOf("\n") >= 0 +// && bean.getSampleSize().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getSampleSize().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSampleSize(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSampleSize()); +// } +// break; +// case 13: +// if (bean.getSampleFreq() != null && bean.getSampleFreq().indexOf("\n") >= 0 +// && bean.getSampleFreq().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getSampleFreq().split("\n")[1]); +// } else if (bean.getSampleFreq() != null && bean.getSampleFreq().indexOf("\n") >= 0 +// && bean.getSampleFreq().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getSampleFreq().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSampleFreq(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSampleFreq()); +// } +// break; +// +// case 14: +// if (bean.getControlMethod() != null && bean.getControlMethod().indexOf("\n") >= 0 +// && bean.getControlMethod().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getControlMethod().split("\n")[1]); +// } else if (bean.getControlMethod() != null && bean.getControlMethod().indexOf("\n") >= 0 +// && bean.getControlMethod().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getControlMethod().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getControlMethod(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getControlMethod()); +// } +// break; +// +// case 15: +// if (bean.getReactionPlan() != null && bean.getReactionPlan().indexOf("\n") >= 0 +// && bean.getReactionPlan().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getReactionPlan().split("\n")[1]); +// } else if (bean.getReactionPlan() != null && bean.getReactionPlan().indexOf("\n") >= 0 +// && bean.getReactionPlan().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getReactionPlan().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getReactionPlan(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getReactionPlan()); +// } +// break; +// +// default: +// break; +// +// } +// } +// } +// if (map != null && map.size() != 0) { +// Iterator> it = map.entrySet().iterator(); +// while (it.hasNext()) { +// Map.Entry entry = it.next(); +// List columnIndex = new ArrayList(); +// for (int i = 0; i < entry.getValue().length; i++) { +// if (entry.getValue()[i] == 3 || (entry.getValue()[i] >= 18 && entry.getValue()[i] <= 20) +// || entry.getValue()[i] == 14 || entry.getValue()[i] == 16) { +// continue; +// } else if (entry.getValue()[i] >= 4 && entry.getValue()[i] <= 13) { +// columnIndex.add(entry.getValue()[i] - 1); +// } else if (entry.getValue()[i] == 15) { +// columnIndex.add(entry.getValue()[i] - 2); +// } else if (entry.getValue()[i] == 17) { +// columnIndex.add(entry.getValue()[i] - 3); +// } else { +// columnIndex.add(entry.getValue()[i]); +// } +// } +// int[] column = new int[columnIndex.size()]; +// for (int i = 0; i < columnIndex.size(); i++) { +// column[i] = columnIndex.get(i); +// } +// if (column.length > 0) { +// combine(sheet, entry.getKey(), column); +// } +// } +// } +// wb.write(output); +// output.close(); +// input.close(); +// System.out.println("-------WRITE EXCEL OVER-------"); +// +// return 0; +// } +// +// /** +// * 博格华纳英文表头--输出控制计划到EXCEL表格中 +// * +// * @param controlPlanBean 控制计划信息 +// * @param input 模版文件流 +// * @param outputFilePath 需要输出的全路径 +// * @throws IOException +// */ +// public static int writeBogehuanaControlPlanToExcel2(TMomControlPlanBean controlPlanBean, InputStream input, +// String outputFilePath) throws IOException { +// +// FileOutputStream output = new FileOutputStream(new File(outputFilePath)); // +// XSSFWorkbook wb = new XSSFWorkbook(input);// ( +// XSSFSheet sheet = wb.getSheetAt(0); +// int startRow = 13; +// map.clear(); +// List simpleBeanList = null; +// if (controlPlanBean != null) { +// // 添加单属性信息到excel表中 +// simpleBeanList = controlPlanBean.getSimpleBeanList(); +// +// // for (int i = 0; i < (simpleBeanList.size()); i++) +// // insertRow(sheet, 14, 1);// 插入表格行数 +// XSSFRow row1 = sheet.getRow(3); +// setCellValue(row1, 0, row1.getCell(0).getStringCellValue() + controlPlanBean.getControlPlanNo()); +// setCellValue(row1, 5, +// connectPhoneAndPersion(controlPlanBean.getKeyPersion(), controlPlanBean.getKeyPhone())); +// setCellValue(row1, 9, controlPlanBean.getCreateDateStr()); +// setCellValue(row1, 12, controlPlanBean.getUpdateDateStr()); +// XSSFRow row2 = sheet.getRow(5); +// setCellValue(row2, 0, controlPlanBean.getPartNumber()); +// +// setCellValue(row2, 5, controlPlanBean.getCoreTeam()); +// setCellValue(row2, 9, controlPlanBean.getCustromEngineeringApprovalDateStr()); +// +// XSSFRow row3 = sheet.getRow(7); +// setCellValue(row3, 0, controlPlanBean.getPartNameDesc()); +// setCellValue(row3, 5, controlPlanBean.getSupplierApprovalDateStr()); +// setCellValue(row3, 9, controlPlanBean.getCustromQuantyApprovalDateStr()); +// +// XSSFRow row4 = sheet.getRow(9); +// setCellValue(row4, 0, controlPlanBean.getSupplier()); +// setCellValue(row4, 3, controlPlanBean.getSupplierCode()); +// setCellValue(row4, 5, controlPlanBean.getOtherApprovalDateStr()); +// setCellValue(row4, 9, controlPlanBean.getOtherApprovalIfDateStr()); +// +// } else { +// return -1; +// } +// if (simpleBeanList == null) { +// return -1; +// } +// for (int i = 0; i < simpleBeanList.size(); i++) { +// TMomControlPlanSimpleBean bean = simpleBeanList.get(i); +// if (bean.getHbdyg() != null && !bean.getHbdyg().equals("")) { +// getCombineRow(bean.getHbdyg(), startRow); +// } +// XSSFRow row = null; +// Boolean isCreat = false; +// System.out.println("row = " + (i + startRow)); +// if ((i + startRow) > sheet.getLastRowNum()) { +// row = sheet.createRow(i + startRow); +// isCreat = true; +// } else { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } +// // 获取特殊字符所在位置 +// String[] columnNames = null; +// Map indexMap = new HashMap(); +// if (bean.getSpecial() != null && !bean.getSpecial().equals("")) { +// try { +// if (bean.getSpecial().indexOf("|") >= 0) { +// columnNames = bean.getSpecial().split("\\|"); +// } else { +// columnNames = new String[] { bean.getSpecial() }; +// } +// if (columnNames != null && columnNames.length > 0) { +// for (int i1 = 0; i1 < columnNames.length; i1++) { +// if (columnNames[i1].indexOf("-") >= 0) { +// String[] columnName = columnNames[i1].split("-"); +// // 通过列名称获取列 +// int cellindex = -1; +// if (columnName[0].indexOf(",") >= 0) { +// cellindex = getOneNamedCellIndex(wb, columnName[0].replaceAll(",", "")); +// } else if (columnName[0].indexOf("/") >= 0) { +// cellindex = getOneNamedCellIndex(wb, columnName[0].replaceAll("/", "")); +// } else { +// cellindex = getOneNamedCellIndex(wb, columnName[0]); +// } +// if (cellindex > -1) { +// indexMap.put(cellindex, Integer.parseInt(columnName[1])); +// } +// } +// } +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// } +// for (int cols = 0; cols < 13; cols++) { +// XSSFCell cell = null; +// if (isCreat) { +// cell = row.createCell(cols); +// } else { +// cell = row.getCell(cols); +// } +// if (cell == null) +// cell = row.getCell(cols); +// cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 +// +// switch (cols) { +// +// case 0: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getPartProcessNumber(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getPartProcessNumber()); +// } +// break; +// case 1: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProcessName(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProcessName()); +// } +// break; +// case 2: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getMachineDevice(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getMachineDevice()); +// } +// break; +// case 3: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getNo(), indexMap.get(cols), indexMap.get(cols) + 1, 10, +// "Y14.5M")); +// } else { +// cell.setCellValue(bean.getNo()); +// } +// break; +// case 4: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProduct(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProduct()); +// } +// break; +// case 5: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProcess(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProcess()); +// } +// break; +// case 6: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSpecialClass(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSpecialClass()); +// } +// break; +// case 7: +// if (bean.getConceal().equals("1")) { +// String processName = bean.getProcessName(); +// if (bean.getProcessName() != null && bean.getProcessName().indexOf("检验(") >= 0) { +// processName = bean.getProcessName().substring(3, +// bean.getProcessName().toString().length() - 1); +// } +// cell.setCellValue("详见" + processName + "作业指导书"); +// } else { +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProductProcessSpecificationTolerance(), +// indexMap.get(cols), indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProductProcessSpecificationTolerance()); +// } +// } +//// if (bean.getUpProductProcessSpecificationTolerance() == null) { +//// sheet.addMergedRegion(new CellRangeAddress( +//// i + startRow, i + startRow + 1, 7, 8)); +//// cell.setCellValue(bean +//// .getProductProcessSpecificationTolerance()); +//// } else if (!bean +//// .getUpProductProcessSpecificationTolerance().trim() +//// .isEmpty() +//// && !bean.getDownProductProcessSpecificationTolerance() +//// .trim().isEmpty()) { +//// +//// sheet.addMergedRegion(new CellRangeAddress( +//// i + startRow, i + startRow + 1, 7, 7)); +//// cell.setCellValue(bean +//// .getProductProcessSpecificationTolerance()); +//// row.getCell(8) +//// .setCellValue( +//// bean.getUpProductProcessSpecificationTolerance()); +//// XSSFRow rowNext = sheet.getRow(i + 1 + startRow); +//// rowNext.getCell(8) +//// .setCellValue( +//// bean.getDownProductProcessSpecificationTolerance()); +//// } else { +//// sheet.addMergedRegion(new CellRangeAddress( +//// i + startRow, i + startRow + 1, 7, 8)); +//// cell.setCellValue(bean +//// .getProductProcessSpecificationTolerance()); +//// } +// break; +// case 8: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getEvaluationMeasurementTechnique(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getEvaluationMeasurementTechnique()); +// } +// break; +// case 9: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSampleSize(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSampleSize()); +// } +// break; +// case 10: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSampleFreq(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSampleFreq()); +// } +// break; +// +// case 11: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getControlMethod(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getControlMethod()); +// } +// break; +// +// case 12: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getReactionPlan(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getReactionPlan()); +// } +// break; +// +// default: +// break; +// +// } +// } +// } +// if (map != null && map.size() != 0) { +// Iterator> it = map.entrySet().iterator(); +// while (it.hasNext()) { +// Map.Entry entry = it.next(); +// List columnIndex = new ArrayList(); +// for (int i = 0; i < entry.getValue().length; i++) { +// if (entry.getValue()[i] == 3 || entry.getValue()[i] == 5 || entry.getValue()[i] == 6 +// || (entry.getValue()[i] >= 18 && entry.getValue()[i] <= 20) || entry.getValue()[i] == 14 +// || entry.getValue()[i] == 16) { +// continue; +// } else if (entry.getValue()[i] == 4) { +// columnIndex.add(entry.getValue()[i] - 1); +// } else if (entry.getValue()[i] >= 7 && entry.getValue()[i] <= 13) { +// columnIndex.add(entry.getValue()[i] - 3); +// } else if (entry.getValue()[i] == 15) { +// columnIndex.add(entry.getValue()[i] - 4); +// } else if (entry.getValue()[i] == 17) { +// columnIndex.add(entry.getValue()[i] - 5); +// } else { +// columnIndex.add(entry.getValue()[i]); +// } +// } +// int[] column = new int[columnIndex.size()]; +// for (int i = 0; i < columnIndex.size(); i++) { +// column[i] = columnIndex.get(i); +// } +// if (column.length > 0) { +// combine(sheet, entry.getKey(), column); +// } +// } +// } +// wb.write(output); +// output.close(); +// input.close(); +// System.out.println("-------WRITE EXCEL OVER-------"); +// +// return 0; +// } + + /** + * 博格华纳--输出控制计划到EXCEL表格中 + * + * @param controlPlanBean 控制计划信息 + * @param input 模版文件流 + * @param outputFilePath 需要输出的全路径 + * @throws IOException + */ +// public static int writeBogehuanaControlPlanToExcel(TMomControlPlanBean controlPlanBean, InputStream input, +// String outputFilePath, String type) throws IOException { +// +// FileOutputStream output = new FileOutputStream(new File(outputFilePath)); // +// XSSFWorkbook wb = new XSSFWorkbook(input);// ( +// XSSFSheet sheet = wb.getSheetAt(0); +// int startRow = 13; +// map.clear(); +// List simpleBeanList = null; +// if (controlPlanBean != null) { +// // 添加单属性信息到excel表中 +// simpleBeanList = controlPlanBean.getSimpleBeanList(); +// +// // for (int i = 0; i < (simpleBeanList.size()); i++) +// // insertRow(sheet, 14, 1);// 插入表格行数 +// XSSFRow row1 = sheet.getRow(3); +// setCellValue(row1, 0, row1.getCell(0).getStringCellValue() + controlPlanBean.getControlPlanNo()); +// setCellValue(row1, 6, +// connectPhoneAndPersion(controlPlanBean.getKeyPersion(), controlPlanBean.getKeyPhone())); +// setCellValue(row1, 10, controlPlanBean.getCreateDateStr()); +// setCellValue(row1, 12, controlPlanBean.getUpdateDateStr()); +// XSSFRow row2 = sheet.getRow(5); +// setCellValue(row2, 0, controlPlanBean.getCustromPartNumber()); +// +// setCellValue(row2, 6, controlPlanBean.getCoreTeam()); +// setCellValue(row2, 10, controlPlanBean.getCustromEngineeringApprovalDateStr()); +// +// XSSFRow row3 = sheet.getRow(7); +// setCellValue(row3, 0, controlPlanBean.getPartNameDesc()); +// setCellValue(row3, 6, controlPlanBean.getSupplierApprovalDateStr()); +// setCellValue(row3, 10, controlPlanBean.getCustromQuantyApprovalDateStr()); +// +// XSSFRow row4 = sheet.getRow(9); +// setCellValue(row4, 0, controlPlanBean.getSupplier()); +// setCellValue(row4, 4, controlPlanBean.getSupplierCode()); +// setCellValue(row4, 6, controlPlanBean.getOtherApprovalDateStr()); +// setCellValue(row4, 10, controlPlanBean.getOtherApprovalIfDateStr()); +// +// } else { +// return -1; +// } +// if (simpleBeanList == null) { +// return -1; +// } +// for (int i = 0; i < simpleBeanList.size(); i++) { +// TMomControlPlanSimpleBean bean = simpleBeanList.get(i); +// if (bean.getHbdyg() != null && !bean.getHbdyg().equals("")) { +// getCombineRow(bean.getHbdyg(), startRow); +// } +// XSSFRow row = null; +// Boolean isCreat = false; +// System.out.println("row = " + (i + startRow)); +// if ((i + startRow) > sheet.getLastRowNum()) { +// row = sheet.createRow(i + startRow); +// isCreat = true; +// } else { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } +// // 获取特殊字符所在位置 +// String[] columnNames = null; +// Map indexMap = new HashMap(); +// if (bean.getSpecial() != null && !bean.getSpecial().equals("")) { +// try { +// if (bean.getSpecial().indexOf("|") >= 0) { +// columnNames = bean.getSpecial().split("\\|"); +// } else { +// columnNames = new String[] { bean.getSpecial() }; +// } +// if (columnNames != null && columnNames.length > 0) { +// for (int i1 = 0; i1 < columnNames.length; i1++) { +// if (columnNames[i1].indexOf("-") >= 0) { +// String[] columnName = columnNames[i1].split("-"); +// // 通过列名称获取列 +// int cellindex = -1; +// if (columnName[0].indexOf(",") >= 0) { +// cellindex = getOneNamedCellIndex(wb, columnName[0].replaceAll(",", "")); +// } else if (columnName[0].indexOf("/") >= 0) { +// cellindex = getOneNamedCellIndex(wb, columnName[0].replaceAll("/", "")); +// } else { +// cellindex = getOneNamedCellIndex(wb, columnName[0]); +// } +// if (cellindex > -1) { +// indexMap.put(cellindex, Integer.parseInt(columnName[1])); +// } +// } +// } +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// } +// for (int cols = 0; cols <= 13; cols++) { +// XSSFCell cell = null; +// if (isCreat) { +// cell = row.createCell(cols); +// } else { +// cell = row.getCell(cols); +// } +// if (cell == null) +// cell = row.getCell(cols); +// cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 +// +// switch (cols) { +// +// case 0: +// if (bean.getPartProcessNumber() != null && bean.getPartProcessNumber().indexOf("\n") >= 0 +// && bean.getPartProcessNumber().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getPartProcessNumber().split("\n")[1]); +// } else if (bean.getPartProcessNumber() != null && bean.getPartProcessNumber().indexOf("\n") >= 0 +// && bean.getPartProcessNumber().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getPartProcessNumber().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getPartProcessNumber(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getPartProcessNumber()); +// } +// break; +// case 1: +// if (bean.getProcessName() != null && bean.getProcessName().indexOf("\n") >= 0 +// && bean.getProcessName().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getProcessName().split("\n")[1]); +// } else if (bean.getProcessName() != null && bean.getProcessName().indexOf("\n") >= 0 +// && bean.getProcessName().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getProcessName().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProcessName(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProcessName()); +// } +// break; +// case 2: +// if (bean.getMachineDevice() != null && bean.getMachineDevice().indexOf("\n") >= 0 +// && bean.getMachineDevice().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getMachineDevice().split("\n")[1]); +// } else if (bean.getMachineDevice() != null && bean.getMachineDevice().indexOf("\n") >= 0 +// && bean.getMachineDevice().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getMachineDevice().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getMachineDevice(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getMachineDevice()); +// } +// break; +// case 3: +// if (bean.getSmjy() != null && bean.getSmjy().indexOf("\n") >= 0 +// && bean.getSmjy().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getSmjy().split("\n")[1]); +// } else if (bean.getSmjy() != null && bean.getSmjy().indexOf("\n") >= 0 +// && bean.getSmjy().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getSmjy().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSmjy(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSmjy()); +// } +// break; +// case 4: +// if (bean.getBubbledPrintNo() != null && bean.getBubbledPrintNo().indexOf("\n") >= 0 +// && bean.getBubbledPrintNo().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getBubbledPrintNo().split("\n")[1]); +// } else if (bean.getBubbledPrintNo() != null && bean.getBubbledPrintNo().indexOf("\n") >= 0 +// && bean.getBubbledPrintNo().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getBubbledPrintNo().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getBubbledPrintNo(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getBubbledPrintNo()); +// } +// break; +// case 5: +// if (bean.getProduct() != null && bean.getProduct().indexOf("\n") >= 0 +// && bean.getProduct().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getProduct().split("\n")[1]); +// } else if (bean.getProduct() != null && bean.getProduct().indexOf("\n") >= 0 +// && bean.getProduct().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getProduct().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProduct(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProduct()); +// } +// break; +// case 6: +// if (bean.getProcess() != null && bean.getProcess().indexOf("\n") >= 0 +// && bean.getProcess().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getProcess().split("\n")[1]); +// } else if (bean.getProcess() != null && bean.getProcess().indexOf("\n") >= 0 +// && bean.getProcess().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getProcess().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProcess(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProcess()); +// } +// break; +// case 7: +// if (bean.getSpecialClass() != null && bean.getSpecialClass().indexOf("\n") >= 0 +// && bean.getSpecialClass().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getSpecialClass().split("\n")[1]); +// } else if (bean.getSpecialClass() != null && bean.getSpecialClass().indexOf("\n") >= 0 +// && bean.getSpecialClass().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getSpecialClass().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSpecialClass(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSpecialClass()); +// } +// break; +// case 8: +// if (bean.getConceal().equals("1")) { +// String processName = bean.getProcessName();// .split("\n")[1]; +// String productId = bean.getMeopId().split("_")[0]; +// StringBuffer value = new StringBuffer(); +// System.out.println(value.length()); +// if (type.indexOf("CHINESE") != -1) { +// String name = processName.split("\n")[0]; +// if (bean.getProcessName() != null && bean.getProcessName().indexOf("检验(") >= 0) { +// name = name.substring(3, name.length() - 1); +// } +// value.append("详见" + name + "作业指导书/" + productId); +// // cell.setCellValue("详见"+processName+"作业指导书/"+productId); +// } +// if (type.indexOf("ENGLISH") != -1) { +// String name = processName.split("\n")[1]; +// if (bean.getProcessName() != null && bean.getProcessName().indexOf("检验(") >= 0) { +// name = name.substring(8, name.length() - 1); +// } +// if (value.length() != 0) +// value.append("\n"); +// value.append("In " + name + " OP INS/" + productId); +// +// } +// cell.setCellValue(value.toString()); +// } else { +// if (bean.getProductProcessSpecificationTolerance() != null +// && bean.getProductProcessSpecificationTolerance().indexOf("\n") >= 0 +// && bean.getProductProcessSpecificationTolerance().split("\n").length == 2 +// && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getProductProcessSpecificationTolerance().split("\n")[1]); +// } else if (bean.getProductProcessSpecificationTolerance() != null +// && bean.getProductProcessSpecificationTolerance().indexOf("\n") >= 0 +// && bean.getProductProcessSpecificationTolerance().split("\n").length == 2 +// && type.equals("CHINESE")) { +// cell.setCellValue(bean.getProductProcessSpecificationTolerance().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProductProcessSpecificationTolerance(), +// indexMap.get(cols), indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProductProcessSpecificationTolerance()); +// } +// } +// break; +// case 9: +// if (bean.getEvaluationMeasurementTechnique() != null +// && bean.getEvaluationMeasurementTechnique().indexOf("\n") >= 0 +// && bean.getEvaluationMeasurementTechnique().split("\n").length == 2 +// && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getEvaluationMeasurementTechnique().split("\n")[1]); +// } else if (bean.getEvaluationMeasurementTechnique() != null +// && bean.getEvaluationMeasurementTechnique().indexOf("\n") >= 0 +// && bean.getEvaluationMeasurementTechnique().split("\n").length == 2 +// && type.equals("CHINESE")) { +// cell.setCellValue(bean.getEvaluationMeasurementTechnique().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getEvaluationMeasurementTechnique(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getEvaluationMeasurementTechnique()); +// } +// break; +// case 10: +// if (bean.getSampleSize() != null && bean.getSampleSize().indexOf("\n") >= 0 +// && bean.getSampleSize().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getSampleSize().split("\n")[1]); +// } else if (bean.getSampleSize() != null && bean.getSampleSize().indexOf("\n") >= 0 +// && bean.getSampleSize().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getSampleSize().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSampleSize(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSampleSize()); +// } +// break; +// case 11: +// if (bean.getSampleFreq() != null && bean.getSampleFreq().indexOf("\n") >= 0 +// && bean.getSampleFreq().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getSampleFreq().split("\n")[1]); +// } else if (bean.getSampleFreq() != null && bean.getSampleFreq().indexOf("\n") >= 0 +// && bean.getSampleFreq().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getSampleFreq().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSampleFreq(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSampleFreq()); +// } +// break; +// +// case 12: +// if (bean.getControlMethod() != null && bean.getControlMethod().indexOf("\n") >= 0 +// && bean.getControlMethod().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getControlMethod().split("\n")[1]); +// } else if (bean.getControlMethod() != null && bean.getControlMethod().indexOf("\n") >= 0 +// && bean.getControlMethod().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getControlMethod().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getControlMethod(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getControlMethod()); +// } +// break; +// +// case 13: +// if (bean.getReactionPlan() != null && bean.getReactionPlan().indexOf("\n") >= 0 +// && bean.getReactionPlan().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getReactionPlan().split("\n")[1]); +// } else if (bean.getReactionPlan() != null && bean.getReactionPlan().indexOf("\n") >= 0 +// && bean.getReactionPlan().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getReactionPlan().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getReactionPlan(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getReactionPlan()); +// } +// break; +// +// default: +// break; +// +// } +// } +// } +// if (map != null && map.size() != 0) { +// Iterator> it = map.entrySet().iterator(); +// while (it.hasNext()) { +// Map.Entry entry = it.next(); +// List columnIndex = new ArrayList(); +// for (int i = 0; i < entry.getValue().length; i++) { +// if (entry.getValue()[i] == 6 || entry.getValue()[i] == 7 +// || (entry.getValue()[i] >= 17 && entry.getValue()[i] <= 20) || entry.getValue()[i] == 15) { +// continue; +// } else if (entry.getValue()[i] == 4) { +// columnIndex.add(entry.getValue()[i] - 1); +// } else if (entry.getValue()[i] >= 8 && entry.getValue()[i] <= 14) { +// columnIndex.add(entry.getValue()[i] - 2); +// } else if (entry.getValue()[i] == 16) { +// columnIndex.add(entry.getValue()[i] - 3); +// } else if (entry.getValue()[i] == 18) { +// columnIndex.add(entry.getValue()[i] - 4); +// } else { +// columnIndex.add(entry.getValue()[i]); +// } +// } +// int[] column = new int[columnIndex.size()]; +// for (int i = 0; i < columnIndex.size(); i++) { +// column[i] = columnIndex.get(i); +// } +// if (column.length > 0) { +// combine(sheet, entry.getKey(), column); +// } +// } +// } +// wb.write(output); +// output.close(); +// input.close(); +// System.out.println("-------WRITE EXCEL OVER-------"); +// +// return 0; +// } +// +// /** +// * 东睦英文表头--输出控制计划到EXCEL表格中 +// * +// * @param controlPlanBean 控制计划信息 +// * @param input 模版文件流 +// * @param outputFilePath 需要输出的全路径 +// * @throws IOException +// */ +// public static int writeNBTMControlPlanToExcel(TMomControlPlanBean controlPlanBean, InputStream input, +// String outputFilePath, String type) throws IOException { +// +// FileOutputStream output = new FileOutputStream(new File(outputFilePath)); // +// XSSFWorkbook wb = new XSSFWorkbook(input);// ( +// XSSFSheet sheet = wb.getSheetAt(0); +// int startRow = 13; +// map.clear(); +// List simpleBeanList = null; +// if (controlPlanBean != null) { +// // 添加单属性信息到excel表中 +// simpleBeanList = controlPlanBean.getSimpleBeanList(); +// +// // for (int i = 0; i < (simpleBeanList.size()); i++) +// // insertRow(sheet, 14, 1);// 插入表格行数 +// XSSFRow row1 = sheet.getRow(3); +// setCellValue(row1, 0, row1.getCell(0).getStringCellValue() + controlPlanBean.getControlPlanNo()); +// setCellValue(row1, 5, +// connectPhoneAndPersion(controlPlanBean.getKeyPersion(), controlPlanBean.getKeyPhone())); +// setCellValue(row1, 10, controlPlanBean.getCreateDateStr()); +// setCellValue(row1, 12, controlPlanBean.getUpdateDateStr()); +// XSSFRow row2 = sheet.getRow(5); +// setCellValue(row2, 0, controlPlanBean.getPartNumber()); +// +// setCellValue(row2, 6, controlPlanBean.getCoreTeam()); +// setCellValue(row2, 10, controlPlanBean.getCustromEngineeringApprovalDateStr()); +// +// XSSFRow row3 = sheet.getRow(7); +// setCellValue(row3, 0, controlPlanBean.getPartNameDesc()); +// setCellValue(row3, 6, controlPlanBean.getSupplierApprovalDateStr()); +// setCellValue(row3, 10, controlPlanBean.getCustromQuantyApprovalDateStr()); +// +// XSSFRow row4 = sheet.getRow(9); +// setCellValue(row4, 0, controlPlanBean.getSupplier()); +// setCellValue(row4, 3, controlPlanBean.getSupplierCode()); +// setCellValue(row4, 6, controlPlanBean.getOtherApprovalDateStr()); +// setCellValue(row4, 10, controlPlanBean.getOtherApprovalIfDateStr()); +// +// } else { +// return -1; +// } +// if (simpleBeanList == null) { +// return -1; +// } +// for (int i = 0; i < simpleBeanList.size(); i++) { +// TMomControlPlanSimpleBean bean = simpleBeanList.get(i); +// if (bean.getHbdyg() != null && !bean.getHbdyg().equals("")) { +// getCombineRow(bean.getHbdyg(), startRow); +// } +// XSSFRow row = null; +// Boolean isCreat = false; +// System.out.println("row = " + (i + startRow)); +// if ((i + startRow) > sheet.getLastRowNum()) { +// row = sheet.createRow(i + startRow); +// isCreat = true; +// } else { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } +// // 获取特殊字符所在位置 +// String[] columnNames = null; +// Map indexMap = new HashMap(); +// if (bean.getSpecial() != null && !bean.getSpecial().equals("")) { +// try { +// if (bean.getSpecial().indexOf("|") >= 0) { +// columnNames = bean.getSpecial().split("\\|"); +// } else { +// columnNames = new String[] { bean.getSpecial() }; +// } +// if (columnNames != null && columnNames.length > 0) { +// for (int i1 = 0; i1 < columnNames.length; i1++) { +// if (columnNames[i1].indexOf("-") >= 0) { +// String[] columnName = columnNames[i1].split("-"); +// // 通过列名称获取列 +// int cellindex = -1; +// if (columnName[0].indexOf(",") >= 0) { +// cellindex = getOneNamedCellIndex(wb, columnName[0].replaceAll(",", "")); +// } else if (columnName[0].indexOf("/") >= 0) { +// cellindex = getOneNamedCellIndex(wb, columnName[0].replaceAll("/", "")); +// } else { +// cellindex = getOneNamedCellIndex(wb, columnName[0]); +// } +// if (cellindex > -1) { +// indexMap.put(cellindex, Integer.parseInt(columnName[1])); +// } +// } +// } +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// } +// for (int cols = 0; cols <= 13; cols++) { +// XSSFCell cell = null; +// if (isCreat) { +// cell = row.createCell(cols); +// } else { +// cell = row.getCell(cols); +// } +// if (cell == null) +// cell = row.getCell(cols); +// cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 +// +// switch (cols) { +// +// case 0: +// // 通过 type.equals("ENGLISH") 来判断中英文显示 +// if (bean.getPartProcessNumber() != null && bean.getPartProcessNumber().indexOf("\n") >= 0 +// && bean.getPartProcessNumber().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getPartProcessNumber().split("\n")[1]);// 英文显示 +// } else if (bean.getPartProcessNumber() != null && bean.getPartProcessNumber().indexOf("\n") >= 0 +// && bean.getPartProcessNumber().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getPartProcessNumber().split("\n")[0]); // 中文显示 +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getPartProcessNumber(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getPartProcessNumber()); // 中英文都显示 +// } +// break; +// case 1: +// if (bean.getProcessName() != null && bean.getProcessName().indexOf("\n") >= 0 +// && bean.getProcessName().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getProcessName().split("\n")[1]); +// } else if (bean.getProcessName() != null && bean.getProcessName().indexOf("\n") >= 0 +// && bean.getProcessName().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getProcessName().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProcessName(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProcessName()); +// } +// break; +// case 2: +// if (bean.getMachineDevice() != null && bean.getMachineDevice().indexOf("\n") >= 0 +// && bean.getMachineDevice().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getMachineDevice().split("\n")[1]); +// } else if (bean.getMachineDevice() != null && bean.getMachineDevice().indexOf("\n") >= 0 +// && bean.getMachineDevice().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getMachineDevice().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getMachineDevice(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getMachineDevice()); +// } +// break; +// case 3: +// if (bean.getSmjy() != null && bean.getSmjy().indexOf("\n") >= 0 +// && bean.getSmjy().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getSmjy().split("\n")[1]); +// } else if (bean.getSmjy() != null && bean.getSmjy().indexOf("\n") >= 0 +// && bean.getSmjy().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getSmjy().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSmjy(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSmjy()); +// } +// break; +// case 4: +// if (bean.getBubbledPrintNo() != null && bean.getBubbledPrintNo().indexOf("\n") >= 0 +// && bean.getBubbledPrintNo().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getBubbledPrintNo().split("\n")[1]); +// } else if (bean.getBubbledPrintNo() != null && bean.getBubbledPrintNo().indexOf("\n") >= 0 +// && bean.getBubbledPrintNo().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getBubbledPrintNo().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getBubbledPrintNo(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getBubbledPrintNo()); +// } +// break; +// case 5: +// if (bean.getProduct() != null && bean.getProduct().indexOf("\n") >= 0 +// && bean.getProduct().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getProduct().split("\n")[1]); +// } else if (bean.getProduct() != null && bean.getProduct().indexOf("\n") >= 0 +// && bean.getProduct().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getProduct().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProduct(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProduct()); +// } +// break; +// case 6: +// if (bean.getProcess() != null && bean.getProcess().indexOf("\n") >= 0 +// && bean.getProcess().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getProcess().split("\n")[1]); +// } else if (bean.getProcess() != null && bean.getProcess().indexOf("\n") >= 0 +// && bean.getProcess().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getProcess().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProcess(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProcess()); +// } +// break; +// case 7: +// if (bean.getSpecialClass() != null && bean.getSpecialClass().indexOf("\n") >= 0 +// && bean.getSpecialClass().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getSpecialClass().split("\n")[1]); +// } else if (bean.getSpecialClass() != null && bean.getSpecialClass().indexOf("\n") >= 0 +// && bean.getSpecialClass().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getSpecialClass().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSpecialClass(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSpecialClass()); +// } +// break; +// case 8: +// if (bean.getConceal().equals("1")) { +// String processName = bean.getProcessName();// .split("\n")[1]; +// String productId = bean.getMeopId().split("_")[0]; +// StringBuffer value = new StringBuffer(); +// System.out.println(value.length()); +// if (type.indexOf("CHINESE") != -1) { +// String name = processName.split("\n")[0]; +// if (bean.getProcessName() != null && bean.getProcessName().indexOf("检验(") >= 0) { +// name = name.substring(3, name.length() - 1); +// } +// value.append("详见" + name + "作业指导书/" + productId); +// // cell.setCellValue("详见"+processName+"作业指导书/"+productId); +// } +// if (type.indexOf("ENGLISH") != -1) { +// String name = processName.split("\n")[1]; +// if (bean.getProcessName() != null && bean.getProcessName().indexOf("检验(") >= 0) { +// name = name.substring(8, name.length() - 1); +// } +// if (value.length() != 0) +// value.append("\n"); +// value.append("In " + name + " OP INS/" + productId); +// +// } +// cell.setCellValue(value.toString()); +// } else { +// if (bean.getProductProcessSpecificationTolerance() != null +// && bean.getProductProcessSpecificationTolerance().indexOf("\n") >= 0 +// && bean.getProductProcessSpecificationTolerance().split("\n").length == 2 +// && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getProductProcessSpecificationTolerance().split("\n")[1]); +// } else if (bean.getProductProcessSpecificationTolerance() != null +// && bean.getProductProcessSpecificationTolerance().indexOf("\n") >= 0 +// && bean.getProductProcessSpecificationTolerance().split("\n").length == 2 +// && type.equals("CHINESE")) { +// cell.setCellValue(bean.getProductProcessSpecificationTolerance().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProductProcessSpecificationTolerance(), +// indexMap.get(cols), indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProductProcessSpecificationTolerance()); +// } +// } +// break; +// case 9: +// if (bean.getEvaluationMeasurementTechnique() != null +// && bean.getEvaluationMeasurementTechnique().indexOf("\n") >= 0 +// && bean.getEvaluationMeasurementTechnique().split("\n").length == 2 +// && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getEvaluationMeasurementTechnique().split("\n")[1]); +// } else if (bean.getEvaluationMeasurementTechnique() != null +// && bean.getEvaluationMeasurementTechnique().indexOf("\n") >= 0 +// && bean.getEvaluationMeasurementTechnique().split("\n").length == 2 +// && type.equals("CHINESE")) { +// cell.setCellValue(bean.getEvaluationMeasurementTechnique().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getEvaluationMeasurementTechnique(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getEvaluationMeasurementTechnique()); +// } +// break; +// case 10: +// if (bean.getSampleSize() != null && bean.getSampleSize().indexOf("\n") >= 0 +// && bean.getSampleSize().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getSampleSize().split("\n")[1]); +// } else if (bean.getSampleSize() != null && bean.getSampleSize().indexOf("\n") >= 0 +// && bean.getSampleSize().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getSampleSize().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSampleSize(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSampleSize()); +// } +// break; +// case 11: +// if (bean.getSampleFreq() != null && bean.getSampleFreq().indexOf("\n") >= 0 +// && bean.getSampleFreq().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getSampleFreq().split("\n")[1]); +// } else if (bean.getSampleFreq() != null && bean.getSampleFreq().indexOf("\n") >= 0 +// && bean.getSampleFreq().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getSampleFreq().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSampleFreq(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSampleFreq()); +// } +// break; +// +// case 12: +// if (bean.getControlMethod() != null && bean.getControlMethod().indexOf("\n") >= 0 +// && bean.getControlMethod().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getControlMethod().split("\n")[1]); +// } else if (bean.getControlMethod() != null && bean.getControlMethod().indexOf("\n") >= 0 +// && bean.getControlMethod().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getControlMethod().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getControlMethod(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getControlMethod()); +// } +// break; +// +// case 13: +// if (bean.getReactionPlan() != null && bean.getReactionPlan().indexOf("\n") >= 0 +// && bean.getReactionPlan().split("\n").length == 2 && type.equals("ENGLISH")) { +// cell.setCellValue(bean.getReactionPlan().split("\n")[1]); +// } else if (bean.getReactionPlan() != null && bean.getReactionPlan().indexOf("\n") >= 0 +// && bean.getReactionPlan().split("\n").length == 2 && type.equals("CHINESE")) { +// cell.setCellValue(bean.getReactionPlan().split("\n")[0]); +// } else if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getReactionPlan(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getReactionPlan()); +// } +// break; +// +// default: +// break; +// +// } +// } +// } +// if (map != null && map.size() != 0) { +// Iterator> it = map.entrySet().iterator(); +// while (it.hasNext()) { +// Map.Entry entry = it.next(); +// List columnIndex = new ArrayList(); +// for (int i = 0; i < entry.getValue().length; i++) { +// if (entry.getValue()[i] == 3 || entry.getValue()[i] == 5 || entry.getValue()[i] == 6 +// || (entry.getValue()[i] >= 18 && entry.getValue()[i] <= 20) || entry.getValue()[i] == 14 +// || entry.getValue()[i] == 16) { +// continue; +// } else if (entry.getValue()[i] == 4) { +// columnIndex.add(entry.getValue()[i] - 1); +// } else if (entry.getValue()[i] >= 7 && entry.getValue()[i] <= 13) { +// columnIndex.add(entry.getValue()[i] - 3); +// } else if (entry.getValue()[i] == 15) { +// columnIndex.add(entry.getValue()[i] - 4); +// } else if (entry.getValue()[i] == 17) { +// columnIndex.add(entry.getValue()[i] - 5); +// } else { +// columnIndex.add(entry.getValue()[i]); +// } +// } +// int[] column = new int[columnIndex.size()]; +// for (int i = 0; i < columnIndex.size(); i++) { +// column[i] = columnIndex.get(i); +// } +// if (column.length > 0) { +// combine(sheet, entry.getKey(), column); +// } +// } +// } +// wb.write(output); +// output.close(); +// input.close(); +// System.out.println("-------WRITE EXCEL OVER-------"); +// +// return 0; +// } +// +// /** +// * 输出本部控制计划到EXCEL表格中 +// * +// * @param controlPlanBean 控制计划信息 +// * @param input 模版文件流 +// * @param outputFilePath 需要输出的全路径 +// * @throws IOException +// */ +// public static int writeControlPlanToExcel(TMomControlPlanBean controlPlanBean, File file) throws IOException { +// file.setWritable(true); +// InputStream is = new FileInputStream(file); +// XSSFWorkbook wb = new XSSFWorkbook(is);// ( +// XSSFSheet sheet = wb.getSheetAt(0); +// map.clear(); +// int startRow = 13; +// List simpleBeanList = null; +// if (controlPlanBean != null) { +// // 添加单属性信息到excel表中 +// simpleBeanList = controlPlanBean.getSimpleBeanList(); +// +// for (int i = 0; i < (simpleBeanList.size()); i++) +// insertRow(sheet, 13, 1);// 插入表格行数 +// XSSFRow row1 = sheet.getRow(3); +// setCellValue(row1, 4, controlPlanBean.getControlPlanNo()); +// setCellValue(row1, 8, controlPlanBean.getKeyPersion()); +// setCellValue(row1, 10, controlPlanBean.getKeyPhone()); +// setCellValue(row1, 12, controlPlanBean.getCreateDateStr()); +// setCellValue(row1, 15, controlPlanBean.getUpdateDateStr()); +// XSSFRow row2 = sheet.getRow(5); +// setCellValue(row2, 0, controlPlanBean.getSorName()); +// setCellValue(row2, 4, controlPlanBean.getPartNumber()); +// setCellValue(row2, 8, controlPlanBean.getCoreTeam()); +// setCellValue(row2, 12, controlPlanBean.getCustromEngineeringApprovalDateStr()); +// XSSFRow row3 = sheet.getRow(7); +// setCellValue(row3, 0, controlPlanBean.getCustromPartNumber()); +// setCellValue(row3, 4, controlPlanBean.getPartNameDesc()); +// setCellValue(row3, 8, controlPlanBean.getSupplierApprovalDateStr()); +// setCellValue(row3, 12, controlPlanBean.getCustromQuantyApprovalDateStr()); +// XSSFRow row4 = sheet.getRow(9); +// setCellValue(row4, 0, controlPlanBean.getSupplier()); +// setCellValue(row4, 4, controlPlanBean.getSupplierCode()); +// setCellValue(row4, 6, controlPlanBean.getChangeLev()); +// setCellValue(row4, 8, controlPlanBean.getMode()); +// setCellValue(row4, 10, controlPlanBean.getCustromApprovalDateStr()); +// setCellValue(row4, 12, controlPlanBean.getOtherApprovalDateStr()); +// setCellValue(row4, 15, controlPlanBean.getOtherApprovalIfDateStr()); +// } else { +// return -1; +// } +// if (simpleBeanList == null) { +// return -1; +// } +// for (int i = 0; i < simpleBeanList.size(); i++) { +// TMomControlPlanSimpleBean bean = simpleBeanList.get(i); +// if (bean.getHbdyg() != null && !bean.getHbdyg().equals("")) { +// getCombineRow(bean.getHbdyg(), startRow); +// } +// XSSFRow row = null; +// Boolean isCreat = false; +// if ((i + startRow) > sheet.getLastRowNum()) { +// row = sheet.createRow(i + startRow); +// isCreat = true; +// } else { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } +// // 获取特殊字符所在位置+++++++++++++++++ +// String[] columnNames = null; +// Map indexMap = new HashMap(); +// if (bean.getSpecial() != null && !bean.getSpecial().equals("")) { +// try { +// if (bean.getSpecial().indexOf("|") >= 0) { +// columnNames = bean.getSpecial().split("\\|"); +// } else { +// columnNames = new String[] { bean.getSpecial() }; +// } +// if (columnNames != null && columnNames.length > 0) { +// for (int i1 = 0; i1 < columnNames.length; i1++) { +// if (columnNames[i1].indexOf("-") >= 0) { +// String[] columnName = columnNames[i1].split("-"); +// // 通过列名称获取列 +// int cellindex = -1; +// if (columnName[0].indexOf(",") >= 0) { +// cellindex = getOneNamedCellIndex(wb, columnName[0].replaceAll(",", "")); +// } else if (columnName[0].indexOf("/") >= 0) { +// cellindex = getOneNamedCellIndex(wb, columnName[0].replaceAll("/", "")); +// } else { +// cellindex = getOneNamedCellIndex(wb, columnName[0]); +// } +// if (cellindex > -1) { +// indexMap.put(cellindex, Integer.parseInt(columnName[1])); +// } +// } +// } +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// } +// for (int cols = 0; cols < 18; cols++) { +// XSSFCell cell = null; +// if (isCreat) { +// cell = row.createCell(cols); +// } else { +// cell = row.getCell(cols); +// } +// cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 +// +// switch (cols) { +// +// case 0: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getPartProcessNumber(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getPartProcessNumber()); +// } +// break; +// case 1: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProcessName(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProcessName()); +// } +// break; +// case 2: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getMachineDevice(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getMachineDevice()); +// } +// break; +// case 3: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSmjy(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSmjy()); +// } +// break; +// case 4: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getBubbledPrintNo(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getBubbledPrintNo()); +// } +// break; +// case 5: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSize(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSize()); +// } +// break; +// case 6: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getNo(), indexMap.get(cols), indexMap.get(cols) + 1, 10, +// "Y14.5M")); +// } else { +// cell.setCellValue(bean.getNo()); +// } +// break; +// case 7: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProduct(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProduct()); +// } +// break; +// case 8: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProcess(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProcess()); +// } +// break; +// case 9: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSpecialClass(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSpecialClass()); +// } +// break; +// case 10: +// if (bean.getConceal().equals("1")) { +// String processName = bean.getProcessName(); +// if (bean.getProcessName() != null && bean.getProcessName().indexOf("检验(") >= 0) { +// processName = bean.getProcessName().substring(3, +// bean.getProcessName().toString().length() - 1); +// } +// cell.setCellValue("详见" + processName + "作业指导书"); +// } else { +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getProductProcessSpecificationTolerance(), +// indexMap.get(cols), indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getProductProcessSpecificationTolerance()); +// } +// } +////注释 +//// if (bean.getUpProductProcessSpecificationTolerance() == null) { +//// cell.setCellValue(""); +//// } else if (!bean +//// .getUpProductProcessSpecificationTolerance().trim() +//// .isEmpty() +//// && !bean.getDownProductProcessSpecificationTolerance() +//// .trim().isEmpty()) +//// cell.setCellValue(bean +//// .getProductProcessSpecificationTolerance() +//// + " " +//// + bean.getUpProductProcessSpecificationTolerance() +//// + "/" +//// + bean.getDownProductProcessSpecificationTolerance()); +//// else { +//// +//// } +////注释 +// break; +// case 11: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getEvaluationMeasurementTechnique(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getEvaluationMeasurementTechnique()); +// } +// break; +// case 12: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSampleSize(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSampleSize()); +// } +// break; +// case 13: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getSampleFreq(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getSampleFreq()); +// } +// break; +// case 14: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getResp(), indexMap.get(cols), indexMap.get(cols) + 1, +// 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getResp()); +// } +// break; +// case 15: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getControlMethod(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getControlMethod()); +// } +// break; +// case 16: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getOperationCriteria(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getOperationCriteria()); +// } +// break; +// case 17: +// if (indexMap.get(cols) != null) { +// cell.setCellValue(setCellFont(wb, bean.getReactionPlan(), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(bean.getReactionPlan()); +// } +// break; +// +// default: +// break; +// +// } +// } +// } +// if (map != null && map.size() != 0) { +// Iterator> it = map.entrySet().iterator(); +// while (it.hasNext()) { +// Map.Entry entry = it.next(); +// List columnIndex = new ArrayList(); +// for (int i = 0; i < entry.getValue().length; i++) { +// if ((entry.getValue()[i] >= 18 && entry.getValue()[i] <= 20)) { +// continue; +// } else { +// columnIndex.add(entry.getValue()[i]); +// } +// } +// int[] column = new int[columnIndex.size()]; +// for (int i = 0; i < columnIndex.size(); i++) { +// column[i] = columnIndex.get(i); +// } +// if (column.length > 0) { +// combine(sheet, entry.getKey(), column); +// } +// } +// } +// //+++++++++++++++++++ +// FileOutputStream output = new FileOutputStream(file); +// wb.write(output); +// output.close(); +// is.close(); +// // file.setReadOnly(); +// System.out.println("-------WRITE EXCEL OVER-------"); +// return 0; +// } +// +// /** +// * 输出本部控制计划到EXCEL表格中 +// * +// * @param controlPlanBean 控制计划信息 +// * @param input 模版文件流 +// * @param outputFilePath 需要输出的全路径 +// * @throws IOException +// */ +// public static int writeControlPlanToExcel(TMomControlPlanBean controlPlanBean, File file, String outFilePath) +// throws IOException { +// InputStream input = new FileInputStream(file); +// FileOutputStream output = new FileOutputStream(new File(outFilePath)); // +// XSSFWorkbook wb = new XSSFWorkbook(input);// ( +// XSSFSheet sheet = wb.getSheetAt(0); +// map.clear(); +// int startRow = 9; +// List simpleBeanList = null; +// if (controlPlanBean != null) { +// // 添加单属性信息到excel表中 +// simpleBeanList = controlPlanBean.getSimpleBeanList(); +// +// for (int i = 0; i < (simpleBeanList.size()); i++) { +// //+++ +// if (simpleBeanList.get(i).getHbdyg() != null && !simpleBeanList.get(i).getHbdyg().equals("")) { +// String sombine = simpleBeanList.get(i).getHbdyg().toString(); +// int rowDif = 0; +// String[] sombines; +// if (sombine.indexOf("-") >= 0) { +// sombines = sombine.split("-"); +// } else { +// sombines = new String[] { sombine }; +// } +// for (int j = 0; j < sombines.length; j++) { +// if (sombines[j].indexOf("/") >= 0) { +// int[] row; +// int[] cloumn; +// String[] cells = sombines[j].split("/"); +// if (cells[0].indexOf(",") >= 0) { +// String[] rows = cells[0].split(","); +// row = new int[rows.length]; +// for (int k = 0; k < rows.length; k++) { +// row[k] = Integer.parseInt(rows[k]) + rowDif; +// } +// } else { +// row = new int[] { Integer.parseInt(cells[0]) + rowDif }; +// } +// if (cells[1].indexOf(",") >= 0) { +// String[] cloumns = cells[1].split(","); +// cloumn = new int[cloumns.length]; +// for (int k = 0; k < cloumns.length; k++) { +// cloumn[k] = Integer.parseInt(cloumns[k]); +// } +// } else { +// cloumn = new int[] { Integer.parseInt(cells[1]) }; +// } +// map.put(row, cloumn); +// } +// } +// } +// //+++ +// // insertRow(sheet, 13, 1);// 插入表格行数 +// } +// XSSFRow row3 = sheet.getRow(2); +// //setCellValue(row3, 0,"控制计划类型:"+ controlPlanBean.getControlType()+"\n控制计划编号:"+controlPlanBean.getControlPlanNo()); +// +// setCellValue(row3,5,"主要联系人/电话:"+controlPlanBean.getKeyPhone()); +// setCellValue(row3,10,"日期(编制):"+controlPlanBean.getCreateDateStr()); +// setCellValue(row3,13,"日期(修订):"+controlPlanBean.getUpdateDateStr()); +// XSSFRow row4 = sheet.getRow(3); +// setCellValue(row4,0,"零件号/最新更改程度:"+controlPlanBean.getPartNumber()); +// setCellValue(row4,5,"核心小组:"+controlPlanBean.getCoreTeam()); +// setCellValue(row4,10,"顾客工程批准/日期(如需要):"+controlPlanBean.getCustromEngineeringApprovalDateStr()); +// XSSFRow row5 = sheet.getRow(4); +// setCellValue(row5,0,"零件名称/描述:"+controlPlanBean.getPartNameDesc()); +// setCellValue(row5,5,"供方/工厂批准/日期:"+controlPlanBean.getSupplierApprovalDateStr()); +// setCellValue(row5,10,"顾客质量批准/日期(如需要):"+controlPlanBean.getCustromQuantyApprovalDateStr()); +// XSSFRow row6 = sheet.getRow(5); +// setCellValue(row6,0,"供方/工厂:"+controlPlanBean.getSupplier()); +// setCellValue(row6,3,"供方代号:"+controlPlanBean.getSupplierCode()); +// setCellValue(row6,5,"其它批准/日期(如需要):"+controlPlanBean.getOtherApprovalDateStr()); +// setCellValue(row6,10,"其它批准/日期(如需要):"+controlPlanBean.getOtherApprovalIfDateStr()); +// +// } else { +// return -1; +// } +// if (simpleBeanList == null) { +// return -1; +// } +// for (int i = 0; i < simpleBeanList.size(); i++) { +// +// XSSFRow row = null; +// Boolean isCreat = false; +// if(i<22) { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// }else{ +// row = sheet.createRow(i+ startRow); +// isCreat = true; +// } +// if (isCreat) { +// XSSFRow oldRow = sheet.getRow(i + startRow - 1); +// for (int j = 0; j < 15; j++) { +// XSSFCell oldCell = oldRow.getCell(j); +// XSSFCell newCell = row.createCell(j); +// newCell.setCellStyle(oldCell.getCellStyle()); +// newCell.setCellType(oldCell.getCellType()); +// } +// combine(sheet, new int[] { i + startRow }, new int[] { 4, 5 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 9, 10 }); +// } +// XSSFCell cell0 = row.getCell(0); +// cell0.setCellValue(simpleBeanList.get(i).getPartProcessNumber()); +// XSSFCell cell1 = row.getCell(1); +// cell1.setCellValue(simpleBeanList.get(i).getProcessName()); +// XSSFCell cell2 = row.getCell(2); +// cell2.setCellValue(simpleBeanList.get(i).getMachineDevice()); +// XSSFCell cell3 = row.getCell(3); +// cell3.setCellValue(simpleBeanList.get(i).getNo()); +// XSSFCell cell4 = row.getCell(4); +// cell4.setCellValue(simpleBeanList.get(i).getProduct()); +// XSSFCell cell6 = row.getCell(6); +// cell6.setCellValue(simpleBeanList.get(i).getProcess()); +//// XSSFCell cell7 = row.getCell(7); +//// cell7.setCellValue(simpleBeanList.get(i).getSpecialClass()); +// +// //+++处理特殊字符,到数据库表格RB3_SPETABLE查询对应的字符 +// XSSFCell cell7 = row.getCell(7); +// ResultSet rs = null; +// SqlUtilT.getTCConnection(); +// String selectSQL = String.format("SELECT SPE FROM RB3_SPETABLE WHERE ORI='%s'",simpleBeanList.get(i).getSpecialClass()); +// System.out.print(selectSQL); +// try { +// String ss=simpleBeanList.get(i).getSpecialClass(); +// rs = SqlUtilT.read(selectSQL); +// while (rs.next()) { +// ss=rs.getString("SPE"); +// } +// cell7.setCellValue(ss); +// } catch (SQLException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// //+++ +// +// XSSFCell cell8 = row.getCell(8); +// cell8.setCellValue(simpleBeanList.get(i).getProductProcessSpecificationTolerance()); +// XSSFCell cell9 = row.getCell(9); +// cell9.setCellValue(simpleBeanList.get(i).getEvaluationMeasurementTechnique()); +// XSSFCell cell11 = row.getCell(11); +// cell11.setCellValue(simpleBeanList.get(i).getSampleSize()); +// XSSFCell cell12 = row.getCell(12); +// cell12.setCellValue(simpleBeanList.get(i).getSampleFreq()); +// XSSFCell cell13 = row.getCell(13); +// cell13.setCellValue(simpleBeanList.get(i).getControlMethod()); +// XSSFCell cell14 = row.getCell(14); +// cell14.setCellValue(simpleBeanList.get(i).getReactionPlan()); +// } +//// TMomControlPlanSimpleBean bean = simpleBeanList.get(i); +//// if (bean.getHbdyg() != null && !bean.getHbdyg().equals("")) { +//// getCombineRow(bean.getHbdyg(), startRow); +//// } +//// XSSFRow row = null; +//// Boolean isCreat = false; +//// if ((i + startRow) > sheet.getLastRowNum()) { +//// row = sheet.createRow(i + startRow); +//// isCreat = true; +//// } else { +//// row = sheet.getRow(i + startRow); +//// isCreat = false; +//// } +//// +//// // 获取特殊字符所在位置++++++ +//// String[] columnNames = null; +//// Map indexMap = new HashMap(); +//// if (bean.getSpecial() != null && !bean.getSpecial().equals("")) { +//// try { +//// if (bean.getSpecial().indexOf("|") >= 0) { +//// columnNames = bean.getSpecial().split("\\|"); +//// } else { +//// columnNames = new String[] { bean.getSpecial() }; +//// } +//// if (columnNames != null && columnNames.length > 0) { +//// for (int i1 = 0; i1 < columnNames.length; i1++) { +//// if (columnNames[i1].indexOf("-") >= 0) { +//// String[] columnName = columnNames[i1].split("-"); +//// // 通过列名称获取列 +//// int cellindex = -1; +//// if (columnName[0].indexOf(",") >= 0) { +//// cellindex = getOneNamedCellIndex(wb, columnName[0].replaceAll(",", "")); +//// } else if (columnName[0].indexOf("/") >= 0) { +//// cellindex = getOneNamedCellIndex(wb, columnName[0].replaceAll("/", "")); +//// } else { +//// cellindex = getOneNamedCellIndex(wb, columnName[0]); +//// } +//// if (cellindex > -1) { +//// indexMap.put(cellindex, Integer.parseInt(columnName[1])); +//// } +//// } +//// } +//// } +//// } catch (Exception e) { +//// // TODO: handle exception +//// e.printStackTrace(); +//// } +//// } +//// for (int cols = 0; cols < 18; cols++) { +//// XSSFCell cell = null; +//// if (isCreat) { +//// cell = row.createCell(cols); +//// } else { +//// cell = row.getCell(cols); +//// } +//// cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 +//// +//// switch (cols) { +//// +//// case 0: +//// if (indexMap.get(cols) != null) { +//// cell.setCellValue(setCellFont(wb, bean.getPartProcessNumber(), indexMap.get(cols), +//// indexMap.get(cols) + 1, 10, "Y14.5M")); +//// } else { +//// cell.setCellValue(bean.getPartProcessNumber()); +//// } +//// break; +//// case 1: +//// if (indexMap.get(cols) != null) { +//// cell.setCellValue(setCellFont(wb, bean.getProcessName(), indexMap.get(cols), +//// indexMap.get(cols) + 1, 10, "Y14.5M")); +//// } else { +//// cell.setCellValue(bean.getProcessName()); +//// } +//// break; +//// case 2: +//// if (indexMap.get(cols) != null) { +//// cell.setCellValue(setCellFont(wb, bean.getMachineDevice(), indexMap.get(cols), +//// indexMap.get(cols) + 1, 10, "Y14.5M")); +//// } else { +//// cell.setCellValue(bean.getMachineDevice()); +//// } +//// break; +//// case 3: +//// if (indexMap.get(cols) != null) { +//// cell.setCellValue(setCellFont(wb, bean.getSmjy(), indexMap.get(cols), indexMap.get(cols) + 1, +//// 10, "Y14.5M")); +//// } else { +//// cell.setCellValue(bean.getSmjy()); +//// } +//// break; +//// case 4: +//// if (indexMap.get(cols) != null) { +//// cell.setCellValue(setCellFont(wb, bean.getBubbledPrintNo(), indexMap.get(cols), +//// indexMap.get(cols) + 1, 10, "Y14.5M")); +//// } else { +//// cell.setCellValue(bean.getBubbledPrintNo()); +//// } +//// break; +//// case 5: +//// if (indexMap.get(cols) != null) { +//// cell.setCellValue(setCellFont(wb, bean.getSize(), indexMap.get(cols), indexMap.get(cols) + 1, +//// 10, "Y14.5M")); +//// } else { +//// cell.setCellValue(bean.getSize()); +//// } +//// break; +//// case 6: +//// if (indexMap.get(cols) != null) { +//// cell.setCellValue(setCellFont(wb, bean.getNo(), indexMap.get(cols), indexMap.get(cols) + 1, 10, +//// "Y14.5M")); +//// } else { +//// cell.setCellValue(bean.getNo()); +//// } +//// break; +//// case 7: +//// if (indexMap.get(cols) != null) { +//// cell.setCellValue(setCellFont(wb, bean.getProduct(), indexMap.get(cols), indexMap.get(cols) + 1, +//// 10, "Y14.5M")); +//// } else { +//// cell.setCellValue(bean.getProduct()); +//// } +//// break; +//// case 8: +//// if (indexMap.get(cols) != null) { +//// cell.setCellValue(setCellFont(wb, bean.getProcess(), indexMap.get(cols), indexMap.get(cols) + 1, +//// 10, "Y14.5M")); +//// } else { +//// cell.setCellValue(bean.getProcess()); +//// } +//// break; +//// case 9: +//// if (indexMap.get(cols) != null) { +//// cell.setCellValue(setCellFont(wb, bean.getSpecialClass(), indexMap.get(cols), +//// indexMap.get(cols) + 1, 10, "Y14.5M")); +//// } else { +//// cell.setCellValue(bean.getSpecialClass()); +//// } +//// break; +//// case 10: +////// if(bean.getConceal().equals("1")) +////// { +////// String processName = bean.getProcessName(); +////// if(bean.getProcessName() != null && bean.getProcessName().indexOf("检验(") >= 0) +////// { +////// processName = bean.getProcessName().substring(3, bean.getProcessName().toString().length()-1); +////// } +////// cell.setCellValue("详见"+processName+"作业指导书"); +////// } +////// else +////// { +//// if (indexMap.get(cols) != null) { +//// cell.setCellValue(setCellFont(wb, bean.getProductProcessSpecificationTolerance(), +//// indexMap.get(cols), indexMap.get(cols) + 1, 10, "Y14.5M")); +//// } else { +//// cell.setCellValue(bean.getProductProcessSpecificationTolerance()); +//// } +//////注释 +////// } +////// if (bean.getUpProductProcessSpecificationTolerance() == null) { +////// cell.setCellValue(""); +////// } else if (!bean +////// .getUpProductProcessSpecificationTolerance().trim() +////// .isEmpty() +////// && !bean.getDownProductProcessSpecificationTolerance() +////// .trim().isEmpty()) +////// cell.setCellValue(bean +////// .getProductProcessSpecificationTolerance() +////// + " " +////// + bean.getUpProductProcessSpecificationTolerance() +////// + "/" +////// + bean.getDownProductProcessSpecificationTolerance()); +////// else { +////// +////// } +//////注释 +//// break; +//// case 11: +//// if (indexMap.get(cols) != null) { +//// cell.setCellValue(setCellFont(wb, bean.getEvaluationMeasurementTechnique(), indexMap.get(cols), +//// indexMap.get(cols) + 1, 10, "Y14.5M")); +//// } else { +//// cell.setCellValue(bean.getEvaluationMeasurementTechnique()); +//// } +//// break; +//// case 12: +//// if (indexMap.get(cols) != null) { +//// cell.setCellValue(setCellFont(wb, bean.getSampleSize(), indexMap.get(cols), +//// indexMap.get(cols) + 1, 10, "Y14.5M")); +//// } else { +//// cell.setCellValue(bean.getSampleSize()); +//// } +//// break; +//// case 13: +//// if (indexMap.get(cols) != null) { +//// cell.setCellValue(setCellFont(wb, bean.getSampleFreq(), indexMap.get(cols), +//// indexMap.get(cols) + 1, 10, "Y14.5M")); +//// } else { +//// cell.setCellValue(bean.getSampleFreq()); +//// } +//// break; +//// case 14: +//// if (indexMap.get(cols) != null) { +//// cell.setCellValue(setCellFont(wb, bean.getResp(), indexMap.get(cols), indexMap.get(cols) + 1, +//// 10, "Y14.5M")); +//// } else { +//// cell.setCellValue(bean.getResp()); +//// } +//// break; +//// case 15: +//// if (indexMap.get(cols) != null) { +//// cell.setCellValue(setCellFont(wb, bean.getControlMethod(), indexMap.get(cols), +//// indexMap.get(cols) + 1, 10, "Y14.5M")); +//// } else { +//// cell.setCellValue(bean.getControlMethod()); +//// } +//// break; +//// case 16: +//// if (indexMap.get(cols) != null) { +//// cell.setCellValue(setCellFont(wb, bean.getOperationCriteria(), indexMap.get(cols), +//// indexMap.get(cols) + 1, 10, "Y14.5M")); +//// } else { +//// cell.setCellValue(bean.getOperationCriteria()); +//// } +//// break; +//// case 17: +//// if (indexMap.get(cols) != null) { +//// cell.setCellValue(setCellFont(wb, bean.getReactionPlan(), indexMap.get(cols), +//// indexMap.get(cols) + 1, 10, "Y14.5M")); +//// } else { +//// cell.setCellValue(bean.getReactionPlan()); +//// } +//// break; +//// +//// default: +//// break; +//// +//// } +//// } +//// } +//// if (map != null && map.size() != 0) { +//// Iterator> it = map.entrySet().iterator(); +//// while (it.hasNext()) { +//// Map.Entry entry = it.next(); +//// List columnIndex = new ArrayList(); +//// for (int i = 0; i < entry.getValue().length; i++) { +//// if ((entry.getValue()[i] >= 18 && entry.getValue()[i] <= 20)) { +//// continue; +//// } else { +//// columnIndex.add(entry.getValue()[i]); +//// } +//// } +//// int[] column = new int[columnIndex.size()]; +//// for (int i = 0; i < columnIndex.size(); i++) { +//// column[i] = columnIndex.get(i); +//// } +//// if (column.length > 0) { +//// combine(sheet, entry.getKey(), column); +//// } +//// } +//// } +// //+++ +// // 合并单元格 +// if (map != null && map.size() > 0) { +// Iterator> it = map.entrySet().iterator(); +// while (it.hasNext()) { +// Map.Entry entry = it.next(); +// int[] row = new int[entry.getKey().length]; +// int[] column = new int[entry.getValue().length]; +// for (int k = 0; k < entry.getKey().length; k++) { +// //row[k] = entry.getKey()[k] + 17; +// row[k] = entry.getKey()[k]+9 ; +// } +// for (int k = 0; k < entry.getValue().length; k++) { +// if(entry.getValue()[k]<=5) { +// column[k] = entry.getValue()[k] -1; +// }else if(entry.getValue()[k]>9) { +// column[k] = entry.getValue()[k] +1; +// }else { +// column[k] = entry.getValue()[k]; +// } +// } +// if(column.length==1&&column[0]==4){ +// for(int s=0;s= firstRow && row <= lastRow) + { + if(column >= firstColumn && column <= lastColumn) + { + index = i; + } + } + } + sheet.removeMergedRegion(index);//移除合并单元格 + } +//+++ + + /** + * 改变数据集的命名引用 + * + * @param tccomponentDataset + * @param quote + * @param type + * @param path + * @throws TCException + */ + public static void changeDataSet(TCComponentDataset tccomponentDataset, String quote, String type, String path) + throws TCException { + String myPath[] = { path }; + String myQuote[] = { quote };// 引用"excel" + String myType[] = { type };// 类型"MSExcelX" + String myPlain[] = { "Plain" }; + + // 删除数据集的引用 + deleDateSetRef(tccomponentDataset); + // 数据集的替换 + tccomponentDataset.setFiles(myPath, myType, myPlain, myQuote); + + } + + /** + * 删除数据集的命名引用 + * + * @param dataset + * @throws TCException + */ + private static void deleDateSetRef(TCComponentDataset dataset) throws TCException { + + TCComponentTcFile[] tcFiles = dataset.getTcFiles(); + for (int i = 0; i < tcFiles.length; i++) { + // 得到数据集的引用类型 + String str_temp = getNamedRefType(dataset, tcFiles[i]); + // 删除引用 + dataset.removeNamedReference(str_temp); + } + + } + + /** + * 得到数据集的引用类型 + * + * @param datasetComponent + * @param tccomponent + * @return + * @throws TCException + */ + private static String getNamedRefType(TCComponentDataset datasetComponent, TCComponentTcFile tccomponent) + throws TCException { + String s; + s = ""; + TCProperty tcproperty; + TCProperty tcproperty1; + TCComponent atccomponent[]; + String as[]; + int i; + int j; + int k; + try { + tcproperty = datasetComponent.getTCProperty("ref_list"); + tcproperty1 = datasetComponent.getTCProperty("ref_names"); + if (tcproperty == null || tcproperty1 == null) + return s; + } catch (TCException tcexception) { + return s; + } + atccomponent = tcproperty.getReferenceValueArray(); + as = tcproperty1.getStringValueArray(); + if (atccomponent == null || as == null) + return s; + i = atccomponent.length; + if (i != as.length) + return s; + j = -1; + k = 0; + do { + if (k >= i) + break; + if (tccomponent == atccomponent[k]) { + j = k; + break; + } + k++; + } while (true); + if (j != -1) + s = as[j]; + return s; + } + + /** + * 下载文件 + * + * @param comps + * @return + * @throws TCException + * @throws IOException + */ +// public static String downLoadFile(TCComponentDataset dateSet, String compType) throws TCException, IOException { +// String value = ""; +// String tempPath = System.getenv("TEMP"); +// // MessageBox.post(" tempPath = "+tempPath,"INFO",MessageBox.INFORMATION); +// if (tempPath == null) { +// tempPath = ""; +// } else if (!tempPath.endsWith("\\")) { +// tempPath = tempPath + "\\"; +// } +// SimpleDateFormat sdf = new SimpleDateFormat("yyyymmdd"); +// TCComponentTcFile[] tcFiles = dateSet.getTcFiles(); +// File file = null; +// if (tcFiles != null) { +// file = tcFiles[0].getFmsFile(); +// String fileName = file.getName(); +// String fileDix = fileName.substring(fileName.lastIndexOf("."), fileName.length()); +// fileName = tempPath + sdf.format(new Date()) + fileDix; +// File dirFile = new File(fileName); +// FileUtility.copyFile(file, dirFile); +//// if (compType.equals("MSExcelX")) { +//// this.excelDataset = (TCComponentDataset) comp; +//// } +// return fileName; +// } +// return value; +// } +// +// public static void setFlowChart(Map valueMap, File file) { +// // TODO Auto-generated method stub +// file.setWritable(true); +// try { +// InputStream is = new FileInputStream(file); +// XSSFWorkbook wb = new XSSFWorkbook(is);// ( +// XSSFSheet sheet = wb.getSheetAt(0); +// +// Iterator> it = valueMap.entrySet().iterator(); +// while (it.hasNext()) { +// Map.Entry entry = it.next(); +// setNamedCellValue(wb, entry.getKey(), entry.getValue()); +// } +// FileOutputStream output = new FileOutputStream(file); +// wb.write(output); +// output.close(); +// is.close(); +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// // file.setReadOnly(); +// System.out.println("-------WRITE EXCEL OVER-------"); +// } +// +// public static Workbook getWorkbok(File file) throws IOException { +// Workbook wb = null; +// FileInputStream in = new FileInputStream(file); +// System.out.println(file.getName()); +// +// if (file.getName().endsWith(EXCEL_XLS)) { // Excel 2003 +// wb = new HSSFWorkbook(in); +// } else if (file.getName().endsWith(EXCEL_XLSX)) { // Excel 2007/2010 +// System.out.println("OK"); +// wb = new XSSFWorkbook(in); +// } +// return wb; +// } + + /** + * 读取EXCEL表 + * + * @param File excel_file + * @return List> 返回的信息 + * @throws IOException + * @throws FileNotFoundException + */ +// public static List readExcelByEntrustment(File excel_file, String type) +// throws FileNotFoundException, IOException { +// if (excel_file == null || !excel_file.exists()) { +// return null; +// } +// // 用来返回的所有的行的信息 +// List lines_msg = new ArrayList(); +// XSSFWorkbook workBook = new XSSFWorkbook(new FileInputStream(excel_file)); +// XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(workBook); +// XSSFSheet sheet = workBook.getSheetAt(0); +// XSSFRow title_row = sheet.getRow(0); +// +// // 得到列的数目 +// int col_count = title_row.getPhysicalNumberOfCells(); +// // 得到行的数目 +// int row_count = sheet.getLastRowNum(); +// boolean isSelectType = false;// 判断是否找到指定的类型 +// for (int j = 0; j < row_count + 1; j++) { +// // 用来返回单行的信息 +// XSSFRow row = sheet.getRow(j); +// if (row == null) { +// isSelectType = false; +// continue; +// } +// // System.out.println(getStringCellValue(evaluator, row.getCell((short) 0))); +// if (getStringCellValue(evaluator, row.getCell((short) 0)) == null +// || getStringCellValue(evaluator, row.getCell((short) 0)).isEmpty()) { +// isSelectType = false; +// } else if (isSelectType || type.compareTo(getStringCellValue(evaluator, row.getCell((short) 0))) == 0) { +// isSelectType = true; +// if (row.getCell((short) 2) != null) { +// String value = getStringCellValue(evaluator, row.getCell((short) 1)); +// lines_msg.add(value); +// } +// } else { +// continue; +// } +// +// } +// // insertRow(sheet,4,1); +// return lines_msg; +// } +// +// /** +// * 读取EXCEL表 +// * +// * @param File excel_file +// * @return List> 返回的信息 +// * @throws IOException +// * @throws FileNotFoundException +// */ +// public static DefaultMutableTreeNode readExcelNodeByEntrustment(File excel_file, String type) +// throws FileNotFoundException, IOException { +// DefaultMutableTreeNode node = new DefaultMutableTreeNode("应用领域"); +// if (excel_file == null || !excel_file.exists()) { +// return node; +// } +// // 用来返回的所有的行的信息 +// //List lines_msg = new ArrayList(); +// XSSFWorkbook workBook = new XSSFWorkbook(new FileInputStream(excel_file)); +// XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(workBook); +// XSSFSheet sheet = workBook.getSheetAt(0); +// XSSFRow title_row = sheet.getRow(0); +// +// // 得到列的数目 +// int col_count = title_row.getPhysicalNumberOfCells(); +// // 得到行的数目 +// int row_count = sheet.getLastRowNum(); +// boolean isSelectType = false;// 判断是否找到指定的类型 +// String no1 = ""; +// String no2 = ""; +// DefaultMutableTreeNode no1Node = null; +// DefaultMutableTreeNode no2Node = null; +// for (int j = 0; j < row_count + 1; j++) { +// +// // 用来返回单行的信息 +// XSSFRow row = sheet.getRow(j); +// String sss=getStringCellValue(evaluator, row.getCell((short) 0)); +// if (row == null) { +// isSelectType = false; +// continue; +// } +// // System.out.println(getStringCellValue(evaluator, row.getCell((short) 0))); +// if (getStringCellValue(evaluator, row.getCell((short) 0)) == null +// || getStringCellValue(evaluator, row.getCell((short) 0)).isEmpty()) { +// isSelectType = false; +// } else if (isSelectType || type.compareTo(sss) == 0) { +// isSelectType = true; +// if (row.getCell((short) 3) != null) { +// String value1 = getStringCellValue(evaluator, row.getCell((short) 1)); +// String value2 = getStringCellValue(evaluator, row.getCell((short) 2)); +// //String value = getStringCellValue(evaluator, row.getCell((short) 3)); +// String value4 = getStringCellValue(evaluator, row.getCell((short) 3)); +// if(!value1.isEmpty() && value1.compareTo(no1) != 0) +// { +// no1Node = new DefaultMutableTreeNode(value1); +// node.add(no1Node); +// no2Node = new DefaultMutableTreeNode(value2); +// no1Node.add(no2Node); +// } +// else if(!value2.isEmpty() && value2.compareTo(no2) != 0) { +// no2Node = new DefaultMutableTreeNode(value2); +// no1Node.add(no2Node); +// } +// +// no2Node.add(new DefaultMutableTreeNode(value4)); +// +// //lines_msg.add(value); +// } +// } else { +// continue; +// } +// +// } +// // insertRow(sheet,4,1); +// return node; +// } +// +// /** +// * 输出本部控制计划到EXCEL表格中 +// * +// * @param controlPlanBean 控制计划信息 +// * @param input 模版文件流 +// * @param outputFilePath 需要输出的全路径 +// * @throws IOException +// */ +// public static int writeEntrustmentFormToExcel(EntrustmentFormBean controlPlanBean, File file, String outFilePath) +// throws IOException { +// InputStream input = new FileInputStream(file); +// FileOutputStream output = new FileOutputStream(new File(outFilePath)); // +// XSSFWorkbook wb = new XSSFWorkbook(input);// ( +// XSSFSheet sheet = wb.getSheetAt(0); +// map.clear(); +// if (controlPlanBean != null) { +// // 添加单属性信息到excel表中 +// XSSFRow row = sheet.getRow(4); +// setCellValue(row, 2, controlPlanBean.getP1()); +// setCellValue(row, 7, controlPlanBean.getItemId()); +// XSSFRow row1 = sheet.getRow(5); +// setCellValue(row1, 2, controlPlanBean.getP3()); +// setCellValue(row1, 7, controlPlanBean.getP4()); +// XSSFRow row2 = sheet.getRow(6); +// setCellValue(row2, 2, controlPlanBean.getP5()); +// setCellValue(row2, 7, controlPlanBean.getP6()); +// XSSFRow row3 = sheet.getRow(7); +// setCellValue(row3, 2, controlPlanBean.getP7()); +// setCellValue(row3, 7, controlPlanBean.getP8()); +// XSSFRow row4 = sheet.getRow(8); +// setCellValue(row4, 2, controlPlanBean.getP9()); +// setCellValue(row4, 7, controlPlanBean.getP10()); +// XSSFRow row5 = sheet.getRow(10); +// setCellValue(row5, 2, controlPlanBean.getP11()); +// XSSFRow row6 = sheet.getRow(11); +// setCellValue(row6, 2, controlPlanBean.getP12()); +// setCellValue(row6, 7, controlPlanBean.getP15()); +// XSSFRow row7 = sheet.getRow(12); +// setCellValue(row7, 1, controlPlanBean.getP13()); +// setCellValue(row7, 4, controlPlanBean.getP14()); +// setCellValue(row7, 7, controlPlanBean.getP16()); +// XSSFRow row8 = sheet.getRow(14); +// setCellValue(row8, 2, controlPlanBean.getP17()); +// setCellValue(row8, 7, controlPlanBean.getP18()); +// XSSFRow row9 = sheet.getRow(15); +// setCellValue(row9, 2, controlPlanBean.getP19()); +// setCellValue(row9, 7, controlPlanBean.getP20()); +// XSSFRow row10 = sheet.getRow(16); +// setCellValue(row10, 2, controlPlanBean.getP21()); +// setCellValue(row10, 7, controlPlanBean.getP22()); +// XSSFRow row11 = sheet.getRow(17); +// setCellValue(row11, 2, controlPlanBean.getP23()); +// setCellValue(row11, 7, controlPlanBean.getP24()); +// XSSFRow row12 = sheet.getRow(18); +// setCellValue(row12, 2, controlPlanBean.getP25()); +// XSSFRow row13 = sheet.getRow(20); +// setCellValue(row13, 2, controlPlanBean.getP26()); +// setCellValue(row13, 7, controlPlanBean.getP27()); +// XSSFRow row14 = sheet.getRow(21); +// setCellValue(row14, 1, controlPlanBean.getP28()); +// setCellValue(row14, 4, controlPlanBean.getP29()); +// setCellValue(row14, 7, controlPlanBean.getP30()); +// XSSFRow row15 = sheet.getRow(22); +// setCellValue(row15, 2, controlPlanBean.getP31()); +// setCellValue(row15, 7, controlPlanBean.getP32()); +// XSSFRow row16 = sheet.getRow(24); +// setCellValue(row16, 0, controlPlanBean.getP33()); +// XSSFRow row17 = sheet.getRow(26); +// setCellValue(row17, 0, controlPlanBean.getP66()); +// } else { +// return -1; +// } +// +// wb.write(output); +// output.close(); +// input.close(); +// System.out.println("-------WRITE EXCEL OVER-------"); +// +// return 0; +// } +// +// /** +// * 竖版作业工艺卡 +// * +// * @param controlPlanBean 控制计划信息 +// * @param input 模版文件流 +// * @param outputFilePath 需要输出的全路径 +// * @throws IOException +// */ +// public static int writeJobProcessFormVerticalToExcel(JobProcessFormBean controlPlanBean, File file, +// String outFilePath,TCComponentTcFile picFile,String outFilePathp) throws IOException { +// //导出图 +// if(outFilePathp!=null) { +// //ExcelUtil.InsertPicture(file,6,10,outFilePath,outFilePathp); +// //第6行到底15行的总行高:5.67cm +// //第10列到17列的总列宽:9.52cm +// ExcelUtil.InsertTitlePicture(file,outFilePath,outFilePathp,new int[] {7,8,9,10,11,12,13,14,15,16}, +// new int[] {10,11,12,13,14,15,16,17},true,3.1,9.52,7,10);//最后两个参数是插入的位置 +// } +// +// File file1=new File(outFilePath); +// InputStream input = new FileInputStream(file1); +// XSSFWorkbook wb = new XSSFWorkbook(input);// ( +// XSSFSheet sheet = wb.getSheetAt(0); +// +// +// wb.removeSheetAt(wb.getActiveSheetIndex());//消除水印 +// map.clear(); +// int startRow = 6; +// if (controlPlanBean != null) { +// // 添加单属性信息到excel表中 +// XSSFRow titleRow = sheet.getRow(0); +// setCellValue(titleRow, 3, controlPlanBean.getGsmc()); +// titleRow = sheet.getRow(1); +// setCellValue(titleRow, 9, controlPlanBean.getLjdh()); +// titleRow = sheet.getRow(2); +// setCellValue(titleRow, 9, controlPlanBean.getSbmc()); +// titleRow = sheet.getRow(3); +// setCellValue(titleRow, 9, controlPlanBean.getSbxh()); +// //setCellValue(titleRow, 13, " 下工序:"+controlPlanBean.getXdgx()); +// +// List> toolingDetailData = controlPlanBean.getToolingDetailData(); +// List> machiningParameterData = controlPlanBean.getMachiningParameterData(); +// List> controlRequirementData = controlPlanBean.getControlRequirementData(); +// for (int i = 0; i < toolingDetailData.size(); i++) { +// +// XSSFRow row = null; +// Boolean isCreat = false; +// if (i == toolingDetailData.size() - 1) { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } else if (i > 9) {//i从0开始,所以i=10是最后一行 +// row = createRow(sheet, i + startRow); +// isCreat = true; +// } else { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } +// // XSSFRow row = sheet.getRow(i + startRow); +// if (isCreat) { +// XSSFRow oldRow = sheet.getRow(i + startRow - 1); +// for (int j = 0; j < 16; j++) { +// XSSFCell oldCell = oldRow.getCell(j); +// XSSFCell newCell = row.createCell(j); +// newCell.setCellStyle(oldCell.getCellStyle()); +// newCell.setCellType(oldCell.getCellType()); +// } +// // 合并单元格 +// combine(sheet, new int[] { i + startRow }, new int[] { 3, 4 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 5, 6 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 7, 8 }); +// } +// +// List toolingDetailList = toolingDetailData.get(i); +// // XSSFRow row = sheet.getRow(i + startRow); +// XSSFCell cell1 = row.getCell(2); +// cell1.setCellValue(toolingDetailList.get(1)); +// XSSFCell cell2 = row.getCell(3); +// cell2.setCellValue(toolingDetailList.get(2)); +// XSSFCell cell3 = row.getCell(5); +// cell3.setCellValue(toolingDetailList.get(3)); +// XSSFCell cell4 = row.getCell(7); +// cell4.setCellValue(toolingDetailList.get(4)); +// } +// startRow = 19; +// if (toolingDetailData.size() > 11) { +// // 拆分合并单元格 +// unMerge(sheet, "A4"); +// // 合并单元格 +// int[] rows = new int[2 + toolingDetailData.size()]; +// rows[0] = 3; +// rows[1] = 4; +// for (int i = 0; i < toolingDetailData.size(); i++) { +// rows[i + 2] = i + 5; +// } +// +// combine(sheet, rows, new int[] { 0, 1 }); +// startRow = 19 + toolingDetailData.size() - 11; +// } +// +// int rows = 10; +// if (machiningParameterData.size() > 20) { +// rows = (int) Math.ceil(machiningParameterData.size() / 2); +// for (int i = 9; i < rows - 1; i++) { +// XSSFRow row = null; +// Boolean isCreat = false; +// if (i == toolingDetailData.size() - 1) { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } else if (i > 8) { +// row = createRow(sheet, i + startRow); +// isCreat = true; +// } else { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } +// // XSSFRow row = sheet.getRow(i + startRow); +// if (isCreat) { +// XSSFRow oldRow = sheet.getRow(i + startRow - 1); +// for (int j = 0; j < 16; j++) { +// XSSFCell oldCell = oldRow.getCell(j); +// XSSFCell newCell = row.createCell(j); +// newCell.setCellStyle(oldCell.getCellStyle()); +// newCell.setCellType(oldCell.getCellType()); +// } +// // 合并单元格 +// combine(sheet, new int[] { i + startRow }, new int[] { 3, 4 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 6, 7, 8 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 10, 11 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 13, 14, 15,16 }); +// } +// } +// } +// +// if (machiningParameterData.size() > 10) { +// +// for (int i = 0; i < rows; i++) { +// List machiningParameterList = machiningParameterData.get(i); +// XSSFRow row = sheet.getRow(i + startRow); +// XSSFCell cell1 = row.getCell(2); +// cell1.setCellValue(machiningParameterList.get(1)); +// XSSFCell cell2 = row.getCell(3); +// cell2.setCellValue(machiningParameterList.get(2)); +// XSSFCell cell3 = row.getCell(5); +// cell3.setCellValue(machiningParameterList.get(3)); +// XSSFCell cell4 = row.getCell(6); +// cell4.setCellValue(machiningParameterList.get(4)); +// } +// for (int i = rows; i < machiningParameterData.size(); i++) { +// List machiningParameterList = machiningParameterData.get(i); +// XSSFRow row = sheet.getRow(i - rows + startRow); +// XSSFCell cell1 = row.getCell(9); +// cell1.setCellValue(machiningParameterList.get(1)); +// XSSFCell cell2 = row.getCell(10); +// cell2.setCellValue(machiningParameterList.get(2)); +// XSSFCell cell3 = row.getCell(12); +// cell3.setCellValue(machiningParameterList.get(3)); +// XSSFCell cell4 = row.getCell(13); +// cell4.setCellValue(machiningParameterList.get(4)); +// } +// } else { +// for (int i = 0; i < machiningParameterData.size(); i++) { +// List machiningParameterList = machiningParameterData.get(i); +// XSSFRow row = sheet.getRow(i + startRow); +// XSSFCell cell1 = row.getCell(2); +// cell1.setCellValue(machiningParameterList.get(1)); +// XSSFCell cell2 = row.getCell(3); +// cell2.setCellValue(machiningParameterList.get(2)); +// XSSFCell cell3 = row.getCell(5); +// cell3.setCellValue(machiningParameterList.get(3)); +// XSSFCell cell4 = row.getCell(6); +// cell4.setCellValue(machiningParameterList.get(4)); +// } +// } +// if (rows > 10) { +// // 拆分合并单元格 +// unMerge(sheet, "A" + startRow); +// // 合并单元格 +// int[] rowInders = new int[1 + rows]; +// rowInders[0] = startRow - 1; +// for (int i = 0; i < rows; i++) { +// rowInders[i + 1] = i + startRow; +// } +// +// combine(sheet, rowInders, new int[] { 0, 1 }); +// } +// if (toolingDetailData.size() > 11) { +// startRow = 33 + toolingDetailData.size() - 11; +// } else { +// startRow = 33; +// } +// if (rows > 10) { +// startRow = startRow + rows - 10; +// } +// for (int i = 0; i < controlRequirementData.size(); i++) { +// +// XSSFRow row = null; +// Boolean isCreat = false; +// if (i == controlRequirementData.size() - 1) { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } else if (i > 7) { +// row = createRow(sheet, i + startRow); +// isCreat = true; +// } else { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } +// // XSSFRow row = sheet.getRow(i + startRow); +// if (isCreat) { +// XSSFRow oldRow = sheet.getRow(i + startRow - 1); +// for (int j = 0; j < 17; j++) { +// XSSFCell oldCell = oldRow.getCell(j); +// XSSFCell newCell = row.createCell(j); +// newCell.setCellStyle(oldCell.getCellStyle()); +// newCell.setCellType(oldCell.getCellType()); +// } +// // 合并单元格 +// combine(sheet, new int[] { i + startRow }, new int[] { 3, 4 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 6, 7 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 10, 11 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 13, 14, 15 }); +// } +// +// List controlRequirementList = controlRequirementData.get(i); +// // XSSFRow row = sheet.getRow(i + startRow); +// XSSFCell cell1 = row.getCell(2); +// cell1.setCellValue(controlRequirementList.get(1)); +// XSSFCell cell2 = row.getCell(3); +// cell2.setCellValue(controlRequirementList.get(2)); +// XSSFCell cell3 = row.getCell(5); +// cell3.setCellValue(controlRequirementList.get(3)); +// XSSFCell cell4 = row.getCell(6); +// cell4.setCellValue(controlRequirementList.get(4)); +// XSSFCell cell5 = row.getCell(8); +// cell5.setCellValue(controlRequirementList.get(5)); +// XSSFCell cell6 = row.getCell(9); +// cell6.setCellValue(controlRequirementList.get(6)); +// XSSFCell cell7 = row.getCell(10); +// cell7.setCellValue(controlRequirementList.get(7)); +// XSSFCell cell8 = row.getCell(12); +// cell8.setCellValue(controlRequirementList.get(8)); +// XSSFCell cell9 = row.getCell(13); +// cell9.setCellValue(controlRequirementList.get(9)); +// XSSFCell cel20 = row.getCell(16); +// cel20.setCellValue(controlRequirementList.get(10)); +// } +// +// if (controlRequirementData.size() > 9) { +// // 拆分合并单元格 +// unMerge(sheet, "A" + (startRow - 2)); +// // 合并单元格 +// int[] rowInders = new int[3 + controlRequirementData.size()]; +// rowInders[0] = startRow - 3; +// rowInders[1] = startRow - 2; +// rowInders[2] = startRow - 1; +// for (int i = 0; i < controlRequirementData.size(); i++) { +// rowInders[i + 3] = i + startRow; +// } +// +// combine(sheet, rowInders, new int[] { 0, 1 }); +// } +// +// } else { +// return -1; +// } +// FileOutputStream output = new FileOutputStream(new File(outFilePath)); // +// wb.write(output); +// output.close(); +// input.close(); +// +// System.out.println("-------WRITE EXCEL OVER-------"); +// +// return 0; +// } +// +// /** +// * 横版作业工艺卡 +// * +// * @param controlPlanBean 控制计划信息 +// * @param input 模版文件流 +// * @param outputFilePath 需要输出的全路径 +// * @throws IOException +// */ +// public static int writeJobProcessFormAcrossToExcel(JobProcessFormBean controlPlanBean, File file, +// String outFilePath,TCComponentTcFile picFile,String outFilePathp) throws IOException{ +// //插入图片 +// //导出图 +// if(outFilePathp!=null) { +// //第17行到底28行的总行高:3.96cm +// //第18列到24列的总列宽:8.9cm +// int i=0; +// if(controlPlanBean.getToolingDetailData().size()>9) { +// i=controlPlanBean.getToolingDetailData().size()-9; +// } +// if(controlPlanBean.getMachiningParameterData().size()-9>i) { +// i=controlPlanBean.getMachiningParameterData().size()-9; +// } +// ExcelUtil.InsertTitlePicture(file,outFilePath,outFilePathp,new int[] {17,18,19,20,21,22,23,24,25,26,27,28}, +// new int[] {18,19,20,21,22,23,24},true,3.96,8.9,17+i,18); +// } +// +// File file1=new File(outFilePath); +// InputStream input = new FileInputStream(file1); +// XSSFWorkbook wb = new XSSFWorkbook(input);// ( +// XSSFSheet sheet = wb.getSheetAt(0); +// wb.removeSheetAt(wb.getActiveSheetIndex()); +// map.clear(); +// int startRow = 5; +// if (controlPlanBean != null) { +// // 添加单属性信息到excel表中 +// XSSFRow titleRow = sheet.getRow(0); +// setCellValue(titleRow, 2, controlPlanBean.getGsmc()); +// setCellValue(titleRow, 17, controlPlanBean.getSbmc()); +// titleRow = sheet.getRow(1); +// setCellValue(titleRow, 13, controlPlanBean.getLjdh()); +// setCellValue(titleRow, 17, controlPlanBean.getSbxh()); +// titleRow = sheet.getRow(2); +// setCellValue(titleRow, 13, controlPlanBean.getBgx()); +// +// +// List> toolingDetailData = controlPlanBean.getToolingDetailData(); +// List> machiningParameterData = controlPlanBean.getMachiningParameterData(); +// List> controlRequirementData = controlPlanBean.getControlRequirementData(); +// for (int i = 0; i < toolingDetailData.size(); i++) { +// +// XSSFRow row = null; +// Boolean isCreat = false; +// if (i == toolingDetailData.size() - 1) { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } else if (i > 7) { +// row = createRow(sheet, i + startRow); +// +// isCreat = true; +// } else { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } +// // XSSFRow row = sheet.getRow(i + startRow); +// if (isCreat) { +// XSSFRow oldRow = sheet.getRow(i + startRow - 1); +// for (int j = 0; j < 24; j++) { +// XSSFCell oldCell = oldRow.getCell(j); +// XSSFCell newCell = row.createCell(j); +// newCell.setCellStyle(oldCell.getCellStyle()); +// newCell.setCellType(oldCell.getCellType()); +// } +// // 合并单元格 +// combine(sheet, new int[] { i + startRow }, new int[] { 3, 4 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 5, 6 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 7, 8, 9, 10 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 16, 17 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 19, 20 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 22, 23 }); +// } +// +// List toolingDetailList = toolingDetailData.get(i); +// XSSFCell cell1 = row.getCell(2); +// cell1.setCellValue(toolingDetailList.get(1)); +// XSSFCell cell2 = row.getCell(3); +// cell2.setCellValue(toolingDetailList.get(2)); +// XSSFCell cell3 = row.getCell(5); +// cell3.setCellValue(toolingDetailList.get(3)); +// XSSFCell cell4 = row.getCell(7); +// cell4.setCellValue(toolingDetailList.get(4)); +// } +// startRow = 4; +//// if (toolingDetailData.size() > 11) { +//// // 拆分合并单元格 +//// unMerge(sheet, "A4"); +//// // 合并单元格 +//// int[] rows = new int[2 + toolingDetailData.size()]; +//// rows[0] = 3; +//// rows[1] = 4; +//// for (int i = 0; i < toolingDetailData.size(); i++) { +//// rows[i + 2] = i + 5; +//// } +//// +//// combine(sheet, rows, new int[] { 0, 1 }); +//// startRow = 18 + toolingDetailData.size() - 10; +//// } +// int rows = 10; +// if (toolingDetailData.size() > 9) { +// rows = toolingDetailData.size() + 1; +// } +// if (machiningParameterData.size() > 2 * rows) { +// rows = (int) Math.ceil(machiningParameterData.size() / 2); +// for (int i = 10; i < rows - 1; i++) { +// XSSFRow row = null; +// Boolean isCreat = false; +// if (i == toolingDetailData.size() - 1) { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } else if (i > 8) { +// row = createRow(sheet, i + startRow); +// isCreat = true; +// } else { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } +// // XSSFRow row = sheet.getRow(i + startRow); +// if (isCreat) { +// XSSFRow oldRow = sheet.getRow(i + startRow - 1); +// for (int j = 0; j < 24; j++) { +// XSSFCell oldCell = oldRow.getCell(j); +// XSSFCell newCell = row.createCell(j); +// newCell.setCellStyle(oldCell.getCellStyle()); +// newCell.setCellType(oldCell.getCellType()); +// } +// // 合并单元格 +// combine(sheet, new int[] { i + startRow }, new int[] { 3, 4 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 5, 6 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 7, 8, 9, 10 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 16, 17 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 19, 20 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 22, 23 }); +// } +// } +// } +// +// if (machiningParameterData.size() > rows) { +// +// for (int i = 0; i < rows; i++) { +// List machiningParameterList = machiningParameterData.get(i); +// XSSFRow row = sheet.getRow(i + startRow); +// XSSFCell cell1 = row.getCell(13); +// cell1.setCellValue(machiningParameterList.get(1)); +// XSSFCell cell2 = row.getCell(14); +// cell2.setCellValue(machiningParameterList.get(2)); +// XSSFCell cell3 = row.getCell(15); +// cell3.setCellValue(machiningParameterList.get(3)); +// XSSFCell cell4 = row.getCell(16); +// cell4.setCellValue(machiningParameterList.get(4)); +// } +// for (int i = rows; i < machiningParameterData.size(); i++) { +// List machiningParameterList = machiningParameterData.get(i); +// XSSFRow row = sheet.getRow(i - rows + startRow); +// XSSFCell cell1 = row.getCell(17); +// cell1.setCellValue(machiningParameterList.get(1)); +// XSSFCell cell2 = row.getCell(18); +// cell2.setCellValue(machiningParameterList.get(2)); +// XSSFCell cell3 = row.getCell(20); +// cell3.setCellValue(machiningParameterList.get(3)); +// XSSFCell cell4 = row.getCell(21); +// cell4.setCellValue(machiningParameterList.get(4)); +// } +// } else { +// for (int i = 0; i < machiningParameterData.size(); i++) { +// List machiningParameterList = machiningParameterData.get(i); +// XSSFRow row = sheet.getRow(i + startRow); +// XSSFCell cell1 = row.getCell(13); +// cell1.setCellValue(machiningParameterList.get(1)); +// XSSFCell cell2 = row.getCell(14); +// cell2.setCellValue(machiningParameterList.get(2)); +// XSSFCell cell3 = row.getCell(15); +// cell3.setCellValue(machiningParameterList.get(3)); +// XSSFCell cell4 = row.getCell(16); +// cell4.setCellValue(machiningParameterList.get(4)); +// } +// } +// // startRow = 18; +// // 合并单元格 +// if (rows > 10) { +// // 拆分合并单元格 +// unMerge(sheet, "A4"); +// // 拆分合并单元格 +// unMerge(sheet, "L1"); +// // 拆分合并单元格 +// unMerge(sheet, "M4"); +// // 合并单元格 +// int[] rowIndexs = new int[2 + rows - 1]; +// rowIndexs[0] = 3; +// rowIndexs[1] = 4; +// for (int i = 0; i < rows - 1; i++) { +// rowIndexs[i + 2] = i + 5; +// } +// // 合并单元格 +// int[] rowIndexs2 = new int[startRow + rows]; +//// rowIndexs2[0] = 3; +//// rowIndexs2[1] = 4; +// for (int i = 0; i < startRow + rows; i++) { +// rowIndexs2[i] = i; +// } +// // 合并单元格 +// int[] rowIndexs3 = new int[1 + rows]; +// rowIndexs3[0] = 3; +// for (int i = 0; i < rows; i++) { +// rowIndexs3[i + 1] = i + 4; +// } +// +// combine(sheet, rowIndexs, new int[] { 0, 1 }); +// combine(sheet, rowIndexs2, new int[] { 11 }); +// combine(sheet, rowIndexs3, new int[] { 12 }); +// startRow = 18 + rows - 10; +// } +// else +// { +// startRow = 18; +// } +// for (int i = 0; i < controlRequirementData.size(); i++) { +// +// XSSFRow row = null; +// Boolean isCreat = false; +// if (i == controlRequirementData.size() - 1) { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } else if (i > 9) { +// row = createRow(sheet, i + startRow); +// isCreat = true; +// } else { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } +// // XSSFRow row = sheet.getRow(i + startRow); +// if (isCreat) { +// XSSFRow oldRow = sheet.getRow(i + startRow - 1); +// for (int j = 0; j < 24; j++) { +// XSSFCell oldCell = oldRow.getCell(j); +// XSSFCell newCell = row.createCell(j); +// newCell.setCellStyle(oldCell.getCellStyle()); +// newCell.setCellType(oldCell.getCellType()); +// } +// // 合并单元格 +// combine(sheet, new int[] { i + startRow }, new int[] { 3, 4 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 6, 7 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 10, 11 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 13, 14}); +// combine(sheet, new int[] { i + startRow }, new int[] { 15, 16}); +// } +// +// List controlRequirementList = controlRequirementData.get(i); +// XSSFCell cell1 = row.getCell(2); +// cell1.setCellValue(controlRequirementList.get(1)); +// XSSFCell cell2 = row.getCell(3); +// cell2.setCellValue(controlRequirementList.get(2)); +// XSSFCell cell3 = row.getCell(5); +// cell3.setCellValue(controlRequirementList.get(3)); +// XSSFCell cell4 = row.getCell(6); +// cell4.setCellValue(controlRequirementList.get(4)); +// XSSFCell cell5 = row.getCell(8); +// cell5.setCellValue(controlRequirementList.get(5)); +// XSSFCell cell6 = row.getCell(9); +// cell6.setCellValue(controlRequirementList.get(6)); +// XSSFCell cell7 = row.getCell(10); +// cell7.setCellValue(controlRequirementList.get(7)); +// XSSFCell cell8 = row.getCell(12); +// cell8.setCellValue(controlRequirementList.get(8)); +// XSSFCell cell9 = row.getCell(13); +// cell9.setCellValue(controlRequirementList.get(9)); +// XSSFCell cell10 = row.getCell(15); +// cell10.setCellValue(controlRequirementList.get(10)); +// } +// +// //++++++ +// // 合并单元格 +// if (controlRequirementData.size() > 11) { +// // 拆分合并单元格 +// unMerge(sheet, "A" + (startRow - 2)); +// // 合并单元格 +// int[] rowIndexs = new int[3 + controlRequirementData.size()]; +// rowIndexs[0] = startRow - 3; +// rowIndexs[1] = startRow - 2; +// rowIndexs[1] = startRow - 1; +// for (int i = 0; i < controlRequirementData.size(); i++) { +// rowIndexs[i + 3] = i + startRow; +// } +// +// combine(sheet, rowIndexs, new int[] { 0, 1 }); +// } +// +// } else { +// return -1; +// } +//// //导出图 +//// if(outFilePathp!=null) { +//// insertPicture(wb, sheet, new ImageIcon(outFilePathp), "工序示意图",7,8); +//// new File(outFilePathp).delete(); +//// } +// FileOutputStream output = new FileOutputStream(new File(outFilePath)); // +// wb.write(output); +// output.close(); +// input.close(); +// +// System.out.println("-------WRITE EXCEL OVER-------"); +// +// return 0; +// } +// +// /** +// * 装配工艺卡 +// * +// * @param controlPlanBean 控制计划信息 +// * @param input 模版文件流 +// * @param outputFilePath 需要输出的全路径 +// * @throws IOException +// */ +// public static int writeAssembleProcessFormToExcel(JobProcessFormBean controlPlanBean, File file, String outFilePath +// ,TCComponentTcFile picFile,String outFilePathp) +// throws IOException { +// //导出图 +// if(outFilePathp!=null) { +// //第5行到底16行的总行高:0.49*12=5.88cm +// //第1列到8列的总列宽:14.56cm +// ExcelUtil.InsertTitlePicture(file,outFilePath,outFilePathp,new int[] {6,7,8,9,10,11,12,13,14,15,16,17}, +// new int[] {1,2,3,4,5,6,7,8},true,5.88,14.56,6,1); +// } +// File file1=new File(outFilePath); +// InputStream input = new FileInputStream(file1); +// +// XSSFWorkbook wb = new XSSFWorkbook(input);// ( +// XSSFSheet sheet = wb.getSheetAt(0); +// wb.removeSheetAt(wb.getActiveSheetIndex()); +// map.clear(); +// int startRow = 7; +// if (controlPlanBean != null) { +// // 添加单属性信息到excel表中 +// XSSFRow titleRow = sheet.getRow(0); +// setCellValue(titleRow, 3, controlPlanBean.getGsmc()); +// titleRow = sheet.getRow(1); +// setCellValue(titleRow, 9, controlPlanBean.getLjdh()); +// titleRow = sheet.getRow(2); +// setCellValue(titleRow, 9, controlPlanBean.getSbmc()); +// titleRow = sheet.getRow(3); +// setCellValue(titleRow, 9, controlPlanBean.getSbxh()); +// //setCellValue(titleRow, 13, " 下工序:"+controlPlanBean.getXdgx()); +// +// List> toolingDetailData = controlPlanBean.getToolingDetailData(); +// List> machiningParameterData = controlPlanBean.getMachiningParameterData(); +// List> controlRequirementData = controlPlanBean.getControlRequirementData(); +// for (int i = 0; i < toolingDetailData.size(); i++) { +// +// XSSFRow row = null; +// Boolean isCreat = false; +// if (i == toolingDetailData.size() - 1) { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } else if (i > 8) { +// row = createRow(sheet, i + startRow); +// isCreat = true; +// } else { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } +// // XSSFRow row = sheet.getRow(i + startRow); +// if (isCreat) { +// XSSFRow oldRow = sheet.getRow(i + startRow - 1); +// for (int j = 8; j < 17; j++) { +// XSSFCell oldCell = oldRow.getCell(j); +// XSSFCell newCell = row.createCell(j); +// newCell.setCellStyle(oldCell.getCellStyle()); +// newCell.setCellType(oldCell.getCellType()); +// } +// // 合并单元格 +// combine(sheet, new int[] { i + startRow }, new int[] { 9, 10 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 11, 12 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 13, 14, 15 }); +// } +// +// List toolingDetailList = toolingDetailData.get(i); +//// XSSFRow row = sheet.getRow(i + startRow); +// XSSFCell cell1 = row.getCell(8); +// cell1.setCellValue(toolingDetailList.get(1)); +// XSSFCell cell2 = row.getCell(9); +// cell2.setCellValue(toolingDetailList.get(2)); +// XSSFCell cell3 = row.getCell(11); +// cell3.setCellValue(toolingDetailList.get(3)); +// XSSFCell cell4 = row.getCell(13); +// cell4.setCellValue(toolingDetailList.get(4)); +// XSSFCell cell5 = row.getCell(16); +// cell5.setCellValue(toolingDetailList.get(5)); +// } +// startRow = 19; +// if (toolingDetailData.size() > 10) { +// // 拆分合并单元格 +// unMerge(sheet, "A5"); +// // 合并单元格 +// int[] rows = new int[2 + toolingDetailData.size()]; +// rows[0] = 4; +// rows[1] = 5; +// for (int i = 0; i < toolingDetailData.size(); i++) { +// rows[i + 2] = i + 6; +// } +// +// combine(sheet, rows, new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }); +// startRow = 19 + toolingDetailData.size() - 10; +// } +// for (int i = 0; i < machiningParameterData.size(); i++) { +// +// XSSFRow row = null; +// Boolean isCreat = false; +// if (i == machiningParameterData.size() - 1) { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } else if (i > 8) { +// row = createRow(sheet, i + startRow); +// isCreat = true; +// } else { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } +// // XSSFRow row = sheet.getRow(i + startRow); +// if (isCreat) { +// XSSFRow oldRow = sheet.getRow(i + startRow - 1); +// for (int j = 0; j < 17; j++) { +// XSSFCell oldCell = oldRow.getCell(j); +// XSSFCell newCell = row.createCell(j); +// newCell.setCellStyle(oldCell.getCellStyle()); +// newCell.setCellType(oldCell.getCellType()); +// } +// // 合并单元格 +// combine(sheet, new int[] { i + startRow }, new int[] { 0, 1 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 2, 3, 4, 5, 6, 7 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 8, 9, 10 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 11, 12, 13 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 14, 15, 16 }); +// } +// +// List machiningParameterList = machiningParameterData.get(i); +// XSSFCell cell1 = row.getCell(0); +// cell1.setCellValue(machiningParameterList.get(1)); +// XSSFCell cell2 = row.getCell(2); +// cell2.setCellValue(machiningParameterList.get(2)); +// XSSFCell cell3 = row.getCell(8); +// cell3.setCellValue(machiningParameterList.get(3)); +// XSSFCell cell4 = row.getCell(11); +// cell4.setCellValue(machiningParameterList.get(4)); +// XSSFCell cell5 = row.getCell(14); +// cell5.setCellValue(machiningParameterList.get(5)); +// } +// startRow = 33; +// if (toolingDetailData.size() > 10) { +// startRow = 33 + toolingDetailData.size() - 10; +// } +// if (machiningParameterData.size() > 10) { +// startRow = startRow + machiningParameterData.size() - 10; +// } +// for (int i = 0; i < controlRequirementData.size(); i++) { +// +// XSSFRow row = null; +// Boolean isCreat = false; +// if (i == controlRequirementData.size() - 1) { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } else if (i > 7) { +// row = createRow(sheet, i + startRow); +// isCreat = true; +// } else { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } +// // XSSFRow row = sheet.getRow(i + startRow); +// if (isCreat) { +// XSSFRow oldRow = sheet.getRow(i + startRow - 1); +// for (int j = 2; j < 17; j++) { +// XSSFCell oldCell = oldRow.getCell(j); +// XSSFCell newCell = row.createCell(j); +// newCell.setCellStyle(oldCell.getCellStyle()); +// newCell.setCellType(oldCell.getCellType()); +// } +// // 合并单元格 +// combine(sheet, new int[] { i + startRow }, new int[] { 3, 4 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 6, 7 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 10, 11 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 13, 14, 15, 16 }); +// } +// +// List controlRequirementList = controlRequirementData.get(i); +// XSSFCell cell1 = row.getCell(2); +// cell1.setCellValue(controlRequirementList.get(1)); +// XSSFCell cell2 = row.getCell(3); +// cell2.setCellValue(controlRequirementList.get(2)); +// XSSFCell cell3 = row.getCell(5); +// cell3.setCellValue(controlRequirementList.get(3)); +// XSSFCell cell4 = row.getCell(6); +// cell4.setCellValue(controlRequirementList.get(4)); +// XSSFCell cell5 = row.getCell(8); +// cell5.setCellValue(controlRequirementList.get(5)); +// XSSFCell cell6 = row.getCell(9); +// cell6.setCellValue(controlRequirementList.get(6)); +// XSSFCell cell7 = row.getCell(10); +// cell7.setCellValue(controlRequirementList.get(7)); +// XSSFCell cell8 = row.getCell(12); +// cell8.setCellValue(controlRequirementList.get(8)); +// XSSFCell cell9 = row.getCell(13); +// cell9.setCellValue(controlRequirementList.get(9)); +// } +// +// if (controlRequirementData.size() > 9) { +// // 拆分合并单元格 +// unMerge(sheet, "A" + startRow); +// // 合并单元格 +// int[] rows = new int[3 + controlRequirementData.size()]; +// rows[0] = startRow - 3; +// rows[1] = startRow - 2; +// rows[2] = startRow - 1; +// for (int i = 0; i < controlRequirementData.size(); i++) { +// rows[i + 3] = i + startRow; +// } +// +// combine(sheet, rows, new int[] { 0, 1 }); +// } +// +// } else { +// return -1; +// } +// +//// //导出图 +//// if(outFilePathp!=null) { +//// insertPicture(wb, sheet, new ImageIcon(outFilePathp), "工序示意图",8,8); +//// new File(outFilePathp).delete(); +//// } +// FileOutputStream output = new FileOutputStream(new File(outFilePath)); // +// wb.write(output); +// output.close(); +// input.close(); +// System.out.println("-------WRITE EXCEL OVER-------"); +// +// return 0; +// } +// +// /** +// * 检验基准书 +// * +// * @param controlPlanBean 控制计划信息 +// * @param input 模版文件流 +// * @param outputFilePath 需要输出的全路径 +// * @throws IOException +// */ +// public static int writeOperationReferenceBookToExcel(JobProcessFormBean controlPlanBean, File file, +// String outFilePath,TCComponentTcFile picFile,String outFilePathp) throws IOException { +// //导出图 +// if(outFilePathp!=null) { +// //第5行到底11行的总行高:6.3cm +// //第7列到14列的总列宽:15.31cm +// ExcelUtil.InsertTitlePicture(file,outFilePath,outFilePathp,new int[] {5,6,7,8,9,10,11}, +// new int[] {7,8,9,10,11,12,13,14},true,6.3,15.31,5,7); +// } +// File file1=new File(outFilePath); +// InputStream input = new FileInputStream(file1); +// +// XSSFWorkbook wb = new XSSFWorkbook(input);// ( +// XSSFSheet sheet = wb.getSheetAt(0); +// wb.removeSheetAt(wb.getActiveSheetIndex()); +// map.clear(); +// int startRow = 14; +// if (controlPlanBean != null) { +// // 添加单属性信息到excel表中 +// XSSFRow titleRow = sheet.getRow(0); +// setCellValue(titleRow, 3, controlPlanBean.getGsmc()); +// titleRow = sheet.getRow(1); +// setCellValue(titleRow, 10, controlPlanBean.getSbxh()); +// titleRow = sheet.getRow(2); +// setCellValue(titleRow, 10, controlPlanBean.getLjdh()); +// +// List> controlRequirementData = controlPlanBean.getControlRequirementData(); +// for (int i = 0; i < controlRequirementData.size(); i++) { +// List controlRequirementList = controlRequirementData.get(i); +// +// XSSFRow row = null; +// Boolean isCreat = false; +// if (i == controlRequirementData.size() - 1) { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } else if ((i + startRow) > sheet.getLastRowNum() - 2) { +// row = createRow(sheet, i + startRow); +// isCreat = true; +// } else { +// row = sheet.getRow(i + startRow); +// isCreat = false; +// } +// // XSSFRow row = sheet.getRow(i + startRow); +// if (isCreat) { +// XSSFRow oldRow = sheet.getRow(i + startRow - 1); +// for (int j = 0; j < 14; j++) { +// XSSFCell oldCell = oldRow.getCell(j); +// XSSFCell newCell = row.createCell(j); +// newCell.setCellStyle(oldCell.getCellStyle()); +// newCell.setCellType(oldCell.getCellType()); +// } +// // 合并单元格 +// combine(sheet, new int[] { i + startRow }, new int[] { 0, 1 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 3, 4 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 6, 7 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 8, 9 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 12, 13 }); +// } +// +// XSSFCell cell1 = row.getCell(0); +// cell1.setCellValue(controlRequirementList.get(1)); +// XSSFCell cell2 = row.getCell(2); +// cell2.setCellValue(controlRequirementList.get(2)); +// XSSFCell cell3 = row.getCell(3); +// cell3.setCellValue(controlRequirementList.get(3)); +// XSSFCell cell4 = row.getCell(5); +// cell4.setCellValue(controlRequirementList.get(4)); +// XSSFCell cell5 = row.getCell(6); +// cell5.setCellValue(controlRequirementList.get(5)); +// XSSFCell cell6 = row.getCell(8); +// cell6.setCellValue(controlRequirementList.get(6)); +// XSSFCell cell7 = row.getCell(10); +// cell7.setCellValue(controlRequirementList.get(7)); +// XSSFCell cell8 = row.getCell(11); +// cell8.setCellValue(controlRequirementList.get(8)); +// XSSFCell cell9 = row.getCell(12); +// cell9.setCellValue(controlRequirementList.get(9)); +// } +// +// } else { +// return -1; +// } +// +//// //导出图 +//// if(outFilePathp!=null) { +//// insertPicture(wb, sheet, new ImageIcon(outFilePathp), "工序示意图",8,7); +//// new File(outFilePathp).delete(); +//// } +// FileOutputStream output = new FileOutputStream(new File(outFilePath)); // +// wb.write(output); +// output.close(); +// input.close(); +// System.out.println("-------WRITE EXCEL OVER-------"); +// +// return 0; +// } +// +// /** +// * 找到需要插入的行数,并新建一个POI的row对象 +// * +// * @param sheet +// * @param rowIndex +// * @return +// */ +// private static XSSFRow createRow(XSSFSheet sheet, Integer rowIndex) { +// XSSFRow row = null; +// if (sheet.getRow(rowIndex) != null) { +// int lastRowNo = sheet.getLastRowNum(); +// sheet.shiftRows(rowIndex, lastRowNo, 1); +// } +// row = sheet.createRow(rowIndex); +// return row; +// } +// +// private static void unMerge(XSSFSheet sheet, String cellName) { +// // 从第C1开始,拆分单元格 +// CellReference ref = new CellReference(cellName); +// // 遍历sheet中的所有的合并区域 +// for (int i = sheet.getNumMergedRegions() - 1; i >= 0; i--) { +// String value = ""; +// CellRangeAddress region = sheet.getMergedRegion(i); +// Row firstRow = sheet.getRow(region.getFirstRow()); +// Cell firstCellOfFirstRow = firstRow.getCell(region.getFirstColumn()); +// // 如果第一个单元格的是字符串 +// if (firstCellOfFirstRow.getCellType() == Cell.CELL_TYPE_STRING) { +// value = firstCellOfFirstRow.getStringCellValue(); +// } +// // 判断到C1才进行拆分单元格 +// if (region.getFirstRow() == ref.getRow() && region.getFirstColumn() == ref.getCol()) { +// sheet.removeMergedRegion(i); +// } +// // 设置第一行的值为,拆分后的每一行的值 +// for (Row row : sheet) { +// for (Cell cell : row) { +// if (region.isInRange(cell.getRowIndex(), cell.getColumnIndex())) { +// cell.setCellType(Cell.CELL_TYPE_STRING); +// cell.setCellValue(value); +// } +// } +// } +// } +// } +// +///** +// * 导出包装方案 +// * @throws IOException +// * +// * +// */ +// public static int writePackagingSchemeToExcel(List mainValueData,List> TableDatas +// ,File file,String outFilePath) throws IOException { +// InputStream input = new FileInputStream(file); +// FileOutputStream output = new FileOutputStream(new File(outFilePath)); // +// XSSFWorkbook wb = new XSSFWorkbook(input);// ( +// XSSFSheet sheet = wb.getSheetAt(0); +// map.clear(); +// if(mainValueData!=null||TableDatas!=null){ +// //零件主属性 +// XSSFRow titleRow = sheet.getRow(2); +// setCellValue(titleRow, 2, mainValueData.get(0)); +// titleRow = sheet.getRow(3); +// setCellValue(titleRow, 2, mainValueData.get(1)); +// titleRow = sheet.getRow(4); +// setCellValue(titleRow, 2, mainValueData.get(2)); +// titleRow = sheet.getRow(5); +// setCellValue(titleRow, 2, mainValueData.get(3)); +// titleRow = sheet.getRow(6); +// setCellValue(titleRow, 2, mainValueData.get(4)); +// titleRow = sheet.getRow(7); +// setCellValue(titleRow, 2, mainValueData.get(5)); +// titleRow = sheet.getRow(8); +// setCellValue(titleRow, 2, mainValueData.get(6)); +// titleRow = sheet.getRow(9); +// setCellValue(titleRow, 2, mainValueData.get(7)); +// titleRow = sheet.getRow(24); +// setCellValue(titleRow, 2, mainValueData.get(8)); +// titleRow = sheet.getRow(25); +// setCellValue(titleRow, 2, mainValueData.get(9)); +// +// //打印表格数据 +// for(int i=0;i lineList=TableDatas.get(i); +// titleRow=sheet.getRow(12+i); +// setCellValue(titleRow, 2, lineList.get(2)); +// setCellValue(titleRow, 3, lineList.get(3)); +// setCellValue(titleRow, 4, lineList.get(4)); +// } +// } +// +// wb.write(output); +// output.close(); +// input.close(); +// return 0; +// } + +} diff --git a/src/com/connor/renben/process/plm/util/ImageFilter.java b/src/com/connor/renben/process/plm/util/ImageFilter.java new file mode 100644 index 0000000..114ac2c --- /dev/null +++ b/src/com/connor/renben/process/plm/util/ImageFilter.java @@ -0,0 +1,32 @@ +package com.connor.renben.process.plm.util; +import java.io.File; + +import javax.swing.filechooser.FileFilter; + +public class ImageFilter extends FileFilter { + + public boolean accept(File f) { + if (f.isDirectory()) { + return true; + } + String fileName = f.getName(); + int index = fileName.lastIndexOf('.'); + String extension = ""; + if (index > 0 && index < fileName.length() - 1) { + extension = fileName.substring(index + 1).toLowerCase(); + } + if (extension != null) { + if (extension.equals("gif") || extension.equals("jpeg") + || extension.equals("jpg") || extension.equals("png")) { + return true; + } else { + return false; + } + } + return false; + } + + public String getDescription() { + return "图片文件(*.jpg, *.jpeg, *.gif, *.png)"; + } +} \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/util/JAutoCompleteComboBox.java b/src/com/connor/renben/process/plm/util/JAutoCompleteComboBox.java new file mode 100644 index 0000000..2c34960 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/JAutoCompleteComboBox.java @@ -0,0 +1,155 @@ +package com.connor.renben.process.plm.util; + +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.util.List; +import java.util.Vector; + +import javax.swing.ComboBoxModel; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JComboBox; +import javax.swing.JTextField; + +public class JAutoCompleteComboBox extends JComboBox { + private AutoCompleter completer; + + public JAutoCompleteComboBox() { + super(); + addCompleter(); + } + + public JAutoCompleteComboBox(ComboBoxModel cm) { + super(cm); + addCompleter(); + } + + public JAutoCompleteComboBox(Object[] items) { + super(items); + addCompleter(); + } + + public JAutoCompleteComboBox(List v) { + super((Vector) v); + addCompleter(); + } + + private void addCompleter() { + setEditable(true); + completer = new AutoCompleter(this); + } + + public void autoComplete(String str) { + this.completer.autoComplete(str, str.length()); + } + + public String getText() { + return ((JTextField) getEditor().getEditorComponent()).getText(); + } + + public void setText(String text) { + ((JTextField) getEditor().getEditorComponent()).setText(text); + } + + public boolean containsItem(String itemString) { + for (int i = 0; i < this.getModel().getSize(); i++) { + String _item = " " + this.getModel().getElementAt(i); + if (_item.equals(itemString)) + return true; + } + return false; + } + +} + +class AutoCompleter implements KeyListener, ItemListener { + + private JComboBox owner = null; + private JTextField editor = null; + + private ComboBoxModel model = null; + + public AutoCompleter(JComboBox comboBox) { + owner = comboBox; + editor = (JTextField) comboBox.getEditor().getEditorComponent(); + editor.addKeyListener(this); + model = comboBox.getModel(); + owner.addItemListener(this); + } + + public void keyTyped(KeyEvent e) { + } + + public void keyPressed(KeyEvent e) { + } + + public void keyReleased(KeyEvent e) { + char ch = e.getKeyChar(); + // if (ch == KeyEvent.CHAR_UNDEFINED || Character.isISOControl(ch) + // || ch == KeyEvent.VK_DELETE) + // return; + if (e.getKeyCode() == KeyEvent.VK_ENTER) { + int caretPosition = editor.getCaretPosition(); + String str = editor.getText(); + if (str.length() == 0) + return; + autoComplete(str, caretPosition); + } + } + + protected void autoComplete(String strf, int caretPosition) { + Object[] opts; + opts = getMatchingOptions(strf.substring(0, caretPosition)); + if (owner != null) { + model = new DefaultComboBoxModel(opts); + owner.setModel(model); + } + if (opts.length > 0) { + String str = opts[0].toString(); + editor.setCaretPosition(caretPosition); + if (owner != null) { + try { + owner.showPopup(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + } + } + + protected Object[] getMatchingOptions(String str) { + List v = new Vector(); + List v1 = new Vector(); + //v.add(str); + for (int k = 0; k < model.getSize(); k++) { + Object itemObj = model.getElementAt(k); + if (itemObj != null) { + String item = itemObj.toString().toLowerCase(); + if (item.indexOf((str.toLowerCase())) > -1) + v.add(model.getElementAt(k)); + else + v1.add(model.getElementAt(k)); + } else + v1.add(model.getElementAt(k)); + } + for (int i = 0; i < v1.size(); i++) { + v.add(v1.get(i)); + } + // if (v.isEmpty()) + return v.toArray(); + } + + public void itemStateChanged(ItemEvent event) { + if (event.getStateChange() == ItemEvent.SELECTED) { + int caretPosition = editor.getCaretPosition(); + if (caretPosition != -1) { + try { + editor.moveCaretPosition(caretPosition); + } catch (IllegalArgumentException ex) { + ex.printStackTrace(); + } + } + } + } +} \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/util/MultiComboBox.java b/src/com/connor/renben/process/plm/util/MultiComboBox.java new file mode 100644 index 0000000..bc5f197 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/MultiComboBox.java @@ -0,0 +1,219 @@ +package com.connor.renben.process.plm.util; +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Graphics; +import java.awt.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(150,30)); +// editor.setBorder(getBorder()); + editor.addMouseListener(new EditorHandler()); + arrowButton = createArrowButton(); + arrowButton.addMouseListener(new EditorHandler()); + + add("1.1.left.top",editor); + //add(arrowButton); + setText() ; + + + } + + public Object[] getSelectedValues() { + return popup.getSelectedValues(); + } + + public void addActionListener(ActionListener listener) { + if (!listeners.contains(listener)) + listeners.add(listener); + } + + public void removeActionListener(ActionListener listener) { + if (listeners.contains(listener)) + listeners.remove(listener); + } + + protected void fireActionPerformed(ActionEvent e) { + for (ActionListener l : listeners) { + l.actionPerformed(e); + } + } + + private class PopupAction implements ActionListener{ + + public void actionPerformed(ActionEvent e) { + + if(e.getActionCommand().equals(MultiPopup.CANCEL_EVENT)){ + + }else if(e.getActionCommand().equals(MultiPopup.COMMIT_EVENT)){ + defaultValues = popup.getSelectedValues(); + setText(); + //把事件继续传递出去 + fireActionPerformed(e); + } + + togglePopup(); + + + } + + } + + private void togglePopup(){ + if(popup.isVisible()){ + popup.setVisible(false); + }else{ + popup.setDefaultValue(defaultValues); + popup.show(this, 0, getHeight()); + } + } + + private void setText() { + StringBuilder builder = new StringBuilder(); + for(Object dv : defaultValues){ + builder.append(dv); + builder.append(valueSperator); + } + + editor.setText(builder.substring(0, builder.length() > 0 ? builder.length() -1 : 0).toString()); + } + + private class EditorHandler implements MouseListener{ + + public void mouseClicked(MouseEvent e) { + togglePopup(); + } + + public void mousePressed(MouseEvent e) { + + } + + public void mouseReleased(MouseEvent e) { + + } + + public void mouseEntered(MouseEvent e) { + + } + + public void mouseExited(MouseEvent e) { + + } + + } + + + public void paintComponent(Graphics g){ + g.setColor(Color.white); + g.fillRect(0,0,getWidth(),getHeight()); + } + + + protected JButton createArrowButton() { + JButton button = new BasicArrowButton(BasicArrowButton.SOUTH, + UIManager.getColor("ComboBox.buttonBackground"), + UIManager.getColor("ComboBox.buttonShadow"), + UIManager.getColor("ComboBox.buttonDarkShadow"), + UIManager.getColor("ComboBox.buttonHighlight")); + button.setName("ComboBox.arrowButton"); + return button; + } + + private class MulitComboboxLayout implements LayoutManager{ + + public void addLayoutComponent(String name, Component comp) { + // TODO Auto-generated method stub + + } + + public void removeLayoutComponent(Component comp) { + // TODO Auto-generated method stub + + } + + public Dimension preferredLayoutSize(Container parent) { + return parent.getPreferredSize(); + } + + public Dimension minimumLayoutSize(Container parent) { + return parent.getMinimumSize(); + } + + public void layoutContainer(Container parent) { + int w=parent.getWidth(); + int h=parent.getHeight(); + Insets insets=parent.getInsets(); + h=h-insets.top-insets.bottom; + + } + + } + +} + + diff --git a/src/com/connor/renben/process/plm/util/MultiComboBox2.java b/src/com/connor/renben/process/plm/util/MultiComboBox2.java new file mode 100644 index 0000000..5b6c7d0 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/MultiComboBox2.java @@ -0,0 +1,260 @@ +//package com.connor.renben.process.plm.util; +//import java.awt.Color; +//import java.awt.Component; +//import java.awt.Container; +//import java.awt.Dimension; +//import java.awt.FlowLayout; +//import java.awt.Graphics; +//import java.awt.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.JFrame; +//import javax.swing.JPanel; +//import javax.swing.JPopupMenu; +//import javax.swing.JScrollPane; +//import javax.swing.JTextArea; +//import javax.swing.JTextField; +//import javax.swing.UIManager; +//import javax.swing.plaf.basic.BasicArrowButton; +// +//import org.eclipse.swt.SWT; +//import org.eclipse.swt.custom.ScrolledComposite; +//import org.jacorb.idl.runtime.int_token; +// +//import com.teamcenter.rac.util.PropertyLayout; +// +//import cn.com.origin.autocode.newitem.generatcode.BorderLayout; +// +///** +// * 下拉复选框组件 +// * +// */ +//public class MultiComboBox2 extends JComponent implements ActionListener { +// +// private String[] values; +// private MultiPopup popup; +// private JTextArea editor; +// protected JButton arrowButton; +// private String[] selectName=null; +// +// public MultiComboBox2(String[] value) { +// values = value; +// initComponent(); +// } +// +// private void initComponent() { +// popup = new MultiPopup(values); +// editor = new JTextArea(); +// editor.setBackground(Color.WHITE); +// editor.setEditable(false); +// //editor.setPreferredSize(new Dimension(300, 100)); +// //editor.addActionListener(this); +// JScrollPane jslp2 = new JScrollPane(); // 给jta加滚动条 +// jslp2.setPreferredSize(new Dimension(300, 100)); +// jslp2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); +// jslp2.getVerticalScrollBar().setUnitIncrement(25); +// jslp2.setViewportView(editor); +// +// arrowButton = createArrowButton(); +// arrowButton.addActionListener(this); +// +// this.setLayout(new PropertyLayout()); +// +// add("1.1.left.top",jslp2); +// add("1.2.left.top",arrowButton); +// } +// +// //获取选中的数据 +// public Object[] getSelectedValues() { +// return popup.getSelectedValues(); +// } +// +// //设置需要选中的值 +// public void setSelectValues(Object[] selectvalues) { +// popup.setSelectValues(selectvalues); +// setText(selectvalues); +// } +// +// private void setText(Object[] values) { +// if (values.length > 0) { +// String value = Arrays.toString(values); +// value = value.replace("[", ""); +// value = value.replace("]", ""); +// String[] vtrings=value.split(","); +// selectName=vtrings; +// String vString=""; +// for(int i=0;i checkBoxList = new ArrayList(); +// private JButton commitButton; +// private JButton cancelButton; +// +// public MultiPopup(Object[] value) { +// super(); +// values = value; +// initComponent(); +// } +// +// private void initComponent() { +// JPanel checkboxPane = new JPanel(); +// JPanel buttonPane = new JPanel(); +// //this.setLayout(new BorderLayout()); +// this.setLayout(new PropertyLayout()); +// for (Object v : values) { +// JCheckBox temp = new JCheckBox(v.toString()); +// checkBoxList.add(temp); +// } +// +// if (checkBoxList.get(0).getText().equals("全选")) { +// checkBoxList.get(0).addItemListener(new ItemListener() { +// public void itemStateChanged(ItemEvent e) { +// if (checkBoxList.get(0).isSelected()) { +// 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); +// } +// JScrollPane jslp2 = new JScrollPane(); // 给jta加滚动条 +// jslp2.setPreferredSize(new Dimension(500, 200)); +// jslp2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); +// jslp2.getVerticalScrollBar().setUnitIncrement(25); +// jslp2.setViewportView(checkboxPane); +// +// commitButton = new JButton("确定"); +// commitButton.addActionListener(this); +// +// cancelButton = new JButton("取消"); +// cancelButton.addActionListener(this); +// +// buttonPane.add(commitButton); +// buttonPane.add(cancelButton); +//// this.add(checkboxPane, BorderLayout.CENTER); +//// this.add(buttonPane, BorderLayout.SOUTH); +// this.add("1.1.left.top",jslp2); +// this.add("2.1.left.top",buttonPane); +// +// } +// +// public void setSelectValues(Object[] values) { +// if (values.length > 0) { +// for (int i = 0; i < values.length; i++) { +// for (int j = 0; j < checkBoxList.size(); j++) { +// if (values[i].equals(checkBoxList.get(j).getText())) { +// checkBoxList.get(j).setSelected(true); +// } +// } +// } +// setText(getSelectedValues()); +// } +// } +// +// +// public Object[] getSelectedValues() { +// List selectedValues = new ArrayList(); +// +// if (checkBoxList.get(0).getText().equals("全选")) { +// 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()]); +// } +// +// +// +// @Override +// public void actionPerformed(ActionEvent arg0) { +// // TODO Auto-generated method stub +// Object source = arg0.getSource(); +// if (source instanceof JButton) { +// JButton button = (JButton) source; +// if (button.equals(commitButton)) { +// setText(getSelectedValues()); +// popup.setVisible(false); +// } else if (button.equals(cancelButton)) { +// popup.setVisible(false); +// } +// } +// } +// +// } +//} \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/util/MultiPopup.java b/src/com/connor/renben/process/plm/util/MultiPopup.java new file mode 100644 index 0000000..49de43e --- /dev/null +++ b/src/com/connor/renben/process/plm/util/MultiPopup.java @@ -0,0 +1,190 @@ +package com.connor.renben.process.plm.util; +import java.awt.BorderLayout; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.util.ArrayList; +import java.util.List; + + + +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; + +public class MultiPopup extends JPopupMenu { + + private List listeners = new ArrayList(); + + private Object[] values; + + private Object[] defaultValues; + + private List checkBoxList = new ArrayList(); + + private JButton commitButton ; + + private JButton cancelButton; + + public static final String COMMIT_EVENT = "commit"; + + public static final String CANCEL_EVENT = "cancel"; + + public MultiPopup(Object[] value , Object[] defaultValue) { + super(); + values = value; + defaultValues = defaultValue; + initComponent(); + } + + public void addActionListener(ActionListener listener) { + if (!listeners.contains(listener)) + listeners.add(listener); + } + + public void removeActionListener(ActionListener listener) { + if (listeners.contains(listener)) + listeners.remove(listener); + } + + private void initComponent() { + + JPanel checkboxPane = new JPanel(); + + JPanel buttonPane = new JPanel(); + + this.setLayout(new BorderLayout()); + + + for(Object v : values){ + JCheckBox temp = new JCheckBox(v.toString() , selected(v)); + checkBoxList.add(temp); + } + + if(checkBoxList.get(0).getText().equals("Selected All")) + checkBoxList.get(0).addItemListener(new ItemListener() + { + public void itemStateChanged(ItemEvent e) + { + System.out.println("被选中状态 "+checkBoxList.get(0).isSelected()); + if(checkBoxList.get(0).isSelected())//Select All 被选中 + { + //检查其他的是否被选中乳沟没有就选中他们 + for(int i=1; i< checkBoxList.size();i++) + { + if(!checkBoxList.get(i).isSelected()) + checkBoxList.get(i).setSelected(true); + } + } + else + { + for(int i=1; i< checkBoxList.size();i++) + { + if(checkBoxList.get(i).isSelected()) + checkBoxList.get(i).setSelected(false); + } + } + } + }); + + + + checkboxPane.setLayout(new GridLayout(checkBoxList.size() , 1 ,3, 3)); + for(JCheckBox box : checkBoxList){ + checkboxPane.add(box); + } + + commitButton = new JButton("ok"); + + commitButton.addActionListener(new ActionListener(){ + + public void actionPerformed(ActionEvent e) { + commit(); + } + + }); + + cancelButton = new JButton("cancel"); + + cancelButton.addActionListener(new ActionListener(){ + + public void actionPerformed(ActionEvent e) { + cancel(); + } + + }); + + buttonPane.add(commitButton); + + buttonPane.add(cancelButton); + + this.add(checkboxPane , BorderLayout.CENTER); + + this.add(buttonPane , BorderLayout.SOUTH); + + + } + + private boolean selected(Object v) { + for(Object dv : defaultValues){ + if( dv .equals(v) ){ + return true; + } + } + return false; + } + + protected void fireActionPerformed(ActionEvent e) { + for (ActionListener l : listeners) { + l.actionPerformed(e); + } + } + + public Object[] getSelectedValues(){ + List selectedValues = new ArrayList(); + + if(checkBoxList.get(0).getText().equals("Selected All")) + { + if(checkBoxList.get(0).isSelected()) + { + for(int i = 1 ; i < checkBoxList.size() ; i++) + { + selectedValues.add(values[i]); + } + } + else + { + for(int i = 1 ; i < checkBoxList.size() ; i++){ + + if(checkBoxList.get(i).isSelected()) + selectedValues.add(values[i]); + } + } + }else + for(int i = 0 ; i < checkBoxList.size() ; i++){ + + if(checkBoxList.get(i).isSelected()) + selectedValues.add(values[i]); + } + + + return selectedValues.toArray(new Object[selectedValues.size()]); + } + + public void setDefaultValue(Object[] defaultValue) { + defaultValues = defaultValue; + + } + + public void commit(){ + fireActionPerformed(new ActionEvent(this, 0, COMMIT_EVENT)); + } + + public void cancel(){ + fireActionPerformed(new ActionEvent(this, 0, CANCEL_EVENT)); + } + +} diff --git a/src/com/connor/renben/process/plm/util/MyComboBox.java b/src/com/connor/renben/process/plm/util/MyComboBox.java new file mode 100644 index 0000000..80d8fb8 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/MyComboBox.java @@ -0,0 +1,66 @@ +package com.connor.renben.process.plm.util; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Vector; + +import javax.swing.JComboBox; +import javax.swing.SwingUtilities; + +public class MyComboBox extends JComboBox implements ActionListener { + public MyComboBox() { + addItem(new CheckValue(false,"Select All")); + this.addActionListener( + new ActionListener() { + + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + itemSelected(); + } + }); + } + private void itemSelected(){ + if(getSelectedItem() instanceof CheckValue){ + if(getSelectedIndex() == 0){ + selectedAllItem(); + } else { + CheckValue jcb = (CheckValue) getSelectedItem(); + jcb.bolValue = (!jcb.bolValue); + setSelectedIndex((getSelectedIndex())); + } + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + //閫変腑鍚庝緷鐒朵繚鎸佸綋鍓嶅脊鍑虹姸鎬? + showPopup(); + + } + }); + } + } + + private void selectedAllItem(){ + boolean bl=false; + for (int i = 0; i < getItemCount(); i++) { + CheckValue jcb = (CheckValue) getItemAt(i); + if(i == 0) { + bl = !jcb.bolValue; + } + jcb.bolValue = (bl); + } + setSelectedIndex(0); + } + + public Vector getComboVc() { + Vector vc = new Vector(); + for (int i = 0; i < getItemCount(); i++) { + CheckValue jcb = (CheckValue) getItemAt(i); + if(jcb.bolValue) { + vc.add(jcb.value); + } + } + return vc; + } +} diff --git a/src/com/connor/renben/process/plm/util/MyTableModel.java b/src/com/connor/renben/process/plm/util/MyTableModel.java new file mode 100644 index 0000000..319522c --- /dev/null +++ b/src/com/connor/renben/process/plm/util/MyTableModel.java @@ -0,0 +1,48 @@ +package com.connor.renben.process.plm.util; + +import java.util.Vector; + +import javax.swing.table.DefaultTableModel; + +/** + * 自定义JTable + * + * @author Administrator + * + */ +public class MyTableModel extends DefaultTableModel { + + public MyTableModel(Object[][] values, Object[] titleNames) { + super(values, titleNames); + } + + public MyTableModel(Vector values, Vector titleNames) { + super(values, titleNames); + } + + + // 重写getColumnClass方法,根据每列的第一个值返回该列真实的数据类型 + @Override + public Class getColumnClass(int columnIndex) { + + Object ob = getValueAt(0, columnIndex); + if (ob == null) { + String bb = ""; + return bb.getClass(); + } else { + return getValueAt(0, columnIndex).getClass(); + } + } + + @Override + public Object getValueAt(int i, int j) { + // TODO Auto-generated method stub + Vector rowValue = (Vector) this.dataVector.get(i); + return rowValue.get(j); + } + + public boolean isCellEditable(int rowIndex, int columnIndex) { + return false; + } + +} diff --git a/src/com/connor/renben/process/plm/util/ParseXMLUtil.java b/src/com/connor/renben/process/plm/util/ParseXMLUtil.java new file mode 100644 index 0000000..50f650a --- /dev/null +++ b/src/com/connor/renben/process/plm/util/ParseXMLUtil.java @@ -0,0 +1,143 @@ +//package com.connor.renben.process.plm.util; +// +//import java.io.File; +//import java.util.ArrayList; +//import java.util.HashMap; +//import java.util.Iterator; +//import java.util.List; +//import java.util.Map; +// +// +//import org.dom4j.Document; +//import org.dom4j.Element; +//import org.dom4j.io.SAXReader; +// +//import com.teamcenter.rac.kernel.TCComponentDataset; +//import com.teamcenter.rac.kernel.TCComponentTcFile; +//import com.teamcenter.rac.kernel.TCException; +//import com.teamcenter.rac.kernel.TCPreferenceService; +//import com.teamcenter.rac.kernel.TCSession; +//import com.teamcenter.rac.util.MessageBox; +///** +// * xml解析类 +// * @author wangc +// * +// */ +//public class ParseXMLUtil { +// +// /** +// * 解析编码规则XML +// * @param file +// */ +// public Map> parseXMLCode(File file) { +// Map> attrMap = new HashMap>(); +// List typelist = new ArrayList(); +// List namelist = new ArrayList(); +// List markList = new ArrayList(); +// List valueList = new ArrayList(); +// try { +// SAXReader saxReader = new SAXReader(); +// Document document = saxReader.read(file); +// Element root = document.getRootElement(); +// Iterator iter = root.elementIterator("largeclass");// largeclass标签 +// while (iter.hasNext()) { +// Element recordEle = (Element) iter.next(); +// Iterator iter2 = recordEle.elementIterator("subclass");// subclass标签 +// while (iter2.hasNext()) { +// Element recordEle2 = (Element) iter2.next(); +// String type = recordEle2.attributeValue("type"); +// System.out.println("Type===================="+type); +// typelist.add(type); +// Iterator iter3 = recordEle2.elementIterator("prop");// prop标签 +// StringBuilder sb = new StringBuilder(); +// StringBuilder sb1 = new StringBuilder(); +// StringBuilder sb2 = new StringBuilder(); +// while (iter3.hasNext()) { +// Element recordEle3 = (Element) iter3.next(); +// String name = recordEle3.attributeValue("attrName"); +// String mark = recordEle3.attributeValue("mark"); +// String value = recordEle3.attributeValue("value"); +// System.out.println("value====="+value); +// if(mark == null || "".equals(mark)) { +// mark = " "; +// } +// if(value == null || "".equals(value)) { +// value = " "; +// } +// sb.append(name); +// sb1.append(mark); +// sb2.append(value); +// sb.append(";"); +// sb1.append(";"); +// sb2.append(";"); +// } +// namelist.add(sb.toString()); +// markList.add(sb1.toString()); +// valueList.add(sb2.toString()); +// } +// } +// +// } catch (Exception e) { +// e.printStackTrace(); +// } +// for (int i = 0; i < typelist.size(); i++) { +// List nameMarkList = new ArrayList(); +// nameMarkList.add(namelist.get(i)); +// nameMarkList.add(markList.get(i)); +// nameMarkList.add(valueList.get(i)); +// attrMap.put(typelist.get(i), nameMarkList); +// } +// return attrMap; +// } +// +// /** +// * 通过首选项里的Uid获得文件 +// * @param pernaem 首选项名称 +// * @param session session +// * @return +// */ +// public File getSXX(String pernaem,TCSession session) { +// TCPreferenceService pref = session.getPreferenceService(); +// String puid = pref.getStringValue(pernaem);// 首选项查puid +// if (puid != null) { +// try { +// TCComponentDataset dataset = (TCComponentDataset) session +// .stringToComponent(puid); +// if (dataset == null) { +// return null; +// } +// TCComponentTcFile[] file = dataset.getTcFiles(); +// if (file.length == 0 || file.length != 1) { +// MessageBox.post("数据集没有命名引用的文件或文件过多,请检查!", "WARNING", +// MessageBox.WARNING); +// return null; +// } else { +// File fmsFile = file[0].getFmsFile(); +// return fmsFile; +// } +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// +// } else { +// MessageBox.post("未找到首选项["+pernaem+"]或首选项配置错误", "错误", +// MessageBox.ERROR); +// return null; +// } +// return null; +// } +// +//// /** +//// * 单例测试 +//// * @param args +//// */ +//// public static void main(String[] args) { +//// // TODO Auto-generated method stub +//// File file = new File("C:\\Users\\wangc\\Desktop\\测试\\人本产品号拼接方式V1.xml"); +//// //File file2 = new File("D:\\2.xml"); +//// ParseXMLUtil t = new ParseXMLUtil(); +//// // t.parseXML(file); +//// t.parseXMLCode(file); +//// } +//} diff --git a/src/com/connor/renben/process/plm/util/PosParamCellEditor.java b/src/com/connor/renben/process/plm/util/PosParamCellEditor.java new file mode 100644 index 0000000..0294b65 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/PosParamCellEditor.java @@ -0,0 +1,37 @@ +package com.connor.renben.process.plm.util; + +import java.awt.Component; + +import javax.swing.DefaultCellEditor; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.JTextField; + +public class PosParamCellEditor extends DefaultCellEditor { + + public PosParamCellEditor(JComboBox box) { + super(box); + } + + public PosParamCellEditor(JCheckBox chb) { + super(chb); + } + + public PosParamCellEditor(JTextField txt) { + super(txt); + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, + boolean isSelected, int row, int column) { + // TODO 当单元格处于编辑状态时 + if (column == 1) { + return new JTextArea(); + } + return super.getTableCellEditorComponent(table, value, isSelected, row, + column); + } + +} diff --git a/src/com/connor/renben/process/plm/util/ProgressBar.java b/src/com/connor/renben/process/plm/util/ProgressBar.java new file mode 100644 index 0000000..85094d9 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/ProgressBar.java @@ -0,0 +1,138 @@ +package com.connor.renben.process.plm.util; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.Registry; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.event.*; +import javax.swing.*; + +import org.eclipse.swt.graphics.Rectangle; + +public class ProgressBar extends AbstractAIFDialog implements ActionListener { + /** + * 内部类,线程任务 + * + * @author Administrator + * + */ + class TaskThread extends Thread { + + public void run() { + + Dimension d = progressbar.getSize(); + bar.paintAll(bar.getGraphics()); + // Rectangle rect = new Rectangle(0,0, d.width, d.height); + for (int i = 0; i < i + 1; i++) { + // 启动线程 + timer.start(); + int value = progressbar.getValue(); + // 让进度条分为100格,以每秒进5格 + if (value < 100) { + value += 5; + progressbar.setValue(value); + + } else { + // 计时器停止,重新开始加载 + timer.stop(); + progressbar.setValue(0); + bar.paintAll(bar.getGraphics()); + } + progressbar.paintImmediately(0, 0, d.width, d.height); + try { + // 线程停止100毫秒 + sleep(100L); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (bool) { + // 设置进度条的可见或者不可见 + bar.setVisible(false); + bar.dispose(); + return; + } + } + + } + + private ProgressBar bar; + + final ProgressBar this$0; + + // 将线程添加到任务中 + public TaskThread(ProgressBar bar) { + super(); + this$0 = ProgressBar.this; + this.bar = bar; + } + } + + public ProgressBar(String showlable) { + super(true); + bool = false; + showLable = null; + showLable = showlable; + } + + public void setBool(boolean bool) { + this.bool = bool; + } + + /** + * 构造进度条的面板 + * + */ + public void initUI() { + Container container = getContentPane(); + JPanel mainPanel = new JPanel(new PropertyLayout()); + label = new JLabel(showLable, 0); + progressbar = new JProgressBar(); + progressbar.setOrientation(0); + // 进度条从0开始,100结束 + progressbar.setMinimum(0); + progressbar.setMaximum(100); + progressbar.setValue(0); + progressbar.setPreferredSize(new Dimension(200, 15)); + progressbar.setBorderPainted(true); + // 启动计时器 + timer = new Timer(50, this); + timer.setRepeats(false); + // 控件的调整 + mainPanel.add("1.1.center", new JLabel(" ")); + mainPanel.add("2.1.center", label); + mainPanel.add("3.1.center", progressbar); + mainPanel.add("4.1.center", new JLabel(" ")); + container.add(mainPanel); + pack(); + setLocation(500, 200); + // 线程任务启动 + TaskThread thread = new TaskThread(this); + thread.start(); + // 内部类,监听关闭按钮的事件 + addWindowListener(new WindowAdapter() { + + public void windowClosing(WindowEvent e) { + bool = true; + } + + }); + setVisible(true); + } + + public void actionPerformed(ActionEvent actionevent) { + } + + private JProgressBar progressbar; + + private JLabel label; + + private Timer timer; + + private boolean bool; + + private Registry registry; + + private String showLable; + +} diff --git a/src/com/connor/renben/process/plm/util/ProgressBarThread.java b/src/com/connor/renben/process/plm/util/ProgressBarThread.java new file mode 100644 index 0000000..7c52305 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/ProgressBarThread.java @@ -0,0 +1,29 @@ +package com.connor.renben.process.plm.util; + +// Referenced classes of package com.teamcenter.rac.importflex: +// ProgressBar + +public class ProgressBarThread extends Thread { + + public ProgressBarThread(String title, String showLable) { + this.title = title; + bar = new ProgressBar(showLable); + } + + public void run() { + bar.setTitle(title); + // 调用初始化面板 + bar.initUI(); + } + + /* + * 设置进度条可显示和不可显示 + */ + public void setBool(boolean bool) { + bar.setBool(true); + } + + private ProgressBar bar; + + private String title; +} diff --git a/src/com/connor/renben/process/plm/util/SaveControlPlan.java b/src/com/connor/renben/process/plm/util/SaveControlPlan.java new file mode 100644 index 0000000..1508ed5 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/SaveControlPlan.java @@ -0,0 +1,518 @@ +//package com.connor.renben.process.plm.util; +// +//import java.io.BufferedInputStream; +//import java.io.IOException; +//import java.io.InputStream; +//import java.sql.ResultSet; +//import java.util.ArrayList; +//import java.util.Arrays; +//import java.util.List; +//import java.util.Properties; +//import java.util.UUID; +// +//import org.apache.poi.xssf.eventusermodel.examples.FromHowTo; +// +//import com.connor.renben.process.plm.sql.util.SqlUtilT; +//import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +//import com.teamcenter.rac.kernel.TCComponent; +//import com.teamcenter.rac.kernel.TCComponentItem; +//import com.teamcenter.rac.kernel.TCPreferenceService; +//import com.teamcenter.rac.kernel.TCSession; +//import com.teamcenter.rac.util.MessageBox; +// +///** +// * 保存数据到控制计划表 +// * @author Administrator +// * +// */ +//public class SaveControlPlan { +// private TCSession session; +// private TCComponentItem item; +// private InterfaceAIFComponent comp; +// private List> properties = new ArrayList>(); +// private List> dataList = new ArrayList>();// 表格中的数据 +// +// public SaveControlPlan(TCSession session,TCComponentItem item,InterfaceAIFComponent comp) { +// // TODO Auto-generated constructor stub +// this.session = session; +// this.item = item; +// this.comp=comp; +// } +// /** +// * 获取没有检验项的工序 +// * @param name 首选项名称 +// * @return 没有检验项的工序名称 +// */ +// private List getMeopNames(String name) { +// // TODO Auto-generated method stub +// String[] values = null; +// if(name != null) +// { +// TCPreferenceService service = this.session.getPreferenceService(); +// String[] props = service.getStringArray(TCPreferenceService.TC_preference_site, name); +// if(props != null || props.length>0) +// { +// values = props; +// } +// } +// else +// { +// MessageBox.post("未找首选项!", "错误!", MessageBox.ERROR); +// } +// return Arrays.asList(values); +// } +// public void insertData() { +// // TODO Auto-generated method stub +// ResultSet rs = null; +// ResultSet result = null; +// ResultSet resultSet = null; +// InputStream input = null; +// try { +// properties = TMomMethodUtil.getBomPropertys(session, item); +// //properties.clear(); +// List meopNameList = getMeopNames("RB3_CONCEAL_MEOP_NAME"); +// String itemUid = item.getUid(); +// //获取工艺下的控制计划对象 +// TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); +// List kzjhList = new ArrayList(); +// for (int i = 0; i < kzjh.length; i++) { +// if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) +// { +// kzjhList.add((TCComponentItem)kzjh[i]); +// } +// } +// SqlUtilT.getTCConnection(); +// input = new BufferedInputStream(getClass().getResourceAsStream( +// "/sql.properties")); +// Properties pro = new Properties(); +// pro.load(input); +// if(kzjhList.size() == 0) +// { +// // 查询数据库中的数据 +// SqlUtilT.getTCConnection(); +// String sql = String.format(pro.getProperty("BOMCHECKSAVESELECT"), +// itemUid, "检验(%",comp.getUid()); +// rs = SqlUtilT.read(sql); +// while (rs.next()) { +// List rowList = new ArrayList(); +// rowList.add(rs.getString("RB3_MEOPID") == null ? "" : rs.getString("RB3_MEOPID")); +// //rowList.add(rs.getString("RB3_MEOPID")); +// rowList.add(rs.getString("RB3_GYBH")); +// rowList.add(rs.getString("RB3_GCMC")); +// rowList.add(rs.getString("RB3_JQSB") == null ? "" : rs.getString("RB3_JQSB")); +// dataList.add(rowList); +// } +// if (dataList == null || dataList.size() == 0) { +// for (int j = 0; j < properties.size(); j++) { +// UUID kzjhUid = UUID.randomUUID(); +//// UUID ssckzjhUid = UUID.randomUUID(); +//// UUID yjkzjhUid = UUID.randomUUID(); +// // 将数据插入到控制计划 +// SqlUtilT.getTCConnection(); +// String insertSQL = pro.getProperty("INSERTSQL"); +//// Integer number = Integer.parseInt(properties.get(j).get(1) +//// .toString()) % 10 == 0 ? Integer +//// .parseInt(properties.get(j).get(1).toString()) + 5 +//// : Integer.parseInt(properties.get(j).get(1) +//// .toString()) + 1; +// String name = "检验(" + properties.get(j).get(2).toString()+ ")"; +// if(properties.get(j).get(2).toString().indexOf("/") >=0 && properties.get(j).get(2).toString().split("/").length == 2 ) +// { +// name = "检验(" + properties.get(j).get(2).toString().split("/")[0] + ")\n" + +// "inspect("+properties.get(j).get(2).toString().split("/")[1]+")"; +// } +// //首末检验 +// String smjy = ""; +// if(properties.get(j).get(2).indexOf("检验") >= 0) +// { +// smjy = "巡检检验\nPatrol inspection"; +// } +// // 插入生产控制计划工序 +// SqlUtilT.getTCConnection(); +// SqlUtilT.write( +// new String[] { +// kzjhUid.toString().replace("-", ""), +// itemUid, properties.get(j).get(0), +// properties.get(j).get(1), +// properties.get(j).get(2).indexOf("/") >=0 ? properties.get(j).get(2).replace("/", "\n") : properties.get(j).get(2), +// properties.get(j).get(3), smjy, "1", "", "", +// "", "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", "", "", "RB3_YJKZJH","1","0","","0",comp.getUid(),properties.get(j).get(4) }, +// insertSQL); +// if(meopNameList.contains(properties.get(j).get(2).toString())) +// { +// // 插入生产控制计划巡检项 +// SqlUtilT.getTCConnection(); +// SqlUtilT.write( +// new String[] { +// UUID.randomUUID().toString() +// .replace("-", ""), itemUid, +// properties.get(j).get(0), +// properties.get(j).get(1).toString(), name, +// "", "巡检检验\nPatrol inspection", "", "", "", +// "", "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", "", "", "RB3_YJKZJH","1","0","","0",comp.getUid(), properties.get(j).get(4) }, +// insertSQL); +// } +// } +// } else { +// // 修改表中相应的工序名称 +// for (int i = 0; i < dataList.size(); i++) { +// for (int j = 0; j < properties.size(); j++) { +// if (dataList.get(i).get(0) +// .equals(properties.get(j).get(0)) +// && (!dataList.get(i).get(1) +// .equals(properties.get(j).get(1)) +// || !dataList +// .get(i) +// .get(2) +// .equals(properties.get(j) +// .get(2)) || !dataList +// .get(i).get(3) +// .equals(properties.get(j).get(3)))) { +//// Integer number = Integer.parseInt(properties.get(j) +//// .get(1).toString()) % 10 == 0 ? Integer +//// .parseInt(properties.get(j).get(1) +//// .toString()) + 5 : Integer +//// .parseInt(properties.get(j).get(1) +//// .toString()) + 1; +// String name = "检验(" +// + properties.get(j).get(2).toString() + ")"; +// if(properties.get(j).get(2).toString().indexOf("/") >=0 && properties.get(j).get(2).toString().split("/").length == 2 ) +// { +// name = "检验(" + properties.get(j).get(2).toString().split("/")[0] + ")\n" + +// "inspect("+properties.get(j).get(2).toString().split("/")[1]+")"; +// } +// // 获取数据库连接 +// // 更新自检 +// SqlUtilT.getTCConnection(); +// String updateSQL = String.format( +// pro.getProperty("BOMCHECKSAVEUPDATE"), +// itemUid, dataList.get(i).get(0), "检验(%"); +// // 更新巡检 +// String updateSQL1 = String.format( +// pro.getProperty("BOMCHECKSAVEUPDATE2"), +// itemUid, dataList.get(i).get(0), "检验(%"); +// SqlUtilT.update(new String[] { +// properties.get(j).get(1), +// properties.get(j).get(2).indexOf("/") >=0 ? properties.get(j).get(2).replace("/", "\n") : properties.get(j).get(2), +// properties.get(j).get(3) }, updateSQL); +// SqlUtilT.update(new String[] { properties.get(j).get(1).toString(), +// name, +// ""}, updateSQL1); +// } +// // if(dataList.get(i).get(1).equals(properties[j][1].getStringValue()) +// // && !dataList.get(i).get(0).equals(properties[j][0])) +// // { +// // //获取数据库连接 +// // String updateSQL = +// // String.format("update CONTROLPLAN set RB3_GYBH = ? where PROCESSPUID = \'%s\' and RB3_GCMC = \'%s\'",itemUid,dataList.get(i).get(1)) +// // ; +// // SqlUtilT.update(new String[]{ +// // properties[j][0].getStringValue() },updateSQL); +// // } +// } +// } +// // 添加工序 +// // 查询数据库中的数据 +// result = SqlUtilT.read(sql); +// List indexList = new ArrayList(); +// while (result.next()) { +// indexList.add(result.getString("RB3_MEOPID")); +// } +// for (int i = 0; i < properties.size(); i++) { +// if (!indexList.contains(properties.get(i).get(0))) { +// UUID kzjhUid = UUID.randomUUID(); +// // 将数据插入到表中 +// SqlUtilT.getTCConnection(); +// String insertSQL = pro.getProperty("INSERTSQL"); +//// Integer number = Integer.parseInt(properties.get(i) +//// .get(1).toString()) % 10 == 0 ? Integer +//// .parseInt(properties.get(i).get(1).toString()) + 5 +//// : Integer.parseInt(properties.get(i).get(1) +//// .toString()) + 1; +// String name = "检验(" +// + properties.get(i).get(2).toString() + ")"; +// if(properties.get(i).get(2).toString().indexOf("/") >=0 && properties.get(i).get(2).toString().split("/").length == 2 ) +// { +// name = "检验(" + properties.get(i).get(2).toString().split("/")[0] + ")\n" + +// "inspect("+properties.get(i).get(2).toString().split("/")[1]+")"; +// } +// +// //首末检验 +// String smjy = ""; +// if(properties.get(i).get(2).indexOf("检验") >= 0) +// { +// smjy = "巡检检验\nPatrol inspection"; +// } +// +// // 插入控制计划工序 +// SqlUtilT.getTCConnection(); +// SqlUtilT.write(new String[] { +// kzjhUid.toString().replace("-", ""), itemUid, +// properties.get(i).get(0), +// properties.get(i).get(1), +// properties.get(i).get(2).indexOf("/") >=0 ? properties.get(i).get(2).replace("/", "\n") : properties.get(i).get(2), +// properties.get(i).get(3), smjy, "1", "", "", "", +// "", "", "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", "RB3_YJKZJH","1","0","","0",comp.getUid(),properties.get(i).get(4) },insertSQL); +// if(meopNameList.contains(properties.get(i).get(2).toString())) +// { +// // 插入控制计划巡检项 +// SqlUtilT.getTCConnection(); +// SqlUtilT.write( +// new String[] { +// UUID.randomUUID().toString() +// .replace("-", ""), itemUid, +// properties.get(i).get(0), +// properties.get(i).get(1).toString(), name, +// "", "巡检检验\nPatrol inspection", "", "", +// "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", "", "", "", "", +// "RB3_YJKZJH","1","0","","0" ,comp.getUid(),properties.get(i).get(4) },insertSQL); +// } +// } +// } +// // 删除表中相应的工序 +// StringBuffer sb = new StringBuffer(); +// sb.append("("); +// for (int i = 0; i < properties.size(); i++) { +// sb.append("\'" + properties.get(i).get(0) + "\',"); +// } +// // 获取数据库连接 +// SqlUtilT.getTCConnection(); +// String selectSql = String +// .format(pro.getProperty("BOMCHECKSAVESELECT2"), +// itemUid, +// sb.toString().substring(0, sb.length() - 1) +// + ")"); +// resultSet = SqlUtilT.read(selectSql); +// List deleteList = new ArrayList(); +// while (resultSet.next()) { +// deleteList.add(resultSet.getString("RB3_MEOPID")); +// } +// if (deleteList != null && deleteList.size() > 0) { +// for (int i = 0; i < deleteList.size(); i++) { +// SqlUtilT.getTCConnection(); +// String deleteSQL = String.format( +// pro.getProperty("DELETE"), deleteList.get(i), +// itemUid); +// SqlUtilT.delete(deleteSQL); +// } +// } +// } +// } +// else +// { +// for (int i1 = 0; i1 < kzjhList.size(); i1++) { +// // 查询数据库中的数据 +// SqlUtilT.getTCConnection(); +// String sql = String.format(pro.getProperty("BOMCHECKSAVESELECT"), +// itemUid, "检验(%",comp.getUid()); +// rs = SqlUtilT.read(sql); +// while (rs.next()) { +// List rowList = new ArrayList(); +// rowList.add(rs.getString("RB3_MEOPID") == null ? "" : rs.getString("RB3_MEOPID")); +// //rowList.add(rs.getString("RB3_MEOPID")); +// rowList.add(rs.getString("RB3_GYBH")); +// rowList.add(rs.getString("RB3_GCMC")); +// rowList.add(rs.getString("RB3_JQSB") == null ? "" : rs.getString("RB3_JQSB")); +// dataList.add(rowList); +// } +// if (dataList == null || dataList.size() == 0) { +// for (int j = 0; j < properties.size(); j++) { +// UUID kzjhUid = UUID.randomUUID(); +//// UUID ssckzjhUid = UUID.randomUUID(); +//// UUID yjkzjhUid = UUID.randomUUID(); +// // 将数据插入到控制计划 +// SqlUtilT.getTCConnection(); +// String insertSQL = pro.getProperty("INSERTSQL"); +// +// String smjy = ""; +// // 插入控制计划工序 +// SqlUtilT.getTCConnection(); +// SqlUtilT.write( +// new String[] { +// kzjhUid.toString().replace("-", ""), +// itemUid, properties.get(j).get(0), +// properties.get(j).get(1), +// properties.get(j).get(2).indexOf("/") >=0 ? properties.get(j).get(2).replace("/", "\n") : properties.get(j).get(2), +// properties.get(j).get(3), smjy, "1", "", "", +// "", "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", "", "", kzjhList.get(i1).getType().toUpperCase(),"","","","",comp.getUid(),properties.get(j).get(4) }, +// insertSQL); +// +// } +// } else { +// // 修改表中相应的工序属性 +// for (int i = 0; i < dataList.size(); i++) { +// for (int j = 0; j < properties.size(); j++) { +// if (dataList.get(i).get(0).equals(properties.get(j).get(0))&& +// (!dataList.get(i).get(1).equals(properties.get(j).get(1)) +// || !dataList.get(i).get(2).equals(properties.get(j).get(2)) +// || !dataList.get(i).get(3).equals(properties.get(j).get(3)))) { +// String name = "检验(" +// + properties.get(j).get(2).toString() + ")"; +// String s = properties.get(j).get(2).toString(); +// if(properties.get(j).get(2).toString().indexOf("/") >=0 && properties.get(j).get(2).toString().split("/").length == 2 ) +// { +// name = "检验(" + properties.get(j).get(2).toString().split("/")[0] + ")\n" + +// "inspect("+properties.get(j).get(2).toString().split("/")[1]+")"; +// } +// // 获取数据库连接 +// // 更新自检 +// SqlUtilT.getTCConnection(); +// String updateSQL = String.format( +// pro.getProperty("BOMCHECKSAVEUPDATE"), +// itemUid, dataList.get(i).get(0), "检验(%"); +// // 更新巡检 +// SqlUtilT.getTCConnection(); +// String updateSQL1 = String.format( +// pro.getProperty("BOMCHECKSAVEUPDATE2"), +// itemUid, dataList.get(i).get(0), "检验(%"); +// SqlUtilT.update(new String[] { +// properties.get(j).get(1), +// properties.get(j).get(2).indexOf("/") >=0 ? properties.get(j).get(2).replace("/", "\n") : properties.get(j).get(2), +// (dataList.get(i).get(3).equals("")?properties.get(j).get(3):dataList.get(i).get(3).toString())}, +// updateSQL);//机器设备只有在为空的时候才更新 +// //System.out.println(updateSQL); +// SqlUtilT.update(new String[] { properties.get(j).get(1).toString(), +// name, +// ""}, updateSQL1); +// } +// // if(dataList.get(i).get(1).equals(properties[j][1].getStringValue()) +// // && !dataList.get(i).get(0).equals(properties[j][0])) +// // { +// // //获取数据库连接 +// // String updateSQL = +// // String.format("update CONTROLPLAN set RB3_GYBH = ? where PROCESSPUID = \'%s\' and RB3_GCMC = \'%s\'",itemUid,dataList.get(i).get(1)) +// // ; +// // SqlUtilT.update(new String[]{ +// // properties[j][0].getStringValue() },updateSQL); +// // } +// } +// } +// // 添加工序 +// // 查询数据库中的数据 +// result = SqlUtilT.read(sql); +// List indexList = new ArrayList(); +// while (result.next()) { +// indexList.add(result.getString("RB3_MEOPID")); +// } +// for (int i = 0; i < properties.size(); i++) { +// if (!indexList.contains(properties.get(i).get(0))) { +// UUID kzjhUid = UUID.randomUUID(); +// // 将数据插入到表中 +// String insertSQL = pro.getProperty("INSERTSQL"); +//// Integer number = Integer.parseInt(properties.get(i) +//// .get(1).toString()) % 10 == 0 ? Integer +//// .parseInt(properties.get(i).get(1).toString()) + 5 +//// : Integer.parseInt(properties.get(i).get(1) +//// .toString()) + 1; +// String name = "检验(" +// + properties.get(i).get(2).toString() + ")"; +// if(properties.get(i).get(2).toString().indexOf("/") >=0 && properties.get(i).get(2).toString().split("/").length == 2 ) +// { +// name = "检验(" + properties.get(i).get(2).toString().split("/")[0] + ")\n" + +// "inspect("+properties.get(i).get(2).toString().split("/")[1]+")"; +// } +// +// +// //首末检验 +// String smjy = ""; +// if(properties.get(i).get(2).indexOf("检验") >= 0) +// { +// smjy = "巡检检验\nPatrol inspection"; +// } +// +// // 插入控制计划工序 +// SqlUtilT.getTCConnection(); +// SqlUtilT.write(new String[] { +// kzjhUid.toString().replace("-", ""), itemUid, +// properties.get(i).get(0), +// properties.get(i).get(1), +// properties.get(i).get(2).indexOf("/") >=0 ? properties.get(i).get(2).replace("/", "\n") : properties.get(i).get(2), +// properties.get(i).get(3), smjy, "1", "", "", "", +// "", "", "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", kzjhList.get(i1).getType().toUpperCase(),"1","0","","0" ,comp.getUid(),properties.get(i).get(4) },insertSQL); +// if(meopNameList.contains(properties.get(i).get(2).toString())) +// { +// // 插入控制计划巡检项 +// SqlUtilT.getTCConnection(); +// SqlUtilT.write( +// new String[] { +// UUID.randomUUID().toString() +// .replace("-", ""), itemUid, +// properties.get(i).get(0), +// properties.get(i).get(1).toString(), name, +// "", "巡检检验\nPatrol inspection", "", "", +// "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", "", "", "", "", +// kzjhList.get(i1).getType().toUpperCase(),"1","0","","0",comp.getUid(),properties.get(i).get(4) },insertSQL); +// } +// } +// } +// // 删除表中相应的工序 +// StringBuffer sb = new StringBuffer(); +// sb.append("("); +// if(properties.size()>0) { +// for (int i = 0; i < properties.size(); i++) { +// sb.append("\'" + properties.get(i).get(0) + "\',"); +// } +// }else { +// sb.append("\'" +"0"+ "\',");//如果没一个工序类,就直接全清空 +// } +// +// // 获取数据库连接 +// SqlUtilT.getTCConnection(); +// String selectSql = String +// .format(pro.getProperty("BOMCHECKSAVESELECT2"), +// itemUid, +// sb.toString().substring(0, sb.length() - 1) +// + ")"); +// resultSet = SqlUtilT.read(selectSql); +// System.out.println(selectSql); +// List deleteList = new ArrayList(); +// while (resultSet.next()) { +// if(!deleteList.contains(resultSet.getString("RB3_MEOPID"))) { +// deleteList.add(resultSet.getString("RB3_MEOPID")); +// } +// } +// if (deleteList != null && deleteList.size() > 0) { +// for (int i = 0; i < deleteList.size(); i++) { +// SqlUtilT.getTCConnection(); +// String deleteSQL = String.format( +// pro.getProperty("DELETE"), deleteList.get(i), +// itemUid); +// System.out.println(deleteSQL); +// SqlUtilT.delete(deleteSQL); +// } +// } +// } +// } +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } finally { +// if (rs != null) { +// SqlUtilT.free(rs); +// } +// if (result != null) { +// SqlUtilT.free(result); +// } +// if (resultSet != null) { +// SqlUtilT.free(resultSet); +// } +// if (input != null) { +// try { +// input.close(); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// SqlUtilT.freeAll(); +// } +// } +//} diff --git a/src/com/connor/renben/process/plm/util/SavePermissions.java b/src/com/connor/renben/process/plm/util/SavePermissions.java new file mode 100644 index 0000000..47e349f --- /dev/null +++ b/src/com/connor/renben/process/plm/util/SavePermissions.java @@ -0,0 +1,245 @@ +//package com.connor.renben.process.plm.util; +// +//import java.io.BufferedInputStream; +//import java.io.IOException; +//import java.io.InputStream; +//import java.sql.ResultSet; +//import java.util.ArrayList; +//import java.util.List; +//import java.util.Properties; +//import java.util.UUID; +// +//import com.connor.renben.process.plm.sql.util.SqlUtilT; +//import com.teamcenter.rac.kernel.TCComponent; +//import com.teamcenter.rac.kernel.TCComponentItem; +//import com.teamcenter.rac.kernel.TCSession; +//import com.teamcenter.rac.util.MessageBox; +// +///** +// * 保存数据到权限表 +// * @author Administrator +// * +// */ +//public class SavePermissions { +// +// private TCSession session; +// private TCComponentItem item; +// private List> properties = new ArrayList>(); +// private List> dataList = new ArrayList>();// 表格中的数据 +// private List controlUids=new ArrayList(); +// private List PFMEAUids=new ArrayList(); +// public SavePermissions(TCSession session,TCComponentItem item) { +// // TODO Auto-generated constructor stub +// this.session = session; +// this.item = item; +// } +// +// public void insertData() { +// // TODO Auto-generated method stub +// ResultSet rs = null; +// ResultSet result = null; +// ResultSet resultSet = null; +// InputStream input = null; +// try { +// properties = TMomMethodUtil.getPermissionsBomPropertys(session, item); +// String itemUid = item.getUid(); +// //获取工艺下的控制计划和PFMEA对象 +// TCComponent[] referenceTarget= item.getRelatedComponents("IMAN_reference"); +// List referenceTargetList = new ArrayList(); +// for (int i = 0; i < referenceTarget.length; i++) { +// //获取控制计划对象 +// if(referenceTarget[i].getType().toUpperCase().indexOf("KZJH") >= 0) +// { +// TCComponent[] ControlRevisions=referenceTarget[i].getReferenceListProperty("revision_list"); +// for(int j=0;j= 0) +// { +// TCComponent[] PFMEAUidsRevisions=referenceTarget[i].getReferenceListProperty("revision_list"); +// for(int j=0;j rowList = new ArrayList(); +// rowList.add(rs.getString("RB3_MEOPID") == null ? "" : rs.getString("RB3_MEOPID"));//如果数据库是null值就赋值为"",不然下面与""进行equals比较会出问题 +// rowList.add(rs.getString("RB3_GYBH") == null ? "" : rs.getString("RB3_GYBH")); +// rowList.add(rs.getString("RB3_GCMC") == null ? "" : rs.getString("RB3_GCMC")); +// rowList.add(rs.getString("RB3_GXH") == null ? "" : rs.getString("RB3_GXH")); +// dataList.add(rowList); +// } +// if (dataList == null || dataList.size() == 0) { +// //这里是如果第一次工艺下没一个工序,就执行这里插入工序。与下面有区别 +// for (int j = 0; j < properties.size(); j++) { +// // 插入到权限表 +// String insertSQL = pro.getProperty("INSERTPERMISSIONS"); +// // 插入工序到权限表 +// SqlUtilT.getTCConnection(); +// SqlUtilT.write(new String[] { +// UUID.randomUUID().toString().replace("-", ""), +// itemUid, properties.get(j).get(0), +// properties.get(j).get(1), properties.get(j).get(2).indexOf("/") >=0 ? properties.get(j).get(2).split("/")[0] : properties.get(j).get(2), +// "", "", "", "",properties.get(j).get(3) }, insertSQL); +// } +// } else { +// // 修改表中相应的工序名称 +// for (int i = 0; i < dataList.size(); i++) { +// for (int j = 0; j < properties.size(); j++) { +// //工序相同,如果工序编号,名称,工序号有改动时会修改permissions。也可以把&&后面的条件去除,则permissions上和properties上都有的工序就会去修改permissions +// //&& (!(dataList.get(i).get(1) == properties.get(j).get(1)) +// //|| !dataList.get(i).get(2).equals(properties.get(j).get(2)) +// //||!dataList.get(i).get(3).equals(properties.get(j).get(3))) +// if (dataList.get(i).get(0).equals(properties.get(j).get(0)) +// && (!(dataList.get(i).get(1).equals(properties.get(j).get(1))) +// || !dataList.get(i).get(2).equals(properties.get(j).get(2)) +// ||!dataList.get(i).get(3).equals(properties.get(j).get(3)))) { +// String updateSQL = String.format( +// pro.getProperty("UPDATEPERMISSIONS"), +// itemUid, dataList.get(i).get(0)); +// System.out.print(i+"+++="+j); +// SqlUtilT.getTCConnection(); +// SqlUtilT.update(new String[] { +// properties.get(j).get(1), +// properties.get(j).get(2).indexOf("/") >=0 ? properties.get(j).get(2).split("/")[0] : properties.get(j).get(2) , +// properties.get(j).get(3) }, updateSQL); +// +// } +// } +// } +// // 添加工序 +// // 查询数据库中的数据 +// result = SqlUtilT.read(sql); +// List indexList = new ArrayList(); +// while (result.next()) { +// indexList.add(result.getString("RB3_MEOPID")); +// } +// for (int i = 0; i < properties.size(); i++) { +// //这里是已有部分工序,中途要插入工序则执行这里 +// if (!indexList.contains(properties.get(i).get(0))) { +// String insertSQL = pro +// .getProperty("INSERTPERMISSIONS"); +// // 插入工序到权限表 +// SqlUtilT.getTCConnection(); +// SqlUtilT.write(new String[] { +// UUID.randomUUID().toString().replace("-", ""), +// itemUid, properties.get(i).get(0), +// properties.get(i).get(1), +// properties.get(i).get(2).indexOf("/") >=0 ? properties.get(i).get(2).split("/")[0] : properties.get(i).get(2), +// "", "", "", "",properties.get(i).get(3) }, +// insertSQL); +// } +// } +// // 删除表中相应的工序 +// StringBuffer sb = new StringBuffer(); +// sb.append("("); +// //sb获取的是先工艺下所有的工序 +// for (int i = 0; i < properties.size(); i++) { +// sb.append("\'" + properties.get(i).get(0) + "\',"); +// } +// // 获取数据库连接 +// String selectSql = String +// .format(pro.getProperty("BOMCHECKSAVESELECTPERMISSIONS2"), +// itemUid, +// sb.toString().substring(0, sb.length() - 1) +// + ")");//将permissions中有,但是properties中没有的工序提取出来。即查询工艺下所有的工序,将不再sb数组中的工序查询出来 +// resultSet = SqlUtilT.read(selectSql); +// List deleteList = new ArrayList(); +// while (resultSet.next()) { +// deleteList.add(resultSet.getString("RB3_MEOPID")); +// } +// if (deleteList != null && deleteList.size() > 0) { +// for (int i = 0; i < deleteList.size(); i++) { +// String deleteSQL = String.format( +// pro.getProperty("DELETEPERMISSIONS"), deleteList.get(i), +// itemUid); +// SqlUtilT.getTCConnection(); +// SqlUtilT.delete(deleteSQL); +// } +// } +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } finally { +// if (rs != null) { +// SqlUtilT.free(rs); +// } +// if (result != null) { +// SqlUtilT.free(result); +// } +// if (resultSet != null) { +// SqlUtilT.free(resultSet); +// } +// if (input != null) { +// try { +// input.close(); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// SqlUtilT.freeAll(); +// } +// +// //++++++修改控制计划和PFMEA数据的编号 +// //控制计划 +// if(controlUids!=null&&controlUids.size()>0) { +// for(int j=0;j property=properties.get(i); +// String updateSql = String +// .format(updateSql = "UPDATE RB3_CONTROLPLAN SET NO=? " +// + "WHERE RB3_MEOPID = \'%s\'and RB3_GCMC = \'%s\'and REVISIONUID = \'%s\'", +// property.get(0),property.get(2),controlUid); +// SqlUtilT.getTCConnection(); +// SqlUtilT.write(new String[] {property.get(1)},updateSql); +// } +// } +// } +// +// //PFMEA +// if(PFMEAUids!=null&&PFMEAUids.size()>0) { +// for(int j=0;j property=properties.get(i); +// String updateSql = String +// .format(updateSql = "UPDATE RB3_PFMEA SET NO=? " +// + "WHERE RB3_MEOPID = \'%s\' and REVISIONID = \'%s\'", +// property.get(0),PFMEAUid); +// SqlUtilT.getTCConnection(); +// SqlUtilT.write(new String[] {property.get(1)},updateSql); +// } +// } +// } +// +// +// //+++++++ +// +// } +//} diff --git a/src/com/connor/renben/process/plm/util/SavePfmea.java b/src/com/connor/renben/process/plm/util/SavePfmea.java new file mode 100644 index 0000000..ccfa9ff --- /dev/null +++ b/src/com/connor/renben/process/plm/util/SavePfmea.java @@ -0,0 +1,212 @@ +//package com.connor.renben.process.plm.util; +// +//import java.io.BufferedInputStream; +//import java.io.IOException; +//import java.io.InputStream; +//import java.sql.ResultSet; +//import java.util.ArrayList; +//import java.util.List; +//import java.util.Properties; +//import java.util.UUID; +// +//import com.connor.renben.process.plm.sql.util.SqlUtilT; +//import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +//import com.teamcenter.rac.kernel.TCComponent; +//import com.teamcenter.rac.kernel.TCComponentItem; +//import com.teamcenter.rac.kernel.TCSession; +// +///** +// * 保存数据到PFMEA表 +// * @author Administrator +// * +// */ +//public class SavePfmea { +// +// private TCSession session; +// private TCComponentItem item; +// private InterfaceAIFComponent comp; +// private List> properties = new ArrayList>(); +// private List> dataList = new ArrayList>();// 表格中的数据 +// +// public SavePfmea(TCSession session,TCComponentItem item,InterfaceAIFComponent comp) { +// // TODO Auto-generated constructor stub +// this.session = session; +// this.item = item; +// this.comp=comp; +// } +// +// public void insertData() { +// // TODO Auto-generated method stub +// ResultSet rs = null; +// ResultSet result = null; +// ResultSet resultSet = null; +// InputStream input = null; +// try { +// properties = TMomMethodUtil.getPFMEABomPropertys(session, item); +// String itemUid = item.getUid(); +// //获取工艺下的控制计划对象 +// TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); +// List kzjhList = new ArrayList(); +// for (int i = 0; i < kzjh.length; i++) { +// if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) +// { +// kzjhList.add((TCComponentItem)kzjh[i]); +// } +// } +// input = new BufferedInputStream(getClass().getResourceAsStream( +// "/sql.properties")); +// Properties pro = new Properties(); +// pro.load(input); +// // 查询数据库中的数据 +// SqlUtilT.getTCConnection(); +// String sql = String.format(pro.getProperty("BOMCHECKSAVESELECTPFMEA"), +// itemUid, "检验(%"); +// rs = SqlUtilT.read(sql); +// while (rs.next()) { +// List rowList = new ArrayList(); +// rowList.add(rs.getString("RB3_MEOPID") == null ? "" : rs.getString("RB3_MEOPID")); +// rowList.add(rs.getString("RB3_STATION")); +// dataList.add(rowList); +// } +// if (dataList == null || dataList.size() == 0) { +// for (int j = 0; j < properties.size(); j++) { +// // 插入到PFMEA表 +// SqlUtilT.getTCConnection(); +// String insertPFMEA = pro.getProperty("INSERTPFMEA"); +// // 插入PFMEA表 +//// SqlUtilT.write(new String[] { +//// UUID.randomUUID().toString().replace("-", ""), +//// itemUid, properties.get(j).get(0), +//// properties.get(j).get(1), +//// properties.get(j).get(2).indexOf("/") >=0 ? properties.get(j).get(2).replace("/", "\n") : properties.get(j).get(2), +//// "", "", "", "", "", "", "", "", "", "", "", "", "", +//// "", "", "", "", "", "", "", "", "", "", "", "", "", +//// "" ,"","","","","","","","",comp.getUid()}, insertPFMEA); +// //+++ +// SqlUtilT.getTCConnection(); +// SqlUtilT.write(new String[] { +// UUID.randomUUID().toString().replace("-", ""), +// itemUid, properties.get(j).get(0), "","","", +// properties.get(j).get(1)+(properties.get(j).get(2).indexOf("/") >=0 ? properties.get(j).get(2).replace("/", "\n") : properties.get(j).get(2)), "", "", "", "", +// "", "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", "", "", "", "", "","","","","","","","","" ,comp.getUid(),properties.get(j).get(4)}, +// insertPFMEA); +// //+++ +// } +// } +// else { +//// //修改后注释的———————— +//// // 修改表中相应的工序名称 +//// for (int i = 0; i < dataList.size(); i++) { +//// for (int j = 0; j < properties.size(); j++) { +//// String station=properties.get(j).get(1)+ +//// (properties.get(j).get(2).indexOf("/") >=0 ? properties.get(j).get(2).replace("/", "\n") : properties.get(j).get(2)); +//// if (dataList.get(i).get(0).equals(properties.get(j).get(0))&&!dataList.get(i).get(1).equals(station) ) { +//// String updatePFMEA = String.format( +//// pro.getProperty("UPDATEPFMEA"), itemUid, +//// dataList.get(i).get(0)); +////// // 更新PFMEA +////// SqlUtilT.update(new String[] { +////// properties.get(j).get(1), +////// properties.get(j).get(2).indexOf("/") >=0 ? properties.get(j).get(2).replace("/", "\n") : properties.get(j).get(2) }, updatePFMEA); +//// //+++ +//// // 更新PFMEA +//// SqlUtilT.update(new String[] { +//// properties.get(j).get(1)+ +//// (properties.get(j).get(2).indexOf("/") >=0 ? properties.get(j).get(2).replace("/", "\n") : properties.get(j).get(2)) }, updatePFMEA); +//// //+++ +//// } +//// } +//// } +//// //———————— +// +// // 添加工序 +// // 查询数据库中的数据 +// result = SqlUtilT.read(sql); +// List indexList = new ArrayList(); +// while (result.next()) { +// indexList.add(result.getString("RB3_MEOPID")); +// } +// for (int i = 0; i < properties.size(); i++) { +// if (!indexList.contains(properties.get(i).get(0))) { +// // 插入到PFMEA表 +// String insertPFMEA = pro.getProperty("INSERTPFMEA"); +// // 插入PFMEA表 +//// SqlUtilT.write(new String[] { +//// UUID.randomUUID().toString().replace("-", ""), +//// itemUid, properties.get(i).get(0), +//// properties.get(i).get(1), +//// properties.get(i).get(2).indexOf("/") >=0 ? properties.get(i).get(2).replace("/", "\n") : properties.get(i).get(2), "", "", "", "", "", +//// "", "", "", "", "", "", "", "", "", "", "", "", +//// "", "", "", "", "", "", "", "", "", "","","","","","","","","",comp.getUid() }, +//// insertPFMEA); +// //+++ +// SqlUtilT.getTCConnection(); +// SqlUtilT.write(new String[] { +// UUID.randomUUID().toString().replace("-", ""), +// itemUid, properties.get(i).get(0), "","", "", +// properties.get(i).get(1)+(properties.get(i).get(2).indexOf("/") >=0 ? properties.get(i).get(2).replace("/", "\n") : properties.get(i).get(2)), "", "", "", "", +// "", "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", "", "", "", "", "","","","","","","","","",comp.getUid(),properties.get(i).get(4) }, +// insertPFMEA); +// //+++ +// +// } +// } +// // 删除表中相应的工序 +// StringBuffer sb = new StringBuffer(); +// sb.append("("); +// if(properties.size()>0) { +// for (int i = 0; i < properties.size(); i++) { +// sb.append("\'" + properties.get(i).get(0) + "\',"); +// } +// }else { +// sb.append("\'" +"0"+ "\',");//如果没一个工序类,就直接全清空 +// } +// // 获取数据库连接 +// SqlUtilT.getTCConnection(); +// String selectSql = String +// .format(pro.getProperty("BOMCHECKSAVESELECTPFMEA2"), +// itemUid, +// sb.toString().substring(0, sb.length() - 1) +// + ")"); +// resultSet = SqlUtilT.read(selectSql); +// List deleteList = new ArrayList(); +// while (resultSet.next()) { +// deleteList.add(resultSet.getString("RB3_MEOPID")); +// } +// if (deleteList != null && deleteList.size() > 0) { +// for (int i = 0; i < deleteList.size(); i++) { +// SqlUtilT.getTCConnection(); +// String deleteSQL = String.format( +// pro.getProperty("DELETEPFMEA"), deleteList.get(i), +// itemUid); +// SqlUtilT.delete(deleteSQL); +// } +// } +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } finally { +// if (rs != null) { +// SqlUtilT.free(rs); +// } +// if (result != null) { +// SqlUtilT.free(result); +// } +// if (resultSet != null) { +// SqlUtilT.free(resultSet); +// } +// if (input != null) { +// try { +// input.close(); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// SqlUtilT.freeAll(); +// } +// } +//} diff --git a/src/com/connor/renben/process/plm/util/TCGroupDialogTree.java b/src/com/connor/renben/process/plm/util/TCGroupDialogTree.java new file mode 100644 index 0000000..3e62abb --- /dev/null +++ b/src/com/connor/renben/process/plm/util/TCGroupDialogTree.java @@ -0,0 +1,73 @@ +//package com.connor.renben.process.plm.util; +// +//import javax.swing.ImageIcon; +//import javax.swing.JTree; +//import javax.swing.tree.DefaultMutableTreeNode; +//import javax.swing.tree.DefaultTreeCellRenderer; +// +//import com.connor.renben.process.plm.bean.TMomUserBean; +//import com.teamcenter.rac.kernel.TCComponent; +//import com.teamcenter.rac.kernel.TCComponentGroup; +//import com.teamcenter.rac.kernel.TCComponentGroupType; +//import com.teamcenter.rac.kernel.TCComponentRole; +//import com.teamcenter.rac.kernel.TCException; +//import com.teamcenter.rac.kernel.TCSession; +// +//public class TCGroupDialogTree { +// +// public void getUsers(DefaultMutableTreeNode node, TCComponent comp, +// TCComponent parent) { +// try { +// if (comp instanceof TCComponentGroup) { +// TCComponent[] comps = ((TCComponentGroup) comp) +// .getRolesAndGroups(); +// for (int i = 0; i < comps.length; i++) { +// TMomUserBean bean = new TMomUserBean(comps[i], comp); +// DefaultMutableTreeNode node1 = new DefaultMutableTreeNode( +// bean); +// node.add(node1); +// getUsers(node1, comps[i], comp); +// } +// } else if (comp instanceof TCComponentRole) { +// TCComponent[] comps = ((TCComponentRole) comp) +// .getUsers((TCComponentGroup) parent); +// for (int i = 0; i < comps.length; i++) { +// TMomUserBean bean = new TMomUserBean(comps[i], comp); +// DefaultMutableTreeNode node1 = new DefaultMutableTreeNode( +// bean); +// node.add(node1); +// } +// } +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// +// public JTree getTcOrgTree(TCSession session, String goupFullName) { +// JTree tree = new JTree(); +// +// try { +// TCComponentGroupType type = ((TCComponentGroupType) session +// .getTypeComponent("Group")); +// TCComponentGroup group = type.find("NBTM"); +// TMomUserBean bean = new TMomUserBean(group, null); +// DefaultMutableTreeNode node1 = new DefaultMutableTreeNode(bean); +// getUsers(node1, group, null); +// tree = new JTree(node1); +// tree.setRowHeight(20); +// DefaultTreeCellRenderer cellRenderer = (DefaultTreeCellRenderer) tree +// .getCellRenderer(); +// cellRenderer.setLeafIcon(new ImageIcon("icons\\person_16.png")); +// cellRenderer.setOpenIcon(new ImageIcon("icons\\role_16.png")); +// cellRenderer.setClosedIcon(new ImageIcon("icons\\group_16.png")); +// +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// +// return tree; +// } +// +//} diff --git a/src/com/connor/renben/process/plm/util/TMomFinalUtil.java b/src/com/connor/renben/process/plm/util/TMomFinalUtil.java new file mode 100644 index 0000000..c9fcad0 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/TMomFinalUtil.java @@ -0,0 +1,106 @@ +package com.connor.renben.process.plm.util; + +public class TMomFinalUtil { + // ---------------ALL---------------------------------------------- + public static final String PROCESS_MODEL_FILE = "PROCESS_MODEL_FILE";// 工艺模板文件 + // ---------------TMom001---------------------------------------------- + public static final int CX_INSTRUCTION = 0;// 成形作业指导书代号 + public static final int ZX_INSTRUCTION = 1;// 整形作业指导书代号 + public static final int SJ_INSTRUCTION = 2;// 烧结作业指导书代号 + public static final int PS_INSTRUCTION = 3;// 喷砂作业指导书代号 + public static final int GS_INSTRUCTION = 4;// 光饰作业指导书代号 + public static final int ST_INSTRUCTION = 5;// ST处理作业指导书代号 + + public static final int ELDECRCL_INSTRUCTION = 6;// Eldec热处理工艺指导书代号 + public static final int BZDXMJ_INSTRUCTION = 7;// 半自动修毛机工艺指导书代号 + public static final int GSJ_INSTRUCTION = 8;// 攻丝机工艺指导书 + public static final int JJG_INSTRUCTION = 9;// 机加工工艺指导书代号 + public static final int PTRCL_INSTRUCTION = 10;// 普通热处理工艺指导书代号 + public static final int TZ_INSTRUCTION = 11;// 台钻工艺指导书代号 + public static final int TGSXMJ_INSTRUCTION = 12;// 通过式修毛机工艺指导书代号 + public static final int TYMC_INSTRUCTION = 13;// 通用磨床工艺指导书代号 + public static final int WXM_INSTRUCTION = 14;// 无心磨工艺指导书代号 + public static final int YZ_INSTRUCTION = 15;// 压装工艺指导书代号 + public static final int TS_INSTRUCTION = 16;//探伤作业指导书 + public static final int CC_INSTRUCTION = 9;//车床工艺指导书 + public static final int JGZX_INSTRUCTION = 9;//加工中心工艺指导书 + + public static final int WG_INSTRUCTION = 17;//外观作业指导书 + + + // ---------------TMom002---------------------------------------------- + public static final int GY_CODE = 0;// 工艺代号 + public static final int HISGY_CODE = 2;// 历史工艺代号 + public static final int GX_CODE = 1;// 工序代号 + public static final int GYTZ_CODE = 3;//工艺图纸代号 + public static final int BZGX_CODE = 4;// 工序代号 + + public static final String GY_TYPE_DIS = "工艺";// 工艺类型 + public static final String GY_TYPE = "MEProcess"; + + public static final String HISGY_TYPE_DIS = "工艺";// 工艺类型 + public static final String HISGY_TYPE = "MEProcess"; + + public static final String GX_TYPE_DIS = "工序";// 工序类型 + public static final String GX_TYPE = "MEOP"; + + public static final String GYTZ_TYPE = "RB3_TEdrawing";//工艺图纸类型 + public static final String GYTZ_TYPE_DIS = "工艺图纸"; + + public static final String GY_ITEM_NAMES = "GY_ITEM_NAMES";// 工艺对象名称下拉列表 + public static final String GX_ITEM_NAMES = "GX_ITEM_NAMES";// 工序对象名称下拉列表 + + // ---------------TMom014---------------------------------------------- + public static final int CXSJTY_CHECKTABLE = 0; //成形首检调试记录表(通用) 烧结首件 200 AjQtFS$T4iZo5B 工序质量检查表(烧结) + public static final int CXSJCNCZY_CHECKTABLE = 0; //成形首检调试记录表(CNC专用) + public static final int CXGCJ_CHECKTABLE = 1; //成形工序过程自检记录表(操作工) 整形工序过程自检记录表(操作工) 101 + public static final int CXMJ_CHECKTABLE = 2; //成形末件记录表 整形末件记录表 102 + public static final int CXXJ_CHECKTABLE = 3; //成形工序巡检检查表 整形工序巡检检查表 103 + public static final int ZX_CHECKTABLE = 4; //精整工序产品批量生产记录单(批准单) + public static final int JJGSJ_CHECKTABLE = 5; //机加工科产品首件检查表 + public static final int JJGGCJ_CHECKTABLE = 6; //机加工科产品过程质量检查表 + public static final int JJGMJ_CHECKTABLE = 7; //机加工科产品末件检查表 + public static final int MKSJ_CHECKTABLE = 8; //盲孔感应淬火批次首件批准单 + public static final int MKGCJ_CHECKTABLE = 9; //盲孔感应淬火过程检验记录表 + public static final int MKMJ_CHECKTABLE = 10;//盲孔感应淬火批次末件记录单 + public static final int GXZL_CHECKTABLE = 11;//工序质量检查表-按时间 + public static final int ZZ_CHECKTABLE = 12;//最终检查表 + public static final int CPZL_CHECKTABLE = 13;//产品质量检查表 + public static final int JJGHDSJ_CHECKTABLE = 14;//机加工换刀首检验检查表 + public static final int JJGHDMJ_CHECKTABLE = 15;//机加工换刀末检验检查表 + public static final int GXZLPC_CHECKTABLE = 16;//工序质量检查表-按批次 + + + // ---------------TMom017---------------------------------------------- + public static final String BZFS_COMBOBOX_VALUES = "BZFS_COMBOBOX_VALUES"; //包装方式下拉菜单 + public static final String QYFS_COMBOBOX_VALUES = "QYFS_COMBOBOX_VALUES"; //油方式下拉菜单 + public static final String OUTERBOX_COMBOBOX_VALUESS = "OUTERBOX_COMBOBOX_VALUESS";//外箱标签下拉菜单 + public static final String STORAGETRAY_COMBOBOX_VALUES = "STORAGETRAY_COMBOBOX_VALUES";//入库托盘下拉菜单 + public static final String CARRIAGEPACK_COMBOBOX_VALUES = "CARRIAGEPACK_COMBOBOX_VALUES";//运输包装类型下拉菜单 + public static final String PACKAGING_COMBOBOX_VALUES = "PACKAGING_COMBOBOX_VALUES";//打包方式下拉列表框 + public static final String PALLETSPEC_COMBOBOX_VALUES = "PALLETSPEC_COMBOBOX_VALUES";//托盘规格下拉列表框 + public static final String METHODSREINFORCEMENT_COMBOBOX_VALUES = "METHODSREINFORCEMENT_COMBOBOX_VALUES";//加固方式下拉列表框 + + //---------------TMom019----------------------------------------------- + //public static final int AIXING_CONTROL = 0;// 爱信控制计划代号 + public static final int AIXING_CHINESE_CONTROL = 0;// 爱信中文控制计划代号 + public static final int AIXING_ENGLISH_CONTROL = 1;// 爱信英文控制计划代号 + public static final int AIXING_CHINESE_ENGLISH_CONTROL = 2;// 爱信中英文控制计划代号 + //public static final int BOGEHUALAEN_CONTROL = 1;// 英文博格华纳控制计划代号 + public static final int BOGEHUALAEN_CHINESE_CONTROL = 3;// 博格华纳中文控制计划代号 + public static final int BOGEHUALAEN_ENGLISH_CONTROL = 4;// 博格华纳英文控制计划代号 + public static final int BOGEHUALAEN_CHINESE_ENGLISH_CONTROL = 5;// 博格华纳中英文控制计划代号 + //public static final int BOGEHUALAZH_CONTROL = 2;// 中午博格华纳控制计划代号 + //public static final int MAIGELA_CONTROL = 3;// 麦格纳控制计划代号 + public static final int MAIGELA_CHINESE_CONTROL = 6;// 麦格纳中文控制计划代号 + public static final int MAIGELA_ENGLISH_CONTROL = 7;// 麦格纳英文控制计划代号 + public static final int MAIGELA_CHINESE_ENGLISH_CONTROL = 8;// 麦格纳中英文控制计划代号 + + public static final int NBTM_CHINESE_CONTROL = 9;//东睦中文控制计划代号 + public static final int NBTM_ENGLISH_CONTROL = 10;// 东睦英文控制计划代号 + public static final int NBTM_CHINESE_ENGLISH_CONTROL = 11;// 东睦中英文控制计划代号 + + + + +} diff --git a/src/com/connor/renben/process/plm/util/TMomMethodUtil.java b/src/com/connor/renben/process/plm/util/TMomMethodUtil.java new file mode 100644 index 0000000..02f3b53 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/TMomMethodUtil.java @@ -0,0 +1,1182 @@ +package com.connor.renben.process.plm.util; + +import java.io.File; +import java.io.IOException; +import java.text.DecimalFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.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.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentMEProcess; +import com.teamcenter.rac.kernel.TCComponentProcess; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCComponentType; +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.TCQueryClause; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTextService; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.util.FileUtility; +import com.teamcenter.rac.util.MessageBox; + +public class TMomMethodUtil { + + private static List> bomPropertyList = new ArrayList>(); + + public static void main(String[] args) { + String str = "123|1234|123124"; + System.out.println(str.split("\\|").length); + } + + /** + * 判断获取的对象是否全部为ITEM + * + * @param comps + * 需要判断的目标对象 + * @param isNotIgor + * 是否需要忽略,如果TRUE 则不能忽略,如果FALSE 则可以忽略 + * + * @param isSameType + * 是否要求是相同的类型,如果TRUE 要求必须是相同的类型 + * @return + */ + public static List getItemList( + InterfaceAIFComponent[] comps, Boolean isNotIgor, Boolean isSameType) { + if (comps == null) { + + return null; + } + List itemList = new ArrayList(); + String type = null; + for (int i = 0; i < comps.length; i++) { + if (comps[i] instanceof TCComponentItem) { + if (isSameType) { + if (type == null) { + type = comps[i].getType(); + } else if (!type.equals(comps[i].getType())) { + return null; + } + } + itemList.add((TCComponentItem) comps[i]); + } else if (isNotIgor) { + return null; + } + } + return itemList; + } + +// /** +// * 获取模板文件 +// * @param session session +// * @param fileName 文件名 +// * @param Filetype 文件类型 +// * @return +// */ + public static File getFile(TCSession session,String fileName,String Filetype) { + // TODO Auto-generated method stub + try { + TCPreferenceService service = session.getPreferenceService(); + String[] modelFiles = service.getStringValues("ZF6-GYGL-Template"); + if (modelFiles == null) + { + System.out.println("未找到首选项"); + return null; + } + String puid = ""; + for (int i = 0; i < modelFiles.length; i++) { + if(modelFiles[i].split(":")[0].equals(fileName)) + { + puid = modelFiles[i].split(":")[1]; + } + } + TCComponentDataset dat = (TCComponentDataset)session + .stringToComponent(puid); + TCComponentTcFile[] tcFile = dat.getTcFiles(); + if(tcFile != null && tcFile.length == 0) + { + System.out.println("未找到配置文件"); + } + else + { + return tcFile[0].getFmsFile(); + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return null; + } + /** + * 获取最新的已发布的版本 + * @param item + * @return + */ +// public static TCComponentItemRevision getLastItemRevision(TCComponentItem item) { +// // TODO Auto-generated method stub +// try { +// TCComponentItemRevision[] items = item.getReleasedItemRevisions(); +// int revId = 0; +// TCComponentItemRevision itemRevision = null; +// for (int i = 0; i < items.length; i++) { +// String revisionId = items[i].getStringProperty("item_revision_id"); +// if(letterToNumber(revisionId) >= revId ) +// { +// itemRevision = items[i]; +// revId = letterToNumber(revisionId); +// } +// } +// return itemRevision; +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// return null; +// } + + public static int letterToNumber(String letter) { + int length = letter.length(); + int num = 0; + int number = 0; + for(int i = 0; i < length; i++) { + char ch = letter.charAt(length - i - 1); + num = (int)(ch - 'A' + 1) ; + num *= Math.pow(26, i); + number += num; + } + return number; + } + + /** + * 获取版本对象 + * + * @param comps + * 需要判断的目标对象 + * @param isNotIgor + * 是否需要忽略,如果TRUE 则不能忽略,如果FALSE 则可以忽略 + * + * @param isSameType + * 是否要求是相同的类型,如果TRUE 要求必须是相同的类型 + * @return + */ + public static List getItemRevList( + InterfaceAIFComponent[] comps, Boolean isNotIgor, Boolean isSameType) { + if (comps == null) { + + return null; + } + List itemList = new ArrayList(); + + String type = null; + for (int i = 0; i < comps.length; i++) { + if (comps[i] instanceof TCComponentItemRevision) { + + if (isSameType) { + if (type == null) { + type = comps[i].getType(); + } else if (!type.equals(comps[i].getType())) { + return null; + } + } + itemList.add((TCComponentItemRevision) comps[i]); + } else if (isNotIgor) { + return null; + } + } + return itemList; + } + + /** + * 获取存放的文件夹 + * + * @param item + * @param name + * @return + */ + public static TCComponentFolder getParentFolder(TCComponentItem item, + String name) { + TCComponentFolder folder = null; + try { + AIFComponentContext[] comtexts = item.whereReferenced(); + if (comtexts != null) { + for (int i = 0; i < comtexts.length; i++) { + if (comtexts[i].getComponent() instanceof TCComponentFolder) { + String nameT = ((TCComponentFolder) comtexts[i] + .getComponent()) + .getStringProperty("object_name"); + if (name.equals("工艺图纸") && nameT.equals("工艺图纸")) { + folder = (TCComponentFolder) comtexts[i] + .getComponent(); + } + else if(nameT.equals(name)) + { + folder = (TCComponentFolder) comtexts[i] + .getComponent(); + } + } + } + } + } catch (TCException e) { + e.printStackTrace(); + } + return folder; + } + + /** + * 获取存在的ITEM的个数 + * + * @param session + * 会话 + * @param oldItemID + * 旧编码 + * @return + */ + public static Integer getItemCount(TCSession session, String oldItemID) { + Integer count = 0; + InterfaceAIFComponent[] comps = searchComponentsCollection(session, + "Connor_TMom_Query_Item", new String[] { "item_id" }, + new String[] { oldItemID }); + if (comps == null) { + return null; + } + count = comps.length; + return count; + } + + /** + * 工艺生成新的ID + * + * @param oldItemID + * @return + */ + public static String getGyRuleID(TCSession session, String oldItemID) { + DecimalFormat df = new DecimalFormat("000"); + String newID = oldItemID + "_P001"; + Integer count = 0; + // String idTemp = + TCComponentItemType tccomponentitemtype; + try { + tccomponentitemtype = (TCComponentItemType) (session + .getTypeComponent("Item")); + + tccomponentitemtype.getNewID(); + int i = 1; + //setByPass(session,true); + while (tccomponentitemtype.find(newID) != null) { + i++; + newID = oldItemID + "_P" + df.format(i); + } + // setByPass(session,false); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return newID; + } + + + /** + * 工序生成新ID + * + * @param oldItemID + * @return + */ + public static String getGxRuleID(TCSession session, String oldItemID) { + TCComponentItemType tccomponentitemtype; + try { + tccomponentitemtype = (TCComponentItemType) (session + .getTypeComponent("MEOP")); + + return tccomponentitemtype.getNewID(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return ""; + } + + /** + * 通过查询,查找符合条件的版本 + * + * @param session + * 会话 + * @param searchName + * 查询名称 + * @param keys + * 查询关键字 + * @param values + * 查询值 + * @return + */ + public static InterfaceAIFComponent[] searchComponentsCollection( + TCSession session, String searchName, String[] keys, String[] values) { + // 信息输出 + InterfaceAIFComponent[] result = new InterfaceAIFComponent[0]; + + try { + TCTextService textService = session.getTextService(); + TCComponentQueryType querytype = (TCComponentQueryType) session + .getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) querytype + .find(searchName); + if (query == null) { + MessageBox.post("通过查询构建器" + searchName + "不存在", "错误", 1); + return null; + } + querytype.clearCache(); + String[] as = new String[keys.length]; + for (int i = 0; i < keys.length; i++) { + as[i] = textService.getTextValue(keys[i]); + } + + String[] as1 = new String[values.length]; + for (int i = 0; i < values.length; i++) { + as1[i] = textService.getTextValue(values[i]); + + } + + query.clearCache(); + TCQueryClause[] clauses = query.describe(); + TCComponentContextList list = query.getExecuteResultsList(as, as1); + + if (list != null) { + int count = list.getListCount(); + result = new InterfaceAIFComponent[count]; + + for (int i = 0; i < count; i++) { + result[i] = list.get(i).getComponent(); + } + } + } catch (TCException e) { + e.printStackTrace(); + MessageBox.post("通过查询构建器" + searchName + "查询发生错误.", "错误", 1); + } + + return result; + } + /** + * 自定义文件名下载文件 + * + * @param comps + * @return + * @throws TCException + * @throws IOException + */ + + public static String downLoadFiles(TCComponent comp,String Titles,String URL,Boolean flag) { + if (comp == null) { + return ""; + } + String value = ""; + String tempPath = System.getenv("TEMP"); + // MessageBox.post(" tempPath = + // "+tempPath,"INFO",MessageBox.INFORMATION); + if (tempPath == null) { + tempPath = ""; + } else if (!tempPath.endsWith("\\")) { + tempPath = tempPath + "\\"; + } + + // MessageBox.post(" tempPath = "+tempPath,"INFO",MessageBox.INFORMATION); + // MessageBox.post(" URL = "+URL,"INFO",MessageBox.INFORMATION); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); + // for(TCComponent comp : comps){ + try { + if (comp instanceof TCComponentDataset) { + TCComponentTcFile[] tcFiles = ((TCComponentDataset) comp) + .getTcFiles(); + File file = null; + if (tcFiles != null && tcFiles.length != 0) { + file = tcFiles[0].getFmsFile(); + String fileName = file.getName(); + String fileDix = fileName.substring( + fileName.lastIndexOf("."), fileName.length()); + if (flag == true) + { + if ((URL != "")&&(URL != " ")&&(URL != null)) + { + fileName = URL + Titles + fileDix; + } + else + { + fileName = tempPath + Titles + fileDix; + } + } + else + { + fileName = tempPath + sdf.format(new Date()) + fileDix; + } + File dirFile = new File(fileName); + FileUtility.copyFile(file, dirFile); + + return fileName; + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // } + return value; + } + + + + + + /** + * 下载文件 + * + * @param comps + * @return + * @throws TCException + * @throws IOException + */ + public static String downLoadFile(TCComponent comp) { + if (comp == null) { + return ""; + } + String value = ""; + String tempPath = System.getenv("TEMP"); + // MessageBox.post(" tempPath = + // "+tempPath,"INFO",MessageBox.INFORMATION); + if (tempPath == null) { + tempPath = ""; + } else if (!tempPath.endsWith("\\")) { + tempPath = tempPath + "\\"; + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); + // for(TCComponent comp : comps){ + try { + if (comp instanceof TCComponentDataset) { + TCComponentTcFile[] tcFiles = ((TCComponentDataset) comp) + .getTcFiles(); + File file = null; + if (tcFiles != null && tcFiles.length != 0) { + file = tcFiles[0].getFmsFile(); + String fileName = file.getName(); + String fileDix = fileName.substring( + fileName.lastIndexOf("."), fileName.length()); + fileName = tempPath + sdf.format(new Date()) + fileDix; + File dirFile = new File(fileName); + FileUtility.copyFile(file, dirFile); + + return fileName; + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // } + return value; + } + + /*** + * 获取首选项 + * + * @param session + * 会话 + * @param preferenceName + * 首选项名称 + * @return + */ + public static String[] getPreferenceValues(String preferenceName) { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + if (preferenceName == null || session == null) { + System.out.println(""); + return null; + } + String[] values = null; + TCPreferenceService service = session.getPreferenceService(); + values = service.getStringArray(TCPreferenceService.TC_preference_site, + preferenceName); + String[] resultValues = new String[values.length]; + for (int i = 0; i < values.length; i++) { + if(values[i].indexOf("\\n") >= 0) + { + resultValues[i] = values[i].replace("\\n", "\n"); + } + else + { + resultValues[i] = values[i]; + } + } + return resultValues; + } + + /** + * 删除文件 + * + * @param filePathList + * 文件地址 + */ + public static void deleteFile(List filePathList) { + for (int i = 0; i < filePathList.size(); i++) { + File file = new File(filePathList.get(i)); + if (file.exists() && file.isFile()) { + if (file.delete()) { + System.out.println("文件" + filePathList.get(i) + "已删除!"); + } + } + } + } + + /** + * 旁路 + * + * @param session + * @param val + * @throws TCException + */ + public static void setByPass(TCSession session, boolean val) + throws TCException { + + TCUserService userservice = session.getUserService(); + + Object[] obj = new Object[1]; + obj[0] = ""; + if (val) { + userservice.call("Connor_set_bypass", obj); + } else { + userservice.call("Connor_close_bypass", obj); + } + } + /** + * 转换合并单元格 + * @param regionCell + * @param row + * @return + */ + public static String getCombineCell(Map regionCell, int row) { + Iterator> it = regionCell.entrySet().iterator(); + StringBuffer sb = new StringBuffer(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + StringBuffer rowSb = new StringBuffer(); + StringBuffer columnSb = new StringBuffer(); + for (int k = 0; k < entry.getKey().length; k++) { + rowSb.append(entry.getKey()[k]); + rowSb.append(","); + } + for (int k = 0; k < entry.getValue().length; k++) { + columnSb.append(entry.getValue()[k]); + columnSb.append(","); + } + if (entry.getKey()[0] == row) { + sb.append(rowSb.substring(0, rowSb.length() - 1)+ "/"+ columnSb.substring(0,columnSb.length() - 1)+"-"); + } + } + if(sb.length() > 0) + { + return sb.toString().substring(0, sb.length()-1); + } + else + { + return ""; + } + } + + /** + * 通知流程 + * + * @param session + * @param val + * @throws TCException + */ + public static void setProcess(TCSession session, + TCComponentProcess process, TCComponentUser user) + throws TCException { + + TCUserService userservice = session.getUserService(); + + Object[] obj = new Object[2]; + obj[0] = process; + obj[1] = user; + userservice.call("TMOM_meop_tongzhi", obj); + } + + /** + * 获取PFMEA BOM属性 + */ + public static List> getPFMEABomPropertys(TCSession session, TCComponentItem item) { + // TODO Auto-generated method stub + //获取BOM + TCComponentBOMWindow bomWindow = null; + bomPropertyList.clear(); + try { + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topBomLine = bomWindow.setWindowTopLine(item, + item.getLatestItemRevision(), null, null); + //获取工艺下的控制计划对象 +// TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); +// List itme = new ArrayList(); +// for (int i = 0; i < kzjh.length; i++) { +// if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) +// { +// itme.add((TCComponentItem)kzjh[i]); +// } +// } + getBomPropertys(topBomLine, true); + return bomPropertyList; + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return null; + } +// public static List> getPFMEABomPropertys(TCSession session, TCComponentItem item) { +// // TODO Auto-generated method stub +// //获取BOM +// TCComponentBOMWindow bomWindow = null; +// try { +// TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session +// .getTypeComponent("BOMWindow"); +// bomWindow = bomWindowType.create(null); +// TCComponentBOMLine topBomLine = bomWindow.setWindowTopLine(item, +// item.getLatestItemRevision(), null, null); +// //获取工艺下的控制计划对象 +// TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); +// List itme = new ArrayList(); +// for (int i = 0; i < kzjh.length; i++) { +// if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) +// { +// itme.add((TCComponentItem)kzjh[i]); +// } +// } +// // 获取工序对象 +// AIFComponentContext aif[] = topBomLine.getChildren(); +// List> properties = new ArrayList>(); +// for (int i = 0; i < aif.length; i++) { +// TCComponentBOMLine subline = (TCComponentBOMLine) aif[i] +// .getComponent(); +// if(subline.getStringProperty("RB3_is_hide") != null && subline.getStringProperty("RB3_is_hide").equals("true")) +// { +// continue; +// } +// List propertie = new ArrayList(); +// propertie +// .add(subline.getStringProperty("bl_indented_title") +// .split("/")[0]); +// propertie.add(subline.getStringProperty("bl_sequence_no")); +// propertie +// .add(subline +// .getStringProperty("bl_item_object_name") == null ? "" +// : subline +// .getStringProperty("bl_item_object_name")); +// //获取工序下的BOM +// List equipmentNameList = new ArrayList(); +// if(subline.getChildren().length>0) +// { +// for (int j = 0; j < subline.getChildren().length; j++) { +// TCComponentBOMLine subChildrenline = (TCComponentBOMLine) subline.getChildren()[j] +// .getComponent(); +// System.out.println(subChildrenline.getType()); +// if(subChildrenline.getType().indexOf("Equipment") >= 0) +// { +// TCComponentICO[] icos = subChildrenline.getItem().getLatestItemRevision() +// .getClassificationObjects(); +// if (icos.length > 0) { +// ICSProperty[] descriptions = icos[0] +// .getICSProperties(true); +// for (int k = 0; k < descriptions.length; k++) { +// if (descriptions[k].getId() == 1004 && descriptions[k].getValue() != null +// && !descriptions[k].getValue().equals("")) { +// System.out.println(equipmentNameList.toString()); +// if(!equipmentNameList.contains(descriptions[k].getValue())) +// { +// equipmentNameList.add(descriptions[k].getValue()); +// } +// System.out.println(equipmentNameList.toString()); +// //sb.append(descriptions[k].getValue()+","); +// +// } +// } +// } +// } +// } +// } +// if(equipmentNameList.size() > 0) +// { +// propertie.add(equipmentNameList.toString().substring(1, equipmentNameList.toString().length()-1)); +// } +// else +// { +// propertie.add(""); +// } +// properties.add(propertie); +// } +// return properties; +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// return null; +// } + + /** + * 获取BOM属性 + */ + public static List> getBomPropertys(TCSession session, TCComponentItem item) { + // TODO Auto-generated method stub + bomPropertyList.clear(); + //获取BOM + TCComponentBOMWindow bomWindow = null; + try { + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topBomLine = bomWindow.setWindowTopLine(item, + item.getLatestItemRevision(), null, null); + //获取工艺下的控制计划对象 + TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); + List itme = new ArrayList(); + for (int i = 0; i < kzjh.length; i++) { + if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) + { + itme.add((TCComponentItem)kzjh[i]); + } + } + getBomPropertys(topBomLine, false); + return bomPropertyList; + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return null; + } +// public static List> getBomPropertys(TCSession session, TCComponentItem item) { +// // TODO Auto-generated method stub +// //获取BOM +// TCComponentBOMWindow bomWindow = null; +// try { +// TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session +// .getTypeComponent("BOMWindow"); +// bomWindow = bomWindowType.create(null); +// TCComponentBOMLine topBomLine = bomWindow.setWindowTopLine(item, +// item.getLatestItemRevision(), null, null); +// //获取工艺下的控制计划对象 +// TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); +// List itme = new ArrayList(); +// for (int i = 0; i < kzjh.length; i++) { +// if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) +// { +// itme.add((TCComponentItem)kzjh[i]); +// } +// } +// // 获取工序对象 +// AIFComponentContext aif[] = topBomLine.getChildren(); +// List> properties = new ArrayList>(); +// for (int i = 0; i < aif.length; i++) { +// TCComponentBOMLine subline = (TCComponentBOMLine) aif[i] +// .getComponent(); +// List propertie = new ArrayList(); +// propertie +// .add(subline.getStringProperty("bl_indented_title") +// .split("/")[0]); +// propertie.add(subline.getStringProperty("bl_sequence_no")); +// propertie +// .add(subline +// .getStringProperty("bl_item_object_name") == null ? "" +// : subline +// .getStringProperty("bl_item_object_name")); +// //获取工序下的BOM +// List equipmentNameList = new ArrayList(); +// if(subline.getChildren().length>0) +// { +// for (int j = 0; j < subline.getChildren().length; j++) { +// TCComponentBOMLine subChildrenline = (TCComponentBOMLine) subline.getChildren()[j] +// .getComponent(); +// System.out.println(subChildrenline.getType()); +// if(subChildrenline.getType().indexOf("Equipment") >= 0) +// { +// TCComponentICO[] icos = subChildrenline.getItem().getLatestItemRevision() +// .getClassificationObjects(); +// if (icos.length > 0) { +// ICSProperty[] descriptions = icos[0] +// .getICSProperties(true); +// for (int k = 0; k < descriptions.length; k++) { +// if (descriptions[k].getId() == 1004 && descriptions[k].getValue() != null +// && !descriptions[k].getValue().equals("")) { +// System.out.println(equipmentNameList.toString()); +// if(!equipmentNameList.contains(descriptions[k].getValue())) +// { +// equipmentNameList.add(descriptions[k].getValue()); +// } +// System.out.println(equipmentNameList.toString()); +// //sb.append(descriptions[k].getValue()+","); +// +// } +// } +// } +// } +// } +// } +// if(equipmentNameList.size() > 0) +// { +// propertie.add(equipmentNameList.toString().substring(1, equipmentNameList.toString().length()-1)); +// } +// else +// { +// propertie.add(""); +// } +// properties.add(propertie); +// } +// return properties; +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// return null; +// } + /** + * 获取插入到权限表的BOM行 + * @param session + * @param item + * @return + */ + public static List> getPermissionsBomPropertys(TCSession session, TCComponentItem item) { + // TODO Auto-generated method stub + //获取BOM + TCComponentBOMWindow bomWindow = null; + + try { + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topBomLine = bomWindow.setWindowTopLine(item, + item.getLatestItemRevision(), null, null); + //获取工艺下的控制计划对象 + TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); + List itme = new ArrayList(); + for (int i = 0; i < kzjh.length; i++) { + if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) + { + itme.add((TCComponentItem)kzjh[i]); + } + } + // 获取工序对象 + AIFComponentContext aif[] = topBomLine.getChildren(); + List> properties = new ArrayList>(); + for (int i = 0; i < aif.length; i++) { + if(((TCComponentBOMLine)aif[i].getComponent()).getItem().getType().equals("MEProcess")) + { + continue; + } + TCComponentBOMLine subline = (TCComponentBOMLine) aif[i] + .getComponent(); + List propertie = new ArrayList(); + propertie + .add(subline.getStringProperty("bl_indented_title") + .split("/")[0]); + propertie.add(subline.getStringProperty("bl_sequence_no")); + + String objectName = subline.getStringProperty("bl_item_object_name") == null ? "" + : subline.getStringProperty("bl_item_object_name"); + if(objectName.indexOf("/") >= 0) + { + propertie.add(objectName.split("/")[0]); + } + else + { + propertie.add(objectName); + } + //+++获取工序号 + propertie.add(subline.getStringProperty("RB3_GXH")); + //+++ + //获取工序下的BOM + List equipmentNameList = new ArrayList(); + if(subline.getChildren().length>0) + { + for (int j = 0; j < subline.getChildren().length; j++) { + TCComponentBOMLine subChildrenline = (TCComponentBOMLine) subline.getChildren()[j] + .getComponent(); + System.out.println(subChildrenline.getType()); + //if(subChildrenline.getType().indexOf("Equipment") >= 0) + //{ + equipmentNameList.add(subChildrenline.getItem().getStringProperty("item_id")); +// TCComponentICO[] icos = subChildrenline.getItem().getLatestItemRevision() +// .getClassificationObjects(); +// +// if (icos.length > 0) { +// ICSProperty[] descriptions = icos[0] +// .getICSProperties(true); +// for (int k = 0; k < descriptions.length; k++) { +// if (descriptions[k].getId() == 1004 && descriptions[k].getValue() != null +// && !descriptions[k].getValue().equals("")) { +// System.out.println(equipmentNameList.toString()); +// if(!equipmentNameList.contains(descriptions[k].getValue())) +// { +// equipmentNameList.add(descriptions[k].getValue()); +// } +// System.out.println(equipmentNameList.toString()); +// //sb.append(descriptions[k].getValue()+","); +// +// } +// } +// } + //} + } + } + if(equipmentNameList.size() > 0) + { + propertie.add(equipmentNameList.toString().substring(1, equipmentNameList.toString().length()-1)); + } + else + { + propertie.add(""); + } + properties.add(propertie); + } + return properties; + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return null; + } + + /** + * 获取BOM信息 + * @param meprocess 工艺BOMLINE + * @param isMeop 是否是PFEMA + * + */ + public static void getBomPropertys(TCComponentBOMLine meprocessBomLine, boolean isPFEMA) + { + try { + //获取工艺下的BOM + AIFComponentContext aif[] = meprocessBomLine.getChildren(); + for (int i = 0; i < aif.length; i++) { + if(aif[i]==null) {//防止 + continue; + } + TCComponentBOMLine subline = (TCComponentBOMLine) aif[i] + .getComponent(); + if(subline==null) { + continue; + } + + TCComponentItem item = subline.getItem(); + + System.out.println("type ==> "+item.getType()); + + //判断是否是工艺 + if(item.getType().equals("ZF6_GYLXRevision")) //.getType().equals("MEProcess") + { + getBomPropertys(subline, isPFEMA); + } + else // if(item.getType().equals("HS2_MEOP")) + { + List propertie = new ArrayList(); + //String ss = subline.getStringProperty("bl_indented_title"); + propertie.add(subline.getStringProperty("bl_indented_title") + .split("/")[0]); + //控制计划中的零件/工艺编号改为工序号 + //propertie.add(subline.getStringProperty("bl_sequence_no")); + propertie.add(subline.getStringProperty("bl_sequence_no")==null ? "": + subline.getStringProperty("bl_sequence_no")); + String bzString = subline.getStringProperty("bl_item_object_name") == null ? "": subline.getStringProperty("bl_item_object_name"); + String processNo = subline.getItemRevision().getStringProperty("zf6_ywfy") == null ? "": subline.getItemRevision().getStringProperty("zf6_ywfy"); + propertie.add(bzString+processNo); + + //获取工序下的BOM的资源,机器设备。PFMEA跳过 + if(isPFEMA) + { + propertie.add(""); + }else { + List equipmentNameList = new ArrayList(); + if(subline.getChildren().length>0) + { + for (int j = 0; j < subline.getChildren().length; j++) { + TCComponentBOMLine subChildrenline = (TCComponentBOMLine) subline.getChildren()[j] + .getComponent(); + if(subChildrenline.toString().equals("<<无法读取>>")&&subChildrenline!=null) {//防止工艺资源出错,无权限读取 + continue; + } + System.out.println(subChildrenline.getType()); + String ClassID=subChildrenline.getItemRevision().getClassificationClass(); + if(ClassID!=null&&!ClassID.equals("")&&ClassID.length()>2) { + if(ClassID.substring(0,2).equals("15")) { + equipmentNameList.add(subChildrenline.getItem().getStringProperty("object_name")); + } + } + + } + } + if(equipmentNameList.size() > 0) + { + propertie.add(equipmentNameList.toString().substring(1, equipmentNameList.toString().length()-1)); + } + else + { + propertie.add(""); + } + } + propertie.add(subline.getItemRevision().getUid()); + propertie.add(String.valueOf(bomPropertyList.size()+1)); + bomPropertyList.add(propertie); + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + /*** + * 根据正则表达式提取括号中的内容 + * @param value + * @return + */ + public static List getListByRegular(String value) + { + List resultList = new ArrayList(); + Pattern p = Pattern.compile("(\\[[^\\]]*\\])"); + Matcher m = p.matcher(value); + while(m.find()) + { + resultList.add(m.group().substring(1, m.group().length() - 1)); + } + return resultList; + } + + public static int getDays(String dateStr1, String dateStr2, String dateFormat) { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormat); + Date date1 = null; + Date date2 = null; + try { + date1 = simpleDateFormat.parse(dateStr1); + date2 = simpleDateFormat.parse(dateStr2); + } catch (ParseException e) { + e.printStackTrace(); + } + + String year1 = String.format("%tY", date1); + String mon1 = String.format("%tm", date1); + String day1 = String.format("%td", date1); + int y1 = Integer.valueOf(year1); + int m1 = Integer.valueOf(mon1); + int d1 = Integer.valueOf(day1); + int days1 = getRecentYearDays(y1, m1, d1); + System.out.println(days1); + + String year2 = String.format("%tY", date2); + String mon2 = String.format("%tm", date2); + String day2 = String.format("%td", date2); + int y2 = Integer.valueOf(year2); + int m2 = Integer.valueOf(mon2); + int d2 = Integer.valueOf(day2); + int days2 = getRecentYearDays(y2, m2, d2); + System.out.println(days2); + + int count = 0; + for (int i = y1; i < y2; i++) { + if ((i % 4 == 0 && i % 100 != 0) || i % 400 == 0) { + count += 366; + } else { + count += 365; + } + } + count = count + days2 - days1; + + return count; + } + + public static int getRecentYearDays(int y, int m, int d) { + + int count = 0; + + switch (m - 1) { + case 1: + count += 31; + break; + case 2: + count += 31 + 28; + break; + case 3: + count += 31 + 28 + 31; + break; + case 4: + count += 31 + 28 + 31 + 30; + break; + case 5: + count += 31 + 28 + 31 + 30 + 31; + break; + case 6: + count += 31 + 28 + 31 + 30 + 31 + 30; + break; + case 7: + count += 31 + 28 + 31 + 30 + 31 + 30 + 31; + break; + case 8: + count += 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31; + break; + case 9: + count += 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30; + break; + case 10: + count += 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31; + break; + case 11: + count += 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30; + break; + } + if (((y % 4 == 0 && y % 100 != 0) || y % 400 == 0) && m > 2) + count++; + return count + d; + } + +// public static ControlPlanComboBoxBean[] getComboxItem(TCSession session,String pernaem) +// { +// ControlPlanComboBoxBean[] comboBoxBeans = null; +// TCPreferenceService pref = session.getPreferenceService(); +// String[] items = pref.getStringValues(pernaem);// 首选项查puid +// comboBoxBeans = new ControlPlanComboBoxBean[items.length]; +// for (int i = 0; i < items.length; i++) { +// if(items[i].indexOf("-")>0) +// { +// ControlPlanComboBoxBean bean = new ControlPlanComboBoxBean(); +// bean.setItemId(items[i].split("-")[0]); +// bean.setItemName(items[i].split("-")[1]); +// comboBoxBeans[i] = bean; +// } +// } +// return comboBoxBeans; +// } + +} diff --git a/src/com/connor/renben/process/plm/util/TableCellCheckboxRenderer.java b/src/com/connor/renben/process/plm/util/TableCellCheckboxRenderer.java new file mode 100644 index 0000000..ae2dc54 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/TableCellCheckboxRenderer.java @@ -0,0 +1,100 @@ +package com.connor.renben.process.plm.util; + +import java.awt.Checkbox; +import java.awt.Color; +import java.awt.Component; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.List; + +import javax.swing.JCheckBox; +import javax.swing.JLabel; +import javax.swing.JTable; +import javax.swing.JTextPane; +import javax.swing.SwingConstants; +import javax.swing.event.ChangeEvent; +import javax.swing.event.EventListenerList; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableCellRenderer; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.StyleConstants; + +import com.teamcenter.rac.util.MessageBox; + +public class TableCellCheckboxRenderer extends JCheckBox implements + TableCellRenderer { + private List processRows; + protected EventListenerList listenerList = new EventListenerList(); + protected ChangeEvent changeEvent = new ChangeEvent(this); + private DefaultTableModel tableModel; + private JTableHeader tableHeader; + + public List getProcessRows() { + return processRows; + } + + public void setProcessRows(List processRows) { + this.processRows = processRows; + } + + public TableCellCheckboxRenderer(final CTable table) { + this.tableModel = (DefaultTableModel) table.getModel(); + this.tableHeader = table.getTableHeader(); + this.setName("4"); + // selectBox = new JCheckBox(tableModel.getColumnName(1)); + this.setSelected(false); + tableHeader.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() > 0) { + // 获得选中列 + int selectColumn = tableHeader.columnAtPoint(e.getPoint()); + if (table.getColumnName(selectColumn).equals("4")) { + boolean value = !TableCellCheckboxRenderer.this.isSelected(); + TableCellCheckboxRenderer.this.setSelected(value); + table.selectAllOrNull(value ? "1" : "0"); + tableHeader.repaint(); + } + } + } + }); + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + // TODO Auto-generated method stub + this.setHorizontalAlignment(SwingConstants.CENTER);// 表头标签剧中 + this.setBorderPainted(true); + if(value != null) + { + this.setSelected(value.toString().equals("1")); + } + else + { + this.setSelected(false); + } +// if() +// String valueStr = (String) value; +// JLabel label = new JLabel(valueStr); +// label.setHorizontalAlignment(SwingConstants.CENTER); // 表头标签剧中 +// this.setHorizontalAlignment(SwingConstants.CENTER);// 表头标签剧中 +// this.setBorderPainted(true); + return this; + } + /** + * 查看一个字符串是否可以转换为数字 + * @param str 字符串 + * @return true 可以; false 不可以 + */ + public boolean isStr2Num(String str) { + try { + Integer.parseInt(str); + return true; + } catch (NumberFormatException e) { + return false; + } + } +} \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/util/TableCellTextAreaRenderer.java b/src/com/connor/renben/process/plm/util/TableCellTextAreaRenderer.java new file mode 100644 index 0000000..3deaef6 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/TableCellTextAreaRenderer.java @@ -0,0 +1,207 @@ +package com.connor.renben.process.plm.util; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.util.List; + +import javax.swing.BorderFactory; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.JTextPane; +import javax.swing.table.TableCellRenderer; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.StyleConstants; + +import org.w3c.dom.css.RGBColor; + +public class TableCellTextAreaRenderer extends JTextPane implements + TableCellRenderer { + private List processRows; + private boolean isRelease=false; + public List getProcessRows() { + return processRows; + } + public void setProcessRows(List processRows) { + this.processRows = processRows; + } + public TableCellTextAreaRenderer() { + // setLineWrap(true);//自动换行 + // setWrapStyleWord(true); + } + + public void setIsRelease(boolean isRelease) { + this.isRelease=isRelease; + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + // TODO Auto-generated method stub + int maxPreferredHeight = 0; + if (table.getColumnName(column).equals("RPN")) { + // 5,9,11 + String yzd = table.getValueAt(row, 7) == null ? "0" : table + .getValueAt(row, 7).toString(); + String pds = table.getValueAt(row, 11) == null ? "0" : table + .getValueAt(row, 11).toString(); + String tcd = table.getValueAt(row, 13) == null ? "0" : table + .getValueAt(row, 13).toString(); + int rpn = Integer.parseInt(yzd) * Integer.parseInt(pds) + * Integer.parseInt(tcd); + if (rpn == 0) { + table.setValueAt("", row, column); + setText(""); + } else { + table.setValueAt(String.valueOf(rpn), row, column); + setText(String.valueOf(rpn)); + } + } else { + setText(value == null ? "" : value.toString()); + } + // 特殊符号 + // setText(value == null ? "" : value.toString()); + // if(table.getValueAt(row, table.getColumnCount()-1) == null) + // { + // return this; + // } + // String special = table.getValueAt(row, + // table.getColumnCount()-1).toString(); + // if(special.indexOf("|") >= 0) + // { + // String[] specials = special.split("\\|"); + // for (int i = 0; i < specials.length; i++) { + // if(specials[i].indexOf("-") >= 0) + // { + // String[] columnName = specials[i].split("-"); + // if(table.getColumnName(column).equals(columnName[0])) + // { + // setTextFont(value.toString(),Integer.parseInt(columnName[1]) + // ,"Y14.5M"); + // } + // } + // } + // } + // else if(special.indexOf("-") >= 0) + // { + // String[] columnName = special.split("-"); + // if(table.getColumnName(column).equals(columnName[0])) + // { + // setTextFont(value.toString(),Integer.parseInt(columnName[1]) + // ,"Y14.5M"); + // } + // } + // if(value!=null) + // { + // if(column == 1) + // { + // setTextFont(value.toString(),"Y14.5M"); + // } + // } + + for (int i = 0; i < table.getColumnCount(); i++) { + setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + maxPreferredHeight = Math.max(maxPreferredHeight, + getPreferredSize().height); + } + if (table.getColumnName(column).equals("RPN") && value != null + && !value.equals("") + && Integer.parseInt(value.toString()) >= 100) { + setBackground(Color.RED); + setForeground(Color.black); + } + else if (isRelease) { + setBackground(new Color(220,220,220)); + setForeground(Color.black); + } + + else { + setBackground(Color.white); + setForeground(Color.black); + } + if (isSelected) { + setBackground(new Color(184,184,184)); + setForeground(Color.black); + } + if (table.getRowHeight(row) != maxPreferredHeight)// 少了这行则处理器瞎忙 + { + table.setRowHeight(row, maxPreferredHeight); + } + return this; + } + + // 设置字体,如一个字符串中需要包含多个字体样式,可创建多个SimpleAttributeSet,并将字符串拆分开,按顺序使用Document的insertString方法插入 + private void setTextFont(String value, int index, String font) { + // TODO Auto-generated method stub + SimpleAttributeSet set = new SimpleAttributeSet(); + // StyleConstants.setForeground(set, Color.red);//设置文字颜色 + StyleConstants.setFontFamily(set, font);// 设置字体样式 + SimpleAttributeSet set2 = new SimpleAttributeSet(); + // StyleConstants.setForeground(set, Color.red);//设置文字颜色 + StyleConstants.setFontFamily(set2, "Courier New");// 设置字体样式 + // StyleConstants.setFontSize(set2, 10); + Document doc = this.getStyledDocument(); + try { + // 插入前需要先删除 + doc.remove(0, value.toString().length()); + value = value.replaceAll(" ", ""); + doc.insertString(doc.getLength(), + value.toString().substring(0, index), set2); + doc.insertString(doc.getLength(), + value.toString().substring(index, index + 1), set); + doc.insertString( + doc.getLength(), + value.toString().substring(index + 1, + value.toString().length()), set2); + if (value.toString() + .substring(index + 1, value.toString().length()) == null + || value.toString() + .substring(index + 1, value.toString().length()) + .equals("")) { + doc.insertString(doc.getLength(), " ", set2); + } + } catch (BadLocationException e) { + e.printStackTrace(); + } finally { + set = null; + doc = null; + System.gc(); + } + } + // + // @Override + // public Component getTableCellRendererComponent(JTable table, Object + // value, boolean isSelected, boolean hasFocus, + // int row, int column) { + // // TODO Auto-generated method stub + // int maxPreferredHeight = 0; + // for (int i = 0; i < table.getColumnCount(); i++) { + // setText("" + table.getValueAt(row, i)); + // setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + // maxPreferredHeight = Math.max(maxPreferredHeight, + // getPreferredSize().height); + // } + // setBorder(BorderFactory.createLineBorder(Color.white)); + // setBackground(Color.white); + // setForeground(Color.black); + // if(isSelected){ + // setBackground(new Color(0, 120, 215)); + // setForeground(Color.white); + // } + // String val=(String) table.getValueAt(row, column); + // int w=0; + // if(val!=null){ + // w=val.length()*6/table.getColumn(table.getColumnName(column)).getWidth(); + // } + // if(w!=0){ + // //System.out.println("height:"+table.getRowHeight()*(w+1)); + // table.setRowHeight(row,table.getRowHeight()*(w+1)); + // } + // + // + // setText(value == null ? "" : value.toString()); + // return this; + // } +} \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/util/TextAreaCellEditor.java b/src/com/connor/renben/process/plm/util/TextAreaCellEditor.java new file mode 100644 index 0000000..df485b9 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/TextAreaCellEditor.java @@ -0,0 +1,193 @@ +package com.connor.renben.process.plm.util; + +import java.awt.Component; +import java.util.EventObject; + +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextPane; +import javax.swing.event.CaretEvent; +import javax.swing.event.CaretListener; +import javax.swing.event.CellEditorListener; +import javax.swing.event.ChangeEvent; +import javax.swing.event.EventListenerList; +import javax.swing.table.TableCellEditor; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.StyleConstants; + +public class TextAreaCellEditor extends JTextPane implements TableCellEditor, + CaretListener { + private static final long serialVersionUID = 5860619160549087886L; + private EventListenerList listenerList = new EventListenerList(); + private ChangeEvent changeEvent = new ChangeEvent(this); + private int index;// 光标所在位置 + + public TextAreaCellEditor() { + // TODO Auto-generated constructor stub + super(); + this.addCaretListener(this); + // this.setLineWrap(true); //自动换行 + // this.setWrapStyleWord(true); + } + + public int getIndex() { + return index; + } + + @Override + public void addCellEditorListener(CellEditorListener listener) { + // TODO Auto-generated method stub + listenerList.add(CellEditorListener.class, listener); + } + + @Override + public void cancelCellEditing() { + // TODO Auto-generated method stub + System.out.println(2); + } + + @Override + public Object getCellEditorValue() { + // TODO Auto-generated method stub + // System.out.println(3); + return this.getText(); + } + + @Override + public boolean isCellEditable(EventObject arg0) { + // TODO Auto-generated method stub + return true; + } + + @Override + public void removeCellEditorListener(CellEditorListener listener) { + // TODO Auto-generated method stub + listenerList.remove(CellEditorListener.class, listener); + } + + private void fireEditingStopped() { + CellEditorListener listener; + Object[] listeners = listenerList.getListenerList(); + for (int i = 0; i < listeners.length; i++) { + if (listeners[i] == CellEditorListener.class) { + // 之所以是i+1,是因为一个为CellEditorListener.class(Class对象), + // 接着的是一个CellEditorListener的实例 + listener = (CellEditorListener) listeners[i + 1]; + // 让changeEvent去通知编辑器已经结束编辑 + // 在editingStopped方法中,JTable调用getCellEditorValue()取回单元格的值, + // 并且把这个值传递给TableValues(TableModel)的setValueAt() + try { + listener.editingStopped(changeEvent); + } catch (Exception e) { + // TODO: handle exception + System.out.println(e.toString()); + } + } + } + } + + @Override + public boolean shouldSelectCell(EventObject arg0) { + // TODO Auto-generated method stub + return true; + } + + @Override + public boolean stopCellEditing() { + // TODO Auto-generated method stub + // 可以注释掉下面的fireEditingStopped();,然后在GenderEditor的构造函数中把 + // addActionListener()的注释去掉(这时请求终止编辑操作从JComboBox获得), + // System.out.println("编辑其中一个单元格,再点击另一个单元格时,调用。"); + fireEditingStopped();// 请求终止编辑操作从JTable获得 + return true; + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, + boolean isSelect, int row, int column) { + // TODO Auto-generated method stub + setText(value == null ? "" : value.toString()); + // 特殊符号 + if (table.getValueAt(row, table.getColumnCount() - 1) == null) { + return new JScrollPane(this); + } + String special = table.getValueAt(row, table.getColumnCount() - 1) + .toString(); + if (special.indexOf("|") >= 0) { + String[] specials = special.split("\\|"); + for (int i = 0; i < specials.length; i++) { + if (specials[i].indexOf("-") >= 0) { + String[] columnName = specials[i].split("-"); + if (table.getColumnName(column).equals(columnName[0])) { + setTextFont(value.toString(), + Integer.parseInt(columnName[1]), "Y14.5M"); + } + } + } + } else if (special.indexOf("-") >= 0) { + String[] columnName = special.split("-"); + if (table.getColumnName(column).equals(columnName[0])) { + setTextFont(value.toString(), Integer.parseInt(columnName[1]), + "Y14.5M"); + } + } + // if(value!=null) + // { + // if(cloumn == 1) + // { + // setTextFont(value.toString(),"Y14.5M"); + // } + // } + // System.out.println(8) + return new JScrollPane(this); + } + + @Override + public void caretUpdate(CaretEvent caretevent) { + // TODO Auto-generated method stub + index = caretevent.getMark(); + // System.out.println(index); + } + + // 设置字体,如一个字符串中需要包含多个字体样式,可创建多个SimpleAttributeSet,并将字符串拆分开,按顺序使用Document的insertString方法插入 + private void setTextFont(String value, int index, String font) { + // TODO Auto-generated method stub + SimpleAttributeSet set = new SimpleAttributeSet(); + // StyleConstants.setForeground(set, Color.red);//设置文字颜色 + StyleConstants.setFontFamily(set, font);// 设置字体样式 + // StyleConstants.setFontSize(set, 14); + SimpleAttributeSet set2 = new SimpleAttributeSet(); + // StyleConstants.setForeground(set, Color.red);//设置文字颜色 + StyleConstants.setFontFamily(set2, "Courier New");// 设置字体样式 + // StyleConstants.setFontSize(set2, 10); + Document doc = this.getStyledDocument(); + try { + // 插入前需要先删除 + doc.remove(0, value.toString().length()); + value = value.replaceAll(" ", ""); + doc.insertString(doc.getLength(), + value.toString().substring(0, index), set2); + doc.insertString(doc.getLength(), + value.toString().substring(index, index + 1), set); + doc.insertString( + doc.getLength(), + value.toString().substring(index + 1, + value.toString().length()), set2); + if (value.toString() + .substring(index + 1, value.toString().length()) == null + || value.toString() + .substring(index + 1, value.toString().length()) + .equals("")) { + doc.insertString(doc.getLength(), " ", set2); + } + } catch (BadLocationException e) { + e.printStackTrace(); + } finally { + set = null; + doc = null; + System.gc(); + } + } +} diff --git a/src/com/connor/renben/process/plm/util/TreeComboBox.java b/src/com/connor/renben/process/plm/util/TreeComboBox.java new file mode 100644 index 0000000..14edb49 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/TreeComboBox.java @@ -0,0 +1,298 @@ +//package com.connor.renben.process.plm.util; +// +//import java.awt.Color; +//import java.awt.Component; +//import java.awt.Container; +//import java.awt.Dimension; +//import java.awt.Graphics; +//import java.awt.Insets; +//import java.awt.LayoutManager; +//import java.awt.event.ActionEvent; +//import java.awt.event.ActionListener; +//import java.awt.event.KeyEvent; +//import java.awt.event.KeyListener; +//import java.awt.event.MouseEvent; +//import java.awt.event.MouseListener; +//import java.util.ArrayList; +//import java.util.Enumeration; +//import java.util.List; +// +//import javax.swing.JButton; +//import javax.swing.JComponent; +//import javax.swing.JPanel; +//import javax.swing.JScrollPane; +//import javax.swing.JTextArea; +//import javax.swing.JTextField; +//import javax.swing.UIManager; +//import javax.swing.plaf.basic.BasicArrowButton; +//import javax.swing.tree.DefaultMutableTreeNode; +//import javax.swing.tree.TreeNode; +//import javax.swing.tree.TreePath; +// +//import com.connor.renben.process.plm.bean.TMomUserBean; +//import com.teamcenter.rac.kernel.TCComponent; +//import com.teamcenter.rac.kernel.TCException; +//import com.teamcenter.rac.kernel.TCSession; +//import com.teamcenter.rac.util.MessageBox; +//import com.teamcenter.rac.util.PropertyLayout; +// +//public class TreeComboBox extends JComponent { +// +// private Object[] values; +// +// public Object[] defaultValues; +// +// private List listeners = new ArrayList(); +// +// public TreeComboBoxPopup popup; +// +// public JTextArea editor; +// +// protected JButton arrowButton; +// +// private String valueSperator; +// +// private TCSession session; +// private String value; +// private List nameList = new ArrayList(); +// +// private static final String DEFAULT_VALUE_SPERATOR = ","; +// +// public TreeComboBox(Object[] value, Object[] defaultValue,TCSession session) { +// this(value, defaultValue, DEFAULT_VALUE_SPERATOR,session); +// } +// +// public TreeComboBox(Object[] value, Object[] defaultValue, String valueSperator,TCSession session) { +// values = value; +// defaultValues = defaultValue; +// this.valueSperator = valueSperator; +// this.session = session; +// initComponent(); +// } +// +// private void initComponent() { +// // 暂时使用该布局,后续自己写个布局 +// this.setLayout(new PropertyLayout()); +// // this.set +// popup = new TreeComboBoxPopup(values, defaultValues,session); +// popup.addActionListener(new PopupAction()); +// +// editor = new JTextArea(); +// editor.setBackground(Color.WHITE); +// editor.setEditable(true); +//// editor.setBorder(getBorder()); +// editor.addKeyListener(new KeyListener() { +// +// @Override +// public void keyTyped(KeyEvent e) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void keyReleased(KeyEvent e) { +// // TODO Auto-generated method stub +// char ch = e.getKeyChar(); +// // if (ch == KeyEvent.CHAR_UNDEFINED || Character.isISOControl(ch) +// // || ch == KeyEvent.VK_DELETE) +// // return; +// if (e.getKeyCode() == KeyEvent.VK_ENTER) { +// editor.setText(editor.getText().substring(0, editor.getText().length()-1)); +// int caretPosition = editor.getCaretPosition(); +// String str = editor.getText(); +// if (str.length() == 0) +// return; +// +// if (value != null && !value.equals(str)) { +// nameList.clear(); +// value = str; +// } else { +// value = str; +// } +// DefaultMutableTreeNode node = popup.searchNode( +// str, nameList); +// if (node != null) { +// String user = ((String) node.getUserObject()); +// nameList.add(user); +// TreeNode[] nodes = popup.m_model.getPathToRoot(node); +// TreePath path = new TreePath(nodes); +// popup.tree.scrollPathToVisible(path); +// popup.tree.setSelectionPath(path); +// +// togglePopup(); +// } else { +// MessageBox.post("未找到选项", "错误", MessageBox.ERROR); +// nameList.clear(); +// } +// +// +// //autoComplete(str, caretPosition); +// } +// } +// +// @Override +// public void keyPressed(KeyEvent e) { +// // TODO Auto-generated method stub +// +// } +// }); +// //editor.addMouseListener(new EditorHandler()); +// arrowButton = new JButton("↓");//createArrowButton(); +// arrowButton.setPreferredSize(new Dimension(50, 60)); +// arrowButton.addMouseListener(new EditorHandler()); +// JScrollPane scrollPane1 = new JScrollPane(); // 给jta加滚动条 +// scrollPane1.setPreferredSize(new Dimension(335, 58)); +// scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); +// scrollPane1.setViewportView(this.editor); +// add("1.1.left.top", scrollPane1); +// add("1.2.left.top", arrowButton); +// // 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(TreeComboBoxPopup.CANCEL_EVENT)) { +// popup.setVisible(false); +// } else if (e.getActionCommand().equals(TreeComboBoxPopup.COMMIT_EVENT)) { +// defaultValues = popup.getSelectedValues(); +// if(defaultValues.length > 0) +// { +// setText(); +// // 把事件继续传递出去 +// fireActionPerformed(e); +// popup.setVisible(false); +// //togglePopup(); +// } +// } +// else if (e.getActionCommand().equals(TreeComboBoxPopup.CANCEL_NEXT)) { +// DefaultMutableTreeNode node = popup.searchNode( +// editor.getText(), nameList); +// if (node != null) { +// String user = ((String) node.getUserObject()); +// nameList.add(user); +// TreeNode[] nodes = popup.m_model.getPathToRoot(node); +// TreePath path = new TreePath(nodes); +// popup.tree.scrollPathToVisible(path); +// popup.tree.setSelectionPath(path); +// } else { +// MessageBox.post("未找到选项", "错误", MessageBox.ERROR); +// nameList.clear(); +// } +// } +// +// +// } +// +// } +// +// 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/com/connor/renben/process/plm/util/TreeComboBoxPopup.java b/src/com/connor/renben/process/plm/util/TreeComboBoxPopup.java new file mode 100644 index 0000000..34b2e4a --- /dev/null +++ b/src/com/connor/renben/process/plm/util/TreeComboBoxPopup.java @@ -0,0 +1,269 @@ +//package com.connor.renben.process.plm.util; +// +//import java.awt.BorderLayout; +//import java.awt.Dimension; +//import java.awt.GridLayout; +//import java.awt.event.ActionEvent; +//import java.awt.event.ActionListener; +//import java.io.File; +//import java.io.FileNotFoundException; +//import java.io.IOException; +//import java.util.ArrayList; +//import java.util.Enumeration; +//import java.util.List; +// +//import javax.swing.JButton; +//import javax.swing.JPanel; +//import javax.swing.JPopupMenu; +//import javax.swing.JScrollPane; +//import javax.swing.JTree; +//import javax.swing.tree.DefaultMutableTreeNode; +//import javax.swing.tree.DefaultTreeModel; +//import javax.swing.tree.TreeNode; +//import javax.swing.tree.TreePath; +// +//import com.connor.renben.process.plm.bean.TMomUserBean; +//import com.teamcenter.rac.kernel.TCComponent; +//import com.teamcenter.rac.kernel.TCException; +//import com.teamcenter.rac.kernel.TCSession; +//import com.teamcenter.rac.util.MessageBox; +// +//public class TreeComboBoxPopup extends JPopupMenu { +// +// private List listeners = new ArrayList(); +// +// private TCSession session; +// +// private Object[] values; +// +// private Object[] defaultValues; +// +// // private List checkBoxList = new ArrayList(); +// +// public JTree tree; +// public DefaultMutableTreeNode parentNode = null; +// public DefaultTreeModel m_model = null; +// public String nodeStr; +// +// private JButton commitButton; +// +// private JButton cancelButton; +// +// private JButton nextButton; +// +// public static final String COMMIT_EVENT = "commit"; +// +// public static final String CANCEL_EVENT = "cancel"; +// +// public static final String CANCEL_NEXT = "next"; +// +// public TreeComboBoxPopup(Object[] value, Object[] defaultValue, TCSession session) { +// super(); +// values = value; +// defaultValues = defaultValue; +// this.session = session; +// 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 treePane = new JPanel(); +// +// JPanel buttonPane = new JPanel(); +// +// this.setLayout(new BorderLayout()); +// +// // 定义几个初始节点 +// +// // File file = new File("C:\\Users\\Administrator\\Desktop\\web\\委托单下拉选项.xlsx"); +// +// File file = TMomMethodUtil.getFile(session, "应用领域", "MSExcelX"); +// +// try { +// parentNode = ExcelUtil07.readExcelNodeByEntrustment(file, "应用领域"); +// } catch (FileNotFoundException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// this.setPreferredSize(new Dimension(465, 400)); +//// DefaultMutableTreeNode parentNode = new DefaultMutableTreeNode( +//// "Agile.201304.WI"); +//// +//// DefaultMutableTreeNode iteration1 = new DefaultMutableTreeNode("迭代1"); +//// +//// DefaultMutableTreeNode iteration2 = new DefaultMutableTreeNode("迭代2"); +//// +//// DefaultMutableTreeNode iteration3 = new DefaultMutableTreeNode("迭代3"); +//// +//// // 通过add方法建立树节点之间的父子关系 +//// +//// parentNode.add(iteration1); +//// +//// parentNode.add(iteration2); +//// +//// parentNode.add(iteration3); +// +// // 以根节点创建树 +// m_model = new DefaultTreeModel(parentNode); +// tree = new JTree(m_model); +// +// // 设置是否显示根节点的“展开/折叠”图标,默认是false +// +// tree.setShowsRootHandles(true); +// +// // 设置节点是否可见,默认是true +// +// tree.setRootVisible(true); +// +// treePane.setLayout(new GridLayout(0, 1, 3, 3)); +// treePane.add(new JScrollPane(tree)); +//// 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(); +// } +// +// }); +// +// nextButton = new JButton("下一个"); +// +// nextButton.addActionListener(new ActionListener() { +// +// public void actionPerformed(ActionEvent e) { +// next(); +// } +// +// }); +// +// buttonPane.add(commitButton); +// +// buttonPane.add(cancelButton); +// +// buttonPane.add(nextButton); +// +// this.add(treePane, BorderLayout.CENTER); +// +// this.add(buttonPane, BorderLayout.SOUTH); +// +// } +// +// // 查找满足添加的节点 +// public DefaultMutableTreeNode searchNode(String nodeStr, List nameList) { +// this.nodeStr = nodeStr; +// DefaultMutableTreeNode node = null; +// Enumeration e = this.parentNode.breadthFirstEnumeration(); +// while (e.hasMoreElements()) { +// node = (DefaultMutableTreeNode) e.nextElement(); +// +// if (node.getUserObject() instanceof String) { +// String user = (String) node.getUserObject(); +// try { +// if (user != null) { +//// System.out.println(user); +//// System.out.println(nodeStr); +// if ((user.indexOf(nodeStr) >= 0 || user.indexOf(nodeStr) >= 0) && !nameList.contains(user)) { +// return node; +// } +// } +// } catch (Exception e1) { +// e1.printStackTrace(); +// } +// } +// } +// return null; +// } +// +// 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(); +// +// int[] rows = tree.getSelectionRows(); +// for (int i = 0; i < rows.length; i++) { +// try { +// Object selectObj = tree.getPathForRow(rows[i]).getPathComponent(3); +// if (selectObj instanceof DefaultMutableTreeNode) { +// selectedValues.add(selectObj); +// } +// } catch (Exception ex) { +// // MessageBox.post("请选择最底层节点!", "错误", MessageBox.ERROR); +// } +// } +// +// 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 next() { +// fireActionPerformed(new ActionEvent(this, 0, CANCEL_NEXT)); +//// DefaultMutableTreeNode node = searchNode( +//// nodeStr, nameList); +//// if (node != null) { +//// String user = ((String) node.getUserObject()); +//// nameList.add(user); +//// TreeNode[] nodes = m_model.getPathToRoot(node); +//// TreePath path = new TreePath(nodes); +//// tree.scrollPathToVisible(path); +//// tree.setSelectionPath(path); +//// +//// //togglePopup(); +//// } else { +//// //MessageBox.post("未找到选项", "错误", MessageBox.ERROR); +//// nameList.clear(); +//// } +// } +//} diff --git a/src/com/connor/renben/process/plm/util/TreeTableCellEditor.java b/src/com/connor/renben/process/plm/util/TreeTableCellEditor.java new file mode 100644 index 0000000..2494568 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/TreeTableCellEditor.java @@ -0,0 +1,36 @@ +package com.connor.renben.process.plm.util; + +import java.awt.Component; + +import javax.swing.JTable; +import javax.swing.JTree; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeCellEditor; +import javax.swing.tree.DefaultTreeCellRenderer; +import javax.swing.tree.TreeCellEditor; + +public class TreeTableCellEditor extends DefaultTreeCellEditor { + + JTable table; + + @Override + public Component getTreeCellEditorComponent(JTree tree, Object value, + boolean isSelected, boolean expanded, boolean leaf, int row) { + DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; + Object ud = node.getUserObject(); + if (!(ud instanceof JTable) || !leaf) { + return super.getTreeCellEditorComponent(tree, value, isSelected, + expanded, leaf, row); + } + return (JTable) ud; + } + + public TreeTableCellEditor(JTree tree, DefaultTreeCellRenderer renderer, + TreeCellEditor editor) { + super(tree, renderer, editor); + } + + public TreeTableCellEditor(JTree tree, DefaultTreeCellRenderer renderer) { + super(tree, renderer); + } +} diff --git a/src/com/connor/renben/process/plm/util/TreeTableCellRenderer.java b/src/com/connor/renben/process/plm/util/TreeTableCellRenderer.java new file mode 100644 index 0000000..06a396c --- /dev/null +++ b/src/com/connor/renben/process/plm/util/TreeTableCellRenderer.java @@ -0,0 +1,26 @@ +package com.connor.renben.process.plm.util; + +import java.awt.Component; + +import javax.swing.JTable; +import javax.swing.JTree; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeCellRenderer; + +public class TreeTableCellRenderer extends DefaultTreeCellRenderer { + JTable table; + + @Override + public Component getTreeCellRendererComponent(JTree tree, Object value, + boolean selected, boolean expanded, boolean leaf, int row, + boolean hasFocus) { + DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; + Object ud = node.getUserObject(); + + if (!(ud instanceof JTable) || !leaf) { + return super.getTreeCellRendererComponent(tree, value, leaf, + expanded, leaf, row, hasFocus); + } + return (JTable) ud; + } +} diff --git a/src/com/connor/zf/controlplan/Adapter.java b/src/com/connor/zf/controlplan/Adapter.java new file mode 100644 index 0000000..5c25f0f --- /dev/null +++ b/src/com/connor/zf/controlplan/Adapter.java @@ -0,0 +1,299 @@ +package com.connor.zf.controlplan; + +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.StringSelection; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.util.ArrayList; +import java.util.List; +import java.util.StringTokenizer; + +import javax.swing.JComponent; +import javax.swing.JOptionPane; +import javax.swing.JTable; +import javax.swing.KeyStroke; + +/** + * Adapter 实现 JTables 中的复制粘贴 剪贴板功能。 适配器所用的剪贴板数据格式 与 Excel 所用的剪贴板格式兼容。这提供了 + * 支持的 JTables 和 Excel 间的互操作。 + */ +public class Adapter implements ActionListener { + private String rowstring, value; + private Clipboard system; + private StringSelection stsel; + private JTable jTable1; + private List> selectValue = new ArrayList>(); + + /** + * Excel 适配器由 JTable 构成, 它实现了 JTable 上的复制粘贴 功能,并充当剪贴板监听程序。 + */ + + public Adapter(JTable myJTable) { + jTable1 = myJTable; + KeyStroke copy = KeyStroke.getKeyStroke(KeyEvent.VK_C, + ActionEvent.CTRL_MASK, false); + + // 确定复制按键用户可以对其进行修改 + // 以实现其它按键组合的复制功能。 + KeyStroke paste = KeyStroke.getKeyStroke(KeyEvent.VK_V, + ActionEvent.CTRL_MASK, false); + + // 确定粘贴按键用户可以对其进行修改 + // 以实现其它按键组合的复制功能。 + + jTable1.registerKeyboardAction(this, "Copy", copy, + JComponent.WHEN_FOCUSED); + + jTable1.registerKeyboardAction(this, "Paste", paste, + JComponent.WHEN_FOCUSED); + + system = Toolkit.getDefaultToolkit().getSystemClipboard(); + } + + /** + * 此适配器运行图表的公共读方法。 + */ + public JTable getJTable() { + return jTable1; + } + + public void setJTable(JTable jTable1) { + this.jTable1 = jTable1; + } + + /** + * 在我们监听此实现的按键上激活这种方法。 此处,它监听复制和粘贴 ActionCommands。 包含不相邻单元格的选择导致选择无效, + * 而且此后复制动作无法执行。 粘贴的方法是将选定内容的左上角与 JTable 的当前选定内容的第一个元素对齐。 + */ + public void actionPerformed(ActionEvent e) { + if (e.getActionCommand().compareTo("Copy") == 0) { + StringBuffer sbf = new StringBuffer(); + + selectValue.clear(); + // 检查以确保我们仅选择了单元格的 + // 相邻块 + int numcols = jTable1.getSelectedColumnCount(); + int numrows = jTable1.getSelectedRowCount(); + int[] rowsselected = jTable1.getSelectedRows(); + int[] colsselected = jTable1.getSelectedColumns(); + +// if (!((numrows - 1 == rowsselected[rowsselected.length - 1] +// - rowsselected[0] && numrows == rowsselected.length) && (numcols - 1 == colsselected[colsselected.length - 1] +// - colsselected[0] && numcols == colsselected.length))) { +// JOptionPane.showMessageDialog(null, "Invalid Copy Selection", +// "Invalid Copy Selection", JOptionPane.ERROR_MESSAGE); +// +// return; +// } + + for (int i=0;i= 0) + { + sbf.append("\""); + sbf.append(jTable1.getValueAt(rowsselected[i],colsselected[j])); + sbf.append("\""); + } + else if(jTable1.getValueAt(rowsselected[i],colsselected[j]) == null) + { + sbf.append(""); + } + else + { + sbf.append(jTable1.getValueAt(rowsselected[i],colsselected[j])); + } + if (j= 0) + { + sb.append(values[i].replace("\n", " $")); + } + else + { + sb.append(values[i]); + } + //System.out.println(i+s[i]); + } + System.out.println("sb======"+sb.toString()); + String copyValue = sb.toString(); + String[] st1=copyValue.split("\\$"); //new StringTokenizer(sb.toString(),"$".toString()); + + + + int[] rows = jTable1.getSelectedRows(); + int[] columns = jTable1.getSelectedColumns(); + int startRow = rows[0]; + int startCol = columns[0]; + if(rows.length ==1 ) + { + for(int i=0;i= 0) + { + String[] cellValue = rowstring.split("\t"); + for(int j=0;j= 0) + { + String[] cellValue = rowstring.split("\t"); + for (int k = 0; k < cellValue.length; k++) { + value=(String)cellValue[k]; + System.out.println("value============"+value); + jTable1.setValueAt(value.trim(),rows[i],startCol+k); + System.out.println("Putting "+ value+"atrow="+startRow+i+"column="+startCol+k); + } + } + else + { + jTable1.setValueAt(rowstring.trim(),rows[i],startCol); + } + //} + //} + } + } + else //写入选中行内容 + { + for(int i=0;i= 0) + { + String[] cellValue = rowstring.split("\t"); + for(int j=0;j st1.length) + { + for (int i = 0; i < rows.length; i++) { + for (int j = 0; j < columns.length; j++) { + rowstring=st1[(i+st1.length)%st1.length]; + System.out.println("rowstring============"+rowstring); + if(rowstring.indexOf("\t") >= 0) + { + String[] cellValue = rowstring.split("\t"); + for (int k = 0; k < cellValue.length; k++) { + value=(String)cellValue[(j+cellValue.length)%cellValue.length]; + System.out.println("value============"+value); + jTable1.setValueAt(value.trim(),rows[i],columns[j]); + System.out.println("Putting "+ value+"atrow="+startRow+i+"column="+startCol+k); + } + } + else + { + jTable1.setValueAt(rowstring.trim(),rows[i],columns[j]); + } + } + } + } + else + { + for (int i = 0; i < st1.length; i++) { + for (int j = 0; j < columns.length; j++) { + rowstring=st1[(i+st1.length)%st1.length]; + System.out.println("rowstring============"+rowstring); + if(rowstring.indexOf("\t") >= 0) + { + String[] cellValue = rowstring.split("\t"); + for (int k = 0; k < cellValue.length; k++) { + value=(String)cellValue[(j+cellValue.length)%cellValue.length]; + System.out.println("value============"+value); + jTable1.setValueAt(value.trim(),startRow+i,columns[j]); + System.out.println("Putting "+ value+"atrow="+startRow+i+"column="+startCol+k); + } + } + else + { + jTable1.setValueAt(rowstring.trim(),startRow+i,columns[j]); + } + } + } + } + } + } catch (Exception ex) { + ex.printStackTrace(); + } + + } + } +} \ No newline at end of file diff --git a/src/com/connor/zf/controlplan/CTMap.java b/src/com/connor/zf/controlplan/CTMap.java new file mode 100644 index 0000000..d17dad0 --- /dev/null +++ b/src/com/connor/zf/controlplan/CTMap.java @@ -0,0 +1,340 @@ +package com.connor.zf.controlplan; + +import java.awt.Dimension; +import java.util.List; +import java.util.Map; +import java.util.Vector; + +import javax.swing.event.TableModelEvent; +import javax.swing.table.DefaultTableModel; + +public class CTMap extends DefaultTableModel implements CellSpan { + protected int rowSize; + protected int columnSize; + protected int[][][] span; // CellSpan + protected boolean isEditable = true; + private List processRowList; + private Map> labelRows;//标注行 + private int row = -1; + private int column = -1; + + public int getRow() { + return row; + } + + public void setRow(int row) { + this.row = row; + } + + public int getColumn() { + return column; + } + + public void setColumn(int column) { + this.column = column; + } + + public void setEditable(boolean isEditable) { + this.isEditable = isEditable; + } + + public List getProcessRowList() { + return processRowList; + } + + public void setProcessRowList(List processRowList) { + this.processRowList = processRowList; + } + + public Map> getLabelRows() { + return labelRows; + } + + public void setLabelRows(Map> labelRows) { + this.labelRows = labelRows; + } + + @Override + //设置单元格不可编辑 + public boolean isCellEditable(int arg0, int arg1) { + // TODO Auto-generated method stub + if (processRowList != null && processRowList.size() > 0) { + //设置列不能编辑 + if (!processRowList.contains(arg0) ) {//|| arg1 == 1 || arg1 == 2 + return false; + } else { + if (arg0 == row && arg1 == column) { + return this.isEditable; + } else { + return false; + } + } + } else { + return false; + } + } + + @Override + public void removeRow(int row) { + // 将可修改的行-1 + if (processRowList != null && processRowList.size() > 0) { + for (int i = processRowList.size() - 1; i >= 0; i--) { + if (processRowList.get(i) != null + && processRowList.get(i) == row) { + processRowList.remove(i); + } else if (processRowList.get(i) != null + && processRowList.get(i) > row) { + processRowList.set(i, processRowList.get(i) - 1); + } + } + } + //将标注行减1 + if (labelRows != null && labelRows.size() > 0 && labelRows.keySet().contains(row)) { + List labelRowList = labelRows.get(row); + for (int i = labelRowList.size() - 1; i >= 0; i--) { + Integer listRow = (Integer.parseInt(labelRowList.get(i))); + if (labelRowList.get(i) != null + && listRow == row) { + labelRowList.remove(i); + } else if (labelRowList.get(i) != null + && listRow > row) { + labelRowList.set(i, ((Integer)(listRow-1)).toString()); + } + } + } + super.removeRow(row); + } + + @Override + public int[] getSpan(int row, int column) { + // TODO Auto-generated method stub + if (isOutOfBounds(row, column)) { + int[] ret_code = { 1, 1 }; + return ret_code; + } + return span[row][column]; + } + + @Override + public void setSpan(int[] span, int row, int column) { + // TODO Auto-generated method stub + if (isOutOfBounds(row, column)) + return; + this.span[row][column] = span; + } + + @Override + public boolean isVisible(int row, int column) { + // TODO Auto-generated method stub + if (isOutOfBounds(row, column)) + return false; + if ((span[row][column][CellSpan.COLUMN] < 1) + || (span[row][column][CellSpan.ROW] < 1)) + return false; + return true; + } + + @Override + public void combine(int[] rows, int[] columns) { + // TODO Auto-generated method stub + + int rowSpan = rows.length; + int columnSpan = columns.length; + int startRow = rows[0]; + int startColumn = columns[0]; + for (int i = 0; i < rowSpan; i++) { + for (int j = 0; j < columnSpan; j++) { + if ((span[startRow + i][startColumn + j][CellSpan.COLUMN] != 1) + || (span[startRow + i][startColumn + j][CellSpan.ROW] != 1)) { + // System.out.println("can't combine"); + return; + } + } + } + for (int i = 0, ii = 0; i < rowSpan; i++, ii--) { + for (int j = 0, jj = 0; j < columnSpan; j++, jj--) { + span[startRow + i][startColumn + j][CellSpan.COLUMN] = jj; + span[startRow + i][startColumn + j][CellSpan.ROW] = ii; + // System.out.println("r " +ii +" c " +jj); + } + } + span[startRow][startColumn][CellSpan.COLUMN] = columnSpan; + span[startRow][startColumn][CellSpan.ROW] = rowSpan; + } + + // @Override + // public boolean isCellEditable(int arg0, int arg1) { + // if(arg1 == 1 ) + // { + // return false; + // } + // return super.isCellEditable(arg0, arg1); + // } + // + public void setSize(Dimension size) { + columnSize = size.width; + rowSize = size.height; + span = new int[rowSize][columnSize][2]; // 2: COLUMN,ROW + initValue(); + } + + protected boolean isOutOfBounds(int row, int column) { + if ((row < 0) || (rowSize <= row) || (column < 0) + || (columnSize <= column)) { + return true; + } + return false; + } + + public void addRow() { + + Vector newData = new Vector(getColumnCount()); + dataVector.add(newData); + + // + newRowsAdded(new TableModelEvent(this, getRowCount() - 1, + getRowCount() - 1, TableModelEvent.ALL_COLUMNS, + TableModelEvent.INSERT)); + int[][][] oldSpan = span; + int numRows = oldSpan.length; + int numColumns = oldSpan[0].length; + span = new int[numRows + 1][numColumns][2]; + System.arraycopy(oldSpan, 0, span, 0, numRows); + for (int i = 0; i < numColumns; i++) { + span[numRows][i][CellSpan.COLUMN] = 1; + span[numRows][i][CellSpan.ROW] = 1; + } + rowSize = span.length; + } + + public void addColumn(Object columnName) { + + int[][][] oldSpan = span; + int numRows = oldSpan.length; + int numColumns = oldSpan[0].length; + span = new int[numRows][numColumns + 1][2]; + for (int i = 0; i < span.length; i++) { + for (int j = 0; j < span[0].length; j++) { + span[i][j][CellSpan.COLUMN] = 1; + span[i][j][CellSpan.ROW] = 1; + } + } + + columnSize = span[0].length; + addColumn(columnName, (Vector) null); + } + + public void insertRow(int row) { + Vector rowData = new Vector(getColumnCount()); + int index = 0; + + dataVector.insertElementAt(rowData, row); + System.out.println("size:" + dataVector.size()); + + // + newRowsAdded(new TableModelEvent(this, row, row, + TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT)); + int[][][] newSpan = new int[span.length + 1][span[0].length][2]; + + int numRows = span.length; + int numColumns = span[0].length; + for (int i = 0; i < newSpan.length; i++) { + if (i < row) { + for (int j = 0; j < numColumns; j++) { + newSpan[i][j][0] = span[i][j][0]; + newSpan[i][j][1] = span[i][j][1]; + // newSpan[i][j][0] = 1; + // newSpan[i][j][1] = 1; + } + } else if (i == row) { + for (int j = 0; j < numColumns; j++) { + newSpan[i][j][0] = 1; + newSpan[i][j][1] = 1; + } + } else { + for (int j = 0; j < numColumns; j++) { + newSpan[i][j][0] = span[i - 1][j][0]; + newSpan[i][j][1] = span[i - 1][j][1]; + // newSpan[i][j][0] = 1; + // newSpan[i][j][1] = 1; + } + } + } + span = newSpan; + rowSize = span.length;// 将可修改的行+1 + if (processRowList != null && processRowList.size() > 0) { + + for (int i = processRowList.size() - 1; i >= 0; i--) { + if (!processRowList.contains(row) + && processRowList.get(i) != null + && processRowList.get(i) == row - 1) { + index = i + 1; + processRowList.add(i + 1, row); + } else if (processRowList.get(i) != null + && processRowList.get(i) == row) { + index = i + 1; + processRowList.add(i + 1, row + 1); + } else if (processRowList.get(i) != null && i > index + && processRowList.get(i) >= row) { + processRowList.set(i, processRowList.get(i) + 1); + } + } + } + //将标注行+1 + if (labelRows != null && labelRows.size() > 0 && labelRows.keySet().contains(row)) { + List labelRowList = labelRows.get(row); + for (int i = labelRowList.size() - 1; i >= 0; i--) { + Integer listRow = (Integer.parseInt(labelRowList.get(i))); + if (labelRowList.get(i) != null && i > index + && listRow >= row) { + labelRowList.set(i, ((Integer)(listRow + 1)).toString()); + } + } + } + + } + + public CTMap(int numRows, int numColumns) { + Vector names = new Vector(numColumns); + names.setSize(numColumns); + setColumnIdentifiers(names); + dataVector = new Vector(); + setNumRows(numRows); + setSize(new Dimension(numColumns, numRows)); + } + + protected void initValue() { + System.out.println(span.length); + for (int i = 0; i < span.length; i++) { + for (int j = 0; j < span[i].length; j++) { + span[i][j][CellSpan.COLUMN] = 1; + span[i][j][CellSpan.ROW] = 1; + } + } + } + + public void split(int row, int column) { + if (isOutOfBounds(row, column)) + return; + int columnSpan = span[row][column][CellSpan.COLUMN]; + int rowSpan = span[row][column][CellSpan.ROW]; + for (int i = 0; i < rowSpan; i++) { + for (int j = 0; j < columnSpan; j++) { + span[row + i][column + j][CellSpan.COLUMN] = 1; + span[row + i][column + j][CellSpan.ROW] = 1; + } + } + } + + public void removeCol() { + + columnIdentifiers.removeElementAt(columnIdentifiers.size() - 1); + dataVector.setSize(getRowCount()); + + for (int i = 0; i < getRowCount() - 1; i++) { + + ((Vector) dataVector.elementAt(i)).setSize(getColumnCount()); + } + fireTableStructureChanged(); + } +} diff --git a/src/com/connor/zf/controlplan/CTUI.java b/src/com/connor/zf/controlplan/CTUI.java new file mode 100644 index 0000000..cf8c3a7 --- /dev/null +++ b/src/com/connor/zf/controlplan/CTUI.java @@ -0,0 +1,107 @@ +package com.connor.zf.controlplan; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Point; +import java.awt.Rectangle; + +import javax.swing.JComponent; +import javax.swing.plaf.basic.BasicTableUI; +import javax.swing.table.TableCellRenderer; + +public class CTUI extends BasicTableUI { + + public void paint(Graphics g, JComponent c) { + Rectangle oldClipBounds = g.getClipBounds(); + Rectangle clipBounds = new Rectangle(oldClipBounds); + int tableWidth = ((CTable) table).getColumnModel() + .getTotalColumnWidth(); + clipBounds.width = Math.min(clipBounds.width, tableWidth); + g.setClip(clipBounds); + + int firstIndex = ((CTable) table) + .rowAtPoint(new Point(0, clipBounds.y)); + int lastIndex = ((CTable) table).getRowCount() - 1; + Rectangle rowRect = new Rectangle(0, 0, tableWidth, + ((CTable) table).getRowHeight() + + ((CTable) table).getRowMargin()); + rowRect.y = firstIndex * rowRect.height; + for (int index = firstIndex; index <= lastIndex; index++) { + if (rowRect.intersects(clipBounds)) { + // System.out.println(); // debug + // System.out.print("" + index +": "); // row + paintRow(g, index); + } + rowRect.y += rowRect.height; + } + g.setClip(oldClipBounds); + } + + private void paintRow(Graphics g, int row) { + Rectangle rect = g.getClipBounds(); + boolean drawn = false; + CellSpan cellAtt = (CellSpan) ((CTable) table).getModel(); + int numColumns = ((CTable) table).getColumnCount(); + + for (int column = 0; column < numColumns; column++) { + Rectangle cellRect = ((CTable) table) + .getCellRect(row, column, true); + + int cellRow, cellColumn; + if (cellAtt.isVisible(row, column)) { + cellRow = row; + cellColumn = column; + // System.out.print(" "+column+" "); // debug + } else { + cellRow = row + cellAtt.getSpan(row, column)[CellSpan.ROW]; + cellColumn = column + + cellAtt.getSpan(row, column)[CellSpan.COLUMN]; + // System.out.print(" ("+column+")"); // debug + } + if (cellRect.intersects(rect)) { + drawn = true; + paintCell(g, cellRect, cellRow, cellColumn); + } else { + if (drawn) + break; + } + } + + } + + private void paintCell(Graphics g, Rectangle cellRect, int row, int column) { + int spacingHeight = ((CTable) table).getRowMargin(); + int spacingWidth = ((CTable) table).getColumnModel().getColumnMargin(); + // System.out.println("X:"+cellRect.x+"Y:"+cellRect.y); + Color c = g.getColor(); + g.setColor(((CTable) table).getGridColor()); + g.drawRect(cellRect.x, cellRect.y, cellRect.width - 1, + cellRect.height - 1); + g.setColor(c); + + cellRect.setBounds(cellRect.x + spacingWidth / 2, cellRect.y + + spacingHeight / 2, cellRect.width - spacingWidth, + cellRect.height - spacingHeight); + + if (((CTable) table).isEditing() + && ((CTable) table).getEditingRow() == row + && ((CTable) table).getEditingColumn() == column) { + Component component = ((CTable) table).getEditorComponent(); + component.setBounds(cellRect); + component.validate(); + } else { + TableCellRenderer renderer = ((CTable) table).getCellRenderer(row, + column); + Component component = ((CTable) table).prepareRenderer(renderer, + row, column); + + if (component.getParent() == null) { + rendererPane.add(component); + } + rendererPane.paintComponent(g, component, ((CTable) table), + cellRect.x, cellRect.y, cellRect.width, cellRect.height, + true); + } + } +} \ No newline at end of file diff --git a/src/com/connor/zf/controlplan/CTable.java b/src/com/connor/zf/controlplan/CTable.java new file mode 100644 index 0000000..ab8d8b8 --- /dev/null +++ b/src/com/connor/zf/controlplan/CTable.java @@ -0,0 +1,254 @@ +package com.connor.zf.controlplan; + +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.event.MouseEvent; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.DefaultCellEditor; +import javax.swing.JComboBox; +import javax.swing.JTable; +import javax.swing.ListSelectionModel; +import javax.swing.event.ListSelectionEvent; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableModel; + +import com.connor.zf.controlplan.*; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; + +public class CTable extends JTable { + Map map; + TableCellTextAreaRenderer renderer = new TableCellTextAreaRenderer(); + TextAreaCellEditor cellEditor = new TextAreaCellEditor(); + ComboBoxCellEditor comboBoxCellEditor2 = new ComboBoxCellEditor( + new Object[] { "首件检验\nFirst off inspection", "过程件检验\nProcessing inspection", "末件检验\nLast off inspection","巡检检验\nPatrol inspection", "设备参数调整\nEquipment parameter adjustment" }); + ComboBoxCellEditor gaugeComboBoxCellEditor = new ComboBoxCellEditor(TMomMethodUtil.getPreferenceValues("RB3_GAUGE_VALUES")); + ComboBoxCellEditor frequencyComboBoxCellEditor = new ComboBoxCellEditor(TMomMethodUtil.getPreferenceValues("RB3_FREQUENCY_VALUES")); + + ComboBoxCellEditor owningComboBoxCellEditor = new ComboBoxCellEditor(TMomMethodUtil.getPreferenceValues("RB3_OWNING_VALUES")); + ComboBoxCellEditor reactionPlanComboBoxCellEditor = new ComboBoxCellEditor(TMomMethodUtil.getPreferenceValues("RB3_REACTION_VALUES")); + ComboBoxCellEditor controlMethodComboBoxCellEditor = new ComboBoxCellEditor(TMomMethodUtil.getPreferenceValues("RB3_CONTROLMETHOD_VALUES")); + CheckBoxCellEditor checkBoxCellEditor = new CheckBoxCellEditor(this); + TableCellCheckboxRenderer checkboxRenderer = new TableCellCheckboxRenderer(this); + TCSession session; + boolean isaddEn; + + public CTable(TableModel model,TCSession session,boolean isaddEn) { + super(model); + this.session=session; + this.isaddEn=isaddEn; + setUI(new CTUI()); + getTableHeader().setReorderingAllowed(false); + setCellSelectionEnabled(true); + setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); + map = new HashMap(); + } + + public String getToolTipText(MouseEvent e) { + int row = this.rowAtPoint(e.getPoint()); + int col = this.columnAtPoint(e.getPoint()); + String tiptextString = null; + if (row > -1 && col > -1) { + Object value = this.getValueAt(row, col); + if (null != value && !"".equals(value)) + tiptextString = value.toString();// 悬浮显示单元格内容 + } + return tiptextString; + } + + // @Override + // protected void processKeyEvent(KeyEvent keyevent) { + // // TODO Auto-generated method stub + // if(keyevent.getKeyCode()==KeyEvent.VK_ENTER){ + // if(keyevent.isControlDown()) + // { + // System.out.println(1); + // } + // this.editCellAt(this.getSelectedRow(),this.getSelectedColumn()); + // } + // } + + public Rectangle getCellRect(int row, int column, boolean includeSpacing) { + Rectangle sRect = super.getCellRect(row, column, includeSpacing); + if ((row < 0) || (column < 0) || (getRowCount() <= row) + || (getColumnCount() <= column)) { + return sRect; + } + CellSpan cellAtt = (CellSpan) getModel(); + if (!cellAtt.isVisible(row, column)) { + int temp_row = row; + int temp_column = column; + row += cellAtt.getSpan(temp_row, temp_column)[CellSpan.ROW]; + column += cellAtt.getSpan(temp_row, temp_column)[CellSpan.COLUMN]; + } + int[] n = cellAtt.getSpan(row, column); + + int index = 0; + int columnMargin = getColumnModel().getColumnMargin(); + Rectangle cellFrame = new Rectangle(); + int aCellHeight = rowHeight + rowMargin; + cellFrame.y = row * aCellHeight; + cellFrame.height = n[CellSpan.ROW] * aCellHeight; + + Enumeration eeration = getColumnModel().getColumns(); + while (eeration.hasMoreElements()) { + TableColumn aColumn = (TableColumn) eeration.nextElement(); + cellFrame.width = aColumn.getWidth(); + if (index == column) + break; + cellFrame.x += cellFrame.width; + index++; + } + for (int i = 0; i < n[CellSpan.COLUMN] - 1; i++) { + TableColumn aColumn = (TableColumn) eeration.nextElement(); + cellFrame.width += aColumn.getWidth() + columnMargin; + } + + if (!includeSpacing) { + Dimension spacing = getIntercellSpacing(); + cellFrame.setBounds(cellFrame.x + spacing.width / 2, cellFrame.y + + spacing.height / 2, cellFrame.width - spacing.width, + cellFrame.height - spacing.height); + } + return cellFrame; + } + + // 隐藏列 + public void HiddenCell(int column) { + TableColumn tc = this.getTableHeader().getColumnModel() + .getColumn(column); + tc.setMaxWidth(0); + tc.setPreferredWidth(0); + tc.setWidth(0); + tc.setMinWidth(0); + this.getTableHeader().getColumnModel().getColumn(column).setMaxWidth(0); + this.getTableHeader().getColumnModel().getColumn(column).setMinWidth(0); + } + + private int[] rowColumnAtPoint(Point point) { + int[] retValue = { -1, -1 }; + int row = point.y / (rowHeight + rowMargin); + if ((row < 0) || (getRowCount() <= row)) + return retValue; + int column = getColumnModel().getColumnIndexAtX(point.x); + + CellSpan cellAtt = (CellSpan) getModel(); + + if (cellAtt.isVisible(row, column)) { + retValue[CellSpan.COLUMN] = column; + retValue[CellSpan.ROW] = row; + return retValue; + } + retValue[CellSpan.COLUMN] = column + + cellAtt.getSpan(row, column)[CellSpan.COLUMN]; + retValue[CellSpan.ROW] = row + + cellAtt.getSpan(row, column)[CellSpan.ROW]; + return retValue; + } + + public int rowAtPoint(Point point) { + return rowColumnAtPoint(point)[CellSpan.ROW]; + } + + public int columnAtPoint(Point point) { + return rowColumnAtPoint(point)[CellSpan.COLUMN]; + } + + public void columnSelectionChanged(ListSelectionEvent e) { + repaint(); + } + + public void valueChanged(ListSelectionEvent e) { + int firstIndex = e.getFirstIndex(); + int lastIndex = e.getLastIndex(); + if (firstIndex == -1 && lastIndex == -1) { // Selection cleared. + repaint(); + } + Rectangle dirtyRegion = getCellRect(firstIndex, 0, false); + int numCoumns = getColumnCount(); + int index = firstIndex; + for (int i = 0; i < numCoumns; i++) { + dirtyRegion.add(getCellRect(index, i, false)); + } + index = lastIndex; + for (int i = 0; i < numCoumns; i++) { + dirtyRegion.add(getCellRect(index, i, false)); + } + repaint(dirtyRegion.x, dirtyRegion.y, dirtyRegion.width, + dirtyRegion.height); + } + + public void setCombo(int row, int col, TableCellEditor ce) { + map.put(new Point(row, col), ce); + } + + @Override + public TableCellEditor getCellEditor(int row, int column) { + if(isaddEn) { + if(column==7) { + TCPreferenceService service = session.getPreferenceService(); + String[] strs = service.getStringValues("ZF6_KZJH_TSTX"); + + String[] strss=new String[strs.length]; + for(int i=0;i 0) { + // 获得选中列 + int selectColumn = tableHeader.columnAtPoint(e.getPoint()); + if (table.getColumnName(selectColumn).equals("换刀检验")) { + boolean value = !CheckBoxCellEditor.this.isSelected(); + CheckBoxCellEditor.this.setSelected(value); + table.selectAllOrNull(value ? "1" : "0"); + tableHeader.repaint(); + } + } + } + }); + addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent event) { + fireEditingStopped(); + } + }); + } + + public void addCellEditorListener(CellEditorListener listener) { + listenerList.add(CellEditorListener.class, listener); + } + + public void removeCellEditorListener(CellEditorListener listener) { + listenerList.remove(CellEditorListener.class, listener); + } + + protected void fireEditingStopped() { + System.out.println(this.isSelected() ? "1" : "0"); + CellEditorListener listener; + Object[] listeners = listenerList.getListenerList(); + for (int i = 0; i < listeners.length; i++) { + if (listeners[i] == CellEditorListener.class) { + listener = (CellEditorListener) listeners[i + 1]; + listener.editingStopped(changeEvent); + } + } + } + + protected void fireEditingCanceled() { + CellEditorListener listener; + Object[] listeners = listenerList.getListenerList(); + for (int i = 0; i < listeners.length; i++) { + if (listeners[i] == CellEditorListener.class) { + listener = (CellEditorListener) listeners[i + 1]; + listener.editingCanceled(changeEvent); + } + } + } + + public void cancelCellEditing() { + fireEditingCanceled(); + } + + public boolean stopCellEditing() { + //this.addItem(this.getSelectedItem()); + fireEditingStopped(); + return true; + } + + public boolean isCellEditable(EventObject event) { + return true; + } + + public boolean shouldSelectCell(EventObject event) { + return true; + } + + public Object getCellEditorValue() { + return this.isSelected() ? "1" : "0"; + } + + public Component getTableCellEditorComponent(JTable table, Object value, + boolean isSelected, int row, int column) { + +// String valueStr = (String) value; +// JLabel label = new JLabel(valueStr); +// label.setHorizontalAlignment(SwingConstants.CENTER); // 表头标签剧中 + this.setHorizontalAlignment(SwingConstants.CENTER);// 表头标签剧中 + this.setBorderPainted(true); + this.setSelected(value.toString().equals("1")); + return this; + } +} \ No newline at end of file diff --git a/src/com/connor/zf/controlplan/ClassPropBean.java b/src/com/connor/zf/controlplan/ClassPropBean.java new file mode 100644 index 0000000..d67b105 --- /dev/null +++ b/src/com/connor/zf/controlplan/ClassPropBean.java @@ -0,0 +1,44 @@ +package com.connor.zf.controlplan; + +public class ClassPropBean { + private String id; + private String name; + private String value; + + public ClassPropBean(String id, String name, String value) { + super(); + this.id = id; + this.name = name; + this.value = value; + } + + public String getId() { + return id; + } + + @Override + public String toString() { + return name; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + +} diff --git a/src/com/connor/zf/controlplan/ClassProperty.java b/src/com/connor/zf/controlplan/ClassProperty.java new file mode 100644 index 0000000..b048266 --- /dev/null +++ b/src/com/connor/zf/controlplan/ClassProperty.java @@ -0,0 +1,42 @@ +package com.connor.zf.controlplan; + +/** + * @copyRight 浙江康勒科技有限公司 + * @author 作者 E-mail:hub@connor.net.cn + * @date 创建时间:2017-7-3 下午11:47:03 + * @version v1.0 + * @parameter + * @since + * @return + */ + +public class ClassProperty { + private int propertyID; + private String value; + + public ClassProperty() { + + } + + public ClassProperty(int propertyID, String value) { + this.propertyID = propertyID; + this.value = value; + } + + public int getPropertyID() { + return propertyID; + } + + public void setPropertyID(int propertyID) { + this.propertyID = propertyID; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + +} diff --git a/src/com/connor/zf/controlplan/ComboBoxCellEditor.java b/src/com/connor/zf/controlplan/ComboBoxCellEditor.java new file mode 100644 index 0000000..81b7882 --- /dev/null +++ b/src/com/connor/zf/controlplan/ComboBoxCellEditor.java @@ -0,0 +1,89 @@ +package com.connor.zf.controlplan; + +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.EventObject; + +import javax.swing.JComboBox; +import javax.swing.JTable; +import javax.swing.event.CellEditorListener; +import javax.swing.event.ChangeEvent; +import javax.swing.event.EventListenerList; +import javax.swing.table.TableCellEditor; + +public class ComboBoxCellEditor extends JComboBox implements TableCellEditor { + + protected EventListenerList listenerList = new EventListenerList(); + protected ChangeEvent changeEvent = new ChangeEvent(this); + + public ComboBoxCellEditor(Object[] itmes) { + super(); + for (int i = 0; i < itmes.length; i++) { + addItem(itmes[i]); + } + addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent event) { + fireEditingStopped(); + } + }); + } + + public void addCellEditorListener(CellEditorListener listener) { + listenerList.add(CellEditorListener.class, listener); + } + + public void removeCellEditorListener(CellEditorListener listener) { + listenerList.remove(CellEditorListener.class, listener); + } + + protected void fireEditingStopped() { + CellEditorListener listener; + Object[] listeners = listenerList.getListenerList(); + for (int i = 0; i < listeners.length; i++) { + if (listeners[i] == CellEditorListener.class) { + listener = (CellEditorListener) listeners[i + 1]; + listener.editingStopped(changeEvent); + } + } + } + + protected void fireEditingCanceled() { + CellEditorListener listener; + Object[] listeners = listenerList.getListenerList(); + for (int i = 0; i < listeners.length; i++) { + if (listeners[i] == CellEditorListener.class) { + listener = (CellEditorListener) listeners[i + 1]; + listener.editingCanceled(changeEvent); + } + } + } + + public void cancelCellEditing() { + fireEditingCanceled(); + } + + public boolean stopCellEditing() { + //this.addItem(this.getSelectedItem()); + fireEditingStopped(); + return true; + } + + public boolean isCellEditable(EventObject event) { + return true; + } + + public boolean shouldSelectCell(EventObject event) { + return true; + } + + public Object getCellEditorValue() { + return getSelectedItem(); + } + + public Component getTableCellEditorComponent(JTable table, Object value, + boolean isSelected, int row, int column) { + this.setSelectedItem(value); + return this; + } +} \ No newline at end of file diff --git a/src/com/connor/zf/controlplan/ControlPlanBean.java b/src/com/connor/zf/controlplan/ControlPlanBean.java new file mode 100644 index 0000000..d5878ec --- /dev/null +++ b/src/com/connor/zf/controlplan/ControlPlanBean.java @@ -0,0 +1,233 @@ +package com.connor.zf.controlplan; + +import java.util.List; + +import javax.swing.JCheckBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +public class ControlPlanBean { + private boolean sc;//生产 + private boolean ssc;//试生产 + private boolean yj;//样件 + + private String kzjhbh;//控制计划编号 + private String zylxr;//主要联系人 + private String zylxrdh;//主要联系人电话 + private String bzriq;//日期(编制) + private String xdrq;//日期(修订) + + private String sorhm;//SOR号码 + private String ljh;//零件号 + private String hxxz;//核心小组 + private String gkgcpz;//顾客工程批准/日期 + + private String khtzbh;//客户图纸编号 + private String ljmc;//零件名称/描述 + private String gfpzrq;//供方/工厂批准/日期 + private String gkzlpz;//顾客质量批准/日期 + + private String gfgc;//供方/工厂 + private String gfdh;//供方代号 + private String xgdj;//修改等级 + private String cx;//车型/年度 + private String gkpz;//顾客批准/日期 + private String qtpz;//其他批准/日期 + private String qtpzrq;//其他批准日期 + + private List processList; + + public boolean isSc() { + return sc; + } + + public void setSc(boolean sc) { + this.sc = sc; + } + + public boolean isSsc() { + return ssc; + } + + public void setSsc(boolean ssc) { + this.ssc = ssc; + } + + public boolean isYj() { + return yj; + } + + public void setYj(boolean yj) { + this.yj = yj; + } + + public String getKzjhbh() { + return kzjhbh; + } + + public void setKzjhbh(String kzjhbh) { + this.kzjhbh = kzjhbh; + } + + public String getZylxr() { + return zylxr; + } + + public void setZylxr(String zylxr) { + this.zylxr = zylxr; + } + + public String getZylxrdh() { + return zylxrdh; + } + + public void setZylxrdh(String zylxrdh) { + this.zylxrdh = zylxrdh; + } + + public String getBzriq() { + return bzriq; + } + + public void setBzriq(String bzriq) { + this.bzriq = bzriq; + } + + public String getXdrq() { + return xdrq; + } + + public void setXdrq(String xdrq) { + this.xdrq = xdrq; + } + + public String getSorhm() { + return sorhm; + } + + public void setSorhm(String sorhm) { + this.sorhm = sorhm; + } + + public String getLjh() { + return ljh; + } + + public void setLjh(String ljh) { + this.ljh = ljh; + } + + public String getHxxz() { + return hxxz; + } + + public void setHxxz(String hxxz) { + this.hxxz = hxxz; + } + + public String getGkgcpz() { + return gkgcpz; + } + + public void setGkgcpz(String gkgcpz) { + this.gkgcpz = gkgcpz; + } + + public String getKhtzbh() { + return khtzbh; + } + + public void setKhtzbh(String khtzbh) { + this.khtzbh = khtzbh; + } + + public String getLjmc() { + return ljmc; + } + + public void setLjmc(String ljmc) { + this.ljmc = ljmc; + } + + public String getGfpzrq() { + return gfpzrq; + } + + public void setGfpzrq(String gfpzrq) { + this.gfpzrq = gfpzrq; + } + + public String getGkzlpz() { + return gkzlpz; + } + + public void setGkzlpz(String gkzlpz) { + this.gkzlpz = gkzlpz; + } + + public String getGfgc() { + return gfgc; + } + + public void setGfgc(String gfgc) { + this.gfgc = gfgc; + } + + public String getGfdh() { + return gfdh; + } + + public void setGfdh(String gfdh) { + this.gfdh = gfdh; + } + + public String getXgdj() { + return xgdj; + } + + public void setXgdj(String xgdj) { + this.xgdj = xgdj; + } + + public String getCx() { + return cx; + } + + public void setCx(String cx) { + this.cx = cx; + } + + public String getGkpz() { + return gkpz; + } + + public void setGkpz(String gkpz) { + this.gkpz = gkpz; + } + + public String getQtpz() { + return qtpz; + } + + public void setQtpz(String qtpz) { + this.qtpz = qtpz; + } + + public String getQtpzrq() { + return qtpzrq; + } + + public void setQtpzrq(String qtpzrq) { + this.qtpzrq = qtpzrq; + } + + public List getProcessList() { + return processList; + } + + public void setProcessList(List processList) { + this.processList = processList; + } + +} diff --git a/src/com/connor/zf/controlplan/ControlPlanComboBoxBean.java b/src/com/connor/zf/controlplan/ControlPlanComboBoxBean.java new file mode 100644 index 0000000..ecbb0cc --- /dev/null +++ b/src/com/connor/zf/controlplan/ControlPlanComboBoxBean.java @@ -0,0 +1,26 @@ +package com.connor.zf.controlplan; + +public class ControlPlanComboBoxBean { + + private String itemId; + private String itemName; + public String getItemId() { + return itemId; + } + public void setItemId(String itemId) { + this.itemId = itemId; + } + public String getItemName() { + return itemName; + } + public void setItemName(String itemName) { + this.itemName = itemName; + } + + @Override + public String toString() { + // TODO Auto-generated method stub + return this.itemName; + //return super.toString(); + } +} diff --git a/src/com/connor/zf/controlplan/CopyOfTMom004SetControlPlanDialog.java b/src/com/connor/zf/controlplan/CopyOfTMom004SetControlPlanDialog.java new file mode 100644 index 0000000..246b3d0 --- /dev/null +++ b/src/com/connor/zf/controlplan/CopyOfTMom004SetControlPlanDialog.java @@ -0,0 +1,1681 @@ +package com.connor.zf.controlplan; +//package com.connor.renben.process.plm.tmom004; +// +//import java.awt.BorderLayout; +//import java.awt.Color; +//import java.awt.Dimension; +//import java.awt.FlowLayout; +//import java.awt.Font; +//import java.awt.event.ActionEvent; +//import java.awt.event.ActionListener; +//import java.awt.event.MouseEvent; +//import java.awt.event.MouseListener; +//import java.io.BufferedInputStream; +//import java.io.IOException; +//import java.io.InputStream; +//import java.sql.ResultSet; +//import java.util.ArrayList; +//import java.util.Arrays; +//import java.util.HashMap; +//import java.util.Iterator; +//import java.util.List; +//import java.util.Map; +//import java.util.Properties; +// +//import javax.swing.BorderFactory; +//import javax.swing.JButton; +//import javax.swing.JCheckBox; +//import javax.swing.JLabel; +//import javax.swing.JPanel; +//import javax.swing.JScrollPane; +//import javax.swing.JSplitPane; +//import javax.swing.JTabbedPane; +//import javax.swing.JTable; +//import javax.swing.table.DefaultTableModel; +//import javax.swing.tree.DefaultMutableTreeNode; +// +//import com.connor.renben.process.plm.bean.ControlPlanBean; +//import com.connor.renben.process.plm.bean.ControlPlanTreeBean; +//import com.connor.renben.process.plm.sql.util.SqlUtilT; +//import com.connor.renben.process.plm.tmom010.CTable; +//import com.connor.renben.process.plm.util.CTextField; +//import com.connor.renben.process.plm.util.CTreeNode; +//import com.connor.renben.process.plm.util.MyTableModel; +//import com.teamcenter.rac.aif.AIFDesktop; +//import com.teamcenter.rac.aif.AbstractAIFApplication; +//import com.teamcenter.rac.aif.AbstractAIFDialog; +//import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +//import com.teamcenter.rac.kernel.TCComponent; +//import com.teamcenter.rac.kernel.TCComponentItemType; +//import com.teamcenter.rac.kernel.TCProperty; +//import com.teamcenter.rac.kernel.TCSession; +//import com.teamcenter.rac.util.MessageBox; +//import com.teamcenter.rac.util.PropertyLayout; +//import com.teamcenter.rac.workflow.commands.newprocess.NewProcessCommand; +// +//public class CopyOfTMom004SetControlPlanDialog extends AbstractAIFDialog +// implements ActionListener { +// private AbstractAIFApplication app; +// private TCSession session; +// private TCProperty[] properties; +// private CTMap map; +// static JScrollPane scrollPane; +// // private String[] header = new +// // String[]{"PLM
EID","零件/工
艺编号","过程名称","机器,设备
,工装,夹具","气泡图编号","尺寸","产品","过程" +// // ,"特殊特
性分类","产品/过程/
规格/公差","评估/测
量方法","容量","频率","负责人","控制方法" +// // ,"操作规范/
记录表单
编号","反应计划"}; +// private String[] header = new String[] { "PLMEID", "零件/工艺编号", "过程名称", +// "机器,设备,工装,夹具", "首末检验", "气泡图编号", "尺寸", "产品", "过程", "特殊特性分类", +// "产品/过程/规格/公差", "评估/测量方法", "容量", "频率", "首件收减百分比", "过程收减百分比", +// "末件收减百分比", "负责人", "控制方法", "操作规范/记录表单编号", "反应计划", "特殊符号位置" }; +// private String[] header2 = new String[] { "PLMEID", "气泡图编号", "尺寸", "产品", +// "过程", "特殊特性分类", "产品/过程/规格/公差", "评估/测量方法", "容量", "频率", "首件收减百分比", +// "末件收减百分比", "过程收减百分比", "负责人", "控制方法", "操作规范/记录表单编号", "反应计划", +// "父节点ID", "特殊字符所在位置" }; +// private Map combineMap;// 存放合并单元格 +// private TCComponent form;// 选中对象的版本表单 +// private TCComponent item;// 选中对象 +// private TCComponent meprocess;// 选中所在的工艺 +// // private List> processRowList;//当前用户可修改的行号 +// private List processRows;// 当前用户可修改的行号 +// private List> dataList; +// private List meopId;// 工序对象的ItemId +// private List deleteRows = new ArrayList(); +// // private TextAreaCellEditor textAreaCellEditor; +// private SpecialDialog specialDialog; +// private LibraryDialog libraryDialog; +// private ControlPlanTreeBean bean; +// private Properties pro = new Properties(); +// private boolean isComplete = false; +// private boolean isOwning; +// +// // 界面所需控件 +// private JPanel titlePanel;// 标题 +// private JLabel titleLabel; +// +// private JPanel mainPanel;// 属性填写 +// +// private JPanel checkPanel;// 复选框 +// private JCheckBox scCheckBox;// 生产 +// private JCheckBox sscCheckBox;// 试生产 +// private JCheckBox yjCheckBox;// 样件 +// +// private JPanel panel1;// 第一行属性 +// private JLabel kzjhbhLabel;// 控制计划编号 +// private CTextField kzjhbhField; +// private JLabel zylxrLabel;// 主要联系人 +// private CTextField zylxrField; +// private JLabel zylxrdhLabel;// 主要联系人电话 +// private CTextField zylxrdhField; +// private JLabel bzriqLabel;// 日期(编制) +// private CTextField bzriqField; +// private JLabel xdrqLabel;// 日期(修订) +// private CTextField xdrqField;// 日期(修订) +// +// private JPanel panel2;// 第二行属性 +// private JLabel sorhmLabel;// SOR号码 +// private CTextField sorhmField; +// private JLabel ljhLabel;// 零件号 +// private CTextField ljhField; +// private JLabel hxxzLabel;// 核心小组 +// private CTextField hxxzField; +// private JLabel gkgcpzLabel;// 顾客工程批准/日期 +// private CTextField gkgcpzField; +// +// private JPanel panel3;// 第三行属性 +// private JLabel khtzbhLabel;// 客户图纸编号 +// private CTextField khtzbhField; +// private JLabel ljmcLabel;// 零件名称/描述 +// private CTextField ljmcField; +// private JLabel gfpzrqLabel;// 供方/工厂批准/日期 +// private CTextField gfpzrqField; +// private JLabel gkzlpzLabel;// 顾客质量批准/日期 +// private CTextField gkzlpzField; +// +// private JPanel panel4;// 第四行属性 +// private JLabel gfgcLabel;// 供方/工厂 +// private CTextField gfgcField; +// private JLabel gfdhLabel;// 供方代号 +// private CTextField gfdhField; +// private JLabel xgdjLabel;// 修改等级 +// private CTextField xgdjField; +// private JLabel cxLabel;// 车型 +// private CTextField cxField; +// private JLabel gkpzLabel;// 顾客批准/日期 +// private CTextField gkpzField; +// private JLabel qtpzLabel;// 其他批准/日期 +// private CTextField qtpzField; +// private JLabel qtpzrqLabel;// 其他批准日期 +// private CTextField qtpzrqField; +// +// private JPanel topPanel;// 第一行的属性和复选框 +// +// private JPanel tablePanel;// 表格控件 +// private TableCellTextAreaRenderer renderer;// 渲染器 +// private static CTable table; +// +// private JPanel rootPanel;// 按钮 +// private JButton addButton;// 添加 +// private JButton remButton;// 移除 +// private JButton comBinebutton;// 合并 +// private JButton splitButton;// 拆分 +// private JButton saveButton;// 保存 +// private JButton completeButton;// 完成 +// private JButton deleteSpecialButton;// 移除特殊符号 +// private JButton addSpecialButton;// 添加特殊符号 +// private JButton libraryButton;// 打开控制计划库 +// +// private JPanel centerPanel; +// +// public CopyOfTMom004SetControlPlanDialog(AbstractAIFApplication app, +// TCSession session, List processRows, TCComponent form, +// TCComponent item, TCComponent meprocess, TCProperty[] properties, +// Map combineMap, List> dataList, +// List meopId, boolean isOwning) { +// super(false); +// // this.processRowList = processRowList; +// this.processRows = processRows; +// this.dataList = dataList; +// this.meopId = meopId; +// this.combineMap = combineMap; +// this.form = form; +// this.item = item; +// this.meprocess = meprocess; +// this.properties = properties; +// this.app = app; +// this.session = session; +// this.isOwning = isOwning; +// init(); +// comBine(); +// } +// +// public void comBine() { +// // TODO Auto-generated method stub +// if (combineMap != null && combineMap.size() != 0) { +// Iterator> it = combineMap.entrySet() +// .iterator(); +// while (it.hasNext()) { +// Map.Entry entry = it.next(); +// map.combine(entry.getKey(), entry.getValue()); +// } +// } +// } +// +// // /** +// // * 动态设置可修改列 +// // */ +// // public void setProcessRows(List> processRowList) { +// // for (int i = 0; i < processRowList.size(); i++) { +// // for (int j = 0; j < processRowList.get(i).size(); j++) { +// // this.processRows.add(processRowList.get(i).get(j)); +// // } +// // } +// // if(this.processRows != null && this.processRows.size()>0) +// // { +// // this.map.setProcessRowList(this.processRows); +// // } +// // } +// +// private void init() { +// this.setTitle("填写控制计划"); +// this.setPreferredSize(new Dimension(1280, 810)); +// // 初始化标题部分控件 +// this.titlePanel = new JPanel(); +// this.titleLabel = new JLabel("CONTROL PLAN/控制计划"); +// this.titleLabel.setFont(new Font("宋体", 1, 18)); +// this.titlePanel.add(titleLabel); +// // 初始化菜单部分控件 +// this.yjCheckBox = new JCheckBox("样件"); +// this.sscCheckBox = new JCheckBox("试生产"); +// this.scCheckBox = new JCheckBox("生产"); +// this.checkPanel = new JPanel(new BorderLayout()); +// this.checkPanel.setPreferredSize(new Dimension(175, 50)); +// this.checkPanel.setBorder((BorderFactory +// .createLineBorder(Color.gray, 1))); +// this.checkPanel.add(scCheckBox, BorderLayout.EAST); +// this.checkPanel.add(sscCheckBox, BorderLayout.CENTER); +// this.checkPanel.add(yjCheckBox, BorderLayout.WEST); +// +// this.panel1 = new JPanel(new PropertyLayout()); +// this.panel1.setPreferredSize(new Dimension(795, 50)); +// this.kzjhbhLabel = new JLabel("控制计划编号"); +// this.kzjhbhLabel.setPreferredSize(new Dimension(150, 20)); +// this.kzjhbhLabel.setBorder((BorderFactory.createLineBorder(Color.gray, +// 1))); +// this.kzjhbhField = new CTextField(this.properties[0].getStringValue()); +// this.kzjhbhField.setPreferredSize(new Dimension(150, 20)); +// this.zylxrLabel = new JLabel("主要联系人/编制人"); +// this.zylxrLabel.setBorder((BorderFactory +// .createLineBorder(Color.gray, 1))); +// this.zylxrLabel.setPreferredSize(new Dimension(150, 20)); +// this.zylxrField = new CTextField(this.properties[1].getStringValue()); +// this.zylxrField.setPreferredSize(new Dimension(150, 20)); +// this.zylxrdhLabel = new JLabel("主要联系人电话/编制人电话"); +// this.zylxrdhLabel.setBorder((BorderFactory.createLineBorder(Color.gray, +// 1))); +// this.zylxrdhLabel.setPreferredSize(new Dimension(170, 20)); +// this.zylxrdhField = new CTextField(this.properties[2].getStringValue()); +// this.zylxrdhField.setPreferredSize(new Dimension(170, 20)); +// this.bzriqLabel = new JLabel("日期(编制)"); +// this.bzriqLabel.setBorder((BorderFactory +// .createLineBorder(Color.gray, 1))); +// this.bzriqLabel.setPreferredSize(new Dimension(151, 20)); +// this.bzriqField = new CTextField(this.properties[3].getStringValue()); +// this.bzriqField.setPreferredSize(new Dimension(151, 20)); +// this.xdrqLabel = new JLabel("日期(修订)"); +// this.xdrqLabel +// .setBorder((BorderFactory.createLineBorder(Color.gray, 1))); +// this.xdrqLabel.setPreferredSize(new Dimension(151, 20)); +// this.xdrqField = new CTextField(this.properties[4].getStringValue()); +// xdrqField.setPreferredSize(new Dimension(151, 20)); +// this.panel1.add("1.1.left.top", kzjhbhLabel); +// this.panel1.add("1.2.left.top", zylxrLabel); +// this.panel1.add("1.3.left.top", zylxrdhLabel); +// this.panel1.add("1.4.left.top", bzriqLabel); +// this.panel1.add("1.5.left.top", xdrqLabel); +// +// this.panel1.add("2.1.left.top", kzjhbhField); +// this.panel1.add("2.2.left.top", zylxrField); +// this.panel1.add("2.3.left.top", zylxrdhField); +// this.panel1.add("2.4.left.top", bzriqField); +// this.panel1.add("2.5.left.top", xdrqField); +// +// this.topPanel = new JPanel(new PropertyLayout()); +// this.topPanel.add("1.1.left.top", this.checkPanel); +// this.topPanel.add("1.2.left.top", this.panel1); +// +// this.panel2 = new JPanel(new PropertyLayout()); +// this.panel2.setPreferredSize(new Dimension(975, 50)); +// this.sorhmLabel = new JLabel("SOR号码/名称"); +// this.sorhmLabel.setPreferredSize(new Dimension(175, 20)); +// this.sorhmLabel.setBorder((BorderFactory +// .createLineBorder(Color.gray, 1))); +// this.sorhmField = new CTextField(this.properties[5].getStringValue()); +// this.sorhmField.setPreferredSize(new Dimension(175, 20)); +// this.ljhLabel = new JLabel("零件号/最终版本"); +// this.ljhLabel +// .setBorder((BorderFactory.createLineBorder(Color.gray, 1))); +// this.ljhLabel.setPreferredSize(new Dimension(150, 20)); +// this.ljhField = new CTextField(this.properties[6].getStringValue()); +// this.ljhField.setPreferredSize(new Dimension(150, 20)); +// this.hxxzLabel = new JLabel("核心小组"); +// this.hxxzLabel +// .setBorder((BorderFactory.createLineBorder(Color.gray, 1))); +// this.hxxzLabel.setPreferredSize(new Dimension(324, 20)); +// this.hxxzField = new CTextField(this.properties[7].getStringValue()); +// this.hxxzField.setPreferredSize(new Dimension(324, 20)); +// this.gkgcpzLabel = new JLabel("顾客工程批准/日期"); +// this.gkgcpzLabel.setBorder((BorderFactory.createLineBorder(Color.gray, +// 1))); +// this.gkgcpzLabel.setPreferredSize(new Dimension(308, 20)); +// this.gkgcpzField = new CTextField(this.properties[8].getStringValue()); +// this.gkgcpzField.setPreferredSize(new Dimension(308, 20)); +// +// this.panel2.add("1.1.left.top", sorhmLabel); +// this.panel2.add("1.2.left.top", ljhLabel); +// this.panel2.add("1.3.left.top", hxxzLabel); +// this.panel2.add("1.4.left.top", gkgcpzLabel); +// +// this.panel2.add("2.1.left.top", sorhmField); +// this.panel2.add("2.2.left.top", ljhField); +// this.panel2.add("2.3.left.top", hxxzField); +// this.panel2.add("2.4.left.top", gkgcpzField); +// +// this.panel3 = new JPanel(new PropertyLayout()); +// this.panel3.setPreferredSize(new Dimension(975, 50)); +// this.khtzbhLabel = new JLabel("客户图纸编号"); +// this.khtzbhLabel.setPreferredSize(new Dimension(175, 20)); +// this.khtzbhLabel.setBorder((BorderFactory.createLineBorder(Color.gray, +// 1))); +// this.khtzbhField = new CTextField(this.properties[9].getStringValue()); +// this.khtzbhField.setPreferredSize(new Dimension(175, 20)); +// this.ljmcLabel = new JLabel("零件名称/描述"); +// this.ljmcLabel +// .setBorder((BorderFactory.createLineBorder(Color.gray, 1))); +// this.ljmcLabel.setPreferredSize(new Dimension(150, 20)); +// this.ljmcField = new CTextField(this.properties[10].getStringValue()); +// this.ljmcField.setPreferredSize(new Dimension(150, 20)); +// this.gfpzrqLabel = new JLabel("供方/工厂批准/日期"); +// this.gfpzrqLabel.setBorder((BorderFactory.createLineBorder(Color.gray, +// 1))); +// this.gfpzrqLabel.setPreferredSize(new Dimension(324, 20)); +// this.gfpzrqField = new CTextField(this.properties[11].getStringValue()); +// this.gfpzrqField.setPreferredSize(new Dimension(324, 20)); +// this.gkzlpzLabel = new JLabel("顾客质量批准/日期"); +// this.gkzlpzLabel.setBorder((BorderFactory.createLineBorder(Color.gray, +// 1))); +// this.gkzlpzLabel.setPreferredSize(new Dimension(308, 20)); +// this.gkzlpzField = new CTextField(this.properties[12].getStringValue()); +// this.gkzlpzField.setPreferredSize(new Dimension(308, 20)); +// +// panel3.add("1.1.left.top", khtzbhLabel); +// panel3.add("1.2.left.top", ljmcLabel); +// panel3.add("1.3.left.top", gfpzrqLabel); +// panel3.add("1.4.left.top", gkzlpzLabel); +// +// panel3.add("2.1.left.top", khtzbhField); +// panel3.add("2.2.left.top", ljmcField); +// panel3.add("2.3.left.top", gfpzrqField); +// panel3.add("2.4.left.top", gkzlpzField); +// +// this.panel4 = new JPanel(new PropertyLayout()); +// this.panel4.setPreferredSize(new Dimension(975, 50)); +// this.gfgcLabel = new JLabel("供方/工厂"); +// this.gfgcLabel.setPreferredSize(new Dimension(175, 20)); +// this.gfgcLabel +// .setBorder((BorderFactory.createLineBorder(Color.gray, 1))); +// this.gfgcField = new CTextField(this.properties[13].getStringValue()); +// this.gfgcField.setPreferredSize(new Dimension(175, 20)); +// this.gfdhLabel = new JLabel("供方代号"); +// this.gfdhLabel +// .setBorder((BorderFactory.createLineBorder(Color.gray, 1))); +// this.gfdhLabel.setPreferredSize(new Dimension(72, 20)); +// this.gfdhField = new CTextField(this.properties[14].getStringValue()); +// this.gfdhField.setPreferredSize(new Dimension(72, 20)); +// this.xgdjLabel = new JLabel("修改等级"); +// this.xgdjLabel +// .setBorder((BorderFactory.createLineBorder(Color.gray, 1))); +// this.xgdjLabel.setPreferredSize(new Dimension(72, 20)); +// this.xgdjField = new CTextField(this.properties[15].getStringValue()); +// this.xgdjField.setPreferredSize(new Dimension(72, 20)); +// this.cxLabel = new JLabel("车型/年度"); +// this.cxLabel.setBorder((BorderFactory.createLineBorder(Color.gray, 1))); +// this.cxLabel.setPreferredSize(new Dimension(159, 20)); +// this.cxField = new CTextField(this.properties[16].getStringValue()); +// this.cxField.setPreferredSize(new Dimension(159, 20)); +// this.gkpzLabel = new JLabel("顾客批准/日期"); +// this.gkpzLabel +// .setBorder((BorderFactory.createLineBorder(Color.gray, 1))); +// this.gkpzLabel.setPreferredSize(new Dimension(160, 20)); +// this.gkpzField = new CTextField(this.properties[17].getStringValue()); +// this.gkpzField.setPreferredSize(new Dimension(160, 20)); +// this.qtpzLabel = new JLabel("其他批准/日期"); +// this.qtpzLabel +// .setBorder((BorderFactory.createLineBorder(Color.gray, 1))); +// this.qtpzLabel.setPreferredSize(new Dimension(152, 20)); +// this.qtpzField = new CTextField(this.properties[18].getStringValue()); +// this.qtpzField.setPreferredSize(new Dimension(152, 20)); +// this.qtpzrqLabel = new JLabel("其他批准/日期"); +// this.qtpzrqLabel.setBorder((BorderFactory.createLineBorder(Color.gray, +// 1))); +// this.qtpzrqLabel.setPreferredSize(new Dimension(152, 20)); +// this.qtpzrqField = new CTextField(this.properties[19].getStringValue()); +// this.qtpzrqField.setPreferredSize(new Dimension(152, 20)); +// panel4.add("1.1.left.top", gfgcLabel); +// panel4.add("1.2.left.top", gfdhLabel); +// panel4.add("1.3.left.top", xgdjLabel); +// panel4.add("1.4.left.top", cxLabel); +// panel4.add("1.5.left.top", gkpzLabel); +// panel4.add("1.6.left.top", qtpzLabel); +// panel4.add("1.7.left.top", qtpzrqLabel); +// +// panel4.add("2.1.left.top", gfgcField); +// panel4.add("2.2.left.top", gfdhField); +// panel4.add("2.3.left.top", xgdjField); +// panel4.add("2.4.left.top", cxField); +// panel4.add("2.5.left.top", gkpzField); +// panel4.add("2.6.left.top", qtpzField); +// panel4.add("2.7.left.top", qtpzrqField); +// +// this.mainPanel = new JPanel(new PropertyLayout()); +// this.mainPanel.add("1.1.left.top", topPanel); +// this.mainPanel.add("2.1.left.top", panel2); +// this.mainPanel.add("3.1.left.top", panel3); +// this.mainPanel.add("4.1.left.top", panel4); +// +// this.tablePanel = new JPanel(new BorderLayout()); +// this.table = getjTable(null, null, header, null); +// // 添加滚动条 +// this.tablePanel.add(new JScrollPane(this.table), BorderLayout.CENTER); +// +// this.rootPanel = new JPanel(new FlowLayout()); +// this.addButton = new JButton("添加"); +// this.remButton = new JButton("移除"); +// this.comBinebutton = new JButton("合并"); +// this.splitButton = new JButton("拆分"); +// this.saveButton = new JButton("保存"); +// this.completeButton = new JButton("完成"); +// this.addSpecialButton = new JButton("添加特殊符号"); +// this.deleteSpecialButton = new JButton("移除特殊符号"); +// // this.sendbutton = new JButton("导出"); +// // this.sendbutton.addActionListener(this); +// this.rootPanel.add(addButton); +// this.rootPanel.add(remButton); +// this.rootPanel.add(comBinebutton); +// this.rootPanel.add(splitButton); +// this.rootPanel.add(saveButton); +// this.rootPanel.add(saveButton); +// this.rootPanel.add(completeButton); +// this.rootPanel.add(addSpecialButton); +// this.rootPanel.add(deleteSpecialButton); +// // this.rootPanel.add(sendbutton); +// +// JPanel centerPanel = new JPanel(new BorderLayout()); +// centerPanel.add(titlePanel, BorderLayout.NORTH); +// centerPanel.add(mainPanel, BorderLayout.CENTER); +// +// // JPanel centerPanel2 = new JPanel(new BorderLayout()); +// // centerPanel2.add(centerPanel,BorderLayout.NORTH); +// // centerPanel2.add(tablePanel, BorderLayout.CENTER); +// +// JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); +// splitPane.setOneTouchExpandable(true);// 让分割线显示出箭头 +// splitPane.setContinuousLayout(true);// 操作箭头,重绘图形 +// splitPane.setTopComponent(centerPanel); +// splitPane.setBottomComponent(tablePanel); +// +// // 添加鼠标监听 +// this.createActionEvent(); +// this.setLayout(new BorderLayout()); +// // this.add(centerPanel, BorderLayout.NORTH); +// this.add(splitPane, BorderLayout.CENTER); +// // dialog.add(tablePanel, BorderLayout.CENTER); +// this.add(rootPanel, BorderLayout.SOUTH); +// this.pack(); +// this.showDialog(); +// +// } +// +// // 添加监听 +// public void createActionEvent() { +// this.addButton.addActionListener(this); +// this.remButton.addActionListener(this); +// this.comBinebutton.addActionListener(this); +// this.splitButton.addActionListener(this); +// this.saveButton.addActionListener(this); +// this.addSpecialButton.addActionListener(this); +// this.deleteSpecialButton.addActionListener(this); +// this.completeButton.addActionListener(this); +// } +// +// /** +// * 写入数据到Jtable中 +// */ +// private void setJTable() { +// for (int i = 0; i < dataList.size(); i++) { +// List rowList = dataList.get(i); +// for (int j = 0; j < header.length; j++) { +// map.setValueAt(rowList.get(j), i, j); +// } +// } +// } +// +// // Jtable通用方法 +// public CTable getjTable(CTable partsTable, DefaultTableModel dtm, +// Object[] titleNames, Object[][] values) { +// int simpleLen = 100; +// int totleLen = 1000; +// if (partsTable == null) { +// this.map = new CTMap(dataList.size(), titleNames.length); +// map.setColumnIdentifiers(titleNames); +// if (processRows != null && processRows.size() > 0) { +// this.map.setProcessRowList(processRows); +// } +// setJTable(); +// partsTable = new CTable(map); +// // partsTable.setRowHeight(1, 50); +// // partsTable.setRowHeight(2, 100); +// partsTable.setRowHeight(50); +// // 隐藏列 +// partsTable.HiddenCell(0); +// partsTable.HiddenCell(titleNames.length - 1); +// // 添加监听 +// partsTable.addMouseListener(new MouseListener() { +// +// @Override +// public void mouseReleased(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mousePressed(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mouseExited(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mouseEntered(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mouseClicked(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// if (mouseevent.getClickCount() == 1) { +// map.setRow(table.getSelectedRow()); +// map.setColumn(table.getSelectedColumn()); +// } +// } +// }); +// // //设置显示器渲染 +// this.renderer = new TableCellTextAreaRenderer(); +// this.renderer.setProcessRows(processRows); +// // //设置居中 +// partsTable.setDefaultRenderer(Object.class, this.renderer); +// // //设置编辑器渲染 +// // this.textAreaCellEditor = new TextAreaCellEditor(); +// // partsTable.setDefaultEditor(Object.class, +// // this.textAreaCellEditor); +// if (simpleLen * titleNames.length >= totleLen) { +// for (int i = 0; i < titleNames.length; i++) { +// partsTable.getColumnModel().getColumn(i) +// .setPreferredWidth(simpleLen); +// } +// partsTable.setAutoResizeMode(0); +// } else { +// partsTable.setAutoResizeMode(1); +// } +// } +// return partsTable; +// } +// +// // Jtable通用方法 +// public CTable getNewjTable(CTable partsTable, DefaultTableModel dtm, +// Object[] titleNames, int rows) { +// int simpleLen = 100; +// int totleLen = 1000; +// if (partsTable == null) { +// CTMap map = new CTMap(rows, titleNames.length); +// map.setColumnIdentifiers(titleNames); +// map.setEditable(false); +// partsTable = new CTable(map); +// partsTable.setRowHeight(50); +// partsTable.HiddenCell(0); +// // 隐藏列 +// partsTable.HiddenCell(titleNames.length - 1); +// partsTable.HiddenCell(titleNames.length - 2); +// // 设置显示器渲染 +// // TableCellTextAreaRenderer renderer = new +// // TableCellTextAreaRenderer(); +// // partsTable.setDefaultRenderer(Object.class, renderer); +// // partsTable.setRowHeight(1, 50); +// if (simpleLen * titleNames.length >= totleLen) { +// for (int i = 0; i < titleNames.length; i++) { +// partsTable.getColumnModel().getColumn(i) +// .setPreferredWidth(simpleLen); +// } +// partsTable.setAutoResizeMode(0); +// } else { +// partsTable.setAutoResizeMode(1); +// } +// } +// return partsTable; +// } +// +// @Override +// public void actionPerformed(ActionEvent arg0) { +// Object source = arg0.getSource(); +// if (source.equals(this.addButton)) { +// int row = table.getSelectedRow(); +// if (this.processRows != null && this.processRows.size() == 0 +// && !(this.processRows.contains(row))) { +// MessageBox.post("无权限添加行!", "错误", MessageBox.ERROR); +// return; +// } +// Map cellMap = new HashMap(); +// Iterator> it = combineMap.entrySet() +// .iterator(); +// while (it.hasNext()) { +// Map.Entry entry = it.next(); +// List keysList = new ArrayList<>(); +// for (int j = 0; j < entry.getKey().length; j++) { +// keysList.add(entry.getKey()[j]); +// } +// if (keysList.contains(row)) { +// int[] newKey = new int[entry.getKey().length + 1]; +// for (int i = 0; i < entry.getKey().length; i++) { +// for (int j = 0; j < entry.getValue().length; j++) { +// map.split(entry.getKey()[i], entry.getValue()[j]); +// } +// newKey[i] = entry.getKey()[i]; +// } +// it.remove(); +// newKey[entry.getKey().length] = newKey[entry.getKey().length - 1] + 1; +// cellMap.put(newKey, entry.getValue()); +// } else if (!keysList.contains(row) +// && Integer.parseInt(keysList.get(0).toString()) > row) { +// int[] newKey = new int[entry.getKey().length]; +// for (int i = 0; i < entry.getKey().length; i++) { +// newKey[i] = entry.getKey()[i] + 1; +// } +// it.remove(); +// cellMap.put(newKey, entry.getValue()); +// } +// } +// map.insertRow(table.getSelectedRow() + 1); +// this.processRows = map.getProcessRowList(); +// this.renderer.setProcessRows(processRows); +// Iterator> cellIt = cellMap.entrySet() +// .iterator(); +// while (cellIt.hasNext()) { +// Map.Entry entry = cellIt.next(); +// map.combine(entry.getKey(), entry.getValue()); +// combineMap.put(entry.getKey(), entry.getValue()); +// } +// table.revalidate(); +// table.repaint(); +// } else if (source.equals(this.remButton)) { +// if (table.getSelectedRow() > 0 && table.getSelectedColumn() > 0) { +// (table.getCellEditor(table.getSelectedRow(), +// table.getSelectedColumn())).stopCellEditing(); +// } +// int row = table.getSelectedRow(); +// if (this.processRows != null && this.processRows.size() > 0 +// && !(this.processRows.contains(row))) { +// MessageBox.post("无权限删除行!", "错误", MessageBox.ERROR); +// return; +// } +// Map cellMap = new HashMap(); +// Iterator> it = combineMap.entrySet() +// .iterator(); +// while (it.hasNext()) { +// Map.Entry entry = it.next(); +// List keysList = new ArrayList<>(); +// for (int j = 0; j < entry.getKey().length; j++) { +// keysList.add(entry.getKey()[j]); +// } +// if (keysList.contains(row)) { +// int[] newKey = new int[entry.getKey().length - 1]; +// for (int i = 0; i < entry.getKey().length; i++) { +// for (int j = 0; j < entry.getValue().length; j++) { +// map.split(entry.getKey()[i], entry.getValue()[j]); +// } +// if (i < newKey.length) { +// newKey[i] = entry.getKey()[i]; +// } +// } +// it.remove(); +// cellMap.put(newKey, entry.getValue()); +// } else if (!keysList.contains(row) +// && Integer.parseInt(keysList.get(0).toString()) > row) { +// int[] newKey = new int[entry.getKey().length]; +// for (int i = 0; i < entry.getKey().length; i++) { +// for (int j = 0; j < entry.getValue().length; j++) { +// map.split(entry.getKey()[i], entry.getValue()[j]); +// } +// newKey[i] = entry.getKey()[i] - 1; +// } +// it.remove(); +// cellMap.put(newKey, entry.getValue()); +// } +// } +// if (map.getValueAt(table.getSelectedRow(), 0) != null) { +// deleteRows.add(map.getValueAt(table.getSelectedRow(), 0) +// .toString()); +// } +// map.removeRow(table.getSelectedRow()); +// this.processRows = map.getProcessRowList(); +// this.renderer.setProcessRows(processRows); +// Iterator> cellIt = cellMap.entrySet() +// .iterator(); +// while (cellIt.hasNext()) { +// Map.Entry entry = cellIt.next(); +// map.combine(entry.getKey(), entry.getValue()); +// combineMap.put(entry.getKey(), entry.getValue()); +// } +// table.revalidate(); +// table.repaint(); +// } else if (source.equals(this.comBinebutton)) { +// // table.setRowHeight(2, 50); +// int[] rows = table.getSelectedRows(); +// int[] columns = table.getSelectedColumns(); +// if (rows.length <= 0) { +// MessageBox.post("请选择要合并的单元格!", "错误", MessageBox.ERROR); +// return; +// } +// for (int i = 0; i < rows.length; i++) { +// if (this.processRows != null && this.processRows.size() > 0 +// && !(this.processRows.contains(rows[i]))) { +// MessageBox.post("无权限合并单元格", "错误", MessageBox.ERROR); +// return; +// } +// } +// if (combineMap != null && combineMap.size() != 0) { +// for (int i = 0; i < rows.length; i++) { +// Iterator> it = combineMap +// .entrySet().iterator(); +// while (it.hasNext()) { +// Map.Entry entry = it.next(); +// List keysList = new ArrayList<>(); +// for (int j = 0; j < entry.getKey().length; j++) { +// keysList.add(entry.getKey()[j]); +// } +// if (keysList.contains(rows[i])) { +// for (int j = 0; j < columns.length; j++) { +// List valueList = new ArrayList<>(); +// for (int k = 0; k < entry.getValue().length; k++) { +// valueList.add(entry.getValue()[k]); +// } +// if (valueList.contains(columns[j])) { +// columns = Union(columns, entry.getValue()); +// rows = Union(rows, entry.getKey()); +// if (combineMap.get(entry.getKey()) != null) { +// it.remove(); +// } +// } +// } +// } +// } +// } +// combineMap.put(rows, columns); +// } else { +// combineMap.put(rows, columns); +// } +// for (int i = 0; i < rows.length; i++) { +// for (int j = 0; j < columns.length; j++) { +// map.split(rows[i], columns[j]); +// } +// } +// Arrays.sort(rows); +// Arrays.sort(columns); +// map.combine(rows, columns); +// // map.removeRow(table.getSelectedRow()); +// table.revalidate(); +// table.repaint(); +// } else if (source.equals(this.splitButton)) { +// int row = table.getSelectedRow(); +// int colmn = table.getSelectedColumn(); +// if (row < 0) { +// MessageBox.post("请选择要拆分的单元格!", "错误", MessageBox.ERROR); +// return; +// } +// if (this.processRows != null && this.processRows.size() > 0 +// && !(this.processRows.contains(row))) { +// MessageBox.post("无权限拆分单元格!", "错误", MessageBox.ERROR); +// return; +// } +// Map cellMap = new HashMap(); +// Iterator> it = combineMap.entrySet() +// .iterator(); +// while (it.hasNext()) { +// Map.Entry entry = it.next(); +// List keysList = new ArrayList<>(); +// List valuesList = new ArrayList<>(); +// for (int j = 0; j < entry.getKey().length; j++) { +// keysList.add(entry.getKey()[j]); +// } +// for (int j = 0; j < entry.getValue().length; j++) { +// valuesList.add(entry.getValue()[j]); +// } +// if (keysList.contains(row) && valuesList.contains(colmn)) { +// for (int i = 0; i < entry.getKey().length; i++) { +// for (int j = 0; j < entry.getValue().length; j++) { +// map.split(entry.getKey()[i], entry.getValue()[j]); +// } +// } +// it.remove(); +// } +// } +// +// table.revalidate(); +// table.repaint(); +// } else if (source.equals(this.saveButton)) { +// okEvent(); +// } else if (source.equals(addSpecialButton)) { +// if (this.specialDialog == null) { +// System.out.println(table.getSelectedRow() + "===" +// + table.getSelectedColumn()); +// this.specialDialog = new SpecialDialog(); +// } else { +// System.out.println(table.getSelectedRow() + "===" +// + table.getSelectedColumn()); +// this.specialDialog.show(); +// } +// } else if (source.equals(libraryButton)) { +// if (this.libraryDialog == null) { +// System.out.println(table.getSelectedRow() + "===" +// + table.getSelectedColumn()); +// this.libraryDialog = new LibraryDialog(); +// } else { +// System.out.println(table.getSelectedRow() + "===" +// + table.getSelectedColumn()); +// this.libraryDialog.showDialog(); +// } +// } else if (source.equals(this.deleteSpecialButton)) { +// String columnName = table.getColumnName(table.getSelectedColumn()); +// String columnValue = table.getValueAt(table.getSelectedRow(), +// table.getColumnCount() - 1).toString(); +// if (columnValue != null && !columnValue.equals("")) { +// if (columnValue.indexOf("|") >= 0) { +// String[] columnValues = columnValue.split("\\|"); +// StringBuffer sb = new StringBuffer(); +// for (int i = 0; i < columnValues.length; i++) { +// if (columnValues[i].indexOf(columnName) < 0) { +// sb.append(columnValues[i]); +// sb.append("-"); +// } +// } +// table.setValueAt(sb.substring(0, sb.length() - 1), +// table.getSelectedRow(), table.getColumnCount() - 1); +// } else { +// if (columnValue.indexOf(columnName) >= 0) { +// table.setValueAt("", table.getSelectedRow(), +// table.getColumnCount() - 1); +// } +// } +// } +// } else if (source.equals(completeButton)) { +// if (isOwning) { +// okEvent(); +// this.disposeDialog(); +// this.dispose(); +// } else { +// try { +// InterfaceAIFComponent[] components = new InterfaceAIFComponent[meopId +// .size()]; +// TCComponentItemType itemType = (TCComponentItemType) this.session +// .getTypeComponent("Item"); +// for (int i = 0; i < meopId.size(); i++) { +// components[i] = itemType.find(meopId.get(i)); +// } +// NewProcessCommand command = new NewProcessCommand( +// AIFDesktop.getActiveDesktop(), +// AIFDesktop.getActiveDesktop() +// .getCurrentApplication(), components); +// isComplete = true; +// okEvent(); +// this.disposeDialog(); +// this.dispose(); +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// } +// } else { +// this.disposeDialog(); +// this.dispose(); +// } +// } +// +// private void okEvent() { +// // TODO Auto-generated method stub +// // 将数据保存到表单中 +// try { +// if (table.getSelectedRow() >= 0 && table.getSelectedColumn() >= 0) { +// (table.getCellEditor(table.getSelectedRow(), +// table.getSelectedColumn())).stopCellEditing(); +// } +// // table.getDefaultEditor(Object.class).stopCellEditing(); +// // TMomMethodUtil.setByPass(session, true); +// // form.getTCProperty("rb3_hbdyg").setStringValueArray(setCombineMap()); +// // form.getTCProperty("rb3_zhs").setIntValue(sumRow); +// ControlPlanBean controlPlan = new ControlPlanBean(); +// if (isOwning) { +// controlPlan.setKzjhbh(this.kzjhbhField.getText()); +// controlPlan.setZylxr(this.zylxrField.getText()); +// controlPlan.setZylxrdh(this.zylxrdhField.getText()); +// controlPlan.setBzriq(this.bzriqField.getText()); +// controlPlan.setXdrq(this.xdrqField.getText()); +// controlPlan.setSorhm(this.sorhmField.getText()); +// controlPlan.setLjh(this.ljhField.getText()); +// controlPlan.setHxxz(this.hxxzField.getText()); +// controlPlan.setGkgcpz(this.gkgcpzField.getText()); +// controlPlan.setKhtzbh(this.khtzbhField.getText()); +// controlPlan.setLjmc(this.ljmcField.getText()); +// controlPlan.setGfpzrq(this.gfpzrqField.getText()); +// controlPlan.setGkzlpz(this.gkzlpzField.getText()); +// controlPlan.setGfgc(this.gfgcField.getText()); +// controlPlan.setGfdh(this.gfdhField.getText()); +// controlPlan.setXgdj(this.xgdjField.getText()); +// controlPlan.setCx(this.cxField.getText()); +// controlPlan.setGkpz(this.gkpzField.getText()); +// controlPlan.setQtpz(this.qtpzField.getText()); +// controlPlan.setQtpzrq(this.qtpzrqField.getText()); +// } +// // 获取JTable中的数据 +// List> dataValeList = getTableValue(); +// TMom004SetControlPlanOperation operation = new TMom004SetControlPlanOperation( +// this.form, this.meprocess, this.session, properties, +// controlPlan, dataValeList, deleteRows, isOwning); +// session.queueOperation(operation); +// } catch (Exception e) { +// // TODO Auto-generated catch block +// MessageBox.post(e.toString(), "错误", MessageBox.ERROR); +// e.printStackTrace(); +// } +// } +// +// // 库控件初始化 +// /** +// * 获取数据库中的数据 +// */ +// public void getData() { +// // TODO Auto-generated method stub +// ResultSet rs = null; +// InputStream input = null; +// try { +// // 获取SQL语句 +// input = new BufferedInputStream(getClass().getResourceAsStream( +// "/sql.properties")); +// pro.load(input); +// // // 获取数据库连接 +// SqlUtilT.getConnectionTC10(); +// // SqlUtilT.getConnection("jdbc:Oracle:thin:@localhost:1521:TC10", +// // "tc10", "infodba"); +// String sql = String +// .format("select * from RB3_CONTROLPLAN_TREE where PARENT_ID is null"); +// rs = SqlUtilT.read(sql); +// List beans = new ArrayList(); +// while (rs.next()) { +// ControlPlanTreeBean bean = new ControlPlanTreeBean(); +// bean.setPlmeid(rs.getString("PLMEID")); +// bean.setId(rs.getString("ID")); +// bean.setName(rs.getString("NAME")); +// bean.setParentId(rs.getString("PARENT_ID")); +// beans.add(bean); +// } +// bean = getChidren(beans.get(0)); +// } catch (Exception e) { +// e.printStackTrace(); +// } finally { +// if (rs != null) { +// SqlUtilT.free(rs); +// } +// if (input != null) { +// try { +// input.close(); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// } +// +// } +// +// public ControlPlanTreeBean getChidren( +// ControlPlanTreeBean controlPlanTreeBean) { +// // TODO Auto-generated method stub +// ResultSet rs = null; +// try { +// // 查询权限库 +// String sql = String +// .format("select * from RB3_CONTROLPLAN_TREE where PARENT_ID = \'%s\'", +// controlPlanTreeBean.getId()); +// rs = SqlUtilT.read(sql); +// List beans = new ArrayList(); +// while (rs.next()) { +// ControlPlanTreeBean bean = new ControlPlanTreeBean(); +// bean.setPlmeid(rs.getString("PLMEID")); +// bean.setId(rs.getString("ID")); +// bean.setName(rs.getString("NAME")); +// bean.setParentId(rs.getString("PARENT_ID")); +// beans.add(bean); +// } +// if (beans.size() > 0) { +// controlPlanTreeBean.setChidrenBeans(beans); +// for (ControlPlanTreeBean controlPlanTreeBean2 : beans) { +// getChidren(controlPlanTreeBean2); +// } +// } +// return controlPlanTreeBean; +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } finally { +// if (rs != null) { +// SqlUtilT.free(rs); +// } +// } +// return controlPlanTreeBean; +// } +// +// public CTreeNode createNodes(DefaultMutableTreeNode node, +// ControlPlanTreeBean bean) { +// CTreeNode root = null; +// System.out.println(bean.getName()); +// root = new CTreeNode(bean); +// ResultSet rs = null; +// try { +// if (bean != null) { +// // 查询权限库 +// String sql = String.format( +// pro.getProperty("CONTROLPLANLIBRARYSELECT"), +// bean.getId()); +// rs = SqlUtilT.read(sql); +// List> rowList = new ArrayList>(); +// while (rs.next()) { +// List list = new ArrayList(); +// list.add(rs.getString("PLMEID")); +// // list.add(rs.getString("RB3_JQSB")); +// // list.add(rs.getString("RB3_SMJY")); +// list.add(rs.getString("RB3_QPTBH")); +// list.add(rs.getString("RB3_CC")); +// list.add(rs.getString("RB3_CP")); +// list.add(rs.getString("RB3_GC")); +// list.add(rs.getString("RB3_TSTX")); +// list.add(rs.getString("RB3_CPGC")); +// list.add(rs.getString("RB3_CLFF")); +// list.add(rs.getString("RB3_RL")); +// list.add(rs.getString("RB3_PL")); +// list.add(rs.getString("RB3_SJSJ")); +// list.add(rs.getString("RB3_GCSJ")); +// list.add(rs.getString("RB3_MJSJ")); +// list.add(rs.getString("RB3_FZR")); +// list.add(rs.getString("RB3_KZFF")); +// list.add(rs.getString("RB3_CZGF")); +// list.add(rs.getString("RB3_FYJH")); +// list.add(rs.getString("PARENT_ID")); +// list.add(rs.getString("RB3_SPECIAL")); +// rowList.add(list); +// } +// if (rowList.size() > 0) { +// final JTable jtable = getNewjTable(null, null, header2, +// rowList.size() + 1); +// for (int i = 0; i < rowList.size() + 1; i++) { +// if (i == 0) { +// for (int j = 0; j < header2.length; j++) { +// jtable.setValueAt(header2[j], i, j); +// } +// } else { +// for (int j = 0; j < rowList.get(i - 1).size(); j++) { +// jtable.setValueAt(rowList.get(i - 1).get(j), i, +// j); +// } +// } +// } +// // 添加监听 +// jtable.addMouseListener(new MouseListener() { +// +// @Override +// public void mouseReleased(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mousePressed(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mouseExited(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mouseEntered(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mouseClicked(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// if (mouseevent.getClickCount() == 2) { +// if (table.getSelectedRow() >= 0) { +// table.getCellEditor(table.getSelectedRow(), +// table.getSelectedColumn()) +// .stopCellEditing(); +// for (int i = 1; i < jtable.getColumnCount(); i++) { +// if (i == jtable.getColumnCount() - 2) { +// continue; +// } else if (i == jtable.getColumnCount() - 1) { +// table.setValueAt( +// jtable.getValueAt(jtable +// .getSelectedRow(), +// i), table +// .getSelectedRow(), +// i + 3); +// } else { +// table.setValueAt( +// jtable.getValueAt(jtable +// .getSelectedRow(), +// i), table +// .getSelectedRow(), +// i + 4); +// } +// } +// } +// } +// } +// }); +// DefaultMutableTreeNode child = new DefaultMutableTreeNode( +// jtable); +// root.add(child); +// node.add(root); +// if (bean.getChidrenBeans() != null) { +// for (int i = 0; i < bean.getChidrenBeans().size(); i++) { +// createNodes(root, bean.getChidrenBeans().get(i)); +// } +// } +// } else if (bean.getChidrenBeans() == null +// || bean.getChidrenBeans().size() == 0) { +// if (node != null) { +// node.add(root); +// } +// } else { +// if (node != null) { +// node.add(root); +// } +// for (int i = 0; i < bean.getChidrenBeans().size(); i++) { +// createNodes(root, bean.getChidrenBeans().get(i)); +// } +// } +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } finally { +// if (rs != null) { +// SqlUtilT.free(rs); +// } +// } +// return root; +// } +// +// private List> getTableValue() { +// // TODO Auto-generated method stub +// List> dataValeList = new ArrayList>(); +// +// for (int j = 0; j < processRows.size(); j++) { +// List rowValue = new ArrayList(); +// for (int j2 = 0; j2 < this.map.getColumnCount(); j2++) { +// rowValue.add(getCellValue(processRows.get(j), j2)); +// } +// rowValue.add(processRows.get(j).toString()); +// // rowValue.add("1"); +// if (combineMap.size() > 0) { +// Iterator> it = combineMap.entrySet() +// .iterator(); +// while (it.hasNext()) { +// Map.Entry entry = it.next(); +// StringBuffer rowSb = new StringBuffer(); +// StringBuffer columnSb = new StringBuffer(); +// for (int k = 0; k < entry.getKey().length; k++) { +// rowSb.append(entry.getKey()[k]); +// rowSb.append(","); +// } +// for (int k = 0; k < entry.getValue().length; k++) { +// columnSb.append(entry.getValue()[k]); +// columnSb.append(","); +// } +// if (entry.getKey()[0] == processRows.get(j)) { +// if (rowValue.size() == 24) { +// rowValue.set( +// 23, +// rowValue.get(23) +// + "-" +// + rowSb.substring(0, +// rowSb.length() - 1) +// + "/" +// + columnSb.substring(0, +// columnSb.length() - 1)); +// } else { +// rowValue.add(rowSb.substring(0, rowSb.length() - 1) +// + "/" +// + columnSb.substring(0, +// columnSb.length() - 1)); +// } +// } +// // else +// // { +// // rowValue.add(""); +// // } +// } +// } +// if (rowValue.size() == 23) { +// rowValue.add(""); +// } +// if (isComplete) { +// rowValue.add("1"); +// } else { +// rowValue.add("0"); +// } +// rowValue.add("1"); +// rowValue.add(item.getType().toUpperCase()); +// dataValeList.add(rowValue); +// } +// // for (int i = 0; i < processRowList.size(); i++) { +// // List rows = processRowList.get(i); +// // } +// return dataValeList; +// } +// +// private String getCellValue(int row, int cloumn) { +// // TODO Auto-generated method stub +// String resultValue = ""; +// if (this.map.getValueAt(row, cloumn) != null) { +// resultValue = this.map.getValueAt(row, cloumn).toString(); +// } +// if (combineMap != null && combineMap.size() > 0) { +// Iterator> it = combineMap.entrySet() +// .iterator(); +// while (it.hasNext()) { +// Map.Entry entry = it.next(); +// List keysList = new ArrayList<>(); +// List valuesList = new ArrayList<>(); +// for (int k = 0; k < entry.getKey().length; k++) { +// keysList.add(entry.getKey()[k]); +// } +// for (int k = 0; k < entry.getValue().length; k++) { +// valuesList.add(entry.getValue()[k]); +// } +// if (keysList.contains(row) && valuesList.contains(cloumn)) { +// return (String) this.map.getValueAt( +// Integer.parseInt(keysList.get(0).toString()), +// Integer.parseInt(valuesList.get(0).toString())); +// } +// } +// } else { +// if (this.map.getValueAt(row, cloumn) != null) { +// return this.map.getValueAt(row, cloumn).toString(); +// } +// } +// return resultValue; +// } +// +// private String[] setCombineMap() { +// String[] combines = new String[combineMap.size()]; +// Iterator> it = combineMap.entrySet().iterator(); +// int index = 0; +// while (it.hasNext()) { +// Map.Entry entry = it.next(); +// StringBuffer rowSb = new StringBuffer(); +// StringBuffer columnSb = new StringBuffer(); +// for (int i = 0; i < entry.getKey().length; i++) { +// rowSb.append(entry.getKey()[i]); +// rowSb.append(","); +// } +// for (int i = 0; i < entry.getValue().length; i++) { +// columnSb.append(entry.getValue()[i]); +// columnSb.append(","); +// } +// combines[index] = rowSb.substring(0, rowSb.length() - 1) + "/" +// + columnSb.substring(0, columnSb.length() - 1); +// index++; +// } +// return combines; +// } +// +// private int[] Union(int[] a1, int[] a2) { +// List list1 = new ArrayList(); +// List list2 = new ArrayList(); +// for (int i : a1) { +// list1.add(i); +// } +// for (int i : a2) { +// list2.add(i); +// } +// list1.removeAll(list2); +// list2.addAll(list1); +// int[] result = new int[list2.size()]; +// for (int i = 0; i < list2.size(); i++) { +// result[i] = list2.get(i); +// } +// return result; +// } +// +// private class SpecialDialog extends AbstractAIFDialog implements +// ActionListener { +// private JPanel tablePanel;// 表格控件 +// private JTable table; +// +// private JPanel rootPanel;// 按钮 +// private JButton okButton;// 确定 +// private JButton celButton;// 取消 +// +// public SpecialDialog() { +// // TODO Auto-generated constructor stub +// super(); +// init(); +// } +// +// private void init() { +// // TODO Auto-generated method stub +// this.setTitle("选择特殊符号"); +// this.table = getjTable(this.table, null, new Object[] { 1, 2, 3, 4, +// 5, 6, 7, 8 }, new Object[][] { { 1, 2, 3, 4, 5, 6, 7, 8 }, +// { 9, 0, "q", "w", "e", "r", "t", "y" } }); +// this.setLocationRelativeTo(this); +// this.table.setRowHeight(30); +// this.table.getTableHeader().setVisible(false); +// this.table.setFont(new Font("Y14.5M", 0, 15)); +// this.tablePanel = new JPanel(new BorderLayout()); +// this.tablePanel.add(this.table); +// +// this.okButton = new JButton("确定"); +// this.okButton.addActionListener(this); +// this.celButton = new JButton("取消"); +// this.celButton.addActionListener(this); +// this.rootPanel = new JPanel(new FlowLayout()); +// this.rootPanel.add(this.okButton); +// this.rootPanel.add(this.celButton); +// +// this.add(this.tablePanel, BorderLayout.CENTER); +// this.add(this.rootPanel, BorderLayout.SOUTH); +// this.pack(); +// this.show(); +// } +// +// // Jtable通用方法 +// public JTable getjTable(JTable partsTable, DefaultTableModel dtm, +// Object[] titleNames, Object[][] values) { +// int simpleLen = 100; +// int totleLen = 1000; +// if (partsTable == null) { +// partsTable = new JTable(this.getTableModel(dtm, titleNames, +// values)); +// partsTable.setCellSelectionEnabled(true); +// if (simpleLen * titleNames.length >= totleLen) { +// for (int i = 0; i < titleNames.length; i++) { +// partsTable.getColumnModel().getColumn(i) +// .setPreferredWidth(simpleLen); +// } +// partsTable.setAutoResizeMode(0); +// } else { +// partsTable.setAutoResizeMode(1); +// } +// } +// return partsTable; +// } +// +// public DefaultTableModel getTableModel(DefaultTableModel dtm, +// Object[] titleNames, Object[][] values) { +// MyTableModel tableModel = null; +// if (dtm == null) { +// tableModel = new MyTableModel(values, titleNames); +// } +// return tableModel; +// } +// +// @Override +// public void actionPerformed(ActionEvent actionevent) { +// // TODO Auto-generated method stub +// Object source = actionevent.getSource(); +// if (source.equals(this.okButton)) { +// int row = CopyOfTMom004SetControlPlanDialog.table +// .getSelectedRow(); +// int column = CopyOfTMom004SetControlPlanDialog.table +// .getSelectedColumn(); +// // 保存特殊符号位置 +// String columnName = CopyOfTMom004SetControlPlanDialog.table +// .getColumnName(CopyOfTMom004SetControlPlanDialog.table +// .getSelectedColumn()); +// +// int cursorIndex = ((TextAreaCellEditor) (CopyOfTMom004SetControlPlanDialog.table +// .getCellEditor(row, column))).getIndex(); +// System.out.println("index+" + cursorIndex); +// (CopyOfTMom004SetControlPlanDialog.table.getCellEditor(row, +// column)).stopCellEditing(); +// // TMom004SetControlPlanDialog.table.getDefaultEditor(Object.class).stopCellEditing(); +// StringBuilder sb = new StringBuilder( +// CopyOfTMom004SetControlPlanDialog.table.getValueAt(row, +// column).toString()); +// +// // 定义循环,如果index的位置不是-1,就一直查找 +// Integer index = 0; +// while ((index = sb.toString().indexOf("\n", index)) != -1) { +// +// // 每循环一次就要明确下一次查找的位置 +// index = index + "\n".length(); +// // 每查找一次计数器自增 +// cursorIndex++; +// } +// // 特殊符号 +// Object special = CopyOfTMom004SetControlPlanDialog.table +// .getValueAt(row, +// CopyOfTMom004SetControlPlanDialog.table +// .getColumnCount() - 1); +// if (special == null || special.toString() == "") { +// CopyOfTMom004SetControlPlanDialog.table.setValueAt( +// columnName + "-" + cursorIndex, row, +// CopyOfTMom004SetControlPlanDialog.table +// .getColumnCount() - 1); +// } else { +// CopyOfTMom004SetControlPlanDialog.table.setValueAt(special +// + "|" + columnName + "-" + cursorIndex, row, +// CopyOfTMom004SetControlPlanDialog.table +// .getColumnCount() - 1); +// } +// System.out.println(sb.length()); +// String s = sb.insert( +// cursorIndex, +// this.table.getValueAt(this.table.getSelectedRow(), +// this.table.getSelectedColumn()).toString()) +// .toString(); +// CopyOfTMom004SetControlPlanDialog.table.setValueAt(s, +// CopyOfTMom004SetControlPlanDialog.table +// .getSelectedRow(), +// CopyOfTMom004SetControlPlanDialog.table +// .getSelectedColumn()); +// System.out.println(CopyOfTMom004SetControlPlanDialog.table +// .getValueAt(row, column).toString()); +// } else { +// this.dispose(); +// } +// } +// } +// +// /** +// * 控制计划 +// * +// * @author Administrator +// * +// */ +// private class LibraryDialog extends AbstractAIFDialog { +// // 界面所需控件 +// private JPanel titlePanel;// 标题 +// private JLabel titleLabel; +// +// // 标签控件 +// private JTabbedPane tabbedPane; +// +// public LibraryDialog() { +// // TODO Auto-generated constructor stub +// super(); +// getData(); +// init(); +// } +// +// private void init() { +// // TODO Auto-generated method stub +// this.setTitle("PFMEA库"); +// this.setPreferredSize(new Dimension(800, 600)); +// // 初始化标题部分控件 +// this.titlePanel = new JPanel(); +// this.titleLabel = new JLabel("潜在失效模式及后果分析"); +// this.titleLabel.setFont(new Font("宋体", 1, 18)); +// this.titlePanel.add(this.titleLabel); +// +// JPanel centerPanel = new JPanel(new BorderLayout()); +// centerPanel.add(titlePanel, BorderLayout.NORTH); +// +// this.setLayout(new BorderLayout()); +// this.add(centerPanel, BorderLayout.NORTH); +// this.add(this.tabbedPane, BorderLayout.CENTER); +// // dialog.add(tablePanel, BorderLayout.CENTER); +// // this.add(rootPanel, BorderLayout.SOUTH); +// this.pack(); +// this.showDialog(); +// } +// +// // 获取PFMEA库 +// /** +// * 获取数据库中的数据 +// */ +// private void getData() { +// // TODO Auto-generated method stub +// ResultSet rs = null; +// InputStream input = null; +// try { +// // 获取SQL语句 +// input = new BufferedInputStream(getClass().getResourceAsStream( +// "/sql.properties")); +// pro.load(input); +// // 获取数据库连接 +// // SqlUtilT.getConnectionTC10(); +// SqlUtilT.getConnection("jdbc:Oracle:thin:@localhost:1521:TC10", +// "tc10", "infodba"); +// String sql = String +// .format("select * from RB3_CONTROLPLAN_TREE"); +// rs = SqlUtilT.read(sql); +// List beans = new ArrayList(); +// while (rs.next()) { +// ControlPlanTreeBean bean = new ControlPlanTreeBean(); +// bean.setPlmeid(rs.getString("PLMEID")); +// bean.setId(rs.getString("ID")); +// bean.setName(rs.getString("NAME")); +// bean.setParentId(rs.getString("PARENT_ID")); +// beans.add(bean); +// } +// createTabbedPane(beans); +// } catch (Exception e) { +// e.printStackTrace(); +// } finally { +// if (rs != null) { +// SqlUtilT.free(rs); +// } +// if (input != null) { +// try { +// input.close(); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// } +// +// } +// +// public void createTabbedPane(List beans) { +// this.tabbedPane = new JTabbedPane(); +// try { +// if (beans != null && beans.size() > 0) { +// for (int i = 0; i < beans.size(); i++) { +// ResultSet rs = null; +// // 查询权限库 +// String sql = String.format( +// pro.getProperty("CONTROLPLANLIBRARYSELECT"), +// beans.get(i).getId()); +// rs = SqlUtilT.read(sql); +// List> dataList = new ArrayList>(); +// while (rs.next()) { +// List rowList = new ArrayList(); +// rowList.add(rs.getString("PLMEID")); +// // list.add(rs.getString("RB3_JQSB")); +// // list.add(rs.getString("RB3_SMJY")); +// rowList.add(rs.getString("RB3_QPTBH")); +// rowList.add(rs.getString("RB3_CC")); +// rowList.add(rs.getString("RB3_CP")); +// rowList.add(rs.getString("RB3_GC")); +// rowList.add(rs.getString("RB3_TSTX")); +// rowList.add(rs.getString("RB3_CPGC")); +// rowList.add(rs.getString("RB3_CLFF")); +// rowList.add(rs.getString("RB3_RL")); +// rowList.add(rs.getString("RB3_PL")); +// rowList.add(rs.getString("RB3_SJSJ")); +// rowList.add(rs.getString("RB3_GCSJ")); +// rowList.add(rs.getString("RB3_MJSJ")); +// rowList.add(rs.getString("RB3_FZR")); +// rowList.add(rs.getString("RB3_KZFF")); +// rowList.add(rs.getString("RB3_CZGF")); +// rowList.add(rs.getString("RB3_FYJH")); +// rowList.add(rs.getString("PARENT_ID")); +// rowList.add(rs.getString("RB3_SPECIAL")); +// dataList.add(rowList); +// } +// final CTable jtable; +// if (dataList.size() > 0) { +// jtable = getNewjTable(null, null, header2, +// dataList.size()); +// for (int j = 0; j < dataList.size(); j++) { +// for (int k = 0; k < dataList.get(j).size(); k++) { +// jtable.setValueAt(dataList.get(j).get(k), +// j, k); +// } +// } +// } else { +// jtable = getNewjTable(null, null, header2, +// dataList.size() + 1); +// jtable.setValueAt(beans.get(i).getId(), 0, +// jtable.getColumnCount() - 2); +// } +// // 添加监听 +// jtable.addMouseListener(new MouseListener() { +// +// @Override +// public void mouseReleased(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mousePressed(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mouseExited(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mouseEntered(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mouseClicked(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// if (mouseevent.getClickCount() == 2) { +// if (table.getSelectedRow() >= 0) { +// table.getCellEditor( +// table.getSelectedRow(), +// table.getSelectedColumn()) +// .stopCellEditing(); +// for (int i = 1; i < jtable +// .getColumnCount(); i++) { +// if (i == jtable.getColumnCount() - 2) { +// continue; +// } else if (i == jtable +// .getColumnCount() - 1) { +// table.setValueAt( +// jtable.getValueAt( +// jtable.getSelectedRow(), +// i), +// table.getSelectedRow(), +// i + 3); +// } else { +// table.setValueAt( +// jtable.getValueAt( +// jtable.getSelectedRow(), +// i), +// table.getSelectedRow(), +// i + 4); +// } +// } +// } +// } +// } +// }); +// tabbedPane.add(beans.get(i).getName(), new JScrollPane( +// jtable)); +// if (rs != null) { +// SqlUtilT.free(rs); +// } +// } +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } finally { +// SqlUtilT.free(); +// } +// } +// } +// +//} diff --git a/src/com/connor/zf/controlplan/CreateControlplanHandler.java b/src/com/connor/zf/controlplan/CreateControlplanHandler.java new file mode 100644 index 0000000..f6e0fa4 --- /dev/null +++ b/src/com/connor/zf/controlplan/CreateControlplanHandler.java @@ -0,0 +1,316 @@ +package com.connor.zf.controlplan; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.util.CreateNewBOHandler; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +import java.awt.Dimension; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.util.Arrays; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JTextField; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; + +import org.eclipse.core.commands.AbstractHandler; + +public class CreateControlplanHandler extends AbstractHandler{ // implements DocumentListener + + private TCComponentItemRevision itemRevision; + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + + + + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + + TCSession session =(TCSession) app.getSession(); + + String type = targetComponent.getType(); + + if(type.equals("ZF6_ZCTRevision")) { + + itemRevision = (TCComponentItemRevision)targetComponent; + + new Thread() { + + public void run() { + + JFrame frame = new JFrame(); + + frame.setLayout(new PropertyLayout()); + + frame.setPreferredSize(new Dimension(450,150)); + + JTextField textField = new JTextField(); +// textName.setEditable(false); + textField.setPreferredSize(new Dimension(300,20)); + JButton btn = new JButton("指派"); + frame.add("1.1.left.center",new JLabel (" ID: ")); + frame.add("1.2.left.center",textField); + frame.add("1.3.left.center",btn); +// btn.add +// btn.getDocument().addDocumentListener(this); + btn.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + try { + String zctId = itemRevision.getStringProperty("item_id"); + + TCComponentItemType itemTypeComp = (TCComponentItemType) session.getTypeComponent("ZF6_KZJH"); + + String pfmeaId = "HZF-CP-"+zctId+"-"; + + int ids = getItemRevision(session,pfmeaId); + + while(true) { + + ids = ids+1; + + String format = String.format("%03d", ids); + + String idString = pfmeaId+format; + + TCComponentItem find = itemTypeComp.find(idString); + + if(find==null) { + pfmeaId = idString; + break; + } + + } + + textField.setText(pfmeaId); + textField.setEditable(false); + + } catch (Exception er) { + // TODO Auto-generated catch block + er.printStackTrace(); + } + } + }); + frame.add("2.1.left.center",new JLabel (" 名称: ")); + + JTextField textField2 = new JTextField(); +// textName.setEditable(false); + textField2.setPreferredSize(new Dimension(300,20)); + frame.add("2.2.left.center",textField2); + JButton btn1 = new JButton("完成"); + btn1.setEnabled(false); + textField2.getDocument().addDocumentListener(new DocumentListener() { + + @Override + public void removeUpdate(DocumentEvent e) { + // TODO Auto-generated method stub + if(!textField2.getText().trim().equals("")) { + btn1.setEnabled(true); + }else { + btn1.setEnabled(false); + } + } + + @Override + public void insertUpdate(DocumentEvent e) { + // TODO Auto-generated method stub + if(!textField2.getText().trim().equals("")) { + btn1.setEnabled(true); + }else { + btn1.setEnabled(false); + } + } + + @Override + public void changedUpdate(DocumentEvent e) { + // TODO Auto-generated method stub + if(!textField2.getText().trim().equals("")) { + btn1.setEnabled(true); + }else { + btn1.setEnabled(false); + } + } + }); + + JButton btn2 = new JButton("取消"); + btn1.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + try { + TCComponentItemType itemTypeComp = (TCComponentItemType) session.getTypeComponent("ZF6_KZJH"); + + TCComponentItem create = itemTypeComp.create(textField.getText(), itemTypeComp.getNewRev(null) ,"ZF6_KZJH",textField2.getText() , "", null); + String obName = create.getStringProperty("object_string"); + textField.setText(""); + textField2.setText(""); + btn1.setEnabled(false); + Boolean flag = false; + String folderName = ""; +// MessageBox.post("创建完成","提示",2); + String userId = session.getUser().getUserId(); + AIFComponentContext[] whereReferenced = itemRevision.getItem().whereReferenced(); + for(AIFComponentContext context:whereReferenced) { + + InterfaceAIFComponent component = context.getComponent(); + + if(component instanceof TCComponentFolder) { + + TCComponentFolder folder = (TCComponentFolder)component; + + String userName = folder.getReferenceProperty("owning_user") + .getStringProperty("user_id"); + if(userId.equals(userName)) { + flag = true; + folderName = folder.getStringProperty("object_name"); + folder.add("contents", create); + break; + } + } + } + + if(flag) { + MessageBox.post(obName+"创建到了"+folderName+"文件夹下","提示",2); + }else { + session.getUser().getHomeFolder().add("contents", create); + MessageBox.post(obName+"创建到了HOME下","提示",2); + } + + + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + } + }); + btn2.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + frame.dispose(); + + } + }); + frame.add("3.1.left.center",btn1); + frame.add("3.2.left.center",btn2); + Toolkit toolkit = Toolkit.getDefaultToolkit(); + + int x = (int)(toolkit.getScreenSize().getWidth()-frame.getWidth())/2; + + int y = (int)(toolkit.getScreenSize().getHeight()-frame.getHeight())/2; + + frame.setLocation(x, y); + frame.pack(); + frame.setResizable(false); + frame.show(); + + } + + + }.start(); + + +// CreateNewBOHandler handler = new CreateNewBOHandler("ZF6_KZJH"); +// handler.execute(arg0); + + + }else { + MessageBox.post("请选中ZF6_ZCTRevision对象","提示",2); + } + + + return null; + } + public static int getItemRevision(TCSession session, String itemId) throws Exception { + System.out.println("Search Revision: " + itemId ); + if (isEmpty(itemId)) { + return 0; + } else { + String queryName = "Item Revision..."; + String[] keys = new String[]{getText(session, "ItemID")}; + String[] vals = new String[]{itemId}; + TCComponent[] res = query(session, queryName, keys, vals); + + if(res==null) { + return 0; + } + + return res.length; + + } + } + public static boolean isEmpty(String str) { + return str == null || "".equals(str.trim()); + } + public static String getText(TCSession session, String str) throws Exception { + if (isEmpty(str)) { + return str; + } else { + String res = session.getTextService().getTextValue(str); + return !isEmpty(res) ? res : str; + } + } + public static TCComponent[] query(TCSession session, String queryName, String[] keys, String[] vals) + throws Exception { + System.out.println("Query: " + queryName); + System.out.println("keys = " + Arrays.toString(keys)); + System.out.println("vals = " + Arrays.toString(vals)); + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + System.out.println("null"+queryName); + } else { + query.clearCache(); + query.refresh(); + return query.execute(keys, vals); + } + return null; + } +// @Override +// public void insertUpdate(DocumentEvent e) { +// // TODO Auto-generated method stub +// +// } +// @Override +// public void removeUpdate(DocumentEvent e) { +// // TODO Auto-generated method stub +// +// } +// @Override +// public void changedUpdate(DocumentEvent e) { +// // TODO Auto-generated method stub +// +// } +} diff --git a/src/com/connor/zf/controlplan/EntrustmentFormBean.java b/src/com/connor/zf/controlplan/EntrustmentFormBean.java new file mode 100644 index 0000000..76339f0 --- /dev/null +++ b/src/com/connor/zf/controlplan/EntrustmentFormBean.java @@ -0,0 +1,524 @@ +package com.connor.zf.controlplan; + +public class EntrustmentFormBean { + private String puid; + private String itemId; + private String p1 = ""; + private String p2 = ""; + private String p3 = ""; + private String p4 = ""; + private String p5 = ""; + private String p6 = ""; + private String p7 = ""; + private String p8 = ""; + private String p9 = ""; + private String p10 = ""; + private String p11 = ""; + private String p12 = ""; + private String p13 = ""; + private String p14 = ""; + private String p15 = ""; + private String p16 = ""; + private String p17 = ""; + private String p18 = ""; + private String p19 = ""; + private String p20 = ""; + private String p21 = ""; + private String p22 = ""; + private String p23 = ""; + private String p24 = ""; + private String p25 = ""; + private String p26 = ""; + private String p27 = ""; + private String p28 = ""; + private String p29 = ""; + private String p30 = ""; + private String p31 = ""; + private String p32 = ""; + private String p33 = ""; + private String p34 = ""; + private String p35 = ""; + private String p36 = ""; + private String p37 = ""; + private String p38 = ""; + private String p39 = ""; + private String p40 = ""; + private String p41 = ""; + private String p42 = ""; + private String p43 = ""; + private String p44 = ""; + private String p45 = ""; + private String p46 = ""; + private String p47 = ""; + private String p48 = ""; + private String p49 = ""; + private String p50 = ""; + private String p51 = ""; + private String p52 = ""; + private String p53 = ""; + private String p54 = ""; + private String p55 = ""; + private String p56 = ""; + private String p57 = ""; + private String p58 = ""; + private String p59 = ""; + private String p60 = ""; + private String p61 = ""; + private String p62 = ""; + private String p63 = ""; + private String p64 = ""; + private String p65 = ""; + private String p66 = ""; + private String p67 = ""; + private String p68 = ""; + private String p69 = ""; + private String p70 = ""; + private String p71 = ""; + private String p72 = ""; + public String getPuid() { + return puid; + } + public void setPuid(String puid) { + this.puid = puid; + } + public String getItemId() { + return itemId; + } + public void setItemId(String itemId) { + this.itemId = itemId; + } + public String getP1() { + return p1; + } + public void setP1(String p1) { + this.p1 = p1; + } + public String getP2() { + return p2; + } + public void setP2(String p2) { + this.p2 = p2; + } + public String getP3() { + return p3; + } + public void setP3(String p3) { + this.p3 = p3; + } + public String getP4() { + return p4; + } + public void setP4(String p4) { + this.p4 = p4; + } + public String getP5() { + return p5; + } + public void setP5(String p5) { + this.p5 = p5; + } + public String getP6() { + return p6; + } + public void setP6(String p6) { + this.p6 = p6; + } + public String getP7() { + return p7; + } + public void setP7(String p7) { + this.p7 = p7; + } + public String getP8() { + return p8; + } + public void setP8(String p8) { + this.p8 = p8; + } + public String getP9() { + return p9; + } + public void setP9(String p9) { + this.p9 = p9; + } + public String getP10() { + return p10; + } + public void setP10(String p10) { + this.p10 = p10; + } + public String getP11() { + return p11; + } + public void setP11(String p11) { + this.p11 = p11; + } + public String getP12() { + return p12; + } + public void setP12(String p12) { + this.p12 = p12; + } + public String getP13() { + return p13; + } + public void setP13(String p13) { + this.p13 = p13; + } + public String getP14() { + return p14; + } + public void setP14(String p14) { + this.p14 = p14; + } + public String getP15() { + return p15; + } + public void setP15(String p15) { + this.p15 = p15; + } + public String getP16() { + return p16; + } + public void setP16(String p16) { + this.p16 = p16; + } + public String getP17() { + return p17; + } + public void setP17(String p17) { + this.p17 = p17; + } + public String getP18() { + return p18; + } + public void setP18(String p18) { + this.p18 = p18; + } + public String getP19() { + return p19; + } + public void setP19(String p19) { + this.p19 = p19; + } + public String getP20() { + return p20; + } + public void setP20(String p20) { + this.p20 = p20; + } + public String getP21() { + return p21; + } + public void setP21(String p21) { + this.p21 = p21; + } + public String getP22() { + return p22; + } + public void setP22(String p22) { + this.p22 = p22; + } + public String getP23() { + return p23; + } + public void setP23(String p23) { + this.p23 = p23; + } + public String getP24() { + return p24; + } + public void setP24(String p24) { + this.p24 = p24; + } + public String getP25() { + return p25; + } + public void setP25(String p25) { + this.p25 = p25; + } + public String getP26() { + return p26; + } + public void setP26(String p26) { + this.p26 = p26; + } + public String getP27() { + return p27; + } + public void setP27(String p27) { + this.p27 = p27; + } + public String getP28() { + return p28; + } + public void setP28(String p28) { + this.p28 = p28; + } + public String getP29() { + return p29; + } + public void setP29(String p29) { + this.p29 = p29; + } + public String getP30() { + return p30; + } + public void setP30(String p30) { + this.p30 = p30; + } + public String getP31() { + return p31; + } + public void setP31(String p31) { + this.p31 = p31; + } + public String getP32() { + return p32; + } + public void setP32(String p32) { + this.p32 = p32; + } + public String getP33() { + return p33; + } + public void setP33(String p33) { + this.p33 = p33; + } + public String getP34() { + return p34; + } + public void setP34(String p34) { + this.p34 = p34; + } + public String getP35() { + return p35; + } + public void setP35(String p35) { + this.p35 = p35; + } + public String getP36() { + return p36; + } + public void setP36(String p36) { + this.p36 = p36; + } + public String getP37() { + return p37; + } + public void setP37(String p37) { + this.p37 = p37; + } + public String getP38() { + return p38; + } + public void setP38(String p38) { + this.p38 = p38; + } + public String getP39() { + return p39; + } + public void setP39(String p39) { + this.p39 = p39; + } + public String getP40() { + return p40; + } + public void setP40(String p40) { + this.p40 = p40; + } + public String getP41() { + return p41; + } + public void setP41(String p41) { + this.p41 = p41; + } + public String getP42() { + return p42; + } + public void setP42(String p42) { + this.p42 = p42; + } + public String getP43() { + return p43; + } + public void setP43(String p43) { + this.p43 = p43; + } + public String getP44() { + return p44; + } + public void setP44(String p44) { + this.p44 = p44; + } + public String getP45() { + return p45; + } + public void setP45(String p45) { + this.p45 = p45; + } + public String getP46() { + return p46; + } + public void setP46(String p46) { + this.p46 = p46; + } + public String getP47() { + return p47; + } + public void setP47(String p47) { + this.p47 = p47; + } + public String getP48() { + return p48; + } + public void setP48(String p48) { + this.p48 = p48; + } + public String getP49() { + return p49; + } + public void setP49(String p49) { + this.p49 = p49; + } + public String getP50() { + return p50; + } + public void setP50(String p50) { + this.p50 = p50; + } + public String getP51() { + return p51; + } + public void setP51(String p51) { + this.p51 = p51; + } + public String getP52() { + return p52; + } + public void setP52(String p52) { + this.p52 = p52; + } + public String getP53() { + return p53; + } + public void setP53(String p53) { + this.p53 = p53; + } + public String getP54() { + return p54; + } + public void setP54(String p54) { + this.p54 = p54; + } + public String getP55() { + return p55; + } + public void setP55(String p55) { + this.p55 = p55; + } + public String getP56() { + return p56; + } + public void setP56(String p56) { + this.p56 = p56; + } + public String getP57() { + return p57; + } + public void setP57(String p57) { + this.p57 = p57; + } + public String getP58() { + return p58; + } + public void setP58(String p58) { + this.p58 = p58; + } + public String getP59() { + return p59; + } + public void setP59(String p59) { + this.p59 = p59; + } + public String getP60() { + return p60; + } + public void setP60(String p60) { + this.p60 = p60; + } + public String getP61() { + return p61; + } + public void setP61(String p61) { + this.p61 = p61; + } + public String getP62() { + return p62; + } + public void setP62(String p62) { + this.p62 = p62; + } + public String getP63() { + return p63; + } + public void setP63(String p63) { + this.p63 = p63; + } + public String getP64() { + return p64; + } + public void setP64(String p64) { + this.p64 = p64; + } + public String getP65() { + return p65; + } + public void setP65(String p65) { + this.p65 = p65; + } + public String getP66() { + return p66; + } + public void setP66(String p66) { + this.p66 = p66; + } + public String getP67() { + return p67; + } + public void setP67(String p67) { + this.p67 = p67; + } + public String getP68() { + return p68; + } + public void setP68(String p68) { + this.p68 = p68; + } + public String getP69() { + return p69; + } + public void setP69(String p69) { + this.p69 = p69; + } + public String getP70() { + return p70; + } + public void setP70(String p70) { + this.p70 = p70; + } + public String getP71() { + return p71; + } + public void setP71(String p71) { + this.p71 = p71; + } + public String getP72() { + return p72; + } + public void setP72(String p72) { + this.p72 = p72; + } + + +} diff --git a/src/com/connor/zf/controlplan/JDMethodUtil.java b/src/com/connor/zf/controlplan/JDMethodUtil.java new file mode 100644 index 0000000..6eae573 --- /dev/null +++ b/src/com/connor/zf/controlplan/JDMethodUtil.java @@ -0,0 +1,47 @@ +package com.connor.zf.controlplan; + +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; + +public class JDMethodUtil { + + public static TCPreferenceService service; + public static TCUserService userservice; + + /** + * + * + * @param prefName + * @return + */ + public static String getPrefStr(String prefName, TCSession session) { + if (service == null) { + service = session.getPreferenceService(); + } + String str = service.getString(TCPreferenceService.TC_preference_site, prefName); + if (str == null) { + str = new String(""); + } + return str; + } + + /** + * + * + * @param prefName + * @return + */ + public static String[] getPrefStrArray(String prefName, TCSession session) { + if (service == null) { + service = session.getPreferenceService(); + } + String[] strs = service.getStringArray(TCPreferenceService.TC_preference_site, prefName); + service.getStringValues(prefName); + service.getStringValue(prefName); + if (strs == null) { + strs = new String[] { "" }; + } + return strs; + } +} diff --git a/src/com/connor/zf/controlplan/JobProcessFormBean.java b/src/com/connor/zf/controlplan/JobProcessFormBean.java new file mode 100644 index 0000000..87cabcc --- /dev/null +++ b/src/com/connor/zf/controlplan/JobProcessFormBean.java @@ -0,0 +1,63 @@ +package com.connor.zf.controlplan; + +import java.util.List; + +public class JobProcessFormBean { + + private String gsmc; + private String ljdh; + private String sbxh; + private String bgx; + private String sbmc; + private List> toolingDetailData; + private List> machiningParameterData; + private List> controlRequirementData; + public String getGsmc() { + return gsmc; + } + public void setGsmc(String gsmc) { + this.gsmc = gsmc; + } + public String getLjdh() { + return ljdh; + } + public void setLjdh(String ljdh) { + this.ljdh = ljdh; + } + public String getSbxh() { + return sbxh; + } + public void setSbxh(String sbxh) { + this.sbxh = sbxh; + } + public String getBgx() { + return bgx; + } + public void setBgx(String bgx) { + this.bgx = bgx; + } + public String getSbmc() { + return sbmc; + } + public void setSbmc(String sbmc) { + this.sbmc = sbmc; + } + public List> getToolingDetailData() { + return toolingDetailData; + } + public void setToolingDetailData(List> toolingDetailData) { + this.toolingDetailData = toolingDetailData; + } + public List> getMachiningParameterData() { + return machiningParameterData; + } + public void setMachiningParameterData(List> machiningParameterData) { + this.machiningParameterData = machiningParameterData; + } + public List> getControlRequirementData() { + return controlRequirementData; + } + public void setControlRequirementData(List> controlRequirementData) { + this.controlRequirementData = controlRequirementData; + } +} diff --git a/src/com/connor/zf/controlplan/MultiComboBox.java b/src/com/connor/zf/controlplan/MultiComboBox.java new file mode 100644 index 0000000..9972e18 --- /dev/null +++ b/src/com/connor/zf/controlplan/MultiComboBox.java @@ -0,0 +1,218 @@ +package com.connor.zf.controlplan; +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(150,30)); +// editor.setBorder(getBorder()); + editor.addMouseListener(new EditorHandler()); + arrowButton = createArrowButton(); + arrowButton.addMouseListener(new EditorHandler()); + + add("1.1.left.top",editor); + //add(arrowButton); + setText() ; + + + } + + public Object[] getSelectedValues() { + return popup.getSelectedValues(); + } + + public void addActionListener(ActionListener listener) { + if (!listeners.contains(listener)) + listeners.add(listener); + } + + public void removeActionListener(ActionListener listener) { + if (listeners.contains(listener)) + listeners.remove(listener); + } + + protected void fireActionPerformed(ActionEvent e) { + for (ActionListener l : listeners) { + l.actionPerformed(e); + } + } + + private class PopupAction implements ActionListener{ + + public void actionPerformed(ActionEvent e) { + + if(e.getActionCommand().equals(MultiPopup.CANCEL_EVENT)){ + + }else if(e.getActionCommand().equals(MultiPopup.COMMIT_EVENT)){ + defaultValues = popup.getSelectedValues(); + setText(); + //把事件继续传递出去 + fireActionPerformed(e); + } + + togglePopup(); + + + } + + } + + private void togglePopup(){ + if(popup.isVisible()){ + popup.setVisible(false); + }else{ + popup.setDefaultValue(defaultValues); + popup.show(this, 0, getHeight()); + } + } + + private void setText() { + StringBuilder builder = new StringBuilder(); + for(Object dv : defaultValues){ + builder.append(dv); + builder.append(valueSperator); + } + + editor.setText(builder.substring(0, builder.length() > 0 ? builder.length() -1 : 0).toString()); + } + + private class EditorHandler implements MouseListener{ + + public void mouseClicked(MouseEvent e) { + togglePopup(); + } + + public void mousePressed(MouseEvent e) { + + } + + public void mouseReleased(MouseEvent e) { + + } + + public void mouseEntered(MouseEvent e) { + + } + + public void mouseExited(MouseEvent e) { + + } + + } + + + public void paintComponent(Graphics g){ + g.setColor(Color.white); + g.fillRect(0,0,getWidth(),getHeight()); + } + + + protected JButton createArrowButton() { + JButton button = new BasicArrowButton(BasicArrowButton.SOUTH, + UIManager.getColor("ComboBox.buttonBackground"), + UIManager.getColor("ComboBox.buttonShadow"), + UIManager.getColor("ComboBox.buttonDarkShadow"), + UIManager.getColor("ComboBox.buttonHighlight")); + button.setName("ComboBox.arrowButton"); + return button; + } + + private class MulitComboboxLayout implements LayoutManager{ + + public void addLayoutComponent(String name, Component comp) { + // TODO Auto-generated method stub + + } + + public void removeLayoutComponent(Component comp) { + // TODO Auto-generated method stub + + } + + public Dimension preferredLayoutSize(Container parent) { + return parent.getPreferredSize(); + } + + public Dimension minimumLayoutSize(Container parent) { + return parent.getMinimumSize(); + } + + public void layoutContainer(Container parent) { + int w=parent.getWidth(); + int h=parent.getHeight(); + Insets insets=parent.getInsets(); + h=h-insets.top-insets.bottom; + + } + + } + +} + + diff --git a/src/com/connor/zf/controlplan/MultiPopup.java b/src/com/connor/zf/controlplan/MultiPopup.java new file mode 100644 index 0000000..659761f --- /dev/null +++ b/src/com/connor/zf/controlplan/MultiPopup.java @@ -0,0 +1,190 @@ +package com.connor.zf.controlplan; +import java.awt.BorderLayout; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.util.ArrayList; +import java.util.List; + + + +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; + +public class MultiPopup extends JPopupMenu { + + private List listeners = new ArrayList(); + + private Object[] values; + + private Object[] defaultValues; + + private List checkBoxList = new ArrayList(); + + private JButton commitButton ; + + private JButton cancelButton; + + public static final String COMMIT_EVENT = "commit"; + + public static final String CANCEL_EVENT = "cancel"; + + public MultiPopup(Object[] value , Object[] defaultValue) { + super(); + values = value; + defaultValues = defaultValue; + initComponent(); + } + + public void addActionListener(ActionListener listener) { + if (!listeners.contains(listener)) + listeners.add(listener); + } + + public void removeActionListener(ActionListener listener) { + if (listeners.contains(listener)) + listeners.remove(listener); + } + + private void initComponent() { + + JPanel checkboxPane = new JPanel(); + + JPanel buttonPane = new JPanel(); + + this.setLayout(new BorderLayout()); + + + for(Object v : values){ + JCheckBox temp = new JCheckBox(v.toString() , selected(v)); + checkBoxList.add(temp); + } + + if(checkBoxList.get(0).getText().equals("Selected All")) + checkBoxList.get(0).addItemListener(new ItemListener() + { + public void itemStateChanged(ItemEvent e) + { + System.out.println("被选中状态 "+checkBoxList.get(0).isSelected()); + if(checkBoxList.get(0).isSelected())//Select All 被选中 + { + //检查其他的是否被选中乳沟没有就选中他们 + for(int i=1; i< checkBoxList.size();i++) + { + if(!checkBoxList.get(i).isSelected()) + checkBoxList.get(i).setSelected(true); + } + } + else + { + for(int i=1; i< checkBoxList.size();i++) + { + if(checkBoxList.get(i).isSelected()) + checkBoxList.get(i).setSelected(false); + } + } + } + }); + + + + checkboxPane.setLayout(new GridLayout(checkBoxList.size() , 1 ,3, 3)); + for(JCheckBox box : checkBoxList){ + checkboxPane.add(box); + } + + commitButton = new JButton("ok"); + + commitButton.addActionListener(new ActionListener(){ + + public void actionPerformed(ActionEvent e) { + commit(); + } + + }); + + cancelButton = new JButton("cancel"); + + cancelButton.addActionListener(new ActionListener(){ + + public void actionPerformed(ActionEvent e) { + cancel(); + } + + }); + + buttonPane.add(commitButton); + + buttonPane.add(cancelButton); + + this.add(checkboxPane , BorderLayout.CENTER); + + this.add(buttonPane , BorderLayout.SOUTH); + + + } + + private boolean selected(Object v) { + for(Object dv : defaultValues){ + if( dv .equals(v) ){ + return true; + } + } + return false; + } + + protected void fireActionPerformed(ActionEvent e) { + for (ActionListener l : listeners) { + l.actionPerformed(e); + } + } + + public Object[] getSelectedValues(){ + List selectedValues = new ArrayList(); + + if(checkBoxList.get(0).getText().equals("Selected All")) + { + if(checkBoxList.get(0).isSelected()) + { + for(int i = 1 ; i < checkBoxList.size() ; i++) + { + selectedValues.add(values[i]); + } + } + else + { + for(int i = 1 ; i < checkBoxList.size() ; i++){ + + if(checkBoxList.get(i).isSelected()) + selectedValues.add(values[i]); + } + } + }else + for(int i = 0 ; i < checkBoxList.size() ; i++){ + + if(checkBoxList.get(i).isSelected()) + selectedValues.add(values[i]); + } + + + return selectedValues.toArray(new Object[selectedValues.size()]); + } + + public void setDefaultValue(Object[] defaultValue) { + defaultValues = defaultValue; + + } + + public void commit(){ + fireActionPerformed(new ActionEvent(this, 0, COMMIT_EVENT)); + } + + public void cancel(){ + fireActionPerformed(new ActionEvent(this, 0, CANCEL_EVENT)); + } + +} diff --git a/src/com/connor/zf/controlplan/MyTableModel.java b/src/com/connor/zf/controlplan/MyTableModel.java new file mode 100644 index 0000000..1a28c6b --- /dev/null +++ b/src/com/connor/zf/controlplan/MyTableModel.java @@ -0,0 +1,48 @@ +package com.connor.zf.controlplan; + +import java.util.Vector; + +import javax.swing.table.DefaultTableModel; + +/** + * 自定义JTable + * + * @author Administrator + * + */ +public class MyTableModel extends DefaultTableModel { + + public MyTableModel(Object[][] values, Object[] titleNames) { + super(values, titleNames); + } + + public MyTableModel(Vector values, Vector titleNames) { + super(values, titleNames); + } + + + // 重写getColumnClass方法,根据每列的第一个值返回该列真实的数据类型 + @Override + public Class getColumnClass(int columnIndex) { + + Object ob = getValueAt(0, columnIndex); + if (ob == null) { + String bb = ""; + return bb.getClass(); + } else { + return getValueAt(0, columnIndex).getClass(); + } + } + + @Override + public Object getValueAt(int i, int j) { + // TODO Auto-generated method stub + Vector rowValue = (Vector) this.dataVector.get(i); + return rowValue.get(j); + } + + public boolean isCellEditable(int rowIndex, int columnIndex) { + return false; + } + +} diff --git a/src/com/connor/zf/controlplan/ProcessBean.java b/src/com/connor/zf/controlplan/ProcessBean.java new file mode 100644 index 0000000..176d42e --- /dev/null +++ b/src/com/connor/zf/controlplan/ProcessBean.java @@ -0,0 +1,222 @@ +package com.connor.zf.controlplan; + +public class ProcessBean { + private String processPuid;//工艺的PUID + private String meopId;//工序的ItemID + private String gybh;//工艺编号 + private String gcmc;//过程名称 + private String jqsb;//机器,设备,工装,夹具 + private String smjy;//首末检验 + private String qptbh;//气泡图编号 + private String cc;//尺寸 + private String no;//序号 + private String cp;//产品 + private String gc;//过程 + private String tstx;//特殊特性 + private String cpgc;//产品/过程/规格/公差 + private String pgclff;//评估测量方法 + private String rl;//容量 + private String pl;//频率 + private String sjsj;//首件缩减 + private String gcsj;//过程缩减 + private String mjsj;//末件缩减 + private String fzr;//负责人 + private String kzff;//控制方法 + private String czgf;//操作规范 + private String fyjh;//反应计划 + private String hh;//行号 + private String hbdyg;//合并单元格 + private String sfwc;//是否完成 + private String hhc;//行号差 + private String special;//特殊字符 + private String type;//类型s + private String revisionuid;//控制计划uid,用来区别版本 + private String NO;//查找编号 + + public String getGybh() { + return gybh; + } + public void setGybh(String gybh) { + this.gybh = gybh; + } + public String getRevisionuid() { + return revisionuid; + } + public void setRevisionuid(String revisionuid) { + this.revisionuid = revisionuid; + } + public String getGcmc() { + return gcmc; + } + public void setGcmc(String gcmc) { + this.gcmc = gcmc; + } + public String getJqsb() { + return jqsb; + } + public void setJqsb(String jqsb) { + this.jqsb = jqsb; + } + public String getQptbh() { + return qptbh; + } + public void setQptbh(String qptbh) { + this.qptbh = qptbh; + } + public String getCc() { + return cc; + } + public void setCc(String cc) { + this.cc = cc; + } + public String getCp() { + return cp; + } + public void setCp(String cp) { + this.cp = cp; + } + public String getGc() { + return gc; + } + public void setGc(String gc) { + this.gc = gc; + } + public String getTstx() { + return tstx; + } + public void setTstx(String tstx) { + this.tstx = tstx; + } + public String getCpgc() { + return cpgc; + } + public void setCpgc(String cpgc) { + this.cpgc = cpgc; + } + public String getPgclff() { + return pgclff; + } + public void setPgclff(String pgclff) { + this.pgclff = pgclff; + } + public String getRl() { + return rl; + } + public void setRl(String rl) { + this.rl = rl; + } + public String getPl() { + return pl; + } + public void setPl(String pl) { + this.pl = pl; + } + public String getFzr() { + return fzr; + } + public void setFzr(String fzr) { + this.fzr = fzr; + } + public String getKzff() { + return kzff; + } + public void setKzff(String kzff) { + this.kzff = kzff; + } + public String getCzgf() { + return czgf; + } + public void setCzgf(String czgf) { + this.czgf = czgf; + } + public String getFyjh() { + return fyjh; + } + public void setFyjh(String fyjh) { + this.fyjh = fyjh; + } + public String getProcessPuid() { + return processPuid; + } + public void setProcessPuid(String processPuid) { + this.processPuid = processPuid; + } + public String getMeopId() { + return meopId; + } + public void setMeopId(String meopId) { + this.meopId = meopId; + } + public String getSmjy() { + return smjy; + } + public void setSmjy(String smjy) { + this.smjy = smjy; + } + public String getSjsj() { + return sjsj; + } + public void setSjsj(String sjsj) { + this.sjsj = sjsj; + } + public String getGcsj() { + return gcsj; + } + public void setGcsj(String gcsj) { + this.gcsj = gcsj; + } + public String getMjsj() { + return mjsj; + } + public void setMjsj(String mjsj) { + this.mjsj = mjsj; + } + public String getHh() { + return hh; + } + public void setHh(String hh) { + this.hh = hh; + } + public String getHbdyg() { + return hbdyg; + } + public void setHbdyg(String hbdyg) { + this.hbdyg = hbdyg; + } + public String getSfwc() { + return sfwc; + } + public void setSfwc(String sfwc) { + this.sfwc = sfwc; + } + public String getHhc() { + return hhc; + } + public void setHhc(String hhc) { + this.hhc = hhc; + } + public String getSpecial() { + return special; + } + public void setSpecial(String special) { + this.special = special; + } + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + public String getNo() { + return no; + } + public void setNo(String no) { + this.no = no; + } + public String getNO() { + return NO; + } + public void setNO(String NO) { + this.NO = NO; + } +} diff --git a/src/com/connor/zf/controlplan/SaveControlPlan.java b/src/com/connor/zf/controlplan/SaveControlPlan.java new file mode 100644 index 0000000..f7daf28 --- /dev/null +++ b/src/com/connor/zf/controlplan/SaveControlPlan.java @@ -0,0 +1,516 @@ +package com.connor.zf.controlplan; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Properties; +import java.util.UUID; + +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +/** + * 保存数据到控制计划表 + * @author Administrator + * + */ +public class SaveControlPlan { + private TCSession session; + private TCComponentItem item; + private InterfaceAIFComponent comp; + private List> properties = new ArrayList>(); + private List> dataList = new ArrayList>();// 表格中的数据 + + public SaveControlPlan(TCSession session,TCComponentItem item,InterfaceAIFComponent comp) { + // TODO Auto-generated constructor stub + this.session = session; + this.item = item; + this.comp=comp; + } + /** + * 获取没有检验项的工序 + * @param name 首选项名称 + * @return 没有检验项的工序名称 + */ + private List getMeopNames(String name) { + // TODO Auto-generated method stub + String[] values = null; + if(name != null) + { + TCPreferenceService service = this.session.getPreferenceService(); + String[] props = service.getStringArray(TCPreferenceService.TC_preference_site, name); + if(props != null || props.length>0) + { + values = props; + } + } + else + { + MessageBox.post("未找首选项!", "错误!", MessageBox.ERROR); + } + return Arrays.asList(values); + } + public void insertData() { + // TODO Auto-generated method stub + ResultSet rs = null; + ResultSet result = null; + ResultSet resultSet = null; + InputStream input = null; + try { + properties = TMomMethodUtil.getBomPropertys(session, item); + //properties.clear(); + List meopNameList = getMeopNames("RB3_CONCEAL_MEOP_NAME"); + String itemUid = item.getUid(); + //获取工艺下的控制计划对象 + TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); + List kzjhList = new ArrayList(); + for (int i = 0; i < kzjh.length; i++) { + if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) + { + kzjhList.add((TCComponentItem)kzjh[i]); + } + } + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + if(kzjhList.size() == 0) + { + // 查询数据库中的数据 + SqlUtilT.getTCConnection(); + String sql = String.format(pro.getProperty("BOMCHECKSAVESELECT"), + itemUid, "检验(%",comp.getUid()); + rs = SqlUtilT.read(sql); + while (rs.next()) { + List rowList = new ArrayList(); + rowList.add(rs.getString("RB3_MEOPID") == null ? "" : rs.getString("RB3_MEOPID")); + //rowList.add(rs.getString("RB3_MEOPID")); + rowList.add(rs.getString("RB3_GYBH")); + rowList.add(rs.getString("RB3_GCMC")); + rowList.add(rs.getString("RB3_JQSB") == null ? "" : rs.getString("RB3_JQSB")); + dataList.add(rowList); + } + if (dataList == null || dataList.size() == 0) { + for (int j = 0; j < properties.size(); j++) { + UUID kzjhUid = UUID.randomUUID(); +// UUID ssckzjhUid = UUID.randomUUID(); +// UUID yjkzjhUid = UUID.randomUUID(); + // 将数据插入到控制计划 + SqlUtilT.getTCConnection(); + String insertSQL = pro.getProperty("INSERTSQL"); +// Integer number = Integer.parseInt(properties.get(j).get(1) +// .toString()) % 10 == 0 ? Integer +// .parseInt(properties.get(j).get(1).toString()) + 5 +// : Integer.parseInt(properties.get(j).get(1) +// .toString()) + 1; + String name = "检验(" + properties.get(j).get(2).toString()+ ")"; + if(properties.get(j).get(2).toString().indexOf("/") >=0 && properties.get(j).get(2).toString().split("/").length == 2 ) + { + name = "检验(" + properties.get(j).get(2).toString().split("/")[0] + ")\n" + + "inspect("+properties.get(j).get(2).toString().split("/")[1]+")"; + } + //首末检验 + String smjy = ""; + if(properties.get(j).get(2).indexOf("检验") >= 0) + { + smjy = "巡检检验\nPatrol inspection"; + } + // 插入生产控制计划工序 + SqlUtilT.getTCConnection(); + SqlUtilT.write( + new String[] { + kzjhUid.toString().replace("-", ""), + itemUid, properties.get(j).get(0), + properties.get(j).get(1), + properties.get(j).get(2).indexOf("/") >=0 ? properties.get(j).get(2).replace("/", "\n") : properties.get(j).get(2), + properties.get(j).get(3), smjy, "1", "", "", + "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "RB3_YJKZJH","1","0","","0",comp.getUid(),properties.get(j).get(4) }, + insertSQL); + if(meopNameList.contains(properties.get(j).get(2).toString())) + { + // 插入生产控制计划巡检项 + SqlUtilT.getTCConnection(); + SqlUtilT.write( + new String[] { + UUID.randomUUID().toString() + .replace("-", ""), itemUid, + properties.get(j).get(0), + properties.get(j).get(1).toString(), name, + "", "巡检检验\nPatrol inspection", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "RB3_YJKZJH","1","0","","0",comp.getUid(), properties.get(j).get(4) }, + insertSQL); + } + } + } else { + // 修改表中相应的工序名称 + for (int i = 0; i < dataList.size(); i++) { + for (int j = 0; j < properties.size(); j++) { + if (dataList.get(i).get(0) + .equals(properties.get(j).get(0)) + && (!dataList.get(i).get(1) + .equals(properties.get(j).get(1)) + || !dataList + .get(i) + .get(2) + .equals(properties.get(j) + .get(2)) || !dataList + .get(i).get(3) + .equals(properties.get(j).get(3)))) { +// Integer number = Integer.parseInt(properties.get(j) +// .get(1).toString()) % 10 == 0 ? Integer +// .parseInt(properties.get(j).get(1) +// .toString()) + 5 : Integer +// .parseInt(properties.get(j).get(1) +// .toString()) + 1; + String name = "检验(" + + properties.get(j).get(2).toString() + ")"; + if(properties.get(j).get(2).toString().indexOf("/") >=0 && properties.get(j).get(2).toString().split("/").length == 2 ) + { + name = "检验(" + properties.get(j).get(2).toString().split("/")[0] + ")\n" + + "inspect("+properties.get(j).get(2).toString().split("/")[1]+")"; + } + // 获取数据库连接 + // 更新自检 + SqlUtilT.getTCConnection(); + String updateSQL = String.format( + pro.getProperty("BOMCHECKSAVEUPDATE"), + itemUid, dataList.get(i).get(0), "检验(%"); + // 更新巡检 + String updateSQL1 = String.format( + pro.getProperty("BOMCHECKSAVEUPDATE2"), + itemUid, dataList.get(i).get(0), "检验(%"); + SqlUtilT.update(new String[] { + properties.get(j).get(1), + properties.get(j).get(2).indexOf("/") >=0 ? properties.get(j).get(2).replace("/", "\n") : properties.get(j).get(2), + properties.get(j).get(3) }, updateSQL); + SqlUtilT.update(new String[] { properties.get(j).get(1).toString(), + name, + ""}, updateSQL1); + } + // if(dataList.get(i).get(1).equals(properties[j][1].getStringValue()) + // && !dataList.get(i).get(0).equals(properties[j][0])) + // { + // //获取数据库连接 + // String updateSQL = + // String.format("update CONTROLPLAN set RB3_GYBH = ? where PROCESSPUID = \'%s\' and RB3_GCMC = \'%s\'",itemUid,dataList.get(i).get(1)) + // ; + // SqlUtilT.update(new String[]{ + // properties[j][0].getStringValue() },updateSQL); + // } + } + } + // 添加工序 + // 查询数据库中的数据 + result = SqlUtilT.read(sql); + List indexList = new ArrayList(); + while (result.next()) { + indexList.add(result.getString("RB3_MEOPID")); + } + for (int i = 0; i < properties.size(); i++) { + if (!indexList.contains(properties.get(i).get(0))) { + UUID kzjhUid = UUID.randomUUID(); + // 将数据插入到表中 + SqlUtilT.getTCConnection(); + String insertSQL = pro.getProperty("INSERTSQL"); +// Integer number = Integer.parseInt(properties.get(i) +// .get(1).toString()) % 10 == 0 ? Integer +// .parseInt(properties.get(i).get(1).toString()) + 5 +// : Integer.parseInt(properties.get(i).get(1) +// .toString()) + 1; + String name = "检验(" + + properties.get(i).get(2).toString() + ")"; + if(properties.get(i).get(2).toString().indexOf("/") >=0 && properties.get(i).get(2).toString().split("/").length == 2 ) + { + name = "检验(" + properties.get(i).get(2).toString().split("/")[0] + ")\n" + + "inspect("+properties.get(i).get(2).toString().split("/")[1]+")"; + } + + //首末检验 + String smjy = ""; + if(properties.get(i).get(2).indexOf("检验") >= 0) + { + smjy = "巡检检验\nPatrol inspection"; + } + + // 插入控制计划工序 + SqlUtilT.getTCConnection(); + SqlUtilT.write(new String[] { + kzjhUid.toString().replace("-", ""), itemUid, + properties.get(i).get(0), + properties.get(i).get(1), + properties.get(i).get(2).indexOf("/") >=0 ? properties.get(i).get(2).replace("/", "\n") : properties.get(i).get(2), + properties.get(i).get(3), smjy, "1", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "RB3_YJKZJH","1","0","","0",comp.getUid(),properties.get(i).get(4) },insertSQL); + if(meopNameList.contains(properties.get(i).get(2).toString())) + { + // 插入控制计划巡检项 + SqlUtilT.getTCConnection(); + SqlUtilT.write( + new String[] { + UUID.randomUUID().toString() + .replace("-", ""), itemUid, + properties.get(i).get(0), + properties.get(i).get(1).toString(), name, + "", "巡检检验\nPatrol inspection", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", + "RB3_YJKZJH","1","0","","0" ,comp.getUid(),properties.get(i).get(4) },insertSQL); + } + } + } + // 删除表中相应的工序 + StringBuffer sb = new StringBuffer(); + sb.append("("); + for (int i = 0; i < properties.size(); i++) { + sb.append("\'" + properties.get(i).get(0) + "\',"); + } + // 获取数据库连接 + SqlUtilT.getTCConnection(); + String selectSql = String + .format(pro.getProperty("BOMCHECKSAVESELECT2"), + itemUid, + sb.toString().substring(0, sb.length() - 1) + + ")"); + resultSet = SqlUtilT.read(selectSql); + List deleteList = new ArrayList(); + while (resultSet.next()) { + deleteList.add(resultSet.getString("RB3_MEOPID")); + } + if (deleteList != null && deleteList.size() > 0) { + for (int i = 0; i < deleteList.size(); i++) { + SqlUtilT.getTCConnection(); + String deleteSQL = String.format( + pro.getProperty("DELETE"), deleteList.get(i), + itemUid); + SqlUtilT.delete(deleteSQL); + } + } + } + } + else + { + for (int i1 = 0; i1 < kzjhList.size(); i1++) { + // 查询数据库中的数据 + SqlUtilT.getTCConnection(); + String sql = String.format(pro.getProperty("BOMCHECKSAVESELECT"), + itemUid, "检验(%",comp.getUid()); + rs = SqlUtilT.read(sql); + System.out.println("====>"+sql); + while (rs.next()) { + List rowList = new ArrayList(); + rowList.add(rs.getString("RB3_MEOPID") == null ? "" : rs.getString("RB3_MEOPID")); + //rowList.add(rs.getString("RB3_MEOPID")); + rowList.add(rs.getString("RB3_GYBH")); + rowList.add(rs.getString("RB3_GCMC")); + rowList.add(rs.getString("RB3_JQSB") == null ? "" : rs.getString("RB3_JQSB")); + dataList.add(rowList); + } + if (dataList == null || dataList.size() == 0) { + for (int j = 0; j < properties.size(); j++) { + UUID kzjhUid = UUID.randomUUID(); +// UUID ssckzjhUid = UUID.randomUUID(); +// UUID yjkzjhUid = UUID.randomUUID(); + // 将数据插入到控制计划 + SqlUtilT.getTCConnection(); + String insertSQL = pro.getProperty("INSERTSQL"); + + String smjy = ""; + // 插入控制计划工序 + SqlUtilT.getTCConnection(); + SqlUtilT.write( + new String[] { + kzjhUid.toString().replace("-", ""), + itemUid, properties.get(j).get(0), + properties.get(j).get(1), + properties.get(j).get(2).indexOf("/") >=0 ? properties.get(j).get(2).replace("/", "\n") : properties.get(j).get(2), + properties.get(j).get(3), smjy, "1", "", "", + "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", kzjhList.get(i1).getType().toUpperCase(),"","","","",comp.getUid(),properties.get(j).get(4) }, + insertSQL); + + } + } else { + // 修改表中相应的工序属性 + for (int i = 0; i < dataList.size(); i++) { + for (int j = 0; j < properties.size(); j++) { + if (dataList.get(i).get(0).equals(properties.get(j).get(0))&& + (!dataList.get(i).get(1).equals(properties.get(j).get(1)) + || !dataList.get(i).get(2).equals(properties.get(j).get(2)) + || !dataList.get(i).get(3).equals(properties.get(j).get(3)))) { + String name = "检验(" + + properties.get(j).get(2).toString() + ")"; + String s = properties.get(j).get(2).toString(); + if(properties.get(j).get(2).toString().indexOf("/") >=0 && properties.get(j).get(2).toString().split("/").length == 2 ) + { + name = "检验(" + properties.get(j).get(2).toString().split("/")[0] + ")\n" + + "inspect("+properties.get(j).get(2).toString().split("/")[1]+")"; + } + // 获取数据库连接 + // 更新自检 + SqlUtilT.getTCConnection(); + String updateSQL = String.format( + pro.getProperty("BOMCHECKSAVEUPDATE"), + itemUid, dataList.get(i).get(0), "检验(%"); + // 更新巡检 + SqlUtilT.getTCConnection(); + String updateSQL1 = String.format( + pro.getProperty("BOMCHECKSAVEUPDATE2"), + itemUid, dataList.get(i).get(0), "检验(%"); + SqlUtilT.update(new String[] { + properties.get(j).get(1), + properties.get(j).get(2).indexOf("/") >=0 ? properties.get(j).get(2).replace("/", "\n") : properties.get(j).get(2), + (dataList.get(i).get(3).equals("")?properties.get(j).get(3):dataList.get(i).get(3).toString())}, + updateSQL);//机器设备只有在为空的时候才更新 + //System.out.println(updateSQL); + SqlUtilT.update(new String[] { properties.get(j).get(1).toString(), + name, + ""}, updateSQL1); + } + // if(dataList.get(i).get(1).equals(properties[j][1].getStringValue()) + // && !dataList.get(i).get(0).equals(properties[j][0])) + // { + // //获取数据库连接 + // String updateSQL = + // String.format("update CONTROLPLAN set RB3_GYBH = ? where PROCESSPUID = \'%s\' and RB3_GCMC = \'%s\'",itemUid,dataList.get(i).get(1)) + // ; + // SqlUtilT.update(new String[]{ + // properties[j][0].getStringValue() },updateSQL); + // } + } + } + // 添加工序 + // 查询数据库中的数据 + result = SqlUtilT.read(sql); + List indexList = new ArrayList(); + while (result.next()) { + indexList.add(result.getString("RB3_MEOPID")); + } + for (int i = 0; i < properties.size(); i++) { + if (!indexList.contains(properties.get(i).get(0))) { + UUID kzjhUid = UUID.randomUUID(); + // 将数据插入到表中 + String insertSQL = pro.getProperty("INSERTSQL"); +// Integer number = Integer.parseInt(properties.get(i) +// .get(1).toString()) % 10 == 0 ? Integer +// .parseInt(properties.get(i).get(1).toString()) + 5 +// : Integer.parseInt(properties.get(i).get(1) +// .toString()) + 1; + String name = "检验(" + + properties.get(i).get(2).toString() + ")"; + if(properties.get(i).get(2).toString().indexOf("/") >=0 && properties.get(i).get(2).toString().split("/").length == 2 ) + { + name = "检验(" + properties.get(i).get(2).toString().split("/")[0] + ")\n" + + "inspect("+properties.get(i).get(2).toString().split("/")[1]+")"; + } + + + //首末检验 + String smjy = ""; + if(properties.get(i).get(2).indexOf("检验") >= 0) + { + smjy = "巡检检验\nPatrol inspection"; + } + + // 插入控制计划工序 + SqlUtilT.getTCConnection(); + SqlUtilT.write(new String[] { + kzjhUid.toString().replace("-", ""), itemUid, + properties.get(i).get(0), + properties.get(i).get(1), + properties.get(i).get(2).indexOf("/") >=0 ? properties.get(i).get(2).replace("/", "\n") : properties.get(i).get(2), + properties.get(i).get(3), smjy, "1", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", kzjhList.get(i1).getType().toUpperCase(),"1","0","","0" ,comp.getUid(),properties.get(i).get(4) },insertSQL); + if(meopNameList.contains(properties.get(i).get(2).toString())) + { + // 插入控制计划巡检项 + SqlUtilT.getTCConnection(); + SqlUtilT.write( + new String[] { + UUID.randomUUID().toString() + .replace("-", ""), itemUid, + properties.get(i).get(0), + properties.get(i).get(1).toString(), name, + "", "巡检检验\nPatrol inspection", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", + kzjhList.get(i1).getType().toUpperCase(),"1","0","","0",comp.getUid(),properties.get(i).get(4) },insertSQL); + } + } + } + // 删除表中相应的工序 + StringBuffer sb = new StringBuffer(); + sb.append("("); + if(properties.size()>0) { + for (int i = 0; i < properties.size(); i++) { + sb.append("\'" + properties.get(i).get(0) + "\',"); + } + }else { + sb.append("\'" +"0"+ "\',");//如果没一个工序类,就直接全清空 + } + + // 获取数据库连接 + SqlUtilT.getTCConnection(); + String selectSql = String + .format(pro.getProperty("BOMCHECKSAVESELECT2"), + itemUid, + sb.toString().substring(0, sb.length() - 1) + + ")"); + resultSet = SqlUtilT.read(selectSql); + System.out.println(selectSql); + List deleteList = new ArrayList(); + while (resultSet.next()) { + if(!deleteList.contains(resultSet.getString("RB3_MEOPID"))) { + deleteList.add(resultSet.getString("RB3_MEOPID")); + } + } + if (deleteList != null && deleteList.size() > 0) { + for (int i = 0; i < deleteList.size(); i++) { + SqlUtilT.getTCConnection(); + String deleteSQL = String.format( + pro.getProperty("DELETE"), deleteList.get(i), + itemUid); + System.out.println(deleteSQL); + SqlUtilT.delete(deleteSQL); + } + } + } + } + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (result != null) { + SqlUtilT.free(result); + } + if (resultSet != null) { + SqlUtilT.free(resultSet); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } +} diff --git a/src/com/connor/zf/controlplan/SoaServerUtil.java b/src/com/connor/zf/controlplan/SoaServerUtil.java new file mode 100644 index 0000000..69cb34c --- /dev/null +++ b/src/com/connor/zf/controlplan/SoaServerUtil.java @@ -0,0 +1,343 @@ +//package com.connor.zf.controlplan; +// +//import java.util.List; +// +//import org.apache.axiom.om.OMAbstractFactory; +//import org.apache.axiom.om.OMElement; +//import org.apache.axiom.om.OMFactory; +//import org.apache.axiom.om.OMNamespace; +//import org.apache.axis2.AxisFault; +//import org.apache.axis2.addressing.EndpointReference; +//import org.apache.axis2.client.Options; +//import org.apache.axis2.client.ServiceClient; +//import org.apache.axis2.transport.http.HTTPConstants; +// +//import com.teamcenter.rac.aif.AbstractAIFApplication; +//import com.teamcenter.rac.aifrcp.AIFUtility; +//import com.teamcenter.rac.kernel.TCAccessControlService; +//import com.teamcenter.rac.kernel.TCComponent; +//import com.teamcenter.rac.kernel.TCComponentItem; +//import com.teamcenter.rac.kernel.TCComponentItemRevision; +//import com.teamcenter.rac.kernel.TCComponentUser; +//import com.teamcenter.rac.kernel.TCComponentUserType; +//import com.teamcenter.rac.kernel.TCException; +//import com.teamcenter.rac.kernel.TCPreferenceService; +//import com.teamcenter.rac.kernel.TCSession; +//import com.teamcenter.rac.kernel.TCUserService; +// +//import net.sf.json.JSONArray; +// +///** +// * 发送分类Util类 +// * @author 61666 +// * +// */ +//public class SoaServerUtil { +// +// public static void sendToClass(String wsoPUID, String classID, String json, String url) { +// // AbstractAIFApplication app; +// // app=AIFUtility.getCurrentApplication(); +// // TCSession session; +// // session=(TCSession) app.getSession(); +// // TCPreferenceService preferenceService; +// // preferenceService=session.getPreferenceService(); +// // String account=preferenceService.getStringValue("Autocode_PriverUser_ID"); +// // String url; +// // url = preferenceService.getStringValue("Autocode_SendClassServer_URL"); +// try { +// ServiceClient sc = new ServiceClient(); +// Options opts = new Options(); +// // url = "http://10.201.5.203:19090/ErpWebService.asmx?WSDL"; +// EndpointReference end = new EndpointReference(url); +// opts.setTo(end); +// opts.setAction("SendToClass"); +// sc.setOptions(opts); +// +// OMFactory fac = OMAbstractFactory.getOMFactory(); +// OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", ""); +// OMElement method = fac.createOMElement("SendToClass", omNs); +// OMElement value = fac.createOMElement("wsoPuiid", omNs); +// value.setText(wsoPUID); +// OMElement value1 = fac.createOMElement("classID", omNs); +// value1.setText(classID); +// OMElement value2 = fac.createOMElement("JsonContainer", omNs); +// // "[{\"value\":\"1\",\"propertyID\":-500003},{\"value\":\"1\",\"propertyID\":-500011}]" +// value2.setText(json); +// +// method.addChild(value); +// method.addChild(value1); +// method.addChild(value2); +// +// OMElement res = sc.sendReceive(method); +// res.getFirstElement().getText(); +// System.out.println(res.getFirstElement().getText()); +// } catch (AxisFault e) { +// e.printStackTrace(); +// } +// +// } +// +// public static String updateToClass(String wsoPUID, String classID, String json, String url, String icoUid) { +// // AbstractAIFApplication app; +// // app=AIFUtility.getCurrentApplication(); +// // TCSession session; +// // session=(TCSession) app.getSession(); +// // TCPreferenceService preferenceService; +// // preferenceService=session.getPreferenceService(); +// // String account=preferenceService.getStringValue("Autocode_PriverUser_ID"); +// // String url; +// // url = preferenceService.getStringValue("Autocode_SendClassServer_URL"); +// String reMsgString=""; +// try { +// ServiceClient sc = new ServiceClient(); +// Options opts = new Options(); +// // url = "http://10.201.5.203:19090/ErpWebService.asmx?WSDL"; +// EndpointReference end = new EndpointReference(url); +// opts.setTo(end); +// opts.setAction("UpdateToClass"); +// sc.setOptions(opts); +// +// OMFactory fac = OMAbstractFactory.getOMFactory(); +// OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", ""); +// OMElement method = fac.createOMElement("UpdateToClass", omNs); +// OMElement value = fac.createOMElement("wsoPuiid", omNs); +// value.setText(wsoPUID); +// OMElement value1 = fac.createOMElement("classID", omNs); +// value1.setText(classID); +// OMElement value2 = fac.createOMElement("JsonContainer", omNs); +// +// OMElement value3 = fac.createOMElement("icoPUID", omNs); +// // "[{\"value\":\"1\",\"propertyID\":-500003},{\"value\":\"1\",\"propertyID\":-500011}]" +// value2.setText(json); +// value3.setText(icoUid); +// +// method.addChild(value); +// method.addChild(value1); +// method.addChild(value2); +// method.addChild(value3); +// OMElement res = sc.sendReceive(method); +// reMsgString=res.getFirstElement().getText(); +// System.out.println(res.getFirstElement().getText()); +// +// } catch (AxisFault e) { +// e.printStackTrace(); +// } +// +// return reMsgString; +// +// } +// public static void deleteAndSendToClass(String icoPUID,String wsoPUID, String classID, String json, String url) { +// // AbstractAIFApplication app; +// // app=AIFUtility.getCurrentApplication(); +// // TCSession session; +// // session=(TCSession) app.getSession(); +// // TCPreferenceService preferenceService; +// // preferenceService=session.getPreferenceService(); +// // String account=preferenceService.getStringValue("Autocode_PriverUser_ID"); +// // String url; +// // url = preferenceService.getStringValue("Autocode_SendClassServer_URL"); +// try { +// ServiceClient sc = new ServiceClient(); +// Options opts = new Options(); +// // url = "http://10.201.5.203:19090/ErpWebService.asmx?WSDL"; +// EndpointReference end = new EndpointReference(url); +// opts.setTo(end); +// opts.setAction("SendToClass"); +// sc.setOptions(opts); +// +// OMFactory fac = OMAbstractFactory.getOMFactory(); +// OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", ""); +// OMElement method = fac.createOMElement("editToClass", omNs); +// OMElement icovalue = fac.createOMElement("icoPUID", omNs); +// icovalue.setText(icoPUID); +// OMElement value = fac.createOMElement("wsoPuiid", omNs); +// value.setText(wsoPUID); +// OMElement value1 = fac.createOMElement("classID", omNs); +// value1.setText(classID); +// OMElement value2 = fac.createOMElement("JsonContainer", omNs); +// // "[{\"value\":\"1\",\"propertyID\":-500003},{\"value\":\"1\",\"propertyID\":-500011}]" +// value2.setText(json); +// method.addChild(icovalue); +// method.addChild(value); +// method.addChild(value1); +// method.addChild(value2); +// +// OMElement res = sc.sendReceive(method); +// res.getFirstElement().getText(); +// System.out.println(res.getFirstElement().getText()); +// } catch (AxisFault e) { +// e.printStackTrace(); +// } +// +// } +// // public static void main(String[] args) { +// // deleteClass("1111", ""); +// // } +// // 分类库中删除临时物料 +// public static void deleteClass(String icoPUID, String url) { +// try { +// ServiceClient sc = new ServiceClient(); +// Options opts = new Options(); +// // url = "http://10.201.5.203:19090/ErpWebService.asmx?WSDL";//TODO +// // 首选项Autocode_SendClassServer_URL +// // url = preferenceService.getStringValue("Autocode_SendClassServer_URL");//TODO +// // 首选项Autocode_SendClassServer_URL +// EndpointReference end = new EndpointReference(url); +// opts.setTo(end); +// opts.setAction("DeleteClass"); +// opts.setProperty(HTTPConstants.CHUNKED, "false"); +// sc.setOptions(opts); +// +// OMFactory fac = OMAbstractFactory.getOMFactory(); +// OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", ""); +// OMElement method = fac.createOMElement("DeleteClass", omNs); +// OMElement value = fac.createOMElement("icoPuid", omNs); +// value.setText(icoPUID); +// // OMElement value1 = fac.createOMElement("classID", omNs); +// //// value1.setText(classID); +// // OMElement value2 = fac.createOMElement("JsonContainer", omNs); +// // "[{\"value\":\"1\",\"propertyID\":-500003},{\"value\":\"1\",\"propertyID\":-500011}]" +// // value2.setText(json); +// +// method.addChild(value); +// // method.addChild(value1); +// // method.addChild(value2); +// +// OMElement res = sc.sendReceive(method); +// res.getFirstElement().getText(); +// System.out.println(res.getFirstElement().getText()); +// } catch (AxisFault e) { +// e.printStackTrace(); +// } +// +// } +// +// public static String objectToJson(List props) { +// String str = null; +// try { +// JSONArray json = JSONArray.fromObject(props);// 将java对象转换为json对象 +// str = json.toString();// 将json对象转换为字符串 +// } catch (Exception e) { +// e.printStackTrace(); +// } +// System.out.println("JSON =>" + str); +// return str; +// } +// +// public static void grantReadPrivilege(TCSession tcSession, TCComponent tccomponent) { +// AbstractAIFApplication app; +// app = AIFUtility.getCurrentApplication(); +// TCSession session; +// session = (TCSession) app.getSession(); +// TCPreferenceService preferenceService; +// preferenceService = session.getPreferenceService(); +// String account = preferenceService.getStringValue("Autocode_PriverUser_ID"); +// try { +// TCAccessControlService accessControlService = tcSession.getTCAccessControlService(); +// TCComponentUserType type = (TCComponentUserType) tcSession.getTypeComponent("User"); +// TCComponentUser user = type.find(account); +// +// if (user == null) { +// return; +// } +// if (tcSession.getUser().equals(user)) { +// return; +// } +// +// String[] as2 = new String[] { "READ" }; +// +// if (tccomponent instanceof TCComponentItemRevision) { +// TCComponentItem tempItem = ((TCComponentItemRevision) tccomponent).getItem(); +// openByPass(tcSession); +// accessControlService.grantPrivilege(tempItem, user, as2); +// closeByPass(tcSession); +// +// openByPass(tcSession); +// accessControlService.grantPrivilege(tccomponent, user, as2); +// closeByPass(tcSession); +// } else { +// openByPass(tcSession); +// accessControlService.grantPrivilege(tccomponent, user, as2); +// closeByPass(tcSession); +// } +// } catch (TCException e) { +// e.printStackTrace(); +// } +// } +// +// public static void grantWritePrivilege(TCSession tcSession, TCComponent tccomponent) { +// AbstractAIFApplication app; +// app = AIFUtility.getCurrentApplication(); +// TCSession session; +// session = (TCSession) app.getSession(); +// TCPreferenceService preferenceService; +// preferenceService = session.getPreferenceService(); +// String account = preferenceService.getStringValue("Autocode_PriverUser_ID"); +// try { +// TCAccessControlService accessControlService = tcSession.getTCAccessControlService(); +// TCComponentUserType type = (TCComponentUserType) tcSession.getTypeComponent("User"); +// +// TCComponentUser user = type.find(account); +// if (user == null) { +// return; +// } +// if (tcSession.getUser().equals(user)) { +// return; +// } +// +// String[] as2 = new String[] { "READ", "WRITE", "DELETE" }; +// +// if (tccomponent instanceof TCComponentItemRevision) { +// TCComponentItem tempItem = ((TCComponentItemRevision) tccomponent).getItem(); +// setByPass(true,tcSession); +// accessControlService.grantPrivilege(tempItem, user, as2); +// setByPass(false,tcSession); +// +// setByPass(true,tcSession); +// accessControlService.grantPrivilege(tccomponent, user, as2); +// setByPass(false,tcSession); +// } else { +// setByPass(true,tcSession); +// accessControlService.grantPrivilege(tccomponent, user, as2); +// setByPass(false,tcSession); +// } +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// +// public static void openByPass(TCSession session) throws TCException { +// TCUserService userservice = session.getUserService(); +// Object[] obj = new Object[1]; +// obj[0] = ""; +// userservice.call("Connor_set_bypass", obj); +// } +// +// public static void closeByPass(TCSession session) throws TCException { +// TCUserService userservice = session.getUserService(); +// Object[] obj = new Object[1]; +// obj[0] = ""; +// userservice.call("Connor_close_bypass", obj); +// +//// session.getUserService().call("Connor_set_bypass", new Object[]{});//开bypass +//// session.getUserService().call("Connor_close_bypass", new Object[]{});//关bypass +// } +// public static void setByPass(boolean val,TCSession session) throws TCException { +// TCUserService userservice = session.getUserService(); +// if (userservice == null) { +// userservice = session.getUserService(); +// } +// Object[] obj = new Object[1]; +// obj[0] = "origin"; +// if (val) { +//// userservice.call("ORIGIN_set_bypass", obj); +// userservice.call("Connor_set_bypass", obj); +// } else { +//// userservice.call("ORIGIN_close_bypass", obj); +// userservice.call("Connor_close_bypass", obj); +// } +// } +// +//} +// diff --git a/src/com/connor/zf/controlplan/SqlUtil.java b/src/com/connor/zf/controlplan/SqlUtil.java new file mode 100644 index 0000000..f0e23a9 --- /dev/null +++ b/src/com/connor/zf/controlplan/SqlUtil.java @@ -0,0 +1,564 @@ +package com.connor.zf.controlplan; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.Registry; + +/** + * 防止误继承因此是final类,防止误建对象因此用私有构造方法,为方便使用类名短小, PreparedStatement对象名和ResultSet对象名短小 + * + * @author hub 2015-02-06 + */ +public final class SqlUtil { + public static Connection connection = null; + public static PreparedStatement ps = null; + public static ResultSet rs = null; + private static Registry reg = Registry.getRegistry(SqlUtil.class); + + /** + * 私有构造器不能new对象,防止误用对象 + */ + private SqlUtil() { + + } + + static { + String driver = reg.getString("ORACEL_DRIVER"); // Util.getProperties("DRIVER"); + if (driver == null) { + driver = "oracle.jdbc.driver.OracleDriver"; + } + + System.out.println("driver " + driver); + try { + Class.forName(driver); + } catch (ClassNotFoundException e) { + System.out.println("ORACEL DRIVER IS EXCEPTION"); + e.printStackTrace(); + } + } + + /** + * 链接数据库 + */ + public static Connection getConnectionTC() { + try { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + TCPreferenceService service = session.getPreferenceService(); + String[] array = service.getStringArray( + TCPreferenceService.TC_preference_site, "TC_Oracel_MSG"); + String driver_temp = null; + String url = null; + String dbName = null; + String dbPassword = null; + if (array != null) + for (String str : array) { + if (str != null && str.startsWith("ORACEL_DRIVER=")) { + driver_temp = str.substring(str.indexOf("=" + 1, + str.length())); + } else if (str != null && str.startsWith("ORACEL_URL=")) { + url = str.substring(str.indexOf("=" + 1, str.length())); + } else if (str != null && str.startsWith("ORACEL_NAME=")) { + dbName = str.substring(str.indexOf("=" + 1, + str.length())); + } else if (str != null + && str.startsWith("ORACEL_PASSWORD=")) { + dbPassword = str.substring(str.indexOf("=" + 1, + str.length())); + } + } + // String driver_temp = reg.getString("ORACEL_DRIVER"); + // String url = reg.getString("ORACEL_URL");// getProperties("URL"); + // String dbName = reg.getString("ORACEL_NAME");// + // Util.getProperties("dbName"); + // String dbPassword = reg.getString("ORACEL_PASSWORD");// + // Util.getProperties("dbPassword"); + + if (driver_temp == null || url == null || dbName == null + || dbPassword == null) { + + MessageBox.post("请检查数据库首选项是否配置正确", "错误提示", MessageBox.ERROR); + + } + // else{ + // MessageBox.post(driver_temp+" | "+url+" | "+dbName+" | "+dbPassword,"错误提示",MessageBox.ERROR); + // + // } + System.out.println(url + dbName + dbPassword); + connection = DriverManager.getConnection(url, dbName, dbPassword); + connection.setAutoCommit(false); + } catch (SQLException e) { + System.out.println("ORACEL CONNECT EXCEPTION"); + e.printStackTrace(); + return null; + // MessageBox.post("ORACEL CONNECT EXCEPTION \n"+e.getMessage(),"ERROR",MessageBox.ERROR); + } + return connection; + } + + /** + * 链接数据库 + */ + public static Connection getConnection() { + try { + String driver_temp = reg.getString("ORACEL_DRIVER"); + String url = reg.getString("ORACEL_URL");// getProperties("URL"); + String dbName = reg.getString("ORACEL_NAME");// Util.getProperties("dbName"); + String dbPassword = reg.getString("ORACEL_PASSWORD");// Util.getProperties("dbPassword"); + + if (driver_temp == null || url == null || dbName == null + || dbPassword == null) { + + MessageBox.post("请检查数据库首选项是否配置正确", "错误提示", MessageBox.ERROR); + + } + // else{ + // MessageBox.post(driver_temp+" | "+url+" | "+dbName+" | "+dbPassword,"错误提示",MessageBox.ERROR); + // + // } + System.out.println(url + dbName + dbPassword); + connection = DriverManager.getConnection(url, dbName, dbPassword); + connection.setAutoCommit(false); + } catch (SQLException e) { + System.out.println("ORACEL CONNECT EXCEPTION"); + e.printStackTrace(); + return null; + // MessageBox.post("ORACEL CONNECT EXCEPTION \n"+e.getMessage(),"ERROR",MessageBox.ERROR); + } + return connection; + } + + /** + * 链接数据库 + */ + public static Connection getConnection(String url, String dbName, + String dbPassword) { + try { + String driver_temp = reg.getString("ORACEL_DRIVER"); + + System.out.println(url + dbName + dbPassword); + connection = DriverManager.getConnection(url, dbName, dbPassword); + connection.setAutoCommit(false); + } catch (SQLException e) { + System.out.println("ORACEL CONNECT EXCEPTION"); + e.printStackTrace(); + // MessageBox.post("ORACEL CONNECT EXCEPTION \n"+e.getMessage(),"ERROR",MessageBox.ERROR); + return null; + } + return connection; + } + + /** + * 拼接SELECT 语句 + * + * @param tableName + * @param selectElement + * @param args + * @return + */ + public static String getSelectSql(String tableName, String[] selectElement, + String... args) { + StringBuffer valuesSB = new StringBuffer("SELECT "); + if (selectElement != null) { + for (String element : selectElement) { + valuesSB.append(element).append(","); + } + valuesSB.delete(valuesSB.length() - 1, valuesSB.length()); + } + valuesSB.append(" FROM "); + valuesSB.append(tableName); + valuesSB.append(" WHERE"); + for (int i = 0; i < args.length; i++) { + valuesSB.append(" "); + valuesSB.append(args[i]); + valuesSB.append("=? "); + valuesSB.append("AND"); + } + + valuesSB.delete(valuesSB.length() - 3, valuesSB.length()); + return valuesSB.toString(); + } + + /** + * 拼接SELECT 语句 + * + * @param tableName + * @param args + * @return + */ + public static String getSelectSql(String tableName, String... args) { + StringBuffer valuesSB = new StringBuffer("SELECT * FROM "); + valuesSB.append(tableName); + valuesSB.append(" WHERE"); + for (int i = 0; i < args.length; i++) { + valuesSB.append(" "); + valuesSB.append(args[i]); + valuesSB.append("=? "); + valuesSB.append("AND"); + } + + valuesSB.delete(valuesSB.length() - 3, valuesSB.length()); + return valuesSB.toString(); + } + + /** + * 拼接更新语句 + * + * @param tableName + * @param args + * @param args2 + * @return + */ + public static String getUpdataSQL(String tableName, String[] args, + String[] args2) { + StringBuffer updateSB = new StringBuffer("UPDATE "); + updateSB.append(tableName); + updateSB.append(" SET "); + // 拼接更新语句 + for (int i = 0; i < args.length; i++) { + if (args[i].toUpperCase().equals("OPERATE_TIME") + || args[i].toUpperCase().equals("LAST_UPDATE_DATE")) { + updateSB.append(args[i]).append( + "=to_date(?,'yyyy-MM-dd HH24:mi:ss') ,"); + } else { + updateSB.append(args[i]).append("=? ,"); + } + } + updateSB.delete(updateSB.length() - 2, updateSB.length()); + ; + updateSB.append(" WHERE "); + for (int i = 0; i < args2.length; i++) { + updateSB.append(args2[i]).append("=? AND "); + } + updateSB.delete(updateSB.length() - 4, updateSB.length()); + return updateSB.toString(); + } + + /** + * 拼接SQL的insert语句 + * + * @param tableName + * @param args + * @return + */ + public static String getInsertSql(String tableName, String... args) { + StringBuffer insertSql = new StringBuffer("insert into "); + StringBuffer values = new StringBuffer("values("); + + if (tableName != null && args != null && args.length > 0) { + insertSql.append(tableName); + insertSql.append("("); + for (int i = 0; i < args.length; i++) { + insertSql.append(args[i]); + insertSql.append(", "); + if (args[i].toUpperCase().equals("COMMIT_TIME") + || args[i].toUpperCase().equals("CREATE_DATE") + || args[i].toUpperCase().equals("INVALID_DATE")) { + values.append("to_date(?,'yyyy-MM-dd HH24:mi:ss'), "); + } else { + values.append("?, "); + } + + } + } else { + return null; + } + insertSql.delete(insertSql.length() - 2, insertSql.length()); + values.delete(values.length() - 2, values.length()); + insertSql.append(") ").append(values).append(")"); + return insertSql.toString(); + } + + /** + * 得到创建表格数据库语句 + * + * @param tableName + * @param args + * 参数的名称 + * @param args2 + * 参数的类型 + * @return 拼接后的创建数据库的语句 + */ + public final static String GetCreateTableSQL(String tableName, + String[] args, String[] args2) { + + if (args == null || args2 == null || args.length != args2.length) { + System.out.println("THE INPUT PRAGREMS IS ERROR"); + return null; + } + StringBuffer createSQL = new StringBuffer("create table "); + createSQL.append(tableName); + createSQL.append("("); + for (int i = 0; i < args.length; i++) { + createSQL.append(args[i] + " "); + createSQL.append(args2[i] + ", "); + } + createSQL.delete(createSQL.length() - 2, createSQL.length()); + createSQL.append(")"); + return createSQL.toString(); + } + + /** + * 得到Statement + */ + public final static PreparedStatement getPs(String sql) throws SQLException { + return getPs(sql, null); + } + + /** + * 得到Statement + */ + public final static PreparedStatement getPs(Object[] argments, String sql) + throws SQLException { + return getPs(sql, argments); + } + + /** + * 得到Statement + */ + public final static PreparedStatement getPs(String sql, Object[] argments) + throws SQLException { + SqlUtil.ps = SqlUtil.connection.prepareStatement(sql); + if (argments != null) { + for (int i = 0; i < argments.length; i++) { + SqlUtil.ps.setObject(i + 1, argments[i]); + } + } + return SqlUtil.ps; + } + + /** + * 增加 + */ + public final static int write(String sql) { + return write(sql, null); + } + + /** + * 增加 + */ + public final static int write(Object[] argments, String sql) { + return write(sql, argments); + } + + /** + * 增加 + */ + public final static int write(String sql, Object[] argments) { + + return update(sql, argments); + } + + /** + * 删除 + */ + public final static int delete(String sql) { + return delete(sql, null); + } + + /** + * 删除 + */ + public final static int delete(Object[] argments, String sql) { + return delete(sql, argments); + } + + /** + * 删除 + */ + public final static int delete(String sql, Object[] argments) { + return update(sql, argments); + } + + /** + * 修改 + */ + public final static int update(String sql) { + return update(sql, null); + } + + /** + * 修改 + */ + public final static int update(String[] argments, String sql) { + return update(sql, argments); + } + + /** + * 修改(增删改最终都要调用此方法,此处进行异常处理,关闭除Connection以为的对象) + */ + public final static int update(String sql, Object[] argments) { + int i = -1; + try { + i = SqlUtil.getPs(argments, sql).executeUpdate(); + // 2015-11-19 + // SqlUtil.connection.commit(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + free(SqlUtil.rs, SqlUtil.ps); + } + return i; + } + + /** + * 查询 + */ + public final static ResultSet read(String sql) throws SQLException { + return read(sql, null); + } + + /** + * 查询 + */ + public final static ResultSet read(Object[] argments, String sql) + throws SQLException { + return read(sql, argments); + } + + /** + * 查询(所有查询最终都要调用此方法,方法里面不处理异常,抛出后由调用者处理,方便在finally语句中释放资源) + * + * @throws SQLException + */ + public final static ResultSet read(String sql, Object[] argments) + throws SQLException { + return SqlUtil.rs = SqlUtil.getPs(argments, sql).executeQuery(); + } + + /** + * 创建表 + */ + public final static boolean createTable(String sql) { + return go(sql, null); + } + + /** + * 删除表 + */ + public final static boolean dropTable(String sql) { + return go(sql, null); + } + + /** + * 修改表 + */ + public final static boolean alterTable(String sql) { + return go(sql, null); + } + + /** + * 此方法用来执行DDL语句(创建表,修改表,删除表) + */ + private final static boolean go(String sql, Object[] argments) { + boolean flag = false; + try { + flag = SqlUtil.getPs(sql, argments).execute(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + free(SqlUtil.rs, SqlUtil.ps); + } + if (flag) { + try { + SqlUtil.connection.commit(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + return flag; + } + + /** + * 释放资源 + */ + public final static void free(ResultSet resultSet) { + free(resultSet, null, null); + } + + /** + * 释放资源 + */ + public final static void free(Statement statement) { + free(null, statement, null); + } + + /** + * 释放资源 + */ + public final static void free(Connection connection) { + free(null, null, connection); + } + + /** + * 释放资源 + */ + public final static void free(ResultSet resultSet, Statement statement) { + free(resultSet, statement, null); + } + + /** + * 释放资源 + */ + public final static void free(Statement statement, Connection connection) { + free(null, statement, connection); + } + + /** + * 释放资源(不传参数默认部分) + */ + public final static void free() { + free(SqlUtil.rs, SqlUtil.ps); + } + + /** + * 释放资源(全部释放) + */ + public final static void freeAll() { + free(SqlUtil.rs, SqlUtil.ps, SqlUtil.connection); + } + + /** + * 释放资源(传满参数也要全部释放) + */ + public final static void free(ResultSet resultSet, Statement statement, + Connection connection) { + try { + if (resultSet != null) { + try { + resultSet.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } finally { + try { + if (statement != null) { + try { + statement.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } finally { + if (connection != null) { + try { + connection.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + } + } +} diff --git a/src/com/connor/zf/controlplan/SqlUtilT.java b/src/com/connor/zf/controlplan/SqlUtilT.java new file mode 100644 index 0000000..c0b4221 --- /dev/null +++ b/src/com/connor/zf/controlplan/SqlUtilT.java @@ -0,0 +1,710 @@ +package com.connor.zf.controlplan; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +/** + * 防止误继承因此是final类,防止误建对象因此用私有构造方法,为方便使用类名短小, PreparedStatement对象名和ResultSet对象名短小 + * + * @author hub 2015-02-06 + */ +public final class SqlUtilT { + public static Connection connection = null; + public static PreparedStatement ps = null; + public static ResultSet rs = null; + + // private static Registry reg = Registry.getRegistry(SqlUtilT.class); + /** + * 私有构造器不能new对象,防止误用对象 + */ + private SqlUtilT() { + + } + + static { + String driver = "oracle.jdbc.driver.OracleDriver"; // Util.getProperties("DRIVER"); + if (driver == null) { + driver = "oracle.jdbc.driver.OracleDriver"; + } + + System.out.println("driver " + driver); + try { + Class.forName(driver); + } catch (ClassNotFoundException e) { + System.out.println("ORACEL DRIVER IS EXCEPTION"); + e.printStackTrace(); + } + } + + /** + * 链接数据库 + */ + public static Connection getConnectionTC12() { + try { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + TCPreferenceService service = session.getPreferenceService(); + String[] array = service.getStringArray( + TCPreferenceService.TC_preference_site, "TC13_SqlServer_MSG"); + String driver_temp = null; + String url = null; + String dbName = null; + String dbPassword = null; + if (array != null) + for (String str : array) { + System.out.println(" SQL = " + str); + if (str != null && str.startsWith("SQL_DRIVER=")) { + driver_temp = str.substring(str.indexOf("=") + 1, + str.length()); + } else if (str != null && str.startsWith("SQL_URL=")) { + url = str.substring(str.indexOf("=") + 1, str.length()); + } else if (str != null && str.startsWith("SQL_NAME=")) { + dbName = str.substring(str.indexOf("=") + 1, + str.length()); + } else if (str != null + && str.startsWith("SQL_PASSWORD=")) { + dbPassword = str.substring(str.indexOf("=") + 1, + str.length()); + } + } + // String driver_temp = reg.getString("ORACEL_DRIVER"); + // String url = reg.getString("ORACEL_URL");// getProperties("URL"); + // String dbName = reg.getString("ORACEL_NAME");// + // Util.getProperties("dbName"); + // String dbPassword = reg.getString("ORACEL_PASSWORD");// + // Util.getProperties("dbPassword"); + + if (driver_temp == null || url == null || dbName == null + || dbPassword == null) { + + MessageBox.post("请检查数据库首选项是否配置正确", "错误提示", MessageBox.ERROR); + + } + // else{ + // MessageBox.post(driver_temp+" | "+url+" | "+dbName+" | "+dbPassword,"错误提示",MessageBox.ERROR); + // + // } + System.out.println(url + dbName + dbPassword); + connection = DriverManager.getConnection(url, dbName, dbPassword); + connection.setAutoCommit(false); + } catch (SQLException e) { + System.out.println("ORACEL CONNECT EXCEPTION"); + e.printStackTrace(); + return null; + // MessageBox.post("ORACEL CONNECT EXCEPTION \n"+e.getMessage(),"ERROR",MessageBox.ERROR); + } + return connection; + } + + /** + * 链接数据库 + */ + public static Connection getConnectionTC() { + try { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + TCPreferenceService service = session.getPreferenceService(); + String[] array = service.getStringArray( + TCPreferenceService.TC_preference_site, "TC_Oracel_MSG"); + String driver_temp = null; + String url = null; + String dbName = null; + String dbPassword = null; + if (array != null) + for (String str : array) { + System.out.println(" ORACLE = " + str); + if (str != null && str.startsWith("ORACEL_DRIVER=")) { + driver_temp = str.substring(str.indexOf("=") + 1, + str.length()); + } else if (str != null && str.startsWith("ORACEL_URL=")) { + url = str.substring(str.indexOf("=") + 1, str.length()); + } else if (str != null && str.startsWith("ORACEL_NAME=")) { + dbName = str.substring(str.indexOf("=") + 1, + str.length()); + } else if (str != null + && str.startsWith("ORACEL_PASSWORD=")) { + dbPassword = str.substring(str.indexOf("=") + 1, + str.length()); + } + } + // String driver_temp = reg.getString("ORACEL_DRIVER"); + // String url = reg.getString("ORACEL_URL");// getProperties("URL"); + // String dbName = reg.getString("ORACEL_NAME");// + // Util.getProperties("dbName"); + // String dbPassword = reg.getString("ORACEL_PASSWORD");// + // Util.getProperties("dbPassword"); + + if (driver_temp == null || url == null || dbName == null + || dbPassword == null) { + + MessageBox.post("请检查数据库首选项是否配置正确", "错误提示", MessageBox.ERROR); + + } + // else{ + // MessageBox.post(driver_temp+" | "+url+" | "+dbName+" | "+dbPassword,"错误提示",MessageBox.ERROR); + // + // } + System.out.println(url + dbName + dbPassword); + connection = DriverManager.getConnection(url, dbName, dbPassword); + connection.setAutoCommit(false); + } catch (SQLException e) { + System.out.println("ORACEL CONNECT EXCEPTION"); + e.printStackTrace(); + return null; + // MessageBox.post("ORACEL CONNECT EXCEPTION \n"+e.getMessage(),"ERROR",MessageBox.ERROR); + } + return connection; + } + + /** + * 链接数据库 + */ + public static Connection getConnection() { + try { + String driver_temp = "oracle.jdbc.driver.OracleDriver"; + String url = "jdbc:oracle:thin:@192.168.1.248:1521:TOPPROD";// getProperties("URL"); + String dbName = "jfgroup";// Util.getProperties("dbName"); + String dbPassword = "jfgroup";// Util.getProperties("dbPassword"); + + /* + * if(driver_temp == null ||url==null|| dbName == null ||dbPassword + * == null ){ + * + * MessageBox.post("请检查数据库首选项是否配置正确","错误提示",MessageBox.ERROR); + * + * } + */ + System.out.println(url + dbName + dbPassword); + connection = DriverManager.getConnection(url, dbName, dbPassword); + connection.setAutoCommit(false); + } catch (SQLException e) { + System.out.println("ORACEL CONNECT EXCEPTION"); + e.printStackTrace(); + return null; + // MessageBox.post("ORACEL CONNECT EXCEPTION \n"+e.getMessage(),"ERROR",MessageBox.ERROR); + } + return connection; + } + + /** + * 链接数据库 + */ + public static Connection getConnection(String url, String dbName, + String dbPassword) { + try { + String driver_temp = "oracle.jdbc.driver.OracleDriver"; + + System.out.println(url + dbName + dbPassword); + connection = DriverManager.getConnection(url, dbName, dbPassword); + connection.setAutoCommit(false); + } catch (SQLException e) { + // MessageBox.post("MSG ==>"+url + dbName + dbPassword,"",1); + System.out.println("ORACEL CONNECT EXCEPTION"); + e.printStackTrace(); + MessageBox.post(" MSG = >" + e.getMessage(), "222", 1); + // MessageBox.post("ORACEL CONNECT EXCEPTION \n"+e.getMessage(),"ERROR",MessageBox.ERROR); + return null; + } + return connection; + } + + /** + * 链接TC数据库 + */ + public static Connection getTCConnection() { + try { + if(connection == null || connection.isClosed()) + { + SqlUtilT.getConnectionTC12(); +// SqlUtilT.getConnection("jdbc:Oracle:thin:@localhost:1521:TC10","tc10", "infodba"); + } + } catch (Exception e) { + // MessageBox.post("MSG ==>"+url + dbName + dbPassword,"",1); + System.out.println("ORACEL CONNECT EXCEPTION"); + e.printStackTrace(); + MessageBox.post(" MSG = >" + e.getMessage(), "222", 1); + // MessageBox.post("ORACEL CONNECT EXCEPTION \n"+e.getMessage(),"ERROR",MessageBox.ERROR); + return null; + } + return connection; + } + + /** + * 拼接SELECT 语句 + * + * @param tableName + * @param selectElement + * @param args + * @return + */ + public static String getSelectSql(String tableName, String[] selectElement, + String... args) { + StringBuffer valuesSB = new StringBuffer("SELECT "); + if (selectElement != null) { + for (String element : selectElement) { + valuesSB.append(element).append(","); + } + valuesSB.delete(valuesSB.length() - 1, valuesSB.length()); + } + valuesSB.append(" FROM "); + valuesSB.append(tableName); + valuesSB.append(" WHERE"); + for (int i = 0; i < args.length; i++) { + valuesSB.append(" "); + valuesSB.append(args[i]); + valuesSB.append("=? "); + valuesSB.append("AND"); + } + + valuesSB.delete(valuesSB.length() - 3, valuesSB.length()); + return valuesSB.toString(); + } + + /** + * 拼接SELECT 语句 + * + * @param tableName + * @param args + * @return + */ + public static String getSelectSql(String tableName, String... args) { + StringBuffer valuesSB = new StringBuffer("SELECT * FROM "); + valuesSB.append(tableName); + valuesSB.append(" WHERE"); + for (int i = 0; i < args.length; i++) { + valuesSB.append(" "); + valuesSB.append(args[i]); + valuesSB.append("=? "); + valuesSB.append("AND"); + } + + valuesSB.delete(valuesSB.length() - 3, valuesSB.length()); + return valuesSB.toString(); + } + + /** + * 拼接更新语句 + * + * @param tableName + * @param args + * @param args2 + * @return + */ + public static String getUpdataSQL(String tableName, String[] args, + String[] args2) { + StringBuffer updateSB = new StringBuffer("UPDATE "); + updateSB.append(tableName); + updateSB.append(" SET "); + // 拼接更新语句 + for (int i = 0; i < args.length; i++) { + if (args[i].toUpperCase().equals("CREATED_DATE") + || args[i].toUpperCase().equals("LAST_UPDATE_DATE")) { + updateSB.append(args[i]).append( + "=to_date(?,'yyyy-MM-dd HH24:mi:ss') ,"); + } else { + updateSB.append(args[i]).append("=? ,"); + } + } + updateSB.delete(updateSB.length() - 2, updateSB.length()); + ; + updateSB.append(" WHERE "); + for (int i = 0; i < args2.length; i++) { + updateSB.append(args2[i]).append("=? AND "); + } + updateSB.delete(updateSB.length() - 4, updateSB.length()); + return updateSB.toString(); + } + + /** + * 拼接SQL的insert语句 + * + * @param tableName + * @param args + * @return + */ + public static String getInsertSql(String tableName, String... args) { + StringBuffer insertSql = new StringBuffer("insert into "); + StringBuffer values = new StringBuffer("values("); + + if (tableName != null && args != null && args.length > 0) { + insertSql.append(tableName); + insertSql.append("("); + for (int i = 0; i < args.length; i++) { + insertSql.append(args[i]); + insertSql.append(", "); + if (args[i].toUpperCase().equals("LAST_UPDATE_DATE") + || args[i].toUpperCase().equals("CREATED_DATE")) { + values.append("to_date(?,'yyyy-MM-dd HH24:mi:ss'), "); + } else { + values.append("?, "); + } + + } + } else { + return null; + } + insertSql.delete(insertSql.length() - 2, insertSql.length()); + values.delete(values.length() - 2, values.length()); + insertSql.append(") ").append(values).append(")"); + return insertSql.toString(); + } + + /** + * 得到创建表格数据库语句 + * + * @param tableName + * @param args + * 参数的名称 + * @param args2 + * 参数的类型 + * @return 拼接后的创建数据库的语句 + */ + public final static String GetCreateTableSQL(String tableName, + String[] args, String[] args2) { + + if (args == null || args2 == null || args.length != args2.length) { + System.out.println("THE INPUT PRAGREMS IS ERROR"); + return null; + } + StringBuffer createSQL = new StringBuffer("create table "); + createSQL.append(tableName); + createSQL.append("("); + for (int i = 0; i < args.length; i++) { + createSQL.append(args[i] + " "); + createSQL.append(args2[i] + ", "); + } + createSQL.delete(createSQL.length() - 2, createSQL.length()); + createSQL.append(")"); + return createSQL.toString(); + } + + /** + * 得到Statement + */ + public final static PreparedStatement getPs(String sql) throws SQLException { + return getPs(sql, null); + } + + /** + * 得到Statement + */ + public final static PreparedStatement getPs(Object[] argments, String sql) + throws SQLException { + return getPs(sql, argments); + } + + /** + * 得到Statement + */ + public final static PreparedStatement getPs(String sql, Object[] argments) + throws SQLException { + System.out.println("==========操作数据库增删改=========="); + SqlUtilT.ps = SqlUtilT.connection.prepareStatement(sql,ResultSet.TYPE_FORWARD_ONLY,ResultSet.CONCUR_READ_ONLY); + SqlUtilT.ps.setFetchSize(1000); + //sql不需要 + //SqlUtilT.ps.setFetchDirection(ResultSet.FETCH_REVERSE); + + if (argments != null) { + for (int i = 0; i < argments.length; i++) { + SqlUtilT.ps.setObject(i + 1, argments[i]); + } + } + return SqlUtilT.ps; + } + + /** + * 增加 + */ + public final static int write(String sql) { + return write(sql, null); + } + + /** + * 增加 + */ + public final static int write(Object[] argments, String sql) { + return write(sql, argments); + } + + /** + * 增加 + */ + public final static int write2(Object[] argments, String sql) { + return write2(sql, argments); + } + + /** + * 增加 + */ + public final static int write(String sql, Object[] argments) { + + return update(sql, argments); + } + + /** + * 增加 + */ + public final static int write2(String sql, Object[] argments) { + + return update2(sql, argments); + } + + /** + * 删除 + */ + public final static int delete(String sql) { + return delete(sql, null); + } + + /** + * 删除 + */ + public final static int delete(Object[] argments, String sql) { + return delete(sql, argments); + } + + /** + * 删除 + */ + public final static int delete(String sql, Object[] argments) { + return update(sql, argments); + } + + /** + * 删除 + */ + public final static int delete2(String sql) { + int i = -1; + try { + i = SqlUtilT.getPs(null,sql).executeUpdate(); + SqlUtilT.connection.commit(); + } catch (SQLException e) { + e.printStackTrace(); + } + return i; + } + + /** + * 修改 + */ + public final static int update(String sql) { + return update(sql, null); + } + + /** + * 修改 + */ + public final static int update(String[] argments, String sql) { + return update(sql, argments); + } + + /** + * 修改(增删改最终都要调用此方法,此处进行异常处理,关闭除Connection以外的对象),不提交事务 + */ + public final static int update2(String sql, Object[] argments) { + int i = -1; + try { + PreparedStatement statement=null; + while(statement==null) { + statement=SqlUtilT.getPs(argments, sql); + if(statement==null) { + getTCConnection(); + System.out.println("+++++++++++++++++statement为空"); + } + } + i = statement.executeUpdate(); + //i = SqlUtilT.getPs(argments, sql).executeUpdate(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + free(SqlUtilT.rs, SqlUtilT.ps); + } + return i; + } + + /** + * 修改(增删改最终都要调用此方法,此处进行异常处理,关闭除Connection以为的对象) + */ + public final static int update(String sql, Object[] argments) { + int i = -1; + try { + PreparedStatement statement=null; + while(statement==null) { + statement=SqlUtilT.getPs(argments, sql); + if(statement==null) { + getTCConnection(); + System.out.println("+++++++++++++++++statement为空"); + } + } + i = statement.executeUpdate(); + //i = SqlUtilT.getPs(argments, sql).executeUpdate(); + SqlUtilT.connection.commit(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + free(SqlUtilT.rs, SqlUtilT.ps); + } + return i; + } + + /** + * 查询 + */ + public final static ResultSet read(String sql) throws SQLException { + return read(sql, null); + } + + /** + * 查询 + */ + public final static ResultSet read(Object[] argments, String sql) + throws SQLException { + return read(sql, argments); + } + + /** + * 查询(所有查询最终都要调用此方法,方法里面不处理异常,抛出后由调用者处理,方便在finally语句中释放资源) + * + * @throws SQLException + */ + public final static ResultSet read(String sql, Object[] argments) + throws SQLException { + return SqlUtilT.rs = SqlUtilT.getPs(argments, sql).executeQuery(); + } + + /** + * 创建表 + */ + public final static boolean createTable(String sql) { + return go(sql, null); + } + + /** + * 删除表 + */ + public final static boolean dropTable(String sql) { + return go(sql, null); + } + + /** + * 修改表 + */ + public final static boolean alterTable(String sql) { + return go(sql, null); + } + + /** + * 此方法用来执行DDL语句(创建表,修改表,删除表) + */ + private final static boolean go(String sql, Object[] argments) { + boolean flag = false; + try { + flag = SqlUtilT.getPs(sql, argments).execute(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + free(SqlUtilT.rs, SqlUtilT.ps); + } + if (flag) { + try { + SqlUtilT.connection.commit(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + return flag; + } + + /** + * 释放资源 + */ + public final static void free(ResultSet resultSet) { + free(resultSet, null, null); + } + + /** + * 释放资源 + */ + public final static void free(Statement statement) { + free(null, statement, null); + } + + /** + * 释放资源 + */ + public final static void free(Connection connection) { + free(null, null, connection); + } + + /** + * 释放资源 + */ + public final static void free(ResultSet resultSet, Statement statement) { + free(resultSet, statement, null); + } + + /** + * 释放资源 + */ + public final static void free(Statement statement, Connection connection) { + free(null, statement, connection); + } + + /** + * 释放资源(不传参数默认部分) + */ + public final static void free() { + free(SqlUtilT.rs, SqlUtilT.ps); + } + + /** + * 释放资源(全部释放) + */ + public final static void freeAll() { + free(SqlUtilT.rs, SqlUtilT.ps, SqlUtilT.connection); + } + + /** + * 释放资源(传满参数也要全部释放) + */ + public final static void free(ResultSet resultSet, Statement statement, + Connection connection) { + try { + if (resultSet != null) { + try { + resultSet.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } finally { + try { + if (statement != null) { + try { + statement.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } finally { + if (connection != null) { + try { + connection.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + } + } +} diff --git a/src/com/connor/zf/controlplan/StringCreateUtil.java b/src/com/connor/zf/controlplan/StringCreateUtil.java new file mode 100644 index 0000000..063b4fb --- /dev/null +++ b/src/com/connor/zf/controlplan/StringCreateUtil.java @@ -0,0 +1,21 @@ +package com.connor.zf.controlplan; + +public class StringCreateUtil { + public static String createBlank(int num) { + StringBuilder sb = new StringBuilder(); + while (num > 0) { + sb.append(" "); + num--; + } + return sb.toString(); + } + + public static String createPoint(int num) { + StringBuilder sb = new StringBuilder(); + while (num > 0) { + sb.append("."); + num--; + } + return sb.toString(); + } +} diff --git a/src/com/connor/zf/controlplan/TMom004LibraryTree.java b/src/com/connor/zf/controlplan/TMom004LibraryTree.java new file mode 100644 index 0000000..1280b8e --- /dev/null +++ b/src/com/connor/zf/controlplan/TMom004LibraryTree.java @@ -0,0 +1,74 @@ +package com.connor.zf.controlplan; + +import javax.swing.ImageIcon; +import javax.swing.JTree; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeCellRenderer; + +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentGroupType; +import com.teamcenter.rac.kernel.TCComponentRole; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom004LibraryTree { + public void getLibrary(DefaultMutableTreeNode node, TCComponent comp, + TCComponent parent) { + try { + if (comp instanceof TCComponentGroup) { + TCComponent[] comps = ((TCComponentGroup) comp) + .getRolesAndGroups(); + for (int i = 0; i < comps.length; i++) { + TMomUserBean bean = new TMomUserBean(comps[i], comp); + DefaultMutableTreeNode node1 = new DefaultMutableTreeNode( + bean); + node.add(node1); + getLibrary(node1, comps[i], comp); + } + } else if (comp instanceof TCComponentRole) { + TCComponent[] comps = ((TCComponentRole) comp) + .getUsers((TCComponentGroup) parent); + for (int i = 0; i < comps.length; i++) { + TMomUserBean bean = new TMomUserBean(comps[i], comp); + DefaultMutableTreeNode node1 = new DefaultMutableTreeNode( + bean); + node.add(node1); + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "错误", MessageBox.ERROR); + e.printStackTrace(); + } + } + + public JTree getTcOrgTree(TCSession session, String goupFullName) { + JTree tree = new JTree(); + + try { + TCComponentGroupType type = ((TCComponentGroupType) session + .getTypeComponent("Group")); + TCComponentGroup group = type.find("NBTM"); + TMomUserBean bean = new TMomUserBean(group, null); + DefaultMutableTreeNode node1 = new DefaultMutableTreeNode(bean); + getLibrary(node1, group, null); + tree = new JTree(node1); + tree.setRowHeight(20); + DefaultTreeCellRenderer cellRenderer = (DefaultTreeCellRenderer) tree + .getCellRenderer(); + cellRenderer.setLeafIcon(new ImageIcon("icons\\person_16.png")); + cellRenderer.setOpenIcon(new ImageIcon("icons\\role_16.png")); + cellRenderer.setClosedIcon(new ImageIcon("icons\\group_16.png")); + + } catch (TCException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "错误", MessageBox.ERROR); + e.printStackTrace(); + } + + return tree; + } + +} diff --git a/src/com/connor/zf/controlplan/TMom004SetControlPlanCommand.java b/src/com/connor/zf/controlplan/TMom004SetControlPlanCommand.java new file mode 100644 index 0000000..109cbf4 --- /dev/null +++ b/src/com/connor/zf/controlplan/TMom004SetControlPlanCommand.java @@ -0,0 +1,894 @@ +package com.connor.zf.controlplan; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.UUID; + +import javax.swing.JFrame; +import javax.swing.JProgressBar; +import javax.swing.plaf.metal.MetalProgressBarUI; + +import org.apache.xmlbeans.impl.xb.xsdschema.Public; +//import org.junit.Test; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.commands.reserve.ReserveOperation; +import com.teamcenter.rac.kernel.TCAccessControlService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentRole; +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.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.services.rac.core.ReservationService; + +public class TMom004SetControlPlanCommand extends AbstractAIFCommand { + private TCSession session; + private AbstractAIFApplication app;// 获取选择的目标对象 + private InterfaceAIFComponent comp; + private TCComponentItem item; + private TCComponentItemRevision itemRevision; + private TCComponent form; + private TCComponentItemRevision meprocess; + private boolean isOwning = false; + private TCTypeService service; + private JFrame frame = new JFrame("正在加载...");//进度条窗口 + private JProgressBar progressBar = new JProgressBar();//进度条 + // private String[] properName = new String[] { + // "zf6_kzjhbh",//控制计划编号 + // "zf6_zylxdh", // 主要联系人电话 + // "zf6_bzrq",//编制日期 + // "zf6_xdrq",//修订日期 + // "zf6_sor", // SOR号码/名称 + // "zf6_ljhzzbb",//零件号/最终版本 + // "zf6_hxxz", // 核心小组 + // "zf6_gkgcpz",// 顾客工程批准/日期 + // "zf6_khtzbh",//客户图纸编号 + // "zf6_ljmcms",//零件名称/描述 + // "zf6_gfgcpz", // 供方/工厂批准/日期 + // "zf6_gkzlpz",// 顾客质量批准/日期 + // "zf6_gfgc",// 供方/工厂 + // "zf6_gfdh",// 供方代号 + // "zf6_gkpz",// 顾客批准/日期 + // "zf6_qtpzrq1", // 其他批准/日期1 + // "zf6_qtpzrq2" }; // 其他批准/日期2; + private Map combineMap = new HashMap();// 存放合并单元格 + // private TCProperty[] properties; + // private List> processRowList = new + // ArrayList>(); + private List processRows = new ArrayList(); + // private List meopNameList; + private Map> labelRows = new HashMap>();//标注行 + private TCComponentUser user;// 当前登录用户 + private List> dataList = new ArrayList>();// 表格中的数据 + private List plmeidList = new ArrayList();// plmeid + private List meopId = new ArrayList();// 工序ID + private List> completeDataList = new ArrayList>();// 已完成的人员数据 + private String UID; + boolean isRelease=false; + private Map meopNameToID = new HashMap();//工序名称与ID + private Map MEOPIDToNO = new HashMap();//工序名称与ID + private List meoplist = new ArrayList();// 数据库中的工序ID + private List HeadList = new ArrayList(); + private boolean isReimport =false; + public TMom004SetControlPlanCommand() { + super(); + } + + public TMom004SetControlPlanCommand(AbstractAIFApplication app,InterfaceAIFComponent comp, + TCSession session,String UID,boolean isReimport) { + this.session = session; + this.app = app; + this.comp = comp; + this.user = session.getUser(); + this.UID=UID; + this.isReimport=isReimport; + this.service = session.getTypeService(); + } + + + + /** + * 获取数据库中的数据 + */ + private void getData() { + // TODO Auto-generated method stub + ResultSet rs = null; + InputStream input = null; + try { + // 获取数据库连接 + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("CONTROLPLANSELECT"), + meprocess.getItem().getUid(),comp.getUid()); + rs = SqlUtilT.read(sql); + System.out.println("sql===>"+sql); + + int num=rs.getFetchSize()/75; + int num1=1; + int num2=0; + while (rs.next()) { + //++++ + if(num2==num*num1) { + progressBar.setValue(num1+20); + num1++; + } + num2++; + //+++ + List rowList = new ArrayList(); + rowList.add(rs.getString("PLMEID"));//0 + rowList.add(rs.getString("LJGCBH"));//1 + rowList.add(rs.getString("GCMC"));//2 + rowList.add(rs.getString("JQZHJJGZ"));//3 + rowList.add(rs.getString("BH"));//4 + rowList.add(rs.getString("CP"));//5 + rowList.add(rs.getString("GC"));//6 + rowList.add(rs.getString("TSTXFL"));//7 + rowList.add(rs.getString("CPGC"));//8 + rowList.add(rs.getString("JSCLJS"));//9 + rowList.add(rs.getString("XM"));//10 + rowList.add(rs.getString("RL"));//11 + rowList.add(rs.getString("PL"));//12 + rowList.add(rs.getString("ZRR"));//13 + rowList.add(rs.getString("KZFF"));//14 + rowList.add(rs.getString("FYJH"));//15 + rowList.add(rs.getString("NO"));//16 + rowList.add(rs.getString("ZF6_HH"));//17 + rowList.add(rs.getString("ZF6_HBDYG"));//18 + rowList.add(rs.getString("ZF6_HHC"));//19 + System.out.println("获取数据:====》"+rowList); + dataList.add(rowList); + } + + + +// // 将表中的行重新排序,并获取当前用户可修改的行号 +// String userName = form.getReferenceProperty("owning_user") +// .getStringProperty("user_id"); + + +// TCPreferenceService service = session.getPreferenceService(); +// String[] strs = service.getStringValues("Cust_ControlPlanLibrary_Privilege"); +// List Privilegelist = Arrays.asList(strs); + + + //根据是否发布或者有读写权限来判断权限 + for (int i = 0; i < dataList.size(); i++) { + // 行号差 + dataList.get(i).set(19,i- Integer.parseInt(dataList.get(i).get(17).toString())); + if(user.getGroups()[0].getGroupName().equals("dba"))//特权用户 + { + isOwning = true; + processRows.add(i); + plmeidList.add(dataList.get(i).get(0).toString()); + continue; + } + else if (isRelease && !user.getGroups()[0].getGroupName().equals("dba")) + { + continue; + } + else { + isOwning = true; + processRows.add(i); + if(dataList.get(i)==null) { + MessageBox.post("dataList.get("+"):"+dataList.get(i).toString(), "错误", MessageBox.ERROR); + } + if(dataList.get(i).get(0)==null) { + MessageBox.post(dataList.get(i).toString(), "错误", MessageBox.ERROR); + } + plmeidList.add(dataList.get(i).get(0).toString()); + + } + } + input.close(); + } catch (Exception e) { + MessageBox.post(e.toString(), "错误", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + + } + + /** + * 获取数据库中表头的数据 + */ + private void getHeadData() { + // TODO Auto-generated method stub + ResultSet rs = null; + InputStream input = null; + try { + // 获取数据库连接 + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("CONTROLPLANHEADSELECT"), + comp.getUid()); + System.out.println("sqlhead=====>"+sql); + + rs = SqlUtilT.read(sql); + if(!rs.next()) {//插入初始表头数据 + String PLMEID=UUID.randomUUID().toString().replace("-", ""); + HeadList.add(PLMEID); + HeadList.add(itemRevision.getUid()); + HeadList.add("");//类型 + HeadList.add(itemRevision.getStringProperty("item_id"));//控制计划编号 + for(int i=0;i<12;i++) { + HeadList.add(""); + } + String[] data=HeadList.toArray(new String[]{}); + System.out.println("数组data===>"+Arrays.toString(data)); + String insertSQL = "insert into ZF6_CONTROLPLANHEAD values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + SqlUtilT.write2(data, insertSQL); + SqlUtilT.connection.commit(); + }else { + HeadList.add(rs.getString("PLMEID"));//0 + HeadList.add(rs.getString("PUID"));//1 + HeadList.add(rs.getString("type"));//2 + HeadList.add(rs.getString("kzjhbh"));//3 + HeadList.add(rs.getString("zylxr"));//4 + HeadList.add(rs.getString("bzriq"));//5 + HeadList.add(rs.getString("xdrq"));//6 + HeadList.add(rs.getString("ljbh"));//7 + HeadList.add(rs.getString("hxxz"));//8 + HeadList.add(rs.getString("gkgcpz"));//9 + HeadList.add(rs.getString("ljmc"));//10 + HeadList.add(rs.getString("gfpzrq"));//11 + HeadList.add(rs.getString("gkzlpz"));//12 + HeadList.add(rs.getString("zzdm"));//13 + HeadList.add(rs.getString("qtpz"));//14 + HeadList.add(rs.getString("qtpzrq"));//15 + System.out.println("添加head===>"+HeadList); + } + + input.close(); + } catch (Exception e) { + MessageBox.post(e.toString(), "错误", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + + } + + + private void getItem() { + try { + // 获取选中对象的版本表单 + // if (comp instanceof TCComponentItem) { + // MessageBox.post("请选择控制计划版本对象!", "错误", MessageBox.ERROR); + // + // //throw new Exception("未找到对象"); + // } else + System.out.println("getitem"); + if (itemRevision.getType().toUpperCase().equals("ZF6_KZJHREVISION")) { + AIFComponentContext[] context = itemRevision.whereReferenced(); + + for (int i = 0; i < context.length; i++) { + if (context[i].getComponent().getType().equals("ZF6_GYLXRevision")) { + + meprocess = (TCComponentItemRevision) context[i].getComponent(); + System.out.println("--------------找到工艺对象--------------------:"+meprocess.getStringProperty("object_name")); + break; + } + } + item = itemRevision.getItem(); + // form = itemRevision.getRelatedComponent("IMAN_master_form_rev"); + }else { + MessageBox.post("请选择控制计划版本对象!", "错误", MessageBox.ERROR); + return; + } + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.toString(), "错误", MessageBox.ERROR); + e.printStackTrace(); + } + } + //是否是DO节点 + public boolean isDoTask(String meopId,String userId) { + try { + TCComponentItemType itemType = (TCComponentItemType) this.session + .getTypeComponent("Item"); + TCComponentItem meopItem = itemType.find(meopId); + if(meopItem != null) + { + TCComponent[] items = meopItem + .getRelatedComponents("process_stage_list"); + for (int i = 0; i < items.length; i++) { + if (items[i].getType().indexOf("DoTask") >= 0) { + TCComponentUser user = (TCComponentUser) items[i].getRelatedComponent("owning_user"); + if(user.getUserId().equals(userId)) + { + return true; + } + } + + } + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + return false; + } + //是否是审批节点 + public boolean isReviewTask(String meopId,String userId) { + try { + TCComponentItemType itemType = (TCComponentItemType) this.session + .getTypeComponent("Item"); + TCComponentItem meopItem = itemType.find(meopId); + if(meopItem != null) + { + TCComponent[] items = meopItem + .getRelatedComponents("process_stage_list"); + for (int i = 0; i < items.length; i++) { + if (items[i].getType().indexOf("ReviewTask") >= 0) { + TCComponentUser user = (TCComponentUser) items[i].getRelatedComponent("owning_user"); + if(user.getUserId().equals(userId)) + { + return true; + } + } + + } + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + return false; + } + + public void getCombineMap() { + try { + if (dataList != null && dataList.size() > 0) { + for (int i = 0; i < dataList.size(); i++) { + if (dataList.get(i).get(18) != null + && !dataList.get(i).get(18).equals("")) { + String sombine = dataList.get(i).get(18).toString(); + int rowDif = Integer.parseInt(dataList.get(i).get(19) + .toString()); + String[] sombines; + if (sombine.indexOf("-") >= 0) { + sombines = sombine.split("-"); + } else { + sombines = new String[] { sombine }; + } + for (int j = 0; j < sombines.length; j++) { + if (sombines[j].indexOf("/") >= 0) { + int[] row; + int[] cloumn; + String[] cells = sombines[j].split("/"); + if (cells[0].indexOf(",") >= 0) { + String[] rows = cells[0].split(","); + row = new int[rows.length]; + for (int k = 0; k < rows.length; k++) { + row[k] = Integer.parseInt(rows[k]) + + rowDif; + } + } else { + row = new int[] { Integer + .parseInt(cells[0]) + rowDif }; + } + if (cells[1].indexOf(",") >= 0) { + String[] cloumns = cells[1].split(","); + cloumn = new int[cloumns.length]; + for (int k = 0; k < cloumns.length; k++) { + cloumn[k] = Integer + .parseInt(cloumns[k]); + } + } else { + cloumn = new int[] { Integer + .parseInt(cells[1]) }; + } + this.combineMap.put(row, cloumn); + } + } + } + } + } + } catch (Exception e) { + MessageBox.post(e.toString(), "错误", MessageBox.ERROR); + e.printStackTrace(); + } + } + + /** + * 获取有检验项的工序 + * @param name 首选项名称 + * @return 没有检验项的工序名称 + */ + private List getMeopNames(String name) { + // TODO Auto-generated method stub + String[] values = null; + if(name != null) + { + TCPreferenceService service = this.session.getPreferenceService(); + String[] props = service.getStringArray(TCPreferenceService.TC_preference_site, name); + if(props != null || props.length>0) + { + values = new String[props.length]; + for (int i = 0; i < props.length; i++) { + if(props[i].indexOf("/") >= 0) + { + values[i] = props[i].split("/")[0]; + } + else + { + values[i] = props[i]; + } + } + } + } + else + { + MessageBox.post("未找首选项!", "错误!", MessageBox.ERROR); + } + return Arrays.asList(values); + } + + + @Override + public void executeModal() throws Exception { + System.out.println("打开控制计划"); + //+++++++判断是否发布 + isRelease = comp.getProperty( + "release_status_list") != ""; + //++++如果没发布isRelease为false就看是否有写的权限 + if(!isRelease) { + try { + TCComponentUser user = session.getUser(); + TCComponentGroup group = session.getCurrentGroup(); + TCComponentRole role = session.getCurrentRole(); + + TCComponent coms[] = { user, group, role }; + TCAccessControlService service = session + .getTCAccessControlService(); + boolean[] flags = service.checkAccessorsPrivileges(coms, (TCComponent) app.getTargetComponent(), + new String[] { "WRITE" }); + for (boolean b : flags) { + if (!b) { + //没有写的权限就让isRelease为true,就不让其编辑 + //MessageBox.post("没有写权限", "错误", MessageBox.ERROR); + isRelease = true; + break; + } + } + } catch (TCException e) { + e.printStackTrace(); + } + } + if(!isRelease) { + //判断是否打开签出 + if(((TCComponent) comp).isCheckedOut()) { + MessageBox.post("控制计划正在编辑!(已签出)", "错误", MessageBox.ERROR); + return; + } + //没签出则在打开时签出对象 + new ReserveOperation(new AIFComponentContext(comp, + comp, "context")).executeModeless(); + } + if (comp instanceof TCComponentItemRevision) { + itemRevision = (TCComponentItemRevision) comp; + } + System.out.println("======1"); + //+++ + getItem(); + + //+++添加进度条 + frame.setSize(300, 70); + frame.setLocationRelativeTo(null); + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + frame.setLayout(new BorderLayout()); + progressBar.setOrientation(JProgressBar.HORIZONTAL); + progressBar.setSize(300, 50); + progressBar.setMinimum(0); + progressBar.setMaximum(100); + progressBar.setBorderPainted(true); + progressBar.setUI(new MetalProgressBarUI()); + progressBar.setBackground(Color.white); + progressBar.setForeground(Color.green); + progressBar.setStringPainted(true); + frame.setAlwaysOnTop(true); + frame.add(progressBar); + frame.setVisible(true); + progressBar.setValue(1); + //+++ + + // meopNameList = getMeopNames("ZF6_CONCEAL_MEOP_NAME"); + // //没发布的版本要同步bom更新 + // if(comp.getProperty("release_status_list")==null||comp.getProperty("release_status_list").equals("")) { + // CollectControlPlan collectControlPlan = new CollectControlPlan(session, item.getType().toUpperCase(), meprocess); + // SaveControlPlan saveControlPlan = new SaveControlPlan(session, meprocess,comp); + // saveControlPlan.insertData(); + // } + + + //++++如果版本的版本不是“00”就获取最后版本的数据给新修订的版本 + // 获取数据库连接 + ResultSet rs0 = null; + ResultSet rs = null; + InputStream input = null; + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + System.out.println("读取数据库配置文件=====>"+input); + Properties pro = new Properties(); + pro.load(input); + + String revisionID=itemRevision.getProperty("item_revision_id"); + TCComponent[] Revisions=itemRevision.getItem().getReferenceListProperty("revision_list"); + + //查看选中目标是否是第一次打开,是新修订的版本就把最新版本的数据复制给他 + System.out.println("CONTROLPLANSELECT"+pro.getProperty("CONTROLPLANSELECT")); +// System.out.println("meprocess.getUid():"+meprocess.getUid()); +// System.out.println("itemRevision.getUid():"+itemRevision.getUid()); + String sql0 = String.format(pro.getProperty("CONTROLPLANSELECT"), + meprocess.getItem().getUid(),comp.getUid()); + System.out.println("sql0:"+sql0); + rs0 = SqlUtilT.read(sql0); + System.out.println("revisionID====>"+revisionID); + System.out.println("Revisions====>"+Revisions); + if(!revisionID.equals("A")&&!rs0.next()) { + System.out.println("不是第一版本!!!"); + List> addData=new ArrayList>(); + + char revID=revisionID.toCharArray()[0]; + String lastRevID=Character.toString(--revID); + String lastRevUid=""; + for(TCComponent rev:Revisions) { + if(rev.getProperty("item_revision_id").equals(lastRevID)) { + lastRevUid=rev.getUid(); + break; + } + } + + System.out.println("lastRevID========>"+lastRevID); + System.out.println("lastRevUid========>"+lastRevUid); + try { + String sql = String.format(pro.getProperty("CONTROLPLANSELECT"), + meprocess.getItem().getUid(),lastRevUid); + SqlUtilT.getTCConnection(); + rs = SqlUtilT.read(sql); + System.out.println("上个版本的数据===>"+sql); + while (rs.next()) { + System.out.println("===查询上个版本的数据插入==="); + List dataList=new ArrayList(); + dataList.add(UUID.randomUUID().toString().replace("-", "")); + dataList.add(rs.getString("PROCESSPUID")); + dataList.add(rs.getString("PROCESSID")); + dataList.add(comp.getUid()); + dataList.add(rs.getString("LJGCBH")); + dataList.add(rs.getString("GCMC")); + dataList.add(rs.getString("JQZHJJGZ")); + dataList.add(rs.getString("BH"));//5 + dataList.add(rs.getString("CP")); + dataList.add(rs.getString("GC")); + dataList.add(rs.getString("TSTXFL")); + dataList.add(rs.getString("CPGC")); + dataList.add(rs.getString("JSCLJS"));//10 + dataList.add(rs.getString("XM")); + dataList.add(rs.getString("RL")); + dataList.add(rs.getString("PL")); + dataList.add(rs.getString("ZRR")); + dataList.add(rs.getString("KZFF"));//15 + dataList.add(rs.getString("FYJH"));//查找编号 + dataList.add(rs.getString("NO"));//uid + dataList.add(rs.getString("ZF6_HH"));//uid + dataList.add(rs.getString("ZF6_HBDYG"));//uid + dataList.add(rs.getString("ZF6_HHC"));//uid + + + addData.add(dataList); + } + + + System.out.println("插入新版本表格数据:"+addData); + for(int i=0;i dataList=new ArrayList(); + dataList=addData.get(i); + String[] data=dataList.toArray(new String[]{}); + String insertSQL = pro.getProperty("INSERTSQL"); + SqlUtilT.getTCConnection(); + SqlUtilT.write2(data, insertSQL); + + } + SqlUtilT.connection.commit(); + + System.out.println("插入新版本表头数据"); + String sql1 = String.format(pro.getProperty("CONTROLPLANHEADSELECT"), + lastRevUid); + ResultSet rs2= SqlUtilT.read(sql1); + System.out.println("更新版本时查询上个表头数据sql======>"+sql1); + if(rs2.next()) {//插入初始表头数据 + List newHeadList = new ArrayList(); + String PLMEID=UUID.randomUUID().toString().replace("-", ""); + newHeadList.add(PLMEID); + newHeadList.add(comp.getUid()); + newHeadList.add(rs2.getString("type"));//类型 + newHeadList.add(rs2.getString("kzjhbh")); + newHeadList.add(rs2.getString("zylxr")); + newHeadList.add(rs2.getString("bzriq")); + newHeadList.add(rs2.getString("xdrq")); + newHeadList.add(rs2.getString("ljbh")); + newHeadList.add(rs2.getString("hxxz")); + newHeadList.add(rs2.getString("gkgcpz")); + newHeadList.add(rs2.getString("ljmc")); + newHeadList.add(rs2.getString("gfpzrq")); + newHeadList.add(rs2.getString("gkzlpz")); + newHeadList.add(rs2.getString("zzdm")); + newHeadList.add(rs2.getString("qtpz")); + newHeadList.add(rs2.getString("qtpzrq")); + System.out.println("更新版本时查询上个表头数据======>"+newHeadList); + String[] data=newHeadList.toArray(new String[]{}); + //System.out.println("数组data===>"+Arrays.toString(data)); + String insertSQL = "insert into ZF6_CONTROLPLANHEAD values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + SqlUtilT.write2(data, insertSQL); + SqlUtilT.connection.commit(); + } + }catch (Exception e) { + MessageBox.post(e.toString(), "错误", MessageBox.ERROR); + e.printStackTrace(); + }finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + + //重新导入对象要同步更新bom数据 + if(isReimport) { + System.out.println("========重新导入======="); + SqlUtilT.getTCConnection(); + ResultSet rsData = null; + String sql13 = String.format(pro.getProperty("CONTROLPLAN_IDTONO"), comp.getUid()); + rsData = SqlUtilT.read(sql13); + while (rsData.next()) { + MEOPIDToNO.put(rsData.getString("PROCESSID"), rsData.getString("NO")); + meoplist.add(rsData.getString("PROCESSID")); + + } + SqlUtilT.free(rsData); + + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow"); + TCComponentBOMWindow view = winType.create(null); + TCComponentBOMLine line = view.setWindowTopLine(meprocess.getItem(), meprocess, null, null); + AIFComponentContext[] childs = line.getChildren(); + Map meopIDtoNO=new HashMap(); + Map meopIDtoName=new HashMap(); + List meops=new ArrayList(); + for (int i = 0; i < childs.length; i++) { + InterfaceAIFComponent comp = childs[i].getComponent(); + if(comp instanceof TCComponentBOMLine) { + TCComponentBOMLine ziLine = (TCComponentBOMLine) comp; + TCComponentItemRevision ziRev = ziLine.getItemRevision();//工序 + String id = ziRev.getStringProperty("item_id");//工序id + String name = ziRev.getStringProperty("object_name")+ziRev.getStringProperty("zf6_ywfy");//工序名称 + String NO = ziLine.getStringProperty("bl_sequence_no"); + meopIDtoNO.put(id, NO); + meopIDtoName.put(id, name); + meops.add(id); + } + } + + //删除数据数据 + for(int i=0;i> addData=new ArrayList>(); + System.out.println("=====插入初始数据=========="); + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow"); + TCComponentBOMWindow view = winType.create(null); + TCComponentBOMLine line = view.setWindowTopLine(meprocess.getItem(), meprocess, null, null); + AIFComponentContext[] childs = line.getChildren(); + for (int i = 0; i < childs.length; i++) { + List dataList=new ArrayList(); + InterfaceAIFComponent comp = childs[i].getComponent(); + if(comp instanceof TCComponentBOMLine) { + TCComponentBOMLine ziLine = (TCComponentBOMLine) comp; + TCComponentItemRevision ziRev = ziLine.getItemRevision();//工序 + String id = ziRev.getStringProperty("item_id");//工序id + String name = ziRev.getStringProperty("object_name")+ziRev.getStringProperty("zf6_ywfy"); + meopNameToID.put(name, id); + dataList.add(UUID.randomUUID().toString().replace("-", ""));//0plmeid + dataList.add(meprocess.getItem().getUid());//1工艺uid + dataList.add(id);//2工序ID +// dataList.add(id); +// dataList.add(name); + dataList.add(itemRevision.getUid());//3 + dataList.add("");//4 + dataList.add(name);//5 + dataList.add("");//6 + dataList.add("1");//7 + dataList.add("");//8 + dataList.add("");//9 + dataList.add("");//10 + dataList.add("");//11 + dataList.add("");//12 + dataList.add("");//13 + dataList.add("");//14 + dataList.add("");//15 + dataList.add("");//16 + dataList.add("");//17 + dataList.add("");//18 + dataList.add(ziLine.getStringProperty("bl_sequence_no"));//19查找编号 + dataList.add(String.valueOf(i));//20 + dataList.add("");//21 + dataList.add("");//22 + //dataList.add(itemRevision.getUid());//选择的对象的puid放在数据库的REVISIONID中 + + addData.add(dataList); + } + } + System.out.println("addDataaddData====>"+addData); + + for(int i=0;i dataList=new ArrayList(); + dataList=addData.get(i); + String[] data=dataList.toArray(new String[]{}); + String insertSQL = pro.getProperty("INSERTSQL"); + System.out.println("插入第"+i+"条数据:"+insertSQL); + SqlUtilT.getTCConnection(); + SqlUtilT.write2(data, insertSQL); + SqlUtilT.connection.commit(); + } + + getData(); + } + progressBar.setValue(15); + //++++++++ + + + //没发布的版本要同步bom更新 + // if(!isRelease) { + // CollectControlPlan collectControlPlan = new CollectControlPlan(session, item.getType().toUpperCase(), meprocess); + // SaveControlPlan saveControlPlan = new SaveControlPlan(session, meprocess,comp); + // saveControlPlan.insertData(); + // } + // progressBar.setValue(20); + +// getData(); + getHeadData(); + getCombineMap(); + // getControlPlanCompleteUser(); + //打印combineMap合并数据 +// for (int[] name : combineMap.keySet()) { +// String key = Arrays.toString(name); +// String value = Arrays.toString(combineMap.get(name)); +// System.out.println("===>"+key + " " + value); +// } + // if (properties == null) { + // return; + // } + //properties[0].getPropertyValue() + //判断是否完成 +// if(processRows.size() > 0 && dataList.get(processRows.get(0)).get(16).toString().equals("1")) +// { +// meopIsComplete = true; +// } + progressBar.setValue(100); +// + + System.out.println("dataList++++>"+dataList); + System.out.println("HeadList++++>"+HeadList); + new Thread() { + @Override + public void run() { + try { + System.out.println("=====打开窗口======"); + TMom004SetControlPlanDialog dislog = new TMom004SetControlPlanDialog( + app, session, processRows,labelRows, item,itemRevision, meprocess.getItem(), + combineMap, dataList,meopId,plmeidList,HeadList, isOwning,UID,meopNameToID,comp); + frame.dispose(); + } catch (Exception e2) { + // TODO: handle exception + } + + } + }.start(); + super.executeModal(); + + } + +} diff --git a/src/com/connor/zf/controlplan/TMom004SetControlPlanDialog.java b/src/com/connor/zf/controlplan/TMom004SetControlPlanDialog.java new file mode 100644 index 0000000..51b289c --- /dev/null +++ b/src/com/connor/zf/controlplan/TMom004SetControlPlanDialog.java @@ -0,0 +1,3406 @@ +package com.connor.zf.controlplan; + +import java.awt.BorderLayout; +import javax.swing.*; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; + +import java.awt.*; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.StringReader; +import java.util.Enumeration; +import java.util.EventObject; +import java.util.Vector; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.io.BufferedInputStream; +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.StringReader; +import java.sql.ResultSet; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Properties; +import java.util.ResourceBundle; +import java.util.Timer; +import java.util.TimerTask; +import java.util.UUID; + +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import javax.swing.event.TableModelEvent; +import javax.swing.event.TableModelListener; +import javax.swing.table.TableRowSorter; + + +//import org.apache.axis2.databinding.types.soapencoding.Array; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +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.services.rac.core.ReservationService; + +public class TMom004SetControlPlanDialog extends JFrame implements ActionListener { + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCProperty[] properties; + private ControlPlanBean controlPlanBean; + private TMomControlPlanBean tMomControlPlanBean; + private CTMap map; + static JScrollPane scrollPane; + private Timer timer; + private String[] ZF6_KZJH_TSTX_strs; + private String[] ZF6_KZJH_XM_strs; + // private String[] header = new + // String[]{"PLM
EID","零件/工
艺编号","过程名称","机器,设备
,工装,夹具","气泡图编号","尺寸","产品","过程" + // ,"特殊特
性分类","产品/过程/
规格/公差","评估/测
量方法","容量","频率","负责人","控制方法" + // ,"操作规范/
记录表单
编号","反应计划"};ljgybh04_display.TITLE + + + private String[] header = new String[] {"PLMEID","零件/过程编号", "过程名称/操作描述", + "机器、装置、夹具、工装", "编号", "产品","过程","特殊特性分类", "产品/过程/规范/公差", + "计算测量技术", "项目","容量","频率","责任人", "控制方法","反应计划","查找编号" }; + + private String[] header2 = new String[] { "PLMEID", "ID", "机器、装置、夹具、工装", "编号", + "产品","过程","特殊特性分类", "产品/过程/规范/公差", "计算测量技术", + "项目","容量","频率","责任人", "控制方法","反应计划"}; + + private String[] thesaurusHeader = new String[] { "PLMEID", "序号", + "值","父节点ID" }; + + private String[] leftHeader = new String[] { "PLMEID", "ID", + "名称"}; + +// private String[] header = new String[] { "PLMEID", "零件/工艺编号", "过程名称", +// "机器,设备,工装,夹具", "首末检验/作业准备", "编号", +// "产品", "过程","特殊特性分类", +// "产品/过程/规格/公差", "评估/测量方法", "容量", +// "频率", "控制方法", "反应计划", +// "特殊符号位置", "是否完成" }; +// +// private String[] header2 = new String[] { "PLMEID", "ID", "机器,设备,工装,夹具", +// "首末检验/作业准备", "编号", "产品", +// "过程", "特殊特性分类", "产品/过程/规格/公差", +// "评估/测量方法","容量", "频率", +// "控制方法", "反应计划", "父节点ID", +// "特殊字符所在位置" }; +// private String[] thesaurusHeader = new String[] { "PLMEID", "序号", +// "值", "父节点ID" }; +// private String[] completeUserHeader = new String[] { "对象ID", "工序编号", "工序名称", "类型", "用户名", "完成情况", "完成日期" }; +// private String[] leftHeader = new String[] { "PLMEID", "ID", +// "名称", "名称" }; + private Map combineMap;// 存放合并单元格 + private TCComponent item;// 选中对象 + private TCComponentItemRevision itemRevision;// 选中对象 + private TCComponentItem meprocess;// 选中所在的工艺 + // private List> processRowList;//当前用户可修改的行号 + private List processRows;// 当前用户可修改的行号 + private Map> labelRows;// 标注行 + private List> dataList; +// private List> completeDataList;// 已完成的人员数据 + private List plmeidList;// plmeid + private List meopId;// 工序编号 + private List deleteRows = new ArrayList(); + // private TextAreaCellEditor textAreaCellEditor; + private SpecialDialog specialDialog; + private LibraryDialog libraryDialog; + private ThesaurusDialog thesaurusDialog; + private TreeBean bean; + private Properties pro = new Properties(); + private boolean isComplete = false; + private boolean isOwning; + private int selectRow = -1; + private int selectColumn = -1; + // 判断单元格显示框是否获取焦点 + private boolean isFocusOwner = false; + + // 界面所需控件 + private JPanel titlePanel;// 标题 + private JLabel titleLabel; + + private JPanel mainPanel;// 属性填写 + + private JPanel checkPanel;// 单选按钮 + private JRadioButton scCheckBox;// 生产 + private JRadioButton sscCheckBox;// 试生产 + private JRadioButton yjCheckBox;// 样件 + + private JPanel panel1;// 第一行属性 + private JLabel kzjhbhLabel;// 控制计划编号 + private CTextField kzjhbhField; + private JLabel zylxrLabel;// 主要联系人/电话 + private CTextField zylxrField; + private JLabel bzriqLabel;// 日期(编制) + private DateButton bzriqField; + private JLabel xdrqLabel;// 日期(修订) + private DateButton xdrqField;// 日期(修订) + + private JPanel panel2;// 第二行属性 + private JLabel ljbhLabel;// 零件编号/最新更改等级 + private CTextField ljbhField; + private JLabel hxxzLabel;// 核心小组 + private CTextField hxxzField; + private JLabel gkgcpzLabel;// 顾客工程批准/日期 + private DateButton gkgcpzField; + + private JPanel panel3;// 第三行属性 + private JLabel ljmcLabel;// 零件名称/描述 + private CTextField ljmcField; + private JLabel gcpzrqLabel;// 组织/工厂批准/日期 + private DateButton gcpzrqField; + private JLabel gkzlpzLabel;// 顾客质量批准/日期 + private DateButton gkzlpzField; + + private JPanel panel4;// 第四行属性 + private JLabel zzdmLabel;// 组织代码 + private CTextField zzdmField; +// private JLabel gfdhLabel;// 供方代号 +// private CTextField gfdhField; + private JLabel qtpzLabel;// 其他批准/日期 + private DateButton qtpzField; + private JLabel qtpzrqLabel;// 其他批准日期 + private DateButton qtpzrqField; + + private JPanel topPanel;// 第一行的属性和复选框 + + // 显示选中单元格内容 + private JTextPane showValuePane; + private JPanel tablePanel;// 表格控件 + private TableCellTextAreaRenderer renderer;// 渲染器 + private static CTable table; + // 任务完成情况 + private CTable completeUserTable;// 控制计划完成情况 + + // 右键菜单 + private static JPopupMenu menu; + // 右键菜单项 + private JMenuItem addRowItem; + private JMenuItem addRowsItem; + private JMenuItem addItem; + private JMenuItem addCombineRowsItem; + private JMenuItem addMeopItem; + private JMenuItem remItem; + private JMenuItem comBineItem; + private JMenuItem splitItem; + private JMenuItem shrinkColumnItem; + private JMenuItem celShrinkColumnItem; + private JMenuItem testItem;// 测试菜单 + // private JMenuItem deleteSpecialItem; + private JPanel rootPanel;// 按钮 + private JButton saveButton;// 保存 + private JButton completeButton;// 完成 + private JButton refButton;// 重新加载 + // private JButton deleteSpecialButton;// 移除特殊符号 + // private JButton addSpecialButton;// 添加特殊符号 + private JButton libraryButton;// 打开控制计划库 + private JButton thesaurusButton;// 打开词库 + private String UID; + private JPanel centerPanel; + private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-M-dd"); + private List HeadList = new ArrayList();//表头数据 + private Map meopNameToID = new HashMap();//工序名称与ID + public TMom004SetControlPlanDialog(AbstractAIFApplication app, TCSession session, List processRows, + Map> labelRows,TCComponent item, TCComponentItemRevision itemRevision, TCComponent meprocess, Map combineMap, List> dataList, + List meopId, List plmeidList,List HeadList ,boolean isOwning,String UID,Map meopNameToID,InterfaceAIFComponent comp) { + super(); + // this.processRowList = processRowList; + this.processRows = processRows; + this.labelRows = labelRows; + this.dataList = dataList; +// this.completeDataList = completeDataList; + this.plmeidList = plmeidList; + this.meopId = meopId; + this.combineMap = combineMap; + this.item = item; + this.itemRevision = itemRevision; + this.meprocess = (TCComponentItem) meprocess; + this.app = app; + this.session = session; + this.isOwning = isOwning; + this.UID=UID; + this.comp = comp; + this.HeadList=HeadList; + this.meopNameToID=meopNameToID; + System.out.println("jinrule "); + init(); + //runTask();//自动保存 + comBine(); + } + + public void comBine() {//合并单元格 + // TODO Auto-generated method stub + if (combineMap != null && combineMap.size() != 0) { + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + map.combine(entry.getKey(), entry.getValue()); + } + } + } + + private void init() { + System.out.println("======>1"); + this.setTitle("填写控制计划"); + this.setPreferredSize(new Dimension(1100, 650)); + this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); + Toolkit kit = Toolkit.getDefaultToolkit(); //定义工具包 + Dimension screenSize = kit.getScreenSize(); //获取屏幕的尺寸 + int screenWidth = screenSize.width; //获取屏幕的宽 + int screenHeight = screenSize.height; //获取屏幕的高 + this.setLocation(screenWidth / 2 - 1100 / 2, screenHeight / 2 - 650 / 2);//设置窗口居中显示 + this.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + if(!isOwning) { + TMom004SetControlPlanDialog.this.dispose(); + }else { + int i = JOptionPane.showConfirmDialog(null, "是否保存?", "保存", JOptionPane.YES_NO_OPTION); + if (i == JOptionPane.YES_OPTION) { + okEvent(false); + TMom004SetControlPlanDialog.this.dispose(); + } else if (i == JOptionPane.NO_OPTION) { + TMom004SetControlPlanDialog.this.dispose(); + } + } + + } + }); + // 初始化标题部分控件 + this.titlePanel = new JPanel(); + this.titleLabel = new JLabel("控制计划 CONTROL PLAN"); + this.titleLabel.setFont(new Font("宋体", 1, 18)); + this.titlePanel.add(titleLabel); + // 初始化菜单部分控件 + //MessageBox.post(itemRevision.toString(), "错误", MessageBox.ERROR); + this.yjCheckBox = new JRadioButton("样件"); + //this.yjCheckBox.setSelected(item.getType().toUpperCase().equals("RB3_YJKZJH")); + this.sscCheckBox = new JRadioButton("试生产"); + this.sscCheckBox.setSelected(item.getType().toUpperCase().equals("RB3_SSCKZJH")); + this.scCheckBox = new JRadioButton("生产"); + this.scCheckBox.setSelected(item.getType().toUpperCase().equals("RB3_SCKZJH")); + if(HeadList.get(2).equals("样件")) { + this.yjCheckBox.setSelected(true); + }else if(HeadList.get(2).equals("试生产")) { + this.sscCheckBox.setSelected(true); + }else if(HeadList.get(2).equals("生产")) { + this.scCheckBox.setSelected(true); + }else { + this.sscCheckBox.setSelected(true); + } + ButtonGroup group = new ButtonGroup(); + group.add(this.yjCheckBox); + group.add(this.sscCheckBox); + group.add(this.scCheckBox); + this.checkPanel = new JPanel(new BorderLayout()); + this.checkPanel.setPreferredSize(new Dimension(180, 50)); + this.checkPanel.setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.checkPanel.add(scCheckBox, BorderLayout.EAST); + this.checkPanel.add(sscCheckBox, BorderLayout.CENTER); + this.checkPanel.add(yjCheckBox, BorderLayout.WEST); + System.out.println("======>2"); + this.panel1 = new JPanel(new PropertyLayout()); + this.panel1.setPreferredSize(new Dimension(800, 50)); + this.kzjhbhLabel = new JLabel("控制计划编号"); + this.kzjhbhLabel.setPreferredSize(new Dimension(150, 20)); + this.kzjhbhLabel.setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.kzjhbhField = new CTextField(HeadList.get(3)); + this.kzjhbhField.setPreferredSize(new Dimension(150, 20)); + this.zylxrLabel = new JLabel("主要联系人/电话"); + this.zylxrLabel.setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.zylxrLabel.setPreferredSize(new Dimension(150, 20)); + this.zylxrField = new CTextField(HeadList.get(4)); + this.zylxrField.setPreferredSize(new Dimension(150, 20)); + this.bzriqLabel = new JLabel("编制日期"); + this.bzriqLabel.setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.bzriqLabel.setPreferredSize(new Dimension(150, 20)); + this.bzriqField = new DateButton(dateFormat); + this.bzriqField.setText(HeadList.get(5)); + this.bzriqField.setPreferredSize(new Dimension(150, 20)); + this.xdrqLabel = new JLabel("修订日期"); + this.xdrqLabel.setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.xdrqLabel.setPreferredSize(new Dimension(150, 20)); + this.xdrqField = new DateButton(dateFormat); + this.xdrqField.setText(HeadList.get(6)); + this.xdrqField.setPreferredSize(new Dimension(150, 20)); + this.ljbhLabel = new JLabel("零件编号/最新更改等级"); + this.ljbhLabel.setPreferredSize(new Dimension(150, 20)); + this.ljbhLabel.setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.ljbhField = new CTextField(HeadList.get(7)); + this.ljbhField.setPreferredSize(new Dimension(150, 20)); + this.panel1.add("1.1.left.top", kzjhbhLabel); + this.panel1.add("1.2.left.top", zylxrLabel); + this.panel1.add("1.3.left.top", bzriqLabel); + this.panel1.add("1.4.left.top", xdrqLabel); + this.panel1.add("1.5.left.top", ljbhLabel); + + this.panel1.add("2.1.left.top", kzjhbhField); + this.panel1.add("2.2.left.top", zylxrField); + this.panel1.add("2.3.left.top", bzriqField); + this.panel1.add("2.4.left.top", xdrqField); + this.panel1.add("2.5.left.top", ljbhField); + + this.topPanel = new JPanel(new PropertyLayout()); + this.topPanel.add("1.1.left.top", this.checkPanel); + this.topPanel.add("1.2.left.top", this.panel1); + System.out.println("======>3"); + + + + this.panel2 = new JPanel(new PropertyLayout()); + this.panel2.setPreferredSize(new Dimension(980, 50)); + this.hxxzLabel = new JLabel("核心小组"); + this.hxxzLabel.setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.hxxzLabel.setPreferredSize(new Dimension(330, 20)); + this.hxxzField = new CTextField(HeadList.get(8)); + this.hxxzField.setPreferredSize(new Dimension(330, 20)); + this.gkgcpzLabel = new JLabel("顾客工程批准/日期"); + this.gkgcpzLabel.setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.gkgcpzLabel.setPreferredSize(new Dimension(200, 20)); + this.gkgcpzField = new DateButton(dateFormat); + this.gkgcpzField.setText(HeadList.get(9)); + this.gkgcpzField.setPreferredSize(new Dimension(200, 20)); + this.gkzlpzLabel = new JLabel("顾客质量批准/日期"); + this.gkzlpzLabel.setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.gkzlpzLabel.setPreferredSize(new Dimension(200, 20)); + this.gkzlpzField =new DateButton(dateFormat); + this.gkzlpzField.setText(HeadList.get(12)); + this.gkzlpzField.setPreferredSize(new Dimension(200, 20)); + this.gcpzrqLabel = new JLabel("组织/工厂批准/日期"); + this.gcpzrqLabel.setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.gcpzrqLabel.setPreferredSize(new Dimension(200, 20)); + this.gcpzrqField = new DateButton(dateFormat); + this.gcpzrqField.setText(HeadList.get(11)); + this.gcpzrqField.setPreferredSize(new Dimension(200, 20)); + + this.panel2.add("1.1.left.top", hxxzLabel); + this.panel2.add("1.2.left.top", gkgcpzLabel); + this.panel2.add("1.3.left.top", gkzlpzLabel); + this.panel2.add("1.4.left.top", gcpzrqLabel); + + this.panel2.add("2.1.left.top", hxxzField); + this.panel2.add("2.2.left.top", gkgcpzField); + this.panel2.add("2.3.left.top", gkzlpzField); + this.panel2.add("2.4.left.top", gcpzrqField); + System.out.println("======>3.1"); + + + + this.panel3 = new JPanel(new PropertyLayout()); + this.panel3.setPreferredSize(new Dimension(980, 50)); + this.ljmcLabel = new JLabel("零件名称/描述"); + this.ljmcLabel.setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.ljmcLabel.setPreferredSize(new Dimension(230, 20)); + this.ljmcField = new CTextField(HeadList.get(10)); + this.ljmcField.setPreferredSize(new Dimension(230, 20)); + this.zzdmLabel = new JLabel("组织代码"); + this.zzdmLabel.setPreferredSize(new Dimension(300, 20)); + this.zzdmLabel.setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.zzdmField = new CTextField(HeadList.get(13)); + this.zzdmField.setPreferredSize(new Dimension(300, 20)); + this.qtpzLabel = new JLabel("其它批准/日期(如需要)"); + this.qtpzLabel.setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.qtpzLabel.setPreferredSize(new Dimension(200, 20)); + this.qtpzField = new DateButton(dateFormat); + this.qtpzField.setText(HeadList.get(14)); + this.qtpzField.setPreferredSize(new Dimension(200, 20)); + this.qtpzrqLabel = new JLabel("其它批准/日期(如需要)"); + this.qtpzrqLabel.setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.qtpzrqLabel.setPreferredSize(new Dimension(200, 20)); + this.qtpzrqField = new DateButton(dateFormat); + this.qtpzrqField.setText(HeadList.get(15)); + this.qtpzrqField.setPreferredSize(new Dimension(200, 20)); + + + panel3.add("1.1.left.top", ljmcLabel); + panel3.add("1.2.left.top", zzdmLabel); + panel3.add("1.3.left.top", qtpzLabel); + panel3.add("1.4.left.top", qtpzrqLabel); + + panel3.add("2.1.left.top", ljmcField); + panel3.add("2.2.left.top", zzdmField); + panel3.add("2.3.left.top", qtpzField); + panel3.add("2.4.left.top", qtpzrqField); + System.out.println("======>3.2"); + + + this.mainPanel = new JPanel(new PropertyLayout()); + this.mainPanel.setPreferredSize(new Dimension(1000, 250)); + this.mainPanel.add("1.1.left.top", topPanel); + this.mainPanel.add("2.1.left.top", panel2); + this.mainPanel.add("3.1.left.top", panel3); + System.out.println("======>4"); + // JPanel showValuePanel = new JPanel(); + this.showValuePane = new JTextPane(); + this.showValuePane.addFocusListener(new FocusListener() { + @Override + public void focusLost(FocusEvent focusevent) { + // TODO Auto-generated method stub + +// if(selectRow != -1 && selectColumn != -1) +// { +// System.out.println("选中行===="+selectRow+",选中列====="+selectColumn+",值====="+showValuePane.getText()); +// table.setValueAt(showValuePane.getText(), selectRow, selectColumn); +// } +// if(this.row == -1 && this.column == -1) +// { +// return; +// } +// System.out.println("设置行:"+this.row+"设置列"+this.column+"值:"+showValuePane.getText()); + } + + @Override + public void focusGained(FocusEvent focusevent) { + // TODO Auto-generated method stub + + isFocusOwner = true; + // if(table.) +// this.row = table.getSelectedRow(); +// this.column = table.getSelectedColumn(); +// if(this.row == -1 || this.column == -1 || table.getValueAt(table.getSelectedRow(), table.getSelectedColumn()) == null) +// { +// showValuePane.setText(""); +// } +// else +// { +// System.out.println("选中行:"+this.row+"选中列"+this.column+"值:"+table.getValueAt(table.getSelectedRow(), table.getSelectedColumn()).toString()); +// showValuePane.setText(table.getValueAt(table.getSelectedRow(), table.getSelectedColumn()).toString()); +// } + } + }); + showValuePane.setPreferredSize(new Dimension(800, 40)); + // JScrollPane js = new JScrollPane(this.showValuePane); + // showValuePanel.add(js); + System.out.println("======>5"); + this.tablePanel = new JPanel(new BorderLayout()); + this.table = getjTable(null, null, header, null); + //设置表格列宽 + for(int i=0;i3&&j5"); + //++++切换单元格超出保存字数的添加监听 + this.table.getModel().addTableModelListener(new TableModelListener() { + @Override + public void tableChanged(TableModelEvent e) { + if (e.getType() == TableModelEvent.UPDATE){ + int row = table.getSelectedRow(); + int col = table.getSelectedColumn(); + if(row>-1&&col>-1) { + // String value=(String) table.getValueAt(row, col).toString(); + String value= String.valueOf(table.getValueAt(row, col));//可以将null值转化 + //System.out.println("修改后=>" + value.getBytes().length); + // int ddd=value.getBytes().length; + if(value.getBytes().length>512) { + table.setValueAt(subStringByte(value,512), row, col); + MessageBox.post("第"+(row+1)+"行,"+col+"列数据"+"填写超出字数,已将超出字段删除,请重新检查。", "错误", MessageBox.ERROR); + } + } + if(col==7) { + boolean is=false; + for(int i=0;i6"); + // 初始化右键菜单 + // 右键菜单 + menu = new JPopupMenu(); + // 添加行 + addRowItem = new JMenuItem("添加行"); + addRowsItem = new JMenuItem("添加多行"); + addItem = new JMenuItem("添加合并行"); + addCombineRowsItem = new JMenuItem("添加多个合并行"); + addMeopItem = new JMenuItem("添加工序"); + comBineItem = new JMenuItem("合并行"); + splitItem = new JMenuItem("拆分合并单元格"); + remItem = new JMenuItem("移除整行"); + shrinkColumnItem = new JMenuItem("缩小选中列"); + celShrinkColumnItem = new JMenuItem("取消缩小选中列"); + testItem = new JMenuItem("填写标准"); + // deleteSpecialItem = new JMenuItem("移除特殊符号"); + if(isOwning) { + menu.add(addRowItem); + menu.add(addRowsItem); + menu.add(addItem); + menu.add(addCombineRowsItem); + menu.add(remItem); + menu.add(comBineItem); + menu.add(splitItem); + menu.add(shrinkColumnItem); + menu.add(celShrinkColumnItem); + } + System.out.println("======>7"); + // menu.add(testItem); + // menu.add(deleteSpecialItem); + + this.rootPanel = new JPanel(new FlowLayout()); +// this.addButton = new JButton("添加"); +// this.remButton = new JButton("移除"); +// this.comBinebutton = new JButton("合并"); +// this.splitButton = new JButton("拆分"); + this.saveButton = new JButton("保存"); + if (isOwning) { + this.completeButton = new JButton("导出控制计划"); + } else { + this.completeButton = new JButton("导出控制计划"); + } + // this.addSpecialButton = new JButton("添加特殊符号"); + // this.deleteSpecialButton = new JButton("移除特殊符号"); + this.libraryButton = new JButton("控制计划库"); + this.thesaurusButton = new JButton("词库"); + this.refButton = new JButton("重新加载"); + // this.sendbutton = new JButton("导出"); + // this.sendbutton.addActionListener(this); +// this.rootPanel.add(addButton); +// this.rootPanel.add(remButton); +// this.rootPanel.add(comBinebutton); +// this.rootPanel.add(splitButton); + +// if (isOwning) { +// this.rootPanel.add(completeButton); +// } else if (!meopIsComplete) { +// this.rootPanel.add(completeButton); +// } + //++++ + if (isOwning) { + this.rootPanel.add(saveButton); + this.rootPanel.add(completeButton); + this.rootPanel.add(refButton); + this.rootPanel.add(libraryButton); + //this.rootPanel.add(thesaurusButton); + } else { + this.rootPanel.add(completeButton); + setPanelEnabled(mainPanel,false); + setPanelEnabled(panel1,false); + } + //++++ + System.out.println("======>8"); + + // 任务完成情况 +// JPanel completeUserTablePanel = new JPanel(new BorderLayout()); +// this.completeUserTable = getNewjTable(null, null, completeUserHeader, completeDataList.size()); +// this.completeUserTable.setRowHeight(30); +// for (int j = 0; j < completeDataList.size(); j++) { +// for (int k = 0; k < completeDataList.get(j).size(); k++) { +// this.completeUserTable.setValueAt(completeDataList.get(j).get(k), j, k); +// } +// } + // 添加滚动条 +// JScrollPane scrollPane1 = new JScrollPane(this.completeUserTable); +// scrollPane1.getVerticalScrollBar().setUnitIncrement(10); +// completeUserTablePanel.add(scrollPane1, BorderLayout.CENTER); + + JPanel centerPanel = new JPanel(new BorderLayout()); + centerPanel.add(titlePanel, BorderLayout.NORTH); + centerPanel.add(mainPanel, BorderLayout.CENTER); + centerPanel.setPreferredSize(new Dimension(1000, 230)); + + JSplitPane showSeleceCellValuePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT); + showSeleceCellValuePanel.setOneTouchExpandable(true);// 让分割线显示出箭头 + showSeleceCellValuePanel.setContinuousLayout(true);// 操作箭头,重绘图形 + showSeleceCellValuePanel.setTopComponent(new JScrollPane(showValuePane)); + showSeleceCellValuePanel.setBottomComponent(tablePanel); + +// JPanel showSeleceCellValuePanel = new JPanel(new BorderLayout()); +// showSeleceCellValuePanel.add(new JScrollPane(showValuePane),BorderLayout.NORTH); +// showSeleceCellValuePanel.add(tablePanel,BorderLayout.CENTER); + + // JPanel centerPanel2 = new JPanel(new BorderLayout()); + // centerPanel2.add(centerPanel,BorderLayout.NORTH); + // centerPanel2.add(tablePanel, BorderLayout.CENTER); + System.out.println("======>9"); + JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); + splitPane.setOneTouchExpandable(true);// 让分割线显示出箭头 + splitPane.setContinuousLayout(true);// 操作箭头,重绘图形 + //splitPane.setTopComponent(centerPanel); + splitPane.setBottomComponent(showSeleceCellValuePanel); + +// JSplitPane splitPane2 = new JSplitPane(); +// splitPane2.setOneTouchExpandable(true);// 让分割线显示出箭头 +// splitPane2.setContinuousLayout(true);// 操作箭头,重绘图形 +// splitPane2.setLeftComponent(splitPane); +// splitPane2.setRightComponent(completeUserTablePanel); + System.out.println("======>10"); + // 添加鼠标监听 + this.createActionEvent(); + this.setLayout(new BorderLayout()); + this.add(centerPanel, BorderLayout.NORTH); + + this.add(splitPane, BorderLayout.CENTER); + // dialog.add(tablePanel, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + System.out.println("======>11"); + this.pack(); + this.show(); + } + + // 添加监听 + public void createActionEvent() { + this.addRowItem.addActionListener(this); + this.addRowsItem.addActionListener(this); + this.addItem.addActionListener(this); + this.addCombineRowsItem.addActionListener(this); + this.addMeopItem.addActionListener(this); + this.remItem.addActionListener(this); + this.comBineItem.addActionListener(this); + this.splitItem.addActionListener(this); + this.shrinkColumnItem.addActionListener(this); + this.celShrinkColumnItem.addActionListener(this); + this.testItem.addActionListener(this); + this.saveButton.addActionListener(this); + this.refButton.addActionListener(this); + // this.addSpecialButton.addActionListener(this); + this.libraryButton.addActionListener(this); + this.thesaurusButton.addActionListener(this); + // this.deleteSpecialItem.addActionListener(this); + this.completeButton.addActionListener(this); + } + + /** + * 写入数据到Jtable中 + */ + private void setJTable() { + for (int i = 0; i < dataList.size(); i++) { + List rowList = dataList.get(i); + System.out.println("rowList===>"+rowList); + for (int j = 0; j < header.length; j++) { + map.setValueAt(rowList.get(j), i, j); + } + } + } + + //设置控件权限 + public void setPanelEnabled(JPanel panel, boolean enabled) { + for (int i = 0; i < panel.getComponentCount(); i++) { + if (panel.getComponent(i) instanceof JPanel) { + JPanel chidPanel = (JPanel) panel.getComponent(i); + for (int j = 0; j < chidPanel.getComponentCount(); j++) { + + chidPanel.getComponent(j).setEnabled(enabled);//一行 + if (chidPanel.getComponent(j) instanceof MultiComboBox) { + MultiComboBox multiComboBox = (MultiComboBox) chidPanel.getComponent(j); + multiComboBox.editor.enable(enabled); + if(enabled) {multiComboBox.popup.show();}else {multiComboBox.popup.hide();} + } + if (chidPanel.getComponent(j) instanceof JScrollPane) { + JScrollPane scrollPane = (JScrollPane) chidPanel.getComponent(j); + JViewport jViewport = scrollPane.getViewport(); + jViewport.getView().setEnabled(enabled); + } + } + } + panel.getComponent(i).setEnabled(enabled); + if (panel.getComponent(i) instanceof MultiComboBox) { + MultiComboBox multiComboBox = (MultiComboBox) panel.getComponent(i); + + multiComboBox.editor.enable(enabled); + if(enabled) {multiComboBox.popup.show();}else {multiComboBox.popup.hide();} + } + if (panel.getComponent(i) instanceof JScrollPane) { + JScrollPane scrollPane = (JScrollPane) panel.getComponent(i); + JViewport jViewport = scrollPane.getViewport(); + jViewport.getView().setEnabled(enabled); + } + } + } + + // Jtable通用方法 + public CTable getjTable(CTable partsTable, DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + int simpleLen = 100; + int totleLen = 1000; + if (partsTable == null) { + this.map = new CTMap(dataList.size(), titleNames.length); + map.setColumnIdentifiers(titleNames); + + if (processRows != null && processRows.size() > 0) { + this.map.setProcessRowList(processRows); + } + if (labelRows != null && labelRows.size() > 0) { + this.map.setLabelRows(labelRows); + } + setJTable(); + partsTable = new CTable(map,session,true); + partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + Adapter adapter = new Adapter(partsTable); + // partsTable.setRowHeight(1, 50); + // partsTable.setRowHeight(2, 100); + partsTable.setRowHeight(50); + + // 隐藏列 + partsTable.HiddenCell(0); + partsTable.HiddenCell(titleNames.length - 1);//编号 +// partsTable.HiddenCell(titleNames.length - 2); +// partsTable.HiddenCell(titleNames.length - 3); + // 添加鼠标监听 + //将数据扩充到在表格上方可编辑 + partsTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if (mouseevent.getClickCount() == 1) { + map.setRow(table.getSelectedRow()); + map.setColumn(table.getSelectedColumn()); + + if (isFocusOwner && selectRow != -1 && selectColumn != -1) { + table.setValueAt(showValuePane.getText(), selectRow, selectColumn); + } + + // System.out.println("row="+table.getSelectedRow()+"column="+table.getSelectedColumn()); + if (table.getValueAt(table.getSelectedRow(), table.getSelectedColumn()) != null) { + showValuePane.setText(""); + showValuePane.setText( + table.getValueAt(table.getSelectedRow(), table.getSelectedColumn()).toString()); + } else { + showValuePane.setText(""); + } + + } + selectRow = table.getSelectedRow(); + selectColumn = table.getSelectedColumn(); + isFocusOwner = false; + + + if (mouseevent.getButton() == MouseEvent.BUTTON3) { + if(isOwning) { + menu.show(table, mouseevent.getX(), mouseevent.getY()); + } + } + } + }); + // //设置显示器渲染 + this.renderer = new TableCellTextAreaRenderer(); + this.renderer.setProcessRows(processRows); + this.renderer.setLabelRows(labelRows); + // //设置居中 + partsTable.setDefaultRenderer(Object.class, this.renderer); + // //设置编辑器渲染 + // this.textAreaCellEditor = new TextAreaCellEditor(); + // partsTable.setDefaultEditor(Object.class, + // this.textAreaCellEditor); + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + //发布了不让编辑 + if(!isOwning) { + partsTable.setEnabled(false); + } +// //++ +// MultiLineHeaderRenderer renderer = new MultiLineHeaderRenderer(); +// Enumeration e = partsTable.getColumnModel().getColumns(); +// while (e.hasMoreElements()) { +// ( (TableColumn) e.nextElement()).setHeaderRenderer(renderer); +// } +// //++ + return partsTable; + } + + + + + + // Jtable通用方法 + public CTable getNewjTable(CTable partsTable, DefaultTableModel dtm, Object[] titleNames, int rows) { + int simpleLen = 100; + int totleLen = 100; + if (partsTable == null) { + CTMap map = new CTMap(rows, titleNames.length); + map.setColumnIdentifiers(titleNames); + map.setEditable(false); + partsTable = new CTable(map,session,false); + // 设置显示器渲染 + TableCellTextAreaRenderer2 renderer = new TableCellTextAreaRenderer2(); + partsTable.setDefaultRenderer(Object.class, renderer); + // partsTable.setRowHeight(1, 50); + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + + @Override + public void dispose() { + // TODO Auto-generated method stub +// this.timer.cancel();/// labelRows completeDataList plmeidList meopId deleteRows +// dataList = null; +// processRows = null; +// labelRows = null; +// completeDataList = null; +// plmeidList = null; +// meopId = null; +// deleteRows = null; +// dataList.clear(); +// processRows.clear(); +// labelRows.clear(); +// completeDataList.clear(); +// plmeidList.clear(); +// meopId.clear(); +// deleteRows.clear(); + super.dispose(); + //关闭权限修改 + closePermission(); + } + + + //按照字节截取字符串 + public static String subStringByte(String source, int length) { + StringBuffer buffer = new StringBuffer(); + char[] chars = source.toCharArray(); + char c; + for (int i = 0;; i++) { + if (length <= 0) { + break; + } + c = source.charAt(i); + buffer.append(c); + length -= String.valueOf(c).getBytes().length; + if (i + 1 < chars.length) { + if (String.valueOf(chars[i + 1]).getBytes().length > length) { + break; + }; + } + } + return buffer.toString(); + } + + + + @Override + public void actionPerformed(ActionEvent arg0) { + Object source = arg0.getSource(); + if (source.equals(this.addRowItem)) { + int row = table.getSelectedRow(); + if ((this.processRows != null && this.processRows.size() != 0 && !(this.processRows.contains(row)))||!isOwning) { + MessageBox.post("无权限添加行!", "错误", MessageBox.ERROR); + return; + } + addRow(1); + } else if (source.equals(this.addRowsItem)) { + int row = table.getSelectedRow(); + if ((this.processRows != null && this.processRows.size() != 0 && !(this.processRows.contains(row)))||!isOwning) { + MessageBox.post("无权限添加行!", "错误", MessageBox.ERROR); + return; + } + AddRowsDialog addRowsDialog = new AddRowsDialog(source); + } else if (source.equals(this.addItem)) { + int row = table.getSelectedRow(); + if ((this.processRows != null && this.processRows.size() != 0 && !(this.processRows.contains(row)))||!isOwning) { + MessageBox.post("无权限添加行!", "错误", MessageBox.ERROR); + return; + } + addCombineRow(1); + } else if (source.equals(this.addCombineRowsItem)) { + int row = table.getSelectedRow(); + if ((this.processRows != null && this.processRows.size() != 0 && !(this.processRows.contains(row)))||!isOwning) { + MessageBox.post("无权限添加行!", "错误", MessageBox.ERROR); + return; + } + AddRowsDialog addRowsDialog = new AddRowsDialog(source); + } else if (source.equals(this.addMeopItem)) { + int row = table.getSelectedRow(); + if ((this.processRows != null && this.processRows.size() != 0 && !(this.processRows.contains(row)))||!isOwning) { + MessageBox.post("无权限添加工序!", "错误", MessageBox.ERROR); + return; + } + AddMeopDialog addRowsDialog = new AddMeopDialog(source); + } else if (source.equals(this.remItem)) { + if (table.getSelectedRow() > 0 && table.getSelectedColumn() > 0) { + (table.getCellEditor(table.getSelectedRow(), table.getSelectedColumn())).stopCellEditing(); + } + int[] rows = table.getSelectedRows(); + int i = JOptionPane.showConfirmDialog(null, "是否删除选中行?", "删除", JOptionPane.YES_NO_OPTION); + if (i != JOptionPane.YES_OPTION) { + return; + } + for (int i1 = 0; i1 < rows.length; i1++) { + if ((this.processRows != null && this.processRows.size() > 0 + && !(this.processRows.contains(table.getSelectedRow())))||!isOwning) { + MessageBox.post("无权限删除行!", "错误", MessageBox.ERROR); + return; + } + remRow(); + } + } else if (source.equals(this.comBineItem)) { + if (!isOwning) { + MessageBox.post("无权限合并单元格!", "错误", MessageBox.ERROR); + return; + } + comBineCell(); + } else if (source.equals(this.splitItem)) { + if (!isOwning) { + MessageBox.post("无权限拆分单元格!", "错误", MessageBox.ERROR); + return; + } + splitCell(); + } else if (source.equals(this.saveButton)) { + if (isOwning) { + okEvent(false); + }else { + MessageBox.post("已发布,无法保存!", "错误", MessageBox.ERROR); + return; + } + // this.dispose(); + } +// else if (source.equals(addSpecialButton)) { +// if (this.specialDialog == null) { +// System.out.println(table.getSelectedRow() + "===" +// + table.getSelectedColumn()); +// this.specialDialog = new SpecialDialog(); +// } else { +// System.out.println(table.getSelectedRow() + "===" +// + table.getSelectedColumn()); +// this.specialDialog.show(); +// } +// } + else if (source.equals(libraryButton)) { + if (this.libraryDialog == null) { + System.out.println(table.getSelectedRow() + "===" + table.getSelectedColumn()); + this.libraryDialog = new LibraryDialog(); + } else { + System.out.println(table.getSelectedRow() + "===" + table.getSelectedColumn()); + this.libraryDialog.show(); + } + } else if (source.equals(thesaurusButton)) { + if (this.thesaurusDialog == null) { + System.out.println(table.getSelectedRow() + "===" + table.getSelectedColumn()); + this.thesaurusDialog = new ThesaurusDialog(); + } else { + System.out.println(table.getSelectedRow() + "===" + table.getSelectedColumn()); + this.thesaurusDialog.show(); + } + } + else if (source.equals(shrinkColumnItem)) { + for (int i = 0; i < table.getSelectedColumns().length; i++) { + table.getColumnModel().getColumn(table.getSelectedColumns()[i]).setPreferredWidth(5); + } + table.revalidate(); + table.repaint(); + } else if (source.equals(celShrinkColumnItem)) { + for (int i = 0; i < table.getSelectedColumns().length; i++) { + table.getColumnModel().getColumn(table.getSelectedColumns()[i]).setPreferredWidth(100); + } + table.revalidate(); + table.repaint(); + } else if (source.equals(completeButton)) { + + if (isOwning) { + // this.disposeDialog(); + // 输出Excel + try { + okEvent(true); +// SaveControlPlan saveControlPlan = new SaveControlPlan(session, meprocess,app.getTargetComponent()); +// saveControlPlan.insertData(); +// this.tMomControlPlanBean = exchangeFormMsgToBean(); + File file = null; + //获取导出的表头数据 + List headValues=getHeadValues(); + List> tableValues=getTableValues(); + + String outFileName=""; + // TODO Auto-generated method stub + switch (headValues.get(0)) { + case "生产": + if (file == null) { + file = TMomMethodUtil.getFile(session, "生产控制计划", "MSExcelX","ZF6-GYGL-Template"); + } + outFileName = "生产控制计划"; + break; + case "试生产": + if (file == null) { + //试生产控制计划 + file = TMomMethodUtil.getFile(session, "试生产控制计划", "MSExcelX","ZF6-GYGL-Template"); + } + outFileName = "试生产控制计划"; + break; + case "样件": + if (file == null) { + file = TMomMethodUtil.getFile(session, "样件控制计划", "MSExcelX","ZF6-GYGL-Template"); + } + outFileName = "样件控制计划"; + break; + default: + break; + } + if (file == null) { + MessageBox.post("未找到控制计划模板!", "错误", MessageBox.ERROR); + return; + } + outFileName=((TCComponentItemRevision) comp).getStringProperty("item_id") + +((TCComponentItemRevision)comp).getStringProperty("object_name"); + //System.out.println(this.tMomControlPlanBean.toString()); + String outFilePath = System.getenv("TEMP") + "\\" + outFileName + ".xlsx"; + + outPutExcel.writeControlPlanToExcel(session,tableValues,headValues,file,outFilePath); + if (outPutExcel.getExcelToItem(session, (TCComponentItemRevision) comp, + "IMAN_specification", "MSExcelX") != null) { + outPutExcel.changeDataSet( + outPutExcel.getExcelToDataset(session, itemRevision, "IMAN_specification", "MSExcelX"), + "excel", "MSExcelX", outFilePath); + new File(outFilePath).delete(); + } else { + outPutExcel.setExcelToItem(session, itemRevision, outFilePath, outFileName, "IMAN_specification", + "MSExcelX", true); + } + MessageBox.post("导出Excel成功!", "成功", MessageBox.INFORMATION); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + this.dispose(); + + }else{ + MessageBox.post("已发布!", "错误", MessageBox.ERROR); + + } + + } else if (source.equals(refButton)) { + this.dispose(); + TMom004SetControlPlanCommand command = new TMom004SetControlPlanCommand(app,comp, session,UID,true); + try { + command.executeModal(); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (source.equals(testItem)) { + // 填写检测标准 + // 弹出词库框 + if (this.libraryDialog == null) { + System.out.println(table.getSelectedRow() + "===" + table.getSelectedColumn()); + this.libraryDialog = new LibraryDialog(); + } else { + System.out.println(table.getSelectedRow() + "===" + table.getSelectedColumn()); + this.libraryDialog.show(); + } + } else { + // this.disposeDialog(); + this.dispose(); + + } + } + + private List> getTableValues() { + // TODO Auto-generated method stub + List> tableValues=new ArrayList>(); + + // TODO Auto-generated method stub + ResultSet rs = null; + InputStream input = null; + try { + // 获取数据库连接 + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("CONTROLPLANSELECT"), + meprocess.getUid(),comp.getUid()); + rs = SqlUtilT.read(sql); + System.out.println("sql===>"+sql); + + while (rs.next()) { + List rowList = new ArrayList(); + rowList.add(rs.getString("LJGCBH"));//0 + rowList.add(rs.getString("GCMC"));//1 + rowList.add(rs.getString("JQZHJJGZ"));//2 + rowList.add(rs.getString("BH"));//3 + rowList.add(rs.getString("CP"));//4 + rowList.add(rs.getString("GC"));//5 + rowList.add(rs.getString("TSTXFL"));//6 + rowList.add(rs.getString("CPGC"));//7 + rowList.add(rs.getString("JSCLJS"));//8 + rowList.add(rs.getString("XM"));//9 + rowList.add(rs.getString("RL"));//10 + rowList.add(rs.getString("PL"));//11 + rowList.add(rs.getString("ZRR"));//12 + rowList.add(rs.getString("KZFF"));//13 + rowList.add(rs.getString("FYJH"));//14 + rowList.add(rs.getString("ZF6_HBDYG"));//15 + tableValues.add(rowList); + } + input.close(); + } catch (Exception e) { + MessageBox.post(e.toString(), "错误", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + return tableValues; + } + + private List getHeadValues() { + // TODO Auto-generated method stub + ResultSet rs = null; + InputStream input = null; + List headValues=new ArrayList(); + try { + // 获取数据库连接 + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("CONTROLPLANHEADSELECT"), + comp.getUid()); + System.out.println("sqlhead=====>"+sql); + rs = SqlUtilT.read(sql); + while(rs.next()) { + headValues.add(rs.getString("type"));//0 + headValues.add(rs.getString("kzjhbh"));//1 + headValues.add(rs.getString("zylxr"));//2 + headValues.add(rs.getString("bzriq"));//3 + headValues.add(rs.getString("xdrq"));//4 + headValues.add(rs.getString("ljbh"));//5 + headValues.add(rs.getString("hxxz"));//6 + headValues.add(rs.getString("gkgcpz"));//7 + headValues.add(rs.getString("ljmc"));//8 + headValues.add(rs.getString("gfpzrq"));//9 + headValues.add(rs.getString("gkzlpz"));//10 + headValues.add(rs.getString("zzdm"));//11 + headValues.add(rs.getString("qtpz"));//12 + headValues.add(rs.getString("qtpzrq"));//13 + } + + input.close(); + } catch (Exception e) { + MessageBox.post(e.toString(), "错误", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + return headValues; + } + + private List checkXLK() { + System.out.println("ZF6_KZJH_TSTX_strs====>"+Arrays.toString(ZF6_KZJH_TSTX_strs)); + System.out.println("ZF6_KZJH_TSTX_strs====>"+Arrays.toString(ZF6_KZJH_XM_strs)); + for(int i=0;i0) { + List ret=new ArrayList(); + ret.add(7); + ret.add(is); + return ret; + } + int isS=0; + for(int ii=0;ii0) { + List ret=new ArrayList(); + ret.add(10); + ret.add(isS); + return ret; + } + } + return null; + } + + + private void okEvent(boolean isAutoSave) { + //检查下拉框填写是否规范 + if(checkXLK()!=null) { + List result=checkXLK(); + System.out.println("=====///////>"+result); + if(result.get(0)==7) { + MessageBox.post("第"+result.get(1)+"行特殊特性分类列只能填写下拉框中的值!请先修改再保存。","错误",MessageBox.ERROR); + return; + }else { + MessageBox.post("第"+result.get(1)+"行项目列只能填写下拉框中的值!请先修改再保存。","错误",MessageBox.ERROR); + return; + } + + } + // TODO Auto-generated method stub + // 将数据保存到表单中 + try { + if(table.getRowCount()!=0) { + if(table.getValueAt(0,0)=="") { + MessageBox.post("操作失误,请退出重新操作","错误",MessageBox.ERROR); + return; + }} + if (table.getSelectedRow() >= 0 && table.getSelectedColumn() >= 0) { + (table.getCellEditor(table.getSelectedRow(), table.getSelectedColumn())).stopCellEditing(); + } + + + //+++获取表头数据++++ + if(yjCheckBox.isSelected()) { + HeadList.set(2, "样件"); + }else if(sscCheckBox.isSelected()) { + HeadList.set(2, "试生产"); + }else if(scCheckBox.isSelected()) { + HeadList.set(2, "生产"); + } + HeadList.set(3, kzjhbhField.getText()); + HeadList.set(4, zylxrField.getText()); + HeadList.set(5, bzriqField.getText()); + HeadList.set(6, xdrqField.getText()); + HeadList.set(7, ljbhField.getText()); + HeadList.set(8, hxxzField.getText()); + HeadList.set(9, gkgcpzField.getText()); + HeadList.set(10, ljmcField.getText()); + HeadList.set(11, gcpzrqField.getText()); + HeadList.set(12, gkzlpzField.getText()); + HeadList.set(13, zzdmField.getText()); + HeadList.set(14, qtpzField.getText()); + HeadList.set(15, qtpzrqField.getText()); + + + + //+++ + + // 获取JTable中的数据 + List> dataValeList = getTableValue(); + TMom004SetControlPlanOperation operation = new TMom004SetControlPlanOperation( this.meprocess, + this.session, properties, HeadList, dataValeList, deleteRows, plmeidList, isOwning, isAutoSave,app.getTargetComponent(),UID,meopNameToID); + operation.executeOperation(); + for (int j = 0; j < processRows.size(); j++) { + if (!plmeidList.contains(table.getValueAt(processRows.get(j), 0))) { + plmeidList.add(table.getValueAt(processRows.get(j), 0).toString()); + } + } + this.rootPanel.setBackground(Color.GREEN); + new Thread() { + @Override + public void run() { + try { + this.sleep(1000); + rootPanel.setBackground(Color.WHITE); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + }.start(); + } catch (Exception e) { + // TODO Auto-generated catch block + this.rootPanel.setBackground(Color.RED); + MessageBox.post(e.toString(), "错误", MessageBox.ERROR); + e.printStackTrace(); + } + } + + + //修改描述信息,关闭权限 + private void closePermission() { + if(isOwning) { + //关闭权限修改 + if(((TCComponent) comp).isCheckedOut()) { + ReservationService service=ReservationService.getService((TCSession)app.getSession()); + service.checkin(new TCComponent[] {(TCComponent) this.comp});//签入 + } + } + } + + private List> getTableValue() { + // TODO Auto-generated method stub + List> dataValeList = new ArrayList>(); + + for (int j = 0; j < processRows.size(); j++) { + List rowValue = new ArrayList(); + for (int j2 = 0; j2 < this.map.getColumnCount(); j2++) { + rowValue.add(getCellValue(processRows.get(j), j2)); + } + rowValue.add(processRows.get(j).toString());//17行号 + // rowValue.add("1"); + if (combineMap.size() > 0) { + rowValue.add(TMomMethodUtil.getCombineCell(combineMap, processRows.get(j)));//18合并单元格 + } else { + rowValue.add(""); + } + rowValue.add("");//19行号差 + dataValeList.add(rowValue); + } + // for (int i = 0; i < processRowList.size(); i++) { + // List rows = processRowList.get(i); + // } + return dataValeList; + } + + private String getCellValue(int row, int cloumn) { + // TODO Auto-generated method stub + String resultValue = ""; + if (combineMap != null && combineMap.size() > 0) { + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + List keysList = new ArrayList<>(); + List valuesList = new ArrayList<>(); + for (int k = 0; k < entry.getKey().length; k++) { + keysList.add(entry.getKey()[k]); + } + for (int k = 0; k < entry.getValue().length; k++) { + valuesList.add(entry.getValue()[k]); + } + if (keysList.contains(row) && valuesList.contains(cloumn)) { + return (String) this.map.getValueAt(Integer.parseInt(keysList.get(0).toString()), + Integer.parseInt(valuesList.get(0).toString())); + } + } + if (this.map.getValueAt(row, cloumn) != null) { + resultValue = this.map.getValueAt(row, cloumn).toString(); + } + } else { + if (this.map.getValueAt(row, cloumn) != null) { + return this.map.getValueAt(row, cloumn).toString(); + } + } + return resultValue; + } + + private String[] setCombineMap() { + String[] combines = new String[combineMap.size()]; + Iterator> it = combineMap.entrySet().iterator(); + int index = 0; + while (it.hasNext()) { + Map.Entry entry = it.next(); + StringBuffer rowSb = new StringBuffer(); + StringBuffer columnSb = new StringBuffer(); + for (int i = 0; i < entry.getKey().length; i++) { + rowSb.append(entry.getKey()[i]); + rowSb.append(","); + } + for (int i = 0; i < entry.getValue().length; i++) { + columnSb.append(entry.getValue()[i]); + columnSb.append(","); + } + combines[index] = rowSb.substring(0, rowSb.length() - 1) + "/" + + columnSb.substring(0, columnSb.length() - 1); + index++; + } + return combines; + } + + private int[] Union(int[] a1, int[] a2) { + List list1 = new ArrayList(); + List list2 = new ArrayList(); + for (int i : a1) { + list1.add(i); + } + for (int i : a2) { + list2.add(i); + } + list1.removeAll(list2); + list2.addAll(list1); + int[] result = new int[list2.size()]; + for (int i = 0; i < list2.size(); i++) { + result[i] = list2.get(i); + } + return result; + } + + /** + * 添加行 + */ + private void addRow(int index) { + // TODO Auto-generated method stub + Map cellMap = new HashMap(); + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + List keysList = new ArrayList<>(); + for (int j = 0; j < entry.getKey().length; j++) { + keysList.add(entry.getKey()[j]); + } + if (keysList.contains(table.getSelectedRow())) { + int[] newKey = new int[entry.getKey().length]; + for (int i = 0; i < entry.getKey().length; i++) { + for (int j = 0; j < entry.getValue().length; j++) { + map.split(entry.getKey()[i], entry.getValue()[j]); + } + newKey[i] = entry.getKey()[i]; + } + it.remove(); + // newKey[entry.getKey().length] = newKey[entry.getKey().length - 1] + 1; + cellMap.put(newKey, entry.getValue()); + } else if (!keysList.contains(table.getSelectedRow()) + && Integer.parseInt(keysList.get(0).toString()) > table.getSelectedRow()) { + int[] newKey = new int[entry.getKey().length]; + for (int i = 0; i < entry.getKey().length; i++) { + newKey[i] = entry.getKey()[i] + 1; + } + it.remove(); + cellMap.put(newKey, entry.getValue()); + } + } + map.insertRow(table.getSelectedRow() + 1); + table.setValueAt(table.getValueAt(table.getSelectedRow(), 1), table.getSelectedRow() + 1, 1);//添加行继承数据 + table.setValueAt(table.getValueAt(table.getSelectedRow(), 2), table.getSelectedRow() + 1, 2); + table.setValueAt(table.getValueAt(table.getSelectedRow(), 3), table.getSelectedRow() + 1, 3); + //table.setValueAt(table.getValueAt(table.getSelectedRow(), 4), table.getSelectedRow() + 1, 4); + //table.setValueAt("0", table.getSelectedRow() + 1, table.getColumnCount() - 3); + if (table.getValueAt(table.getSelectedRow(), 4) != null + && isStr2Num(table.getValueAt(table.getSelectedRow(), 4).toString())) { + table.setValueAt(Integer.parseInt(table.getValueAt(table.getSelectedRow(), 4).toString()) + index, + table.getSelectedRow() + 1, 4); + } else { + table.setValueAt(0 + index, table.getSelectedRow() + 1, 4); + } +// table.setValueAt(table.getValueAt(table.getSelectedRow(), table.getColumnCount() - 2), +// table.getSelectedRow() + 1, table.getColumnCount() - 2); + table.setValueAt(UUID.randomUUID().toString().replace("-", ""), table.getSelectedRow() + 1, 0); + table.setValueAt(table.getValueAt(table.getSelectedRow(), table.getColumnCount() - 1), + table.getSelectedRow() + 1, table.getColumnCount() - 1); + this.processRows = map.getProcessRowList(); + this.renderer.setProcessRows(processRows); + this.renderer.setLabelRows(map.getLabelRows()); + Iterator> cellIt = cellMap.entrySet().iterator(); + while (cellIt.hasNext()) { + Map.Entry entry = cellIt.next(); + map.combine(entry.getKey(), entry.getValue()); + combineMap.put(entry.getKey(), entry.getValue()); + } + table.revalidate(); + table.repaint(); + } + + /** + * 添加合并行 + */ + private void addCombineRow(int index) { + // TODO Auto-generated method stub + Map cellMap = new HashMap(); + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + List keysList = new ArrayList<>(); + for (int j = 0; j < entry.getKey().length; j++) { + keysList.add(entry.getKey()[j]); + } + if (keysList.contains(table.getSelectedRow())) { + int[] newKey = new int[entry.getKey().length + 1]; + for (int i = 0; i < entry.getKey().length; i++) { + for (int j = 0; j < entry.getValue().length; j++) { + map.split(entry.getKey()[i], entry.getValue()[j]); + } + newKey[i] = entry.getKey()[i]; + } + it.remove(); + newKey[entry.getKey().length] = newKey[entry.getKey().length - 1] + 1; + cellMap.put(newKey, entry.getValue()); + } else if (!keysList.contains(table.getSelectedRow()) + && Integer.parseInt(keysList.get(0).toString()) > table.getSelectedRow()) { + int[] newKey = new int[entry.getKey().length]; + for (int i = 0; i < entry.getKey().length; i++) { + newKey[i] = entry.getKey()[i] + 1; + } + it.remove(); + cellMap.put(newKey, entry.getValue()); + } + } + map.insertRow(table.getSelectedRow() + 1); + table.setValueAt(UUID.randomUUID().toString().replace("-", ""), table.getSelectedRow() + 1, 0); + table.setValueAt(table.getValueAt(table.getSelectedRow(), 1), table.getSelectedRow() + 1, 1); + table.setValueAt(table.getValueAt(table.getSelectedRow(), 2), table.getSelectedRow() + 1, 2); + table.setValueAt(table.getValueAt(table.getSelectedRow(), 3), table.getSelectedRow() + 1, 3); + //table.setValueAt("0", table.getSelectedRow() + 1, table.getColumnCount() - 3); + if (table.getValueAt(table.getSelectedRow(), 4) != null + && isStr2Num(table.getValueAt(table.getSelectedRow(), 4).toString())) { + table.setValueAt(Integer.parseInt(table.getValueAt(table.getSelectedRow(), 4).toString()) + index, + table.getSelectedRow() + 1, 4); + } else { + table.setValueAt(0 + index, table.getSelectedRow() + 1, 4); + } + table.setValueAt(table.getValueAt(table.getSelectedRow(), table.getColumnCount() - 2), + table.getSelectedRow() + 1, table.getColumnCount() - 2); + table.setValueAt(table.getValueAt(table.getSelectedRow(), table.getColumnCount() - 1), + table.getSelectedRow() + 1, table.getColumnCount() - 1); + this.processRows = map.getProcessRowList(); + this.renderer.setProcessRows(processRows); + this.renderer.setLabelRows(map.getLabelRows()); + Iterator> cellIt = cellMap.entrySet().iterator(); + while (cellIt.hasNext()) { + Map.Entry entry = cellIt.next(); + map.combine(entry.getKey(), entry.getValue()); + combineMap.put(entry.getKey(), entry.getValue()); + } + table.revalidate(); + table.repaint(); + } + + /** + * 移除行 + */ + private void remRow() { + // TODO Auto-generated method stub + Map cellMap = new HashMap(); + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + List keysList = new ArrayList<>(); + for (int j = 0; j < entry.getKey().length; j++) { + keysList.add(entry.getKey()[j]); + } + if (keysList.contains(table.getSelectedRow())) { + int[] newKey = new int[entry.getKey().length - 1]; + for (int i = 0; i < entry.getKey().length; i++) { + for (int j = 0; j < entry.getValue().length; j++) { + map.split(entry.getKey()[i], entry.getValue()[j]); + } + if (i < newKey.length) { + newKey[i] = entry.getKey()[i]; + } + } + it.remove(); + cellMap.put(newKey, entry.getValue()); + } else if (!keysList.contains(table.getSelectedRow()) + && Integer.parseInt(keysList.get(0).toString()) > table.getSelectedRow()) { + int[] newKey = new int[entry.getKey().length]; + for (int i = 0; i < entry.getKey().length; i++) { + for (int j = 0; j < entry.getValue().length; j++) { + map.split(entry.getKey()[i], entry.getValue()[j]); + } + newKey[i] = entry.getKey()[i] - 1; + } + it.remove(); + cellMap.put(newKey, entry.getValue()); + } + } + if (map.getValueAt(table.getSelectedRow(), 0) != null + && plmeidList.contains(map.getValueAt(table.getSelectedRow(), 0))) { + deleteRows.add(map.getValueAt(table.getSelectedRow(), 0).toString()); + } + map.removeRow(table.getSelectedRow()); + //this.processRows = map.getProcessRowList(); + this.renderer.setProcessRows(processRows); + this.renderer.setLabelRows(map.getLabelRows()); + Iterator> cellIt = cellMap.entrySet().iterator(); + while (cellIt.hasNext()) { + Map.Entry entry = cellIt.next(); + if (entry.getKey().length > 0 && entry.getValue().length > 0) { + map.combine(entry.getKey(), entry.getValue()); + combineMap.put(entry.getKey(), entry.getValue()); + } + } + table.revalidate(); + table.repaint(); + } + + /** + * 合并单元格 + */ + private void comBineCell() { + // TODO Auto-generated method stub + // table.setRowHeight(2, 50); + int[] rows = table.getSelectedRows(); + int[] columns = table.getSelectedColumns(); + //检查合并的单元格是否是同一个工序,根据编号是否相同来判断 + + if(rows.length>1) { + String Novalue=(String) table.getValueAt(rows[0], table.getColumnCount() - 1);//编号值 + System.out.println("编号值===>"+Novalue); + for(int row:rows) { + System.out.println("第"+row+"行当前编号值====>"+table.getValueAt(row, table.getColumnCount() - 1)); + if(!table.getValueAt(row, table.getColumnCount() - 1).equals(Novalue)) { + MessageBox.post("请勿将不同工序合并单元格!", "错误", MessageBox.ERROR); + return; + } + + } + } + + if (rows.length <= 0) { + MessageBox.post("请选择要合并的单元格!", "错误", MessageBox.ERROR); + return; + } + for (int i = 0; i < rows.length; i++) { + if (this.processRows != null && this.processRows.size() > 0 && !(this.processRows.contains(rows[i]))) { + MessageBox.post("无权限合并单元格", "错误", MessageBox.ERROR); + return; + } + } + if (combineMap != null && combineMap.size() != 0) { + for (int i = 0; i < rows.length; i++) { + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + List keysList = new ArrayList<>(); + for (int j = 0; j < entry.getKey().length; j++) { + keysList.add(entry.getKey()[j]); + } + if (keysList.contains(rows[i])) { + for (int j = 0; j < columns.length; j++) { + List valueList = new ArrayList<>(); + for (int k = 0; k < entry.getValue().length; k++) { + valueList.add(entry.getValue()[k]); + } + if (valueList.contains(columns[j])) { + columns = Union(columns, entry.getValue()); + rows = Union(rows, entry.getKey()); + if (combineMap.get(entry.getKey()) != null) { + it.remove(); + } + } + } + } + } + } + combineMap.put(rows, columns); + } else { + combineMap.put(rows, columns); + } + for (int i = 0; i < rows.length; i++) { + for (int j = 0; j < columns.length; j++) { + map.split(rows[i], columns[j]); + } + } + Arrays.sort(rows); + Arrays.sort(columns); + map.combine(rows, columns); + // map.removeRow(table.getSelectedRow()); + table.revalidate(); + table.repaint(); + } + + /** + * 拆分单元格 + */ + private void splitCell() { + // TODO Auto-generated method stub + int row = table.getSelectedRow(); + int colmn = table.getSelectedColumn(); + if (row < 0) { + MessageBox.post("请选择要拆分的单元格!", "错误", MessageBox.ERROR); + return; + } + if (this.processRows != null && this.processRows.size() > 0 && !(this.processRows.contains(row))) { + MessageBox.post("无权限拆分单元格!", "错误", MessageBox.ERROR); + return; + } + Map cellMap = new HashMap(); + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + List keysList = new ArrayList<>(); + List valuesList = new ArrayList<>(); + for (int j = 0; j < entry.getKey().length; j++) { + keysList.add(entry.getKey()[j]); + } + for (int j = 0; j < entry.getValue().length; j++) { + valuesList.add(entry.getValue()[j]); + } + if (keysList.contains(row) && valuesList.contains(colmn)) { + for (int i = 0; i < entry.getKey().length; i++) { + for (int j = 0; j < entry.getValue().length; j++) { + map.split(entry.getKey()[i], entry.getValue()[j]); + } + } + it.remove(); + } + } + + table.revalidate(); + table.repaint(); + } + + /** + * 将Form表单中的数据转化为bean中的数据 + * + * @param revMasterForm 表单 + * @return + * @throws TCException + */ + public TMomControlPlanBean exchangeFormMsgToBean() throws TCException, Exception { + TMomControlPlanBean controlPlanBean = new TMomControlPlanBean(); + + ResultSet rs = null; + try { + // 设置数组属性的值 + SqlUtilT.getTCConnection(); + String sql = String.format( + "SELECT RB3_GYBH,RB3_GCMC,RB3_JQSB,RB3_SMJY,RB3_QPTBH,RB3_CC,RB3_NO,RB3_CP,RB3_GC,RB3_TSTX,RB3_CPGC,RB3_CLFF,RB3_RL,RB3_PL,RB3_FZR,RB3_KZFF,RB3_CZGF,RB3_FYJH,RB3_HBDYG,RB3_SPECIAL,RB3_CONCEAL,NO FROM RB3_CONTROLPLAN where processpuid = \'%s\' and type = \'%s\' and REVISIONUID=\'%s\' order by to_number(NO),to_number(RB3_HH)", + meprocess.getUid(), item.getType().toUpperCase(),UID); + System.out.println(sql); + rs = SqlUtilT.read(sql); + List simpleBeanList = new ArrayList<>(); + while (rs.next()) { + TMomControlPlanSimpleBean bean = new TMomControlPlanSimpleBean(); + bean.setPartProcessNumber(rs.getString("RB3_GYBH"));// 零件工艺编号 + bean.setProcessName(rs.getString("RB3_GCMC"));// 过程名称 + bean.setMachineDevice(rs.getString("RB3_JQSB"));// 机器设备 + bean.setSmjy(rs.getString("RB3_SMJY"));// 首末检验 + bean.setBubbledPrintNo(rs.getString("RB3_QPTBH"));// 气泡图编号(可删除,RB3_QPTBH现在放的是编(序)号) + bean.setNo(rs.getString("RB3_QPTBH"));// 序号 + bean.setSize(rs.getString("RB3_CC"));// 5 尺寸 + bean.setProduct(rs.getString("RB3_CP"));// 产品 + bean.setProcess(rs.getString("RB3_GC"));// 过程 + bean.setSpecialClass(rs.getString("RB3_TSTX"));// 特殊分类 + bean.setProductProcessSpecificationTolerance(rs.getString("RB3_CPGC"));// 10 产品过程特殊分类公差 + bean.setEvaluationMeasurementTechnique(rs.getString("RB3_CLFF"));// 评估测量方法 + bean.setSampleSize(rs.getString("RB3_RL"));// 样品容量 + bean.setSampleFreq(rs.getString("RB3_PL"));// 15 样品频率 + bean.setResp(rs.getString("RB3_FZR"));// rs.getString("")负责人 + bean.setControlMethod(rs.getString("RB3_KZFF"));// 控制方法 + bean.setOperationCriteria(rs.getString("RB3_CZGF"));// 操作规范 + bean.setReactionPlan(rs.getString("RB3_FYJH"));// 反应计划 + bean.setHbdyg(rs.getString("RB3_HBDYG")); + bean.setSpecial(rs.getString("RB3_SPECIAL")); + bean.setConceal(rs.getString("RB3_CONCEAL")); + simpleBeanList.add(bean); + } + controlPlanBean.setSimpleBeanList(simpleBeanList); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + SqlUtilT.freeAll(); + } +// if (propValues[18] != null) { +// String[] strValues = propValues[18].getStringArrayValue(); +// if (strValues != null) { +// int valueCount = strValues.length; +// List simpleBeanList = new ArrayList<>(); +// for (int i = 0; i < valueCount; i++) { +// +// TMomControlPlanSimpleBean simpleBean = new TMomControlPlanSimpleBean(); +// simpleBeanList.add(simpleBean); +// } +// for (int i = 18; i < TMomControlPlanBean.PROP_COUNT_T; i++) { +// getSimpleBean(simpleBeanList, i, valueCount, propValues[i]); +// } +// controlPlanBean.setSimpleBeanList(simpleBeanList); +// } +// } + + return controlPlanBean; + } + + /** + * 查看一个字符串是否可以转换为数字 + * + * @param str 字符串 + * @return true 可以; false 不可以 + */ + public boolean isStr2Num(String str) { + try { + Integer.parseInt(str); + return true; + } catch (NumberFormatException e) { + return false; + } + } + + //++++ + /** + * 定时保存 + */ + public void runTask() { + timer = new Timer(); + timer.schedule(new TimerTask() { + + @Override + public void run() { + // TODO Auto-generated method stub + System.out.println("....."); + //okEvent(true);//自动保存 + + } + }, 300 * 1000, 300 * 1000); + //++++ +// final long timeInterval = 120000;// 两分钟运行一次 +// Runnable runnable = new Runnable() { +// public void run() { +// while (true) { +// // ------- code for task to run +// okEvent(); +// // ------- ends here +// try { +// Thread.sleep(timeInterval); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// } +// } +// } +// }; +// thread = new Thread(runnable); +// thread.start(); + } + + private class selectExportPath extends AbstractAIFDialog implements ActionListener { + // 界面控件 + private JPanel mainPanel; + private JFileChooser jfc; + private JButton okButton; + private JButton celButton; + private JButton fileButton; + private JTextField pathText; + private JTextField fleName; + private TMomControlPlanBean tMomControlPlanBean; + private File file; + public selectExportPath(TMomControlPlanBean tMomControlPlanBean,File file) { + this.tMomControlPlanBean=tMomControlPlanBean; + this.file=file; + init(); + } + + private void init() { + + // TODO Auto-generated method stub + this.setTitle("选择导出路径"); + this.setPreferredSize(new Dimension(480, 200)); + jfc = new JFileChooser(); + jfc.setCurrentDirectory(new File("c:\\"));// 文件选择器的初始目录定为d盘 + this.okButton = new JButton("导出"); + this.celButton = new JButton("取消"); + this.fileButton = new JButton("..."); + this.okButton.addActionListener(this); + this.celButton.addActionListener(this); + this.fileButton.addActionListener(this); + this.fileButton.setPreferredSize(new Dimension(50, 30)); + this.pathText = new JTextField(); + pathText.setText("C:"); + this.pathText.setPreferredSize(new Dimension(300, 30)); + fleName = new JTextField(); + fleName.setText("试生产控制计划"); + this.fleName.setPreferredSize(new Dimension(300, 30)); + + JLabel label = new JLabel("文件名称"); + label.setPreferredSize(new Dimension(100, 30)); + JLabel label2 = new JLabel("选择文件夹:"); + label2.setPreferredSize(new Dimension(100, 30)); + + JPanel panel1 = new JPanel(new FlowLayout()); + panel1.add(label); + panel1.add(fleName); + JPanel panel2 = new JPanel(new FlowLayout()); + panel2.add(label2); + panel2.add(pathText); + panel2.add(fileButton); + + this.mainPanel = new JPanel(new PropertyLayout()); + + this.mainPanel.add("1.1.left.top", panel1); + this.mainPanel.add("2.1.left.top", panel2); + + JPanel rootPanel = new JPanel(new FlowLayout()); + rootPanel.add(new JLabel(" ")); + rootPanel.add(new JLabel(" ")); + rootPanel.add(this.okButton); + rootPanel.add(new JLabel(" ")); + rootPanel.add(this.celButton); + + + this.setLayout(new BorderLayout()); + this.add(mainPanel, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + this.pack(); + // this.centerToScreen(); + this.showDialog(); + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + if (source.equals(this.fileButton)) { + selectFileButtonEvent(e); + } else if (source.equals(this.okButton)) { + + // 获取导出模板 + String outFilePath = this.pathText.getText() + "\\"+this.fleName.getText()+".xlsx"; + MessageBox.post("导出Excel成功!", "成功", MessageBox.INFORMATION); + this.dispose(); + } else if (source.equals(this.celButton)) { + this.dispose(); + } + } + + /** + * 文件夹选择按钮事件 + * + * @param e + */ + public void selectFileButtonEvent(ActionEvent e) { + jfc.setFileSelectionMode(1);// 设定只能选择到文件夹 + int state = jfc.showOpenDialog(null);// 此句是打开文件选择器界面的触发语句 + if (state == 1) { + return; + } else { + File f = jfc.getSelectedFile();// f为选择到的目录 + pathText.setText(f.getAbsolutePath()); + } + } + } + + + private class SpecialDialog extends JFrame implements ActionListener { + private JPanel tablePanel;// 表格控件 + private JTable table; + + private JPanel rootPanel;// 按钮 + private JButton okButton;// 确定 + private JButton celButton;// 取消 + + public SpecialDialog() { + // TODO Auto-generated constructor stub + super(); + init(); + } + + private void init() { + // TODO Auto-generated method stub + this.setTitle("选择特殊符号"); + this.table = getjTable(this.table, null, new Object[] { 1, 2, 3, 4, 5, 6, 7, 8 }, + new Object[][] { { 1, 2, 3, 4, 5, 6, 7, 8 }, { 9, 0, "q", "w", "e", "r", "t", "y" } }); + this.setLocationRelativeTo(this); + this.table.setRowHeight(30); + this.table.getTableHeader().setVisible(false); + this.table.setFont(new Font("Y14.5M", 0, 15)); + this.tablePanel = new JPanel(new BorderLayout()); + this.tablePanel.add(this.table); + + this.okButton = new JButton("确定"); + this.okButton.addActionListener(this); + this.celButton = new JButton("取消"); + this.celButton.addActionListener(this); + this.rootPanel = new JPanel(new FlowLayout()); + this.rootPanel.add(this.okButton); + this.rootPanel.add(this.celButton); + + this.add(this.tablePanel, BorderLayout.CENTER); + this.add(this.rootPanel, BorderLayout.SOUTH); + this.pack(); + this.show(); + } + + // Jtable通用方法 + public JTable getjTable(JTable partsTable, DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + int simpleLen = 100; + int totleLen = 1000; + if (partsTable == null) { + partsTable = new JTable(this.getTableModel(dtm, titleNames, values)); + partsTable.setCellSelectionEnabled(true); + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + + public DefaultTableModel getTableModel(DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + MyTableModel tableModel = null; + if (dtm == null) { + tableModel = new MyTableModel(values, titleNames); + } + return tableModel; + } + + @Override + public void actionPerformed(ActionEvent actionevent) { + // TODO Auto-generated method stub + Object source = actionevent.getSource(); + if (source.equals(this.okButton)) { + int row = TMom004SetControlPlanDialog.table.getSelectedRow(); + int column = TMom004SetControlPlanDialog.table.getSelectedColumn(); + // 保存特殊符号位置 + String columnName = TMom004SetControlPlanDialog.table + .getColumnName(TMom004SetControlPlanDialog.table.getSelectedColumn()); + + int cursorIndex = ((TextAreaCellEditor) (TMom004SetControlPlanDialog.table.getCellEditor(row, column))) + .getIndex(); + System.out.println("index+" + cursorIndex); + (TMom004SetControlPlanDialog.table.getCellEditor(row, column)).stopCellEditing(); + // TMom004SetControlPlanDialog.table.getDefaultEditor(Object.class).stopCellEditing(); + StringBuilder sb = new StringBuilder( + TMom004SetControlPlanDialog.table.getValueAt(row, column).toString()); + + // 定义循环,如果index的位置不是-1,就一直查找 + Integer index = 0; + while ((index = sb.toString().indexOf("\n", index)) != -1) { + + // 每循环一次就要明确下一次查找的位置 + index = index + "\n".length(); + // 每查找一次计数器自增 + cursorIndex++; + } + // 特殊符号 + Object special = TMom004SetControlPlanDialog.table.getValueAt(row, + TMom004SetControlPlanDialog.table.getColumnCount() - 1); + if (special == null || special.toString() == "") { + TMom004SetControlPlanDialog.table.setValueAt(columnName + "-" + cursorIndex, row, + TMom004SetControlPlanDialog.table.getColumnCount() - 1); + } else { + TMom004SetControlPlanDialog.table.setValueAt(special + "|" + columnName + "-" + cursorIndex, row, + TMom004SetControlPlanDialog.table.getColumnCount() - 1); + } + System.out.println(sb.length()); + String s = sb + .insert(cursorIndex, this.table + .getValueAt(this.table.getSelectedRow(), this.table.getSelectedColumn()).toString()) + .toString(); + TMom004SetControlPlanDialog.table.setValueAt(s, TMom004SetControlPlanDialog.table.getSelectedRow(), + TMom004SetControlPlanDialog.table.getSelectedColumn()); + System.out.println(TMom004SetControlPlanDialog.table.getValueAt(row, column).toString()); + } else { + this.dispose(); + } + } + } + + /** + * 控制计划库 + * + * @author Administrator + * + */ + private class LibraryDialog extends JFrame { + private List beans = new ArrayList(); + private int index = -1; + private TableRowSorter mainSorter; + // 界面所需控件 + private JPanel titlePanel;// 标题 + private JLabel titleLabel; + + private JTextPane selectCellValuePane; + // 查询框 + private JTextField findLeftField; + private JButton findLeftButton; + // 查询框 + private JTextField findMainField; + private JButton findMainButton; + // 导航栏 + private CTable leftTable; + private CTable mainTable; + // 右键菜单 + private JPopupMenu libraryMenu; + // 右键菜单项 + private JMenuItem copyRowItem;// 复制多行 + + // 标签控件 + // private JTabbedPane tabbedPane; + + public LibraryDialog() { + // TODO Auto-generated constructor stub + super(); + getTreeBeanData(); + // getData(); + init(); + } + + private void init() { + // TODO Auto-generated method stub + this.setTitle("控制计划库"); + this.setPreferredSize(new Dimension(850, 600)); + // 初始化标题部分控件 + this.titlePanel = new JPanel(); + this.titleLabel = new JLabel("CONTROL PLAN/控制计划"); + this.titleLabel.setFont(new Font("宋体", 1, 18)); + this.titlePanel.add(this.titleLabel); + + JPanel centerPanel = new JPanel(new BorderLayout()); + centerPanel.add(titlePanel, BorderLayout.NORTH); + + JPanel findLeftPanel = new JPanel(new PropertyLayout()); + this.findLeftField = new JTextField(); + this.findLeftField.setPreferredSize(new Dimension(100, 20)); + this.findLeftButton = new JButton("查找"); + findLeftPanel.add("1.1.left.top", this.findLeftField); + findLeftPanel.add("1.2.left.top", this.findLeftButton); + this.leftTable = getNewjTable(null, null, leftHeader, beans.size()); + // 隐藏列 + leftTable.HiddenCell(0); + leftTable.setRowHeight(30); + for (int i = 0; i < beans.size(); i++) { + this.leftTable.setValueAt(beans.get(i).getPlmeid(), i, 0); + this.leftTable.setValueAt(beans.get(i).getId(), i, 1); + this.leftTable.setValueAt(beans.get(i).getName(), i, 2); + } + final TableRowSorter sorter = new TableRowSorter(this.leftTable.getModel()); + this.leftTable.setRowSorter(sorter); // 为JTable设置排序器 + + this.findLeftButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if (findLeftField.getText().length() == 0) { + sorter.setRowFilter(null); + } else { + sorter.setRowFilter(RowFilter.regexFilter(findLeftField.getText()));// 为JTable设置基于正则表达式的过滤条件 + } + } + }); + leftTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { + @Override + public void valueChanged(ListSelectionEvent arg0) { + System.out.println("index====>"+index); + // TODO Auto-generated method stub + if (index == -1) { + refreshTable(); + index = leftTable.getSelectedRow(); + } else if (index != -1 && index != leftTable.getSelectedRow()) { + refreshTable(); + index = leftTable.getSelectedRow(); + } + } + }); + JPanel findMainPanel = new JPanel(new PropertyLayout()); + this.findMainField = new JTextField(); + this.findMainField.setPreferredSize(new Dimension(100, 20)); + this.findMainButton = new JButton("查找"); + findMainPanel.add("1.1.left.top", this.findMainField); + findMainPanel.add("1.2.left.top", this.findMainButton); + this.mainTable = getNewjTable(null, null, header2, 0); + // 隐藏列 + mainTable.HiddenCell(0); + mainTable.HiddenCell(header2.length - 1); + mainTable.setRowHeight(40); + mainSorter = new TableRowSorter(this.mainTable.getModel()); + this.mainTable.setRowSorter(mainSorter); // 为JTable设置排序器 + + this.findMainButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if (findMainField.getText().length() == 0) { + mainSorter.setRowFilter(null); + } else { + mainSorter.setRowFilter(RowFilter.regexFilter(findMainField.getText()));// 为JTable设置基于正则表达式的过滤条件 + } + } + }); + // 添加鼠标监听 + mainTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if (mouseevent.getClickCount() == 2) { + if (table.getSelectedRow() >= 0) { + table.getCellEditor(table.getSelectedRow(), table.getSelectedColumn()).stopCellEditing(); + for (int i = 2; i < mainTable.getColumnCount(); i++) { + if(i!=3) { + table.setValueAt(mainTable.getValueAt(mainTable.getSelectedRow(), i), + table.getSelectedRow(), i + 1); + } + + } + } + } + if (mouseevent.getClickCount() == 1) { + if (mainTable.getValueAt(mainTable.getSelectedRow(), mainTable.getSelectedColumn()) != null) { + selectCellValuePane.setText(mainTable + .getValueAt(mainTable.getSelectedRow(), mainTable.getSelectedColumn()).toString()); + } else { + selectCellValuePane.setText(""); + } + } + if (mouseevent.getButton() == MouseEvent.BUTTON3) { + libraryMenu.show(mainTable, mouseevent.getX(), mouseevent.getY()); + } + } + }); + Adapter adapter = new Adapter(mainTable); + JScrollPane scrollPane = new JScrollPane(mainTable); + scrollPane.getVerticalScrollBar().setUnitIncrement(2); + JScrollPane scrollPane2 = new JScrollPane(leftTable); + scrollPane2.setPreferredSize(new Dimension(150, 600)); + scrollPane2.getVerticalScrollBar().setUnitIncrement(2); + + JSplitPane splitPane2 = new JSplitPane(); + splitPane2.setOneTouchExpandable(true);// 让分割线显示出箭头 + splitPane2.setContinuousLayout(true);// 操作箭头,重绘图形 + splitPane2.setLeftComponent(scrollPane2); + splitPane2.setRightComponent(scrollPane); + // 右键菜单 + libraryMenu = new JPopupMenu(); + // 添加行 + copyRowItem = new JMenuItem("复制多行"); + copyRowItem.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent actionevent) { + // TODO Auto-generated method stub +// Component component = tabbedPane.getSelectedComponent(); +// if (component instanceof JScrollPane) { +// JScrollPane scrollPane = (JScrollPane) component; +// Component tableComponent = scrollPane.getViewport().getView(); +// if (tableComponent instanceof CTable) { + CTable jtable = mainTable; + for (int i = 0; i < jtable.getSelectedRows().length; i++) { + if (table.getSelectedRow() >= 0) { + table.getCellEditor(table.getSelectedRow(), table.getSelectedColumn()).stopCellEditing(); + for (int j = 1; j < jtable.getColumnCount(); j++) { + if (j == jtable.getColumnCount() - 2 || j == 1) { + continue; + } +// else if (j == jtable.getColumnCount() - 1) { +// table.setValueAt(jtable.getValueAt(jtable.getSelectedRows()[i], j), +// table.getSelectedRow() + i, j + 2); +// } + else { + table.setValueAt(jtable.getValueAt(jtable.getSelectedRows()[i], j), + table.getSelectedRow() + i, j + 1); + } + } + } + } + } +// } +// } + }); +// libraryMenu.add(copyRowItem); + + selectCellValuePane = new JTextPane(); + selectCellValuePane.setPreferredSize(new Dimension(500, 40)); + + JPanel southPanel = new JPanel(new PropertyLayout()); + southPanel.add("1.1.left.top", findLeftPanel); + southPanel.add("1.2.left.top", new JScrollPane(selectCellValuePane)); + southPanel.add("1.3.left.top", findMainPanel); + + this.setLayout(new BorderLayout()); + this.add(centerPanel, BorderLayout.NORTH); + this.add(splitPane2, BorderLayout.CENTER); + // dialog.add(tablePanel, BorderLayout.CENTER); + // this.add(new JScrollPane(selectCellValuePane), BorderLayout.SOUTH); + this.add(southPanel, BorderLayout.SOUTH); + this.pack(); + this.show(); + } + + private void refreshTable() { + // TODO Auto-generated method stub + // 刷新右侧数据 + ResultSet rs = null; + InputStream input = null; + try { + + SqlUtilT.getTCConnection(); + + String sql = String.format("select * from ZF6_CONTROLPLANLIBRARY where PARENTPLMEID = \'%s\' order by CAST(ID AS INT)", + leftTable.getValueAt(leftTable.getSelectedRow(), 0)); + System.out.println("查询数据库=====》"+sql); + rs = SqlUtilT.read(sql); + List> rowList = new ArrayList>(); + while (rs.next()) { + List list = new ArrayList(); + list.add(rs.getString("PLMEID")); + list.add(rs.getString("ID")); + list.add(rs.getString("JQZHJJGZ")); + list.add(rs.getString("BH")); + list.add(rs.getString("CP")); + list.add(rs.getString("GC")); + list.add(rs.getString("TSTXFL")); + list.add(rs.getString("CPGC")); + list.add(rs.getString("JSCLJS")); + list.add(rs.getString("XM")); + list.add(rs.getString("RL")); + list.add(rs.getString("PL")); + list.add(rs.getString("ZRR")); + list.add(rs.getString("KZFF")); + list.add(rs.getString("FYJH")); + rowList.add(list); + } + System.out.println("rowList====>"+rowList); + if (rowList.size() > 0) { + CTMap map = new CTMap(rowList.size(), header2.length); + map.setColumnIdentifiers(header2); + map.setEditable(true); + mainTable.setModel(map); + mainSorter = new TableRowSorter(map); + this.mainTable.setRowSorter(mainSorter); // 为JTable设置排序器 + for (int j = 0; j < rowList.size(); j++) { + System.out.println("========>添加第"+j+"行"); + for (int k = 0; k < rowList.get(j).size(); k++) { + mainTable.setValueAt(rowList.get(j).get(k), j, k); + } + } + } else { + CTMap map = new CTMap(1, header2.length); + map.setColumnIdentifiers(header2); + mainTable.setModel(map); + mainSorter = new TableRowSorter(map); + this.mainTable.setRowSorter(mainSorter); // 为JTable设置排序器 + map.setValueAt(leftTable.getValueAt(leftTable.getSelectedRow(), 1), 0, + mainTable.getColumnCount() - 1); + } + mainTable.HiddenCell(0); + mainTable.HiddenCell(header2.length - 1); + mainTable.invalidate(); + } catch (Exception e) { + // TODO: handle exception + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + + /** + * 获取数据库中的数据 + */ + private void getTreeBeanData() { + // TODO Auto-generated method stub + ResultSet rs = null; + try { + // 获取数据库连接 + SqlUtilT.getTCConnection(); + String sql = "select * from ZF6_CONTROLPLANLIBRARYTREE order by ID"; + rs = SqlUtilT.read(sql); + while (rs.next()) { + TreeBean bean = new TreeBean(); + bean.setPlmeid(rs.getString("PLMEID")); + bean.setId(rs.getString("ID")); + bean.setName(rs.getString("NAME")); + beans.add(bean); + } + Collections.sort(beans, new NaturalOrderComparator<>(true)); + beans.forEach(item -> System.out.println(item)); + // createTabbedPane(beans); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + + SqlUtilT.freeAll(); + } + } + + + } + + + class NaturalOrderComparator implements Comparator { + + private final boolean caseInsensitive; + + public NaturalOrderComparator(boolean caseInsensitive) { + this.caseInsensitive = caseInsensitive; + } + + private int compareRight(String a, String b) { + int bias = 0; + int ia = 0; + int ib = 0; + for (; ; ia++, ib++) { + char ca = charAt(a, ia); + char cb = charAt(b, ib); + + if (!Character.isDigit(ca) && !Character.isDigit(cb)) { + return bias; + } else if (!Character.isDigit(ca)) { + return -1; + } else if (!Character.isDigit(cb)) { + return +1; + } else if (ca < cb) { + if (bias == 0) { + bias = -1; + } + } else if (ca > cb) { + if (bias == 0) { + bias = +1; + } + } else if (ca == 0 && cb == 0) { + return bias; + } + } + } + + @Override + public int compare(T o1, T o2) { + + TreeBean bean1 = (TreeBean)o1; + TreeBean bean2 = (TreeBean)o2; + + String a = bean1.getId(); + String b = bean2.getId(); + int ia = 0, ib = 0; + int nza = 0, nzb = 0; + char ca, cb; + int result; + while (true) { + nza = nzb = 0; + ca = charAt(a, ia); + cb = charAt(b, ib); + + while (ca == '0') { + nza++; + if (!Character.isDigit(charAt(a, ia + 1))) { + break; + } + ca = charAt(a, ++ia); + } + while (cb == '0') { + nzb++; + if (!Character.isDigit(charAt(b, ib + 1))) { + break; + } + cb = charAt(b, ++ib); + } + + if (Character.isDigit(ca) && Character.isDigit(cb)) { + if ((result = compareRight(a.substring(ia), b.substring(ib))) != 0) { + return result; + } + } + if (ca == 0 && cb == 0) { + return nza - nzb; + } + if (ca < cb) { + return -1; + } else if (ca > cb) { + return +1; + } + ++ia; + ++ib; + } + } + + private char charAt(String s, int i) { + if (i >= s.length()) { + return 0; + } else { + return caseInsensitive ? Character.toUpperCase(s.charAt(i)) : s.charAt(i); + } + } + } + /** + * 词库 + * + * @author Administrator + * + */ + private class ThesaurusDialog extends JFrame { + + private List beans = new ArrayList(); + private int index = -1; + private TableRowSorter mainSorter; + // 界面所需控件 + private JPanel titlePanel;// 标题 + private JLabel titleLabel; + + private JButton other; + + // 查询框 + private JTextPane selectCellValuePane; + private JButton findButton; + // 导航栏 + private CTable leftTable; + private CTable mainTable; + + public ThesaurusDialog() { + // TODO Auto-generated constructor stub + getTreeBeanData(); + // getData(); + init(); + } + + private void init() { + // TODO Auto-generated method stub + this.setTitle("词库"); + this.setPreferredSize(new Dimension(800, 600)); + // 初始化标题部分控件 + this.titlePanel = new JPanel(); + this.titleLabel = new JLabel("词库"); + this.titleLabel.setFont(new Font("宋体", 1, 18)); + this.titlePanel.add(this.titleLabel); + + this.setAlwaysOnTop(true); + JPanel typePanel = new JPanel(); + other = new JButton("其他"); + other.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + String s = mainTable.getValueAt(mainTable.getSelectedRow(), 3).toString(); + String s2 = mainTable.getValueAt(mainTable.getSelectedRow(), 4).toString(); + AddStandard addStandard = new AddStandard(s, s2); + } + }); + // typePanel.add(other); + JPanel centerPanel = new JPanel(new BorderLayout()); + centerPanel.add(titlePanel, BorderLayout.NORTH); + centerPanel.add(typePanel, BorderLayout.SOUTH); + this.leftTable = getNewjTable(null, null, leftHeader, beans.size()); + // 隐藏列 + leftTable.HiddenCell(0); + leftTable.HiddenCell(3); + leftTable.setRowHeight(30); + leftTable.getColumnModel().getColumn(2) + .setPreferredWidth(200); + for (int i = 0; i < beans.size(); i++) { + this.leftTable.setValueAt(beans.get(i).getPlmeid(), i, 0); + this.leftTable.setValueAt(beans.get(i).getId(), i, 1); + this.leftTable.setValueAt(beans.get(i).getName(), i, 2); + this.leftTable.setValueAt(beans.get(i).getParentId(), i, 3); + } + leftTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { + @Override + public void valueChanged(ListSelectionEvent arg0) { + // TODO Auto-generated method stub + if (index == -1) { + refreshThesaurusTable(); + index = leftTable.getSelectedRow(); + } else if (index != -1 && index != leftTable.getSelectedRow()) { + refreshThesaurusTable(); + index = leftTable.getSelectedRow(); + } + } + }); + this.mainTable = getNewjTable(null, null, thesaurusHeader, 0); + // 隐藏列 + mainTable.HiddenCell(0); + mainTable.HiddenCell(thesaurusHeader.length - 1); + mainTable.setRowHeight(20); + mainTable.getColumnModel().getColumn(2) + .setPreferredWidth(300); + mainSorter = new TableRowSorter(this.mainTable.getModel()); + this.mainTable.setRowSorter(mainSorter); // 为JTable设置排序器 + this.findButton = new JButton("查找"); + this.findButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if (selectCellValuePane.getText().length() == 0) { + mainSorter.setRowFilter(null); + } else { + mainSorter.setRowFilter(RowFilter.regexFilter(selectCellValuePane.getText()));// 为JTable设置基于正则表达式的过滤条件 + } + } + }); + // 添加鼠标监听 + mainTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if (mouseevent.getClickCount() == 2) { + if (table.getSelectedRow() >= 0) { + System.out.println(leftTable.getValueAt(leftTable.getSelectedRow(), 3)); + if (leftTable.getValueAt(leftTable.getSelectedRow(), 2).equals("特殊符号")) { + int row = TMom004SetControlPlanDialog.table.getSelectedRow(); + int column = TMom004SetControlPlanDialog.table.getSelectedColumn(); + // 保存特殊符号位置 + String columnName = TMom004SetControlPlanDialog.table + .getColumnName(TMom004SetControlPlanDialog.table.getSelectedColumn()); + + int cursorIndex = ((TextAreaCellEditor) (TMom004SetControlPlanDialog.table + .getCellEditor(row, column))).getIndex(); + System.out.println("index+" + cursorIndex); + (TMom004SetControlPlanDialog.table.getCellEditor(row, column)).stopCellEditing(); + // TMom004SetControlPlanDialog.table.getDefaultEditor(Object.class).stopCellEditing(); + StringBuilder sb = new StringBuilder( + TMom004SetControlPlanDialog.table.getValueAt(row, column).toString()); + + // 定义循环,如果index的位置不是-1,就一直查找 + Integer index = 0; + while ((index = sb.toString().indexOf("\n", index)) != -1) { + + // 每循环一次就要明确下一次查找的位置 + index = index + "\n".length(); + // 每查找一次计数器自增 + cursorIndex++; + } + // 特殊符号 + Object special = TMom004SetControlPlanDialog.table.getValueAt(row, + TMom004SetControlPlanDialog.table.getColumnCount() - 1); + System.out.println(sb.length()); + String s = sb.insert(cursorIndex, + mainTable.getValueAt(mainTable.getSelectedRow(), mainTable.getSelectedColumn()) + .toString()) + .toString(); + TMom004SetControlPlanDialog.table.setValueAt(s, + TMom004SetControlPlanDialog.table.getSelectedRow(), + TMom004SetControlPlanDialog.table.getSelectedColumn()); + System.out + .println(TMom004SetControlPlanDialog.table.getValueAt(row, column).toString()); + } else { + table.getCellEditor(table.getSelectedRow(), table.getSelectedColumn()) + .stopCellEditing(); + table.setValueAt(mainTable.getValueAt(mainTable.getSelectedRow(), 2), + table.getSelectedRow(), table.getSelectedColumn()); + } + } + } + if (mouseevent.getClickCount() == 1) { + ((CTMap) mainTable.getModel()).setRow(mainTable.getSelectedRow()); + ((CTMap) mainTable.getModel()).setRow(mainTable.getSelectedColumn()); + if (mainTable.getValueAt(mainTable.getSelectedRow(), mainTable.getSelectedColumn()) != null) { + selectCellValuePane.setText(mainTable + .getValueAt(mainTable.getSelectedRow(), mainTable.getSelectedColumn()).toString()); + } else { + selectCellValuePane.setText(""); + } + } + } + }); + Adapter adapter = new Adapter(mainTable); + JScrollPane scrollPane = new JScrollPane(mainTable); + scrollPane.setPreferredSize(new Dimension(180, 600)); + scrollPane.getVerticalScrollBar().setUnitIncrement(2); + JScrollPane scrollPane2 = new JScrollPane(leftTable); + scrollPane2.setPreferredSize(new Dimension(300, 600)); + scrollPane2.getVerticalScrollBar().setUnitIncrement(2); + + JSplitPane splitPane2 = new JSplitPane(); + splitPane2.setOneTouchExpandable(true);// 让分割线显示出箭头 + splitPane2.setContinuousLayout(true);// 操作箭头,重绘图形 + splitPane2.setLeftComponent(scrollPane2); + splitPane2.setRightComponent(scrollPane); + selectCellValuePane = new JTextPane(); + selectCellValuePane.setPreferredSize(new Dimension(325, 20)); + + JPanel southPanel = new JPanel(new PropertyLayout()); + southPanel.add("1.1.left.top", new JScrollPane(selectCellValuePane)); + southPanel.add("1.2.left.top", findButton); + + this.setLayout(new BorderLayout()); + this.add(centerPanel, BorderLayout.NORTH); + this.add(splitPane2, BorderLayout.CENTER); + // dialog.add(tablePanel, BorderLayout.CENTER); + // this.add(new JScrollPane(selectCellValuePane), BorderLayout.SOUTH); + this.add(southPanel, BorderLayout.SOUTH); + this.pack(); + this.show(); + } + + /** + * 获取数据库中的数据 + */ + private void getTreeBeanData() { + // TODO Auto-generated method stub + ResultSet rs = null; + InputStream input = null; + try { + // 获取数据库连接 + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + pro.load(input); + String sql = String.format(pro.getProperty("TM2THESAURUSTREESELECT")); + // String sql = String.format("select * from RB3_CONTROLPLAN_TREE"); + rs = SqlUtilT.read(sql); + while (rs.next()) { + TreeBean bean = new TreeBean(); + bean.setPlmeid(rs.getString("PLMEID")); + bean.setId(rs.getString("ID")); + bean.setName(rs.getString("NAME")); + bean.setParentId(rs.getString("PARENT_ID")); + beans.add(bean); + } + // createTabbedPane(beans); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + + private void refreshThesaurusTable() { + // TODO Auto-generated method stub + // 刷新右侧数据 + ResultSet rs = null; + InputStream input = null; + try { + + SqlUtilT.getTCConnection(); + // 获取SQL语句 + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("TM2THESAURUSNODESELECT"), + leftTable.getValueAt(leftTable.getSelectedRow(), 1)); + rs = SqlUtilT.read(sql); + List> rowList = new ArrayList>(); + while (rs.next()) { + List list = new ArrayList(); + list.add(rs.getString("PLMEID")); + list.add(rs.getString("ID")); + list.add(rs.getString("RB3_VALUE")); + //list.add(rs.getString("RB3_VALUE2")); + //list.add(rs.getString("RB3_EXAMPLE")); + list.add(rs.getString("PARENT_ID")); + rowList.add(list); + } + if (rowList.size() > 0) { + CTMap map = new CTMap(rowList.size(), thesaurusHeader.length); + map.setColumnIdentifiers(thesaurusHeader); + map.setEditable(true); + mainTable.setModel(map); + mainTable.getColumnModel().getColumn(2) + .setPreferredWidth(300); + mainSorter = new TableRowSorter(map); + this.mainTable.setRowSorter(mainSorter); // 为JTable设置排序器 + for (int j = 0; j < rowList.size(); j++) { + for (int k = 0; k < rowList.get(j).size(); k++) { + if (k == rowList.get(j).size() - 2) { + mainTable.setValueAt(rowList.get(j).get(k + 1), j, k + 1); + } else if (k == rowList.get(j).size() - 1) { + mainTable.setValueAt(rowList.get(j).get(k - 1), j, k - 1); + } else { + mainTable.setValueAt(rowList.get(j).get(k), j, k); + } + } + } + } else { + CTMap map = new CTMap(1, thesaurusHeader.length); + map.setColumnIdentifiers(thesaurusHeader); + map.setEditable(true); + mainTable.setModel(map); + mainTable.getColumnModel().getColumn(2) + .setPreferredWidth(300); + mainSorter = new TableRowSorter(map); + this.mainTable.setRowSorter(mainSorter); // 为JTable设置排序器 + map.setValueAt(leftTable.getValueAt(leftTable.getSelectedRow(), 1), 0, + mainTable.getColumnCount() - 1); + } + mainTable.HiddenCell(0); + mainTable.HiddenCell(thesaurusHeader.length - 1); + mainTable.setRowHeight(30); + mainTable.invalidate(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + + } + + private class AddRowsDialog extends AbstractAIFDialog implements ActionListener { + + private JPanel panel; + private JLabel label; + private JTextField textField; + private JButton button; + + private Object source; + + public AddRowsDialog(Object source) { + super(); + this.source = source; + init(); + } + + private void init() { + this.panel = new JPanel(new PropertyLayout()); + this.label = new JLabel("插入行数"); + this.textField = new JTextField(20); + this.textField.addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(KeyEvent arg0) { + if (arg0.getKeyCode() == KeyEvent.VK_ENTER) { + okEvent(); + } else { + super.keyPressed(arg0); + } + } + }); + this.button = new JButton("确定"); + this.button.addActionListener(this); + this.panel.add("1.1.left.top", label); + this.panel.add("1.2.left.top", textField); + this.panel.add("1.3.left.top", button); + + this.add(this.panel, BorderLayout.CENTER); + this.pack(); + this.showDialog(); + } + + @Override + public void actionPerformed(ActionEvent actionevent) { + // TODO Auto-generated method stub + Object source = actionevent.getSource(); + if (source.equals(this.button)) { + okEvent(); + } + } + + private void okEvent() { + // TODO Auto-generated method stub + if (this.source.equals(addRowsItem)) { + if (!isStr2Num(textField.getText())) { + MessageBox.post("请输入正确的数字!", "错误!", MessageBox.ERROR); + return; + } + for (int i1 = Integer.parseInt(textField.getText()); i1 > 0; i1--) { + addRow(i1); + } + this.disposeDialog(); + this.dispose(); + } else if (this.source.equals(addCombineRowsItem)) { + if (!isStr2Num(textField.getText())) { + MessageBox.post("请输入正确的数字!", "错误!", MessageBox.ERROR); + return; + } + for (int i1 = Integer.parseInt(textField.getText()); i1 > 0; i1--) { + addCombineRow(i1); + } + this.disposeDialog(); + this.dispose(); + } + } + + } + + /** + * 添加标准 + * + */ + private class AddStandard extends AbstractAIFDialog implements ActionListener { + + private JPanel panel; + private JPanel rootPanel; + private JLabel label1; + private JTextField textField1; + private JLabel label2; + private JTextField textField2; + private JLabel label3; + private JTextField textField3; + private JLabel label4; + private JTextField textField4; + private JLabel label5; + private JTextField textField5; + + private JLabel labelStandard1; + private JLabel labelStandard2; + private JLabel labelExample1; + private JLabel labelExample2; + private JButton button; + + private String standard;// 标准 + + private String example;// 例子 + + public AddStandard(String standard, String example) { + super(); + this.standard = standard; + this.example = example; + init(); + } + + private void init() { + this.panel = new JPanel(new PropertyLayout()); + + List resultList = TMomMethodUtil.getListByRegular(standard); + this.label1 = new JLabel(resultList.get(0)); + this.label2 = new JLabel(resultList.get(1)); + this.label3 = new JLabel(resultList.get(2)); + this.label4 = new JLabel(resultList.get(3)); + + this.textField1 = new JTextField(20); + this.textField2 = new JTextField(20); + this.textField3 = new JTextField(20); + this.textField4 = new JTextField(20); + + this.labelStandard1 = new JLabel("标准"); + this.labelStandard2 = new JLabel(this.standard); + + this.labelExample1 = new JLabel("标准"); + this.labelExample2 = new JLabel(example); + + this.panel.add("1.1.left.top", label1); + this.panel.add("1.2.left.top", textField1); + + this.panel.add("2.1.left.top", label2); + this.panel.add("2.2.left.top", textField2); + + this.panel.add("3.1.left.top", label3); + this.panel.add("3.2.left.top", textField3); + + this.panel.add("4.1.left.top", label4); + this.panel.add("4.2.left.top", textField4); + + this.panel.add("5.1.left.top", labelStandard1); + this.panel.add("5.2.left.top", labelStandard2); + + this.panel.add("5.3.left.top", labelExample1); + this.panel.add("5.4.left.top", labelExample2); + + this.button = new JButton("确定"); + this.button.addActionListener(this); + + this.rootPanel = new JPanel(new BorderLayout()); + + this.rootPanel.add(button); + + this.add(this.panel, BorderLayout.CENTER); + this.add(this.rootPanel, BorderLayout.SOUTH); + this.pack(); + this.showDialog(); + } + + @Override + public void actionPerformed(ActionEvent actionevent) { + // TODO Auto-generated method stub + Object source = actionevent.getSource(); + if (source.equals(this.button)) { + okEvent(); + } + } + + private void okEvent() { + // TODO Auto-generated method stub + if (!this.label1.getText().isEmpty()) { + this.standard = this.standard.replace("[" + this.label1.getText() + "]", this.textField1.getText()); + } + if (!this.label2.getText().isEmpty()) { + this.standard = this.standard.replace("[" + this.label2.getText() + "]", this.textField2.getText()); + } + if (!this.label3.getText().isEmpty()) { + this.standard = this.standard.replace("[" + this.label3.getText() + "]", this.textField3.getText()); + } + if (!this.label4.getText().isEmpty()) { + this.standard = this.standard.replace("[" + this.label4.getText() + "]", this.textField4.getText()); + } + table.setValueAt(this.standard, table.getSelectedRow(), table.getSelectedColumn()); + } + + } + + private class AddMeopDialog extends AbstractAIFDialog implements ActionListener { + + private JPanel panel; +// private JLabel meopIDLabel; +// private JTextField meopIDTextField; + private JLabel idLabel; + private JTextField idTextField; + private JLabel nameLabel; + private JTextPane nameTextField; + private JPanel rootPanel; + private JButton okButton; + private JButton celButton; + + private Object source; + + public AddMeopDialog(Object source) { + // TODO Auto-generated constructor stub + super(); + this.source = source; + init(); + } + + private void init() { + // TODO Auto-generated method stub + this.panel = new JPanel(new PropertyLayout()); +// this.meopIDLabel = new JLabel("工序ID"); +// this.meopIDTextField = new JTextField(); +// this.idTextField.setPreferredSize(new Dimension(200,50)); + this.idLabel = new JLabel("零件/工艺编号"); + this.idTextField = new JTextField(); + this.idTextField.setPreferredSize(new Dimension(200, 20)); + this.nameLabel = new JLabel("过程名称"); + this.nameTextField = new JTextPane(); + this.nameTextField.setPreferredSize(new Dimension(200, 50)); +// this.panel.add("1.1.left.top", meopIDLabel); +// this.panel.add("1.2.left.top", meopIDTextField); + this.panel.add("1.1.left.top", idLabel); + this.panel.add("1.2.left.top", idTextField); + this.panel.add("2.1.left.top", nameLabel); + this.panel.add("2.2.left.top", nameTextField); + + this.rootPanel = new JPanel(); + this.okButton = new JButton("确定"); + this.okButton.addActionListener(this); + this.celButton = new JButton("取消"); + this.celButton.addActionListener(this); + this.rootPanel.add(okButton); + this.rootPanel.add(celButton); + + this.add(this.panel, BorderLayout.CENTER); + this.add(this.rootPanel, BorderLayout.SOUTH); + this.pack(); + this.showDialog(); + } + + @Override + public void actionPerformed(ActionEvent actionevent) { + // TODO Auto-generated method stub + Object source = actionevent.getSource(); + if (source.equals(this.okButton)) { + if (!isStr2Num(this.idTextField.getText())) { + MessageBox.post("请输入正确的数字!", "错误!", MessageBox.ERROR); + return; + } + if (this.nameTextField.getText() == null || this.nameTextField.getText().equals("")) { + MessageBox.post("请输入过程名称!", "错误!", MessageBox.ERROR); + return; + } +// if(this.meopIDTextField.getText() == null || this.meopIDTextField.getText().equals("")) +// { +// MessageBox.post("请输入工序ID!", "错误!", MessageBox.ERROR); +// return; +// } + + Map cellMap = new HashMap(); + Iterator> it = combineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + List keysList = new ArrayList<>(); + for (int j = 0; j < entry.getKey().length; j++) { + keysList.add(entry.getKey()[j]); + } + if (keysList.contains(table.getSelectedRow())) { +// int[] newKey = new int[entry.getKey().length ]; +// for (int i = 0; i < entry.getKey().length; i++) { +// for (int j = 0; j < entry.getValue().length; j++) { +// map.split(entry.getKey()[i], entry.getValue()[j]); +// } +// newKey[i] = entry.getKey()[i]; +// } +// it.remove(); +// //newKey[entry.getKey().length] = newKey[entry.getKey().length - 1] + 1; +// cellMap.put(newKey, entry.getValue()); + } else if (!keysList.contains(table.getSelectedRow()) + && Integer.parseInt(keysList.get(0).toString()) > table.getSelectedRow()) { + int[] newKey = new int[entry.getKey().length]; + for (int i = 0; i < entry.getKey().length; i++) { + newKey[i] = entry.getKey()[i] + 1; + } + it.remove(); + cellMap.put(newKey, entry.getValue()); + } + } + if (Integer.parseInt(table.getValueAt(table.getSelectedRow(), 1).toString()) > Integer + .parseInt(this.idTextField.getText())) { + map.insertRow(table.getSelectedRow()); + table.setValueAt(this.idTextField.getText(), table.getSelectedRow(), 1); + table.setValueAt(this.nameTextField.getText(), table.getSelectedRow(), 2); + table.setValueAt(table.getValueAt(table.getSelectedRow(), 3), table.getSelectedRow(), 3); + table.setValueAt(table.getValueAt(table.getSelectedRow(), 4), table.getSelectedRow(), 4); + // table.setValueAt(table.getValueAt(table.getSelectedRow(), + // table.getColumnCount()-1), table.getSelectedRow() - 1, + // table.getColumnCount()-1); + table.setValueAt(UUID.randomUUID().toString().replace("-", ""), table.getSelectedRow(), 0); + } else { + map.insertRow(table.getSelectedRow() + 1); + table.setValueAt(this.idTextField.getText(), table.getSelectedRow() + 1, 1); + table.setValueAt(this.nameTextField.getText(), table.getSelectedRow() + 1, 2); + table.setValueAt(table.getValueAt(table.getSelectedRow(), 3), table.getSelectedRow() + 1, 3); + table.setValueAt(table.getValueAt(table.getSelectedRow(), 4), table.getSelectedRow() + 1, 4); + // table.setValueAt(table.getValueAt(table.getSelectedRow(), + // table.getColumnCount()-1), table.getSelectedRow() + 1, + // table.getColumnCount()-1); + table.setValueAt(UUID.randomUUID().toString().replace("-", ""), table.getSelectedRow() + 1, 0); + } + processRows = map.getProcessRowList(); + renderer.setProcessRows(processRows); + renderer.setLabelRows(map.getLabelRows()); + Iterator> cellIt = cellMap.entrySet().iterator(); + while (cellIt.hasNext()) { + Map.Entry entry = cellIt.next(); + map.combine(entry.getKey(), entry.getValue()); + combineMap.put(entry.getKey(), entry.getValue()); + } + table.revalidate(); + table.repaint(); + this.disposeDialog(); + this.dispose(); + } else if (source.equals(this.celButton)) { + this.dispose(); + this.disposeDialog(); + } + } + + } + +} + + +//++++ + class MultiLineHeaderRenderer extends JList implements TableCellRenderer { + public MultiLineHeaderRenderer() { + setOpaque(true); + setForeground(UIManager.getColor("TableHeader.foreground")); + setBackground(UIManager.getColor("TableHeader.background")); + setBorder(UIManager.getBorder("TableHeader.cellBorder")); + ListCellRenderer renderer = getCellRenderer(); + ((JLabel) renderer).setHorizontalAlignment(JLabel.CENTER); + setCellRenderer(renderer); + } + + + + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + setFont(table.getFont()); + String str = (value == null) ? "" : value.toString(); + BufferedReader br = new BufferedReader(new StringReader(str)); + String line; + Vector v = new Vector(); + try { + while ((line = br.readLine()) != null) { + v.addElement(line); + } + } catch (IOException ex) { + ex.printStackTrace(); + } + setListData(v); + return this; + } + + } + + + /** + * 自定义celleditor实现 + * 指定单元格设置下拉框,其他单元格设置文本框 + * + */ + class JBoxTestCell extends AbstractCellEditor implements + TableCellEditor { + int row; + private JTable table; + private JPanel p1; + private JComboBox jbox; + private Object val = null; + private JTextField jt_0=new JTextField(); + private JTextField jt_2=new JTextField(); + public JBoxTestCell() { + p1 = new JPanel(new BorderLayout()); + + p1.setPreferredSize(new Dimension(300, 30)); + String[] interest1 = { "rap", "手指舞", "理发","冲天炮"}; + jbox = new JComboBox(interest1); + jbox.setPreferredSize(new Dimension(200,25)); + jbox.setSelectedIndex(0); + p1.add(jbox, BorderLayout.CENTER); + } + @Override + public boolean isCellEditable(EventObject anEvent) { + return true; + } + public void showSave() { + jbox.setVisible(true); + } + public Object getCellEditorValue() { + if(row==1) { + String v1 = jbox.getSelectedItem().toString(); + return v1; + } + String result=""; + switch(this.row) { + case 0 : result = jt_0.getText().trim(); break; + case 2 : result = jt_2.getText().trim(); break; + } + return result; + } + + public Component getTableCellEditorComponent(JTable table, Object value, + boolean isSelected, int row, int column) { + this.table = table; + this.row = row; + val = value; + JTextField result = new JTextField(); + switch(this.row) { + case 0 : result = jt_0; break; + case 1 : return this.jbox; + case 2 : result = jt_2; break; + } + return result; + } + } + //++++ diff --git a/src/com/connor/zf/controlplan/TMom004SetControlPlanHandler.java b/src/com/connor/zf/controlplan/TMom004SetControlPlanHandler.java new file mode 100644 index 0000000..a6032a2 --- /dev/null +++ b/src/com/connor/zf/controlplan/TMom004SetControlPlanHandler.java @@ -0,0 +1,59 @@ +package com.connor.zf.controlplan; + +import java.sql.ResultSet; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.common.NotDefinedException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.commands.reserve.ReserveOperation; +import com.teamcenter.rac.kernel.TCAccessControlService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentRole; +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.MessageBox; +import com.teamcenter.services.rac.core.ReservationService; + +public class TMom004SetControlPlanHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + if(app.getTargetComponent()==null + ||!(app.getTargetComponent() instanceof TCComponentItemRevision) + ||!(app.getTargetComponent().getType().toUpperCase().indexOf("KZJH") >= 0)) { + MessageBox.post("未选中控制计划版本对象,请重新选择!", "错误", MessageBox.ERROR); + return null; + } + String UID; + UID=app.getTargetComponent().getUid(); + TMom004SetControlPlanCommand command = new TMom004SetControlPlanCommand( + app,app.getTargetComponent() ,session,UID,false); + if(UID==null) { + MessageBox.post("请选择对象!", "错误", MessageBox.ERROR); + + return null; + } + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("填写控制计划失败!", "错误", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/zf/controlplan/TMom004SetControlPlanOperation.java b/src/com/connor/zf/controlplan/TMom004SetControlPlanOperation.java new file mode 100644 index 0000000..f15d4cf --- /dev/null +++ b/src/com/connor/zf/controlplan/TMom004SetControlPlanOperation.java @@ -0,0 +1,235 @@ +package com.connor.zf.controlplan; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.concurrent.TimeUnit; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JProgressBar; +import javax.swing.SwingUtilities; +import javax.swing.plaf.metal.MetalProgressBarUI; + +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom004SetControlPlanOperation extends AbstractAIFOperation { + private TCProperty[] properties; + private InterfaceAIFComponent comp; + private List> dataValueList; + private TCSession session; +// private TCComponent form; + private TCComponent meprocess; + private List deleteRows; + private List plmeidList; + private boolean isOwning; + private boolean isAutoSave; + private boolean isNotStandard; + private String UID; + private List HeadList = new ArrayList(); + private Map meopNameToID = new HashMap();//工序名称与ID + public TMom004SetControlPlanOperation( TCComponent meprocess, TCSession session, + TCProperty[] properties, List HeadList, List> dataValueList, + List deleteRows, List plmeidList, boolean isOwning, boolean isAutoSave, + InterfaceAIFComponent comp,String UID,Map meopNameToID) { + this.meprocess = meprocess; + this.session = session; + this.properties = properties; + this.dataValueList = dataValueList; + this.deleteRows = deleteRows; + this.plmeidList = plmeidList; + this.HeadList = HeadList; + this.meopNameToID=meopNameToID; + + this.isOwning = isOwning; + this.isAutoSave = isAutoSave; + this.comp=comp; + this.UID=UID; + } + + @Override + public void executeOperation() throws Exception { + //+++添加进度条 + JFrame frame = new JFrame("正在保存..."); + //frame.setUndecorated(true); // 没有标题栏 + frame.setSize(300, 70); + frame.setLocationRelativeTo(null); + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + frame.setLayout(new BorderLayout()); + JProgressBar progressBar = new JProgressBar(); + progressBar.setOrientation(JProgressBar.HORIZONTAL); + progressBar.setSize(300, 50); + progressBar.setMinimum(0); + progressBar.setMaximum(100); + progressBar.setBorderPainted(true); + progressBar.setUI(new MetalProgressBarUI()); + progressBar.setBackground(Color.white); + progressBar.setForeground(Color.green); + progressBar.setStringPainted(true); + frame.setAlwaysOnTop(true); + frame.add(progressBar); + frame.setVisible(true); + //+++ + ResultSet rs = null; + InputStream input = null; + try { + + + progressBar.setValue(1);//++++ + + // 获取SQL语句 + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + + + //获取工序ID名称对应的ID + if(meopNameToID.size()==0) { + SqlUtilT.getTCConnection(); + ResultSet rsData = null; + String sql13 = String.format(pro.getProperty("RB3_meopNameToID"), comp.getUid()); + rsData = SqlUtilT.read(sql13); + while (rsData.next()) { + meopNameToID.put(rsData.getString("GCMC"), rsData.getString("PROCESSID")); + } + SqlUtilT.free(rsData); + } + + + //+++更新表头数据 + String headDataupdateSQL = String.format(pro.getProperty("CONTROLPLANHEADUPDATE"),HeadList.get(0),HeadList.get(1)); + System.out.println("更新语句+"+pro.getProperty("CONTROLPLANHEADUPDATE")); + SqlUtilT.getTCConnection(); + SqlUtilT.update(new String[] {HeadList.get(2),HeadList.get(3),HeadList.get(4),HeadList.get(5),HeadList.get(6),HeadList.get(7), + HeadList.get(8),HeadList.get(9),HeadList.get(10),HeadList.get(11),HeadList.get(12),HeadList.get(13),HeadList.get(14), + HeadList.get(15)}, + headDataupdateSQL); + + //+++ + + + + + // 查询工序编号和ID + //String selectSQL = String.format(pro.getProperty("CONTROLPLANOPERATIONSELECT"), meprocess.getUid()); + // 获取数据库连接 + SqlUtilT.getTCConnection(); + //rs = SqlUtilT.read(selectSQL); + //Map itemIdMap = new HashMap(); + //while (rs.next()) { + // itemIdMap.put(rs.getString("zf6_gybh"), rs.getString("ZF6_MEOPID")); + //} + //SqlUtilT.freeAll(); + // 删除行 + int Speed=1; + int num=deleteRows.size()/9; + for (int i = 0; i < deleteRows.size(); i++) { + // 获取数据库连接 + String deleteSQL = String.format(pro.getProperty("CONTROLPLANDELETE"), deleteRows.get(i)); + SqlUtilT.getTCConnection(); + SqlUtilT.delete(deleteSQL); + if(i==num*Speed) { + Speed++; + progressBar.setValue(Speed);//++++ + } + //SqlUtilT.freeAll(); + } + progressBar.setValue(10);//++++ + Speed=10; + // 获取数据库连接 + SqlUtilT.getTCConnection(); + // 往数据库中写入数据 + isNotStandard = false; + List arr_GYBH = new ArrayList(); + List arr_CPGC = new ArrayList(); + int num2=dataValueList.size()/90; + for (int i = 0; i < dataValueList.size(); i++) { + List rowList = dataValueList.get(i); +// //检查表格数据的填写 +// if (rowList.get(2) == null || rowList.get(2).trim().equals("") || rowList.get(2).trim() == null) { +// if (arr_GYBH.indexOf(rowList.get(1)) < 0) +// arr_GYBH.add(rowList.get(1)); +// isNotStandard = true; +// } +// if (rowList.get(11) == null || rowList.get(11).trim().equals("") || rowList.get(11).trim() == null) { +// if (arr_CPGC.indexOf(rowList.get(1)) < 0) +// arr_CPGC.add(rowList.get(1)); +// isNotStandard = true; +// } + + if (rowList.get(0) != null && !rowList.get(0).equals("") && plmeidList.contains(rowList.get(0))) { + // 获取数据库连接 + String updateSQL = String.format(pro.getProperty("CONTROLPLANUPDATE"), rowList.get(0),UID); + SqlUtilT.getTCConnection(); + SqlUtilT.update(new String[] { rowList.get(1), rowList.get(2), rowList.get(3), rowList.get(4), + rowList.get(5), rowList.get(6), rowList.get(7), rowList.get(8), rowList.get(9), + rowList.get(10), rowList.get(11), rowList.get(12),rowList.get(13), rowList.get(14),rowList.get(15), + rowList.get(16), rowList.get(17),rowList.get(18), rowList.get(19)}, + updateSQL); + } else if(rowList.get(0) != null && !rowList.get(0).equals("") ){ + String insertSQL = pro.getProperty("INSERTSQL"); + SqlUtilT.getTCConnection(); + SqlUtilT.write2(new String[] { rowList.get(0), meprocess.getUid(), meopNameToID.get(rowList.get(2)),UID, + rowList.get(1), rowList.get(2), rowList.get(3), rowList.get(4),rowList.get(5),rowList.get(6), + rowList.get(7), rowList.get(8), rowList.get(9), rowList.get(10),rowList.get(11),rowList.get(12), + rowList.get(13), rowList.get(14), rowList.get(15), rowList.get(16),rowList.get(17),rowList.get(18), + rowList.get(19)}, insertSQL); + } + if(i==num2*(Speed-9)) { + Speed++; + progressBar.setValue(Speed);//++++ + } + } + progressBar.setValue(100); + frame.setTitle("保存完成"); + frame.dispose(); + SqlUtilT.connection.commit(); + input.close(); +// if (isNotStandard && !isAutoSave) { +// MessageBox.post( +// "保存成功!检测到控制计划填写不规范,可能导致作业指导书或检查报表输出异常,请查阅!\n提示:" +// + (arr_GYBH.size() != 0 ? "\n工艺编号" + arr_GYBH.toString() + "中存在条目未填写过程名称" : "") +// + (arr_CPGC.size() != 0 ? "\n工艺编号" + arr_CPGC.toString() + "中存在条目未填写技术要求" : ""), +// "成功", MessageBox.WARNING); +// } + // MessageBox.post("保存成功!", "成功", MessageBox.WARNING); + } catch (Exception e) { + MessageBox.post(e.toString(), "错误", MessageBox.ERROR); + e.printStackTrace(); + throw e; + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } +} + + + diff --git a/src/com/connor/zf/controlplan/TMomControlPlanBean.java b/src/com/connor/zf/controlplan/TMomControlPlanBean.java new file mode 100644 index 0000000..0e65d0f --- /dev/null +++ b/src/com/connor/zf/controlplan/TMomControlPlanBean.java @@ -0,0 +1,244 @@ +package com.connor.zf.controlplan; + +import java.util.List; + +public class TMomControlPlanBean { + + public static final int PROP_COUNT = 40; + public static final int PROP_COUNT_T = 37; + private String controlType = "";// 控制计划类型 rb3_cpjd + private String controlPlanNo = "";// 控制计划编号 + private String keyPersion = "";// 主要联系人 + private String custromApprovalDateStr = "";// 客户批准日期 + private String keyPhone = "";// 主要联系人电话 + private String createDateStr = "";// 编制日期 + private String updateDateStr = "";// 修改日期 + private String sorName = "";// SOR名称 + private String partNumber = "";// 零件号最终版本 + private String coreTeam = "";// 核心小组 + private String custromEngineeringApprovalDateStr = "";// 客户工程师批准日期 + private String custromDrawingNumber = "";// 客户图纸编号 + private String custromPartNumber = "";// 客户零件号 + private String partNameDesc = "";// 零件名称描述 + private String supplierApprovalDateStr = "";// 供方批准日期 + private String custromQuantyApprovalDateStr = "";// 客户质量批准日期 + private String supplier = "";// 供方 + private String supplierCode = "";// 供方代号 + private String changeLev = "";// 修改等级 + private String mode = "";// 车型 + private String otherApprovalDateStr = "";// 其他批准 + private String otherApprovalIfDateStr = "";// 其他是否批准 + private List simpleBeanList;// 数组属性 + + // -------------------------------------------------- + + public String getControlType() { + return controlType; + } + + public String getChangeLev() { + return changeLev; + } + + public void setChangeLev(String changeLev) { + this.changeLev = changeLev; + } + + public static int getPropCount() { + return PROP_COUNT; + } + + public String getCustromDrawingNumber() { + return custromDrawingNumber; + } + + public void setCustromDrawingNumber(String custromDrawingNumber) { + this.custromDrawingNumber = custromDrawingNumber; + } + + public String getKeyPersion() { + return keyPersion; + } + + public void setKeyPersion(String keyPersion) { + this.keyPersion = keyPersion; + } + + public String getCustromApprovalDateStr() { + return custromApprovalDateStr; + } + + public void setCustromApprovalDateStr(String custromApprovalDateStr) { + this.custromApprovalDateStr = custromApprovalDateStr; + } + + public void setControlType(String controlType) { + this.controlType = controlType; + } + + public String getControlPlanNo() { + return controlPlanNo; + } + + public void setControlPlanNo(String controlPlanNo) { + this.controlPlanNo = controlPlanNo; + } + + public String getKeyPhone() { + return keyPhone; + } + + public void setKeyPhone(String keyPhone) { + this.keyPhone = keyPhone; + } + + public String getCreateDateStr() { + return createDateStr; + } + + public void setCreateDateStr(String createDateStr) { + this.createDateStr = createDateStr; + } + + public String getUpdateDateStr() { + return updateDateStr; + } + + public void setUpdateDateStr(String updateDateStr) { + this.updateDateStr = updateDateStr; + } + + public String getSorName() { + return sorName; + } + + public void setSorName(String sorName) { + this.sorName = sorName; + } + + public String getPartNumber() { + return partNumber; + } + + public void setPartNumber(String partNumber) { + this.partNumber = partNumber; + } + + public String getCoreTeam() { + return coreTeam; + } + + public void setCoreTeam(String coreTeam) { + this.coreTeam = coreTeam; + } + + public String getCustromEngineeringApprovalDateStr() { + return custromEngineeringApprovalDateStr; + } + + public void setCustromEngineeringApprovalDateStr( + String custromEngineeringApprovalDateStr) { + this.custromEngineeringApprovalDateStr = custromEngineeringApprovalDateStr; + } + + public String getCustromPartNumber() { + return custromPartNumber; + } + + public void setCustromPartNumber(String custromPartNumber) { + this.custromPartNumber = custromPartNumber; + } + + public String getPartNameDesc() { + return partNameDesc; + } + + public void setPartNameDesc(String partNameDesc) { + this.partNameDesc = partNameDesc; + } + + public String getSupplierApprovalDateStr() { + return supplierApprovalDateStr; + } + + public void setSupplierApprovalDateStr(String supplierApprovalDateStr) { + this.supplierApprovalDateStr = supplierApprovalDateStr; + } + + public String getCustromQuantyApprovalDateStr() { + return custromQuantyApprovalDateStr; + } + + public void setCustromQuantyApprovalDateStr( + String custromQuantyApprovalDateStr) { + this.custromQuantyApprovalDateStr = custromQuantyApprovalDateStr; + } + + public String getSupplier() { + return supplier; + } + + public void setSupplier(String supplier) { + this.supplier = supplier; + } + + public String getSupplierCode() { + return supplierCode; + } + + public void setSupplierCode(String supplierCode) { + this.supplierCode = supplierCode; + } + + public String getMode() { + return mode; + } + + public void setMode(String mode) { + this.mode = mode; + } + + public String getOtherApprovalDateStr() { + return otherApprovalDateStr; + } + + public void setOtherApprovalDateStr(String otherApprovalDateStr) { + this.otherApprovalDateStr = otherApprovalDateStr; + } + + public String getOtherApprovalIfDateStr() { + return otherApprovalIfDateStr; + } + + public void setOtherApprovalIfDateStr(String otherApprovalIfDateStr) { + this.otherApprovalIfDateStr = otherApprovalIfDateStr; + } + + public List getSimpleBeanList() { + return simpleBeanList; + } + + public void setSimpleBeanList(List simpleBeanList) { + this.simpleBeanList = simpleBeanList; + } + + @Override + public String toString() { + return "TMomControlPlanBean [controlType=" + controlType + + ", controlPlanNo=" + controlPlanNo + ", keyPhone=" + keyPhone + + ", createDateStr=" + createDateStr + ", updateDateStr=" + + updateDateStr + ", sorName=" + sorName + ", partNumber=" + + partNumber + ", coreTeam=" + coreTeam + + ", custromEngineeringApprovalDateStr=" + + custromEngineeringApprovalDateStr + ", custromPartNumber=" + + custromPartNumber + ", partNameDesc=" + partNameDesc + + ", supplierApprovalDateStr=" + supplierApprovalDateStr + + ", custromQuantyApprovalDateStr=" + + custromQuantyApprovalDateStr + ", supplier=" + supplier + + ", supplierCode=" + supplierCode + ", mode=" + mode + + ", otherApprovalDateStr=" + otherApprovalDateStr + + ", otherApprovalIfDateStr=" + otherApprovalIfDateStr + + ", simpleBeanList=" + simpleBeanList + "]"; + } + +} diff --git a/src/com/connor/zf/controlplan/TMomControlPlanSimpleBean.java b/src/com/connor/zf/controlplan/TMomControlPlanSimpleBean.java new file mode 100644 index 0000000..429c8b3 --- /dev/null +++ b/src/com/connor/zf/controlplan/TMomControlPlanSimpleBean.java @@ -0,0 +1,253 @@ +package com.connor.zf.controlplan; + +public class TMomControlPlanSimpleBean { + + public static final int PROP_COUNT = 19;// 数组的属性的个数 + private String meopId = "";//工艺ID + private String partProcessNumber = "";// 零件工艺编号 + private String processName = "";// 过程名称 + private String machineDevice = "";// 机器设备 + private String smjy = "";//首末检验 + private String bubbledPrintNo = "";// 起泡图编号 + private String size = "";// 5 尺寸 + private String No = "";// 编号 + private String product = "";// 产品 + private String process = "";// 过程 + private String specialClass = "";// 特殊分类 + private String productProcessSpecificationTolerance = "";// 10 产品过程特殊分类公差 + + private String upProductProcessSpecificationTolerance = "";// 产品过程特殊分类公差(上偏差) + private String downProductProcessSpecificationTolerance = "";// 产品过程特殊分类公差(下偏差) + private String evaluationMeasurementTechnique = "";// 评估测量方法 + private String sampleSize = "";// 样品容量 + private String sampleFreq = "";// 15 样品频率 + private String resp = "";// 负责人 + private String controlMethod = "";// 控制方法 + private String operationCriteria = "";// 操作规范 + private String reactionPlan = "";// 反应计划 + + private String hbdyg = ""; + private String special = ""; + + private String conceal = "0";//是否隐藏 + + // --------------------------- + + public String getProductProcessSpecificationTolerance() { + return productProcessSpecificationTolerance; + } + + public void setProductProcessSpecificationTolerance( + String productProcessSpecificationTolerance) { + this.productProcessSpecificationTolerance = productProcessSpecificationTolerance; + } + + public String getPartProcessNumber() { + return partProcessNumber; + } + + public void setPartProcessNumber(String partProcessNumber) { + this.partProcessNumber = partProcessNumber; + } + + public String getProcessName() { + return processName; + } + + public void setProcessName(String processName) { + this.processName = processName; + } + + public String getMachineDevice() { + return machineDevice; + } + + public void setMachineDevice(String machineDevice) { + this.machineDevice = machineDevice; + } + + public String getBubbledPrintNo() { + return bubbledPrintNo; + } + + public void setBubbledPrintNo(String bubbledPrintNo) { + this.bubbledPrintNo = bubbledPrintNo; + } + + public String getSize() { + return size; + } + + public void setSize(String size) { + this.size = size; + } + + public String getNo() { + return No; + } + + public void setNo(String no) { + No = no; + } + + public String getProduct() { + return product; + } + + public void setProduct(String product) { + this.product = product; + } + + public String getProcess() { + return process; + } + + public void setProcess(String process) { + this.process = process; + } + + public String getSpecialClass() { + return specialClass; + } + + public void setSpecialClass(String specialClass) { + this.specialClass = specialClass; + } + + public String getUpProductProcessSpecificationTolerance() { + return upProductProcessSpecificationTolerance; + } + + public void setUpProductProcessSpecificationTolerance( + String upProductProcessSpecificationTolerance) { + this.upProductProcessSpecificationTolerance = upProductProcessSpecificationTolerance; + } + + public String getDownProductProcessSpecificationTolerance() { + return downProductProcessSpecificationTolerance; + } + + public void setDownProductProcessSpecificationTolerance( + String downProductProcessSpecificationTolerance) { + this.downProductProcessSpecificationTolerance = downProductProcessSpecificationTolerance; + } + + public String getEvaluationMeasurementTechnique() { + return evaluationMeasurementTechnique; + } + + public void setEvaluationMeasurementTechnique( + String evaluationMeasurementTechnique) { + this.evaluationMeasurementTechnique = evaluationMeasurementTechnique; + } + + public String getSampleSize() { + return sampleSize; + } + + public void setSampleSize(String sampleSize) { + this.sampleSize = sampleSize; + } + + public String getSampleFreq() { + return sampleFreq; + } + + public void setSampleFreq(String sampleFreq) { + this.sampleFreq = sampleFreq; + } + + public String getResp() { + return resp; + } + + public void setResp(String resp) { + this.resp = resp; + } + + public String getControlMethod() { + return controlMethod; + } + + public void setControlMethod(String controlMethod) { + this.controlMethod = controlMethod; + } + + public String getOperationCriteria() { + return operationCriteria; + } + + public void setOperationCriteria(String operationCriteria) { + this.operationCriteria = operationCriteria; + } + + public String getReactionPlan() { + return reactionPlan; + } + + public void setReactionPlan(String reactionPlan) { + this.reactionPlan = reactionPlan; + } + + public String getHbdyg() { + return hbdyg; + } + + public void setHbdyg(String hbdyg) { + this.hbdyg = hbdyg; + } + + public String getSpecial() { + return special; + } + + public void setSpecial(String special) { + this.special = special; + } + + public String getConceal() { + return conceal; + } + + public void setConceal(String conceal) { + this.conceal = conceal; + } + + public String getSmjy() { + return smjy; + } + + public void setSmjy(String smjy) { + this.smjy = smjy; + } + + @Override + public String toString() { + return "TMomControlPlanSimpleBean [partProcessNumber=" + + partProcessNumber + ", processName=" + processName + + ", machineDevice=" + machineDevice + ", bubbledPrintNo=" + + bubbledPrintNo + ", size=" + size + ", No=" + No + + ", product=" + product + ", process=" + process + + ", specialClass=" + specialClass + + ", productProcessSpecificationTolerance=" + + productProcessSpecificationTolerance + + ", upProductProcessSpecificationTolerance=" + + upProductProcessSpecificationTolerance + + ", downProductProcessSpecificationTolerance=" + + downProductProcessSpecificationTolerance + + ", evaluationMeasurementTechnique=" + + evaluationMeasurementTechnique + ", sampleSize=" + sampleSize + + ", sampleFreq=" + sampleFreq + ", resp=" + resp + + ", controlMethod=" + controlMethod + ", operationCriteria=" + + operationCriteria + ", reactionPlan=" + reactionPlan + "]"; + } + + public String getMeopId() { + return meopId; + } + + public void setMeopId(String meopId) { + this.meopId = meopId; + } + +} diff --git a/src/com/connor/zf/controlplan/TMomFinalUtil.java b/src/com/connor/zf/controlplan/TMomFinalUtil.java new file mode 100644 index 0000000..90d7685 --- /dev/null +++ b/src/com/connor/zf/controlplan/TMomFinalUtil.java @@ -0,0 +1,106 @@ +package com.connor.zf.controlplan; + +public class TMomFinalUtil { + // ---------------ALL---------------------------------------------- + public static final String PROCESS_MODEL_FILE = "PROCESS_MODEL_FILE";// 工艺模板文件 + // ---------------TMom001---------------------------------------------- + public static final int CX_INSTRUCTION = 0;// 成形作业指导书代号 + public static final int ZX_INSTRUCTION = 1;// 整形作业指导书代号 + public static final int SJ_INSTRUCTION = 2;// 烧结作业指导书代号 + public static final int PS_INSTRUCTION = 3;// 喷砂作业指导书代号 + public static final int GS_INSTRUCTION = 4;// 光饰作业指导书代号 + public static final int ST_INSTRUCTION = 5;// ST处理作业指导书代号 + + public static final int ELDECRCL_INSTRUCTION = 6;// Eldec热处理工艺指导书代号 + public static final int BZDXMJ_INSTRUCTION = 7;// 半自动修毛机工艺指导书代号 + public static final int GSJ_INSTRUCTION = 8;// 攻丝机工艺指导书 + public static final int JJG_INSTRUCTION = 9;// 机加工工艺指导书代号 + public static final int PTRCL_INSTRUCTION = 10;// 普通热处理工艺指导书代号 + public static final int TZ_INSTRUCTION = 11;// 台钻工艺指导书代号 + public static final int TGSXMJ_INSTRUCTION = 12;// 通过式修毛机工艺指导书代号 + public static final int TYMC_INSTRUCTION = 13;// 通用磨床工艺指导书代号 + public static final int WXM_INSTRUCTION = 14;// 无心磨工艺指导书代号 + public static final int YZ_INSTRUCTION = 15;// 压装工艺指导书代号 + public static final int TS_INSTRUCTION = 16;//探伤作业指导书 + public static final int CC_INSTRUCTION = 9;//车床工艺指导书 + public static final int JGZX_INSTRUCTION = 9;//加工中心工艺指导书 + + public static final int WG_INSTRUCTION = 17;//外观作业指导书 + + + // ---------------TMom002---------------------------------------------- + public static final int GY_CODE = 0;// 工艺代号 + public static final int HISGY_CODE = 2;// 历史工艺代号 + public static final int GX_CODE = 1;// 工序代号 + public static final int GYTZ_CODE = 3;//工艺图纸代号 + public static final int BZGX_CODE = 4;// 工序代号 + + public static final String GY_TYPE_DIS = "工艺";// 工艺类型 + public static final String GY_TYPE = "MEProcess"; + + public static final String HISGY_TYPE_DIS = "工艺";// 工艺类型 + public static final String HISGY_TYPE = "MEProcess"; + + public static final String GX_TYPE_DIS = "工序";// 工序类型 + public static final String GX_TYPE = "MEOP"; + + public static final String GYTZ_TYPE = "RB3_TEdrawing";//工艺图纸类型 + public static final String GYTZ_TYPE_DIS = "工艺图纸"; + + public static final String GY_ITEM_NAMES = "GY_ITEM_NAMES";// 工艺对象名称下拉列表 + public static final String GX_ITEM_NAMES = "GX_ITEM_NAMES";// 工序对象名称下拉列表 + + // ---------------TMom014---------------------------------------------- + public static final int CXSJTY_CHECKTABLE = 0; //成形首检调试记录表(通用) 烧结首件 200 AjQtFS$T4iZo5B 工序质量检查表(烧结) + public static final int CXSJCNCZY_CHECKTABLE = 0; //成形首检调试记录表(CNC专用) + public static final int CXGCJ_CHECKTABLE = 1; //成形工序过程自检记录表(操作工) 整形工序过程自检记录表(操作工) 101 + public static final int CXMJ_CHECKTABLE = 2; //成形末件记录表 整形末件记录表 102 + public static final int CXXJ_CHECKTABLE = 3; //成形工序巡检检查表 整形工序巡检检查表 103 + public static final int ZX_CHECKTABLE = 4; //精整工序产品批量生产记录单(批准单) + public static final int JJGSJ_CHECKTABLE = 5; //机加工科产品首件检查表 + public static final int JJGGCJ_CHECKTABLE = 6; //机加工科产品过程质量检查表 + public static final int JJGMJ_CHECKTABLE = 7; //机加工科产品末件检查表 + public static final int MKSJ_CHECKTABLE = 8; //盲孔感应淬火批次首件批准单 + public static final int MKGCJ_CHECKTABLE = 9; //盲孔感应淬火过程检验记录表 + public static final int MKMJ_CHECKTABLE = 10;//盲孔感应淬火批次末件记录单 + public static final int GXZL_CHECKTABLE = 11;//工序质量检查表-按时间 + public static final int ZZ_CHECKTABLE = 12;//最终检查表 + public static final int CPZL_CHECKTABLE = 13;//产品质量检查表 + public static final int JJGHDSJ_CHECKTABLE = 14;//机加工换刀首检验检查表 + public static final int JJGHDMJ_CHECKTABLE = 15;//机加工换刀末检验检查表 + public static final int GXZLPC_CHECKTABLE = 16;//工序质量检查表-按批次 + + + // ---------------TMom017---------------------------------------------- + public static final String BZFS_COMBOBOX_VALUES = "BZFS_COMBOBOX_VALUES"; //包装方式下拉菜单 + public static final String QYFS_COMBOBOX_VALUES = "QYFS_COMBOBOX_VALUES"; //油方式下拉菜单 + public static final String OUTERBOX_COMBOBOX_VALUESS = "OUTERBOX_COMBOBOX_VALUESS";//外箱标签下拉菜单 + public static final String STORAGETRAY_COMBOBOX_VALUES = "STORAGETRAY_COMBOBOX_VALUES";//入库托盘下拉菜单 + public static final String CARRIAGEPACK_COMBOBOX_VALUES = "CARRIAGEPACK_COMBOBOX_VALUES";//运输包装类型下拉菜单 + public static final String PACKAGING_COMBOBOX_VALUES = "PACKAGING_COMBOBOX_VALUES";//打包方式下拉列表框 + public static final String PALLETSPEC_COMBOBOX_VALUES = "PALLETSPEC_COMBOBOX_VALUES";//托盘规格下拉列表框 + public static final String METHODSREINFORCEMENT_COMBOBOX_VALUES = "METHODSREINFORCEMENT_COMBOBOX_VALUES";//加固方式下拉列表框 + + //---------------TMom019----------------------------------------------- + //public static final int AIXING_CONTROL = 0;// 爱信控制计划代号 + public static final int AIXING_CHINESE_CONTROL = 0;// 爱信中文控制计划代号 + public static final int AIXING_ENGLISH_CONTROL = 1;// 爱信英文控制计划代号 + public static final int AIXING_CHINESE_ENGLISH_CONTROL = 2;// 爱信中英文控制计划代号 + //public static final int BOGEHUALAEN_CONTROL = 1;// 英文博格华纳控制计划代号 + public static final int BOGEHUALAEN_CHINESE_CONTROL = 3;// 博格华纳中文控制计划代号 + public static final int BOGEHUALAEN_ENGLISH_CONTROL = 4;// 博格华纳英文控制计划代号 + public static final int BOGEHUALAEN_CHINESE_ENGLISH_CONTROL = 5;// 博格华纳中英文控制计划代号 + //public static final int BOGEHUALAZH_CONTROL = 2;// 中午博格华纳控制计划代号 + //public static final int MAIGELA_CONTROL = 3;// 麦格纳控制计划代号 + public static final int MAIGELA_CHINESE_CONTROL = 6;// 麦格纳中文控制计划代号 + public static final int MAIGELA_ENGLISH_CONTROL = 7;// 麦格纳英文控制计划代号 + public static final int MAIGELA_CHINESE_ENGLISH_CONTROL = 8;// 麦格纳中英文控制计划代号 + + public static final int NBTM_CHINESE_CONTROL = 9;//东睦中文控制计划代号 + public static final int NBTM_ENGLISH_CONTROL = 10;// 东睦英文控制计划代号 + public static final int NBTM_CHINESE_ENGLISH_CONTROL = 11;// 东睦中英文控制计划代号 + + + + +} diff --git a/src/com/connor/zf/controlplan/TMomItemBean.java b/src/com/connor/zf/controlplan/TMomItemBean.java new file mode 100644 index 0000000..963d0e2 --- /dev/null +++ b/src/com/connor/zf/controlplan/TMomItemBean.java @@ -0,0 +1,130 @@ +package com.connor.zf.controlplan; + +import java.util.Map; + +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItem; + +public class TMomItemBean { + private TCComponentItem item; + private String itemID;// 零组件ID + private String revID;// 版本ID + private String name;// 名称 + private String unitDis;// 单位显示 + private String unit;// 单位 + private String typeDis;// 类型显示 + private String type;// 类型 + private Map itemProps;// 零组件属性 + private Map revProps;// 版本属性 + private Map formProps;// 版本表单属性 + private TCComponentFolder folder; + + public TCComponentFolder getFolder() { + return folder; + } + + public void setFolder(TCComponentFolder folder) { + this.folder = folder; + } + + public String getTypeDis() { + return typeDis; + } + + public void setTypeDis(String typeDis) { + this.typeDis = typeDis; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getUnitDis() { + return unitDis; + } + + public void setUnitDis(String unitDis) { + this.unitDis = unitDis; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public TCComponentItem getItem() { + return item; + } + + public void setItem(TCComponentItem item) { + this.item = item; + } + + // ---------------------------------------------------- + public String getItemID() { + return itemID; + } + + public void setItemID(String itemID) { + this.itemID = itemID; + } + + public String getRevID() { + return revID; + } + + public void setRevID(String revID) { + this.revID = revID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Map getItemProps() { + return itemProps; + } + + public void setItemProps(Map itemProps) { + this.itemProps = itemProps; + } + + public Map getRevProps() { + return revProps; + } + + public void setRevProps(Map revProps) { + this.revProps = revProps; + } + + public Map getFormProps() { + return formProps; + } + + public void setFormProps(Map formProps) { + + this.formProps = formProps; + } + + @Override + public String toString() { + return "TMom001DeriveItemBean [itemID=" + itemID + ", revID=" + revID + + ", name=" + name + ", itemProps=" + itemProps + ", revProps=" + + revProps + ", formProps=" + formProps + "]"; + + } + + // ------------------------------ + +} diff --git a/src/com/connor/zf/controlplan/TMomMethodUtil.java b/src/com/connor/zf/controlplan/TMomMethodUtil.java new file mode 100644 index 0000000..3d4f127 --- /dev/null +++ b/src/com/connor/zf/controlplan/TMomMethodUtil.java @@ -0,0 +1,1471 @@ +package com.connor.zf.controlplan; + +import java.io.File; +import java.io.IOException; +import java.text.DecimalFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.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.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentProcess; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCComponentType; +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.TCQueryClause; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTextService; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.util.FileUtility; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.services.rac.core.DataManagementService; + +public class TMomMethodUtil { + + private static List> bomPropertyList = new ArrayList>(); + + public static void main(String[] args) { + String str = "123|1234|123124"; + System.out.println(str.split("\\|").length); + } + + /** + * 判断获取的对象是否全部为ITEM + * + * @param comps + * 需要判断的目标对象 + * @param isNotIgor + * 是否需要忽略,如果TRUE 则不能忽略,如果FALSE 则可以忽略 + * + * @param isSameType + * 是否要求是相同的类型,如果TRUE 要求必须是相同的类型 + * @return + */ + public static List getItemList( + InterfaceAIFComponent[] comps, Boolean isNotIgor, Boolean isSameType) { + if (comps == null) { + + return null; + } + List itemList = new ArrayList(); + String type = null; + for (int i = 0; i < comps.length; i++) { + if (comps[i] instanceof TCComponentItem) { + if (isSameType) { + if (type == null) { + type = comps[i].getType(); + } else if (!type.equals(comps[i].getType())) { + return null; + } + } + itemList.add((TCComponentItem) comps[i]); + } else if (isNotIgor) { + return null; + } + } + return itemList; + } + + /** + * 获取模板文件 + * @param session session + * @param fileName 文件名 + * @param Filetype 文件类型 + * @return + */ + public static File getFile(TCSession session,String fileName,String Filetype,String preName) { + // TODO Auto-generated method stub + try { + TCPreferenceService service = session.getPreferenceService(); + String[] modelFiles = service.getStringValues(preName); + System.out.println("首选项为:"+Arrays.toString(modelFiles)); + if (modelFiles == null) + { + System.out.println("未找到首选项"); + return null; + } + String puid = ""; + for (int i = 0; i < modelFiles.length; i++) { + if(modelFiles[i].split(":")[0].equals(fileName)) + { + System.out.println("puid======>"+puid); + puid = modelFiles[i].split(":")[1]; + } + } + TCComponentDataset dat = (TCComponentDataset)session + .stringToComponent(puid); + TCComponentTcFile[] tcFile = dat.getTcFiles(); + if(tcFile == null || tcFile.length == 0) + { + System.out.println("未找到配置文件"); + } + else + { + return tcFile[0].getFmsFile(); + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return null; + } + /** + * 获取最新的已发布的版本 + * @param item + * @return + */ + public static TCComponentItemRevision getLastItemRevision(TCComponentItem item) { + // TODO Auto-generated method stub + try { + TCComponentItemRevision[] items = item.getReleasedItemRevisions(); + int revId = 0; + TCComponentItemRevision itemRevision = null; + for (int i = 0; i < items.length; i++) { + String revisionId = items[i].getStringProperty("item_revision_id"); + if(letterToNumber(revisionId) >= revId ) + { + itemRevision = items[i]; + revId = letterToNumber(revisionId); + } + } + return itemRevision; + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + public static int letterToNumber(String letter) { + int length = letter.length(); + int num = 0; + int number = 0; + for(int i = 0; i < length; i++) { + char ch = letter.charAt(length - i - 1); + num = (int)(ch - 'A' + 1) ; + num *= Math.pow(26, i); + number += num; + } + return number; + } + + /** + * 获取选取的ITEM的目标的信息 + * + * @param itemList + * @return + */ + public static List getTargetsMsg( + List itemList) { + if (itemList == null) { + return null; + } + List beanList = new ArrayList<>(); + try { + TCProperty[][] props = TCComponentType.getTCPropertiesSet(itemList, + new String[] { "object_name", // 名称 + "object_type",// 类型 + "uom_tag",// 单位 + "item_id" }); + for (int i = 0; i < props.length; i++) { + + TCProperty[] prop = props[i]; + TMomItemBean bean = new TMomItemBean(); + bean.setItem(itemList.get(i)); + if (prop[0] != null) { + bean.setName(prop[0].getDisplayValue()); + } + bean.setFolder(getParentFolder(itemList.get(i), bean.getName())); + if (prop[1] != null) { + bean.setTypeDis(prop[1].getDisplayValue()); + bean.setType(itemList.get(i).getType()); + } + if (prop[2] != null) { + bean.setUnit(prop[2].getDisplayableValue()); + bean.setUnitDis(prop[2].getDisplayValue()); + } + if (prop[3] != null) { + // bean.setUnit(prop[2].getDisplayableValue()); + bean.setItemID(prop[3].getDisplayValue()); + } + beanList.add(bean); + } + } catch (TCException e) { + e.printStackTrace(); + } + return beanList; + } + + /** + * 过滤掉所有不需要显示的属性的 + * + * @param session + * @return + */ + public static List getExplictPropList(TCSession session) { + List beanList = new ArrayList<>(); + TCPreferenceService service = session.getPreferenceService(); + String[] values = service.getStringArray( + TCPreferenceService.TC_preference_site, + "Cust_prop_explict_mapping"); + if (values != null) { + for (int i = 0; i < values.length; i++) { + String[] types = values[i].split("\\|"); + if (types.length != 2) { + continue; + } + String[] props = types[1].split("\\;"); + if (props.length == 0) { + continue; + } + List list = new ArrayList<>(); + for (String str : props) { + list.add(str); + } + TMomPropExplictBean bean = new TMomPropExplictBean(); + bean.setType(types[0]); + bean.setPropList(list); + beanList.add(bean); + } + } + + return beanList; + } + + /** + * 获取版本对象 + * + * @param comps + * 需要判断的目标对象 + * @param isNotIgor + * 是否需要忽略,如果TRUE 则不能忽略,如果FALSE 则可以忽略 + * + * @param isSameType + * 是否要求是相同的类型,如果TRUE 要求必须是相同的类型 + * @return + */ + public static List getItemRevList( + InterfaceAIFComponent[] comps, Boolean isNotIgor, Boolean isSameType) { + if (comps == null) { + + return null; + } + List itemList = new ArrayList(); + + String type = null; + for (int i = 0; i < comps.length; i++) { + if (comps[i] instanceof TCComponentItemRevision) { + + if (isSameType) { + if (type == null) { + type = comps[i].getType(); + } else if (!type.equals(comps[i].getType())) { + return null; + } + } + itemList.add((TCComponentItemRevision) comps[i]); + } else if (isNotIgor) { + return null; + } + } + return itemList; + } + + /** + * 获取存放的文件夹 + * + * @param item + * @param name + * @return + */ + public static TCComponentFolder getParentFolder(TCComponentItem item, + String name) { + TCComponentFolder folder = null; + try { + AIFComponentContext[] comtexts = item.whereReferenced(); + if (comtexts != null) { + for (int i = 0; i < comtexts.length; i++) { + if (comtexts[i].getComponent() instanceof TCComponentFolder) { + String nameT = ((TCComponentFolder) comtexts[i] + .getComponent()) + .getStringProperty("object_name"); + if (name.equals("工艺图纸") && nameT.equals("工艺图纸")) { + folder = (TCComponentFolder) comtexts[i] + .getComponent(); + } + else if(nameT.equals(name)) + { + folder = (TCComponentFolder) comtexts[i] + .getComponent(); + } + } + } + } + } catch (TCException e) { + e.printStackTrace(); + } + return folder; + } + + /** + * 获取存在的ITEM的个数 + * + * @param session + * 会话 + * @param oldItemID + * 旧编码 + * @return + */ + public static Integer getItemCount(TCSession session, String oldItemID) { + Integer count = 0; + InterfaceAIFComponent[] comps = searchComponentsCollection(session, + "Connor_TMom_Query_Item", new String[] { "item_id" }, + new String[] { oldItemID }); + if (comps == null) { + return null; + } + count = comps.length; + return count; + } + + /** + * 根据规则获取ID + * + * @param oldItemID + * 旧的ID + * @return 新的ID + */ + public static String getRuleItemID(TCSession session, String oldItemID, + String typeID, int operateCode) { + String newId = null; + // 调用查询 Connor_TMom_Query_Item item_id + // 添加规则 + switch (operateCode) { + case TMomFinalUtil.GY_CODE: + newId = getGyRuleID(session, oldItemID); + break; + case TMomFinalUtil.HISGY_CODE: + newId = getGyRuleID(session, oldItemID); + break; + case TMomFinalUtil.GX_CODE: + newId = getGxRuleID(session, oldItemID); + break; + default: + break; + } + return newId; + } + +// /** +// * 工艺生成新的ID +// * +// * @param oldItemID +// * @return +// */ +// public static String getGyRuleID(TCSession session, String oldItemID) { +// DecimalFormat df = new DecimalFormat("00"); +// String newID = oldItemID + "_MEP01"; +// Integer count = 0; +// // String idTemp = +// TCComponentItemType tccomponentitemtype; +// try { +// tccomponentitemtype = (TCComponentItemType) (session +// .getTypeComponent("Item")); +// +// tccomponentitemtype.getNewID(); +// int i = 1; +// while (tccomponentitemtype.find(newID) != null) { +// i++; +// newID = oldItemID + "_MEP" + df.format(i); +// } +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// return newID; +// } + /** + * 工艺生成新的ID + * + * @param oldItemID + * @return + */ + public static String getGyRuleID(TCSession session, String oldItemID) { + DecimalFormat df = new DecimalFormat("000"); + String newID = oldItemID + "_P001"; + Integer count = 0; + // String idTemp = + TCComponentItemType tccomponentitemtype; + try { + tccomponentitemtype = (TCComponentItemType) (session + .getTypeComponent("Item")); + + tccomponentitemtype.getNewID(); + int i = 1; + //setByPass(session,true); + while (tccomponentitemtype.find(newID) != null) { + i++; + newID = oldItemID + "_P" + df.format(i); + } + // setByPass(session,false); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return newID; + } + +// /** +// * 工序生成新ID +// * +// * @param oldItemID +// * @return +// */ +// public static String getGxRuleID(TCSession session, String oldItemID) { +// DecimalFormat df = new DecimalFormat("000"); +// String newID = oldItemID.substring( +// 0, +// oldItemID.indexOf("_") > 0 ? oldItemID.indexOf("_") : oldItemID +// .length()) +// + "_MEOP001"; +// Integer count = 0; +// // String idTemp = +// TCComponentItemType tccomponentitemtype; +// try { +// tccomponentitemtype = (TCComponentItemType) (session +// .getTypeComponent("Item")); +// int i = 0; +// while (tccomponentitemtype.find(newID) != null) { +// i++; +// newID = oldItemID.substring(0, +// oldItemID.indexOf("_") > 0 ? oldItemID.indexOf("_") +// : oldItemID.length()) +// + "_MEOP" + df.format(i); +// } +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// return newID; +// } + + /** + * 工序生成新ID + * + * @param oldItemID + * @return + */ + public static String getGxRuleID(TCSession session, String oldItemID) { + // DecimalFormat df = new DecimalFormat("000"); + // String newID = oldItemID.substring( +// 0, +// oldItemID.indexOf("_") > 0 ? oldItemID.indexOf("_") : oldItemID +// .length()) +// + "_MEOP001"; + // Integer count = 0; + // String idTemp = + TCComponentItemType tccomponentitemtype; + try { + tccomponentitemtype = (TCComponentItemType) (session + .getTypeComponent("MEOP")); + + return tccomponentitemtype.getNewID(); + // int i = 0; + // while (tccomponentitemtype.find(newID) != null) { +// i++; +// newID = oldItemID.substring(0, +// oldItemID.indexOf("_") > 0 ? oldItemID.indexOf("_") +// : oldItemID.length()) +// + "_MEOP" + df.format(i); + // } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return ""; + } + /** + * 通过SOA创建ITEM对象 + * + * @param session + * 会话 + * @param itemID + * 创建对象的ID + * @param itemRev + * 创建对象的版本 + * @param itemType + * 创建对象的类型 + * @param itemName + * 创建对象的名称 + * @param itemDesc + * 创建对象的描述 + * @param unit + * 创建对象的单位 + * @param itemPropMap + * 创建对象的ITEM属性 + * @param itemRevPropMap + * 创建对象的版本属性 + * @param itemRevMasterPropMap + * 创建对象的版本表单属性 + */ + public static TCComponentItem createNewItemSoa(TCSession session, + String itemID, String itemRev, String itemType, String itemName, + String itemDesc, String unit, Map itemPropMap, + Map itemRevPropMap, + Map itemRevMasterPropMap) { + TCComponentItem newComp = null; + try { + DataManagementService datamanagementservice = DataManagementService + .getService(session); + com.teamcenter.services.rac.core._2006_03.DataManagement.CreateItemsResponse createitemsresponse = null; + // 设置创建对象的主要属性 + com.teamcenter.services.rac.core._2006_03.DataManagement.ItemProperties aitemproperties[] = new com.teamcenter.services.rac.core._2006_03.DataManagement.ItemProperties[1]; + aitemproperties[0] = new com.teamcenter.services.rac.core._2006_03.DataManagement.ItemProperties(); + aitemproperties[0].clientId = Integer.toString(1); + aitemproperties[0].description = itemDesc; + aitemproperties[0].itemId = itemID; + aitemproperties[0].name = itemName; + aitemproperties[0].revId = itemRev; + aitemproperties[0].type = itemType; + aitemproperties[0].uom = unit;// == null ? "" : uomComp.toString(); + // 设置扩展属性 + // com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes + // extendedattributes[] = new + // com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes[3]; + ArrayList list = new ArrayList(); + // 设置item对象的扩展属性 + if (itemPropMap != null) { + com.teamcenter.services.rac.core._2006_03.DataManagement.RevisionIds revids = null; + com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes extendedattributesItem = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes(); + extendedattributesItem = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes(); + extendedattributesItem.objectType = itemType; + extendedattributesItem.attributes = itemPropMap; + list.add(extendedattributesItem); + } + // 设置REV的扩展属性 + if (itemRevPropMap != null) { + com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes extendedattributesRev = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes(); + extendedattributesRev = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes(); + extendedattributesRev.objectType = itemType + "Revision"; + extendedattributesRev.attributes = itemRevPropMap; + list.add(extendedattributesRev); + } + // 设置REVMASTER的扩展属性 + if (itemRevMasterPropMap != null) { + com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes extendedattributesRevMaster = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes(); + extendedattributesRevMaster = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes(); + extendedattributesRevMaster.objectType = itemType + + "RevisionMaster"; + extendedattributesRevMaster.attributes = itemRevMasterPropMap; + list.add(extendedattributesRevMaster); + } + // 添加扩展属性 + if (list.size() != 0) { + com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes extendedattributes[] = null; + extendedattributes = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes[list + .size()]; + for (int i = 0; i < list.size(); i++) { + extendedattributes[i] = list.get(i); + } + aitemproperties[0].extendedAttributes = extendedattributes; + } + TCComponent tccomponent1 = null; + String s1 = ""; + createitemsresponse = datamanagementservice.createItems( + aitemproperties, tccomponent1, s1); + if (createitemsresponse.serviceData.sizeOfPartialErrors() == 0) { + newComp = createitemsresponse.output[0].item; + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + System.out.println("创建对象[item_id= " + itemID + " / rev =" + itemRev + + " / name= " + itemName + "]失败"); + } + return newComp; + } + + /** + * 通过查询,查找符合条件的版本 + * + * @param session + * 会话 + * @param searchName + * 查询名称 + * @param keys + * 查询关键字 + * @param values + * 查询值 + * @return + */ + public static InterfaceAIFComponent[] searchComponentsCollection( + TCSession session, String searchName, String[] keys, String[] values) { + // 信息输出 + InterfaceAIFComponent[] result = new InterfaceAIFComponent[0]; + + try { + TCTextService textService = session.getTextService(); + TCComponentQueryType querytype = (TCComponentQueryType) session + .getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) querytype + .find(searchName); + if (query == null) { + MessageBox.post("通过查询构建器" + searchName + "不存在", "错误", 1); + return null; + } + querytype.clearCache(); + String[] as = new String[keys.length]; + for (int i = 0; i < keys.length; i++) { + as[i] = textService.getTextValue(keys[i]); + } + + String[] as1 = new String[values.length]; + for (int i = 0; i < values.length; i++) { + as1[i] = textService.getTextValue(values[i]); + + } + + query.clearCache(); + TCQueryClause[] clauses = query.describe(); + TCComponentContextList list = query.getExecuteResultsList(as, as1); + + if (list != null) { + int count = list.getListCount(); + result = new InterfaceAIFComponent[count]; + + for (int i = 0; i < count; i++) { + result[i] = list.get(i).getComponent(); + } + } + } catch (TCException e) { + e.printStackTrace(); + MessageBox.post("通过查询构建器" + searchName + "查询发生错误.", "错误", 1); + } + + return result; + } + /** + * 自定义文件名下载文件 + * + * @param comps + * @return + * @throws TCException + * @throws IOException + */ + + public static String downLoadFiles(TCComponent comp,String Titles,String URL,Boolean flag) { + if (comp == null) { + return ""; + } + String value = ""; + String tempPath = System.getenv("TEMP"); + // MessageBox.post(" tempPath = + // "+tempPath,"INFO",MessageBox.INFORMATION); + if (tempPath == null) { + tempPath = ""; + } else if (!tempPath.endsWith("\\")) { + tempPath = tempPath + "\\"; + } + + // MessageBox.post(" tempPath = "+tempPath,"INFO",MessageBox.INFORMATION); + // MessageBox.post(" URL = "+URL,"INFO",MessageBox.INFORMATION); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); + // for(TCComponent comp : comps){ + try { + if (comp instanceof TCComponentDataset) { + TCComponentTcFile[] tcFiles = ((TCComponentDataset) comp) + .getTcFiles(); + File file = null; + if (tcFiles != null && tcFiles.length != 0) { + file = tcFiles[0].getFmsFile(); + String fileName = file.getName(); + String fileDix = fileName.substring( + fileName.lastIndexOf("."), fileName.length()); + if (flag == true) + { + if ((URL != "")&&(URL != " ")&&(URL != null)) + { + fileName = URL + Titles + fileDix; + } + else + { + fileName = tempPath + Titles + fileDix; + } + } + else + { + fileName = tempPath + sdf.format(new Date()) + fileDix; + } + File dirFile = new File(fileName); + FileUtility.copyFile(file, dirFile); + + return fileName; + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // } + return value; + } + + + + + + /** + * 下载文件 + * + * @param comps + * @return + * @throws TCException + * @throws IOException + */ + public static String downLoadFile(TCComponent comp) { + if (comp == null) { + return ""; + } + String value = ""; + String tempPath = System.getenv("TEMP"); + // MessageBox.post(" tempPath = + // "+tempPath,"INFO",MessageBox.INFORMATION); + if (tempPath == null) { + tempPath = ""; + } else if (!tempPath.endsWith("\\")) { + tempPath = tempPath + "\\"; + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); + // for(TCComponent comp : comps){ + try { + if (comp instanceof TCComponentDataset) { + TCComponentTcFile[] tcFiles = ((TCComponentDataset) comp) + .getTcFiles(); + File file = null; + if (tcFiles != null && tcFiles.length != 0) { + file = tcFiles[0].getFmsFile(); + String fileName = file.getName(); + String fileDix = fileName.substring( + fileName.lastIndexOf("."), fileName.length()); + fileName = tempPath + sdf.format(new Date()) + fileDix; + File dirFile = new File(fileName); + FileUtility.copyFile(file, dirFile); + + return fileName; + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // } + return value; + } + + /*** + * 获取首选项 + * + * @param session + * 会话 + * @param preferenceName + * 首选项名称 + * @return + */ + public static String[] getPreferenceValues(String preferenceName) { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + if (preferenceName == null || session == null) { + System.out.println(""); + return null; + } + String[] values = null; + TCPreferenceService service = session.getPreferenceService(); + values = service.getStringArray(TCPreferenceService.TC_preference_site, + preferenceName); + String[] resultValues = new String[values.length]; + for (int i = 0; i < values.length; i++) { + if(values[i].indexOf("\\n") >= 0) + { + resultValues[i] = values[i].replace("\\n", "\n"); + } + else + { + resultValues[i] = values[i]; + } + } + return resultValues; + } + + /** + * 删除文件 + * + * @param filePathList + * 文件地址 + */ + public static void deleteFile(List filePathList) { + for (int i = 0; i < filePathList.size(); i++) { + File file = new File(filePathList.get(i)); + if (file.exists() && file.isFile()) { + if (file.delete()) { + System.out.println("文件" + filePathList.get(i) + "已删除!"); + } + } + } + } + + /** + * 旁路 + * + * @param session + * @param val + * @throws TCException + */ + public static void setByPass(TCSession session, boolean val) + throws TCException { + + TCUserService userservice = session.getUserService(); + + Object[] obj = new Object[1]; + obj[0] = ""; + if (val) { + userservice.call("Connor_set_bypass", obj); + } else { + userservice.call("Connor_close_bypass", obj); + } + } + /** + * 转换合并单元格 + * @param regionCell + * @param row + * @return + */ + public static String getCombineCell(Map regionCell, int row) { + Iterator> it = regionCell.entrySet().iterator(); + StringBuffer sb = new StringBuffer(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + StringBuffer rowSb = new StringBuffer(); + StringBuffer columnSb = new StringBuffer(); + for (int k = 0; k < entry.getKey().length; k++) { + rowSb.append(entry.getKey()[k]); + rowSb.append(","); + } + for (int k = 0; k < entry.getValue().length; k++) { + columnSb.append(entry.getValue()[k]); + columnSb.append(","); + } + if (entry.getKey()[0] == row) { + sb.append(rowSb.substring(0, rowSb.length() - 1)+ "/"+ columnSb.substring(0,columnSb.length() - 1)+"-"); + } + } + if(sb.length() > 0) + { + return sb.toString().substring(0, sb.length()-1); + } + else + { + return ""; + } + } + + /** + * 通知流程 + * + * @param session + * @param val + * @throws TCException + */ + public static void setProcess(TCSession session, + TCComponentProcess process, TCComponentUser user) + throws TCException { + + TCUserService userservice = session.getUserService(); + + Object[] obj = new Object[2]; + obj[0] = process; + obj[1] = user; + userservice.call("TMOM_meop_tongzhi", obj); + } + + /** + * 获取PFMEA BOM属性 + */ + public static List> getPFMEABomPropertys(TCSession session, TCComponentItem item) { + // TODO Auto-generated method stub + //获取BOM + TCComponentBOMWindow bomWindow = null; + bomPropertyList.clear(); + try { + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topBomLine = bomWindow.setWindowTopLine(item, + item.getLatestItemRevision(), null, null); + //获取工艺下的控制计划对象 + TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); + List itme = new ArrayList(); + for (int i = 0; i < kzjh.length; i++) { + if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) + { + itme.add((TCComponentItem)kzjh[i]); + } + } + getBomPropertys(topBomLine, true); + return bomPropertyList; + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return null; + } +// public static List> getPFMEABomPropertys(TCSession session, TCComponentItem item) { +// // TODO Auto-generated method stub +// //获取BOM +// TCComponentBOMWindow bomWindow = null; +// try { +// TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session +// .getTypeComponent("BOMWindow"); +// bomWindow = bomWindowType.create(null); +// TCComponentBOMLine topBomLine = bomWindow.setWindowTopLine(item, +// item.getLatestItemRevision(), null, null); +// //获取工艺下的控制计划对象 +// TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); +// List itme = new ArrayList(); +// for (int i = 0; i < kzjh.length; i++) { +// if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) +// { +// itme.add((TCComponentItem)kzjh[i]); +// } +// } +// // 获取工序对象 +// AIFComponentContext aif[] = topBomLine.getChildren(); +// List> properties = new ArrayList>(); +// for (int i = 0; i < aif.length; i++) { +// TCComponentBOMLine subline = (TCComponentBOMLine) aif[i] +// .getComponent(); +// if(subline.getStringProperty("RB3_is_hide") != null && subline.getStringProperty("RB3_is_hide").equals("true")) +// { +// continue; +// } +// List propertie = new ArrayList(); +// propertie +// .add(subline.getStringProperty("bl_indented_title") +// .split("/")[0]); +// propertie.add(subline.getStringProperty("bl_sequence_no")); +// propertie +// .add(subline +// .getStringProperty("bl_item_object_name") == null ? "" +// : subline +// .getStringProperty("bl_item_object_name")); +// //获取工序下的BOM +// List equipmentNameList = new ArrayList(); +// if(subline.getChildren().length>0) +// { +// for (int j = 0; j < subline.getChildren().length; j++) { +// TCComponentBOMLine subChildrenline = (TCComponentBOMLine) subline.getChildren()[j] +// .getComponent(); +// System.out.println(subChildrenline.getType()); +// if(subChildrenline.getType().indexOf("Equipment") >= 0) +// { +// TCComponentICO[] icos = subChildrenline.getItem().getLatestItemRevision() +// .getClassificationObjects(); +// if (icos.length > 0) { +// ICSProperty[] descriptions = icos[0] +// .getICSProperties(true); +// for (int k = 0; k < descriptions.length; k++) { +// if (descriptions[k].getId() == 1004 && descriptions[k].getValue() != null +// && !descriptions[k].getValue().equals("")) { +// System.out.println(equipmentNameList.toString()); +// if(!equipmentNameList.contains(descriptions[k].getValue())) +// { +// equipmentNameList.add(descriptions[k].getValue()); +// } +// System.out.println(equipmentNameList.toString()); +// //sb.append(descriptions[k].getValue()+","); +// +// } +// } +// } +// } +// } +// } +// if(equipmentNameList.size() > 0) +// { +// propertie.add(equipmentNameList.toString().substring(1, equipmentNameList.toString().length()-1)); +// } +// else +// { +// propertie.add(""); +// } +// properties.add(propertie); +// } +// return properties; +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// return null; +// } + + /** + * 获取BOM属性 + */ + public static List> getBomPropertys(TCSession session, TCComponentItem item) { + // TODO Auto-generated method stub + bomPropertyList.clear(); + //获取BOM + TCComponentBOMWindow bomWindow = null; + try { + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topBomLine = bomWindow.setWindowTopLine(item, + item.getLatestItemRevision(), null, null); + //获取工艺下的控制计划对象 + TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); + List itme = new ArrayList(); + for (int i = 0; i < kzjh.length; i++) { + if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) + { + itme.add((TCComponentItem)kzjh[i]); + } + } + getBomPropertys(topBomLine, false); + return bomPropertyList; + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return null; + } +// public static List> getBomPropertys(TCSession session, TCComponentItem item) { +// // TODO Auto-generated method stub +// //获取BOM +// TCComponentBOMWindow bomWindow = null; +// try { +// TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session +// .getTypeComponent("BOMWindow"); +// bomWindow = bomWindowType.create(null); +// TCComponentBOMLine topBomLine = bomWindow.setWindowTopLine(item, +// item.getLatestItemRevision(), null, null); +// //获取工艺下的控制计划对象 +// TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); +// List itme = new ArrayList(); +// for (int i = 0; i < kzjh.length; i++) { +// if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) +// { +// itme.add((TCComponentItem)kzjh[i]); +// } +// } +// // 获取工序对象 +// AIFComponentContext aif[] = topBomLine.getChildren(); +// List> properties = new ArrayList>(); +// for (int i = 0; i < aif.length; i++) { +// TCComponentBOMLine subline = (TCComponentBOMLine) aif[i] +// .getComponent(); +// List propertie = new ArrayList(); +// propertie +// .add(subline.getStringProperty("bl_indented_title") +// .split("/")[0]); +// propertie.add(subline.getStringProperty("bl_sequence_no")); +// propertie +// .add(subline +// .getStringProperty("bl_item_object_name") == null ? "" +// : subline +// .getStringProperty("bl_item_object_name")); +// //获取工序下的BOM +// List equipmentNameList = new ArrayList(); +// if(subline.getChildren().length>0) +// { +// for (int j = 0; j < subline.getChildren().length; j++) { +// TCComponentBOMLine subChildrenline = (TCComponentBOMLine) subline.getChildren()[j] +// .getComponent(); +// System.out.println(subChildrenline.getType()); +// if(subChildrenline.getType().indexOf("Equipment") >= 0) +// { +// TCComponentICO[] icos = subChildrenline.getItem().getLatestItemRevision() +// .getClassificationObjects(); +// if (icos.length > 0) { +// ICSProperty[] descriptions = icos[0] +// .getICSProperties(true); +// for (int k = 0; k < descriptions.length; k++) { +// if (descriptions[k].getId() == 1004 && descriptions[k].getValue() != null +// && !descriptions[k].getValue().equals("")) { +// System.out.println(equipmentNameList.toString()); +// if(!equipmentNameList.contains(descriptions[k].getValue())) +// { +// equipmentNameList.add(descriptions[k].getValue()); +// } +// System.out.println(equipmentNameList.toString()); +// //sb.append(descriptions[k].getValue()+","); +// +// } +// } +// } +// } +// } +// } +// if(equipmentNameList.size() > 0) +// { +// propertie.add(equipmentNameList.toString().substring(1, equipmentNameList.toString().length()-1)); +// } +// else +// { +// propertie.add(""); +// } +// properties.add(propertie); +// } +// return properties; +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// return null; +// } + /** + * 获取插入到权限表的BOM行 + * @param session + * @param item + * @return + */ + public static List> getPermissionsBomPropertys(TCSession session, TCComponentItem item) { + // TODO Auto-generated method stub + //获取BOM + TCComponentBOMWindow bomWindow = null; + + try { + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topBomLine = bomWindow.setWindowTopLine(item, + item.getLatestItemRevision(), null, null); + //获取工艺下的控制计划对象 + TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); + List itme = new ArrayList(); + for (int i = 0; i < kzjh.length; i++) { + if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) + { + itme.add((TCComponentItem)kzjh[i]); + } + } + // 获取工序对象 + AIFComponentContext aif[] = topBomLine.getChildren(); + List> properties = new ArrayList>(); + for (int i = 0; i < aif.length; i++) { + if(((TCComponentBOMLine)aif[i].getComponent()).getItem().getType().equals("MEProcess")) + { + continue; + } + TCComponentBOMLine subline = (TCComponentBOMLine) aif[i] + .getComponent(); + List propertie = new ArrayList(); + propertie + .add(subline.getStringProperty("bl_indented_title") + .split("/")[0]); + propertie.add(subline.getStringProperty("bl_sequence_no")); + + String objectName = subline.getStringProperty("bl_item_object_name") == null ? "" + : subline.getStringProperty("bl_item_object_name"); + if(objectName.indexOf("/") >= 0) + { + propertie.add(objectName.split("/")[0]); + } + else + { + propertie.add(objectName); + } + //+++获取工序号 + propertie.add(subline.getStringProperty("RB3_GXH")); + //+++ + //获取工序下的BOM + List equipmentNameList = new ArrayList(); + if(subline.getChildren().length>0) + { + for (int j = 0; j < subline.getChildren().length; j++) { + TCComponentBOMLine subChildrenline = (TCComponentBOMLine) subline.getChildren()[j] + .getComponent(); + System.out.println(subChildrenline.getType()); + //if(subChildrenline.getType().indexOf("Equipment") >= 0) + //{ + equipmentNameList.add(subChildrenline.getItem().getStringProperty("item_id")); +// TCComponentICO[] icos = subChildrenline.getItem().getLatestItemRevision() +// .getClassificationObjects(); +// +// if (icos.length > 0) { +// ICSProperty[] descriptions = icos[0] +// .getICSProperties(true); +// for (int k = 0; k < descriptions.length; k++) { +// if (descriptions[k].getId() == 1004 && descriptions[k].getValue() != null +// && !descriptions[k].getValue().equals("")) { +// System.out.println(equipmentNameList.toString()); +// if(!equipmentNameList.contains(descriptions[k].getValue())) +// { +// equipmentNameList.add(descriptions[k].getValue()); +// } +// System.out.println(equipmentNameList.toString()); +// //sb.append(descriptions[k].getValue()+","); +// +// } +// } +// } + //} + } + } + if(equipmentNameList.size() > 0) + { + propertie.add(equipmentNameList.toString().substring(1, equipmentNameList.toString().length()-1)); + } + else + { + propertie.add(""); + } + properties.add(propertie); + } + return properties; + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return null; + } + + /** + * 获取BOM信息 + * @param meprocess 工艺BOMLINE + * @param isMeop 是否是PFEMA + * + */ + public static void getBomPropertys(TCComponentBOMLine meprocessBomLine, boolean isPFEMA) + { + try { + //获取工艺下的BOM + AIFComponentContext aif[] = meprocessBomLine.getChildren(); + for (int i = 0; i < aif.length; i++) { + if(aif[i]==null) {//防止 + continue; + } + TCComponentBOMLine subline = (TCComponentBOMLine) aif[i] + .getComponent(); + if(subline==null) { + continue; + } + TCComponentItem item = subline.getItem(); + //判断是否是工艺 + if(item.getType().equals("MEProcess")) + { + getBomPropertys(subline, isPFEMA); + } + else if(item.getType().equals("MEOP")) + { + List propertie = new ArrayList(); + //String ss = subline.getStringProperty("bl_indented_title"); + propertie + .add(subline.getStringProperty("bl_indented_title") + .split("/")[0]); + //控制计划中的零件/工艺编号改为工序号 + //propertie.add(subline.getStringProperty("bl_sequence_no")); + propertie.add(subline.getStringProperty("RB3_GXH")==null ? "": + subline.getStringProperty("RB3_GXH")); + propertie + .add(subline + .getStringProperty("bl_item_object_name") == null ? "" + : subline + .getStringProperty("bl_item_object_name")); + + //获取工序下的BOM的资源,机器设备。PFMEA跳过 + if(isPFEMA) + { + propertie.add(""); + }else { + List equipmentNameList = new ArrayList(); + if(subline.getChildren().length>0) + { + for (int j = 0; j < subline.getChildren().length; j++) { + TCComponentBOMLine subChildrenline = (TCComponentBOMLine) subline.getChildren()[j] + .getComponent(); + if(subChildrenline.toString().equals("<<无法读取>>")&&subChildrenline!=null) {//防止工艺资源出错,无权限读取 + continue; + } + System.out.println(subChildrenline.getType()); + String ClassID=subChildrenline.getItemRevision().getClassificationClass(); + if(ClassID!=null&&!ClassID.equals("")&&ClassID.length()>2) { + if(ClassID.substring(0,2).equals("15")) { + equipmentNameList.add(subChildrenline.getItem().getStringProperty("object_name")); + } + } + + } + } + if(equipmentNameList.size() > 0) + { + propertie.add(equipmentNameList.toString().substring(1, equipmentNameList.toString().length()-1)); + } + else + { + propertie.add(""); + } + } + propertie.add(subline.getStringProperty("bl_sequence_no")); + bomPropertyList.add(propertie); + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + /*** + * 根据正则表达式提取括号中的内容 + * @param value + * @return + */ + public static List getListByRegular(String value) + { + List resultList = new ArrayList(); + Pattern p = Pattern.compile("(\\[[^\\]]*\\])"); + Matcher m = p.matcher(value); + while(m.find()) + { + resultList.add(m.group().substring(1, m.group().length() - 1)); + } + return resultList; + } + + public static int getDays(String dateStr1, String dateStr2, String dateFormat) { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormat); + Date date1 = null; + Date date2 = null; + try { + date1 = simpleDateFormat.parse(dateStr1); + date2 = simpleDateFormat.parse(dateStr2); + } catch (ParseException e) { + e.printStackTrace(); + } + + String year1 = String.format("%tY", date1); + String mon1 = String.format("%tm", date1); + String day1 = String.format("%td", date1); + int y1 = Integer.valueOf(year1); + int m1 = Integer.valueOf(mon1); + int d1 = Integer.valueOf(day1); + int days1 = getRecentYearDays(y1, m1, d1); + System.out.println(days1); + + String year2 = String.format("%tY", date2); + String mon2 = String.format("%tm", date2); + String day2 = String.format("%td", date2); + int y2 = Integer.valueOf(year2); + int m2 = Integer.valueOf(mon2); + int d2 = Integer.valueOf(day2); + int days2 = getRecentYearDays(y2, m2, d2); + System.out.println(days2); + + int count = 0; + for (int i = y1; i < y2; i++) { + if ((i % 4 == 0 && i % 100 != 0) || i % 400 == 0) { + count += 366; + } else { + count += 365; + } + } + count = count + days2 - days1; + + return count; + } + + public static int getRecentYearDays(int y, int m, int d) { + + int count = 0; + + switch (m - 1) { + case 1: + count += 31; + break; + case 2: + count += 31 + 28; + break; + case 3: + count += 31 + 28 + 31; + break; + case 4: + count += 31 + 28 + 31 + 30; + break; + case 5: + count += 31 + 28 + 31 + 30 + 31; + break; + case 6: + count += 31 + 28 + 31 + 30 + 31 + 30; + break; + case 7: + count += 31 + 28 + 31 + 30 + 31 + 30 + 31; + break; + case 8: + count += 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31; + break; + case 9: + count += 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30; + break; + case 10: + count += 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31; + break; + case 11: + count += 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30; + break; + } + if (((y % 4 == 0 && y % 100 != 0) || y % 400 == 0) && m > 2) + count++; + return count + d; + } + + public static ControlPlanComboBoxBean[] getComboxItem(TCSession session,String pernaem) + { + ControlPlanComboBoxBean[] comboBoxBeans = null; + TCPreferenceService pref = session.getPreferenceService(); + String[] items = pref.getStringValues(pernaem);// 首选项查puid + comboBoxBeans = new ControlPlanComboBoxBean[items.length]; + for (int i = 0; i < items.length; i++) { + if(items[i].indexOf("-")>0) + { + ControlPlanComboBoxBean bean = new ControlPlanComboBoxBean(); + bean.setItemId(items[i].split("-")[0]); + bean.setItemName(items[i].split("-")[1]); + comboBoxBeans[i] = bean; + } + } + return comboBoxBeans; + } + +} diff --git a/src/com/connor/zf/controlplan/TMomPropExplictBean.java b/src/com/connor/zf/controlplan/TMomPropExplictBean.java new file mode 100644 index 0000000..f1d6dc4 --- /dev/null +++ b/src/com/connor/zf/controlplan/TMomPropExplictBean.java @@ -0,0 +1,25 @@ +package com.connor.zf.controlplan; + +import java.util.List; + +public class TMomPropExplictBean { + private String Type = ""; + private List PropList; + + public String getType() { + return Type; + } + + public void setType(String type) { + Type = type; + } + + public List getPropList() { + return PropList; + } + + public void setPropList(List propList) { + PropList = propList; + } + +} diff --git a/src/com/connor/zf/controlplan/TMomUserBean.java b/src/com/connor/zf/controlplan/TMomUserBean.java new file mode 100644 index 0000000..20b40cb --- /dev/null +++ b/src/com/connor/zf/controlplan/TMomUserBean.java @@ -0,0 +1,69 @@ +package com.connor.zf.controlplan; + +import javax.swing.ImageIcon; + +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentPerson; +import com.teamcenter.rac.kernel.TCComponentRole; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; + +public class TMomUserBean { + private TCComponent User; + private TCComponent Parent; + private ImageIcon ImageIcon; + private String UserName; + + public TCComponent getParent() { + return Parent; + } + + public void setParent(TCComponent Parent) { + this.Parent = Parent; + } + + public TCComponent getUser() { + return User; + } + + public void setUser(TCComponent user) { + User = user; + } + + public TMomUserBean() { + + } + + public TMomUserBean(TCComponent user, TCComponent Parent) { + this.Parent = Parent; + this.User = user; + if (user != null) { + + try { + if (user instanceof TCComponentRole) { + this.ImageIcon = new ImageIcon("icons\\role_16.png"); + + } else if (user instanceof TCComponentPerson) { + this.ImageIcon = new ImageIcon("icons\\persons_16.png"); + + } else if (user instanceof TCComponentGroup) { + this.ImageIcon = new ImageIcon("icons\\group_16.png"); + + } else if (user instanceof TCComponentUser) { + this.ImageIcon = new ImageIcon("icons\\persons_16.png"); + } + this.UserName = user.getStringProperty("object_string"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + @Override + public String toString() { + return UserName; + } + +} diff --git a/src/com/connor/zf/controlplan/TableCellCheckboxRenderer.java b/src/com/connor/zf/controlplan/TableCellCheckboxRenderer.java new file mode 100644 index 0000000..cfb1264 --- /dev/null +++ b/src/com/connor/zf/controlplan/TableCellCheckboxRenderer.java @@ -0,0 +1,121 @@ +package com.connor.zf.controlplan; + +import java.awt.Checkbox; +import java.awt.Color; +import java.awt.Component; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.List; + +import javax.swing.JCheckBox; +import javax.swing.JLabel; +import javax.swing.JTable; +import javax.swing.JTextPane; +import javax.swing.SwingConstants; +import javax.swing.event.ChangeEvent; +import javax.swing.event.EventListenerList; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableCellRenderer; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.StyleConstants; + +import com.teamcenter.rac.util.MessageBox; + +public class TableCellCheckboxRenderer extends JCheckBox implements + TableCellRenderer { + private List processRows; + protected EventListenerList listenerList = new EventListenerList(); + protected ChangeEvent changeEvent = new ChangeEvent(this); + private CTMap tableModel; + private JTableHeader tableHeader; + + public List getProcessRows() { + return processRows; + } + + public void setProcessRows(List processRows) { + this.processRows = processRows; + } + + public TableCellCheckboxRenderer(final CTable table) { + this.tableModel = (CTMap) table.getModel(); + this.tableHeader = table.getTableHeader(); + this.setName("换刀检验"); + // selectBox = new JCheckBox(tableModel.getColumnName(1)); + this.setSelected(false); + tableHeader.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() > 0) { + // 获得选中列 + int selectColumn = tableHeader.columnAtPoint(e.getPoint()); + if (table.getColumnName(selectColumn).equals("换刀检验")) { + boolean value = !TableCellCheckboxRenderer.this.isSelected(); + TableCellCheckboxRenderer.this.setSelected(value); + table.selectAllOrNull(value ? "1" : "0"); + tableHeader.repaint(); + } + } + } + }); + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + // TODO Auto-generated method stub +// if(value != null) +// { +// String valueStr = (boolean)value ? "true" : "false"; +// //System.out.println(valueStr); +// JLabel label = new JLabel(valueStr); +// label.setHorizontalAlignment(SwingConstants.CENTER); // 表头标签剧中 +// this.setHorizontalAlignment(SwingConstants.CENTER);// 表头标签剧中 +// this.setBorderPainted(true); +// this.setSelected((boolean)value); +// } +// else +// { +// String valueStr = (String) value; +// JLabel label = new JLabel(valueStr); +// label.setHorizontalAlignment(SwingConstants.CENTER); // 表头标签剧中 +// this.setHorizontalAlignment(SwingConstants.CENTER);// 表头标签剧中 +// this.setBorderPainted(true); +// this.setSelected(false); +// } +// String valueStr = (String) value; +// JLabel label = new JLabel(valueStr); +// label.setHorizontalAlignment(SwingConstants.CENTER); // 表头标签剧中 + this.setHorizontalAlignment(SwingConstants.CENTER);// 表头标签剧中 + this.setBorderPainted(true); + if(value != null) + { + this.setSelected(value.toString().equals("1")); + } + else + { + this.setSelected(false); + } +// if() +// String valueStr = (String) value; +// JLabel label = new JLabel(valueStr); +// label.setHorizontalAlignment(SwingConstants.CENTER); // 表头标签剧中 +// this.setHorizontalAlignment(SwingConstants.CENTER);// 表头标签剧中 +// this.setBorderPainted(true); + return this; + } + /** + * 查看一个字符串是否可以转换为数字 + * @param str 字符串 + * @return true 可以; false 不可以 + */ + public boolean isStr2Num(String str) { + try { + Integer.parseInt(str); + return true; + } catch (NumberFormatException e) { + return false; + } + } +} \ No newline at end of file diff --git a/src/com/connor/zf/controlplan/TableCellTextAreaRenderer.java b/src/com/connor/zf/controlplan/TableCellTextAreaRenderer.java new file mode 100644 index 0000000..dc98159 --- /dev/null +++ b/src/com/connor/zf/controlplan/TableCellTextAreaRenderer.java @@ -0,0 +1,220 @@ +package com.connor.zf.controlplan; + +import java.awt.Color; +import java.awt.Component; +import java.util.List; +import java.util.Map; + +import javax.swing.JTable; +import javax.swing.JTextPane; +import javax.swing.table.TableCellRenderer; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.StyleConstants; + +public class TableCellTextAreaRenderer extends JTextPane implements + TableCellRenderer { + private List processRows; + private Map> labelRows;//标注行 + public List getProcessRows() { + return processRows; + } + + public void setProcessRows(List processRows) { + this.processRows = processRows; + } + + public Map> getLabelRows() { + return labelRows; + } + + public void setLabelRows(Map> labelRows) { + this.labelRows = labelRows; + } + + public TableCellTextAreaRenderer() { + // setLineWrap(true);//自动换行 + // setWrapStyleWord(true); + + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + // TODO Auto-generated method stub + int maxPreferredHeight = 0; + if (table.getColumnName(column).equals("RPN")) { + // 5,9,11 + String yzd = table.getValueAt(row, 6) == null ? "0" : table + .getValueAt(row, 6).toString(); + String pds = table.getValueAt(row, 10) == null ? "0" : table + .getValueAt(row, 10).toString(); + String tcd = table.getValueAt(row, 12) == null ? "0" : table + .getValueAt(row, 12).toString(); + int rpn = Integer.parseInt(yzd) * Integer.parseInt(pds) + * Integer.parseInt(tcd); + if (rpn == 0) { + table.setValueAt("", row, column); + setText(""); + } else { + table.setValueAt(String.valueOf(rpn), row, column); + setText(String.valueOf(rpn)); + } + } else { + setText(value == null ? "" : value.toString()); + } + // //特殊符号 + // if(table.getValueAt(row, table.getColumnCount()-1) != null) + // { + // String special = table.getValueAt(row, + // table.getColumnCount()-1).toString(); + // if(special.indexOf("|") >= 0) + // { + // String[] specials = special.split("\\|"); + // for (int i = 0; i < specials.length; i++) { + // if(specials[i].indexOf("-") >= 0) + // { + // String[] columnName = specials[i].split("-"); + // if(table.getColumnName(column).equals(columnName[0])) + // { + // setTextFont(value.toString(),Integer.parseInt(columnName[1]) + // ,"Y14.5M"); + // } + // } + // } + // } + // else if(special.indexOf("-") >= 0) + // { + // String[] columnName = special.split("-"); + // if(table.getColumnName(column).equals(columnName[0])) + // { + // setTextFont(value.toString(),Integer.parseInt(columnName[1]) + // ,"Y14.5M"); + // } + // } + // } + + for (int i = 0; i < table.getColumnCount(); i++) { + setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + maxPreferredHeight = Math.max(maxPreferredHeight, + getPreferredSize().height); + } + if (table.getColumnName(column).equals("RPN") && value != null + && !value.equals("") + && Integer.parseInt(value.toString()) >= 100) { + setBackground(Color.RED); + setForeground(Color.black); + } + else if (processRows == null || processRows.size() <= 0 + || !processRows.contains(row)) { + setBackground(new Color(220,220,220)); + setForeground(Color.black); + + } + else { + setBackground(Color.white); + setForeground(Color.black); + } + if (labelRows != null && labelRows.keySet().contains(row)) { + if(labelRows.get(row).contains(((Integer)column).toString())) + { + setBackground(Color.RED); + setForeground(Color.black); + } + } +// else if (row == table.getSelectedRow()) { +// setBackground(Color.GRAY); +// setForeground(Color.black); +// } else if (column == table.getSelectedColumn()) { +// setBackground(Color.GRAY); +// setForeground(Color.black); +// } + + //判断单元格选中并且为可修改状态 + if (isSelected) { + // setBackground(new Color(0, 120, 215)); + setBackground(new Color(184,184,184)); + setForeground(Color.black); + } + if (table.getRowHeight(row) != maxPreferredHeight)// 少了这行则处理器瞎忙 + { + table.setRowHeight(row, maxPreferredHeight); + } + return this; + } + + // 设置字体,如一个字符串中需要包含多个字体样式,可创建多个SimpleAttributeSet,并将字符串拆分开,按顺序使用Document的insertString方法插入 + private void setTextFont(String value, int index, String font) { + // TODO Auto-generated method stub + SimpleAttributeSet set = new SimpleAttributeSet(); + // StyleConstants.setForeground(set, Color.red);//设置文字颜色 + StyleConstants.setFontFamily(set, font);// 设置字体样式 + SimpleAttributeSet set2 = new SimpleAttributeSet(); + // StyleConstants.setForeground(set, Color.red);//设置文字颜色 + StyleConstants.setFontFamily(set2, "Courier New");// 设置字体样式 + // StyleConstants.setFontSize(set2, 10); + Document doc = this.getStyledDocument(); + try { + // 插入前需要先删除 + doc.remove(0, value.toString().length()); + value = value.replaceAll(" ", ""); + doc.insertString(doc.getLength(), + value.toString().substring(0, index), set2); + doc.insertString(doc.getLength(), + value.toString().substring(index, index + 1), set); + doc.insertString( + doc.getLength(), + value.toString().substring(index + 1, + value.toString().length()), set2); + if (value.toString() + .substring(index + 1, value.toString().length()) == null + || value.toString() + .substring(index + 1, value.toString().length()) + .equals("")) { + doc.insertString(doc.getLength(), " ", set2); + } + } catch (BadLocationException e) { + e.printStackTrace(); + } finally { + set = null; + doc = null; + System.gc(); + } + } + // + // @Override + // public Component getTableCellRendererComponent(JTable table, Object + // value, boolean isSelected, boolean hasFocus, + // int row, int column) { + // // TODO Auto-generated method stub + // int maxPreferredHeight = 0; + // for (int i = 0; i < table.getColumnCount(); i++) { + // setText("" + table.getValueAt(row, i)); + // setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + // maxPreferredHeight = Math.max(maxPreferredHeight, + // getPreferredSize().height); + // } + // setBorder(BorderFactory.createLineBorder(Color.white)); + // setBackground(Color.white); + // setForeground(Color.black); + // if(isSelected){ + // setBackground(new Color(0, 120, 215)); + // setForeground(Color.white); + // } + // String val=(String) table.getValueAt(row, column); + // int w=0; + // if(val!=null){ + // w=val.length()*6/table.getColumn(table.getColumnName(column)).getWidth(); + // } + // if(w!=0){ + // //System.out.println("height:"+table.getRowHeight()*(w+1)); + // table.setRowHeight(row,table.getRowHeight()*(w+1)); + // } + // + // + // setText(value == null ? "" : value.toString()); + // return this; + // } + +} diff --git a/src/com/connor/zf/controlplan/TableCellTextAreaRenderer2.java b/src/com/connor/zf/controlplan/TableCellTextAreaRenderer2.java new file mode 100644 index 0000000..de0d57f --- /dev/null +++ b/src/com/connor/zf/controlplan/TableCellTextAreaRenderer2.java @@ -0,0 +1,203 @@ +package com.connor.zf.controlplan; + +import java.awt.Color; +import java.awt.Component; +import java.util.List; + +import javax.swing.JTable; +import javax.swing.JTextPane; +import javax.swing.table.TableCellRenderer; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.StyleConstants; + +import com.teamcenter.rac.util.MessageBox; + +public class TableCellTextAreaRenderer2 extends JTextPane implements + TableCellRenderer { + private List processRows; + + public List getProcessRows() { + return processRows; + } + + public void setProcessRows(List processRows) { + this.processRows = processRows; + } + + public TableCellTextAreaRenderer2() { + // setLineWrap(true);//自动换行 + // setWrapStyleWord(true); + + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + // TODO Auto-generated method stub + int maxPreferredHeight = 0; + if (row > 0 && table.getColumnName(column).equals("RPN")) { + // 5,9,11 + String yzd = table.getValueAt(row, 5) == null ? "0" : table + .getValueAt(row, 5).toString(); + String pds = table.getValueAt(row, 9) == null ? "0" : table + .getValueAt(row, 9).toString(); + String tcd = table.getValueAt(row, 11) == null ? "0" : table + .getValueAt(row, 11).toString(); + int rpn = Integer.parseInt(yzd) * Integer.parseInt(pds) + * Integer.parseInt(tcd); + if (rpn == 0) { + table.setValueAt("", row, column); + setText(""); + } else { + table.setValueAt(String.valueOf(rpn), row, column); + setText(String.valueOf(rpn)); + } + } else { + setText(value == null ? "" : value.toString()); + } + // 特殊符号 + // setText(value == null ? "" : value.toString()); + // if(table.getValueAt(row, table.getColumnCount()-1) == null) + // { + // return this; + // } + // String special = table.getValueAt(row, + // table.getColumnCount()-1).toString(); + // if(special.indexOf("|") >= 0) + // { + // String[] specials = special.split("\\|"); + // for (int i = 0; i < specials.length; i++) { + // if(specials[i].indexOf("-") >= 0) + // { + // String[] columnName = specials[i].split("-"); + // if(table.getColumnName(column).equals(columnName[0])) + // { + // setTextFont(value.toString(),Integer.parseInt(columnName[1]) + // ,"Y14.5M"); + // } + // } + // } + // } + // else if(special.indexOf("-") >= 0) + // { + // String[] columnName = special.split("-"); + // if(table.getColumnName(column).equals(columnName[0])) + // { + // setTextFont(value.toString(),Integer.parseInt(columnName[1]) + // ,"Y14.5M"); + // } + // } + // if(value!=null) + // { + // if(column == 1) + // { + // setTextFont(value.toString(),"Y14.5M"); + // } + // } + + for (int i = 0; i < table.getColumnCount(); i++) { + setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + maxPreferredHeight = Math.max(maxPreferredHeight, + getPreferredSize().height); + } + if (row > 0 && table.getColumnName(column).equals("RPN") + && value != null && !value.equals("") + && Integer.parseInt(value.toString()) >= 100) { + setBackground(Color.RED); + setForeground(Color.black); + } +// else if (row == table.getSelectedRow()) { +// setBackground(Color.GRAY); +// setForeground(Color.black); +// } + else if (isSelected) { + setBackground(Color.GRAY); + setForeground(Color.black); + } + else { + setBackground(Color.white); + setForeground(Color.black); + } + if (table.getRowHeight(row) != maxPreferredHeight)// 少了这行则处理器瞎忙 + { + table.setRowHeight(row, maxPreferredHeight); + } + return this; + } + + // 设置字体,如一个字符串中需要包含多个字体样式,可创建多个SimpleAttributeSet,并将字符串拆分开,按顺序使用Document的insertString方法插入 + private void setTextFont(String value, int index, String font) { + // TODO Auto-generated method stub + SimpleAttributeSet set = new SimpleAttributeSet(); + // StyleConstants.setForeground(set, Color.red);//设置文字颜色 + StyleConstants.setFontFamily(set, font);// 设置字体样式 + SimpleAttributeSet set2 = new SimpleAttributeSet(); + // StyleConstants.setForeground(set, Color.red);//设置文字颜色 + StyleConstants.setFontFamily(set2, "Courier New");// 设置字体样式 + // StyleConstants.setFontSize(set2, 10); + Document doc = this.getStyledDocument(); + try { + // 插入前需要先删除 + doc.remove(0, value.toString().length()); + value = value.replaceAll(" ", ""); + doc.insertString(doc.getLength(), + value.toString().substring(0, index), set2); + doc.insertString(doc.getLength(), + value.toString().substring(index, index + 1), set); + doc.insertString( + doc.getLength(), + value.toString().substring(index + 1, + value.toString().length()), set2); + if (value.toString() + .substring(index + 1, value.toString().length()) == null + || value.toString() + .substring(index + 1, value.toString().length()) + .equals("")) { + doc.insertString(doc.getLength(), " ", set2); + } + } catch (BadLocationException e) { + MessageBox.post(e.toString(), "错误", MessageBox.ERROR); + e.printStackTrace(); + } finally { + set = null; + doc = null; + System.gc(); + } + } + // + // @Override + // public Component getTableCellRendererComponent(JTable table, Object + // value, boolean isSelected, boolean hasFocus, + // int row, int column) { + // // TODO Auto-generated method stub + // int maxPreferredHeight = 0; + // for (int i = 0; i < table.getColumnCount(); i++) { + // setText("" + table.getValueAt(row, i)); + // setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + // maxPreferredHeight = Math.max(maxPreferredHeight, + // getPreferredSize().height); + // } + // setBorder(BorderFactory.createLineBorder(Color.white)); + // setBackground(Color.white); + // setForeground(Color.black); + // if(isSelected){ + // setBackground(new Color(0, 120, 215)); + // setForeground(Color.white); + // } + // String val=(String) table.getValueAt(row, column); + // int w=0; + // if(val!=null){ + // w=val.length()*6/table.getColumn(table.getColumnName(column)).getWidth(); + // } + // if(w!=0){ + // //System.out.println("height:"+table.getRowHeight()*(w+1)); + // table.setRowHeight(row,table.getRowHeight()*(w+1)); + // } + // + // + // setText(value == null ? "" : value.toString()); + // return this; + // } +} \ No newline at end of file diff --git a/src/com/connor/zf/controlplan/TextAreaCellEditor.java b/src/com/connor/zf/controlplan/TextAreaCellEditor.java new file mode 100644 index 0000000..07a5e63 --- /dev/null +++ b/src/com/connor/zf/controlplan/TextAreaCellEditor.java @@ -0,0 +1,193 @@ +package com.connor.zf.controlplan; + +import java.awt.Component; +import java.util.EventObject; + +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextPane; +import javax.swing.event.CaretEvent; +import javax.swing.event.CaretListener; +import javax.swing.event.CellEditorListener; +import javax.swing.event.ChangeEvent; +import javax.swing.event.EventListenerList; +import javax.swing.table.TableCellEditor; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.StyleConstants; + +public class TextAreaCellEditor extends JTextPane implements TableCellEditor, + CaretListener { + private static final long serialVersionUID = 5860619160549087886L; + private EventListenerList listenerList = new EventListenerList(); + private ChangeEvent changeEvent = new ChangeEvent(this); + private int index;// 光标所在位置 + + public TextAreaCellEditor() { + // TODO Auto-generated constructor stub + super(); + this.addCaretListener(this); + // this.setLineWrap(true); //自动换行 + // this.setWrapStyleWord(true); + } + + public int getIndex() { + return index; + } + + @Override + public void addCellEditorListener(CellEditorListener listener) { + // TODO Auto-generated method stub + listenerList.add(CellEditorListener.class, listener); + } + + @Override + public void cancelCellEditing() { + // TODO Auto-generated method stub + System.out.println(2); + } + + @Override + public Object getCellEditorValue() { + // TODO Auto-generated method stub + // System.out.println(3); + return this.getText(); + } + + @Override + public boolean isCellEditable(EventObject arg0) { + // TODO Auto-generated method stub + return true; + } + + @Override + public void removeCellEditorListener(CellEditorListener listener) { + // TODO Auto-generated method stub + listenerList.remove(CellEditorListener.class, listener); + } + + private void fireEditingStopped() { + CellEditorListener listener; + Object[] listeners = listenerList.getListenerList(); + for (int i = 0; i < listeners.length; i++) { + if (listeners[i] == CellEditorListener.class) { + // 之所以是i+1,是因为一个为CellEditorListener.class(Class对象), + // 接着的是一个CellEditorListener的实例 + listener = (CellEditorListener) listeners[i + 1]; + // 让changeEvent去通知编辑器已经结束编辑 + // 在editingStopped方法中,JTable调用getCellEditorValue()取回单元格的值, + // 并且把这个值传递给TableValues(TableModel)的setValueAt() + try { + listener.editingStopped(changeEvent); + } catch (Exception e) { + // TODO: handle exception + System.out.println(e.toString()); + } + } + } + } + + @Override + public boolean shouldSelectCell(EventObject arg0) { + // TODO Auto-generated method stub + return true; + } + + @Override + public boolean stopCellEditing() { + // TODO Auto-generated method stub + // 可以注释掉下面的fireEditingStopped();,然后在GenderEditor的构造函数中把 + // addActionListener()的注释去掉(这时请求终止编辑操作从JComboBox获得), + // System.out.println("编辑其中一个单元格,再点击另一个单元格时,调用。"); + fireEditingStopped();// 请求终止编辑操作从JTable获得 + return true; + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, + boolean isSelect, int row, int column) { + // TODO Auto-generated method stub + setText(value == null ? "" : value.toString()); + // 特殊符号 + if (table.getValueAt(row, table.getColumnCount() - 1) == null) { + return new JScrollPane(this); + } + String special = table.getValueAt(row, table.getColumnCount() - 1) + .toString(); + if (special.indexOf("|") >= 0) { + String[] specials = special.split("\\|"); + for (int i = 0; i < specials.length; i++) { + if (specials[i].indexOf("-") >= 0) { + String[] columnName = specials[i].split("-"); + if (table.getColumnName(column).equals(columnName[0])) { + setTextFont(value.toString(), + Integer.parseInt(columnName[1]), "Y14.5M"); + } + } + } + } else if (special.indexOf("-") >= 0) { + String[] columnName = special.split("-"); + if (table.getColumnName(column).equals(columnName[0])) { + setTextFont(value.toString(), Integer.parseInt(columnName[1]), + "Y14.5M"); + } + } + // if(value!=null) + // { + // if(cloumn == 1) + // { + // setTextFont(value.toString(),"Y14.5M"); + // } + // } + // System.out.println(8) + return new JScrollPane(this); + } + + @Override + public void caretUpdate(CaretEvent caretevent) { + // TODO Auto-generated method stub + index = caretevent.getMark(); + // System.out.println(index); + } + + // 设置字体,如一个字符串中需要包含多个字体样式,可创建多个SimpleAttributeSet,并将字符串拆分开,按顺序使用Document的insertString方法插入 + private void setTextFont(String value, int index, String font) { + // TODO Auto-generated method stub + SimpleAttributeSet set = new SimpleAttributeSet(); + // StyleConstants.setForeground(set, Color.red);//设置文字颜色 + StyleConstants.setFontFamily(set, font);// 设置字体样式 + // StyleConstants.setFontSize(set, 14); + SimpleAttributeSet set2 = new SimpleAttributeSet(); + // StyleConstants.setForeground(set, Color.red);//设置文字颜色 + StyleConstants.setFontFamily(set2, "Courier New");// 设置字体样式 + // StyleConstants.setFontSize(set2, 10); + Document doc = this.getStyledDocument(); + try { + // 插入前需要先删除 + doc.remove(0, value.toString().length()); + value = value.replaceAll(" ", ""); + doc.insertString(doc.getLength(), + value.toString().substring(0, index), set2); + doc.insertString(doc.getLength(), + value.toString().substring(index, index + 1), set); + doc.insertString( + doc.getLength(), + value.toString().substring(index + 1, + value.toString().length()), set2); + if (value.toString() + .substring(index + 1, value.toString().length()) == null + || value.toString() + .substring(index + 1, value.toString().length()) + .equals("")) { + doc.insertString(doc.getLength(), " ", set2); + } + } catch (BadLocationException e) { + e.printStackTrace(); + } finally { + set = null; + doc = null; + System.gc(); + } + } +} diff --git a/src/com/connor/zf/controlplan/TreeBean.java b/src/com/connor/zf/controlplan/TreeBean.java new file mode 100644 index 0000000..b41d693 --- /dev/null +++ b/src/com/connor/zf/controlplan/TreeBean.java @@ -0,0 +1,77 @@ +package com.connor.zf.controlplan; +import java.util.List; + + +public class TreeBean { + private String plmeid; + private String id; + private String P1; + private String P2; + private String P3; + private String P4; + private String P5; + private String name; + private String parentId; + private List chidrenBeans; + public String getPlmeid() { + return plmeid; + } + public void setPlmeid(String plmeid) { + this.plmeid = plmeid; + } + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + public String getP1() { + return P1; + } + public void setP1(String P1) { + this.P1 = P1; + } + public String getP2() { + return P2; + } + public void setP2(String P2) { + this.P2 = P2; + } + public String getP3() { + return P3; + } + public void setP3(String P3) { + this.P3 = P3; + } + public String getP4() { + return P4; + } + public void setP4(String P4) { + this.P4 = P4; + } + public String getP5() { + return P5; + } + public void setP5(String P5) { + this.P5 = P5; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public String getParentId() { + return parentId; + } + public void setParentId(String parentId) { + this.parentId = parentId; + } + public List getChidrenBeans() { + return chidrenBeans; + } + public void setChidrenBeans(List chidrenBeans) { + this.chidrenBeans = chidrenBeans; + } + +} diff --git a/src/com/connor/zf/controlplan/outPutExcel.java b/src/com/connor/zf/controlplan/outPutExcel.java new file mode 100644 index 0000000..f59b7d1 --- /dev/null +++ b/src/com/connor/zf/controlplan/outPutExcel.java @@ -0,0 +1,1107 @@ +package com.connor.zf.controlplan; + + +import java.awt.image.BufferedImage; +import java.io.*; +import java.util.*; + +import javax.imageio.ImageIO; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.ClientAnchor; +import org.apache.poi.ss.usermodel.Drawing; +import org.apache.poi.ss.usermodel.Picture; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFClientAnchor; +import org.apache.poi.xssf.usermodel.XSSFDrawing; +import org.apache.poi.xssf.usermodel.XSSFPicture; +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; + +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +public class outPutExcel { + + + private static Map excelCombineMap = new HashMap();// 存放合并单元格 + /** + * 输出本部控制计划到EXCEL表格中 + * + * @param controlPlanBean 控制计划信息 + * @param input 模版文件流 + * @param outputFilePath 需要输出的全路径 + * @throws IOException + */ + public static int writeControlPlanToExcel(TCSession session,List> tableValues, List headValue,File file,String outPutPath) throws IOException { + file.setWritable(true); + InputStream input = new FileInputStream(file); + XSSFWorkbook wb = new XSSFWorkbook(input); + XSSFSheet sheet = wb.getSheetAt(0); + excelCombineMap.clear(); + //获取特殊特性的图片 + TCPreferenceService service = session.getPreferenceService(); + String[] strs = service.getStringValues("ZF6_KZJH_TSTX"); + Map NameToPicpath=new HashMap(); + for(String str:strs) { + System.out.println("添加NameToPicpath===》"+str.split(":")[0]+"==="+getPic(session, str.split(":")[1])); + NameToPicpath.put(str.split(":")[0], getPic(session, str.split(":")[1])); + } + + + XSSFRow row1 = sheet.getRow(1); + if(row1==null) { + row1=sheet.createRow(1); + } + setCellValue(row1, 7, "主要联系人/电话Key Contact:"+headValue.get(2)); + setCellValue(row1, 14, headValue.get(3).toString()); + + XSSFRow row2 = sheet.getRow(2); + if(row2==null) { + row2=sheet.createRow(2); + } + setCellValue(row2, 5, headValue.get(1).toString()); + setCellValue(row2, 8, headValue.get(6).toString()); + setCellValue(row2, 14, headValue.get(4).toString()); + + XSSFRow row3 = sheet.getRow(4); + if(row3==null) { + row3=sheet.createRow(4); + } + setCellValue(row3, 0, headValue.get(5).toString()); + setCellValue(row3, 12, headValue.get(7).toString()); + + XSSFRow row4 = sheet.getRow(6); + if(row4==null) { + row4=sheet.createRow(6); + } + setCellValue(row4, 0, headValue.get(8).toString()); + setCellValue(row4, 7, headValue.get(9).toString()); + setCellValue(row4, 12, headValue.get(10).toString()); + + XSSFRow row5 = sheet.getRow(8); + if(row5==null) { + row5=sheet.createRow(8); + } + setCellValue(row5, 5, headValue.get(11).toString()); + setCellValue(row5, 7, headValue.get(12).toString()); + setCellValue(row5, 12, headValue.get(13).toString()); + + int startRow=12; + short h1= sheet.getRow(startRow).getHeight(); + if(tableValues.size()>34) { + sheet.shiftRows(46,sheet.getLastRowNum(), tableValues.size()-34 ); + } + + for(int n=0;n dataValeList=tableValues.get(n); + //for (int i = 0; i < dataValeList.size(); i++) { + XSSFRow row = null; + Boolean isCreat = false; + row = sheet.getRow(n + startRow); + if(n>=34) { + //sheet.shiftRows(n + startRow,sheet.getLastRowNum(), 1 ); + //row = sheet.getRow(n + startRow); + //row = sheet.createRow(n+ startRow); + row = sheet.createRow(n + startRow); + row.setHeight(h1); + combine2(sheet, new int[] {n+startRow}, new int[] {0,1}); + combine2(sheet, new int[] {n+startRow}, new int[] {3,4}); + isCreat = true; + } + if (isCreat) { + XSSFRow oldRow = sheet.getRow( startRow); + + if(oldRow==null) { + oldRow = sheet.createRow(startRow); + } + for (int j = 0; j < 17; j++) { + XSSFCell oldCell = oldRow.getCell(j); + if(oldCell==null) { + oldCell=oldRow.createCell(j); + } + XSSFCell newCell = row.createCell(j); + newCell.setCellStyle(oldCell.getCellStyle()); + newCell.setCellType(oldCell.getCellType()); + } + } + + //} + //循环添加列 + for(int j=0;j<17;j++) { + XSSFCell cell = row.getCell(j); + if(cell==null) { + cell=row.createCell(j); + } + if(j>1) { + if(j>4) { + if(j==8) {//特殊特性插入图片 + if(NameToPicpath.containsKey((String)dataValeList.get(j-2))) { + System.out.println((String)dataValeList.get(j-2)+"获取的路径为:"+NameToPicpath.get((String)dataValeList.get(j-2))); + insertPicture(sheet, wb, n + startRow, 8, NameToPicpath.get((String)dataValeList.get(j-2))); + } + }else { + cell.setCellValue((String)dataValeList.get(j-2)); + } + + }else if(j<4) { + + cell.setCellValue((String)dataValeList.get(j-1)); + } + }else if(j==0) { + cell.setCellValue((String)dataValeList.get(j)); + } + } + } + + //+++++++++++++ + + + + //获取合并单元格的信息 + for(int i=0;i rowList = tableValues.get(i); + if (rowList.get(15) != null && !rowList.get(15).equals("")) { + String sombine = rowList.get(15); + int rowDif = 0; + String[] sombines; + if (sombine.indexOf("-") >= 0) { + sombines = sombine.split("-"); + } else { + sombines = new String[] { sombine }; + } + for (int j = 0; j < sombines.length; j++) { + if (sombines[j].indexOf("/") >= 0) { + int[] row; + int[] cloumn; + String[] cells = sombines[j].split("/"); + if (cells[0].indexOf(",") >= 0) { + String[] rows = cells[0].split(","); + row = new int[rows.length]; + for (int k = 0; k < rows.length; k++) { + row[k] = Integer.parseInt(rows[k]) + rowDif; + } + } else { + row = new int[] { Integer.parseInt(cells[0]) + rowDif }; + } + if (cells[1].indexOf(",") >= 0) { + String[] cloumns = cells[1].split(","); + cloumn = new int[cloumns.length]; + for (int k = 0; k < cloumns.length; k++) { + cloumn[k] = Integer.parseInt(cloumns[k]); + } + } else { + cloumn = new int[] { Integer.parseInt(cells[1]) }; + } + System.out.println("添加合并信息===>行:"+Arrays.toString(row)+"----列:"+Arrays.toString(cloumn)); + excelCombineMap.put(row, cloumn); + } + } + } + + } + System.out.println("合并信息===》"+excelCombineMap.toString()); + + + if (excelCombineMap != null && excelCombineMap.size() != 0) { + Iterator> it = excelCombineMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + List columnIndex = new ArrayList(); + for (int i = 0; i < entry.getValue().length; i++) { + columnIndex.add(entry.getValue()[i]); + } + int[] column = new int[columnIndex.size()]; + for (int i = 0; i < columnIndex.size(); i++) { + column[i] = columnIndex.get(i); + } + if (column.length > 0) { + combine(sheet, entry.getKey(), column); + } + } + } + //combine(sheet, new int[] {12,13,14}, new int[] {6,7}); + //+++++++++++++++++++ + FileOutputStream output = new FileOutputStream(new File(outPutPath)); + wb.write(output); + output.close(); + input.close(); + // file.setReadOnly(); + // + System.out.println("-------WRITE EXCEL OVER-------"); + return 0; + } + + /** + * 输出工艺卡到EXCEL表格中,竖版 + * + * @param controlPlanBean 控制计划信息 + * @param input 模版文件流 + * @param outputFilePath 需要输出的全路径 + * @throws IOException + */ + public static int writeGYKToExcel(TCSession session,List> productTableValue, List> processTableValue, + List headValue,File file,String outPutPath,String ID,String revID,String type) throws IOException { + file.setWritable(true); + InputStream input = new FileInputStream(file); + XSSFWorkbook wb = new XSSFWorkbook(input); + XSSFSheet sheet = wb.getSheetAt(0); + + + //获取特殊特性的图片 + TCPreferenceService service = session.getPreferenceService(); + String[] strs = service.getStringValues("ZF6_KZJH_TSTX"); + Map NameToPicpath=new HashMap(); + for(String str:strs) { + System.out.println("添加NameToPicpath===》"+str.split(":")[0]+"==="+getPic(session, str.split(":")[1])); + NameToPicpath.put(str.split(":")[0], getPic(session, str.split(":")[1])); + } + + + //根据工艺卡类型来插入表头数据 + XSSFRow row1 = sheet.getRow(0); + setCellValue(row1, 20, ID);//编号 + XSSFRow row2 = sheet.getRow(1); + setCellValue(row2, 20, revID);//版次 + XSSFRow row3 = sheet.getRow(4); + setCellValue(row3, 3, headValue.get(3).toString());//产品型号 + setCellValue(row3, 7, headValue.get(11).toString());//零件名称 + setCellValue(row3, 9, headValue.get(4).toString());//工序名称 + if(type.indexOf("车加工")>=0) { + setCellValue(row3, 13, headValue.get(7).toString());//设备型号 + setCellValue(row3, 17, headValue.get(10).toString());//刀具刀片型号 + }else if(type.indexOf("拉花键")>=0) { + setCellValue(row3, 13, headValue.get(7).toString());//设备型号 + setCellValue(row3, 17, headValue.get(10).toString());//刀具刀片型号 + }else if(type.indexOf("磨加工")>=0) { + setCellValue(row3, 13, headValue.get(7).toString());//设备型号 + setCellValue(row3, 17, headValue.get(5).toString());//砂轮油石规格 + setCellValue(row3, 21, headValue.get(6).toString());//砂轮油石材质 + }else if(type.indexOf("钻孔")>=0) { + setCellValue(row3, 13, headValue.get(7).toString());//设备型号 + setCellValue(row3, 17, headValue.get(10).toString());//刀具刀片型号 + }else if(type.indexOf("热处理")>=0) { + setCellValue(row3, 13, headValue.get(8).toString());//设备型号 + setCellValue(row3, 19, headValue.get(9).toString());//刀具刀片型号 + } + + + + //根据数据量增加行数 + int startRow1=33; + int startRow2=36; + XSSFRow oldRow1 = sheet.getRow( startRow1); + XSSFRow oldRow2 = sheet.getRow( startRow2); + short h1= oldRow1.getHeight(); + short h2= oldRow2.getHeight(); + //第一个表格添加行数 + if(productTableValue.size()>1) { + sheet.shiftRows(startRow1+1,sheet.getLastRowNum(), productTableValue.size()-1 ); + + } + + for(int i=1;i1) { + sheet.shiftRows(startRow2+1,sheet.getLastRowNum(), processTableValue.size()-1 ); + } + +// XSSFRow rowh2 = sheet.createRow(startRow2); +// rowh2.setHeight(h2); + for(int i=1;i value=productTableValue.get(i); + XSSFRow row = sheet.getRow(i+ startRow1); + row.getCell(1).setCellValue((value.get(1)==null||value.get(1).equals(""))?" ":value.get(1).toString()); + row.getCell(2).setCellValue((value.get(2)==null||value.get(2).equals(""))?" ":value.get(2).toString()); + //插入图片 + insertPicture(sheet, wb, i+ startRow1, 6, NameToPicpath.get((value.get(3)==null||value.get(3).equals(""))?" ":value.get(3).toString())); + //row.getCell(6).setCellValue((value.get(3)==null||value.get(3).equals(""))?" ":value.get(3).toString()); + row.getCell(7).setCellValue((value.get(4)==null||value.get(4).equals(""))?" ":value.get(4).toString()); + row.getCell(11).setCellValue((value.get(5)==null||value.get(5).equals(""))?" ":value.get(5).toString()); + row.getCell(16).setCellValue((value.get(6)==null||value.get(6).equals(""))?" ":value.get(6).toString()); + row.getCell(17).setCellValue((value.get(7)==null||value.get(7).equals(""))?" ":value.get(7).toString()); + row.getCell(19).setCellValue((value.get(8)==null||value.get(8).equals(""))?" ":value.get(8).toString()); + row.getCell(20).setCellValue((value.get(9)==null||value.get(9).equals(""))?" ":value.get(9).toString()); + row.getCell(22).setCellValue((value.get(10)==null||value.get(10).equals(""))?" ":value.get(10).toString()); + } + //插入process数据 + for(int i=0;i value=processTableValue.get(i); + System.out.println("value====>"+value); + XSSFRow row = sheet.getRow(i+ startRow2); + row.getCell(1).setCellValue((value.get(1)==null||value.get(1).equals(""))?" ":value.get(1).toString()); + row.getCell(2).setCellValue((value.get(2)==null||value.get(2).equals(""))?" ":value.get(2).toString()); + //插入图片 + //插入图片 + insertPicture(sheet, wb, i+ startRow2, 6, NameToPicpath.get((value.get(3)==null||value.get(3).equals(""))?" ":value.get(3).toString())); + //row.getCell(6).setCellValue((value.get(3)==null||value.get(3).equals(""))?" ":value.get(3).toString()); + row.getCell(7).setCellValue((value.get(4)==null||value.get(4).equals(""))?" ":value.get(4).toString()); + row.getCell(11).setCellValue((value.get(5)==null||value.get(5).equals(""))?" ":value.get(5).toString()); + row.getCell(18).setCellValue((value.get(6)==null||value.get(6).equals(""))?" ":value.get(6).toString()); + row.getCell(20).setCellValue((value.get(7)==null||value.get(7).equals(""))?" ":value.get(7).toString()); + row.getCell(22).setCellValue((value.get(8)==null||value.get(8).equals(""))?" ":value.get(8).toString()); + } + + + + + FileOutputStream output = new FileOutputStream(new File(outPutPath)); + wb.write(output); + output.close(); + input.close(); + // file.setReadOnly(); + System.out.println("-------WRITE EXCEL OVER-------"); + return 0; + } + + + + /** + * 输出装配工艺卡到EXCEL表格中,横板 + * + * @param controlPlanBean 控制计划信息 + * @param input 模版文件流 + * @param outputFilePath 需要输出的全路径 + * @throws IOException + */ + public static int writeZPGYKToExcel(TCSession session,List> productTableValue, List> processTableValue, + List headValue,File file,String outPutPath,String ID,String revID) throws IOException { + file.setWritable(true); + InputStream input = new FileInputStream(file); + XSSFWorkbook wb = new XSSFWorkbook(input); + XSSFSheet sheet = wb.getSheetAt(0); + + + //获取特殊特性的图片 + TCPreferenceService service = session.getPreferenceService(); + String[] strs = service.getStringValues("ZF6_KZJH_TSTX"); + Map NameToPicpath=new HashMap(); + for(String str:strs) { + System.out.println("添加NameToPicpath===》"+str.split(":")[0]+"==="+getPic(session, str.split(":")[1])); + NameToPicpath.put(str.split(":")[0], getPic(session, str.split(":")[1])); + } + + + //插入表头数据 + XSSFRow row1 = sheet.getRow(1); + setCellValue(row1, 30, ID); + setCellValue(row1, 34, revID); + setCellValue(row1, 16, headValue.get(3).toString()); + setCellValue(row1, 20, headValue.get(4).toString()); + setCellValue(row1, 24, headValue.get(7).toString()); + + + //根据数据量增加行数 + int startRow1=23; + int startRow2=22; + XSSFRow oldRow1 = sheet.getRow( startRow1); + //XSSFRow oldRow2 = sheet.getRow( startRow2); + short h1= oldRow1.getHeight(); + //short h2= oldRow2.getHeight(); + //第一个表格添加行数 + int addrows=0; + if(productTableValue.size()>=11||processTableValue.size()>=12) { + if(productTableValue.size()>=(processTableValue.size()-1)) { + addrows=productTableValue.size()-11; + }else { + addrows=processTableValue.size()-12; + } + sheet.shiftRows(startRow1+1,sheet.getLastRowNum(), addrows ); + + } + + for(int i=1;i<=addrows;i++) {//第一行不用新建 + XSSFRow row = sheet.createRow(i+ startRow1); + row.setHeight(h1); + //复制单元格格式 + for (int j = 0; j < 35; j++) { + XSSFCell oldCell = oldRow1.getCell(j); +// if(oldCell==null) { +// oldCell=oldRow1.createCell(j); +// } + XSSFCell newCell = row.createCell(j); + newCell.setCellStyle(oldCell.getCellStyle()); + newCell.setCellType(oldCell.getCellType()); + } + //合并单元格 + combine2(sheet, new int[] {i+startRow1}, new int[] {1,2}); + combine2(sheet, new int[] {i+startRow1}, new int[] {4,5,6}); + combine2(sheet, new int[] {i+startRow1}, new int[] {7,8,9,10}); + combine2(sheet, new int[] {i+startRow1}, new int[] {12,13}); + combine2(sheet, new int[] {i+startRow1}, new int[] {15,16}); + combine2(sheet, new int[] {i+startRow1}, new int[] {17,18}); + combine2(sheet, new int[] {i+startRow1}, new int[] {20,21}); + combine2(sheet, new int[] {i+startRow1}, new int[] {23,24,25}); + combine2(sheet, new int[] {i+startRow1}, new int[] {26,27,28}); + combine2(sheet, new int[] {i+startRow1}, new int[] {29,30}); + combine2(sheet, new int[] {i+startRow1}, new int[] {31,32}); + combine2(sheet, new int[] {i+startRow1}, new int[] {33,34}); + } +// //第一列表名列合并 +// combine2(sheet, new int[] {startRow1,startRow1+productTableValue.size()-1}, new int[] {0}); +// +// //第二个表格添加行数 +// startRow2=startRow2+productTableValue.size()-1; +// if(processTableValue.size()>1) { +// sheet.shiftRows(startRow2+1,sheet.getLastRowNum(), processTableValue.size()-1 ); +// } +// +// for(int i=1;i value=productTableValue.get(i); + XSSFRow row = sheet.getRow(i+ startRow1); + row.getCell(0).setCellValue((value.get(1)==null||value.get(1).equals(""))?" ":value.get(1).toString()); + row.getCell(1).setCellValue((value.get(2)==null||value.get(2).equals(""))?" ":value.get(2).toString()); + //插入图片 + insertPicture(sheet, wb, i+ startRow1, 3, NameToPicpath.get((value.get(3)==null||value.get(3).equals(""))?" ":value.get(3).toString())); + //row.getCell(6).setCellValue((value.get(3)==null||value.get(3).equals(""))?" ":value.get(3).toString()); + row.getCell(4).setCellValue((value.get(4)==null||value.get(4).equals(""))?" ":value.get(4).toString()); + row.getCell(7).setCellValue((value.get(5)==null||value.get(5).equals(""))?" ":value.get(5).toString()); + row.getCell(11).setCellValue((value.get(6)==null||value.get(6).equals(""))?" ":value.get(6).toString()); + row.getCell(12).setCellValue((value.get(7)==null||value.get(7).equals(""))?" ":value.get(7).toString()); + row.getCell(14).setCellValue((value.get(8)==null||value.get(8).equals(""))?" ":value.get(8).toString()); + row.getCell(15).setCellValue((value.get(9)==null||value.get(9).equals(""))?" ":value.get(9).toString()); + row.getCell(17).setCellValue((value.get(10)==null||value.get(10).equals(""))?" ":value.get(10).toString()); + } + //插入process数据 + for(int i=0;i value=processTableValue.get(i); + System.out.println("value====>"+value); + XSSFRow row = sheet.getRow(i+ startRow2); + row.getCell(19).setCellValue((value.get(1)==null||value.get(1).equals(""))?" ":value.get(1).toString()); + row.getCell(20).setCellValue((value.get(2)==null||value.get(2).equals(""))?" ":value.get(2).toString()); + //插入图片 + //插入图片 + insertPicture(sheet, wb, i+ startRow2, 22, NameToPicpath.get((value.get(3)==null||value.get(3).equals(""))?" ":value.get(3).toString())); + //row.getCell(6).setCellValue((value.get(3)==null||value.get(3).equals(""))?" ":value.get(3).toString()); + row.getCell(23).setCellValue((value.get(4)==null||value.get(4).equals(""))?" ":value.get(4).toString()); + row.getCell(26).setCellValue((value.get(5)==null||value.get(5).equals(""))?" ":value.get(5).toString()); + row.getCell(29).setCellValue((value.get(6)==null||value.get(6).equals(""))?" ":value.get(6).toString()); + row.getCell(31).setCellValue((value.get(7)==null||value.get(7).equals(""))?" ":value.get(7).toString()); + row.getCell(33).setCellValue((value.get(8)==null||value.get(8).equals(""))?" ":value.get(8).toString()); + } + + + + + FileOutputStream output = new FileOutputStream(new File(outPutPath)); + wb.write(output); + output.close(); + input.close(); + // file.setReadOnly(); + System.out.println("-------WRITE EXCEL OVER-------"); + return 0; + } + + + + /** + * + * @param session + * @param puid + * @return 返回图片缓存路径 + */ + public static String getPic(TCSession session,String puid) { + + String outFilePathp=""; + try { + TCComponentDataset Dataset = (TCComponentDataset)session + .stringToComponent(puid); + TCComponentTcFile[] tcFile; + TCComponentTcFile picFile; + tcFile =Dataset.getTcFiles(); + picFile=tcFile[0]; + outFilePathp = System.getenv("TEMP") + "\\"+picFile.toString(); + CopyPic(picFile.getFmsFile(),outFilePathp); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return outFilePathp; + } + + //复制图片 + public static void CopyPic(File path1,String path2) { + // 创建文件字节输入流对象 + FileInputStream fis = null; + // 创建文件字节输出流对象 + FileOutputStream fos = null; + try { + // 连接文件字节输入流 + fis = new FileInputStream(path1); + // 连接文件字节输出流 + fos = new FileOutputStream(path2); + //准备一个byte[]数组,存储字节码,大小为1024字节,即1KB + byte[] bytes = new byte[1024]; + int readCount = 0; + // 开始读和写 + while ((readCount = fis.read(bytes)) != -1) { + // 将数组中读到的字节码写入 + fos.write(bytes, 0, readCount); + } + // 最后刷新管道,强制输出完数据 + fos.flush(); + + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (fis != null) { + try { + fis.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (fos != null) { + try { + fos.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + + + + + /** + * 设置单元格 + * + * @param row1 + * @param index + * @param str + */ + public static void setCellValue(XSSFRow row1, int index, String str) { + XSSFCell cell = row1.getCell(index); + if(cell==null) { + cell=row1.createCell(index); + } + cell.setCellType(XSSFCell.CELL_TYPE_STRING); + cell.setCellValue(str); + } + + /** + * 设置单元格 + * + * @param row1 + * @param index + * @param str + */ + public static void setCellValue(Row row1, int index, String str) { + Cell cell = row1.getCell(index); + cell.setCellType(XSSFCell.CELL_TYPE_STRING); + cell.setCellValue(str); + } + + public static boolean combine(XSSFSheet sheet, int[] rows, int[] columns) { + boolean isOK = false; + if (rows.length <=1 && columns.length <=1) {//对单个单元格合并则跳过 + }else { + if(columns.length == 1&&columns[0]==1) { + System.out.println("-------合并第1列----"); + for(int row=0;row= firstRow && row <= lastRow) + { + if(column >= firstColumn && column <= lastColumn) + { + index = i; + } + } + } + sheet.removeMergedRegion(index);//移除合并单元格 + } + + /** + * 获取命名的引用 + * + * @param session + * @param item 对象的版本 + * @param relationType 关系名称 + */ + public static File getExcelToItem(TCSession session, TCComponentItemRevision item, String relationType, + String fileType) { + try { + TCComponent[] zyzdsChildrens = item.getRelatedComponents(relationType); + if (zyzdsChildrens == null || zyzdsChildrens.length < 1) { + return null; + } + for (TCComponent zyzdsChildren : zyzdsChildrens) { + if (fileType.equals(zyzdsChildren.getType())) { + TCComponentDataset dateSet = (TCComponentDataset) zyzdsChildren; + TCComponentTcFile[] tcFile = dateSet.getTcFiles(); + return tcFile[0].getFmsFile(); + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + public static void insertPicture(XSSFSheet sheet,XSSFWorkbook wb ,int row,int col,String fileUrl) { //, double scaleX, double scaleY + //, double scaleX, double scaleY + try { + + int row2=row; + ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream(); + if(fileUrl==null||fileUrl.equals("")||!new File(fileUrl).exists()) { + return; + } + BufferedImage bufferImg = ImageIO.read(new File(fileUrl)); + ImageIO.write(bufferImg, "png", byteArrayOut); + Drawing drawing = sheet.createDrawingPatriarch(); + XSSFClientAnchor anchor = new XSSFClientAnchor(); + int picHeight = 500; + int picWidth = 1050; + int rowHeight = 0; + for(int i =row;i<=row2;i++) { + rowHeight += sheet.getRow(i).getHeight(); + } + int strLength = sheet.getRow(row).getCell(col).getStringCellValue().length(); + int colWidth = sheet.getColumnWidth(col); + row2 +=1; + System.out.println("当前首行:"+row); + System.out.println("当前尾行:"+row2); + System.out.println("当前列:"+col); + System.out.println("行高:"+rowHeight); + System.out.println("当前列宽:"+colWidth); + + colWidth = sheet.getColumnWidth(col); + + int t3 = (int)(picHeight/15);//图片占单元格高度 + int t4 = (int)(picWidth/32);//图片占单元格宽度 + +// int t6 = (int)(strLength%t5!=0?strLength/t5+1:strLength/t5);//单元格文字行数 +// int t7 = (int)(t6*417/15);//文字占单元格高度 + int t8 = t3*2;//所需单元格高度 +// System.out.println("计算出文字行数:"+t6); +// System.out.println("计算出文字高度:"+t7); + System.out.println("当前单元格高度="+(int)(rowHeight/15)); + System.out.println("所需单元格高度="+t8); + if((int)(rowHeight/15)0) { + tempcolwid /= 2; + int t = (int)(rowHeight/15); + int t2 = (int)(tempcolwid/32); + System.out.println("t="+t); + System.out.println("t2="+t2); + anchor.setCol1(col); + anchor.setCol2(col); + anchor.setRow1(row); + anchor.setRow2(row2); + System.out.println("tw"+XSSFShape.EMU_PER_PIXEL); + System.out.println("tw"+t); + anchor.setDx1(XSSFShape.EMU_PER_PIXEL * t2); + anchor.setDx2(XSSFShape.EMU_PER_PIXEL * (t2+t4)); + if(row+1==row2) {//单行 + System.out.println("单行"); +// anchor.setDy1(XSSFShape.EMU_PER_PIXEL * 100); + anchor.setDy1(XSSFShape.EMU_PER_PIXEL * (t/5)); //-XSSFShape.EMU_PER_PIXEL*(t/3) +// anchor.setDy2(XSSFShape.EMU_PER_PIXEL * 1); + anchor.setDy2(XSSFShape.EMU_PER_PIXEL * (t3-4*t/5-2)); //-XSSFShape.EMU_PER_PIXEL*(t/3) + }else {//多行合并 + System.out.println("多行"); + int tempRow = row; + int row1Height = 0; + row1Height = sheet.getRow(tempRow).getHeight(); + int t9 = (int)(row1Height/15); + do { + if(t9>(t/2)||tempRow==row2)break; + tempRow++; + row1Height = sheet.getRow(tempRow).getHeight(); + t9 +=(int)(row1Height/15); + }while(true); + if(tempRow == row2)System.out.println("第"+row+"行,第"+col+"列未找到合适的行!"); + anchor.setRow1(tempRow); + anchor.setRow2(tempRow+1); + System.out.println("临时行:"+tempRow); + System.out.println("临时行高度:"+row1Height/15); +// anchor.setDy1(XSSFShape.EMU_PER_PIXEL * 150); +// anchor.setDy2(XSSFShape.EMU_PER_PIXEL * 500); + anchor.setDy1(XSSFShape.EMU_PER_PIXEL * (t9-t/2)); + anchor.setDy2(XSSFShape.EMU_PER_PIXEL * (t3+t9-t/2-row1Height/15)); + } +// anchor.setDy1(XSSFShape.EMU_PER_PIXEL * (t - t2/2)); +// anchor.setDy2(XSSFShape.EMU_PER_PIXEL * (-1*t + t2/2)); + } + System.out.println("y1="+anchor.getDy1()); + System.out.println("y2="+anchor.getDy2()); + + anchor.setAnchorType(ClientAnchor.MOVE_AND_RESIZE); + Picture picture = drawing.createPicture(anchor, wb.addPicture(byteArrayOut.toByteArray(), HSSFWorkbook.PICTURE_TYPE_JPEG)); +// picture.resize(1d); + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +// public static void insertPicture(XSSFSheet sheetAt,XSSFWorkbook wb ,int row,int col,String path) { //, double scaleX, double scaleY +// try { +// if(path==null||path.equals("")) { +// System.out.println("未找到图片,请检查首选项。"); +// return; +// }else if(!new File(path).exists()) { +// System.out.println("路径:"+path+",不存在图片,请检查首选项。"); +// return; +// } +// ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream(); +// BufferedImage bufferImg = ImageIO.read(new File(path)); +// int width = bufferImg.getWidth(); +// int height = bufferImg.getHeight(); +// double i = (double)width/(double)height; +// +// ImageIO.write(bufferImg, "png", byteArrayOut); +// //画图的顶级管理器,一个sheet只能获取一个(一定要注意这点) +// XSSFDrawing patriarch = sheetAt.createDrawingPatriarch(); +//// //anchor主要用于设置图片的属性 +//// +//// /** +//// * @param dx1 图片的左上角在开始单元格(col1,row1)中的横坐标 +//// * @param dy1 图片的左上角在开始单元格(col1,row1)中的纵坐标 +//// * @param dx2 图片的右下角在结束单元格(col2,row2)中的横坐标 +//// * @param dy2 图片的右下角在结束单元格(col2,row2)中的纵坐标 +//// * @param col1 开始单元格所处的列号, base 0, 图片左上角在开始单元格内 +//// * @param row1 开始单元格所处的行号, base 0, 图片左上角在开始单元格内 +//// * @param col2 结束单元格所处的列号, base 0, 图片右下角在结束单元格内 +//// * @param row2 结束单元格所处的行号, base 0, 图片右下角在结束单元格内 +//// */ +// //XSSFClientAnchor anchor = new XSSFClientAnchor(dx1, dy1, dx2, dy2,(short) col1, row1, (short) col2, row2); +// XSSFClientAnchor anchor = new XSSFClientAnchor(); +// anchor.setRow1(row); +// anchor.setRow2(row+1); +// //System.out.println("-----"+i); +// anchor.setCol1(col); +// anchor.setCol2(col+1); +// +//// anchor.setDx1(10); +//// anchor.setDy1(10); +// +// anchor.setAnchorType(ClientAnchor.DONT_MOVE_AND_RESIZE); +// +// +//// 插入图片wb.addPicture(byteArrayOut.toByteArray(), XSSFWorkbook.PICTURE_TYPE_PNG); +// XSSFPicture createPicture = patriarch.createPicture(anchor, wb.addPicture(byteArrayOut.toByteArray(), XSSFWorkbook.PICTURE_TYPE_PNG)); +//// +// System.out.println(createPicture); +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } + + + /** + * 改变数据集的命名引用 + * + * @param tccomponentDataset + * @param quote + * @param type + * @param path + * @throws TCException + */ + public static void changeDataSet(TCComponentDataset tccomponentDataset, String quote, String type, String path) + throws TCException { + String myPath[] = { path }; + String myQuote[] = { quote };// 引用"excel" + String myType[] = { type };// 类型"MSExcelX" + String myPlain[] = { "Plain" }; + + // 删除数据集的引用 + deleDateSetRef(tccomponentDataset); + // 数据集的替换 + tccomponentDataset.setFiles(myPath, myType, myPlain, myQuote); + + } + + /** + * 删除数据集的命名引用 + * + * @param dataset + * @throws TCException + */ + private static void deleDateSetRef(TCComponentDataset dataset) throws TCException { + + TCComponentTcFile[] tcFiles = dataset.getTcFiles(); + for (int i = 0; i < tcFiles.length; i++) { + // 得到数据集的引用类型 + String str_temp = getNamedRefType(dataset, tcFiles[i]); + // 删除引用 + dataset.removeNamedReference(str_temp); + } + + } + + /** + * 得到数据集的引用类型 + * + * @param datasetComponent + * @param tccomponent + * @return + * @throws TCException + */ + private static String getNamedRefType(TCComponentDataset datasetComponent, TCComponentTcFile tccomponent) + throws TCException { + String s; + s = ""; + TCProperty tcproperty; + TCProperty tcproperty1; + TCComponent atccomponent[]; + String as[]; + int i; + int j; + int k; + try { + tcproperty = datasetComponent.getTCProperty("ref_list"); + tcproperty1 = datasetComponent.getTCProperty("ref_names"); + if (tcproperty == null || tcproperty1 == null) + return s; + } catch (TCException tcexception) { + return s; + } + atccomponent = tcproperty.getReferenceValueArray(); + as = tcproperty1.getStringValueArray(); + if (atccomponent == null || as == null) + return s; + i = atccomponent.length; + if (i != as.length) + return s; + j = -1; + k = 0; + do { + if (k >= i) + break; + if (tccomponent == atccomponent[k]) { + j = k; + break; + } + k++; + } while (true); + if (j != -1) + s = as[j]; + return s; + } + + /** + * 获取命名的引用 + * + * @param session + * @param item 对象的版本 + * @param relationType 关系名称 + */ + public static TCComponentDataset getExcelToDataset(TCSession session, TCComponentItemRevision item, + String relationType, String fileType) { + try { + TCComponent[] zyzdsChildrens = item.getRelatedComponents(relationType); + if (zyzdsChildrens == null || zyzdsChildrens.length < 1) { + return null; + } + for (TCComponent zyzdsChildren : zyzdsChildrens) { + if (fileType.equals(zyzdsChildren.getType())) { + return (TCComponentDataset) zyzdsChildren; +// TCComponentTcFile[] tcFile = dateSet.getTcFiles(); +// return tcFile[0].getFmsFile(); + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + + /** + * 添加命名的引用 + * + * @param session + * @param item 对象的版本 + * @param tcResource 文件的物理路径 + * @param relationType 关系名称 + * @param fileName 文件名 + */ + public static void setExcelToItem(TCSession session, TCComponentItemRevision item, String tcResource, + String fileName, String relationType, String excelType, boolean isDelete) { + try { + String as1[] = { tcResource };// 文件的物理路径 + String as2[] = { "excel" }; + String as3[] = { excelType }; + String as4[] = { "Plain" }; + TCComponentDatasetType tccomponentDatasetType = (TCComponentDatasetType) session + .getTypeComponent("Dataset"); + TCComponentDataset tccomponentDataset = tccomponentDatasetType.create(fileName, "excel", excelType); + tccomponentDataset.setFiles(as1, as3, as4, as2); + AIFComponentContext[] zyzdsChildrens = item.getChildren(); + TCComponentItemRevision zyzdsRev = item; + for (AIFComponentContext zyzdsChildren : zyzdsChildrens) { + if (excelType.equals(zyzdsChildren.getComponent().getType())) { + TCComponentDataset dateSet = (TCComponentDataset) zyzdsChildren.getComponent(); + if (dateSet.getStringProperty("object_name").equals(fileName)) { + dateSet.delete(); + zyzdsRev.remove(relationType, dateSet); + } + } + } + item.add(relationType, tccomponentDataset); + if (isDelete) { + new File(tcResource).delete(); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + + + + +} diff --git a/src/com/connor/zf/controlplan/test.java b/src/com/connor/zf/controlplan/test.java new file mode 100644 index 0000000..90a4221 --- /dev/null +++ b/src/com/connor/zf/controlplan/test.java @@ -0,0 +1,42 @@ +package com.connor.zf.controlplan; +// +//import java.io.BufferedInputStream; +//import java.io.IOException; +//import java.io.InputStream; +//import java.util.Properties; +// +//import org.junit.Test; +// +public class test { +// @Test +// public void name() { +// InputStream input = null; +// input = new BufferedInputStream(getClass().getResourceAsStream( +// "/sql.properties")); +// +// Properties pro = new Properties(); +// try { +// +// System.out.println("=====>"+input); +// pro.load(input); +// String sql0 = String.format(pro.getProperty("CONTROLPLANSELECT"), +// "sss","ddddd"); +// System.out.println("=====>"+sql0); +// +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// }finally { +// try { +// +// input.close(); +// System.out.println("------------清理------------"); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// System.out.println("input异常"); +// e.printStackTrace(); +// } +// } +// +// } +} diff --git a/src/com/connor/zf/controlplanlibrary/CTMap.java b/src/com/connor/zf/controlplanlibrary/CTMap.java new file mode 100644 index 0000000..20cc67b --- /dev/null +++ b/src/com/connor/zf/controlplanlibrary/CTMap.java @@ -0,0 +1,331 @@ +package com.connor.zf.controlplanlibrary; + +import java.awt.Dimension; +import java.util.List; +import java.util.Vector; + +import javax.swing.event.TableModelEvent; +import javax.swing.table.DefaultTableModel; + +public class CTMap extends DefaultTableModel implements CellSpan { + protected int rowSize; + protected int columnSize; + protected int[][][] span; // CellSpan + protected boolean isEditable = false; + + private int row = -1; + private int column = -1; + + public int getRow() { + return row; + } + + public void setRow(int row) { + this.row = row; + } + + public int getColumn() { + return column; + } + + public void setColumn(int column) { + this.column = column; + } + + + public void setEditable(boolean isEditable) { + this.isEditable = isEditable; + } + + private List processRowList; + + public List getProcessRowList() { + return processRowList; + } + + public void setProcessRowList(List processRowList) { + this.processRowList = processRowList; + } + + @Override + public boolean isCellEditable(int arg0, int arg1) { + // TODO Auto-generated method stub + if (arg0 == row && arg1 == column) { + return this.isEditable; + } else { + return false; + } + //return this.isEditable; + } + + @Override + public void removeRow(int row) { + // 将可修改的行-1 + if (processRowList != null && processRowList.size() > 0) { + for (int i = processRowList.size() - 1; i >= 0; i--) { + if (processRowList.get(i) != null + && processRowList.get(i) == row) { + processRowList.remove(i); + } else if (processRowList.get(i) != null + && processRowList.get(i) > row) { + processRowList.set(i, processRowList.get(i) - 1); + } + } + } + super.removeRow(row); + } + + @Override + public int[] getSpan(int row, int column) { + // TODO Auto-generated method stub + if (isOutOfBounds(row, column)) { + int[] ret_code = { 1, 1 }; + return ret_code; + } + return span[row][column]; + } + + @Override + public void setSpan(int[] span, int row, int column) { + // TODO Auto-generated method stub + if (isOutOfBounds(row, column)) + return; + this.span[row][column] = span; + } + + @Override + public boolean isVisible(int row, int column) { + // TODO Auto-generated method stub + if (isOutOfBounds(row, column)) + return false; + if ((span[row][column][CellSpan.COLUMN] < 1) + || (span[row][column][CellSpan.ROW] < 1)) + return false; + return true; + } + + @Override + public void combine(int[] rows, int[] columns) { + // TODO Auto-generated method stub + + int rowSpan = rows.length; + int columnSpan = columns.length; + int startRow = rows[0]; + int startColumn = columns[0]; + for (int i = 0; i < rowSpan; i++) { + for (int j = 0; j < columnSpan; j++) { + if ((span[startRow + i][startColumn + j][CellSpan.COLUMN] != 1) + || (span[startRow + i][startColumn + j][CellSpan.ROW] != 1)) { + // System.out.println("can't combine"); + return; + } + } + } + for (int i = 0, ii = 0; i < rowSpan; i++, ii--) { + for (int j = 0, jj = 0; j < columnSpan; j++, jj--) { + span[startRow + i][startColumn + j][CellSpan.COLUMN] = jj; + span[startRow + i][startColumn + j][CellSpan.ROW] = ii; + // System.out.println("r " +ii +" c " +jj); + } + } + span[startRow][startColumn][CellSpan.COLUMN] = columnSpan; + span[startRow][startColumn][CellSpan.ROW] = rowSpan; + } + + // @Override + // public boolean isCellEditable(int arg0, int arg1) { + // if(arg1 == 1 ) + // { + // return false; + // } + // return super.isCellEditable(arg0, arg1); + // } + // + public void setSize(Dimension size) { + columnSize = size.width; + rowSize = size.height; + span = new int[rowSize][columnSize][2]; // 2: COLUMN,ROW + initValue(); + } + + protected boolean isOutOfBounds(int row, int column) { + if ((row < 0) || (rowSize <= row) || (column < 0) + || (columnSize <= column)) { + return true; + } + return false; + } + + public void addRow() { + + Vector newData = new Vector(getColumnCount()); + dataVector.add(newData); + + // + newRowsAdded(new TableModelEvent(this, getRowCount() - 1, + getRowCount() - 1, TableModelEvent.ALL_COLUMNS, + TableModelEvent.INSERT)); + int[][][] oldSpan = span; + int numRows = oldSpan.length; + int numColumns = oldSpan[0].length; + span = new int[numRows + 1][numColumns][2]; + System.arraycopy(oldSpan, 0, span, 0, numRows); + for (int i = 0; i < numColumns; i++) { + span[numRows][i][CellSpan.COLUMN] = 1; + span[numRows][i][CellSpan.ROW] = 1; + } + rowSize = span.length; + } + + public void addColumn(Object columnName) { + + int[][][] oldSpan = span; + int numRows = oldSpan.length; + int numColumns = oldSpan[0].length; + span = new int[numRows][numColumns + 1][2]; + for (int i = 0; i < span.length; i++) { + for (int j = 0; j < span[0].length; j++) { + span[i][j][CellSpan.COLUMN] = 1; + span[i][j][CellSpan.ROW] = 1; + } + } + + columnSize = span[0].length; + addColumn(columnName, (Vector) null); + } + + public void insertRow(int row) { + Vector rowData = new Vector(getColumnCount()); + int index = 0; + + dataVector.insertElementAt(rowData, row); + System.out.println("size:" + dataVector.size()); + + // + newRowsAdded(new TableModelEvent(this, row, row, + TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT)); + int[][][] newSpan = new int[span.length + 1][span[0].length][2]; + + int numRows = span.length; + int numColumns = span[0].length; + for (int i = 0; i < newSpan.length; i++) { + if (i < row) { + for (int j = 0; j < numColumns; j++) { + newSpan[i][j][0] = span[i][j][0]; + newSpan[i][j][1] = span[i][j][1]; + // newSpan[i][j][0] = 1; + // newSpan[i][j][1] = 1; + } + } else if (i == row) { + for (int j = 0; j < numColumns; j++) { + newSpan[i][j][0] = 1; + newSpan[i][j][1] = 1; + } + } else { + for (int j = 0; j < numColumns; j++) { + newSpan[i][j][0] = span[i - 1][j][0]; + newSpan[i][j][1] = span[i - 1][j][1]; + // newSpan[i][j][0] = 1; + // newSpan[i][j][1] = 1; + } + } + } + span = newSpan; + rowSize = span.length;// 将可修改的行+1 + if (processRowList != null && processRowList.size() > 0) { + + for (int i = processRowList.size() - 1; i >= 0; i--) { + if (!processRowList.contains(row) + && processRowList.get(i) != null + && processRowList.get(i) == row - 1) { + index = i + 1; + processRowList.add(i + 1, row); + } else if (processRowList.get(i) != null + && processRowList.get(i) == row) { + index = i + 1; + processRowList.add(i + 1, row + 1); + } else if (processRowList.get(i) != null && i > index + && processRowList.get(i) >= row) { + processRowList.set(i, processRowList.get(i) + 1); + } + } + + // if (processRowList.contains(row)) { + // for (int i = 0; i < processRowList.size(); i++) { + // if(processRowList.get(i) != null && processRowList.get(i) == row) + // { + // index = i+1; + // processRowList.add(i+1, row+1); + // } + // else if(processRowList.get(i) != null && i > index && + // processRowList.get(i) >= row+1) + // { + // processRowList.set(i, processRowList.get(i)+1); + // } + // } + // } + // else + // { + // for (int i = 0; i < processRowList.size(); i++) { + // if(processRowList.get(i) != null && processRowList.get(i) == + // row-1) + // { + // index = i+1; + // processRowList.add(i+1, row); + // } + // else if(processRowList.get(i) != null && i > index && + // processRowList.get(i) >= row) + // { + // processRowList.set(i, processRowList.get(i)+1); + // } + // } + // } + + } + + } + + public CTMap(int numRows, int numColumns) { + Vector names = new Vector(numColumns); + names.setSize(numColumns); + setColumnIdentifiers(names); + dataVector = new Vector(); + setNumRows(numRows); + setSize(new Dimension(numColumns, numRows)); + } + + protected void initValue() { + System.out.println(span.length); + for (int i = 0; i < span.length; i++) { + for (int j = 0; j < span[i].length; j++) { + span[i][j][CellSpan.COLUMN] = 1; + span[i][j][CellSpan.ROW] = 1; + } + } + } + + public void split(int row, int column) { + if (isOutOfBounds(row, column)) + return; + int columnSpan = span[row][column][CellSpan.COLUMN]; + int rowSpan = span[row][column][CellSpan.ROW]; + for (int i = 0; i < rowSpan; i++) { + for (int j = 0; j < columnSpan; j++) { + span[row + i][column + j][CellSpan.COLUMN] = 1; + span[row + i][column + j][CellSpan.ROW] = 1; + } + } + } + + public void removeCol() { + + columnIdentifiers.removeElementAt(columnIdentifiers.size() - 1); + dataVector.setSize(getRowCount()); + + for (int i = 0; i < getRowCount() - 1; i++) { + + ((Vector) dataVector.elementAt(i)).setSize(getColumnCount()); + } + fireTableStructureChanged(); + } +} diff --git a/src/com/connor/zf/controlplanlibrary/CTUI.java b/src/com/connor/zf/controlplanlibrary/CTUI.java new file mode 100644 index 0000000..8bbd994 --- /dev/null +++ b/src/com/connor/zf/controlplanlibrary/CTUI.java @@ -0,0 +1,107 @@ +package com.connor.zf.controlplanlibrary; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Point; +import java.awt.Rectangle; + +import javax.swing.JComponent; +import javax.swing.plaf.basic.BasicTableUI; +import javax.swing.table.TableCellRenderer; + +public class CTUI extends BasicTableUI { + + public void paint(Graphics g, JComponent c) { + Rectangle oldClipBounds = g.getClipBounds(); + Rectangle clipBounds = new Rectangle(oldClipBounds); + int tableWidth = ((CTable) table).getColumnModel() + .getTotalColumnWidth(); + clipBounds.width = Math.min(clipBounds.width, tableWidth); + g.setClip(clipBounds); + + int firstIndex = ((CTable) table) + .rowAtPoint(new Point(0, clipBounds.y)); + int lastIndex = ((CTable) table).getRowCount() - 1; + Rectangle rowRect = new Rectangle(0, 0, tableWidth, + ((CTable) table).getRowHeight() + + ((CTable) table).getRowMargin()); + rowRect.y = firstIndex * rowRect.height; + for (int index = firstIndex; index <= lastIndex; index++) { + if (rowRect.intersects(clipBounds)) { + // System.out.println(); // debug + // System.out.print("" + index +": "); // row + paintRow(g, index); + } + rowRect.y += rowRect.height; + } + g.setClip(oldClipBounds); + } + + private void paintRow(Graphics g, int row) { + Rectangle rect = g.getClipBounds(); + boolean drawn = false; + CellSpan cellAtt = (CellSpan) ((CTable) table).getModel(); + int numColumns = ((CTable) table).getColumnCount(); + + for (int column = 0; column < numColumns; column++) { + Rectangle cellRect = ((CTable) table) + .getCellRect(row, column, true); + + int cellRow, cellColumn; + if (cellAtt.isVisible(row, column)) { + cellRow = row; + cellColumn = column; + // System.out.print(" "+column+" "); // debug + } else { + cellRow = row + cellAtt.getSpan(row, column)[CellSpan.ROW]; + cellColumn = column + + cellAtt.getSpan(row, column)[CellSpan.COLUMN]; + // System.out.print(" ("+column+")"); // debug + } + if (cellRect.intersects(rect)) { + drawn = true; + paintCell(g, cellRect, cellRow, cellColumn); + } else { + if (drawn) + break; + } + } + + } + + private void paintCell(Graphics g, Rectangle cellRect, int row, int column) { + int spacingHeight = ((CTable) table).getRowMargin(); + int spacingWidth = ((CTable) table).getColumnModel().getColumnMargin(); + // System.out.println("X:"+cellRect.x+"Y:"+cellRect.y); + Color c = g.getColor(); + g.setColor(((CTable) table).getGridColor()); + g.drawRect(cellRect.x, cellRect.y, cellRect.width - 1, + cellRect.height - 1); + g.setColor(c); + + cellRect.setBounds(cellRect.x + spacingWidth / 2, cellRect.y + + spacingHeight / 2, cellRect.width - spacingWidth, + cellRect.height - spacingHeight); + + if (((CTable) table).isEditing() + && ((CTable) table).getEditingRow() == row + && ((CTable) table).getEditingColumn() == column) { + Component component = ((CTable) table).getEditorComponent(); + component.setBounds(cellRect); + component.validate(); + } else { + TableCellRenderer renderer = ((CTable) table).getCellRenderer(row, + column); + Component component = ((CTable) table).prepareRenderer(renderer, + row, column); + + if (component.getParent() == null) { + rendererPane.add(component); + } + rendererPane.paintComponent(g, component, ((CTable) table), + cellRect.x, cellRect.y, cellRect.width, cellRect.height, + true); + } + } +} \ No newline at end of file diff --git a/src/com/connor/zf/controlplanlibrary/CTable.java b/src/com/connor/zf/controlplanlibrary/CTable.java new file mode 100644 index 0000000..235cb3b --- /dev/null +++ b/src/com/connor/zf/controlplanlibrary/CTable.java @@ -0,0 +1,304 @@ +package com.connor.zf.controlplanlibrary; + +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseEvent; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.DefaultCellEditor; +import javax.swing.JComboBox; +import javax.swing.JTable; +import javax.swing.ListSelectionModel; +import javax.swing.event.ListSelectionEvent; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableModel; + +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; + + + +public class CTable extends JTable { + Map map; + TableCellTextAreaRenderer renderer = new TableCellTextAreaRenderer(); + TextAreaCellEditor cellEditor = new TextAreaCellEditor(); + ComboBoxCellEditor comboBoxCellEditor = new ComboBoxCellEditor( + new Object[] { 2, 3, 4, 5, 6, 7, 8, 9, 10 }); + TCSession session; + boolean isaddEn; +// ComboBoxCellEditor gaugeComboBoxCellEditor = new ComboBoxCellEditor(TMomMethodUtil.getPreferenceValues("RB3_GAUGE_VALUES")); +// ComboBoxCellEditor frequencyComboBoxCellEditor = new ComboBoxCellEditor(TMomMethodUtil.getPreferenceValues("RB3_FREQUENCY_VALUES")); +// +// ComboBoxCellEditor owningComboBoxCellEditor = new ComboBoxCellEditor(TMomMethodUtil.getPreferenceValues("RB3_OWNING_VALUES")); +// ComboBoxCellEditor reactionPlanComboBoxCellEditor = new ComboBoxCellEditor(TMomMethodUtil.getPreferenceValues("RB3_REACTION_VALUES")); +// ComboBoxCellEditor controlMethodComboBoxCellEditor = new ComboBoxCellEditor(TMomMethodUtil.getPreferenceValues("RB3_CONTROLMETHOD_VALUES")); + public CTable(TableModel model,TCSession session,boolean isaddEn) { + super(model); + setUI(new CTUI()); + this.session=session; + this.isaddEn=isaddEn; + getTableHeader().setReorderingAllowed(false); + setCellSelectionEnabled(true); + setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); +// // 添加键盘监听 +// this.addKeyListener(new KeyAdapter() { +// @Override +// public void keyPressed(KeyEvent arg0) { +// // TODO Auto-generated method stub +// if(arg0.getKeyChar() == KeyEvent.VK_DELETE) +// { +// int[] selectRows = CTable.this.getSelectedRows(); +// int[] selectColumns = CTable.this.getSelectedColumns(); +// for (int i = 0; i < selectRows.length; i++) { +// for (int j = 0; j < selectColumns.length; j++) { +// CTable.this.setValueAt("", selectRows[i], selectColumns[j]); +// } +// } +// } +// super.keyPressed(arg0); +// } +// }); + map = new HashMap(); + } + + public String getToolTipText(MouseEvent e) { + int row = this.rowAtPoint(e.getPoint()); + int col = this.columnAtPoint(e.getPoint()); + String tiptextString = null; + if (row > -1 && col > -1) { + Object value = this.getValueAt(row, col); + if (null != value && !"".equals(value)) + tiptextString = value.toString();// 悬浮显示单元格内容 + } + return tiptextString; + } + + // @Override + // protected void processKeyEvent(KeyEvent keyevent) { + // // TODO Auto-generated method stub + // if(keyevent.getKeyCode()==KeyEvent.VK_ENTER){ + // if(keyevent.isControlDown()) + // { + // System.out.println(1); + // } + // this.editCellAt(this.getSelectedRow(),this.getSelectedColumn()); + // } + // } + + public Rectangle getCellRect(int row, int column, boolean includeSpacing) { + Rectangle sRect = super.getCellRect(row, column, includeSpacing); + if ((row < 0) || (column < 0) || (getRowCount() <= row) + || (getColumnCount() <= column)) { + return sRect; + } + CellSpan cellAtt = (CellSpan) getModel(); + if (!cellAtt.isVisible(row, column)) { + int temp_row = row; + int temp_column = column; + row += cellAtt.getSpan(temp_row, temp_column)[CellSpan.ROW]; + column += cellAtt.getSpan(temp_row, temp_column)[CellSpan.COLUMN]; + } + int[] n = cellAtt.getSpan(row, column); + + int index = 0; + int columnMargin = getColumnModel().getColumnMargin(); + Rectangle cellFrame = new Rectangle(); + int aCellHeight = rowHeight + rowMargin; + cellFrame.y = row * aCellHeight; + cellFrame.height = n[CellSpan.ROW] * aCellHeight; + + Enumeration eeration = getColumnModel().getColumns(); + while (eeration.hasMoreElements()) { + TableColumn aColumn = (TableColumn) eeration.nextElement(); + cellFrame.width = aColumn.getWidth(); + if (index == column) + break; + cellFrame.x += cellFrame.width; + index++; + } + for (int i = 0; i < n[CellSpan.COLUMN] - 1; i++) { + TableColumn aColumn = (TableColumn) eeration.nextElement(); + cellFrame.width += aColumn.getWidth() + columnMargin; + } + + if (!includeSpacing) { + Dimension spacing = getIntercellSpacing(); + cellFrame.setBounds(cellFrame.x + spacing.width / 2, cellFrame.y + + spacing.height / 2, cellFrame.width - spacing.width, + cellFrame.height - spacing.height); + } + return cellFrame; + } + + // 隐藏列 + public void HiddenCell(int column) { + TableColumn tc = this.getTableHeader().getColumnModel() + .getColumn(column); + tc.setMaxWidth(0); + tc.setPreferredWidth(0); + tc.setWidth(0); + tc.setMinWidth(0); + this.getTableHeader().getColumnModel().getColumn(column).setMaxWidth(0); + this.getTableHeader().getColumnModel().getColumn(column).setMinWidth(0); + } + + private int[] rowColumnAtPoint(Point point) { + int[] retValue = { -1, -1 }; + int row = point.y / (rowHeight + rowMargin); + if ((row < 0) || (getRowCount() <= row)) + return retValue; + int column = getColumnModel().getColumnIndexAtX(point.x); + + CellSpan cellAtt = (CellSpan) getModel(); + + if (cellAtt.isVisible(row, column)) { + retValue[CellSpan.COLUMN] = column; + retValue[CellSpan.ROW] = row; + return retValue; + } + retValue[CellSpan.COLUMN] = column + + cellAtt.getSpan(row, column)[CellSpan.COLUMN]; + retValue[CellSpan.ROW] = row + + cellAtt.getSpan(row, column)[CellSpan.ROW]; + return retValue; + } + + public int rowAtPoint(Point point) { + return rowColumnAtPoint(point)[CellSpan.ROW]; + } + + public int columnAtPoint(Point point) { + return rowColumnAtPoint(point)[CellSpan.COLUMN]; + } + + public void columnSelectionChanged(ListSelectionEvent e) { + repaint(); + } + + public void valueChanged(ListSelectionEvent e) { + int firstIndex = e.getFirstIndex(); + int lastIndex = e.getLastIndex(); + if (firstIndex == -1 && lastIndex == -1) { // Selection cleared. + repaint(); + } + Rectangle dirtyRegion = getCellRect(firstIndex, 0, false); + int numCoumns = getColumnCount(); + int index = firstIndex; + for (int i = 0; i < numCoumns; i++) { + dirtyRegion.add(getCellRect(index, i, false)); + } + index = lastIndex; + for (int i = 0; i < numCoumns; i++) { + dirtyRegion.add(getCellRect(index, i, false)); + } + repaint(dirtyRegion.x, dirtyRegion.y, dirtyRegion.width, + dirtyRegion.height); + } + + public void setCombo(int row, int col, TableCellEditor ce) { + map.put(new Point(row, col), ce); + } + + @Override + public TableCellEditor getCellEditor(int row, int column) { + + if(isaddEn) { + if(column==6) { + TCPreferenceService service = session.getPreferenceService(); + String[] strs = service.getStringValues("ZF6_KZJH_TSTX"); + + String[] strss=new String[strs.length]; + for(int i=0;i> processRowList = new ArrayList>(); +// private TCComponentUser user;// 当前登录用户 +// private List> dataList = new ArrayList>();// 表格中的数据 +// private ControlPlanTreeBean bean; +// private Properties pro = new Properties(); +// private String[] header = new String[]{"PLMEID","气泡图编号","尺寸","产品","过程" +// ,"特殊特性分类","产品/过程/规格/公差","评估/测量方法","容量","频率","首件收减百分比","末件收减百分比","过程收减百分比","负责人","控制方法" +// ,"操作规范/记录表单编号","反应计划","父节点ID","特殊字符所在位置"}; +// +// public CopyOfTMom012ControlPlanLibraryCommand() { +// super(); +// } +// +// public CopyOfTMom012ControlPlanLibraryCommand(AbstractAIFApplication app, +// TCSession session,String commandId) { +// this.session = session; +// this.app = app; +// this.commandId = commandId; +// this.comp = app.getTargetComponent(); +// this.user = session.getUser(); +// } +//// /** +//// * 获取权限 +//// */ +//// private void getAuthority() { +//// ResultSet rs = null; +//// try { +//// SqlUtilT.getConnection("jdbc:Oracle:thin:@localhost:1521:TC10", +//// "tc10", "infodba"); +//// InputStream input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); +//// Properties pro = new Properties(); +//// pro.load(input); +//// //工艺的所有者 +//// String userName = form.getReferenceProperty("owning_user") +//// .getStringProperty("user_id"); +//// String sql; +//// if(user.getUserId().equals(userName)) +//// { +//// sql = String.format(pro.getProperty("CONTROLPLANSELECT3"),form.getUid()); +//// } +//// else +//// { +//// sql = String.format(pro.getProperty("CONTROLPLANSELECT2"),form.getUid(),user.getUserId()); +//// } +//// rs = SqlUtilT.read(sql); +//// while (rs.next()) { +//// List rowList = new ArrayList(); +//// rowList.add(rs.getString("RB3_MEOPID")); +//// } +//// } catch (Exception e) { +//// e.printStackTrace(); +//// } +//// } +// +//// /** +//// * 获取数据库中的数据 +//// */ +//// private void getData() { +//// // TODO Auto-generated method stub +//// ResultSet rs = null; +//// InputStream input = null; +//// try { +//// // 获取数据库连接 +////// SqlUtilT.getConnectionTC10(); +//// SqlUtilT.getConnection("jdbc:Oracle:thin:@localhost:1521:TC10", +//// "tc10", "infodba"); +//// input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); +//// Properties pro = new Properties(); +//// pro.load(input); +//// String sql = String +//// .format(pro.getProperty("PFMEALIBRARYSELECT")); +//// rs = SqlUtilT.read(sql); +//// while (rs.next()) { +//// List rowList = new ArrayList(); +//// rowList.add(rs.getString("PLMEID")); +//// rowList.add(rs.getInt("RB3_NO")); +//// rowList.add(rs.getString("RB3_STATION")); +//// rowList.add(rs.getString("RB3_REQUIREMENT")); +//// rowList.add(rs.getString("RB3_QZSXMS")); +//// rowList.add(rs.getString("RB3_QZSXHG")); +//// rowList.add(rs.getString("RB3_YZD")); +//// rowList.add(rs.getString("RB3_JB")); +//// rowList.add(rs.getString("RB3_QZSXQY")); +//// rowList.add(rs.getString("RB3_XXGCKZYF")); +//// rowList.add(rs.getString("RB3_PDS")); +//// rowList.add(rs.getString("RB3_XXGCKZTC")); +//// rowList.add(rs.getString("RB3_TCD")); +//// rowList.add(rs.getString("RB3_RPN")); +//// rowList.add(rs.getString("RB3_JYCS")); +//// rowList.add(rs.getString("RB3_ZZR")); +//// rowList.add(rs.getString("RB3_JHWCRQ")); +//// rowList.add(rs.getString("RB3_CQDCS")); +//// rowList.add(rs.getString("RB3_NEW_SEV")); +//// rowList.add(rs.getString("RB3_NEW_OCC")); +//// rowList.add(rs.getString("RB3_NEW_DET")); +//// rowList.add(rs.getString("RB3_NEW_RPN")); +//// rowList.add(rs.getString("RB3_IDEAL_STATE")); +//// rowList.add(rs.getString("RB3_SPECIAL")); +//// dataList.add(rowList); +//// } +//// } catch (Exception e) { +//// e.printStackTrace(); +//// } finally { +//// if (rs != null) { +//// SqlUtilT.free(rs); +//// } +//// if(input != null) +//// { +//// try { +//// input.close(); +//// } catch (IOException e) { +//// // TODO Auto-generated catch block +//// e.printStackTrace(); +//// } +//// } +//// SqlUtilT.freeAll(); +//// } +//// +//// } +// +//// /** +//// * 获取对象属性 +//// */ +//// public void getPropertys() { +//// // 获取选择的目标对象 +//// try { +//// // 获取选中对象的版本表单 +//// if (comp instanceof TCComponentItemRevision) { +//// AIFComponentContext[] context = ((TCComponentItemRevision) comp).getItem().whereReferenced(); +//// for (int i = 0; i < context.length; i++) { +//// if(context[i].getComponent().getType().equals("MEProcess")) +//// { +//// meprocess = (TCComponent) context[i].getComponent(); +//// } +//// } +//// form = ((TCComponentItemRevision) comp) +//// .getRelatedComponent("IMAN_master_form_rev"); +//// } +//// else +//// { +//// MessageBox.post("请选择版本对象!", "错误", MessageBox.ERROR); +//// return; +//// } +//// } catch (Exception e) { +//// e.printStackTrace(); +//// } +//// } +// +// /** +// * 获取数据库中的数据 +// */ +// private void getData() { +// // TODO Auto-generated method stub +// ResultSet rs = null; +// InputStream input = null; +// try { +// // 获取数据库连接 +// SqlUtilT.getConnectionTC10(); +//// SqlUtilT.getConnection("jdbc:Oracle:thin:@localhost:1521:TC10", +//// "tc10", "infodba"); +// String sql = String.format("select * from RB3_CONTROLPLAN_TREE where PARENT_ID is null"); +// rs = SqlUtilT.read(sql); +// List beans = new ArrayList(); +// while (rs.next()) { +// ControlPlanTreeBean bean = new ControlPlanTreeBean(); +// bean.setPlmeid(rs.getString("PLMEID")); +// bean.setId(rs.getString("ID")); +// bean.setName(rs.getString("NAME")); +// bean.setParentId(rs.getString("PARENT_ID")); +// beans.add(bean); +// } +// bean = getChidren(beans.get(0)); +// } catch (Exception e) { +// e.printStackTrace(); +// } finally { +// if (rs != null) { +// SqlUtilT.free(rs); +// } +// if(input != null) +// { +// try { +// input.close(); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// //SqlUtilT.freeAll(); +// } +// +// } +// +// public ControlPlanTreeBean getChidren(ControlPlanTreeBean controlPlanTreeBean) { +// // TODO Auto-generated method stub +// ResultSet rs = null; +// try { +// //查询权限库 +// String sql = String.format("select * from RB3_CONTROLPLAN_TREE where PARENT_ID = \'%s\'",controlPlanTreeBean.getId()); +// rs = SqlUtilT.read(sql); +// List beans = new ArrayList(); +// while (rs.next()) { +// ControlPlanTreeBean bean = new ControlPlanTreeBean(); +// bean.setPlmeid(rs.getString("PLMEID")); +// bean.setId(rs.getString("ID")); +// bean.setName(rs.getString("NAME")); +// bean.setParentId(rs.getString("PARENT_ID")); +// beans.add(bean); +// } +// if (beans.size() > 0) { +// controlPlanTreeBean.setChidrenBeans(beans); +// for (ControlPlanTreeBean controlPlanTreeBean2 : beans) { +// getChidren(controlPlanTreeBean2); +// } +// } +// return controlPlanTreeBean; +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// return controlPlanTreeBean; +// } +// +// public CTreeNode createNodes(DefaultMutableTreeNode node,ControlPlanTreeBean bean) { +// CTreeNode root = null; +// System.out.println(bean.getName()); +// root = new CTreeNode(bean); +// try { +// if(bean != null) +// { +// ResultSet rs = null; +// //查询权限库 +// String sql = String.format(pro.getProperty("CONTROLPLANLIBRARYSELECT"),bean.getId()); +// rs = SqlUtilT.read(sql); +// List> beans = new ArrayList>(); +// while (rs.next()) { +// List list = new ArrayList(); +// list.add(rs.getString("PLMEID")); +// //list.add(rs.getString("RB3_JQSB")); +// //list.add(rs.getString("RB3_SMJY")); +// list.add(rs.getString("RB3_QPTBH")); +// list.add(rs.getString("RB3_CC")); +// list.add(rs.getString("RB3_CP")); +// list.add(rs.getString("RB3_GC")); +// list.add(rs.getString("RB3_TSTX")); +// list.add(rs.getString("RB3_CPGC")); +// list.add(rs.getString("RB3_CLFF")); +// list.add(rs.getString("RB3_RL")); +// list.add(rs.getString("RB3_PL")); +// list.add(rs.getString("RB3_SJSJ")); +// list.add(rs.getString("RB3_GCSJ")); +// list.add(rs.getString("RB3_MJSJ")); +// list.add(rs.getString("RB3_FZR")); +// list.add(rs.getString("RB3_KZFF")); +// list.add(rs.getString("RB3_CZGF")); +// list.add(rs.getString("RB3_FYJH")); +// list.add(rs.getString("PARENT_ID")); +// list.add(rs.getString("RB3_SPECIAL")); +// beans.add(list); +// } +// if (beans.size() > 0) { +// final JTable table = getNewjTable(null, null, header,beans.size()+1); +// for (int i = 0; i < beans.size()+1; i++) { +// if(i == 0) +// { +// for (int j = 0; j < header.length; j++) { +// table.setValueAt(header[j], i, j); +// } +// } +// else +// { +// for (int j = 0; j < beans.get(i-1).size(); j++) { +// table.setValueAt(beans.get(i-1).get(j), i, j); +// } +// } +// } +// DefaultMutableTreeNode child = new DefaultMutableTreeNode(table); +// root.add(child); +// node.add(root); +// if(bean.getChidrenBeans() != null) +// { +// for (int i = 0; i < bean.getChidrenBeans().size(); i++) { +// createNodes(root,bean.getChidrenBeans().get(i)); +// } +// } +// } +// else if(bean.getChidrenBeans() == null || bean.getChidrenBeans().size() == 0) +// { +// if(node != null) +// { +// node.add(root); +// } +// } +// else +// { +// if(node != null) +// { +// node.add(root); +// } +// for (int i = 0; i < bean.getChidrenBeans().size(); i++) { +// createNodes(root,bean.getChidrenBeans().get(i)); +// } +// } +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// +// return root; +// } +// +// //Jtable通用方法 +// public CTable getNewjTable(CTable partsTable, DefaultTableModel dtm, +// Object[] titleNames,int rows) { +// int simpleLen = 100; +// int totleLen = 1000; +// if (partsTable == null) { +// CTMap map = new CTMap(rows, titleNames.length); +// map.setColumnIdentifiers(titleNames); +// map.setEditable(true); +// partsTable = new CTable(map); +// partsTable.setRowHeight(50); +// partsTable.HiddenCell(0); +// //隐藏列 +// partsTable.HiddenCell(titleNames.length-1); +// partsTable.HiddenCell(titleNames.length-2); +// //设置显示器渲染 +//// TableCellTextAreaRenderer renderer = new TableCellTextAreaRenderer(); +//// partsTable.setDefaultRenderer(Object.class, renderer); +// //partsTable.setRowHeight(1, 50); +// if (simpleLen * titleNames.length >= totleLen) { +// for (int i = 0; i < titleNames.length; i++) { +// partsTable.getColumnModel().getColumn(i) +// .setPreferredWidth(simpleLen); +// } +// partsTable.setAutoResizeMode(0); +// } else { +// partsTable.setAutoResizeMode(1); +// } +// } +// return partsTable; +// } +// +// @Override +// public void executeModal() throws Exception { +// // 获取版本表单的所有者 +// try { +// InputStream input = null; +// //获取SQL语句 +// input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); +// pro.load(input); +// //获取树形结构节点 +// getData(); +// final CTreeNode node = createNodes(null, bean); +// new Thread() { +// @Override +// public void run() { +// TMom012ControlPlanLibraryDialog dislog = new TMom012ControlPlanLibraryDialog( +// app, session,commandId,form, node,header,isOwning,titleName,titleLabel); +// } +// }.start(); +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// super.executeModal(); +// } +// } diff --git a/src/com/connor/zf/controlplanlibrary/CopyOfTMom012ControlPlanLibraryDialog.java b/src/com/connor/zf/controlplanlibrary/CopyOfTMom012ControlPlanLibraryDialog.java new file mode 100644 index 0000000..639a66d --- /dev/null +++ b/src/com/connor/zf/controlplanlibrary/CopyOfTMom012ControlPlanLibraryDialog.java @@ -0,0 +1,722 @@ +package com.connor.zf.controlplanlibrary; +//package com.connor.renben.process.plm.tmom012; +// +//import java.awt.BorderLayout; +//import java.awt.Dimension; +//import java.awt.FlowLayout; +//import java.awt.Font; +//import java.awt.Toolkit; +//import java.awt.event.ActionEvent; +//import java.awt.event.ActionListener; +//import java.sql.ResultSet; +//import java.sql.SQLException; +//import java.util.ArrayList; +//import java.util.Enumeration; +//import java.util.List; +//import java.util.UUID; +// +//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.JTree; +//import javax.swing.table.DefaultTableModel; +//import javax.swing.tree.DefaultMutableTreeNode; +//import javax.swing.tree.DefaultTreeCellRenderer; +//import javax.swing.tree.DefaultTreeModel; +// +//import com.connor.renben.process.plm.bean.ControlPlanTreeBean; +//import com.connor.renben.process.plm.sql.util.SqlUtilT; +//import com.connor.renben.process.plm.tmom013.TMom013PFMEALibraryOperation; +//import com.connor.renben.process.plm.util.CTreeNode; +//import com.connor.renben.process.plm.util.MyTableModel; +//import com.connor.renben.process.plm.util.TMomFinalUtil; +//import com.connor.renben.process.plm.util.TreeTableCellEditor; +//import com.connor.renben.process.plm.util.TreeTableCellRenderer; +//import com.teamcenter.rac.aif.AbstractAIFApplication; +//import com.teamcenter.rac.aif.AbstractAIFDialog; +//import com.teamcenter.rac.kernel.TCComponent; +//import com.teamcenter.rac.kernel.TCSession; +//import com.teamcenter.rac.util.MessageBox; +//import com.teamcenter.rac.util.PropertyLayout; +// +//public class CopyOfTMom012ControlPlanLibraryDialog extends AbstractAIFDialog implements ActionListener { +// +// private AbstractAIFApplication app; +// private TCSession session; +// private String titleName; +// private String title; +// private String commandId; +// //private CTMap map; +// static JScrollPane scrollPane; +//// private String[] header = new String[]{"PLM
EID","零件/工
艺编号","过程名称","机器,设备
,工装,夹具","气泡图编号","尺寸","产品","过程" +//// ,"特殊特
性分类","产品/过程/
规格/公差","评估/测
量方法","容量","频率","负责人","控制方法" +//// ,"操作规范/
记录表单
编号","反应计划"}; +// private String[] header; +// private List> dataValeList = new ArrayList>();; +// +// private CTreeNode node; +// private List deleteRows = new ArrayList(); +// private SpecialDialog specialDialog; +// private String nodeName;//节点名称 +// +// //界面所需控件 +// private JPanel titlePanel;//标题 +// private JLabel titleLabel; +// +// private JPanel treePanel;//树形结构 +// private static JTree tree; +// +// private JPanel rootPanel;//按钮 +// private JButton addButton;//添加行 +// private JButton addNodeButton;//添加节点 +// private JButton remButton;//移除行 +// private JButton remNodeButton;//移除节点 +// private JButton saveButton;//保存 +// private JButton addSpecialButton;//添加特殊符号 +// //JButton sendbutton = new JButton("导出"); +// +// +// public CopyOfTMom012ControlPlanLibraryDialog(AbstractAIFApplication app, +// TCSession session,String commandId,TCComponent form,CTreeNode node,String[] header,boolean isOwning,String titleName,String title) { +// super(); +// this.setLocationRelativeTo(null); +// //this.dataList = dataList; +// this.node = node; +// this.app = app; +// this.session = session; +// this.commandId = commandId; +// this.titleName =titleName; +// this.title = title; +// this.header = header; +// init(); +// } +// +//// /** +//// * 动态设置可修改列 +//// */ +//// public void setProcessRows(List> processRowList) { +//// for (int i = 0; i < processRowList.size(); i++) { +//// for (int j = 0; j < processRowList.get(i).size(); j++) { +//// this.processRows.add(processRowList.get(i).get(j)); +//// } +//// } +//// if(this.processRows != null && this.processRows.size()>0) +//// { +//// this.map.setProcessRowList(this.processRows); +//// } +//// } +// +// +// private void init() { +// this.setTitle(this.titleName); +// this.setPreferredSize(new Dimension(800, 600)); +// //初始化标题部分控件 +// this.titlePanel = new JPanel(); +// this.titleLabel = new JLabel(this.title); +// this.titleLabel.setFont(new Font("宋体", 1, 18)); +// this.titlePanel.add(titleLabel); +// +// this.treePanel = new JPanel(new BorderLayout()); +// this.tree = new JTree(this.node); +// this.tree.setRowHeight(0); +// this.tree.setCellRenderer(new TreeTableCellRenderer()); +// this.tree.setCellEditor(new TreeTableCellEditor(this.tree, new DefaultTreeCellRenderer())); +// this.tree.setEditable(true); +// //this.table = getjTable(null, null, header, null); +// //添加滚动条 +// this.treePanel.add(new JScrollPane(this.tree),BorderLayout.CENTER); +// +// this.rootPanel = new JPanel(new FlowLayout()); +// this.addNodeButton = new JButton("添加节点"); +// this.addButton = new JButton("添加行"); +// this.remButton = new JButton("移除行"); +// this.remNodeButton = new JButton("移除节点"); +// this.saveButton = new JButton("保存"); +// this.addSpecialButton = new JButton("添加特殊符号"); +// //this.sendbutton = new JButton("导出"); +// //this.sendbutton.addActionListener(this); +// this.rootPanel.add(addNodeButton); +// this.rootPanel.add(addButton); +// this.rootPanel.add(remButton); +// this.rootPanel.add(remNodeButton); +// this.rootPanel.add(saveButton); +// this.rootPanel.add(addSpecialButton); +// //this.rootPanel.add(sendbutton); +// +// JPanel centerPanel = new JPanel(new BorderLayout()); +// centerPanel.add(titlePanel, BorderLayout.NORTH); +// +// //添加鼠标监听 +// this.createActionEvent(); +// this.setLayout(new BorderLayout()); +// this.add(centerPanel, BorderLayout.NORTH); +// this.add(this.treePanel, BorderLayout.CENTER); +// // dialog.add(tablePanel, BorderLayout.CENTER); +// this.add(rootPanel, BorderLayout.SOUTH); +// this.pack(); +// this.showDialog(); +// +// +// } +// +// //添加监听 +// public void createActionEvent() { +// this.addButton.addActionListener(this); +// this.addNodeButton.addActionListener(this); +// this.remButton.addActionListener(this); +// this.remNodeButton.addActionListener(this); +// this.saveButton.addActionListener(this); +// this.addSpecialButton.addActionListener(this); +// } +//// /** +//// * 写入数据到Jtable中 +//// */ +//// private void setJTable() { +//// for (int i = 0; i < dataList.size(); i++) { +//// List rowList = dataList.get(i); +//// for (int j = 0; j < header.length; j++) { +//// map.setValueAt(rowList.get(j), i, j); +//// } +//// } +//// } +// +//// // Jtable通用方法 +//// public CTable getjTable(CTable partsTable, DefaultTableModel dtm, +//// Object[] titleNames, Object[][] values) { +//// int simpleLen = 100; +//// int totleLen = 1000; +//// if (partsTable == null) { +//// if(dataList.size() == 0) +//// { +//// this.map = new CTMap(1, titleNames.length); +//// this.map.setValueAt(1, 0, 1); +//// } +//// else +//// { +//// this.map = new CTMap(dataList.size(), titleNames.length); +//// } +//// map.setColumnIdentifiers(titleNames); +//// setJTable(); +//// partsTable = new CTable(map); +//// //partsTable.setRowHeight(1, 50); +//// //partsTable.setRowHeight(2, 100); +//// partsTable.setRowHeight(50); +//// //隐藏列 +//// partsTable.HiddenCell(0); +//// partsTable.HiddenCell(titleNames.length-1); +////// //设置显示器渲染 +//// TableCellTextAreaRenderer renderer = new TableCellTextAreaRenderer(); +//// partsTable.setDefaultRenderer(Object.class, renderer); +////// //设置编辑器渲染 +////// this.textAreaCellEditor = new TextAreaCellEditor(); +////// partsTable.setDefaultEditor(Object.class, this.textAreaCellEditor); +//// if (simpleLen * titleNames.length >= totleLen) { +//// for (int i = 0; i < titleNames.length; i++) { +//// partsTable.getColumnModel().getColumn(i) +//// .setPreferredWidth(simpleLen); +//// } +//// partsTable.setAutoResizeMode(0); +//// } else { +//// partsTable.setAutoResizeMode(1); +//// } +//// } +//// return partsTable; +//// } +// +// //Jtable通用方法 +// public CTable getNewjTable(CTable partsTable, DefaultTableModel dtm, +// Object[] titleNames,int rows) { +// int simpleLen = 100; +// int totleLen = 1000; +// if (partsTable == null) { +// CTMap map = new CTMap(rows, titleNames.length); +// map.setColumnIdentifiers(titleNames); +// map.setEditable(true); +// partsTable = new CTable(map); +// partsTable.setRowHeight(50); +// partsTable.HiddenCell(0); +// //隐藏列 +// partsTable.HiddenCell(titleNames.length-1); +// partsTable.HiddenCell(titleNames.length-2); +// //partsTable.setRowHeight(1, 50); +// if (simpleLen * titleNames.length >= totleLen) { +// for (int i = 0; i < titleNames.length; i++) { +// partsTable.getColumnModel().getColumn(i) +// .setPreferredWidth(simpleLen); +// } +// partsTable.setAutoResizeMode(0); +// } else { +// partsTable.setAutoResizeMode(1); +// } +// } +// return partsTable; +// } +// +// @Override +// public void actionPerformed(ActionEvent arg0) { +// Object source=arg0.getSource(); +// if(source.equals(this.addButton)) +// { +// DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getSelectionPath().getLastPathComponent(); +// //node.add(new DefaultMutableTreeNode("烧结")); +// if(node.getUserObject() instanceof CTable) +// { +// CTable table = ((CTable)node.getUserObject()); +// if(table.getSelectedRow() > -1) +// { +// ((CTMap)table.getModel()).insertRow(table.getSelectedRow()+1); +// table.setValueAt(table.getValueAt(table.getSelectedRow(), table.getColumnCount()-2), table.getSelectedRow()+1, table.getColumnCount()-2); +// table.revalidate(); +// table.repaint(); +// this.tree.updateUI(); +// } +// } +// else +// { +// JTable t2 = getNewjTable(null, null, header, 2); +// t2.setRowHeight(50); +// for (int i = 0; i < t2.getRowCount(); i++) { +// if(i == 0) +// { +// for (int j = 0; j < header.length; j++) { +// t2.setValueAt(header[j],i,j); +// } +// } +// else +// { +// t2.setValueAt(((ControlPlanTreeBean)node.getUserObject()).getId(), i, t2.getColumnCount()-2); +// } +// } +// DefaultMutableTreeNode child = new DefaultMutableTreeNode(t2); +// ((DefaultTreeModel)tree.getModel()).insertNodeInto(child,node,0); +// } +// } +// else if(source.equals(this.addNodeButton)) +// { +// final JFrame frame = new JFrame(); +// frame.setLocationRelativeTo(this); +// frame.setSize(new Dimension(200,100)); +// JLabel label = new JLabel("节点名称"); +// final JTextField field = new JTextField(20); +// JButton okButton = new JButton("确定"); +// okButton.addActionListener(new ActionListener() { +// +// @Override +// public void actionPerformed(ActionEvent arg0) { +// // TODO Auto-generated method stub +// nodeName = field.getText(); +// DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getSelectionPath().getLastPathComponent(); +// //node.add(new DefaultMutableTreeNode("烧结")); +// String selectSql = ""; +// String insterSql = ""; +// switch (commandId) { +// case "com.connor.renben.process.plm.commands.ControlPlanLibrary": +// selectSql = "select addId_Sequence.nextval as id from dual"; +// insterSql = "insert into RB3_CONTROLPLAN_TREE values(?,?,?,?)"; +// break; +// case "com.connor.renben.process.plm.commands.PFMEALibrary": +// selectSql = "select ADDPFMEAID_SEQUENCE.nextval as id from dual"; +// insterSql = "insert into RB3_PFMEA_TREE values(?,?,?,?)"; +// break; +// default: +// break; +// } +// String id = ""; +// try { +// ResultSet rs = SqlUtilT.read(selectSql); +// while (rs.next()) { +// id = rs.getString("id"); +// } +// } catch (SQLException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// UUID uid = UUID.randomUUID(); +// ControlPlanTreeBean bean = new ControlPlanTreeBean(); +// bean.setPlmeid(uid.toString().replace("-", "")); +// bean.setId(id); +// bean.setName(nodeName); +// bean.setParentId(((ControlPlanTreeBean)node.getUserObject()).getId()); +// if(((ControlPlanTreeBean)node.getUserObject()).getChidrenBeans() == null) +// { +// List beanList = new ArrayList(); +// beanList.add(bean); +// ((ControlPlanTreeBean)node.getUserObject()).setChidrenBeans(beanList); +// } +// else +// { +// ((ControlPlanTreeBean)node.getUserObject()).getChidrenBeans().add(bean); +// } +// ((DefaultTreeModel)tree.getModel()).insertNodeInto(new CTreeNode(bean),node,0); +// SqlUtilT.write(new String[]{uid.toString().replace("-", ""),id,nodeName,bean.getParentId()},insterSql); +// frame.dispose(); +// } +// }); +// JButton celButton = new JButton("取消"); +// celButton.addActionListener(new ActionListener() { +// +// @Override +// public void actionPerformed(ActionEvent arg0) { +// frame.dispose(); +// } +// }); +// JPanel jPanel = new JPanel(new PropertyLayout()); +// jPanel.add("1.1.left.top",label); +// jPanel.add("1.2.left.top",field); +// JPanel rootJPanel = new JPanel(new FlowLayout()); +// rootJPanel.add(okButton); +// rootJPanel.add(celButton); +// JPanel panel = new JPanel(new BorderLayout()); +// panel.add(new JScrollPane(jPanel),BorderLayout.CENTER); +// panel.add(rootJPanel,BorderLayout.SOUTH); +// frame.add(panel); +// frame.show(); +// } +// else if(source.equals(this.remButton)) +// { +// DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getSelectionPath().getLastPathComponent(); +// //node.add(new DefaultMutableTreeNode("烧结")); +// if(node.getUserObject() instanceof CTable) +// { +// CTable table = ((CTable)node.getUserObject()); +// if(table.getSelectedRow() >= 1 && table.getSelectedColumn() > 0) +// { +// (table.getCellEditor(table.getSelectedRow(), table.getSelectedColumn())).stopCellEditing(); +// int row = table.getSelectedRow(); +// if(((CTMap)table.getModel()).getValueAt(table.getSelectedRow(), 0) != null) +// { +// deleteRows.add(((CTMap)table.getModel()).getValueAt(table.getSelectedRow(), 0).toString()); +// } +// ((CTMap)table.getModel()).removeRow(table.getSelectedRow()); +// table.revalidate(); +// table.repaint(); +// this.tree.updateUI(); +// } +// } +// } +// else if(source.equals(this.remNodeButton)) +// { +// DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getSelectionPath().getLastPathComponent(); +// //node.add(new DefaultMutableTreeNode("烧结")); +// if(node.getUserObject() instanceof CTable) +// { +// if(((DefaultMutableTreeNode)node.getParent()).getUserObject() instanceof ControlPlanTreeBean) +// { +// ControlPlanTreeBean parentNode = ((ControlPlanTreeBean)((DefaultMutableTreeNode)node.getParent()).getUserObject()); +// ((DefaultTreeModel)tree.getModel()).removeNodeFromParent(node); +// String deleteSql = ""; +// switch (commandId) { +// case "com.connor.renben.process.plm.commands.ControlPlanLibrary": +// deleteSql = String.format("delete from RB3_CONTROLPLAN_TREE where PARENT_ID = \'%s\'", parentNode.getId()); +// break; +// case "com.connor.renben.process.plm.commands.PFMEALibrary": +// deleteSql = String.format("delete from RB3_PFMEA_TREE where PARENT_ID = \'%s\'", parentNode.getId()); +// break; +// default: +// break; +// } +// SqlUtilT.delete(deleteSql); +// } +// } +// else +// { +// //node.add(new DefaultMutableTreeNode("烧结")); +// if(node.getUserObject() instanceof ControlPlanTreeBean) +// { +// if(((DefaultMutableTreeNode)node.getParent()).getUserObject() instanceof ControlPlanTreeBean) +// { +// ControlPlanTreeBean parentNode = ((ControlPlanTreeBean)((DefaultMutableTreeNode)node.getParent()).getUserObject()); +// if(parentNode.getChidrenBeans() != null && parentNode.getChidrenBeans().contains((ControlPlanTreeBean)node.getUserObject())) +// { +// parentNode.getChidrenBeans().remove((ControlPlanTreeBean)node.getUserObject()); +// } +// } +// ((DefaultTreeModel)tree.getModel()).removeNodeFromParent(node); +// String deleteSql = ""; +// switch (commandId) { +// case "com.connor.renben.process.plm.commands.ControlPlanLibrary": +// deleteSql = String.format("delete from RB3_CONTROLPLAN_TREE where plmeid = \'%s\'", ((ControlPlanTreeBean)node.getUserObject()).getPlmeid()); +// break; +// case "com.connor.renben.process.plm.commands.PFMEALibrary": +// deleteSql = String.format("delete from RB3_PFMEA_TREE where plmeid = \'%s\'", ((ControlPlanTreeBean)node.getUserObject()).getPlmeid()); +// break; +// default: +// break; +// } +// SqlUtilT.delete(deleteSql); +// } +// } +// } +// else if(source.equals(this.saveButton)) +// { +// okEvent(true); +// this.disposeDialog(); +// this.dispose(); +// } +// else if(source.equals(addSpecialButton)) +// { +// if (this.specialDialog == null) { +// DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getSelectionPath().getLastPathComponent(); +// if(node.getUserObject() instanceof CTable) +// { +// CTable table = ((CTable)node.getUserObject()); +// System.out.println(table.getSelectedRow()+"==="+table.getSelectedColumn()); +// this.specialDialog = new SpecialDialog(); +// } +// } else { +// DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getSelectionPath().getLastPathComponent(); +// //node.add(new DefaultMutableTreeNode("烧结")); +// if(node.getUserObject() instanceof CTable) +// { +// CTable table = ((CTable)node.getUserObject()); +// System.out.println(table.getSelectedRow()+"==="+table.getSelectedColumn()); +// this.specialDialog.show(); +// } +// } +// } +// else +// { +// this.disposeDialog(); +// this.dispose(); +// //this.setVisible(false); +// } +// } +// +// private void okEvent(boolean isSave) { +// // TODO Auto-generated method stub +// //将数据保存到表单中 +// try { +// if(tree.getSelectionPath() != null) +// { +// DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getSelectionPath().getLastPathComponent(); +// if(node.getUserObject() instanceof CTable) +// { +// CTable table = ((CTable)node.getUserObject()); +// if(table.getSelectedRow() >= 0 && table.getSelectedColumn() >= 0) +// { +// (table.getCellEditor(table.getSelectedRow(), table.getSelectedColumn())).stopCellEditing(); +// } +// } +// } +//// if(isOwning) +//// { +//// } +// //获取JTable中的数据 +// this.dataValeList.clear(); +// List> dataValeList = getTableValue(this.node); +// switch (commandId) { +// case "com.connor.renben.process.plm.commands.ControlPlanLibrary": +// TMom012ControlPlanLibraryOperation operation = new TMom012ControlPlanLibraryOperation(this.session,dataValeList,deleteRows); +// session.queueOperation(operation); +// break; +// case "com.connor.renben.process.plm.commands.PFMEALibrary": +// TMom013PFMEALibraryOperation pfmeaOperation = new TMom013PFMEALibraryOperation(this.session,dataValeList,deleteRows); +// session.queueOperation(pfmeaOperation); +// break; +// default: +// break; +// } +// } catch (Exception e) { +// // TODO Auto-generated catch block +// MessageBox.post(e.toString(), "错误", MessageBox.ERROR); +// e.printStackTrace(); +// } +// } +// +// private List> getTableValue(DefaultMutableTreeNode node) { +// // TODO Auto-generated method stub +// Enumeration children = node.children(); +// while (children.hasMoreElements()) { +// DefaultMutableTreeNode child = children.nextElement(); +// if (child.getUserObject() instanceof CTable) +// { +// CTable table = ((CTable)child.getUserObject()); +// for (int j = 1; j < table.getRowCount(); j++) { +// List rowValue = new ArrayList(); +// for (int j2 = 0; j2 < table.getColumnCount(); j2++) { +// if(table.getValueAt(j, j2) != null) +// { +// rowValue.add(table.getValueAt(j, j2).toString()); +// } +// else +// { +// rowValue.add(""); +// } +// } +// dataValeList.add(rowValue); +// } +// } +// else +// { +// getTableValue(child); +// } +// } +// +//// for (int i = 0; i < tree.getComponents().length; i++) { +//// for (int j = 0; j < table.getRowCount(); j++) { +//// List rowValue = new ArrayList(); +//// for (int j2 = 0; j2 < this.map.getColumnCount(); j2++) { +//// if(table.getValueAt(j, j2) != null) +//// { +//// rowValue.add(table.getValueAt(j, j2).toString()); +//// } +//// else +//// { +//// rowValue.add(""); +//// } +//// } +//// rowValue.add(""); +//// dataValeList.add(rowValue); +//// } +//// } +//// for (int i = 0; i < processRowList.size(); i++) { +//// List rows = processRowList.get(i); +//// } +// return dataValeList; +// } +// +// private int[] Union(int[] a1, int[] a2) { +// List list1 = new ArrayList(); +// List list2 = new ArrayList(); +// for (int i : a1) { +// list1.add(i); +// } +// for (int i : a2) { +// list2.add(i); +// } +// list1.removeAll(list2); +// list2.addAll(list1); +// int[] result = new int[list2.size()]; +// for (int i = 0; i < list2.size(); i++) { +// result[i] = list2.get(i); +// } +// return result; +// } +// +// private class SpecialDialog extends AbstractAIFDialog implements ActionListener +// { +// private JPanel tablePanel;//表格控件 +// private JTable table; +// +// private JPanel rootPanel;//按钮 +// private JButton okButton;//确定 +// private JButton celButton;//取消 +// +// public SpecialDialog() { +// // TODO Auto-generated constructor stub +// super(); +// init(); +// } +// private void init() { +// // TODO Auto-generated method stub +// this.setTitle("选择特殊符号"); +// this.table = getjTable(this.table, null,new Object[]{1,2,3,4,5,6,7,8}, new Object[][]{{1,2,3,4,5,6,7,8},{9,0,"q","w","e","r","t","y"}}); +// this.setLocationRelativeTo(this); +// this.table.setRowHeight(30); +// this.table.getTableHeader().setVisible(false); +// this.table.setFont(new Font("Y14.5M", 0, 15)); +// this.tablePanel = new JPanel(new BorderLayout()); +// this.tablePanel.add(this.table); +// +// this.okButton = new JButton("确定"); +// this.okButton.addActionListener(this); +// this.celButton = new JButton("取消"); +// this.celButton.addActionListener(this); +// this.rootPanel = new JPanel(new FlowLayout()); +// this.rootPanel.add(this.okButton); +// this.rootPanel.add(this.celButton); +// +// this.add(this.tablePanel, BorderLayout.CENTER); +// this.add(this.rootPanel, BorderLayout.SOUTH); +// this.pack(); +// this.show(); +// } +// +// // Jtable通用方法 +// public JTable getjTable(JTable partsTable, DefaultTableModel dtm, +// Object[] titleNames, Object[][] values) { +// int simpleLen = 100; +// int totleLen = 1000; +// if (partsTable == null) { +// partsTable = new JTable(this.getTableModel(dtm, titleNames, values)); +// partsTable.setCellSelectionEnabled(true); +// if (simpleLen * titleNames.length >= totleLen) { +// for (int i = 0; i < titleNames.length; i++) { +// partsTable.getColumnModel().getColumn(i) +// .setPreferredWidth(simpleLen); +// } +// partsTable.setAutoResizeMode(0); +// } else { +// partsTable.setAutoResizeMode(1); +// } +// } +// return partsTable; +// } +// +// public DefaultTableModel getTableModel(DefaultTableModel dtm, +// Object[] titleNames, Object[][] values) { +// MyTableModel tableModel = null; +// if (dtm == null) { +// tableModel = new MyTableModel(values, titleNames); +// } +// return tableModel; +// } +// +// @Override +// public void actionPerformed(ActionEvent actionevent) { +// // TODO Auto-generated method stub +// Object source = actionevent.getSource(); +// if(source.equals(this.okButton)) +// { +// DefaultMutableTreeNode node = (DefaultMutableTreeNode) CopyOfTMom012ControlPlanLibraryDialog.tree.getSelectionPath().getLastPathComponent(); +// //node.add(new DefaultMutableTreeNode("烧结")); +// if(node.getUserObject() instanceof CTable) +// { +// CTable table = ((CTable)node.getUserObject()); +// int row = table.getSelectedRow(); +// int column = table.getSelectedColumn(); +// //保存特殊符号位置 +// String columnName = table.getColumnName(table.getSelectedColumn()); +// +// int cursorIndex = ((TextAreaCellEditor)(table.getCellEditor(row, column))).getIndex(); +// System.out.println("index+"+cursorIndex); +// (table.getCellEditor(row, column)).stopCellEditing(); +// //TMom010SetPFMEADialog.table.getDefaultEditor(Object.class).stopCellEditing(); +// StringBuilder sb = new StringBuilder(table.getValueAt(row, column).toString()); +// +// //定义循环,如果index的位置不是-1,就一直查找 +// Integer index = 0; +// while((index = sb.toString().indexOf("\n",index))!=-1){ +// +// //每循环一次就要明确下一次查找的位置 +// index = index+"\n".length(); +// //每查找一次计数器自增 +// cursorIndex ++; +// } +// //特殊符号 +// Object special = table.getValueAt(row, table.getColumnCount()-1); +// if(special == null || special.toString() == "") +// { +// table.setValueAt(columnName+"-"+cursorIndex, row, table.getColumnCount()-1); +// } +// else +// { +// table.setValueAt(special+"|"+columnName+"-"+cursorIndex, row, table.getColumnCount()-1); +// } +// System.out.println(sb.length()); +// String s = sb.insert(cursorIndex, this.table.getValueAt(this.table.getSelectedRow(), this.table.getSelectedColumn()).toString()).toString(); +// table.setValueAt(s, table.getSelectedRow(), table.getSelectedColumn()); +// System.out.println(table.getValueAt(row, column).toString()); +// } +// } +// else +// { +// this.dispose(); +// } +// } +// } +// } diff --git a/src/com/connor/zf/controlplanlibrary/TMom012ControlPlanLibraryCommand.java b/src/com/connor/zf/controlplanlibrary/TMom012ControlPlanLibraryCommand.java new file mode 100644 index 0000000..ebe6cc6 --- /dev/null +++ b/src/com/connor/zf/controlplanlibrary/TMom012ControlPlanLibraryCommand.java @@ -0,0 +1,223 @@ +package com.connor.zf.controlplanlibrary; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Properties; + +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.table.DefaultTableModel; + +import com.connor.renben.process.plm.util.Adapter; +import com.connor.renben.process.plm.util.DraggableTabbedPane; +import com.connor.zf.controlplan.SqlUtilT; +import com.connor.zf.controlplan.TreeBean; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCSession; + +public class TMom012ControlPlanLibraryCommand extends AbstractAIFCommand { + + private TCSession session; + private AbstractAIFApplication app; + private String commandId; + private String titleName = "控制计划库"; + private String titleLabel = "CONTROL PLAN/控制计划"; + private InterfaceAIFComponent comp; + private TCComponent form; + private boolean isOwning = false; + // private List> processRowList = new + // ArrayList>(); + private TCComponentUser user;// 当前登录用户 + private List> dataList = new ArrayList>();// 表格中的数据 + private Properties pro = new Properties(); + private String[] header = new String[] {"PLMEID", "ID", + "机器、装置、夹具、工装","编号", "产品","过程","特殊特性分类", "产品/过程/规范/公差", + "计算测量技术", "项目","容量","频率","责任人", "控制方法","反应计划","节点PLMEID" }; + // 标签页 + // private JTabbedPane tabbedPane; + // private DraggableTabbedPane tabbedPane; + private List beans = new ArrayList(); + + public TMom012ControlPlanLibraryCommand() { + super(); + } + + public TMom012ControlPlanLibraryCommand(AbstractAIFApplication app, TCSession session, String commandId) { + this.session = session; + this.app = app; + this.commandId = commandId; + this.comp = app.getTargetComponent(); + this.user = session.getUser(); + } + + + /** + * 获取数据库中的数据 + */ + private void getData() { + // TODO Auto-generated method stub + ResultSet rs = null; + InputStream input = null; + try { + // 获取数据库连接 + SqlUtilT.getTCConnection(); + String sql = "select * from ZF6_CONTROLPLANLIBRARYTREE order by ID "; + // String sql = String.format("select * from RB3_CONTROLPLAN_TREE"); + rs = SqlUtilT.read(sql); + while (rs.next()) { + TreeBean bean = new TreeBean(); + bean.setPlmeid(rs.getString("PLMEID")); + bean.setId(rs.getString("ID")); + bean.setName(rs.getString("NAME")); + beans.add(bean); + } + Collections.sort(beans, new NaturalOrderComparator<>(true)); + beans.forEach(item -> System.out.println(item)); + // createTabbedPane(beans); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + + class NaturalOrderComparator implements Comparator { + + private final boolean caseInsensitive; + + public NaturalOrderComparator(boolean caseInsensitive) { + this.caseInsensitive = caseInsensitive; + } + + private int compareRight(String a, String b) { + int bias = 0; + int ia = 0; + int ib = 0; + for (; ; ia++, ib++) { + char ca = charAt(a, ia); + char cb = charAt(b, ib); + + if (!Character.isDigit(ca) && !Character.isDigit(cb)) { + return bias; + } else if (!Character.isDigit(ca)) { + return -1; + } else if (!Character.isDigit(cb)) { + return +1; + } else if (ca < cb) { + if (bias == 0) { + bias = -1; + } + } else if (ca > cb) { + if (bias == 0) { + bias = +1; + } + } else if (ca == 0 && cb == 0) { + return bias; + } + } + } + + @Override + public int compare(T o1, T o2) { + + TreeBean bean1 = (TreeBean)o1; + TreeBean bean2 = (TreeBean)o2; + + String a = bean1.getId(); + String b = bean2.getId(); + int ia = 0, ib = 0; + int nza = 0, nzb = 0; + char ca, cb; + int result; + while (true) { + nza = nzb = 0; + ca = charAt(a, ia); + cb = charAt(b, ib); + + while (ca == '0') { + nza++; + if (!Character.isDigit(charAt(a, ia + 1))) { + break; + } + ca = charAt(a, ++ia); + } + while (cb == '0') { + nzb++; + if (!Character.isDigit(charAt(b, ib + 1))) { + break; + } + cb = charAt(b, ++ib); + } + + if (Character.isDigit(ca) && Character.isDigit(cb)) { + if ((result = compareRight(a.substring(ia), b.substring(ib))) != 0) { + return result; + } + } + if (ca == 0 && cb == 0) { + return nza - nzb; + } + if (ca < cb) { + return -1; + } else if (ca > cb) { + return +1; + } + ++ia; + ++ib; + } + } + + private char charAt(String s, int i) { + if (i >= s.length()) { + return 0; + } else { + return caseInsensitive ? Character.toUpperCase(s.charAt(i)) : s.charAt(i); + } + } + } + + @Override + public void executeModal() throws Exception { + // 获取版本表单的所有者 + try { + InputStream input = null; + // 获取SQL语句 + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + pro.load(input); + // 获取树形结构节点 + getData(); + new Thread() { + @Override + public void run() { + TMom012ControlPlanLibraryDialog dislog = new TMom012ControlPlanLibraryDialog(app, session, + commandId, form, beans, header, isOwning, titleName, titleLabel); + } + }.start(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + super.executeModal(); + } +} diff --git a/src/com/connor/zf/controlplanlibrary/TMom012ControlPlanLibraryDialog.java b/src/com/connor/zf/controlplanlibrary/TMom012ControlPlanLibraryDialog.java new file mode 100644 index 0000000..80e9a14 --- /dev/null +++ b/src/com/connor/zf/controlplanlibrary/TMom012ControlPlanLibraryDialog.java @@ -0,0 +1,1326 @@ +package com.connor.zf.controlplanlibrary; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Locale; +import java.util.Properties; +import java.util.ResourceBundle; +import java.util.UUID; +import com.connor.zf.controlplan.SqlUtilT; +import com.connor.zf.controlplan.TreeBean; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.JTextPane; +import javax.swing.ListSelectionModel; +import javax.swing.RowSorter; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import javax.swing.event.TableModelEvent; +import javax.swing.event.TableModelListener; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; + +import com.connor.renben.process.plm.util.Adapter; +import com.connor.renben.process.plm.util.MyTableModel; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class TMom012ControlPlanLibraryDialog extends JFrame + implements ActionListener { + + private AbstractAIFApplication app; + private TCSession session; + private String titleName; + private String title; + private String commandId; + private String[] header2 = new String[]{"PLMEID","ID","名称"}; + private String[] header; + private List deleteRows = new ArrayList(); + private List beans; + private int index = -1; + private boolean isMeopSave = false; + private SpecialDialog specialDialog; + private String nodeName;// 节点名称 + private String nodeID;// 节点名称 + private int selectRow = -1; + private int selectColumn = -1; + //判断单元格显示框是否获取焦点 + private boolean isFocusOwner = false; + // 界面所需控件 + private JPanel titlePanel;// 标题 + private JLabel titleLabel; + private JTextPane selectCellValuePane; + //单行栏 + private CTable leftTable; + private CTable mainTable; + + //右键菜单 + private static JPopupMenu mainMenu; + private JMenuItem addItem; + private JMenuItem addItems; + private JMenuItem remItem; + private static JPopupMenu leftMenu; + private JMenuItem addNodeItem; + private JMenuItem remNodeItem; + private JMenuItem updateNodItem; + private JMenuItem shrinkColumnItem; + private JMenuItem celShrinkColumnItem; + + private JPanel rootPanel;// 按钮 + //private JButton addButton;// 添加行 + //private JButton addNodeButton;// 添加节点 + //private JButton remButton;// 移除行 + //private JButton remNodeButton;// 移除节点 + private JButton saveButton;// 保存 + //private JButton addSpecialButton;// 添加特殊符号 + + + public TMom012ControlPlanLibraryDialog(AbstractAIFApplication app, + TCSession session, String commandId, TCComponent form, + List beans, String[] header, boolean isOwning, + String titleName, String title) { + super(); + this.beans = beans; + this.app = app; + this.session = session; + this.commandId = commandId; + this.titleName = titleName; + this.title = title; + this.header = header; + init(); + } + + private void init() { + this.setTitle(this.titleName); + this.setPreferredSize(new Dimension(800, 600)); + // 初始化标题部分控件 + this.titlePanel = new JPanel(); + this.titleLabel = new JLabel(this.title); + this.titleLabel.setFont(new Font("宋体", 1, 18)); + this.titlePanel.add(titleLabel); + + this.leftTable = getNewjTable(null, null, header2, beans.size()); + + // 隐藏列 + leftTable.HiddenCell(0); + leftTable.setRowHeight(30); + //设置列宽 + leftTable.getColumnModel().getColumn(2) + .setPreferredWidth(200); + // 添加鼠标监听 + leftTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if(mouseevent.getButton() == MouseEvent.BUTTON3) + { + leftMenu.show(leftTable, mouseevent.getX(), mouseevent.getY()); + } + } + }); + for (int i = 0; i < beans.size(); i++) { + this.leftTable.setValueAt(beans.get(i).getPlmeid(), i, 0); + this.leftTable.setValueAt(beans.get(i).getId(), i, 1); + this.leftTable.setValueAt(beans.get(i).getName(), i, 2); + } + leftTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { + @Override + public void valueChanged(ListSelectionEvent arg0) { + // TODO Auto-generated method stub + if(index == -1) + { + refreshTable(); + index = leftTable.getSelectedRow(); + } + else if(index != -1 && index != leftTable.getSelectedRow()) + { + if (mainTable.getSelectedRow() >= 0 + && mainTable.getSelectedColumn() >= 0) { + (mainTable.getCellEditor(mainTable.getSelectedRow(), + mainTable.getSelectedColumn())).stopCellEditing(); + } + if(isMeopSave) + { + okEvent(true); + refreshTable(); + index = leftTable.getSelectedRow(); + }else { + refreshTable(); + index = leftTable.getSelectedRow(); + } + + } + } + }); + this.mainTable = getNewjTable(null, null, header, 0); + // 隐藏列 + mainTable.HiddenCell(0); + mainTable.HiddenCell(header.length - 1); + // 添加鼠标监听 + mainTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if (mouseevent.getClickCount() ==1) { + ((CTMap)mainTable.getModel()).setRow(mainTable.getSelectedRow()); + ((CTMap)mainTable.getModel()).setColumn(mainTable.getSelectedColumn()); + + if(isFocusOwner && selectRow != -1 && selectColumn != -1) + { + mainTable.setValueAt(selectCellValuePane.getText(), selectRow, selectColumn); + } + + if(mainTable.getValueAt(mainTable.getSelectedRow(), mainTable.getSelectedColumn()) != null) + { + selectCellValuePane.setText(""); + selectCellValuePane.setText(mainTable.getValueAt(mainTable.getSelectedRow(), mainTable.getSelectedColumn()).toString()); + } + else + { + selectCellValuePane.setText(""); + } + } + selectRow = mainTable.getSelectedRow(); + selectColumn = mainTable.getSelectedColumn(); + isFocusOwner = false; + if(mouseevent.getButton() == MouseEvent.BUTTON3) + { + mainMenu.show(mainTable, mouseevent.getX(), mouseevent.getY()); + } + } + }); + mainTable.getModel().addTableModelListener(new TableModelListener() { + + @Override + public void tableChanged(TableModelEvent tablemodelevent) { + // TODO Auto-generated method stub + if(tablemodelevent.getType() == TableModelEvent.UPDATE){ + isMeopSave = true; + System.out.println("执行失去焦点"); + (mainTable.getCellEditor(mainTable.getSelectedRow(), + mainTable.getSelectedColumn())).stopCellEditing(); + } + } + }); + mainTable.addKeyListener(new KeyAdapter() { + + @Override + public void keyPressed(KeyEvent arg0) { + // TODO Auto-generated method stub + //delete键清空 + if (arg0.getKeyChar() == KeyEvent.VK_DELETE) { + int[] selectRows = mainTable.getSelectedRows(); + int[] selectColumns = mainTable.getSelectedColumns(); + + for (int i = 0; i < selectRows.length; i++) { + + for (int j = 0; j < selectColumns.length; j++) { + if(selectColumns.length==mainTable.getColumnCount()) {//Ctrl+A全选时 + if(j>0&&j> rowList = new ArrayList>(); + while (rs.next()) { + List list = new ArrayList(); + list.add(rs.getString("PLMEID")); + list.add(rs.getString("ID")); + list.add(rs.getString("JQZHJJGZ")); + list.add(rs.getString("BH")); + list.add(rs.getString("CP")); + list.add(rs.getString("GC")); + list.add(rs.getString("TSTXFL")); + list.add(rs.getString("CPGC")); + list.add(rs.getString("JSCLJS")); + list.add(rs.getString("XM")); + list.add(rs.getString("RL")); + list.add(rs.getString("PL")); + list.add(rs.getString("ZRR")); + list.add(rs.getString("KZFF")); + list.add(rs.getString("FYJH")); + list.add(rs.getString("PARENTPLMEID")); + rowList.add(list); + } + if (rowList.size() > 0) { + CTMap map = new CTMap(rowList.size(),header.length); + map.setColumnIdentifiers(header); + map.setEditable(true); + mainTable.setModel(map); + mainTable.getColumnModel().getColumn(2) + .setPreferredWidth(300); + for (int j = 0; j < rowList.size(); j++) { + for (int k = 0; k < rowList.get(j).size(); k++) { + mainTable.setValueAt(rowList.get(j).get(k), j, k); + } + } + map.addTableModelListener(new TableModelListener() { + + @Override + public void tableChanged(TableModelEvent tablemodelevent) { + // TODO Auto-generated method stub + if(tablemodelevent.getType() == TableModelEvent.UPDATE){ + isMeopSave = true; + } + } + }); + } else { + CTMap map = new CTMap(1,header.length); + map.setColumnIdentifiers(header); + map.setEditable(true); + mainTable.setModel(map); + mainTable.getColumnModel().getColumn(2) + .setPreferredWidth(300); + map.setValueAt(leftTable.getValueAt(leftTable.getSelectedRow(), 0), 0, + mainTable.getColumnCount() - 1); + map.addTableModelListener(new TableModelListener() { + + @Override + public void tableChanged(TableModelEvent tablemodelevent) { + // TODO Auto-generated method stub + if(tablemodelevent.getType() == TableModelEvent.UPDATE){ + isMeopSave = true; + } + } + }); + } + mainTable.HiddenCell(0); + mainTable.HiddenCell(header.length - 1); +// mainTable.HiddenCell(header.length - 2); + mainTable.invalidate(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + System.out.println("-------刷新完数据关闭连接----------"); + SqlUtilT.freeAll(); + } + } + + + + /** + * 更新左侧数据 + */ + private void refreshLeftTable() { + // TODO Auto-generated method stub + //刷新右侧数据 + ResultSet rs = null; + InputStream input = null; + try { + + SqlUtilT.getTCConnection(); + + String sql = "select * from ZF6_CONTROLPLANLIBRARYTREE order by ID"; + rs = SqlUtilT.read(sql); + List bneanList = new ArrayList(); + while (rs.next()) { + TreeBean bean = new TreeBean(); + bean.setPlmeid(rs.getString("PLMEID")); + bean.setId(rs.getString("ID")); + bean.setName(rs.getString("NAME")); + bneanList.add(bean); + } + Collections.sort(bneanList, new NaturalOrderComparator<>(true)); + bneanList.forEach(item -> System.out.println(item)); + if (bneanList.size() > 0) { + CTMap map = new CTMap(bneanList.size(),header2.length); + map.setColumnIdentifiers(header2); + //map.setEditable(true); + leftTable.setModel(map); + leftTable.setRowHeight(30); + leftTable.getColumnModel().getColumn(2) + .setPreferredWidth(200); + for (int i = 0; i < bneanList.size(); i++) { + this.leftTable.setValueAt(bneanList.get(i).getPlmeid(), i, 0); + this.leftTable.setValueAt(bneanList.get(i).getId(), i, 1); + this.leftTable.setValueAt(bneanList.get(i).getName(), i, 2); + } + } + leftTable.HiddenCell(0); + leftTable.invalidate(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + + class NaturalOrderComparator implements Comparator { + + private final boolean caseInsensitive; + + public NaturalOrderComparator(boolean caseInsensitive) { + this.caseInsensitive = caseInsensitive; + } + + private int compareRight(String a, String b) { + int bias = 0; + int ia = 0; + int ib = 0; + for (; ; ia++, ib++) { + char ca = charAt(a, ia); + char cb = charAt(b, ib); + + if (!Character.isDigit(ca) && !Character.isDigit(cb)) { + return bias; + } else if (!Character.isDigit(ca)) { + return -1; + } else if (!Character.isDigit(cb)) { + return +1; + } else if (ca < cb) { + if (bias == 0) { + bias = -1; + } + } else if (ca > cb) { + if (bias == 0) { + bias = +1; + } + } else if (ca == 0 && cb == 0) { + return bias; + } + } + } + + @Override + public int compare(T o1, T o2) { + + TreeBean bean1 = (TreeBean)o1; + TreeBean bean2 = (TreeBean)o2; + + String a = bean1.getId(); + String b = bean2.getId(); + int ia = 0, ib = 0; + int nza = 0, nzb = 0; + char ca, cb; + int result; + while (true) { + nza = nzb = 0; + ca = charAt(a, ia); + cb = charAt(b, ib); + + while (ca == '0') { + nza++; + if (!Character.isDigit(charAt(a, ia + 1))) { + break; + } + ca = charAt(a, ++ia); + } + while (cb == '0') { + nzb++; + if (!Character.isDigit(charAt(b, ib + 1))) { + break; + } + cb = charAt(b, ++ib); + } + + if (Character.isDigit(ca) && Character.isDigit(cb)) { + if ((result = compareRight(a.substring(ia), b.substring(ib))) != 0) { + return result; + } + } + if (ca == 0 && cb == 0) { + return nza - nzb; + } + if (ca < cb) { + return -1; + } else if (ca > cb) { + return +1; + } + ++ia; + ++ib; + } + } + + private char charAt(String s, int i) { + if (i >= s.length()) { + return 0; + } else { + return caseInsensitive ? Character.toUpperCase(s.charAt(i)) : s.charAt(i); + } + } + } + // 添加监听 + public void createActionEvent() { + this.addItem.addActionListener(this); + this.addItems.addActionListener(this); + this.addNodeItem.addActionListener(this); + this.updateNodItem.addActionListener(this); + this.shrinkColumnItem.addActionListener(this); + this.celShrinkColumnItem.addActionListener(this); + this.remItem.addActionListener(this); + this.remNodeItem.addActionListener(this); + this.saveButton.addActionListener(this); + //this.addSpecialButton.addActionListener(this); + } + + // Jtable通用方法 + public CTable getNewjTable(CTable partsTable, DefaultTableModel dtm, + Object[] titleNames, int rows) { + int simpleLen = 100; + int totleLen = 100; + if (partsTable == null) { + CTMap map; + if(rows==0) { + map = new CTMap(rows+1, titleNames.length); + }else { + map = new CTMap(rows, titleNames.length); + } + + //CTMap map = new CTMap(rows, titleNames.length); + map.setColumnIdentifiers(titleNames); + map.setEditable(false); + partsTable = new CTable(map,session,true); + partsTable.setRowHeight(50); + //partsTable.HiddenCell(0); + // 隐藏列 + //partsTable.HiddenCell(titleNames.length - 1); + // partsTable.HiddenCell(titleNames.length-2); + // partsTable.setRowHeight(1, 50); + TableCellTextAreaRenderer2 renderer = new TableCellTextAreaRenderer2(); + partsTable.setDefaultRenderer(Object.class, renderer); + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i) + .setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + + @Override + public void actionPerformed(ActionEvent arg0) { + Object source = arg0.getSource(); + if (source.equals(this.addItem)) { +// Component component = tabbedPane.getSelectedComponent(); +// if (component instanceof JScrollPane) { +// JScrollPane scrollPane = (JScrollPane) component; +// Component tableComponent = scrollPane.getViewport().getView(); +// if (tableComponent instanceof CTable) { + CTable table = this.mainTable; + if (table.getSelectedRow() > -1) { + ((CTMap) table.getModel()).insertRow(table + .getSelectedRow() + 1); + + table.setValueAt( + table.getValueAt(table.getSelectedRow(), + table.getColumnCount() - 1), + table.getSelectedRow() + 1, + table.getColumnCount() - 1); + + table.revalidate(); + table.repaint(); + //this.tabbedPane.updateUI(); + } +// } +// } + } else if (source.equals(this.addItems)) { + CTable table = this.mainTable; + AddRowsDialog addRowsDialog = new AddRowsDialog(table); + } + else if (source.equals(this.addNodeItem)) { + + + final JFrame frame = new JFrame(); + frame.setLocationRelativeTo(this); + frame.setSize(new Dimension(400, 200)); + JLabel label = new JLabel("节点名称"); + final JTextField field = new JTextField(20); + JLabel idlabel = new JLabel("节点ID"); + final JTextField idfield = new JTextField(20); + JButton okButton = new JButton("确定"); + okButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + nodeName = field.getText(); + nodeID = idfield.getText(); + // node.add(new DefaultMutableTreeNode("烧结")); + String selectSql = ""; + String insterSql = "insert into ZF6_CONTROLPLANLIBRARYTREE values(?,?,?)"; + + try { +// SqlUtilT.getTCConnection(); +// rs = SqlUtilT.read(selectSql); +// while (rs.next()) { +// id = rs.getString("id"); +// } + UUID uid = UUID.randomUUID(); + TreeBean bean = new TreeBean(); + bean.setPlmeid(uid.toString().replace("-", "")); + bean.setId(nodeID); + bean.setName(nodeName); + // tabbedPane.add(nodeName, new JScrollPane(table)); + // 获取数据库连接 + SqlUtilT.getTCConnection(); + SqlUtilT.write( + new String[] { uid.toString().replace("-", ""), + nodeID, nodeName}, + insterSql); + refreshLeftTable(); + + frame.dispose(); + //tabbedPane.updateUI(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + SqlUtilT.freeAll(); + } + } + }); + JButton celButton = new JButton("取消"); + celButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent arg0) { + frame.dispose(); + } + }); + JPanel jPanel = new JPanel(new PropertyLayout()); + jPanel.add("1.1.left.top", idlabel); + jPanel.add("1.2.left.top", idfield); + jPanel.add("2.1.left.top", label); + jPanel.add("2.2.left.top", field); + JPanel rootJPanel = new JPanel(new FlowLayout()); + rootJPanel.add(okButton); + rootJPanel.add(celButton); + JPanel panel = new JPanel(new BorderLayout()); + panel.add(new JScrollPane(jPanel), BorderLayout.CENTER); + panel.add(rootJPanel, BorderLayout.SOUTH); + frame.add(panel); + frame.show(); + }else if (source.equals(this.updateNodItem)) { + CTable table = this.leftTable; + final JFrame frame = new JFrame(); + frame.setLocationRelativeTo(this); + frame.setSize(new Dimension(400, 200)); + JLabel label = new JLabel("节点名称"); + final JTextField field = new JTextField(20); + field.setText(table.getValueAt(table.getSelectedRow(), 2) == null ? "": table.getValueAt(table.getSelectedRow(), 2).toString()); + JLabel idlabel = new JLabel("节点ID"); + final JTextField idfield = new JTextField(20); + idfield.setText(table.getValueAt(table.getSelectedRow(),1 ) == null ? "" : table.getValueAt(table.getSelectedRow(),1 ).toString()); + JButton okButton = new JButton("确定"); + okButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + nodeName = field.getText() == null ? "" : field.getText(); + nodeID = idfield.getText() == null ? "" : idfield.getText(); + String updateSql = ""; + updateSql = String + .format("update ZF6_CONTROLPLANLIBRARYTREE set ID=?,NAME = ? where PLMEID = \'%s\'", + leftTable.getValueAt(leftTable.getSelectedRow(), 0).toString()); + + try { + SqlUtilT.getTCConnection(); + SqlUtilT.write( + new String[] { nodeID, nodeName }, + updateSql); + refreshLeftTable(); + + frame.dispose(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + SqlUtilT.freeAll(); + } + } + }); + + + JButton celButton = new JButton("取消"); + celButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent arg0) { + frame.dispose(); + } + }); + JPanel jPanel = new JPanel(new PropertyLayout()); + jPanel.add("1.1.left.top", idlabel); + jPanel.add("1.2.left.top", idfield); + jPanel.add("2.1.left.top", label); + jPanel.add("2.2.left.top", field); + JPanel rootJPanel = new JPanel(new FlowLayout()); + rootJPanel.add(okButton); + rootJPanel.add(celButton); + JPanel panel = new JPanel(new BorderLayout()); + panel.add(new JScrollPane(jPanel), BorderLayout.CENTER); + panel.add(rootJPanel, BorderLayout.SOUTH); + frame.add(panel); + frame.show(); + } else if (source.equals(this.remItem)) { +// Component component = tabbedPane.getSelectedComponent(); +// if (component instanceof JScrollPane) { +// JScrollPane scrollPane = (JScrollPane) component; +// Component tableComponent = scrollPane.getViewport().getView(); +// if (tableComponent instanceof CTable) { + int i=JOptionPane.showConfirmDialog(null, "是否删除选中行?", "删除", JOptionPane.YES_NO_OPTION); + if(i!=JOptionPane.YES_OPTION){ + return; + } + CTable table = this.mainTable; + if (table.getSelectedRow() >= 0 + && table.getSelectedColumn() > 0) { + (table.getCellEditor(table.getSelectedRow(), + table.getSelectedColumn())).stopCellEditing(); + if (((CTMap) table.getModel()).getValueAt( + table.getSelectedRow(), 0) != null) { + deleteRows.add(((CTMap) table.getModel()) + .getValueAt(table.getSelectedRow(), 0) + .toString()); + } + ((CTMap) table.getModel()).removeRow(table + .getSelectedRow()); + table.revalidate(); + table.repaint(); + //this.tabbedPane.updateUI(); + } +// } +// } + } else if (source.equals(this.remNodeItem)) { +// Component component = tabbedPane.getSelectedComponent(); +// if (component instanceof JScrollPane) { +// JScrollPane scrollPane = (JScrollPane) component; +// Component tableComponent = scrollPane.getViewport().getView(); +// if (tableComponent instanceof CTable) { + CTable table = this.mainTable; +// String deleteNodeSql = ""; + String deleteTreeSql = ""; + deleteTreeSql = String + .format("delete from ZF6_CONTROLPLANLIBRARYTREE where PLMEID = \'%s\'", + leftTable.getValueAt(leftTable.getSelectedRow(), 0).toString()); +// deleteNodeSql = String +// .format("delete from RB3_CONTROLPLAN_NODE where PARENT_ID = \'%s\'", +// leftTable.getValueAt(leftTable.getSelectedRow(), 1).toString()); + + SqlUtilT.getTCConnection(); + SqlUtilT.delete(deleteTreeSql); + SqlUtilT.freeAll(); +// SqlUtilT.getTCConnection(); +// SqlUtilT.delete(deleteNodeSql); +// SqlUtilT.freeAll(); + refreshLeftTable(); + + } else if (source.equals(this.saveButton)) { + okEvent(true); + + //this.disposeDialog(); + //this.dispose(); + } + else if (source.equals(shrinkColumnItem)) { + for (int i = 0; i < mainTable.getSelectedColumns().length; i++) { + mainTable.getColumnModel().getColumn(mainTable.getSelectedColumns()[i]).setPreferredWidth(5); + } + mainTable.revalidate(); + mainTable.repaint(); + } + else if (source.equals(celShrinkColumnItem)) { + for (int i = 0; i < mainTable.getSelectedColumns().length; i++) { + mainTable.getColumnModel().getColumn(mainTable.getSelectedColumns()[i]).setPreferredWidth(100); + } + mainTable.revalidate(); + mainTable.repaint(); + } + else { + //this.disposeDialog(); + this.dispose(); + // this.setVisible(false); + } + } + + private void okEvent(boolean isSave) { + isMeopSave = false; + if (mainTable.getSelectedRow() >= 0 + && mainTable.getSelectedColumn() >= 0) { + (mainTable.getCellEditor(mainTable.getSelectedRow(), + mainTable.getSelectedColumn())).stopCellEditing(); + } + // TODO Auto-generated method stub + // 将数据保存到表单中 + try { +// // 移除焦点 +// Component component = tabbedPane.getSelectedComponent(); +// if (component instanceof JScrollPane) { +// JScrollPane scrollPane = (JScrollPane) component; +// Component tableComponent = scrollPane.getViewport().getView(); +// if (tableComponent instanceof CTable) { +// CTable table = ((CTable) tableComponent); +// +// } +// } + // 获取JTable中的数据 + List> dataValeList = getTableValue(); + ResultSet rs = null; + InputStream input = null; + try { + SqlUtilT.getTCConnection(); + System.out.println("调用opration保存----------"); +// // 获取SQL语句 +// input = new BufferedInputStream(getClass().getResourceAsStream( +// "/sql.properties")); +// Properties pro = new Properties(); +// pro.load(input); + // 删除行 + for (int i = 0; i < deleteRows.size(); i++) { + // 获取数据库连接 + SqlUtilT.getTCConnection(); + String deleteSQL = String.format("delete from ZF6_CONTROLPLANLIBRARY where PLMEID = \'%s\'", + deleteRows.get(i)); + SqlUtilT.delete(deleteSQL); + //SqlUtilT.freeAll(); + } + // 查询工序编号和ID + // 往数据库中写入数据 + + System.out.println("控制计划库保存数据dataValueList====>"+dataValeList); + for (int i = 0; i < dataValeList.size(); i++) { + //SqlUtilT.getTCConnection(); + List rowList = dataValeList.get(i); + if (rowList.get(0) != null && !rowList.get(0).equals("")) { + // 获取数据库连接 + String updateSQL = String.format( + "update ZF6_CONTROLPLANLIBRARY set ID = ?,JQZHJJGZ = ?,BH = ?,CP = ?,GC = ?,TSTXFL = ?,CPGC = ?,JSCLJS = ?,XM = ?,RL = ?," + + "PL = ?,ZRR = ?,KZFF = ?,FYJH = ? where PLMEID = \'%s\'", + rowList.get(0)); + //SqlUtilT.getTCConnection(); + SqlUtilT.update( + new String[] { rowList.get(1), rowList.get(2), + rowList.get(3), rowList.get(4), + rowList.get(5), rowList.get(6), + rowList.get(7), rowList.get(8), + rowList.get(9), rowList.get(10), + rowList.get(11),rowList.get(12), + rowList.get(13), rowList.get(14)}, updateSQL); + } else { + String insertSQL = "insert into ZF6_CONTROLPLANLIBRARY values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + //SqlUtilT.getTCConnection(); + SqlUtilT.write( + new String[] { + UUID.randomUUID().toString() + .replace("-", ""), rowList.get(1), rowList.get(2), + rowList.get(3),rowList.get(4),rowList.get(5), + rowList.get(6),rowList.get(7),rowList.get(8), + rowList.get(9),rowList.get(10),rowList.get(11), + rowList.get(12),rowList.get(13),rowList.get(14), + rowList.get(15)}, + insertSQL); + } + + } + + //SqlUtilT.freeAll(); + } catch (Exception e) { + MessageBox.post(e.toString(), "错误", MessageBox.ERROR); + e.printStackTrace(); + throw e; + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.connection.commit(); + System.out.println("opration保存完----------"); + SqlUtilT.freeAll(); + } +// TMom012ControlPlanLibraryOperation operation = new TMom012ControlPlanLibraryOperation( +// this.session, dataValeList, deleteRows); +// session.queueOperation(operation); + this.rootPanel.setBackground(Color.GREEN); + new Thread() { + @Override + public void run() { + try { + this.sleep(1000); + rootPanel.setBackground(Color.WHITE); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + }.start(); + } catch (Exception e) { + // TODO Auto-generated catch block + this.rootPanel.setBackground(Color.RED); + MessageBox.post(e.toString(), "错误", MessageBox.ERROR); + e.printStackTrace(); + } + } + + private List> getTableValue() { + // TODO Auto-generated method stub + List> dataList = new ArrayList>(); +// Component[] components = tabbedPane.getComponents(); +// for (int i = 0; i < components.length; i++) { +// if (components[i] instanceof JScrollPane) { +// JScrollPane scrollPane = (JScrollPane) components[i]; +// Component tableComponent = scrollPane.getViewport().getView(); +// if (tableComponent instanceof CTable) { + CTable table = this.mainTable; + //移除焦点 + if (table.getSelectedRow() >= 0 && table.getSelectedColumn() >= 0) { + (table.getCellEditor(table.getSelectedRow(), + table.getSelectedColumn())).stopCellEditing(); + } + for (int j = 0; j < table.getRowCount(); j++) { + List rowValue = new ArrayList(); + for (int j2 = 0; j2 < table.getColumnCount(); j2++) { + rowValue.add(table.getValueAt(j, j2) == null ? "" + : table.getValueAt(j, j2).toString()); + + } + dataList.add(rowValue); + } + System.out.println("收集到的数据====>"+dataList); + return dataList; + } + + private int[] Union(int[] a1, int[] a2) { + List list1 = new ArrayList(); + List list2 = new ArrayList(); + for (int i : a1) { + list1.add(i); + } + for (int i : a2) { + list2.add(i); + } + list1.removeAll(list2); + list2.addAll(list1); + int[] result = new int[list2.size()]; + for (int i = 0; i < list2.size(); i++) { + result[i] = list2.get(i); + } + return result; + } + + private class AddRowsDialog extends AbstractAIFDialog implements ActionListener { + + private JPanel panel; + private JLabel label; + private JTextField textField; + private JButton button; + + private CTable table; + + public AddRowsDialog(CTable table) { + super(); + this.table = table; + init(); + } + + private void init() { + this.panel = new JPanel(new PropertyLayout()); + this.label = new JLabel("插入行数"); + this.textField = new JTextField(20); + this.textField.addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(KeyEvent arg0) { + if (arg0.getKeyCode() == KeyEvent.VK_ENTER) { + okEvent(); + } else { + super.keyPressed(arg0); + } + } + }); + this.button = new JButton("确定"); + this.button.addActionListener(this); + this.panel.add("1.1.left.top", label); + this.panel.add("1.2.left.top", textField); + this.panel.add("1.3.left.top", button); + + this.add(this.panel, BorderLayout.CENTER); + this.pack(); + this.showDialog(); + } + + @Override + public void actionPerformed(ActionEvent actionevent) { + // TODO Auto-generated method stub + Object source = actionevent.getSource(); + if (source.equals(this.button)) { + okEvent(); + } + } + + private void okEvent() { + // TODO Auto-generated method stub + if (!isStr2Num(textField.getText())) { + MessageBox.post("请输入正确的数字!", "错误!", MessageBox.ERROR); + return; + } + for (int i1 = Integer.parseInt(textField.getText()); i1 > 0; i1--) { + if (table.getSelectedRow() > -1) { + ((CTMap) table.getModel()).insertRow(table + .getSelectedRow() + 1); + + table.setValueAt( + table.getValueAt(table.getSelectedRow(), + table.getColumnCount() - 1), + table.getSelectedRow() + 1, + table.getColumnCount() - 1); + + table.revalidate(); + table.repaint(); + //this.tabbedPane.updateUI(); + } + } + this.disposeDialog(); + this.dispose(); + + } + + } + + + + + + /** + * 查看一个字符串是否可以转换为数字 + * @param str 字符串 + * @return true 可以; false 不可以 + */ + public boolean isStr2Num(String str) { + try { + Integer.parseInt(str); + return true; + } catch (NumberFormatException e) { + return false; + } + } + + private class SpecialDialog extends AbstractAIFDialog implements + ActionListener { + private JPanel tablePanel;// 表格控件 + private JTable table; + + private JPanel rootPanel;// 按钮 + private JButton okButton;// 确定 + private JButton celButton;// 取消 + + public SpecialDialog() { + // TODO Auto-generated constructor stub + super(); + init(); + } + + private void init() { + //获取国际化语言 + Locale defaultLocale=Locale.getDefault(); + ResourceBundle rb=ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message",defaultLocale); + // TODO Auto-generated method stub + this.setTitle(rb.getString("xztsfh12_display.TITLE")); + this.table = getjTable(this.table, null, new Object[] { 1, 2, 3, 4, + 5, 6, 7, 8 }, new Object[][] { { 1, 2, 3, 4, 5, 6, 7, 8 }, + { 9, 0, "q", "w", "e", "r", "t", "y" } }); + this.setLocationRelativeTo(this); + this.table.setRowHeight(30); + this.table.getTableHeader().setVisible(false); + this.table.setFont(new Font("Y14.5M", 0, 15)); + this.tablePanel = new JPanel(new BorderLayout()); + this.tablePanel.add(this.table); + + this.okButton = new JButton(rb.getString("qd_display.TITLE")); + this.okButton.addActionListener(this); + this.celButton = new JButton(rb.getString("qx_display.TITLE")); + this.celButton.addActionListener(this); + this.rootPanel = new JPanel(new FlowLayout()); + this.rootPanel.add(this.okButton); + this.rootPanel.add(this.celButton); + + this.add(this.tablePanel, BorderLayout.CENTER); + this.add(this.rootPanel, BorderLayout.SOUTH); + this.pack(); + this.show(); + } + + // Jtable通用方法 + public JTable getjTable(JTable partsTable, DefaultTableModel dtm, + Object[] titleNames, Object[][] values) { + int simpleLen = 100; + int totleLen = 1000; + if (partsTable == null) { + partsTable = new JTable(this.getTableModel(dtm, titleNames, + values)); + partsTable.setCellSelectionEnabled(true); + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i) + .setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + + public DefaultTableModel getTableModel(DefaultTableModel dtm, + Object[] titleNames, Object[][] values) { + MyTableModel tableModel = null; + if (dtm == null) { + tableModel = new MyTableModel(values, titleNames); + } + return tableModel; + } + + @Override + public void actionPerformed(ActionEvent actionevent) { + // TODO Auto-generated method stub + Object source = actionevent.getSource(); + if (source.equals(this.okButton)) { + // DefaultMutableTreeNode node = (DefaultMutableTreeNode) + // TMom012ControlPlanLibraryDialog.tree.getSelectionPath().getLastPathComponent(); + // node.add(new DefaultMutableTreeNode("烧结")); +// Component component = tabbedPane.getSelectedComponent(); +// if (component instanceof JScrollPane) { +// JScrollPane scrollPane = (JScrollPane) component; +// Component tableComponent = scrollPane.getViewport() +// .getView(); +// if (tableComponent instanceof CTable) { + CTable table = mainTable; + int row = table.getSelectedRow(); + int column = table.getSelectedColumn(); + // 保存特殊符号位置 + String columnName = table.getColumnName(table + .getSelectedColumn()); + + int cursorIndex = ((TextAreaCellEditor) (table + .getCellEditor(row, column))).getIndex(); + System.out.println("index+" + cursorIndex); + (table.getCellEditor(row, column)).stopCellEditing(); + // TMom010SetPFMEADialog.table.getDefaultEditor(Object.class).stopCellEditing(); + StringBuilder sb = new StringBuilder(table.getValueAt( + row, column).toString()); + + // 定义循环,如果index的位置不是-1,就一直查找 + Integer index = 0; + while ((index = sb.toString().indexOf("\n", index)) != -1) { + + // 每循环一次就要明确下一次查找的位置 + index = index + "\n".length(); + // 每查找一次计数器自增 + cursorIndex++; + } + // 特殊符号 + Object special = table.getValueAt(row, + table.getColumnCount() - 1); + if (special == null || special.toString() == "") { + table.setValueAt(columnName + "-" + cursorIndex, + row, table.getColumnCount() - 1); + } else { + table.setValueAt(special + "|" + columnName + "-" + + cursorIndex, row, + table.getColumnCount() - 1); + } + System.out.println(sb.length()); + String s = sb.insert( + cursorIndex, + this.table.getValueAt( + this.table.getSelectedRow(), + this.table.getSelectedColumn()) + .toString()).toString(); + table.setValueAt(s, table.getSelectedRow(), + table.getSelectedColumn()); + System.out.println(table.getValueAt(row, column) + .toString()); +// } +// } + } else { + this.dispose(); + } + } + } +} diff --git a/src/com/connor/zf/controlplanlibrary/TMom012ControlPlanLibraryHandler.java b/src/com/connor/zf/controlplanlibrary/TMom012ControlPlanLibraryHandler.java new file mode 100644 index 0000000..f5ca78e --- /dev/null +++ b/src/com/connor/zf/controlplanlibrary/TMom012ControlPlanLibraryHandler.java @@ -0,0 +1,43 @@ +package com.connor.zf.controlplanlibrary; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom012ControlPlanLibraryHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + String commandId = arg0.getCommand().getId(); + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + TMom012ControlPlanLibraryCommand command = new TMom012ControlPlanLibraryCommand( + app, session, commandId); + try { + TCPreferenceService service = session.getPreferenceService(); + String[] options = service.getStringArray(TCPreferenceService.TC_preference_site, "Cust_ControlPlanLibrary_Privilege"); + boolean hasPrivilege = false; + for(String option : options){ + if(option.equals(session.getUserName())){ + command.executeModal(); + hasPrivilege = true; + } + } + if(!hasPrivilege){ + MessageBox.post("无管理权限!请联系系统管理员。", "错误", MessageBox.ERROR); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("填写控制计划库失败!", "错误", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/zf/controlplanlibrary/TMom012ControlPlanLibraryOperation.java b/src/com/connor/zf/controlplanlibrary/TMom012ControlPlanLibraryOperation.java new file mode 100644 index 0000000..7a050bb --- /dev/null +++ b/src/com/connor/zf/controlplanlibrary/TMom012ControlPlanLibraryOperation.java @@ -0,0 +1,116 @@ +package com.connor.zf.controlplanlibrary; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.UUID; +import com.connor.zf.controlplan.SqlUtilT; +import com.connor.zf.controlplan.TreeBean; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom012ControlPlanLibraryOperation extends AbstractAIFOperation { + + private List> dataValueList; + private TCSession session; + private List deleteRows; + + public TMom012ControlPlanLibraryOperation(TCSession session, + List> dataValueList, List deleteRows) { + this.session = session; + this.dataValueList = dataValueList; + this.deleteRows = deleteRows; + + } + + @Override + public void executeOperation() throws Exception { + ResultSet rs = null; + InputStream input = null; + try { + SqlUtilT.getTCConnection(); + System.out.println("调用opration保存----------"); +// // 获取SQL语句 +// input = new BufferedInputStream(getClass().getResourceAsStream( +// "/sql.properties")); +// Properties pro = new Properties(); +// pro.load(input); + // 删除行 + for (int i = 0; i < deleteRows.size(); i++) { + // 获取数据库连接 + SqlUtilT.getTCConnection(); + String deleteSQL = String.format("delete from ZF6_CONTROLPLANLIBRARY where PLMEID = \'%s\'", + deleteRows.get(i)); + SqlUtilT.delete(deleteSQL); + //SqlUtilT.freeAll(); + } + // 查询工序编号和ID + // 往数据库中写入数据 + + System.out.println("控制计划库保存数据dataValueList====>"+dataValueList); + for (int i = 0; i < dataValueList.size(); i++) { + //SqlUtilT.getTCConnection(); + List rowList = dataValueList.get(i); + if (rowList.get(0) != null && !rowList.get(0).equals("")) { + // 获取数据库连接 + String updateSQL = String.format( + "update ZF6_CONTROLPLANLIBRARY set ID = ?,JQZHJJGZ = ?,BH = ?,CP = ?,GC = ?,TSTXFL = ?,CPGC = ?,JSCLJS = ?,XM = ?,RL = ?," + + "PL = ?,ZRR = ?,KZFF = ?,FYJH = ? where PLMEID = \'%s\'", + rowList.get(0)); + //SqlUtilT.getTCConnection(); + SqlUtilT.update( + new String[] { rowList.get(1), rowList.get(2), + rowList.get(3), rowList.get(4), + rowList.get(5), rowList.get(6), + rowList.get(7), rowList.get(8), + rowList.get(9), rowList.get(10), + rowList.get(11),rowList.get(12), + rowList.get(13), rowList.get(14)}, updateSQL); + } else { + String insertSQL = "insert into ZF6_CONTROLPLANLIBRARY values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + //SqlUtilT.getTCConnection(); + SqlUtilT.write( + new String[] { + UUID.randomUUID().toString() + .replace("-", ""), rowList.get(1), rowList.get(2), + rowList.get(3),rowList.get(4),rowList.get(5), + rowList.get(6),rowList.get(7),rowList.get(8), + rowList.get(9),rowList.get(10),rowList.get(11), + rowList.get(12),rowList.get(13),rowList.get(14), + rowList.get(15)}, + insertSQL); + } + + } + + //SqlUtilT.freeAll(); + } catch (Exception e) { + MessageBox.post(e.toString(), "错误", MessageBox.ERROR); + e.printStackTrace(); + throw e; + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.connection.commit(); + System.out.println("opration保存完----------"); + SqlUtilT.freeAll(); + } + } +} diff --git a/src/com/connor/zf/controlplanlibrary/TableCellTextAreaRenderer.java b/src/com/connor/zf/controlplanlibrary/TableCellTextAreaRenderer.java new file mode 100644 index 0000000..07b1cf2 --- /dev/null +++ b/src/com/connor/zf/controlplanlibrary/TableCellTextAreaRenderer.java @@ -0,0 +1,292 @@ +package com.connor.zf.controlplanlibrary; + +import java.awt.Color; +import java.awt.Component; +import java.util.List; + +import javax.swing.JTable; +import javax.swing.JTextPane; +import javax.swing.table.TableCellRenderer; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.StyleConstants; +import javax.swing.text.StyledDocument; + +public class TableCellTextAreaRenderer extends JTextPane implements + TableCellRenderer { + private List processRows; + + public List getProcessRows() { + return processRows; + } + + public void setProcessRows(List processRows) { + this.processRows = processRows; + } + + public TableCellTextAreaRenderer() { + // setLineWrap(true);//自动换行 + // setWrapStyleWord(true); + + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + // TODO Auto-generated method stub + int maxPreferredHeight = 0; + if (table.getColumnName(column).equals("RPN")) { + // 5,9,11 + String yzd = table.getValueAt(row, 6) == null ? "0" : table + .getValueAt(row, 6).toString(); + String pds = table.getValueAt(row, 10) == null ? "0" : table + .getValueAt(row, 10).toString(); + String tcd = table.getValueAt(row, 12) == null ? "0" : table + .getValueAt(row, 12).toString(); + + if(isStr2Num(yzd) && isStr2Num(pds) && isStr2Num(tcd)) + { + int rpn = Integer.parseInt(yzd) * Integer.parseInt(pds) + * Integer.parseInt(tcd); + if (rpn == 0) { + table.setValueAt("", row, column); + setText(""); + } else { + table.setValueAt(String.valueOf(rpn), row, column); + setText(String.valueOf(rpn)); + } + } + else + { + setText(""); + } +// int rpn = Integer.parseInt(yzd) * Integer.parseInt(pds) +// * Integer.parseInt(tcd); +// if (rpn == 0) { +// table.setValueAt("", row, column); +// setText(""); +// } else { +// table.setValueAt(String.valueOf(rpn), row, column); +// setText(String.valueOf(rpn)); +// } + } else if (table.getColumnName(column).equals("New_RPN")) { + // 17,18,19 + String yzd = table.getValueAt(row, 18) == null ? "0" : table + .getValueAt(row, 18).toString(); + String pds = table.getValueAt(row, 19) == null ? "0" : table + .getValueAt(row, 19).toString(); + String tcd = table.getValueAt(row, 20) == null ? "0" : table + .getValueAt(row, 20).toString(); + if(isStr2Num(yzd) && isStr2Num(pds) && isStr2Num(tcd)) + { + int rpn = Integer.parseInt(yzd) * Integer.parseInt(pds) + * Integer.parseInt(tcd); + if (rpn == 0) { + table.setValueAt("", row, column); + setText(""); + } else { + table.setValueAt(String.valueOf(rpn), row, column); + setText(String.valueOf(rpn)); + } + } + else + { + setText(""); + } +// if (rpn == 0) { +// table.setValueAt("", row, column); +// setText(""); +// } else { +// table.setValueAt(String.valueOf(rpn), row, column); +// setText(String.valueOf(rpn)); +// } + } else { + setText(value == null ? "" : value.toString()); + } + // 居中对齐 + // if(value != null) + // { + // SimpleAttributeSet set = new SimpleAttributeSet(); + // StyleConstants.setAlignment(set, StyleConstants.ALIGN_CENTER);//设置居中 + // StyledDocument doc = this.getStyledDocument(); + // try { + // //doc.remove(0, value.toString().length()); + // doc.setCharacterAttributes(0, doc.getLength(), set, false); + // } catch (Exception e) { + // e.printStackTrace(); + // } + // } + // 特殊符号 + // setText(value == null ? "" : value.toString()); + // if(table.getValueAt(row, table.getColumnCount()-1) == null) + // { + // return this; + // } + // String special = table.getValueAt(row, + // table.getColumnCount()-1).toString(); + // if(special.indexOf("|") >= 0) + // { + // String[] specials = special.split("\\|"); + // for (int i = 0; i < specials.length; i++) { + // if(specials[i].indexOf("-") >= 0) + // { + // String[] columnName = specials[i].split("-"); + // if(table.getColumnName(column).equals(columnName[0])) + // { + // setTextFont(value.toString(),Integer.parseInt(columnName[1]) + // ,"Y14.5M"); + // } + // } + // } + // } + // else if(special.indexOf("-") >= 0) + // { + // String[] columnName = special.split("-"); + // if(table.getColumnName(column).equals(columnName[0])) + // { + // setTextFont(value.toString(),Integer.parseInt(columnName[1]) + // ,"Y14.5M"); + // } + // } + // if(value!=null) + // { + // if(column == 1) + // { + // setTextFont(value.toString(),"Y14.5M"); + // } + // } + + for (int i = 0; i < table.getColumnCount(); i++) { + setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + maxPreferredHeight = Math.max(maxPreferredHeight, + getPreferredSize().height); + } + if (table.getColumnName(column).equals("RPN") && value != null + && !value.equals("") + && Integer.parseInt(value.toString()) >= 100) { + setBackground(Color.RED); + setForeground(Color.black); + } else if (table.getColumnName(column).equals("New_RPN") && value != null + && !value.equals("") + && Integer.parseInt(value.toString()) >= 100) { + setBackground(Color.RED); + setForeground(Color.black); + } + // else if(processRows == null || processRows.size() <= 0 || + // !processRows.contains(row)) + // { + // setBackground(Color.YELLOW); + // setForeground(Color.black); + // } +// else if (row == table.getSelectedRow()) { +// setBackground(Color.GRAY); +// setForeground(Color.black); +// } +// else if (column == table.getSelectedColumn()) { +// setBackground(Color.GRAY); +// setForeground(Color.black); +// } + else { + setBackground(Color.white); + setForeground(Color.black); + } + + if (isSelected) { + // setBackground(new Color(0, 120, 215)); + setBackground(new Color(184,184,184)); + setForeground(Color.black); + } + if (table.getRowHeight(row) != maxPreferredHeight)// 少了这行则处理器瞎忙 + { + table.setRowHeight(row, maxPreferredHeight); + } + return this; + } + + // 设置字体,如一个字符串中需要包含多个字体样式,可创建多个SimpleAttributeSet,并将字符串拆分开,按顺序使用Document的insertString方法插入 + private void setTextFont(String value, int index, String font) { + // TODO Auto-generated method stub + SimpleAttributeSet set = new SimpleAttributeSet(); + // StyleConstants.setForeground(set, Color.red);//设置文字颜色 + StyleConstants.setFontFamily(set, font);// 设置字体样式 + SimpleAttributeSet set2 = new SimpleAttributeSet(); + // StyleConstants.setForeground(set, Color.red);//设置文字颜色 + StyleConstants.setFontFamily(set2, "Courier New");// 设置字体样式 + // StyleConstants.setFontSize(set2, 10); + Document doc = this.getStyledDocument(); + try { + // 插入前需要先删除 + doc.remove(0, value.toString().length()); + value = value.replaceAll(" ", ""); + doc.insertString(doc.getLength(), + value.toString().substring(0, index), set2); + doc.insertString(doc.getLength(), + value.toString().substring(index, index + 1), set); + doc.insertString( + doc.getLength(), + value.toString().substring(index + 1, + value.toString().length()), set2); + if (value.toString() + .substring(index + 1, value.toString().length()) == null + || value.toString() + .substring(index + 1, value.toString().length()) + .equals("")) { + doc.insertString(doc.getLength(), " ", set2); + } + } catch (BadLocationException e) { + e.printStackTrace(); + } finally { + set = null; + doc = null; + System.gc(); + } + } + /** + * 查看一个字符串是否可以转换为数字 + * @param str 字符串 + * @return true 可以; false 不可以 + */ + public boolean isStr2Num(String str) { + try { + Integer.parseInt(str); + return true; + } catch (NumberFormatException e) { + return false; + } + } + // + // @Override + // public Component getTableCellRendererComponent(JTable table, Object + // value, boolean isSelected, boolean hasFocus, + // int row, int column) { + // // TODO Auto-generated method stub + // int maxPreferredHeight = 0; + // for (int i = 0; i < table.getColumnCount(); i++) { + // setText("" + table.getValueAt(row, i)); + // setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + // maxPreferredHeight = Math.max(maxPreferredHeight, + // getPreferredSize().height); + // } + // setBorder(BorderFactory.createLineBorder(Color.white)); + // setBackground(Color.white); + // setForeground(Color.black); + // if(isSelected){ + // setBackground(new Color(0, 120, 215)); + // setForeground(Color.white); + // } + // String val=(String) table.getValueAt(row, column); + // int w=0; + // if(val!=null){ + // w=val.length()*6/table.getColumn(table.getColumnName(column)).getWidth(); + // } + // if(w!=0){ + // //System.out.println("height:"+table.getRowHeight()*(w+1)); + // table.setRowHeight(row,table.getRowHeight()*(w+1)); + // } + // + // + // setText(value == null ? "" : value.toString()); + // return this; + // } +} \ No newline at end of file diff --git a/src/com/connor/zf/controlplanlibrary/TableCellTextAreaRenderer2.java b/src/com/connor/zf/controlplanlibrary/TableCellTextAreaRenderer2.java new file mode 100644 index 0000000..67fc565 --- /dev/null +++ b/src/com/connor/zf/controlplanlibrary/TableCellTextAreaRenderer2.java @@ -0,0 +1,208 @@ +package com.connor.zf.controlplanlibrary; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.util.List; + +import javax.swing.BorderFactory; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.JTextPane; +import javax.swing.table.TableCellRenderer; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.StyleConstants; + +public class TableCellTextAreaRenderer2 extends JTextPane implements + TableCellRenderer { + private List processRows; + + public List getProcessRows() { + return processRows; + } + + public void setProcessRows(List processRows) { + this.processRows = processRows; + } + + public TableCellTextAreaRenderer2() { + // setLineWrap(true);//自动换行 + // setWrapStyleWord(true); + + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + // TODO Auto-generated method stub + int maxPreferredHeight = 0; + if (table.getColumnName(column).equals("RPN")) { + // 5,9,11 + String yzd = table.getValueAt(row, 6) == null ? "0" : table + .getValueAt(row, 6).toString(); + String pds = table.getValueAt(row, 10) == null ? "0" : table + .getValueAt(row, 10).toString(); + String tcd = table.getValueAt(row, 12) == null ? "0" : table + .getValueAt(row, 12).toString(); + int rpn = Integer.parseInt(yzd) * Integer.parseInt(pds) + * Integer.parseInt(tcd); + if (rpn == 0) { + table.setValueAt("", row, column); + setText(""); + } else { + table.setValueAt(String.valueOf(rpn), row, column); + setText(String.valueOf(rpn)); + } + } else { + setText(value == null ? "" : value.toString()); + } + // 特殊符号 + // setText(value == null ? "" : value.toString()); + // if(table.getValueAt(row, table.getColumnCount()-1) == null) + // { + // return this; + // } + // String special = table.getValueAt(row, + // table.getColumnCount()-1).toString(); + // if(special.indexOf("|") >= 0) + // { + // String[] specials = special.split("\\|"); + // for (int i = 0; i < specials.length; i++) { + // if(specials[i].indexOf("-") >= 0) + // { + // String[] columnName = specials[i].split("-"); + // if(table.getColumnName(column).equals(columnName[0])) + // { + // setTextFont(value.toString(),Integer.parseInt(columnName[1]) + // ,"Y14.5M"); + // } + // } + // } + // } + // else if(special.indexOf("-") >= 0) + // { + // String[] columnName = special.split("-"); + // if(table.getColumnName(column).equals(columnName[0])) + // { + // setTextFont(value.toString(),Integer.parseInt(columnName[1]) + // ,"Y14.5M"); + // } + // } + // if(value!=null) + // { + // if(column == 1) + // { + // setTextFont(value.toString(),"Y14.5M"); + // } + // } + + for (int i = 0; i < table.getColumnCount(); i++) { + setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + maxPreferredHeight = Math.max(maxPreferredHeight, + getPreferredSize().height); + } + if (table.getColumnName(column).equals("RPN") && value != null + && !value.equals("") + && Integer.parseInt(value.toString()) >= 100) { + setBackground(Color.RED); + setForeground(Color.black); + } else if (processRows == null || processRows.size() <= 0 + || !processRows.contains(row)) { + setBackground(Color.YELLOW); + setForeground(Color.black); + } else { + setBackground(Color.white); + setForeground(Color.black); + } + System.out.println(row); + if (row == table.getSelectedRow()) { + setBackground(Color.YELLOW); + setForeground(Color.black); + } + if (isSelected) { + // setBackground(new Color(0, 120, 215)); + setBackground(Color.YELLOW); + setForeground(Color.black); + } + if (table.getRowHeight(row) != maxPreferredHeight)// 少了这行则处理器瞎忙 + { + table.setRowHeight(row, maxPreferredHeight); + } + return this; + } + + // 设置字体,如一个字符串中需要包含多个字体样式,可创建多个SimpleAttributeSet,并将字符串拆分开,按顺序使用Document的insertString方法插入 + private void setTextFont(String value, int index, String font) { + // TODO Auto-generated method stub + SimpleAttributeSet set = new SimpleAttributeSet(); + // StyleConstants.setForeground(set, Color.red);//设置文字颜色 + StyleConstants.setFontFamily(set, font);// 设置字体样式 + SimpleAttributeSet set2 = new SimpleAttributeSet(); + // StyleConstants.setForeground(set, Color.red);//设置文字颜色 + StyleConstants.setFontFamily(set2, "Courier New");// 设置字体样式 + // StyleConstants.setFontSize(set2, 10); + Document doc = this.getStyledDocument(); + try { + // 插入前需要先删除 + doc.remove(0, value.toString().length()); + value = value.replaceAll(" ", ""); + doc.insertString(doc.getLength(), + value.toString().substring(0, index), set2); + doc.insertString(doc.getLength(), + value.toString().substring(index, index + 1), set); + doc.insertString( + doc.getLength(), + value.toString().substring(index + 1, + value.toString().length()), set2); + if (value.toString() + .substring(index + 1, value.toString().length()) == null + || value.toString() + .substring(index + 1, value.toString().length()) + .equals("")) { + doc.insertString(doc.getLength(), " ", set2); + } + } catch (BadLocationException e) { + e.printStackTrace(); + } finally { + set = null; + doc = null; + System.gc(); + } + } + // + // @Override + // public Component getTableCellRendererComponent(JTable table, Object + // value, boolean isSelected, boolean hasFocus, + // int row, int column) { + // // TODO Auto-generated method stub + // int maxPreferredHeight = 0; + // for (int i = 0; i < table.getColumnCount(); i++) { + // setText("" + table.getValueAt(row, i)); + // setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + // maxPreferredHeight = Math.max(maxPreferredHeight, + // getPreferredSize().height); + // } + // setBorder(BorderFactory.createLineBorder(Color.white)); + // setBackground(Color.white); + // setForeground(Color.black); + // if(isSelected){ + // setBackground(new Color(0, 120, 215)); + // setForeground(Color.white); + // } + // String val=(String) table.getValueAt(row, column); + // int w=0; + // if(val!=null){ + // w=val.length()*6/table.getColumn(table.getColumnName(column)).getWidth(); + // } + // if(w!=0){ + // //System.out.println("height:"+table.getRowHeight()*(w+1)); + // table.setRowHeight(row,table.getRowHeight()*(w+1)); + // } + // + // + // setText(value == null ? "" : value.toString()); + // return this; + // } +} \ No newline at end of file diff --git a/src/com/connor/zf/controlplanlibrary/TextAreaCellEditor.java b/src/com/connor/zf/controlplanlibrary/TextAreaCellEditor.java new file mode 100644 index 0000000..0c03d40 --- /dev/null +++ b/src/com/connor/zf/controlplanlibrary/TextAreaCellEditor.java @@ -0,0 +1,204 @@ +package com.connor.zf.controlplanlibrary; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Event; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.io.UnsupportedEncodingException; +import java.util.EventObject; + +import javax.swing.DefaultCellEditor; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.JTextPane; +import javax.swing.event.CaretEvent; +import javax.swing.event.CaretListener; +import javax.swing.event.CellEditorListener; +import javax.swing.event.ChangeEvent; +import javax.swing.event.EventListenerList; +import javax.swing.table.TableCellEditor; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.StyleConstants; + +public class TextAreaCellEditor extends JTextPane implements TableCellEditor, + CaretListener { + private static final long serialVersionUID = 5860619160549087886L; + private EventListenerList listenerList = new EventListenerList(); + private ChangeEvent changeEvent = new ChangeEvent(this); + private int index;// 光标所在位置 + + public TextAreaCellEditor() { + // TODO Auto-generated constructor stub + super(); + this.addCaretListener(this); + // this.setLineWrap(true); //自动换行 + // this.setWrapStyleWord(true); + } + + public int getIndex() { + return index; + } + + @Override + public void addCellEditorListener(CellEditorListener listener) { + // TODO Auto-generated method stub + listenerList.add(CellEditorListener.class, listener); + } + + @Override + public void cancelCellEditing() { + // TODO Auto-generated method stub + System.out.println(2); + } + + @Override + public Object getCellEditorValue() { + // TODO Auto-generated method stub + // System.out.println(3); + return this.getText(); + } + + @Override + public boolean isCellEditable(EventObject arg0) { + // TODO Auto-generated method stub + return true; + } + + @Override + public void removeCellEditorListener(CellEditorListener listener) { + // TODO Auto-generated method stub + listenerList.remove(CellEditorListener.class, listener); + } + + private void fireEditingStopped() { + CellEditorListener listener; + Object[] listeners = listenerList.getListenerList(); + for (int i = 0; i < listeners.length; i++) { + if (listeners[i] == CellEditorListener.class) { + // 之所以是i+1,是因为一个为CellEditorListener.class(Class对象), + // 接着的是一个CellEditorListener的实例 + listener = (CellEditorListener) listeners[i + 1]; + // 让changeEvent去通知编辑器已经结束编辑 + // 在editingStopped方法中,JTable调用getCellEditorValue()取回单元格的值, + // 并且把这个值传递给TableValues(TableModel)的setValueAt() + try { + listener.editingStopped(changeEvent); + } catch (Exception e) { + // TODO: handle exception + System.out.println(e.toString()); + } + } + } + } + + @Override + public boolean shouldSelectCell(EventObject arg0) { + // TODO Auto-generated method stub + return true; + } + + @Override + public boolean stopCellEditing() { + // TODO Auto-generated method stub + // 可以注释掉下面的fireEditingStopped();,然后在GenderEditor的构造函数中把 + // addActionListener()的注释去掉(这时请求终止编辑操作从JComboBox获得), + // System.out.println("编辑其中一个单元格,再点击另一个单元格时,调用。"); + fireEditingStopped();// 请求终止编辑操作从JTable获得 + return true; + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, + boolean isSelect, int row, int column) { + // TODO Auto-generated method stub + setText(value == null ? "" : value.toString()); + // 特殊符号 + if (table.getValueAt(row, table.getColumnCount() - 1) == null) { + return new JScrollPane(this); + } + String special = table.getValueAt(row, table.getColumnCount() - 1) + .toString(); + if (special.indexOf("|") >= 0) { + String[] specials = special.split("\\|"); + for (int i = 0; i < specials.length; i++) { + if (specials[i].indexOf("-") >= 0) { + String[] columnName = specials[i].split("-"); + if (table.getColumnName(column).equals(columnName[0])) { + setTextFont(value.toString(), + Integer.parseInt(columnName[1]), "Y14.5M"); + } + } + } + } else if (special.indexOf("-") >= 0) { + String[] columnName = special.split("-"); + if (table.getColumnName(column).equals(columnName[0])) { + setTextFont(value.toString(), Integer.parseInt(columnName[1]), + "Y14.5M"); + } + } + // if(value!=null) + // { + // if(cloumn == 1) + // { + // setTextFont(value.toString(),"Y14.5M"); + // } + // } + // System.out.println(8) + return new JScrollPane(this); + } + + @Override + public void caretUpdate(CaretEvent caretevent) { + // TODO Auto-generated method stub + index = caretevent.getMark(); + // System.out.println(index); + } + + // 设置字体,如一个字符串中需要包含多个字体样式,可创建多个SimpleAttributeSet,并将字符串拆分开,按顺序使用Document的insertString方法插入 + private void setTextFont(String value, int index, String font) { + // TODO Auto-generated method stub + SimpleAttributeSet set = new SimpleAttributeSet(); + // StyleConstants.setForeground(set, Color.red);//设置文字颜色 + StyleConstants.setFontFamily(set, font);// 设置字体样式 + // StyleConstants.setFontSize(set, 14); + SimpleAttributeSet set2 = new SimpleAttributeSet(); + // StyleConstants.setForeground(set, Color.red);//设置文字颜色 + StyleConstants.setFontFamily(set2, "Courier New");// 设置字体样式 + // StyleConstants.setFontSize(set2, 10); + Document doc = this.getStyledDocument(); + try { + // 插入前需要先删除 + doc.remove(0, value.toString().length()); + value = value.replaceAll(" ", ""); + doc.insertString(doc.getLength(), + value.toString().substring(0, index), set2); + doc.insertString(doc.getLength(), + value.toString().substring(index, index + 1), set); + doc.insertString( + doc.getLength(), + value.toString().substring(index + 1, + value.toString().length()), set2); + if (value.toString() + .substring(index + 1, value.toString().length()) == null + || value.toString() + .substring(index + 1, value.toString().length()) + .equals("")) { + doc.insertString(doc.getLength(), " ", set2); + } + } catch (BadLocationException e) { + e.printStackTrace(); + } finally { + set = null; + doc = null; + System.gc(); + } + } +} diff --git a/src/com/connor/zf/editClassAttr/EditClassificationDialog.java b/src/com/connor/zf/editClassAttr/EditClassificationDialog.java new file mode 100644 index 0000000..5142d5b --- /dev/null +++ b/src/com/connor/zf/editClassAttr/EditClassificationDialog.java @@ -0,0 +1,419 @@ +//package com.connor.zf.editClassAttr; +// +//import java.awt.BorderLayout; +//import java.awt.Dimension; +//import java.awt.FlowLayout; +//import java.awt.event.ActionEvent; +//import java.awt.event.ActionListener; +//import java.util.ArrayList; +//import java.util.Arrays; +//import java.util.HashMap; +//import java.util.LinkedHashMap; +//import java.util.List; +//import java.util.Map; +//import java.util.Map.Entry; +// +//import javax.swing.JButton; +//import javax.swing.JComboBox; +//import javax.swing.JComponent; +//import javax.swing.JLabel; +//import javax.swing.JOptionPane; +//import javax.swing.JPanel; +//import javax.swing.JScrollPane; +//import javax.swing.JTextField; +// +//import org.apache.axiom.om.OMAbstractFactory; +//import org.apache.axiom.om.OMElement; +//import org.apache.axiom.om.OMFactory; +//import org.apache.axiom.om.OMNamespace; +//import org.apache.axis2.AxisFault; +//import org.apache.axis2.addressing.EndpointReference; +//import org.apache.axis2.client.Options; +//import org.apache.axis2.client.ServiceClient; +// +//import com.connor.zf.util.ClassPropBean; +//import com.connor.zf.util.ClassProperty; +//import com.connor.zf.util.JDMethodUtil; +//import com.connor.zf.util.SoaServerUtil; +//import com.connor.zf.util.StringCreateUtil; +//import com.teamcenter.rac.aif.AbstractAIFApplication; +//import com.teamcenter.rac.aif.AbstractAIFDialog; +//import com.teamcenter.rac.aifrcp.AIFUtility; +//import com.teamcenter.rac.kernel.TCClassService; +//import com.teamcenter.rac.kernel.TCClassificationService; +//import com.teamcenter.rac.kernel.TCComponent; +//import com.teamcenter.rac.kernel.TCComponentForm; +//import com.teamcenter.rac.kernel.TCComponentICO; +//import com.teamcenter.rac.kernel.TCComponentItemRevision; +//import com.teamcenter.rac.kernel.TCException; +//import com.teamcenter.rac.kernel.TCSession; +//import com.teamcenter.rac.kernel.ics.ICSAdminClass; +//import com.teamcenter.rac.kernel.ics.ICSKeyLov; +//import com.teamcenter.rac.kernel.ics.ICSProperty; +//import com.teamcenter.rac.kernel.ics.ICSPropertyDescription; +//import com.teamcenter.rac.kernel.ics.ICSKeyLov.KeyLov; +//import com.teamcenter.rac.util.MessageBox; +//import com.teamcenter.rac.util.PropertyLayout; +// +//import net.sf.json.JSONArray; +// +///** +// * 修改分类属性 +// */ +//public class EditClassificationDialog extends AbstractAIFDialog { +// +// private static final long serialVersionUID = 1L; +// private AbstractAIFApplication app; +// private TCSession session; +// private TCComponent target; +// private Map propMap; +// private TCClassificationService myService; +// final EditClassificationDialog DIALOG = this; +// private TCComponentItemRevision rev; +// private int[] ids; +// private String[] values; +// private String[] names; +// private boolean finished; +// private ICSPropertyDescription[] desc; +// private String url = ""; +// public EditClassificationDialog(AbstractAIFApplication app) throws TCException { +// this.app = app; +// this.session = (TCSession) app.getSession(); +// this.myService = session.getClassificationService(); +// this.target = (TCComponent) AIFUtility.getCurrentApplication().getTargetComponent(); +// this.url = JDMethodUtil.getPrefStr("Autocode_SendClassServer_URL", session); +// System.out.println(target.getType()); +// System.out.println(target instanceof TCComponentItemRevision ? "是" : "否"); +// +// if (target instanceof TCComponentItemRevision) { +// try { +// rev = (TCComponentItemRevision) target; +// boolean isAccess = session.getTCAccessControlService().checkPrivilege(rev, "WRITE"); +// if (!isAccess) { +// //JOptionPane.showMessageDialog(this, "没有版本修改权限,请联系系统管理员", "提示", JOptionPane.WARNING_MESSAGE); +// MessageBox.post("没有版本修改权限,请联系系统管理员", "提示", MessageBox.INFORMATION); +// return; +// } +// initUI(); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } else { +// MessageBox.post("请选择版本", "错误", MessageBox.ERROR); +// } +// } +// +// /** +// * 获取分类属性LOV显示值 +// * @param icsD +// * @return +// */ +// public static String getClassDisplayableValue(ICSPropertyDescription icsD) { +// String result = ""; +// ICSKeyLov lov = icsD.getFormat().getKeyLov(); +// if (lov != null) { +// String[] keys = lov.getKeys(); +// for (String key : keys) { +// result = lov.getValueOfKey(key); +// return result; +// } +// } +// return result; +// } +// +// private void initUI() { +// this.setTitle("修改分类属性"); +// +// JPanel rootPanel = new JPanel(); +// rootPanel.setLayout(new BorderLayout()); +// rootPanel.setPreferredSize(new Dimension(600, 350)); +// +// Map displayMap = new LinkedHashMap(); +// propMap = new HashMap(); +// +// try { +// if (rev.getClassificationClass() != null && !"".equals(rev.getClassificationClass())) { +// try { +// rev.refresh(); +// System.out.println("rev.getClassificationClass()=" + rev.getClassificationClass()); +// TCComponentICO ico = rev.getClassificationObjects()[0]; +// ICSProperty[] props = ico.getICSProperties(true); +// desc = ico.getICSPropertyDescriptors(); +// for (int i = 0; i < props.length; i++) { +//// System.out.println(props[i].getId() + "===>" + props[i].getValue());// 30101===> +// // desc.getName=Type and size series 就是分类属性的名字||| desc.getId=30101就是分类属性ID +//// System.out.println("desc.getName=" + desc[i].getName() + " desc.getId=" + desc[i].getId()); +// displayMap.put(props[i], desc[i]); +// } +// } catch (TCException e1) { +// e1.printStackTrace(); +// } +// } else { +// this.disposeDialog(); +// MessageBox.post("当前版本未被分类", "错误", MessageBox.ERROR); +// return; +// } +// } catch (TCException e) { +// e.printStackTrace(); +// } +// +// if (displayMap.size() == 0) { +// return; +// } +// +// JPanel content = new JPanel(); +// content.setLayout(null); +// content.setPreferredSize(new Dimension(600, displayMap.size() * (25 + 10))); +// +// int num = 0; +// // 通过对象获取所有的分类属性,然后遍历分类属性 +// for (Entry entry : displayMap.entrySet()) { +// //+++ +// if(entry.getValue().isHidden()) { +// continue; +// } +// //+++ +// JLabel label = new JLabel(entry.getValue().getName() + ":"); +// label.setBounds(10, num * 35 + 10, 100, 25); +// +// ICSKeyLov lov = entry.getValue().getFormat().getKeyLov(); +//// ArrayList list = new ArrayList<>(); +// if (lov != null) { +// String[] keys = lov.getKeys(); +// JAutoCompleteComboBox combo = new JAutoCompleteComboBox(); +//// JComboBox combo = new JComboBox(); +// combo.addItem(new ClassPropBean("", "", "")); +// for (String key : keys) { +// //+++ +// KeyLov lov_key = lov.getKeyLovOfKey(key); +// boolean deprecated = lov_key.isDeprecated(); +// if(deprecated) { +// continue; +// } +// //+++ +// combo.addItem(new ClassPropBean(key, lov.getValueOfKey(key), "")); +// } +// +// String v = entry.getKey().getValue(); +// for (int i = 0; i < combo.getItemCount(); i++) { +// if (v.equals(((ClassPropBean) combo.getItemAt(i)).getId())) { +// combo.setSelectedIndex(i); +// break; +// } +// } +//// combo.setSelectedItem(v); +//// if (!Arrays.asList(lov.getDisplayValues()).contains(v)) { +//// combo.addItem(v); +//// combo.setSelectedItem(v); +//// } +// +// combo.setBounds(130, num * 35 + 10, 350, 25); +// +// propMap.put(entry.getValue().getName(), combo); +// content.add(combo); +// } else { +// JTextField text = new JTextField(entry.getKey().getValue()); +// text.setBounds(130, num * 35 + 10, 350, 25); +// propMap.put(entry.getValue().getName(), text); +// content.add(text); +// } +// +// content.add(label); +// +// num++; +// } +// +// JButton okBtn = new JButton("确认"); +//// okBtn.setBounds(40, 310, 100, 25); +// okBtn.setSelected(true); +// okBtn.addActionListener(ok()); +// JButton cancelBtn = new JButton("取消"); +//// cancelBtn.setBounds(160, 310, 100, 25); +// cancelBtn.addActionListener(cancel()); +// +// JScrollPane jsp = new JScrollPane(content); +// jsp.getVerticalScrollBar().setUnitIncrement(16); +//// jsp.setBounds(0, 0, 600, 300); +// jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); +// rootPanel.add(jsp,BorderLayout.CENTER); +// JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); +// buttonPanel.add(okBtn); +// buttonPanel.add(cancelBtn); +//// rootPanel.add(okBtn); +//// rootPanel.add(cancelBtn); +// rootPanel.add(buttonPanel,BorderLayout.SOUTH); +// this.setLayout(new BorderLayout()); +// this.add(rootPanel,BorderLayout.CENTER); +// this.pack(); +// this.centerToScreen(); +// this.setAutoRequestFocus(true); +//// this.setResizable(false); +// this.setAlwaysOnTop(true); +// this.showDialog(); +// } +// +// private ActionListener ok() { +// return new ActionListener() { +// +// @Override +// public void actionPerformed(ActionEvent e) { +// ((JButton) e.getSource()).setEnabled(false); +// rev = (TCComponentItemRevision) target; +// +// new Thread(new Runnable() { +// +// @Override +// public void run() { +// int i = 1; +// while (!DIALOG.finished) { +// try { +// DIALOG.setTitle("正在修改分类属性 " + StringCreateUtil.createPoint(i++ % 3)); +// Thread.sleep(200); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// } +// } +// } +// }).start(); +// +// EditClassificationDialog.this.setAlwaysOnTop(false); +// if (saveClassification(rev)) { +// MessageBox.post("修改分类属性成功!", "", MessageBox.ERROR); +// EditClassificationDialog.this.disposeDialog(); +// } else { +// MessageBox.post("修改分类属性失败!", "", MessageBox.ERROR); +// } +// +// } +// }; +// } +// +// private ActionListener cancel() { +// return new ActionListener() { +// +// @Override +// public void actionPerformed(ActionEvent e) { +// DIALOG.disposeDialog(); +// } +// }; +// } +// +// +// private TCComponentICO getICO(TCComponentItemRevision rev, String classId) throws Exception { +// if (rev == null || classId.equals("")) { +// return null; +// } +// TCComponentICO[] icos = rev.getClassificationObjects(); +// System.out.println(rev + " -> 已存在分类:" + Arrays.toString(icos)); +// int len = icos.length; +// if (len == 0) { +// return null; +// } +// TCClassificationService classService = session.getClassificationService(); +// for (int i = 0; i < len; i++) { +// TCComponentICO ico = icos[i]; +// classService.loadICOs(new String[] { ico.getUid() }, ""); +// if (ico.getClassId() == null || ico.getClassId().equals("")) { +// throw new Exception("分类加载异常,请联系管理员处理"); +// } +// if (classId.equals(ico.getClassId())) { +// return ico; +// } +// } +// return null; +// } +// +// public void deleteClass(String icoPuid) { +// try { +// ServiceClient sc = new ServiceClient(); +// Options opts = new Options(); +// String url = JDMethodUtil.getPrefStr("Autocode_SendClassServer_URL", session);// "http://10.201.5.203:19090/ErpWebService.asmx?WSDL"; +// EndpointReference end = new EndpointReference(url); +// opts.setTo(end); +// opts.setAction("DeleteClass"); +// sc.setOptions(opts); +// OMFactory fac = OMAbstractFactory.getOMFactory(); +// OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", ""); +// OMElement method = fac.createOMElement("DeleteClass", omNs); +// OMElement value = fac.createOMElement("icoPuid", omNs); +// value.setText(icoPuid); +// +// method.addChild(value); +// +// OMElement res = sc.sendReceive(method); +// res.getFirstElement().getText(); +// System.out.println(res.getFirstElement().getText()); +// } catch (AxisFault e) { +// e.printStackTrace(); +// } +// +// } +// +// public boolean sendToClass(String wsoPUID, String classID, String json) { +// try { +// ServiceClient sc = new ServiceClient(); +// Options opts = new Options(); +// String url = JDMethodUtil.getPrefStr("Autocode_SendClassServer_URL", session); +// // "http://10.201.5.203:19090/ErpWebService.asmx?WSDL"; +// EndpointReference end = new EndpointReference(url); +// opts.setTo(end); +// opts.setAction("SendToClass"); +// sc.setOptions(opts); +// OMFactory fac = OMAbstractFactory.getOMFactory(); +// OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", ""); +// OMElement method = fac.createOMElement("SendToClass", omNs); +// OMElement value = fac.createOMElement("wsoPuiid", omNs); +// value.setText(wsoPUID); +// OMElement value1 = fac.createOMElement("classID", omNs); +// value1.setText(classID); +// OMElement value2 = fac.createOMElement("JsonContainer", omNs); +// // "[{\"value\":\"1\",\"propertyID\":-500003},{\"value\":\"1\",\"propertyID\":-500011}]" +// value2.setText(json); +// +// method.addChild(value); +// method.addChild(value1); +// method.addChild(value2); +// +// OMElement res = sc.sendReceive(method); +// res.getFirstElement().getText(); +// System.out.println(res.getFirstElement().getText()); +// } catch (AxisFault e) { +//// MessageBox.post("发送分类失败!", "", MessageBox.ERROR); +// e.printStackTrace(); +// return false; +// } +// return true; +// +// } +// +// public String sendObjToClassficationByWebService(String icoPUID,String class_id, TCComponentItemRevision rev, String json) { +// String updateToClass=""; +// try { +// System.out.println("class_id-----dddddd----->" + class_id); +// System.out.println("icoPUID-----dddddd----->" + icoPUID); +// if (!class_id.replace(" ", "").equals("")) { +// SoaServerUtil.grantWritePrivilege(session, rev);// 赋予写权限 +// updateToClass = SoaServerUtil.updateToClass(rev.getUid(), class_id, json, url,icoPUID);// 发送到分类 +//// SoaServerUtil.deleteAndSendToClass(icoPUID,rev.getUid(), class_id, json, url);// 发送到分类 +// +// SoaServerUtil.grantReadPrivilege(session, rev);// 赋予读权限 +// } +// +// } catch (Exception e) { +// e.printStackTrace(); +// } +// return updateToClass; +// } +// +//// public static String objectToJson(List props) { +//// String str = null; +//// try { +//// JSONArray json = JSONArray.fromObject(props);// 将java对象转换为json对象 +//// str = json.toString();// 将json对象转换为字符串 +//// } catch (Exception e) { +//// e.printStackTrace(); +//// } +//// System.out.println("JSON =>" + str); +//// return str; +//// } +//} diff --git a/src/com/connor/zf/editClassAttr/JAutoCompleteComboBox.java b/src/com/connor/zf/editClassAttr/JAutoCompleteComboBox.java new file mode 100644 index 0000000..be3562f --- /dev/null +++ b/src/com/connor/zf/editClassAttr/JAutoCompleteComboBox.java @@ -0,0 +1,160 @@ +package com.connor.zf.editClassAttr; + +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.util.List; +import java.util.Vector; + +import javax.swing.ComboBoxModel; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JComboBox; +import javax.swing.JTextField; + +@SuppressWarnings({ "serial", "rawtypes", "unchecked" }) +public class JAutoCompleteComboBox extends JComboBox { + private AutoCompleter completer; + + public JAutoCompleteComboBox() { + super(); + addCompleter(); + } + + public JAutoCompleteComboBox(ComboBoxModel cm) { + super(cm); + addCompleter(); + } + + public JAutoCompleteComboBox(Object[] items) { + super(items); + addCompleter(); + } + + public JAutoCompleteComboBox(List v) { + super((Vector) v); + addCompleter(); + } + + private void addCompleter() { + setEditable(true); + completer = new AutoCompleter(this); + } + + public void autoComplete(String str) { + this.completer.autoComplete(str, str.length()); + } + + public String getText() { + return ((JTextField) getEditor().getEditorComponent()).getText(); + } + + public void setText(String text) { + ((JTextField) getEditor().getEditorComponent()).setText(text); + } + + public boolean containsItem(String itemString) { + for (int i = 0; i < this.getModel().getSize(); i++) { + String _item = " " + this.getModel().getElementAt(i); + if (_item.equals(itemString)) + return true; + } + return false; + } + +} + +@SuppressWarnings({"rawtypes"}) +class AutoCompleter implements KeyListener, ItemListener { + + private JComboBox owner = null; + private JTextField editor = null; + + private ComboBoxModel model = null; + + public AutoCompleter(JComboBox comboBox) { + owner = comboBox; + editor = (JTextField) comboBox.getEditor().getEditorComponent(); + editor.addKeyListener(this); + model = comboBox.getModel(); + owner.addItemListener(this); + } + + public void keyTyped(KeyEvent e) { + } + + public void keyPressed(KeyEvent e) { + } + + @SuppressWarnings("unused") + public void keyReleased(KeyEvent e) { + char ch = e.getKeyChar(); + // if (ch == KeyEvent.CHAR_UNDEFINED || Character.isISOControl(ch) + // || ch == KeyEvent.VK_DELETE) + // return; + if (e.getKeyCode() == KeyEvent.VK_ENTER) { + int caretPosition = editor.getCaretPosition(); + String str = editor.getText(); + if (str.length() == 0) + return; + autoComplete(str, caretPosition); + } + } + + @SuppressWarnings({ "unchecked", "unused" }) + protected void autoComplete(String strf, int caretPosition) { + Object[] opts; + opts = getMatchingOptions(strf.substring(0, caretPosition)); + if (owner != null) { + model = new DefaultComboBoxModel(opts); + owner.setModel(model); + } + if (opts.length > 0) { + String str = opts[0].toString(); + editor.setCaretPosition(caretPosition); + if (owner != null) { + try { + owner.showPopup(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + } + } + + @SuppressWarnings("unchecked") + protected Object[] getMatchingOptions(String str) { + List v = new Vector(); + List v1 = new Vector(); + // v.add(str); + for (int k = 0; k < model.getSize(); k++) { + Object itemObj = model.getElementAt(k); + if (itemObj != null) { + String item = itemObj.toString().toLowerCase(); + if (item.indexOf((str.toLowerCase())) > -1) + v.add(model.getElementAt(k)); + else + v1.add(model.getElementAt(k)); + } else + v1.add(model.getElementAt(k)); + } + for (int i = 0; i < v1.size(); i++) { + v.add(v1.get(i)); + } + // if (v.isEmpty()) + return v.toArray(); + } + + public void itemStateChanged(ItemEvent event) { + if (event.getStateChange() == ItemEvent.SELECTED) { + int caretPosition = editor.getCaretPosition(); + if (caretPosition != -1) { + try { + editor.moveCaretPosition(caretPosition); + } catch (IllegalArgumentException ex) { + ex.printStackTrace(); + } + } + } + } +} \ No newline at end of file diff --git a/src/com/connor/zf/editClassAttr/editClassAttrHandler.java b/src/com/connor/zf/editClassAttr/editClassAttrHandler.java new file mode 100644 index 0000000..170f511 --- /dev/null +++ b/src/com/connor/zf/editClassAttr/editClassAttrHandler.java @@ -0,0 +1,24 @@ +//package com.connor.zf.editClassAttr; +// +//import org.eclipse.core.commands.AbstractHandler; +//import org.eclipse.core.commands.ExecutionEvent; +//import org.eclipse.core.commands.ExecutionException; +// +//import com.teamcenter.rac.aif.AbstractAIFApplication; +//import com.teamcenter.rac.aifrcp.AIFUtility; +//import com.teamcenter.rac.kernel.TCException; +// +//public class editClassAttrHandler extends AbstractHandler { +// +// @Override +// public Object execute(ExecutionEvent arg0) throws ExecutionException { +// AbstractAIFApplication app = AIFUtility.getCurrentApplication(); +// try { +// new Thread(new EditClassificationDialog(app)).start(); +// } catch (TCException e) { +// e.printStackTrace(); +// } +// return null; +// } +// +//} diff --git a/src/com/connor/zf/plm/bean/NodeBean.java b/src/com/connor/zf/plm/bean/NodeBean.java new file mode 100644 index 0000000..c55605f --- /dev/null +++ b/src/com/connor/zf/plm/bean/NodeBean.java @@ -0,0 +1,66 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.connor.zf.plm.bean; + +import com.teamcenter.rac.kernel.TCComponentBOMLine; + +/** + * + * @author vearn + */ +public class NodeBean { + + private String id; + private String name; + private String label;// 选中属性 + private TCComponentBOMLine targer; + + public TCComponentBOMLine getTarger() { + return targer; + } + + public void setTarger(TCComponentBOMLine targer) { + this.targer = targer; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public NodeBean() { + + } + + public NodeBean(String id, String name, String label, TCComponentBOMLine targer) { + super(); + this.id = id; + this.name = name; + this.label = label; + this.targer = targer; + } + + + +} \ No newline at end of file diff --git a/src/com/connor/zf/plm/xmlUtil/CNCompontent.java b/src/com/connor/zf/plm/xmlUtil/CNCompontent.java new file mode 100644 index 0000000..7c833a3 --- /dev/null +++ b/src/com/connor/zf/plm/xmlUtil/CNCompontent.java @@ -0,0 +1,61 @@ +package com.connor.zf.plm.xmlUtil; + +import java.util.List; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; + +/** + * @copyRight 浙江康勒科技有限公司 + * @author 作者 E-mail:hub@connor.net.cn + * @date 创建时间:2017-7-2 下午8:12:38 + * @version v1.0 + * @parameter + * @since + * @return + */ + +public class CNCompontent { + String type; + String compententType; + List propertyList; + + public CNCompontent() { + + } + + public CNCompontent(String type, String compententType, + List propertyList) { + this.type = type; + this.compententType = compententType; + this.propertyList = propertyList; + } + + @XmlAttribute(name = "type") + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @XmlAttribute(name = "compententType") + public String getCompententType() { + return compententType; + } + + public void setCompententType(String compententType) { + this.compententType = compententType; + } + + @XmlElement(name = "property") + public List getPropertyList() { + return propertyList; + } + + public void setPropertyList(List propertyList) { + this.propertyList = propertyList; + } + +} diff --git a/src/com/connor/zf/plm/xmlUtil/CNPart.java b/src/com/connor/zf/plm/xmlUtil/CNPart.java new file mode 100644 index 0000000..672bfd2 --- /dev/null +++ b/src/com/connor/zf/plm/xmlUtil/CNPart.java @@ -0,0 +1,54 @@ +package com.connor.zf.plm.xmlUtil; + +/** + * @copyRight 浙江康勒科技有限公司 + * @author 作者 E-mail:hub@connor.net.cn + * @date 创建时间:2017-7-2 下午6:57:03 + * @version v1.0 + * @parameter + * @since + * @return + */ + +import java.util.List; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; + +public class CNPart { + String type; // 类型 + + List compontentList; // + + + + + + + public CNPart() { + } + + public CNPart(String type, List compontentList) { + this.type = type; + this.compontentList = compontentList; + } + + @XmlAttribute(name = "type") + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @XmlElement(name = "compontent") + public List getCompontentList() { + return compontentList; + } + + public void setCompontentList(List compontentList) { + this.compontentList = compontentList; + } + +} diff --git a/src/com/connor/zf/plm/xmlUtil/CNPartList.java b/src/com/connor/zf/plm/xmlUtil/CNPartList.java new file mode 100644 index 0000000..5d1defb --- /dev/null +++ b/src/com/connor/zf/plm/xmlUtil/CNPartList.java @@ -0,0 +1,43 @@ +package com.connor.zf.plm.xmlUtil; + +/** + * @copyRight 浙江康勒科技有限公司 + * @author 作者 E-mail:hub@connor.net.cn + * @date 创建时间:2017-7-2 下午7:59:50 + * @version v1.0 + * @parameter + * @since + * @return + */ + +import java.util.List; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "parts") +public class CNPartList { + + List partList; // + + + + + public CNPartList() { + } + + public CNPartList(List partList) { + + this.partList = partList; + } + + @XmlElement(name = "part") + public List getPartList() { + return partList; + } + + public void setPartList(List partList) { + this.partList = partList; + } + +} \ No newline at end of file diff --git a/src/com/connor/zf/plm/xmlUtil/CNProperty.java b/src/com/connor/zf/plm/xmlUtil/CNProperty.java new file mode 100644 index 0000000..99d65cb --- /dev/null +++ b/src/com/connor/zf/plm/xmlUtil/CNProperty.java @@ -0,0 +1,141 @@ +package com.connor.zf.plm.xmlUtil; + +/** + * @copyRight 浙江康勒科技有限公司 + * @author 作者 E-mail:hub@connor.net.cn + * @date 创建时间:2017-7-2 下午7:59:01 + * @version v1.0 + * @parameter + * @since + * @return + */ + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlAttribute; + +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.soa.client.model.LovValue; + +public class CNProperty { + // + String lovName; // lov属性名称 + Boolean isLov; // 是否是lov + Boolean isMust; // 是否必须 + String propertyType;// 属性类型 + String displayName;// 显示名称 + String realName;// 属性真实名称 + String defaultValue; + public List lovValueList; + public List lovDisplayValueList; + public int selectIndex = -1; + public Object value; + public TCComponentListOfValues lov; + + public void initProperty() { + try { + this.lovValueList = new ArrayList<>(); + this.lovDisplayValueList = new ArrayList<>(); + if (this.isLov) { + lov = TCComponentListOfValuesType + .findLOVByName(lovName); + if (lov != null) { + ListOfValuesInfo info = lov.getListOfValues(); + info.getLOVDisplayValues(); + List lovValueList = info.getValues(); + for (LovValue lovV : lovValueList) { + this.lovDisplayValueList.add(lovV.getDisplayValue()); + this.lovValueList.add(lovV.getStringValue()); + } + } + } + } catch (TCException e) { + e.printStackTrace(); + } + + } + + public CNProperty() { + } + + public CNProperty(String realName, String displayName, String propertyType, + Boolean isMust, Boolean isLov, String lovName) { + this.realName = realName; + this.displayName = displayName; + this.propertyType = propertyType; + this.isMust = isMust; + this.isLov = isLov; + this.lovName = lovName; + } + + + + @XmlAttribute(name = "defaultValue") + public String getDefaultValue() { + return defaultValue; + } + + public void setDefaultValue(String defaultValue) { + this.defaultValue = defaultValue; + } + + @XmlAttribute(name = "lovName") + public String getLovName() { + return lovName; + } + + public void setLovName(String lovName) { + this.lovName = lovName; + } + + @XmlAttribute(name = "isLov") + public Boolean getIsLov() { + return isLov; + } + + public void setIsLov(Boolean isLov) { + this.isLov = isLov; + } + + @XmlAttribute(name = "isMust") + public Boolean getIsMust() { + return isMust; + } + + public void setIsMust(Boolean isMust) { + this.isMust = isMust; + } + + @XmlAttribute(name = "propertyType") + public String getPropertyType() { + return propertyType; + } + + public void setPropertyType(String propertyType) { + this.propertyType = propertyType; + } + + @XmlAttribute(name = "displayName") + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + @XmlAttribute(name = "realName") + public String getRealName() { + return realName; + } + + public void setRealName(String realName) { + this.realName = realName; + } + +} \ No newline at end of file diff --git a/src/com/connor/zf/plm/xmlUtil/CNXmlUtil.java b/src/com/connor/zf/plm/xmlUtil/CNXmlUtil.java new file mode 100644 index 0000000..31eecd2 --- /dev/null +++ b/src/com/connor/zf/plm/xmlUtil/CNXmlUtil.java @@ -0,0 +1,60 @@ +package com.connor.zf.plm.xmlUtil; + +/** + * @copyRight 浙江康勒科技有限公司 + * @author 作者 E-mail:hub@connor.net.cn + * @date 创建时间:2017-7-2 下午8:52:53 + * @version v1.0 + * @parameter + * @since + * @return + */ + +import java.io.File; +import java.io.IOException; +import java.util.List; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; + +public class CNXmlUtil { + + /** + * xml文件配置转换为对象 + * + * @param xmlPath + * xml文件路径 + * @param load + * java对象.Class + * @return java对象 + * @throws JAXBException + * @throws IOException + */ + public static Object xmlToBean(String xmlPath, Class load) + throws JAXBException, IOException { + JAXBContext context = JAXBContext.newInstance(load); + Unmarshaller unmarshaller = context.createUnmarshaller(); + Object object = unmarshaller.unmarshal(new File(xmlPath)); + return object; + } + + public static void main(String[] args) throws IOException, JAXBException { + String xmlPath = "C:\\Users\\Administrator\\AppData\\Local\\Temp\\20170702215339358.xml"; + Object object = CNXmlUtil.xmlToBean(xmlPath, CNPartList.class); + CNPartList parts = (CNPartList) object; + List partList = parts.getPartList(); + + for (int i = 0; i < partList.size(); i++) { + System.out.println(partList.get(i).getType()); + for (CNCompontent comp : partList.get(i).getCompontentList()) { + System.out.println(comp.type); + System.out.println(comp.compententType); + for (CNProperty prop : comp.propertyList) { + System.out.println(prop.displayName); + } + } + } + System.out.println("-----------------------------"); + } +} \ No newline at end of file diff --git a/src/com/connor/zf/plm001/DDInClassDialog.java b/src/com/connor/zf/plm001/DDInClassDialog.java new file mode 100644 index 0000000..81aa444 --- /dev/null +++ b/src/com/connor/zf/plm001/DDInClassDialog.java @@ -0,0 +1,544 @@ +package com.connor.zf.plm001; + +import java.awt.BorderLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.DefaultListModel; +import javax.swing.JButton; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; + +import com.connor.zf.plm001.TMom005CreateOPByModuleOperation; +//import com.connor.renben.process.plm.tmom005.TMom005CreateOPByModuleOperation; +//import com.connor.renben.process.plm.tmom006.TMom006CreateProcessByProcessOperation; +//import com.connor.renben.process.plm.tmom007.TMom007ResourcesAssignedOperation; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.classification.common.G4MInClassDialog; +import com.teamcenter.rac.classification.common.table.G4MTable; +import com.teamcenter.rac.classification.common.table.G4MTableModel; +import com.teamcenter.rac.classification.common.tree.G4MTree; +import com.teamcenter.rac.commands.paste.PasteCommand; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSHierarchyNodeDescriptor; +import com.teamcenter.rac.util.ButtonLayout; +import com.teamcenter.rac.util.HorizontalLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.Registry; +import com.teamcenter.rac.util.SplitPane; +import com.teamcenter.rac.util.Utilities; +import com.teamcenter.rac.util.VerticalLayout; + +//import org.apache.log4j.Logger; + +public class DDInClassDialog extends G4MInClassDialog { + private Registry m_reg; + private TCSession m_session; + protected InterfaceAIFComponent targets; + private ArrayList listComps; + private TCClassificationService m_ics; + private JButton addButton; + private JButton removeButton; + private ArrayList objectsToBePasted = new ArrayList(); + private ArrayList childrenList = new ArrayList(); + private DefaultListModel selectedDictionaryListModel; + private JList selectedDictionaryList; + private TCPreferenceService m_filterPrefService; + private String[] m_filterValues; + private static final long serialVersionUID = 1L; + private String commandId; + + // private static final Logger logger = + // Logger.getLogger(DDInClassDialog.class); + + public DDInClassDialog( + AbstractAIFUIApplication paramAbstractAIFUIApplication, + InterfaceAIFComponent paramTCComponentBOMLine, int paramInt) { + super(paramAbstractAIFUIApplication, paramInt); + this.m_reg = Registry.getRegistry(DDInClassDialog.class); + this.targets = paramTCComponentBOMLine; + this.m_session = ((TCSession) paramAbstractAIFUIApplication + .getSession()); + this.m_ics = this.m_session.getClassificationService(); + buildInitialization(); + } + + public DDInClassDialog( + AbstractAIFUIApplication paramAbstractAIFUIApplication, + InterfaceAIFComponent paramTCComponentBOMLine, int paramInt, + String commandId) { + super(paramAbstractAIFUIApplication, paramInt); + this.m_reg = Registry.getRegistry(DDInClassDialog.class); + this.targets = paramTCComponentBOMLine; + this.m_session = ((TCSession) paramAbstractAIFUIApplication + .getSession()); + this.m_ics = this.m_session.getClassificationService(); + this.commandId = commandId; + buildInitialization(); + } + + public DDInClassDialog( + AbstractAIFUIApplication paramAbstractAIFUIApplication, + int paramInt, boolean paramBoolean) { + super(paramAbstractAIFUIApplication, paramInt, paramBoolean); + } + + public DDInClassDialog( + AbstractAIFUIApplication paramAbstractAIFUIApplication, int paramInt) { + super(paramAbstractAIFUIApplication, paramInt); + } + + public DDInClassDialog( + AbstractAIFUIApplication paramAbstractAIFUIApplication) { + super(paramAbstractAIFUIApplication); + } + + private void buildInitialization() { + setTitle(this.m_reg.getString("DDInClassDialog.TITLE")); + super.setTitleText(this.m_reg.getString("DDInClassDialog.TITLE")); + JPanel localJPanel1 = new JPanel(new BorderLayout()); + JPanel localJPanel2 = tableListPanel(); + SplitPane localSplitPane = new SplitPane(1); + localSplitPane.setTopComponent(localJPanel2); + localSplitPane.setDividerLocation(0.95D); + JPanel localJPanel3 = createButtonPanel(); + localJPanel1.add("Center", localSplitPane); + localJPanel1.add("South", localJPanel3); + setContentPane(localJPanel1); + } + + protected void initializeDialogBasedOnCookie() { + setPersistentDisplayCookieFileName(G4MInClassDialog.COOKIE_FILENAME); + setPersistentDisplay(true); + setLocation(100, 100); + pack(); + setSize(700, 400); + readDisplayParameters(); + } + + private JPanel tableListPanel() { + JPanel localJPanel1 = new JPanel(new HorizontalLayout(10, 10, 10, 10, + 10)); + JPanel localJPanel2 = treeTablePanel(); + JPanel localJPanel3 = buildAddandRemoveButtonPanel(); + JPanel localJPanel4 = new JPanel(new BorderLayout()); + localJPanel4.add(localJPanel2, "Center"); + localJPanel1.add("unbound.bind", localJPanel4); + localJPanel1.add("right.bind.center.center", localJPanel3); + JPanel localJPanel5 = buildSelectedDictionaryPanel(this.m_session, + this.m_reg); + SplitPane localSplitPane = new SplitPane(0); + localSplitPane.setLeftComponent(localJPanel1); + localSplitPane.setRightComponent(new JScrollPane(localJPanel5)); + localSplitPane.setDividerLocation(0.85D); + JPanel localJPanel6 = new JPanel(new BorderLayout()); + localJPanel6.add(localSplitPane, "Center"); + return localJPanel6; + } + + protected JPanel buildAddandRemoveButtonPanel() { + JPanel localJPanel = new JPanel(); + localJPanel.setLayout(new ButtonLayout(2)); + this.addButton = new JButton( + this.m_reg.getImageIcon("quickAddButton.ICON")); + this.listComps = new ArrayList(); + this.addButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent paramAnonymousActionEvent) { + DDInClassDialog.this.addSelectedNodeAction(); + } + }); + this.listComps.clear(); + localJPanel.add(this.addButton); + this.removeButton = new JButton(this.m_reg.getImageIcon("minus.ICON")); + this.removeButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent paramAnonymousActionEvent) { + DDInClassDialog.this.removeSelectedNodeAction(); + } + }); + localJPanel.add(this.removeButton); + return localJPanel; + } + + protected JPanel createButtonPanel() { + JPanel localJPanel = new JPanel(); + JButton localJButton = new JButton(this.m_reg.getString("cancel.NAME")); + this.m_okButton = new JButton(this.m_reg.getString("oK.NAME")); + this.m_okButton.addActionListener(this); + if (this.selectedDictionaryListModel.getSize() > 0) { + this.m_okButton.setEnabled(true); + } + localJButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent paramAnonymousActionEvent) { + DDInClassDialog.this.closeDialogs(); + } + }); + localJPanel.add(this.m_okButton); + localJPanel.add(localJButton); + return localJPanel; + } + + private JPanel treeTablePanel() { + setLayout(new BorderLayout()); + JTabbedPane localJTabbedPane = createMainTabbedPane(); + this.m_filterPrefService = this.m_session.getPreferenceService(); + this.m_filterValues = this.m_filterPrefService + .getStringValues("ICS_FilterBy_Library_types"); + if (this.m_filterValues == null) { + this.m_filterValues = new String[0]; + } + String[] arrayOfString = getAssoicateToProjectClassID(); + if ((arrayOfString != null) && (arrayOfString.length > 0)) { + this.m_tree = new G4MTree(this.m_context, true, + this.m_filterValues, "Library"); + this.m_tree.addG4MTreeListener(this); + this.m_tree.setReducedClassList(arrayOfString); + this.m_tree.refresh("ICM", true, false); + } else { + this.m_tree = new G4MTree(this.m_context, true, + this.m_filterValues, "Library"); + this.m_tree.addG4MTreeListener(this); + } + SplitPane localSplitPane = new SplitPane(0); + localSplitPane.setDividerSize(2); + localSplitPane.setDividerLocation(0.4D); + localSplitPane.setLeftComponent(this.m_tree); + localSplitPane.getLeftComponent().validate(); + localSplitPane.setRightComponent(localJTabbedPane); + localSplitPane.getRightComponent().validate(); + JPanel localJPanel = new JPanel(new BorderLayout()); + localJPanel.add(localSplitPane, "Center"); + return localJPanel; + } + + private String[] getAssoicateToProjectClassID() { + String[] arrayOfString1 = null; + ArrayList localArrayList1 = new ArrayList(); + TCComponent[] arrayOfTCComponent1 = null; + try { + TCComponentItem localTCComponentItem = ((TCComponentItemRevision) this.targets) + .getItem(); + arrayOfTCComponent1 = localTCComponentItem + .getReferenceListProperty("project_list"); + TCClassificationService localTCClassificationService = this.m_session + .getClassificationService(); + int i; + if ((arrayOfTCComponent1 != null) + && (arrayOfTCComponent1.length > 0)) { + for (i = 0; i < arrayOfTCComponent1.length; i++) { + TCComponent[] arrayOfTCComponent2 = arrayOfTCComponent1[i] + .getRelatedComponents("Fnd0LibraryForProject"); + if (arrayOfTCComponent2.length > 0) { + for (int j = 0; j < arrayOfTCComponent2.length; j++) { + ICSHierarchyNodeDescriptor localICSHierarchyNodeDescriptor = localTCClassificationService + .describeNode(arrayOfTCComponent2[j] + .getProperty("cid"), 0); + ICSHierarchyNodeDescriptor[] arrayOfICSHierarchyNodeDescriptor = this.m_context + .getChildren( + localICSHierarchyNodeDescriptor + .getId(), + localICSHierarchyNodeDescriptor + .getClassChildrenCount()); + String[] arrayOfString2 = this.m_context + .getParents(arrayOfTCComponent2[j] + .getProperty("cid")); + if (arrayOfString2.length > 0) { + for (int k = 0; k < arrayOfString2.length; k++) { + localArrayList1.add(arrayOfString2[k]); + } + if (arrayOfICSHierarchyNodeDescriptor != null) { + ArrayList localArrayList2 = new ArrayList(); + localArrayList2 = getAssociateChildrensClassID(localICSHierarchyNodeDescriptor); + for (int m = 0; m < localArrayList2.size(); m++) { + localArrayList1.add(localArrayList2 + .get(m)); + } + } + localArrayList1.add(arrayOfTCComponent2[j] + .getProperty("cid")); + } + } + } + } + } + if (localArrayList1 != null) { + arrayOfString1 = new String[localArrayList1.size()]; + for (i = 0; i < localArrayList1.size(); i++) { + arrayOfString1[i] = ((String) localArrayList1.get(i)); + } + } + } catch (Exception localException) { + } + return arrayOfString1; + } + + private ArrayList getAssociateChildrensClassID( + ICSHierarchyNodeDescriptor paramICSHierarchyNodeDescriptor) { + ICSHierarchyNodeDescriptor[] arrayOfICSHierarchyNodeDescriptor = this.m_context + .getChildren(paramICSHierarchyNodeDescriptor.getId(), + paramICSHierarchyNodeDescriptor.getClassChildrenCount()); + if (arrayOfICSHierarchyNodeDescriptor != null) { + for (int i = 0; i < arrayOfICSHierarchyNodeDescriptor.length; i++) { + getAssociateChildrensClassID(arrayOfICSHierarchyNodeDescriptor[i]); + this.childrenList.add(arrayOfICSHierarchyNodeDescriptor[i] + .getId()); + } + } + return this.childrenList; + } + + private void performOKAction() { + this.selectedDictionaryListModel = ((DefaultListModel) this.selectedDictionaryList + .getModel()); + if (this.selectedDictionaryListModel.getSize() > 0) { + Object[] arrayOfObject = this.selectedDictionaryListModel.toArray(); + int i = arrayOfObject.length; + for (int j = 0; j < i; j++) { + TCComponent localTCComponent = (TCComponent) this.selectedDictionaryListModel + .get(j); + this.objectsToBePasted.add(localTCComponent); + } + } + try { + if (this.objectsToBePasted.size() > 0) { + callPasteObjects(this.objectsToBePasted); + } + this.listComps.clear(); + disposeDialog(); + } catch (Exception localException) { + // logger.error(localException.getClass().getName(), + // localException); + } + } + + private void callPasteObjects(ArrayList paramArrayList) throws Exception { + InterfaceAIFComponent[] arrayOfInterfaceAIFComponent = { this.targets }; + TCComponent[] arrayOfTCComponent = null; + PasteCommand localPasteCommand = null; + arrayOfTCComponent = new TCComponent[paramArrayList.size()]; + arrayOfTCComponent = (TCComponent[]) paramArrayList + .toArray(arrayOfTCComponent); + localPasteCommand = new PasteCommand(arrayOfTCComponent, + arrayOfInterfaceAIFComponent, Boolean.TRUE); + localPasteCommand.setFailBackFlag(true); + localPasteCommand.executeModal(); + } + + public void actionPerformed(ActionEvent paramActionEvent) { + if (paramActionEvent.getSource() == this.m_clearButton.getButton()) { + this.m_OIDtextField.setText(""); + this.m_compTextField.setText(""); + } else if (paramActionEvent.getSource() == this.m_okButton) { + // String s = this.m_OIDtextField.getText(); + // String s1 = this.m_compTextField.getText(); + // MessageBox.post("确定按钮!", "错误!", 1); + // performOKAction(); + System.out.println("当前的commandId为:" + commandId); + this.selectedDictionaryListModel = ((DefaultListModel) this.selectedDictionaryList + .getModel()); + if (this.selectedDictionaryListModel.getSize() > 0) { + Object[] arrayOfObject = this.selectedDictionaryListModel.toArray(); + TMom005CreateOPByModuleOperation createOPOperation = new TMom005CreateOPByModuleOperation( + this.m_session, this.targets, + arrayOfObject); + this.m_session.queueOperation(createOPOperation); + } + +// TMom005CreateOPByModuleOperation createOPOperation = new TMom005CreateOPByModuleOperation( +// this.m_session, this.targets, +// this.m_compTextField.getText()); +// this.m_session.queueOperation(createOPOperation); + switch (commandId) { + case "com.connor.renben.process.plm.commands.CreateOPByModule": +// TMom005CreateOPByModuleOperation createOPOperation = new TMom005CreateOPByModuleOperation( +// this.m_session, this.targets, +// this.m_compTextField.getText()); +// this.m_session.queueOperation(createOPOperation); + break; + case "com.connor.renben.process.plm.commands.CreateProcessByModule": +// TMom006CreateProcessByProcessOperation createProcessOperation = new TMom006CreateProcessByProcessOperation( +// targets, this.m_compTextField.getText(), this.m_session); +// this.m_session.queueOperation(createProcessOperation); + break; + case "com.connor.renben.process.plm.commands.ResourcesAssigned": +// TMom007ResourcesAssignedOperation resourcesAssignedOperation = new TMom007ResourcesAssignedOperation( +// targets, this.m_compTextField.getText(), this.m_session); +// this.m_session.queueOperation(resourcesAssignedOperation); + break; + + default: + break; + } + } else if (paramActionEvent.getSource() == this.m_searchButton) { + performAttributeSearch(); + } else { + performObjectIDSearch(); + } + } + + private void addSelectedNodeAction() { + int i = 1; + ArrayList localArrayList = new ArrayList(); + DefaultListModel localDefaultListModel = (DefaultListModel) this.selectedDictionaryList + .getModel(); + int j = this.m_tabbedPane.getSelectedIndex(); + TCComponent localTCComponent = null; + Object localObject1; + Object localObject2; + Object localObject3; + if (j == 1) { + localObject1 = this.m_context.getICSApplicationObject() + .getClassifiedObjectUid(); + try { + localTCComponent = this.m_ics + .getTCComponent((String) localObject1); + if (!this.listComps.contains(localTCComponent)) { + localDefaultListModel.addElement(localTCComponent); + this.listComps.add(localTCComponent); + this.selectedDictionaryList.setModel(localDefaultListModel); + } else { + localArrayList.add(localTCComponent); + i = 0; + } + } catch (TCException localTCException1) { + // logger.error(localTCException1.getClass().getName(), + // localTCException1); + } + } else if (j == 2) { + localObject1 = this.m_tablePane.getG4MTable(); + if (localObject1 != null) { + G4MTableModel localG4MTableModel = ((G4MTable) localObject1) + .getG4MTableModel(); + localObject2 = null; + localObject3 = ((G4MTable) localObject1).getSelectedRows(); + if (((int[]) localObject3).length == 0) { + return; + } + for (int m = 0; m < ((int[]) localObject3).length; m++) { + String str2 = localG4MTableModel.getValueAt( + ((int[]) localObject3)[m], + localG4MTableModel.getWSOColumnNo()).toString(); + if ((str2 != null) && (str2.length() > 0)) { + try { + localObject2 = this.m_ics.getTCComponent(str2); + if (!this.listComps.contains(localObject2)) { + localDefaultListModel.addElement(localObject2); + this.listComps.add((TCComponent) localObject2); + this.selectedDictionaryList + .setModel(localDefaultListModel); + } else { + localArrayList.add(localObject2); + i = 0; + } + } catch (TCException localTCException2) { + // logger.error(localTCException2.getClass().getName(), + // localTCException2); + } + } else { + MessageBox + .post(Utilities.getCurrentFrame(), + this.m_reg + .getString("invalidSelectedObject.MESSAGE"), + this.m_reg + .getString("absOccIllegalSelection.TITLE"), + 1); + } + if (this.m_tree != null) { + this.m_tree.getTree().getSelectionModel() + .clearSelection(); + } + } + } + } + if (i == 0) { + localObject1 = new StringBuffer(); + if (localArrayList.size() > 0) { + for (int k = 0; k < localArrayList.size(); k++) { + if (((StringBuffer) localObject1).length() > 0) { + ((StringBuffer) localObject1).append(","); + } + ((StringBuffer) localObject1).append(localArrayList.get(k)); + } + } + if (((StringBuffer) localObject1).length() > 0) { + Registry localRegistry = Registry.getRegistry(this); + localObject2 = localRegistry + .getString("duplicateAdded.MESSAGE"); + localObject3 = ((String) localObject2).substring(0, + ((String) localObject2).indexOf("%1")); + String str1 = ((String) localObject2) + .substring(((String) localObject2).indexOf("%1") + 2); + MessageBox.post( + Utilities.getCurrentFrame(), + localObject3 + "[" + + ((StringBuffer) localObject1).toString() + + "]" + str1, + localRegistry.getString("duplicateAdded.TITLE"), 1); + } + } + } + + private void removeSelectedNodeAction() { + List localList = this.selectedDictionaryList.getSelectedValuesList(); + if ((localList != null) && (localList.size() > 0)) { + for (int i = 0; i < localList.size(); i++) { + this.selectedDictionaryListModel + .removeElement(localList.get(i)); + this.listComps.remove(localList.get(i)); + } + } + if (this.selectedDictionaryList.getSelectedValue() != null) { + this.selectedDictionaryListModel + .removeElement(this.selectedDictionaryList + .getSelectedValue()); + this.listComps.remove(this.selectedDictionaryList + .getSelectedValue()); + } + } + + protected JPanel buildSelectedDictionaryPanel(TCSession paramTCSession, + Registry paramRegistry) { + this.selectedDictionaryListModel = new DefaultListModel(); + this.selectedDictionaryList = new JList( + this.selectedDictionaryListModel); + this.selectedDictionaryList.setSelectionMode(2); + JScrollPane localJScrollPane = new JScrollPane( + this.selectedDictionaryList, 20, 30); + JPanel localJPanel1 = new JPanel(new VerticalLayout(3, 3, 3, 3, 3)); + localJPanel1.add("unbound", localJScrollPane); + JPanel localJPanel2 = new JPanel(new BorderLayout()); + localJPanel2.add(localJPanel1, "Center"); + JPanel localJPanel3 = new JPanel(new HorizontalLayout(3, 3, 3, 3, 3)); + localJPanel3.add("unbound.bind", localJPanel2); + return localJPanel3; + } + + public ArrayList getObjectsToBePasted() { + if ((this.objectsToBePasted == null) + || (this.objectsToBePasted.size() == 0)) { + this.selectedDictionaryListModel = ((DefaultListModel) this.selectedDictionaryList + .getModel()); + if (this.selectedDictionaryListModel.getSize() > 0) { + Object[] arrayOfObject = this.selectedDictionaryListModel + .toArray(); + int i = arrayOfObject.length; + for (int j = 0; j < i; j++) { + TCComponent localTCComponent = (TCComponent) this.selectedDictionaryListModel + .get(j); + this.objectsToBePasted.add(localTCComponent); + } + } + } + return this.objectsToBePasted; + } +} diff --git a/src/com/connor/zf/plm001/MaintenanceProcedureHandler.java b/src/com/connor/zf/plm001/MaintenanceProcedureHandler.java new file mode 100644 index 0000000..fd01c6c --- /dev/null +++ b/src/com/connor/zf/plm001/MaintenanceProcedureHandler.java @@ -0,0 +1,35 @@ +package com.connor.zf.plm001; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; + +public class MaintenanceProcedureHandler extends AbstractHandler{ + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + final AbstractAIFUIApplication localAbstractAIFUIApplication = AIFDesktop + .getActiveDesktop().getCurrentApplication(); + String commandId = arg0.getCommand().getId(); + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + new Thread() { + @Override + public void run() { + DDInClassDialog localDDInClassDialog = new DDInClassDialog( + localAbstractAIFUIApplication,targetComponent, 2, + commandId); + localDDInClassDialog.setVisible(true); + } + }.start(); + return null; + } + +} diff --git a/src/com/connor/zf/plm001/TMom005CreateOPByModuleOperation.java b/src/com/connor/zf/plm001/TMom005CreateOPByModuleOperation.java new file mode 100644 index 0000000..edce6f0 --- /dev/null +++ b/src/com/connor/zf/plm001/TMom005CreateOPByModuleOperation.java @@ -0,0 +1,244 @@ +package com.connor.zf.plm001; + +import java.awt.print.Printable; +import java.util.ArrayList; + +import com.connor.zf.utils.TMomFinalUtil; +import com.connor.zf.utils.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom005CreateOPByModuleOperation extends AbstractAIFOperation { + private InterfaceAIFComponent targets;// 选中对象 + private String selectItems;// 分类界面选择对象 + private TCSession session; + private Object[] arrayOfObject; + + public TMom005CreateOPByModuleOperation(TCSession session, + InterfaceAIFComponent targets, String selectItems) { + this.session = session; + this.targets = targets; + this.selectItems = selectItems; + } + + public TMom005CreateOPByModuleOperation(TCSession session,InterfaceAIFComponent targets,Object[] arrayOfObject) { + this.session = session; + this.targets = targets; + this.arrayOfObject = arrayOfObject; + } + + @Override + public void executeOperation() throws Exception { + ArrayList itemlists = new ArrayList(); + TCComponentItem item = null; + + if (this.targets instanceof TCComponentBOMLine) { + item = ((TCComponentBOMLine) this.targets).getItem(); + } + // 获取ItemId +// String[] itemID = null; +// if (selectItems.indexOf(" | ") > -1) { +// itemID = selectItems.split(" | "); +// } else { +// itemID = new String[] { selectItems }; +// } + String[] itemID = new String[arrayOfObject.length]; + for (int i = 0; i < arrayOfObject.length; i++) { + String[] split = arrayOfObject[i].toString().split(";"); + itemID[i] = split[0]; + } + // 获取选中的对象 + TCComponentItemType itemType = (TCComponentItemType) this.session + .getTypeComponent("Item"); + TCComponentItemType gxType = (TCComponentItemType) session + .getTypeComponent("ZF6_BZGX"); + String classID=""; + if (itemID != null && itemID.length > 0) { + for (int i = 0; i < itemID.length; i++) { + TCComponentItem childrenItem = itemType.find(itemID[i] + .substring(0, itemID[i].length() - 1)); + //通过String类型的物料号和对象类型来查找对象+++ + if (itemID[i].indexOf("/") >= 0) { + childrenItem = itemType.find(itemID[i].split("/")[0]); + classID=(childrenItem.getLatestItemRevision()).getClassificationClass(); + } + if (!childrenItem.getType().equals("ZF6_BZGX")) { + MessageBox.post("请选择工序对象!" + childrenItem.getType(), "错误!", MessageBox.ERROR); + return; + } + TCComponent[] mepComponents = item.getLatestItemRevision() + .getRelatedComponents("ps_children"); + int mepCount = 0; + for (int j = 0; j < mepComponents.length; j++) { + if (mepComponents[j].getType().indexOf("ZF6_BZGX") >= 0) { + mepCount++; + } + } + TCComponentItem newItem = saveAsItem(childrenItem,"ZF6_GX"); + // 工序的BOM + TCComponent[] childrenComponents = childrenItem + .getLatestItemRevision().getRelatedComponents( + "ps_children"); + if (childrenComponents.length > 0) { + ArrayList childrenItemlists = new ArrayList(); + for (int k = 0; k < childrenComponents.length; k++) { + String mould = childrenComponents[k] + .getStringProperty("object_type"); + if (childrenComponents[k].getStringProperty( + "object_type").indexOf("mould") < 0) { + if (childrenComponents[k] instanceof TCComponentItemRevision) { + TCComponentBOMLine bomLine = (TCComponentBOMLine) childrenComponents[k]; + TCComponentItem newChildItem = saveAsItem(bomLine.getItem(),"ZF6_GB"); + childrenItemlists.add(newChildItem); + } + } + } + + if (newItem != null && childrenItemlists != null + && childrenItemlists.size() > 0) { + recreateBom(newItem, childrenItemlists, true,classID); + } + } + itemlists.add(newItem); + } + } + if (item != null && itemlists != null && itemlists.size() > 0) { + + recreateBom(item, itemlists, false,classID); + + MessageBox.post("根据模板创建工序成功!", "成功", MessageBox.WARNING); + } + } + + /** + * 另存为 + * + * @param item + */ + public TCComponentItem saveAsItem(TCComponentItem item,String type) { + TCComponentItem newItem = null; + try { + String itemID = ""; +// if (item.getType().equals("ZF6_BZGX")) { +// itemID = TMomMethodUtil.getRuleItemID(session, +// processItem.getStringProperty("item_id"), null, +// TMomFinalUtil.GX_CODE); +// } else { +// itemID = item.getTypeComponent().getNewID(); +// } +// newItem = item.getLatestItemRevision().saveAsItem( +// itemID, +// item.getLatestItemRevision().getStringProperty( +// "item_revision_id")); + TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent(type); + itemID = itemType.getNewID(); + newItem = TMomMethodUtil.createNewItemSoa(session, itemID, + item.getLatestItemRevision().getStringProperty("item_revision_id"), + "ZF6_GX", + item.getStringProperty("object_name"), + "", "", null, null, null); + TCComponentItemRevision newRevision = newItem.getLatestItemRevision(); + TCComponentItemRevision oldRevision = item.getLatestItemRevision(); + //更新string属性 + newRevision.setStringProperty("zf6_yxxs", oldRevision.getStringProperty("zf6_yxxs")); + newRevision.setStringProperty("zf6_bzde", oldRevision.getStringProperty("zf6_bzde")); + newRevision.setStringProperty("zf6_scphdm", oldRevision.getStringProperty("zf6_scphdm")); + newRevision.setStringProperty("zf6_ywfy", oldRevision.getStringProperty("zf6_ywfy")); + //更新boolean属性 + newRevision.setLogicalProperty("zf6_sfbzgx", oldRevision.getLogicalProperty("zf6_sfbzgx")); + newRevision.setLogicalProperty("zf6_sffj", oldRevision.getLogicalProperty("zf6_sffj")); + newRevision.setLogicalProperty("zf6_sfcg", oldRevision.getLogicalProperty("zf6_sfcg")); + newRevision.setLogicalProperty("zf6_sfyzgx", oldRevision.getLogicalProperty("zf6_sfyzgx")); + TCComponent[] datas = item + .getReferenceListProperty("IMAN_reference"); + if (datas.length > 0) { + newItem.remove("IMAN_reference", datas); + } + for (int j = 0; j < datas.length; j++) { + if (datas[j] instanceof TCComponentItem) { + TCComponentItem dataItem = (TCComponentItem) datas[j]; + // TCComponentItemType dataType=(TCComponentItemType) + // session.getTypeComponent(dataItem.getStringProperty("object_type")); + TCComponentItem newDataItem = dataItem + .getLatestItemRevision().saveAsItem( + dataItem.getTypeComponent().getNewID(), + dataItem.getLatestItemRevision() + .getStringProperty( + "item_revision_id")); + newItem.add("IMAN_reference", newDataItem); + } + } + } catch (TCException e) { + MessageBox.post(e.toString(), "错误", MessageBox.ERROR); + e.printStackTrace(); + } + return newItem; + } + + /** + * 重新创建BOM + * + * @param item + * @param itemlists + * @throws TCException + */ + public void recreateBom(TCComponentItem item, + ArrayList itemlists, boolean isDelete,String classID) + throws TCException { + TCComponentBOMWindow bomWindow = null; + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(item, + item.getLatestItemRevision(), null, null); + bomWindow.lock(); + topline.lock(); + if (isDelete) { + if (topline.hasChildren()) { + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + ((TCComponentBOMLine) children.getComponent()).cut(); + } + } + } + for (TCComponentItem n_item : itemlists) { + + TCComponentItemRevision revision = n_item.getLatestItemRevision(); + topline.add(n_item, revision, null, false, ""); + //+++++ + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + //寻找新添加的bomline + String[] itemflagString= n_item.toString().split("-"); + String[] bomflagString= children.toString().split("/"); + + if(itemflagString[0].equals(bomflagString[0])) { + //获取分类ID后前面“BZGX”字段不需要 + ((TCComponentBOMLine) children.getComponent()).setStringProperty("RB3_GXH", + classID.substring(classID.indexOf("X")+1,classID.length())); + } + } + //++++++ + } + bomWindow.unlock(); + bomWindow.save(); + //+++将工序保存到permissions数据库中 + //SavePermissions permissions = new SavePermissions(session, topline.getItem()); + + //permissions.insertData(); + //+++ + } + +} diff --git a/src/com/connor/zf/plm002/CopyProcessRouteDialog.java b/src/com/connor/zf/plm002/CopyProcessRouteDialog.java new file mode 100644 index 0000000..1167714 --- /dev/null +++ b/src/com/connor/zf/plm002/CopyProcessRouteDialog.java @@ -0,0 +1,971 @@ + package com.connor.zf.plm002; + +import java.awt.AWTException; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.GridLayout; +import java.awt.Robot; +import java.awt.Window; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.StringTokenizer; +import java.util.Vector; +import java.util.Map.Entry; + +import javax.swing.BorderFactory; +import javax.swing.JButton; + +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.ListSelectionModel; +import javax.swing.RowSorter; +import javax.swing.border.TitledBorder; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; +import javax.swing.tree.TreePath; + +import org.jdesktop.swingx.decorator.HighlighterFactory; +import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; + +import com.connor.zf.plm.bean.NodeBean; + +import com.connor.zf.utils.TCUtil; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.commands.newitem.NamingRule; +import com.teamcenter.rac.commands.newitem.NamingRulesHelper; +import com.teamcenter.rac.commands.revise.RevisionNamingRuleHelper; +import com.teamcenter.rac.kernel.SoaUtil; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOPWindow; +import com.teamcenter.rac.kernel.TCComponentBOPWindowType; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentNameRule; +import com.teamcenter.rac.kernel.TCComponentNameRuleType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCExceptionPartial; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.services.rac.core.DataManagementService; +import com.teamcenter.services.rac.core._2006_03.DataManagement; +import com.teamcenter.services.rac.core._2008_06.DataManagement.SaveAsNewItemInfo; +import com.teamcenter.services.rac.core._2008_06.DataManagement.SaveAsNewItemOutput2; +import com.teamcenter.services.rac.core._2008_06.DataManagement.SaveAsNewItemResponse2; + +public class CopyProcessRouteDialog extends AbstractAIFDialog implements ActionListener,MouseListener{ + + private TCSession session; + private TCComponentItemRevision tarRevision; + private String tarType; + + private JLabel partIDLabel; + private JTextField partIDField; + private JLabel partNameLabel; + private JTextField partNameField; + private JLabel routeIDLabel; + private JTextField routeIDField; + private JLabel routeNameLabel; + private JTextField routeNameField; + private JButton selectButton; + + private JTextField idField = new JTextField();//用来存放id + private JTextField revField = new JTextField();//用来存放版本 + + String[] oneColumnNames = {"品名编号","品名","版本","工艺路线编码","工艺路线名称"}; + String[] twoColumnNames = {"","选择","工序号","工序名称"}; + private JTable impTable; + private DefaultTableModel impModel; +// private JTable processTable; +// private DefaultTableModel processModel; + private JTreeTable processTable; + private JTreeTableModel processModel; + + private JButton okButton; + private JButton celButton; + + private Vector> dataVector = new Vector>();// 零件信息的数据 + private Object[][] values; + private DefaultMutableTreeTableNode rootNode; + //存放工艺路线的node结构 + private HashMap nodeMap = new HashMap(); + + + public CopyProcessRouteDialog(TCSession session,InterfaceAIFComponent targetComponent,String tarType) { + super(false); + this.session = session; + //this.tarRevision = (TCComponentItemRevision) targetComponent; + this.tarType = tarType; + init(); + } + + + + private void init() { + this.setTitle("工艺路线复制"); + this.setPreferredSize(new Dimension(666,666)); + + partIDLabel = new JLabel("品名编码:"); + partIDLabel.setPreferredSize(new Dimension(100,25)); + partIDField = new JTextField(); + partIDField.setPreferredSize(new Dimension(180,25)); + + partNameLabel = new JLabel("品名:"); + partNameLabel.setPreferredSize(new Dimension(100,25)); + partNameField = new JTextField(); + partNameField.setPreferredSize(new Dimension(180,25)); + + routeIDLabel = new JLabel("工艺路线编号:"); + routeIDLabel.setPreferredSize(new Dimension(100,25)); + routeIDField = new JTextField(); + routeIDField.setPreferredSize(new Dimension(180,25)); + + routeNameLabel = new JLabel("工艺路线名称:"); + routeNameLabel.setPreferredSize(new Dimension(100,25)); + routeNameField = new JTextField(); + routeNameField.setPreferredSize(new Dimension(180,25)); + + selectButton = new JButton("查询"); + selectButton.addActionListener(this); + + JPanel selectPanel = new JPanel(new PropertyLayout()); + selectPanel.add("1.1.center",partIDLabel); + selectPanel.add("1.2.center",partIDField); + selectPanel.add("1.3.center",partNameLabel); + selectPanel.add("1.4.center",partNameField); + selectPanel.add("2.1.center",routeIDLabel); + selectPanel.add("2.2.center",routeIDField); + selectPanel.add("2.3.center",routeNameLabel); + selectPanel.add("2.4.center",routeNameField); + selectPanel.add("2.5.center",selectButton); + + impModel = new DefaultTableModel() { + @Override + public boolean isCellEditable(int row, int col) { + return false; + } + }; + impModel.setDataVector(null, oneColumnNames); + impTable = new JTable(impModel); + impTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + if(e.getClickCount() == 2) { + //获得选中行 + int rowIndex = impTable.getSelectedRow(); + System.out.println("当前选中的行为:" + rowIndex); + String processID = impTable.getValueAt(rowIndex, 3).toString(); + processModel = (JTreeTableModel) processTable.getTreeTableModel(); + //rootNode = nodeMap.get(processID); + processModel.setRoot(nodeMap.get(processID)); + processTable.repaint(); + processTable.expandAll(); + } + } + }); + JScrollPane itemPanel = new JScrollPane(impTable); + itemPanel.setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), "零件信息:")); + + this.processTable = getJTreeTable(null, null, twoColumnNames); + this.processTable.addMouseListener(this); + + JScrollPane processPanel = new JScrollPane(processTable); + processPanel.setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), "工艺信息:")); + JPanel tablePanel = new JPanel(new GridLayout(0,1,2,5)); + tablePanel.add(itemPanel); + tablePanel.add(processPanel); + + okButton = new JButton("确认"); + celButton = new JButton("取消"); + okButton.addActionListener(this); + celButton.addActionListener(this); + JPanel buttonPanel = new JPanel(); + buttonPanel.add(okButton); + buttonPanel.add(celButton); + + this.setLayout(new BorderLayout()); + this.add(BorderLayout.NORTH,selectPanel); + this.add(BorderLayout.CENTER,tablePanel); + this.add(BorderLayout.SOUTH,buttonPanel); + showDialog(); + } + + @Override + public void actionPerformed(ActionEvent e) { + if(e.getSource() == this.celButton) { + this.disposeDialog(); + }else if(e.getSource() == this.selectButton) { + //select(); + selects(); + }else if(e.getSource() == this.okButton) { + try { + copy(); + } catch (TCException e1) { + e1.printStackTrace(); + } + } + } + + private void selects() { + String partID = partIDField.getText(); + String partName = partNameField.getText(); + String routeID = routeIDField.getText(); + String routeName = routeNameField.getText(); + if(partID.isEmpty() && partName.isEmpty() && routeID.isEmpty() && routeName.isEmpty()) { + MessageBox.post("请填写查询条件!","提示",2); + return; + } + dataVector.clear(); + nodeMap.clear(); + Vector keyV = new Vector<>(); + Vector valueV = new Vector<>(); + if(!partID.isEmpty()) { + keyV.add("品名编码"); + valueV.add(partID); + } + if(!partName.isEmpty()) { + keyV.add("品名"); + valueV.add(partName); + } + if(!routeID.isEmpty()) { + keyV.add("工艺路线ID"); + valueV.add(routeID); + } + if(!routeName.isEmpty()) { + keyV.add("工艺路线名称"); + valueV.add(routeName); + } + String preName = ""; + switch (tarType) { + case "ZF6_LBJRevision": + preName = "工艺路线查询"; + break; + case "ZF6_YZRevision": + preName = "工艺路线查询"; + break; + case "ZF6_YCLRevision": + preName = "工艺路线查询"; + break; + default: + break; + } + try { + TCComponent[] result = TCUtil.query(session, preName, keyV, valueV); + System.out.println("查询到的对象长度为:" + result.length); + result = TCUtil.TCsort(result, new int[] { 1, -1 }, "item_id", "item_revision_id"); + TCComponentBOPWindowType bomWinType = (TCComponentBOPWindowType) session.getTypeComponent("BOPWindow"); + TCComponentBOPWindow window = (TCComponentBOPWindow) bomWinType.createBOPWindow(null); + if(result.length > 0) { + for (TCComponent tcComponent : result) { + AIFComponentContext[] whereReferenced = tcComponent.whereReferenced(); + System.out.println("对象的引用长度为:" + whereReferenced.length); + for (int i = 0; i < whereReferenced.length; i++) { + String refType = whereReferenced[i].getComponent().getType(); + System.out.println("选中对象的类型为:" + tarType + "----引用对象的类型为:" + refType); + if(refType.equals(tarType)) { + TCComponentItemRevision rev = (TCComponentItemRevision) whereReferenced[i].getComponent(); + TCComponentItemRevision meprocess = (TCComponentItemRevision) tcComponent; + TCComponentItem pitem = meprocess.getItem(); + String id = rev.getStringProperty("item_id"); + Vector vector = new Vector(); + vector.add(id); + vector.add(rev.getStringProperty("object_name")); + vector.add(rev.getStringProperty("item_revision_id")); + vector.add(tcComponent.getStringProperty("item_id")); + vector.add(tcComponent.getStringProperty("object_name")); + this.dataVector.add(vector); + TCComponentBOMLine ebom = window.setWindowTopLine(pitem, meprocess, null, null); + NodeBean rootBean = new NodeBean("","订层","",null); + DefaultMutableTreeTableNode root = new DefaultMutableTreeTableNode(rootBean); + buildStructure(ebom,root); + break; + } + } + } + } + this.values = new Object[this.dataVector.size()][]; + for (int i = 0; i < this.dataVector.size(); i++) { + Vector rowVector = this.dataVector.get(i); + for (int j = 0; j < rowVector.size(); j++) { + Object[] rowData = new Object[rowVector.size()]; + + rowData[j] = rowVector.get(j); + this.values[i] = rowData; + } + } + this.addData(impTable,oneColumnNames); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * 搭建工艺路线下面的结构,工艺路线-工序-子工序 + * @param ebom + * @throws TCException + */ + private void buildStructure(TCComponentBOMLine ebom, DefaultMutableTreeTableNode root) throws TCException { + NodeBean bean = new NodeBean(ebom.getStringProperty("bl_item_item_id"), + ebom.getStringProperty("bl_item_object_name"), "1", ebom); + DefaultMutableTreeTableNode node = new DefaultMutableTreeTableNode(bean); + root.add(node); + AIFComponentContext[] children = ebom.getChildren(); + for (int i = 0; i < children.length; i++) { + TCComponentBOMLine procedure = (TCComponentBOMLine) children[i].getComponent(); + NodeBean bean1 = new NodeBean(procedure.getStringProperty("bl_item_item_id"), + procedure.getStringProperty("bl_item_object_name"), "1", procedure); + DefaultMutableTreeTableNode node1 = new DefaultMutableTreeTableNode(bean1); + node.add(node1); + AIFComponentContext[] children2 = procedure.getChildren(); + for (int j = 0; j < children2.length; j++) { + TCComponentBOMLine procedure2 = (TCComponentBOMLine) children2[j].getComponent(); + NodeBean bean2 = new NodeBean(procedure2.getStringProperty("bl_item_item_id"), + procedure2.getStringProperty("bl_item_object_name"), "1", procedure2); + DefaultMutableTreeTableNode node2 = new DefaultMutableTreeTableNode(bean2); + node1.add(node2); + } + } + nodeMap.put(ebom.getStringProperty("bl_item_item_id"), root); + } + + + + /** + * 执行查询操作 + * @throws Exception + */ + private void select(){ + String partID = partIDField.getText(); + String partName = partNameField.getText(); + String routeID = routeIDField.getText(); + String routeName = routeNameField.getText(); + if(partID.isEmpty() && partName.isEmpty() && routeID.isEmpty() && routeName.isEmpty()) { + MessageBox.post("请填写查询条件!","提示",2); + return; + } + dataVector.clear(); + Vector keyV = new Vector<>(); + Vector valueV = new Vector<>(); + try { + //用来判断查询的结果是否重复 + HashSet idSet = new HashSet(); + //零件ID或零件名称不为空,查零件 + if(!partID.isEmpty() || !partName.isEmpty()) { + if(!partID.isEmpty()) { + keyV.add("零组件 ID"); + valueV.add(partID); + } + if(!partName.isEmpty()) { + keyV.add("名称"); + valueV.add(partName); + } + keyV.add("类型"); + valueV.add("ZF6_LBJRevision;ZF6_YZRevision;ZF6_YCLRevision"); + TCComponent[] result = TCUtil.query(session, "零组件版本...", keyV, valueV); + if(result.length > 0) { + for (TCComponent tcComponent : result) { + idSet.add(tcComponent.getStringProperty("item_id")); + TCComponent[] relatedComponents = tcComponent.getRelatedComponents("ZF6_R_GYLX"); + for (int i = 0; i < relatedComponents.length; i++) { + TCComponent route = relatedComponents[i]; + //符合工艺的查询条件 + String id = route.getStringProperty("item_id"); + String name = route.getStringProperty("object_name"); + if(!routeID.isEmpty() && routeName.isEmpty()) { + if((routeID.contains("*") && id.contains(routeID.replace("*", ""))) + || (!routeID.contains("*") && id.equals(routeID))) { + Vector vector = new Vector(); + vector.add(tcComponent.getStringProperty("item_id")); + vector.add(tcComponent.getStringProperty("object_name")); + vector.add(id); + vector.add(name); + this.dataVector.add(vector); + } + }else if(!routeName.isEmpty() && routeID.isEmpty()){ + if((routeName.contains("*") && name.contains(routeName.replace("*", ""))) + || (!routeName.contains("*") && name.equals(routeName))) { + Vector vector = new Vector(); + vector.add(tcComponent.getStringProperty("item_id")); + vector.add(tcComponent.getStringProperty("object_name")); + vector.add(id); + vector.add(name); + this.dataVector.add(vector); + } + }else if(!routeID.isEmpty() && !routeName.isEmpty()){ + if((routeID.contains("*") && id.contains(routeID.replace("*", ""))) + || (!routeID.contains("*") && id.equals(routeID))) { + if((routeName.contains("*") && name.contains(routeName.replace("*", ""))) + || (!routeName.contains("*") && name.equals(routeName))) { + Vector vector = new Vector(); + vector.add(tcComponent.getStringProperty("item_id")); + vector.add(tcComponent.getStringProperty("object_name")); + vector.add(id); + vector.add(name); + this.dataVector.add(vector); + } + } + }else { + Vector vector = new Vector(); + vector.add(tcComponent.getStringProperty("item_id")); + vector.add(tcComponent.getStringProperty("object_name")); + vector.add(id); + vector.add(name); + this.dataVector.add(vector); + } + } + } + } + } + //工艺ID或工艺名称不为空,查工艺 + if(!routeID.isEmpty() || !routeName.isEmpty()) { + if(!routeID.isEmpty()) { + keyV.add("零组件 ID"); + valueV.add(routeID); + } + if(!routeName.isEmpty()) { + keyV.add("名称"); + valueV.add(routeName); + } + keyV.add("类型"); + valueV.add("ZF6_GYLXRevision"); + TCComponent[] result = TCUtil.query(session, "零组件版本...", keyV, valueV); + if(result.length > 0) { + for (TCComponent tcComponent : result) { + AIFComponentContext[] whereReferenced = tcComponent.whereReferenced(); + for (int i = 0; i < whereReferenced.length; i++) { + String refType = whereReferenced[i].getComponent().getType(); + if(refType.equals("ZF6_LBJRevision") || refType.equals("ZF6_YZRevision") + || refType.equals("ZF6_YCLRevision")) { + TCComponentItemRevision rev = (TCComponentItemRevision) whereReferenced[i].getComponent(); + String id = rev.getStringProperty("item_id"); + if(!idSet.contains(id)) { + Vector vector = new Vector(); + vector.add(id); + vector.add(rev.getStringProperty("object_name")); + vector.add(tcComponent.getStringProperty("item_id")); + vector.add(tcComponent.getStringProperty("object_name")); + this.dataVector.add(vector); + } + } + } + } + } + } + this.values = new Object[this.dataVector.size()][]; + for (int i = 0; i < this.dataVector.size(); i++) { + Vector rowVector = this.dataVector.get(i); + for (int j = 0; j < rowVector.size(); j++) { + Object[] rowData = new Object[rowVector.size()]; + + rowData[j] = rowVector.get(j); + this.values[i] = rowData; + } + } + this.addData(impTable,oneColumnNames); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * 执行复制工艺路线操作 + * @throws TCException + */ + private void copy() throws TCException { + InterfaceAIFComponent targetComponent = AIFUtility.getCurrentApplication().getTargetComponent(); + System.out.println("当前选中的对象为:" + targetComponent); + if("ZF6_LBJRevision".equals(targetComponent.getType()) || "ZF6_YZRevision".equals(targetComponent.getType()) + || "ZF6_YCLRevision".equals(targetComponent.getType())) { + }else { + MessageBox.post("请选中正确的版本对象复制!!!", "错误", MessageBox.ERROR); + return ; + } + tarRevision = (TCComponentItemRevision) targetComponent; + DefaultMutableTreeTableNode top = (DefaultMutableTreeTableNode) processTable.getTreeTableModel().getRoot(); + rootNode = (DefaultMutableTreeTableNode)top.getChildAt(0); + NodeBean rootBean = (NodeBean) rootNode.getUserObject(); + TCComponentItemType itemType; + //得到符合该ID的命名规则 + TCComponentNameRuleType nameRuleType = (TCComponentNameRuleType) session.getTypeComponent("NameRule"); + TCComponentNameRule nameRule = nameRuleType.find("ZF6_GYLXMMGZ"); + String[] patterns = nameRule.getPatterns(); + String tar_item_id = rootBean.getTarger().getItem().getStringProperty("item_id"); + String[] split = tar_item_id.split("-"); + for (String pattern : patterns) { + if(pattern.contains(split[0])) { + updateLastUsedPref(pattern); + getAssignedIds(); + break; + } + } + + itemType = (TCComponentItemType) session.getTypeService().getTypeComponent(rootBean.getTarger().getItem().getType()); + System.out.println("新建对象的ID为:" + idField.getText() + "======版本为" + revField.getText()); + TCComponentItem newItem = rootBean.getTarger().getItemRevision().saveAsItem(idField.getText(), revField.getText()); + TCComponentItemRevision newRev = newItem.getLatestItemRevision(); + TCComponentBOPWindowType bomWinType = (TCComponentBOPWindowType) session.getTypeComponent("BOPWindow"); + TCComponentBOPWindow window = (TCComponentBOPWindow) bomWinType.createBOPWindow(null); + //新的工艺路线对象 + TCComponentBOMLine routebom = window.setWindowTopLine(newItem, newRev, null, null); + //删除原来的结构 + if (routebom.hasChildren()) { + AIFComponentContext[] childrens = routebom.getChildren(); + for (AIFComponentContext children : childrens) { + ((TCComponentBOMLine) children.getComponent()).cut(); + } + } + //存放工序新ID,和旧工序下面的子工序 + HashMap> ssMap = new HashMap>(); + //第一层工序对象 + for (int i = 0; i < rootNode.getChildCount(); i++) { + DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) rootNode.getChildAt(i); + NodeBean childBean = (NodeBean) childNode.getUserObject(); + if(childBean.getLabel().equals("1") && !childBean.getId().isEmpty()){ + itemType = (TCComponentItemType) session.getTypeService().getTypeComponent(childBean.getTarger().getItem().getType()); + TCComponentItem newChildItem = childBean.getTarger().getItemRevision().saveAsItem(itemType.getNewID(), ""); + TCComponentItemRevision newChildRev = newChildItem.getLatestItemRevision(); + routebom.add(newChildItem, newChildRev, null, false, ""); + //判断是否有子工序 + if(childNode.getChildCount() > 0) { + ArrayList list = new ArrayList(); + for (int k = 0; k < childNode.getChildCount(); k++) { + DefaultMutableTreeTableNode ssNode = (DefaultMutableTreeTableNode) childNode.getChildAt(k); + NodeBean ssBean = (NodeBean) ssNode.getUserObject(); + if(ssBean.getLabel().equals("1")) { + list.add(ssBean.getTarger().getItemRevision()); + } + } + ssMap.put(newChildItem.getStringProperty("item_id"),list); + } + } + } + routebom.save(); + routebom.unlock(); + routebom.refresh(); + if(routebom.getBOMView() != null) + { + routebom.getBOMView().save(); + routebom.getBOMView().refresh(); + } + //删除新工序的子结构 + if (routebom.hasChildren()) { + AIFComponentContext[] childrens = routebom.getChildren(); + for (AIFComponentContext children : childrens) { + TCComponentBOMLine childLine = (TCComponentBOMLine) children.getComponent(); + if(childLine.hasChildren()) { + for (AIFComponentContext aifComponentContext : childLine.getChildren()) { + ((TCComponentBOMLine) aifComponentContext.getComponent()).cut(); + } + } + + } + } + routebom.save(); + routebom.unlock(); + routebom.refresh(); + if(routebom.getBOMView() != null) + { + routebom.getBOMView().save(); + routebom.getBOMView().refresh(); + } + //第二次子工序对象 + AIFComponentContext[] children = routebom.getChildren(); + for (AIFComponentContext aifComponentContext : children) { + TCComponentBOMLine bomline = (TCComponentBOMLine) aifComponentContext.getComponent(); + String cid = bomline.getItem().getStringProperty("item_id"); + if(ssMap.containsKey(cid)) { + ArrayList list = ssMap.get(cid); + if(list != null && list.size() > 0) { + itemType = (TCComponentItemType) session.getTypeService().getTypeComponent(list.get(0).getItem().getType()); + for (TCComponentItemRevision rev : list) { + if(rev.getType().equals("ZF6_SCXRevision")) { + bomline.add(rev.getItem(),rev, null, false, ""); + }else { + TCComponentItem newSsItem = rev.saveAsItem(itemType.getNewID(), ""); + bomline.add(newSsItem, newSsItem.getLatestItemRevision(), null, false, ""); + } + + } + } + } + } + routebom.save(); + routebom.unlock(); + routebom.refresh(); + if(routebom.getBOMView() != null) + { + routebom.getBOMView().save(); + routebom.getBOMView().refresh(); + } + window.save(); + window.unlock(); + window.refresh(); + //把新的工艺路线放到所选对象下 + tarRevision.add("ZF6_R_GYLX", newRev); + MessageBox.post("复制成功!!!", "提示", 2); + //置空 + idField.setText(""); + revField.setText(""); + } + + public void addData(JTable table,String[] columnNames) { + DefaultTableModel tableModel = (DefaultTableModel) table + .getModel(); + tableModel.setRowCount(0); + RowSorter sorter = new TableRowSorter(tableModel); + table.setRowSorter(sorter); + for (int i = 0; i < dataVector.size(); i++) { + tableModel.addRow(this.dataVector.get(i)); + } + // 表格数据不可修改 + table.setEnabled(true); + // 更新表格 + table.invalidate(); + } + + public JTreeTable getJTreeTable(JTreeTable partsTable, DefaultTableModel dtm, Object[] titleNames) { + if (partsTable == null) { + processModel = new JTreeTableModel(rootNode); + List isNotEditableRow = new ArrayList(); + processModel.setIsNotEditableRow(isNotEditableRow); + partsTable = new JTreeTable(processModel); + partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + // partsTable.setRowHeight(1, 50); + // partsTable.setRowHeight(2, 100); + partsTable.setRowHeight(30); + partsTable.expandAll(); // 展开全部节点 + + partsTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);// 以下设置表格列宽 +// partsTable.getColumnModel().getColumn(0).setPreferredWidth(50); // 设置第一列宽度 +// partsTable.getColumnModel().getColumn(1).setPreferredWidth(50); // 设置第一列宽度 +// partsTable.getColumnModel().getColumn(2).setPreferredWidth(283); // 设置第一列宽度 +// partsTable.getColumnModel().getColumn(3).setPreferredWidth(283); // 设置第一列宽度 + partsTable.setHighlighters(HighlighterFactory.createSimpleStriping()); + } + return partsTable; + } + + @Override + public void mouseClicked(MouseEvent e) { + if(e.getClickCount() > 0) + { + // 获得选中列 + int selectColumn = processTable.getTableHeader().columnAtPoint(e.getPoint()); + if (selectColumn != 1) { + return; + } + TreePath treePath = processTable.getPathForLocation(e.getX(), e.getY()); + if (treePath != null) { + DefaultMutableTreeTableNode node = (DefaultMutableTreeTableNode) treePath.getLastPathComponent(); + NodeBean nodeBean = (NodeBean) node.getUserObject(); + + DefaultMutableTreeTableNode parentNode = (DefaultMutableTreeTableNode) node.getParent(); + if(parentNode != null) + { + NodeBean parentNodeBean = (NodeBean) parentNode.getUserObject(); + if(parentNodeBean.getLabel().equals("0") && nodeBean.getLabel().equals("0")) + { + MessageBox.post("上层未勾选对象,下层不允许勾选!", "错误", MessageBox.ERROR); + return; + } + try { + if(nodeBean.getLabel().equals("0")) + { + nodeBean.setLabel("1"); + } + else if(nodeBean.getLabel().equals("1")) + { + nodeBean.setLabel("0"); + //isHaveBom(node, nodeBean.getEbomId(), "0", itemType); + } + Robot robot = new Robot(); + robot.keyPress(KeyEvent.VK_TAB); + robot.keyRelease(KeyEvent.VK_TAB); + } catch (AWTException e1) { + e1.printStackTrace(); + } + + } + } + } + + } + + @Override + public void mousePressed(MouseEvent paramMouseEvent) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseReleased(MouseEvent paramMouseEvent) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseEntered(MouseEvent paramMouseEvent) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseExited(MouseEvent paramMouseEvent) { + // TODO Auto-generated method stub + + } + + /** + * 通过SOA另存为ITEM对象 + * + * @param session + * 会话 + * @param itemID + * 创建对象的ID + * @param itemRev + * 创建对象的版本 + * @param itemType + * 创建对象的类型 + * @param itemName + * 创建对象的名称 + * @param itemDesc + * 创建对象的描述 + * @param unit + * 创建对象的单位 + * @param itemPropMap + * 创建对象的ITEM属性 + * @param itemRevPropMap + * 创建对象的版本属性 + * @param itemRevMasterPropMap + * 创建对象的版本表单属性 + */ + public static TCComponentItem saveAsNewItemSoa(TCSession session, + String itemID, String itemRev, String itemType, String itemName, + String itemDesc) { + TCComponentItem newComp = null; + try { + DataManagementService datamanagementservice = DataManagementService + .getService(session); + //newComp = saveAsNewItemResponse.inputToNewItem + SaveAsNewItemInfo info[] = new SaveAsNewItemInfo[1]; + + info[0].description = itemDesc; + info[0].newItemId = itemID; + info[0].name = itemName; + info[0].newRevId = itemRev; + SaveAsNewItemResponse2 saveAsNewItemResponse = datamanagementservice.saveAsNewItem2(info); + Map saveAsOutputMap = saveAsNewItemResponse.saveAsOutputMap; + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + System.out.println("创建对象[item_id= " + itemID + " / rev =" + itemRev + + " / name= " + itemName + "]失败"); + } + return newComp; + } + + final String ITEMTYPE = "ZF6_GYLX"; + protected void updateLastUsedPref(String string) { + try { + //String string = (String) this.ruleBox.getSelectedItem(); + String string2 = "";// (String) this.revisionIdCombobox.getSelectedItem(); + boolean bl = false; + boolean bl2 = false; + String[] arrstring = new String[] { "item_id", "item_revision_id" }; + String[] arrstring2 = new String[] { ITEMTYPE, ITEMTYPE }; + NamingRule[] arrnamingRule = NamingRulesHelper.getInstance().getNamingRules(this.session, arrstring2, arrstring); + String string3 = arrnamingRule[0].getCondition(); + String string4 = arrnamingRule[1].getCondition(); + if (string3 == null) { + string3 = ""; + } + if (string4 == null) { + string4 = ""; + } + bl = arrnamingRule[0].patternPresent(string); + bl2 = arrnamingRule[1].patternPresent(string2); + string = bl ? string : ""; + // string2 = bl2 ? (String) this.revisionIdCombobox.getSelectedItem() : ""; + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append(string3); + stringBuilder.append(":"); + stringBuilder.append(ITEMTYPE); + stringBuilder.append(":"); + stringBuilder.append("item_id"); + stringBuilder.append(":"); + stringBuilder.append(string); + String string5 = stringBuilder.toString(); + StringBuilder stringBuilder2 = new StringBuilder(); + stringBuilder2.append(string4); + stringBuilder2.append(":"); + stringBuilder2.append(ITEMTYPE); + stringBuilder2.append(":"); + stringBuilder2.append("item_revision_id"); + stringBuilder2.append(":"); + stringBuilder2.append(string2); + String string6 = stringBuilder2.toString(); + String[] arrstring3 = null; + if (string2.equals("") && !string.equals("")) { + arrstring3 = new String[] { string5 }; + } else if (!string2.equals("") && string.equals("")) { + arrstring3 = new String[] { string6 }; + } else if (!string2.equals("") && !string.equals("")) { + arrstring3 = new String[] { string5, string6 }; + } + if (arrstring3 != null) { + // this.prefService = this.session.getPreferenceService(); + String[] arrstring4 = session.getPreferenceService().getStringArray(1, "TC_LAST_USED_PATTERNS"); + ArrayList arrayList = new ArrayList(); + int n = 0; + int n2 = 0; + int n3 = 0; + int n4 = 0; + while (n4 < arrstring4.length) { + String string7 = arrstring4[n4]; + if (!string7.equals("")) { + StringTokenizer stringTokenizer = new StringTokenizer(string7, ":"); + stringTokenizer.nextToken(); + String string8 = stringTokenizer.nextToken(); + String string9 = stringTokenizer.nextToken(); + if (ITEMTYPE.equals(string8)) { + ++n; + if (string9.equals("item_id") && arrstring3[0] != null) { + arrayList.add(n4, arrstring3[0]); + ++n2; + } + if (string9.equals("item_revision_id")) { + if (arrstring3.length == 1 && arrstring3[0] != null) { + arrayList.add(n4, arrstring3[0]); + ++n3; + } + if (arrstring3.length > 1 && arrstring3[1] != null) { + arrayList.add(n4, arrstring3[1]); + ++n3; + } + } + } else { + arrayList.add(n4, arrstring4[n4]); + } + } + ++n4; + } + n4 = 0; + n4 = arrstring4.length == 1 && arrstring4[0].equals("") ? 0 : arrstring4.length; + int n5 = 0; + int n6 = 0; + int n7 = 0; + while (n7 < arrstring3.length) { + if (n < 1 && n2 < 1 && n3 < 1) { + arrayList.add(n4, arrstring3[n7]); + ++n4; + } + if (n2 > 0 && n3 < 1 && !string2.equals("") && n5 == 0) { + arrayList.add(n4, arrstring3[1]); + ++n5; + } + if (n3 > 0 && n2 < 1 && !string.equals("") && n6 == 0) { + arrayList.add(n4, arrstring3[0]); + ++n6; + } + ++n7; + } + String[] arrstring5 = arrayList.toArray(new String[arrayList.size()]); + session.getPreferenceService().setStringArray(1, "TC_LAST_USED_PATTERNS", arrstring5); + } + } catch (TCException tCException) { + } + } + + public void getAssignedIds() { + TCComponentItemType tCComponentItemType = null; + boolean bl = true; + boolean bl2 = true; + try { + tCComponentItemType = (TCComponentItemType) this.session.getTypeComponent(ITEMTYPE); + DataManagementService dataManagementService = DataManagementService.getService((TCSession) this.session); + RevisionNamingRuleHelper.getInstance().loadRevNamingRuleDetails(this.session, ITEMTYPE, null); + int[] arrn = RevisionNamingRuleHelper.getInstance().getRevisionNamingRuleFormats(); + int n = arrn[0]; + int n2 = arrn[1]; + if (this.idField.getText().length() == 0) { + DataManagement.GenerateItemIdsAndInitialRevisionIdsProperties[] arrgenerateItemIdsAndInitialRevisionIdsProperties = new DataManagement.GenerateItemIdsAndInitialRevisionIdsProperties[] { + new DataManagement.GenerateItemIdsAndInitialRevisionIdsProperties() }; + arrgenerateItemIdsAndInitialRevisionIdsProperties[0].item = null; + arrgenerateItemIdsAndInitialRevisionIdsProperties[0].itemType = ITEMTYPE; + arrgenerateItemIdsAndInitialRevisionIdsProperties[0].count = 1; + DataManagement.GenerateItemIdsAndInitialRevisionIdsResponse generateItemIdsAndInitialRevisionIdsResponse = dataManagementService + .generateItemIdsAndInitialRevisionIds(arrgenerateItemIdsAndInitialRevisionIdsProperties); + if (generateItemIdsAndInitialRevisionIdsResponse.serviceData.sizeOfPartialErrors() > 0) { + this.idField.setText(""); + this.idField.requestFocusInWindow(); + TCExceptionPartial tCExceptionPartial = SoaUtil.checkPartialErrorsNoThrow((com.teamcenter.soa.client.model.ServiceData) generateItemIdsAndInitialRevisionIdsResponse.serviceData); + MessageBox.post(this, (Throwable) tCExceptionPartial); + return; + } + String string = null; + String string2 = null; + Map map = generateItemIdsAndInitialRevisionIdsResponse.outputItemIdsAndInitialRevisionIds; + Iterator iterator = map.entrySet().iterator(); + if (iterator.hasNext()) { + Map.Entry entry = (Entry) iterator.next(); + DataManagement.ItemIdsAndInitialRevisionIds[] arritemIdsAndInitialRevisionIds = (DataManagement.ItemIdsAndInitialRevisionIds[]) entry.getValue(); + DataManagement.ItemIdsAndInitialRevisionIds itemIdsAndInitialRevisionIds = arritemIdsAndInitialRevisionIds[0]; + string = itemIdsAndInitialRevisionIds.newItemId; + if (n != 0) { + /* + * if (n2 == 0) { this.assignRevIdWithRevisionRule(); } + */ + } else { + string2 = itemIdsAndInitialRevisionIds.newRevId; + this.revField.setText(string2); + } + bl = itemIdsAndInitialRevisionIds.isItemModify; + bl2 = itemIdsAndInitialRevisionIds.isRevModify; + } + this.idField.setText(string); + return; + } + boolean bl3 = true; + // bl3 = this.validateId(); + /* + * if (!bl3) { this.idField.setText(""); this.idField.requestFocusInWindow(); + * return; } + */ + if (n != 0) { + if (n2 == 0) { + // this.assignRevIdWithRevisionRule(); + } + } else { + String string = tCComponentItemType.getNewRev(null); + bl2 = tCComponentItemType.isNewRevModifiable(null, string); + this.revField.setText(string); + } + if (!bl2) { + this.revField.setEditable(false); + } + } catch (TCException tCException) { + MessageBox.post((Window) this, (Throwable) tCException); + } + } +} diff --git a/src/com/connor/zf/plm002/CopyProcessRouteHandler.java b/src/com/connor/zf/plm002/CopyProcessRouteHandler.java new file mode 100644 index 0000000..0f91b80 --- /dev/null +++ b/src/com/connor/zf/plm002/CopyProcessRouteHandler.java @@ -0,0 +1,30 @@ +package com.connor.zf.plm002; + +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 CopyProcessRouteHandler extends AbstractHandler{ + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + if("ZF6_LBJRevision".equals(targetComponent.getType()) || "ZF6_YZRevision".equals(targetComponent.getType()) + || "ZF6_YCLRevision".equals(targetComponent.getType())) { + new CopyProcessRouteDialog(session, targetComponent,targetComponent.getType()); + }else { + MessageBox.post("请选中正确的版本对象复制!!!", "错误", MessageBox.ERROR); + return null; + } + return null; + } + +} diff --git a/src/com/connor/zf/plm002/CreateProcessRouteDialog.java b/src/com/connor/zf/plm002/CreateProcessRouteDialog.java new file mode 100644 index 0000000..f127abd --- /dev/null +++ b/src/com/connor/zf/plm002/CreateProcessRouteDialog.java @@ -0,0 +1,489 @@ +package com.connor.zf.plm002; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Window; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.StringTokenizer; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextField; + +import com.connor.zf.utils.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.commands.newitem.NamingRule; +import com.teamcenter.rac.commands.newitem.NamingRulesHelper; +import com.teamcenter.rac.commands.revise.RevisionNamingRuleHelper; +import com.teamcenter.rac.common.Activator; +import com.teamcenter.rac.common.lov.view.components.LOVDisplayer; +import com.teamcenter.rac.kernel.ServiceData; +import com.teamcenter.rac.kernel.SoaUtil; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentNameRule; +import com.teamcenter.rac.kernel.TCComponentNameRuleType; +import com.teamcenter.rac.kernel.TCComponentRule; +import com.teamcenter.rac.kernel.TCComponentRuleType; +import com.teamcenter.rac.kernel.TCComponentType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCExceptionPartial; +import com.teamcenter.rac.kernel.TCPropertyDescriptor; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.services.rac.core.DataManagementService; +import com.teamcenter.services.rac.core._2006_03.DataManagement; + + +public class CreateProcessRouteDialog extends AbstractAIFDialog implements ActionListener{ + private TCSession session; + private TCComponentItemRevision tarRevision; + + private JLabel idLabel; + private JTextField idField; + private JButton assignButton; + private JLabel nameLabel; + private JTextField nameField; + private JPanel centerPanel; + private JButton celButton; + private JButton okButton; + + private JComboBox ruleBox; + private JTextField revField = new JTextField(); + final String type = "ZF6_GYLX"; + final String ITEMTYPE = "ZF6_GYLX"; + + private LinkedHashMap proHashMap = new LinkedHashMap(); + private HashMap itemMap = new HashMap(); + private HashMap revMap = new HashMap(); + private HashMap boolMap = new HashMap(); + private HashMap revMasterMap = new HashMap(); + + public CreateProcessRouteDialog(TCSession session,InterfaceAIFComponent targetComponent) { + super(false); + this.session = session; + this.tarRevision = (TCComponentItemRevision) targetComponent; + getPro(); + init(); + } + + private void init() { + this.setTitle("工艺路线创建"); + idLabel = new JLabel("ID:"); + idLabel.setPreferredSize(new Dimension(120,40)); + idField = new JTextField(); + idField.setPreferredSize(new Dimension(220,40)); + assignButton = new JButton("指派"); + assignButton.setPreferredSize(new Dimension(66,40)); + nameLabel = new JLabel("名称:"); + nameLabel.setPreferredSize(new Dimension(120,40)); + nameField = new JTextField(); + nameField.setPreferredSize(new Dimension(220,40)); + ruleBox = new JComboBox(); + assignRule(); + ruleBox.setPreferredSize(new Dimension(220,40)); + + centerPanel = new JPanel(new PropertyLayout()); + centerPanel.add("1.1.center",idLabel); + centerPanel.add("1.2.center",idField); + centerPanel.add("1.3.center",ruleBox); + centerPanel.add("1.4.center",assignButton); + centerPanel.add("2.1.center",nameLabel); + centerPanel.add("2.2.center",nameField); + int index = 3; + for (Entry entry : proHashMap.entrySet()) { + String[] split = entry.getKey().split("="); + JLabel label = new JLabel(split[0]); + label.setPreferredSize(new Dimension(120,40)); + centerPanel.add(index + ".1.center",label); + if("string".equals(entry.getValue())) { + JTextField field = new JTextField(); + field.setPreferredSize(new Dimension(220,40)); + field.setName(split[1]); + centerPanel.add(index + ".2.center",field); + }else if("boolean".equals(entry.getValue())) { + JComboBox comboBox = new JComboBox(); + comboBox.setPreferredSize(new Dimension(220,40)); + comboBox.setName(split[1]); + comboBox.addItem("是"); + comboBox.addItem("否"); + centerPanel.add(index + ".2.center",comboBox); + }else if("lov".equals(entry.getValue())) { + try { + TCComponentType localTCComponentType = session.getTypeComponent("ZF6_GYLXRevision"); + TCPropertyDescriptor descriptor = localTCComponentType.getPropertyDescriptor(split[1]); + LOVDisplayer combo = new LOVDisplayer(descriptor); + combo.setName(split[1]); + combo.setPreferredSize(new Dimension(240,40)); + centerPanel.add(index + ".2.center",combo); + } catch (TCException e) { + e.printStackTrace(); + } + } + index++; + } + + JScrollPane jsp = new JScrollPane(centerPanel); + + okButton = new JButton("确认"); + celButton = new JButton("取消"); + JPanel buttonPanel = new JPanel(); + buttonPanel.add(okButton); + buttonPanel.add(celButton); + this.setLayout(new BorderLayout()); + this.add(BorderLayout.CENTER,jsp); + this.add(BorderLayout.SOUTH,buttonPanel); + + assignButton.addActionListener(this); + okButton.addActionListener(this); + celButton.addActionListener(this); + showDialog(); + } + + private void assignRule() { + TCComponentNameRuleType nameRuleType; + try { + nameRuleType = (TCComponentNameRuleType) session.getTypeComponent("NameRule"); + TCComponentNameRule nameRule = nameRuleType.find("ZF6_GYLXMMGZ"); + String[] patterns = nameRule.getPatterns(); + for (String string : patterns) { + ruleBox.addItem(string); + } + } catch (TCException e) { + e.printStackTrace(); + } + + } + + /** + * 得到首选项中的属性配置 + */ + private void getPro() { + //显示名=属性真实名=string/boolean/lov + String[] stringValues = session.getPreferenceService().getStringValues("ZF_Process_Create"); + for (String string : stringValues) { + String[] split = string.split("="); + if(split.length == 3) { + proHashMap.put(split[0] + "=" +split[1],split[2]); + } + } + + } + + @Override + public void actionPerformed(ActionEvent e) { + if(e.getSource() == this.assignButton) { + //指派id + updateLastUsedPref(); + getAssignedIds(); +// try { +// TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent(type); +// String newID = itemType.getNewID(); +// idField.setText(newID); +// } catch (TCException e1) { +// e1.printStackTrace(); +// } + }else if(e.getSource() == this.celButton) { + dispose(); + }else if(e.getSource() == this.okButton) { + revMap.clear(); + int componentCount = centerPanel.getComponentCount(); + for (int i = 6; i < componentCount; i++) { + Component component = centerPanel.getComponent(i); + if(component instanceof JTextField) { + JTextField field = (JTextField) component; + String name = field.getName(); + String value = field.getText(); + revMap.put(name, value); + }else if(component instanceof JComboBox) { + JComboBox comBox = (JComboBox) component; + String name = comBox.getName(); + String value = comBox.getSelectedItem().toString(); + if("是".equals(value)) { + boolMap.put(name, true); + }else if("否".equals(value)) { + boolMap.put(name, false); + } + }else if(component instanceof LOVDisplayer) { + LOVDisplayer combox = (LOVDisplayer)component; + revMap.put(combox.getName(), combox.getSelectedValue().toString()); + } + } + if(idField.getText().isEmpty()) { + MessageBox.post("请填写‘ID’", "错误", MessageBox.ERROR); + return; + }else if(nameField.getText().isEmpty()) { + MessageBox.post("请填写‘名称’", "错误", MessageBox.ERROR); + return; + } + TCComponentItem item = TMomMethodUtil.createNewItemSoa(session, idField.getText(), "A", type, + nameField.getText(), "", "", itemMap, revMap, revMasterMap); + if(item != null) { + try { + //更新boolean属性 + for(Entry entry : boolMap.entrySet()) { + item.getLatestItemRevision().setLogicalProperty(entry.getKey(), entry.getValue()); + } + //更新string属性 + for(Entry entry : revMap.entrySet()) { + item.getLatestItemRevision().setProperty(entry.getKey(), entry.getValue()); + } + recreateBom(item); + tarRevision.add("ZF6_R_GYLX", item.getLatestItemRevision()); + //item.getLatestItemRevision().add("IMAN_METarget",tarRevision); + MessageBox.post("创建成功!!!", "成功", MessageBox.INFORMATION); + this.disposeDialog(); + this.dispose(); + } catch (TCException e1) { + e1.printStackTrace(); + } + } + } + + } + + @SuppressWarnings("deprecation") + public void recreateBom(TCComponentItem item) + throws TCException { + TCComponentBOMWindow bomWindow = null; + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(item, + item.getLatestItemRevision(), null, null); + TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent("Item"); + TCComponentItem find = itemType.find(tarRevision.getStringProperty("item_id")); + topline.add(find, find.getLatestItemRevision(), null, false, ""); + AIFComponentContext[] children = topline.getChildren(); + TCComponentBOMLine component = (TCComponentBOMLine) children[0].getComponent(); + component.cut(); + bomWindow.lock(); + topline.lock(); + bomWindow.unlock(); + bomWindow.save(); + } + + public static void throwServiceDataError(ServiceData data) throws Exception { + if (data.sizeOfPartialErrors() > 0) { + StringBuilder errInfo = new StringBuilder(); + for (int i = 0; i < data.sizeOfPartialErrors(); i++) { + for (String msg : data.getPartialError(i).getMessages()) { + errInfo.append(msg + "\n"); + } + } + throw new Exception(errInfo.toString()); + } + } + + protected void updateLastUsedPref() { + try { + String string = (String) this.ruleBox.getSelectedItem(); + String string2 = "";// (String) this.revisionIdCombobox.getSelectedItem(); + boolean bl = false; + boolean bl2 = false; + String[] arrstring = new String[] { "item_id", "item_revision_id" }; + String[] arrstring2 = new String[] { ITEMTYPE, ITEMTYPE }; + NamingRule[] arrnamingRule = NamingRulesHelper.getInstance().getNamingRules(this.session, arrstring2, arrstring); + String string3 = arrnamingRule[0].getCondition(); + String string4 = arrnamingRule[1].getCondition(); + if (string3 == null) { + string3 = ""; + } + if (string4 == null) { + string4 = ""; + } + bl = arrnamingRule[0].patternPresent(string); + bl2 = arrnamingRule[1].patternPresent(string2); + string = bl ? (String) this.ruleBox.getSelectedItem() : ""; + // string2 = bl2 ? (String) this.revisionIdCombobox.getSelectedItem() : ""; + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append(string3); + stringBuilder.append(":"); + stringBuilder.append(ITEMTYPE); + stringBuilder.append(":"); + stringBuilder.append("item_id"); + stringBuilder.append(":"); + stringBuilder.append(string); + String string5 = stringBuilder.toString(); + StringBuilder stringBuilder2 = new StringBuilder(); + stringBuilder2.append(string4); + stringBuilder2.append(":"); + stringBuilder2.append(ITEMTYPE); + stringBuilder2.append(":"); + stringBuilder2.append("item_revision_id"); + stringBuilder2.append(":"); + stringBuilder2.append(string2); + String string6 = stringBuilder2.toString(); + String[] arrstring3 = null; + if (string2.equals("") && !string.equals("")) { + arrstring3 = new String[] { string5 }; + } else if (!string2.equals("") && string.equals("")) { + arrstring3 = new String[] { string6 }; + } else if (!string2.equals("") && !string.equals("")) { + arrstring3 = new String[] { string5, string6 }; + } + if (arrstring3 != null) { + // this.prefService = this.session.getPreferenceService(); + String[] arrstring4 = session.getPreferenceService().getStringArray(1, "TC_LAST_USED_PATTERNS"); + ArrayList arrayList = new ArrayList(); + int n = 0; + int n2 = 0; + int n3 = 0; + int n4 = 0; + while (n4 < arrstring4.length) { + String string7 = arrstring4[n4]; + if (!string7.equals("")) { + StringTokenizer stringTokenizer = new StringTokenizer(string7, ":"); + stringTokenizer.nextToken(); + String string8 = stringTokenizer.nextToken(); + String string9 = stringTokenizer.nextToken(); + if (ITEMTYPE.equals(string8)) { + ++n; + if (string9.equals("item_id") && arrstring3[0] != null) { + arrayList.add(n4, arrstring3[0]); + ++n2; + } + if (string9.equals("item_revision_id")) { + if (arrstring3.length == 1 && arrstring3[0] != null) { + arrayList.add(n4, arrstring3[0]); + ++n3; + } + if (arrstring3.length > 1 && arrstring3[1] != null) { + arrayList.add(n4, arrstring3[1]); + ++n3; + } + } + } else { + arrayList.add(n4, arrstring4[n4]); + } + } + ++n4; + } + n4 = 0; + n4 = arrstring4.length == 1 && arrstring4[0].equals("") ? 0 : arrstring4.length; + int n5 = 0; + int n6 = 0; + int n7 = 0; + while (n7 < arrstring3.length) { + if (n < 1 && n2 < 1 && n3 < 1) { + arrayList.add(n4, arrstring3[n7]); + ++n4; + } + if (n2 > 0 && n3 < 1 && !string2.equals("") && n5 == 0) { + arrayList.add(n4, arrstring3[1]); + ++n5; + } + if (n3 > 0 && n2 < 1 && !string.equals("") && n6 == 0) { + arrayList.add(n4, arrstring3[0]); + ++n6; + } + ++n7; + } + String[] arrstring5 = arrayList.toArray(new String[arrayList.size()]); + session.getPreferenceService().setStringArray(1, "TC_LAST_USED_PATTERNS", arrstring5); + } + } catch (TCException tCException) { + } + } + + public void getAssignedIds() { + TCComponentItemType tCComponentItemType = null; + boolean bl = true; + boolean bl2 = true; + try { + tCComponentItemType = (TCComponentItemType) this.session.getTypeComponent(ITEMTYPE); + DataManagementService dataManagementService = DataManagementService.getService((TCSession) this.session); + RevisionNamingRuleHelper.getInstance().loadRevNamingRuleDetails(this.session, ITEMTYPE, null); + int[] arrn = RevisionNamingRuleHelper.getInstance().getRevisionNamingRuleFormats(); + int n = arrn[0]; + int n2 = arrn[1]; + if (this.idField.getText().length() == 0) { + DataManagement.GenerateItemIdsAndInitialRevisionIdsProperties[] arrgenerateItemIdsAndInitialRevisionIdsProperties = new DataManagement.GenerateItemIdsAndInitialRevisionIdsProperties[] { + new DataManagement.GenerateItemIdsAndInitialRevisionIdsProperties() }; + arrgenerateItemIdsAndInitialRevisionIdsProperties[0].item = null; + arrgenerateItemIdsAndInitialRevisionIdsProperties[0].itemType = ITEMTYPE; + arrgenerateItemIdsAndInitialRevisionIdsProperties[0].count = 1; + DataManagement.GenerateItemIdsAndInitialRevisionIdsResponse generateItemIdsAndInitialRevisionIdsResponse = dataManagementService + .generateItemIdsAndInitialRevisionIds(arrgenerateItemIdsAndInitialRevisionIdsProperties); + if (generateItemIdsAndInitialRevisionIdsResponse.serviceData.sizeOfPartialErrors() > 0) { + this.idField.setText(""); + this.idField.requestFocusInWindow(); + TCExceptionPartial tCExceptionPartial = SoaUtil.checkPartialErrorsNoThrow((com.teamcenter.soa.client.model.ServiceData) generateItemIdsAndInitialRevisionIdsResponse.serviceData); + MessageBox.post(this, (Throwable) tCExceptionPartial); + return; + } + String string = null; + String string2 = null; + Map map = generateItemIdsAndInitialRevisionIdsResponse.outputItemIdsAndInitialRevisionIds; + Iterator iterator = map.entrySet().iterator(); + if (iterator.hasNext()) { + Map.Entry entry = (Entry) iterator.next(); + DataManagement.ItemIdsAndInitialRevisionIds[] arritemIdsAndInitialRevisionIds = (DataManagement.ItemIdsAndInitialRevisionIds[]) entry.getValue(); + DataManagement.ItemIdsAndInitialRevisionIds itemIdsAndInitialRevisionIds = arritemIdsAndInitialRevisionIds[0]; + string = itemIdsAndInitialRevisionIds.newItemId; + if (n != 0) { + /* + * if (n2 == 0) { this.assignRevIdWithRevisionRule(); } + */ + } else { + string2 = itemIdsAndInitialRevisionIds.newRevId; + this.revField.setText(string2); + } + bl = itemIdsAndInitialRevisionIds.isItemModify; + bl2 = itemIdsAndInitialRevisionIds.isRevModify; + } + this.idField.setText(string); + if (!bl) { + this.idField.setEditable(false); + this.ruleBox.setEnabled(false); + } + if (!bl2) { + this.revField.setEditable(false); + // this.revisionIdCombobox.setEnabled(false); + } + this.nameField.requestFocusInWindow(); + return; + } + boolean bl3 = true; + // bl3 = this.validateId(); + /* + * if (!bl3) { this.idField.setText(""); this.idField.requestFocusInWindow(); + * return; } + */ + if (n != 0) { + if (n2 == 0) { + // this.assignRevIdWithRevisionRule(); + } + } else { + String string = tCComponentItemType.getNewRev(null); + bl2 = tCComponentItemType.isNewRevModifiable(null, string); + this.revField.setText(string); + } + if (!bl2) { + this.revField.setEditable(false); + } + this.nameField.requestFocusInWindow(); + } catch (TCException tCException) { + MessageBox.post((Window) this, (Throwable) tCException); + } + } + +} diff --git a/src/com/connor/zf/plm002/CreateProcessRouteHandler.java b/src/com/connor/zf/plm002/CreateProcessRouteHandler.java new file mode 100644 index 0000000..c994011 --- /dev/null +++ b/src/com/connor/zf/plm002/CreateProcessRouteHandler.java @@ -0,0 +1,76 @@ +package com.connor.zf.plm002; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.zf.utils.TMomFinalUtil; +import com.connor.zf.utils.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class CreateProcessRouteHandler extends AbstractHandler{ + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + +// // 获取国际化语言 +// Locale defaultLocale = Locale.getDefault(); +// ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); +// // 创建工艺 +// final AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); +// final TCSession session = (TCSession) app.getSession(); +// InterfaceAIFComponent[] comps = app.getTargetComponents(); +// if (comps.length == 0 || comps == null) { +// MessageBox.post(rb.getString("wxzcpdxqcxxz02_display.TITLE"), "错误", MessageBox.ERROR);// "未选中产品对象,请重新选择!" +// return null; +// } +// List itemList = new ArrayList(); +// try { +// for (int i = 0; i < comps.length; i++) { +// String type = comps[i].getType(); +// if (type.equals("ZF6_LBJRevision") || type.equals("ZF6_YZRevision") || type.equals("ZF6_YCLRevision")) { +// itemList.add(((TCComponentItemRevision) comps[i]).getItem()); +// } else { +// MessageBox.post(rb.getString("qxzzcdxhcj02_display.TITLE"), "错误", MessageBox.ERROR);// "请选择总成对象后创建" +// return null; +// } +// } +// +// } catch (Exception e) { +// MessageBox.post(e.toString(), "错误", MessageBox.ERROR); +// e.printStackTrace(); +// } +// new Thread() { +// @Override +// public void run() { +// // TODO Auto-generated method stub +// new TMom002AbtractDialog(session, app, "工艺", itemList, null, TMomFinalUtil.GY_CODE);// "工艺" +// super.run(); +// } +// }.start(); + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + if("ZF6_LBJRevision".equals(targetComponent.getType()) || "ZF6_YZRevision".equals(targetComponent.getType()) + || "ZF6_YCLRevision".equals(targetComponent.getType())) { + new CreateProcessRouteDialog(session, targetComponent); + }else { + MessageBox.post("请选中正确的版本对象创建!!!", "错误", MessageBox.ERROR); + return null; + } + + return null; + } + +} diff --git a/src/com/connor/zf/plm002/JTreeTable.java b/src/com/connor/zf/plm002/JTreeTable.java new file mode 100644 index 0000000..7f046cb --- /dev/null +++ b/src/com/connor/zf/plm002/JTreeTable.java @@ -0,0 +1,81 @@ +package com.connor.zf.plm002; + +import java.awt.event.MouseEvent; +import java.util.List; + +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; + +import org.jdesktop.swingx.JXTreeTable; + +public class JTreeTable extends JXTreeTable { + + + private List isNotEditableRow; + TableCellCheckboxRenderer checkboxRenderer = new TableCellCheckboxRenderer(this); + + public List getIsNotEditableRow() { + return isNotEditableRow; + } + + public void setIsNotEditableRow(List isNotEditableRow) { + this.isNotEditableRow = isNotEditableRow; + } + + public JTreeTable(JTreeTableModel testTreeTableModel) { + super(testTreeTableModel); + } + + @Override + public boolean isCellEditable(int arg0, int arg1) { + return true;//super.isCellEditable(arg0, arg1); + } + + @Override + public TableCellEditor getCellEditor(int row, int column) { + //if(isNotEditableRow.contains(row) && column == 2) + + + return cellEditor; + //return super.getCellEditor(row, column); + } + + public String getToolTipText(MouseEvent e) { + int row = this.rowAtPoint(e.getPoint()); + int col = this.columnAtPoint(e.getPoint()); + String tiptextString = null; + if (row > -1 && col > -1) { + Object value = this.getValueAt(row, col); + if (null != value && !"".equals(value)) + tiptextString = value.toString();// 悬浮显示单元格内容 + } + return tiptextString; + } + + @Override + public TableCellRenderer getCellRenderer(int row, int column) { + // TODO Auto-generated method stub + if(this.getValueAt(row, 1) != null && (this.getValueAt(row, 1).toString().equals("0") || this.getValueAt(row, 1).toString().equals("1")) && column == 1) + { + return checkboxRenderer; + } + else + { + return super.getCellRenderer(row, column); + } + } + + // 隐藏列 + public void HiddenCell(int column) { + TableColumn tc = this.getTableHeader().getColumnModel() + .getColumn(column); + tc.setMaxWidth(0); + tc.setPreferredWidth(0); + tc.setWidth(0); + tc.setMinWidth(0); + this.getTableHeader().getColumnModel().getColumn(column).setMaxWidth(0); + this.getTableHeader().getColumnModel().getColumn(column).setMinWidth(0); + } + +} diff --git a/src/com/connor/zf/plm002/JTreeTableModel.java b/src/com/connor/zf/plm002/JTreeTableModel.java new file mode 100644 index 0000000..0d1aa53 --- /dev/null +++ b/src/com/connor/zf/plm002/JTreeTableModel.java @@ -0,0 +1,107 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.connor.zf.plm002; + +import java.util.List; + +import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; +import org.jdesktop.swingx.treetable.DefaultTreeTableModel; +import org.jdesktop.swingx.treetable.TreeTableNode; + +import com.connor.zf.plm.bean.NodeBean; + +/** + * + * @author vearn + */ +public class JTreeTableModel extends DefaultTreeTableModel { + + private String[] _names = {"","选择","工序号","工序名称"}; + + + private List isNotEditableRow; + + + + public JTreeTableModel(TreeTableNode node) { + super(node); + } + + + public List getIsNotEditableRow() { + return isNotEditableRow; + } + + public void setIsNotEditableRow(List isNotEditableRow) { + this.isNotEditableRow = isNotEditableRow; + } + + /** + * 列的数量 + */ + @Override + public int getColumnCount() { + return _names.length; + } + + /** + * 表头显示的内容 + */ + @Override + public String getColumnName(int column) { + return _names[column]; + } + + /** + * 返回在单元格中显示的Object + */ + @Override + public Object getValueAt(Object node, int column) { + Object value = null; + if (node instanceof DefaultMutableTreeTableNode) { + DefaultMutableTreeTableNode mutableNode = (DefaultMutableTreeTableNode) node; + Object o = mutableNode.getUserObject(); + if (o != null && o instanceof NodeBean) { + NodeBean bean = (NodeBean) o; + switch (column) { + case 0: + value = ""; + break; + case 1: + value = bean.getLabel(); + break; + case 2: + value = bean.getId(); + break; + case 3: + value = bean.getName(); + break; + } + } + } + return value; + } + + /** + * 设置所有单元格都不能编辑 + * + * @param the node (i.e. row) for which editing is to be determined + * @param the column for which editing is to be determined + * @return false + */ + @Override + public boolean isCellEditable(Object node, int column) { + //if(column == 5) + //{ + return false; + //} + //else + //{ + // return false; + //} + } + + +} diff --git a/src/com/connor/zf/plm002/TableCellCheckboxRenderer.java b/src/com/connor/zf/plm002/TableCellCheckboxRenderer.java new file mode 100644 index 0000000..894641f --- /dev/null +++ b/src/com/connor/zf/plm002/TableCellCheckboxRenderer.java @@ -0,0 +1,50 @@ +package com.connor.zf.plm002; + +import java.awt.Component; +import java.util.List; + +import javax.swing.JCheckBox; +import javax.swing.JTable; +import javax.swing.SwingConstants; +import javax.swing.event.ChangeEvent; +import javax.swing.event.EventListenerList; +import javax.swing.table.TableCellRenderer; + + +public class TableCellCheckboxRenderer extends JCheckBox implements + TableCellRenderer { + private List processRows; + protected EventListenerList listenerList = new EventListenerList(); + protected ChangeEvent changeEvent = new ChangeEvent(this); + //private TestTreeTableModel tableModel; + + public List getProcessRows() { + return processRows; + } + + public void setProcessRows(List processRows) { + this.processRows = processRows; + + } + + public TableCellCheckboxRenderer(final JTreeTable table) { + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + // TODO Auto-generated method stub + this.setHorizontalAlignment(SwingConstants.CENTER);// 表头标签剧中 + this.setBorderPainted(true); + + if(value != null) + { + this.setSelected(value.toString().equals("1")); + } + else + { + this.setSelected(false); + } + return this; + } +} \ No newline at end of file diff --git a/src/com/connor/zf/plm003/CreateToolingDialog.java b/src/com/connor/zf/plm003/CreateToolingDialog.java new file mode 100644 index 0000000..0d6e929 --- /dev/null +++ b/src/com/connor/zf/plm003/CreateToolingDialog.java @@ -0,0 +1,343 @@ +package com.connor.zf.plm003; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.IOException; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextField; +import javax.xml.bind.JAXBException; + +import com.connor.zf.plm.xmlUtil.CNCompontent; +import com.connor.zf.plm.xmlUtil.CNPart; +import com.connor.zf.plm.xmlUtil.CNPartList; +import com.connor.zf.plm.xmlUtil.CNProperty; +import com.connor.zf.plm.xmlUtil.CNXmlUtil; +import com.connor.zf.utils.JFomMethodUtil; +import com.connor.zf.utils.SqlUtilT; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentFaultCode; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + + + +public class CreateToolingDialog extends AbstractAIFDialog implements ActionListener{ + private TCSession session; + private TCComponentItemRevision tarRevision; + + final String GZDH_PRE = "ZF6_GZSJ_GZDH"; //工装代号 + final String JCDH_PRE = "ZF6_GZSJ_JCDH"; //机床代号 + final String GZMJDH_PRE = "ZF6_GZSJ_GZMJDH"; //工装模具种类代号 + final String XML_PUID = "ZF6_GZSJ_ATT"; + final String newType = "ZF6_GZ"; + private LinkedHashMap gzdhMap = new LinkedHashMap(); + private LinkedHashMap jcdhMap = new LinkedHashMap(); + private LinkedHashMap gzmjdhMap = new LinkedHashMap(); + + private JComboBox gzdhBox; + private JComboBox jcdhBox; + private JComboBox gzmjdhBox; + private JPanel centerPanel; + + private JButton okButton; + private JButton celButton; + private CNPart currentCNPart; + + int index = 4; + + private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-dd HH:mm"); + + private HashMap itemProMap = new HashMap(); + + private HashMap mappingMap = new HashMap(); + + public CreateToolingDialog(TCSession session,InterfaceAIFComponent targetComponent){ + super(false); + this.session = session; + this.tarRevision = (TCComponentItemRevision) targetComponent; + getData(); + getMapping(); + init(); + } + + private void init() { + this.setTitle("工装创建"); + this.setPreferredSize(new Dimension(555,666)); + + centerPanel = new JPanel(new PropertyLayout()); + JLabel oneLabel = new JLabel("工装代号:"); + oneLabel.setPreferredSize(new Dimension(150,30)); + gzdhBox = new JComboBox(); + for (Entry entry : gzdhMap.entrySet()) { + gzdhBox.addItem(entry.getKey()); + } + gzdhBox.setPreferredSize(new Dimension(350,30)); + JLabel twoLabel = new JLabel("机床代号:"); + twoLabel.setPreferredSize(new Dimension(150,30)); + jcdhBox = new JComboBox(); + for (Entry entry : jcdhMap.entrySet()) { + jcdhBox.addItem(entry.getKey()); + } + jcdhBox.setPreferredSize(new Dimension(350,30)); + JLabel threeLabel = new JLabel("工装模具种类代号:"); + threeLabel.setPreferredSize(new Dimension(150,30)); + gzmjdhBox = new JComboBox(); + for (Entry entry : gzmjdhMap.entrySet()) { + gzmjdhBox.addItem(entry.getKey()); + } + gzmjdhBox.setPreferredSize(new Dimension(350,30)); + centerPanel.add("1.1.center",oneLabel); + centerPanel.add("1.2.center",gzdhBox); + centerPanel.add("2.1.center",twoLabel); + centerPanel.add("2.2.center",jcdhBox); + centerPanel.add("3.1.center",threeLabel); + centerPanel.add("3.2.center",gzmjdhBox); + for (CNCompontent cnComp : this.currentCNPart.getCompontentList()) { + List propertyList = cnComp.getPropertyList(); + for (CNProperty cnProperty : propertyList) { + JLabel label; + if(cnProperty.getIsMust()) { + label = new JLabel("" +cnProperty.getDisplayName()+ " *:"); + }else { + label = new JLabel(cnProperty.getDisplayName() + ":"); + } + label.setName(cnProperty.getRealName()); + label.setPreferredSize(new Dimension(150,30)); + centerPanel.add(index + ".1.center",label); + if(cnProperty.getIsLov()) { + + }else { + if(cnProperty.getPropertyType().toUpperCase().equals("STRING")) { + JTextField field = new JTextField(cnProperty.getDefaultValue()); + field.setName(cnProperty.getRealName()); + field.setPreferredSize(new Dimension(350,30)); + centerPanel.add(index + ".2.center",field); + } + else if(cnProperty.getPropertyType().toUpperCase().equals("BOOLEAN")) { + JComboBox comboBox = new JComboBox(); + comboBox.addItem(true); + comboBox.addItem(false); + comboBox.setName(cnProperty.getRealName()); + comboBox.setPreferredSize(new Dimension(350,30)); + centerPanel.add(index + ".2.center",comboBox); + } + else if(cnProperty.getPropertyType().toUpperCase().equals("DATE")) { + DateButton dateButton = new DateButton(sdf); + dateButton.setName(cnProperty.getRealName()); + dateButton.setPreferredSize(new Dimension(350,30)); + centerPanel.add(index + ".2.center",dateButton); + } + } + if(cnComp.getType().equals("I")) { + itemProMap.put(cnProperty.getRealName(), ""); + } + index++; + } + } + JScrollPane jsp = new JScrollPane(centerPanel); + + okButton = new JButton("确认"); + celButton = new JButton("取消"); + okButton.addActionListener(this); + celButton.addActionListener(this); + JPanel buttonJPanel = new JPanel(); + buttonJPanel.add(okButton); + buttonJPanel.add(celButton); + + this.setLayout(new BorderLayout()); + this.add(BorderLayout.CENTER,jsp); + this.add(BorderLayout.SOUTH,buttonJPanel); + this.setResizable(false); + showDialog(); + } + + private void getMapping() { + //选中对象的属性映射(ZF6_GZSJ_Mapping: 所选对象类型:属性1=工装设计版本属性1;属性2=工装设计版本属性2) + String[] mappingValues = session.getPreferenceService().getStringValues("ZF6_GZSJ_Mapping"); + for (String string : mappingValues) { + if(string.contains(tarRevision.getType() + ":")) { + String[] split = string.split(":")[1].split(";"); + for (String value : split) { + String[] split2 = value.split("="); + mappingMap.put(split2[0], split2[1]); + } + } + } + } + + private void getData() { + changePreValues(GZDH_PRE,"=",gzdhMap); + changePreValues(JCDH_PRE,"=",jcdhMap); + changePreValues(GZMJDH_PRE,"=",gzmjdhMap); + String puid = JFomMethodUtil.getOptionValue(XML_PUID, session); + TCComponent datasetcomp; + try { + datasetcomp = session.stringToComponent(puid); + String filePath = JFomMethodUtil.downLoadFile(datasetcomp); + Object object = CNXmlUtil.xmlToBean(filePath, CNPartList.class); + CNPartList parts = (CNPartList) object; + List partList = parts.getPartList(); + currentCNPart = partList.get(0); + } catch (TCException | JAXBException | IOException e) { + e.printStackTrace(); + } + } + + private void changePreValues(String preName,String splitSign,Map map) { + String[] stringValues = session.getPreferenceService().getStringValues(preName); + map.put("", ""); + for (String string : stringValues) { + String[] split = string.split(splitSign); + if(split.length == 2) { + map.put(split[0], split[1]); + } + } + } + + @Override + public void actionPerformed(ActionEvent arg0) { + if(arg0.getSource() == this.celButton) { + this.disposeDialog(); + }else if(arg0.getSource() == this.okButton) { + try { + String newID = getNewID(); + TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent(newType); + //id,版本,类型,名称,描述 + TCComponentItem newItem = itemType.create(newID,"",newType ,"", "", null); + TCComponentItemRevision itemRevision = newItem.getLatestItemRevision(); + //设置属性 + for (int i = 6; i < centerPanel.getComponentCount(); i++) { + Component component2 = centerPanel.getComponent(i); + String propName = component2.getName(); + if (component2 instanceof JTextField) { + JTextField field = (JTextField) component2; + // 为null是版本属性(名称都要) + if ("object_name".equals(propName)) { + itemRevision.setProperty(propName, field.getText()); + newItem.setProperty(propName, field.getText()); + } else if (itemProMap.get(propName) == null) { + itemRevision.setProperty(propName, field.getText()); + } else { + newItem.setProperty(propName, field.getText()); + } + } + else if(component2 instanceof JComboBox) { + JComboBox comboBox = (JComboBox) component2; + Boolean selectedItem = (Boolean) comboBox.getSelectedItem(); + //为null是版本属性 + if(itemProMap.get(propName) == null) { + itemRevision.setLogicalProperty(propName, selectedItem); + }else { + newItem.setLogicalProperty(propName, selectedItem); + } + } + } + //属性映射 + if(!mappingMap.isEmpty()) { + for(Entry entry : mappingMap.entrySet()) { + itemRevision.setProperty(entry.getValue(), tarRevision.getStringProperty(entry.getKey())); + } + } + TCComponentFolder folder = null; + String folderName = ""; + AIFComponentContext[] whereReferenced = tarRevision.getItem().whereReferenced(); + if (whereReferenced != null) { + for (AIFComponentContext con : whereReferenced) { + InterfaceAIFComponent component2 = con.getComponent(); + if (component2 instanceof TCComponentFolder) { + TCComponentFolder tempfolder = (TCComponentFolder) component2; + String owning_user = tempfolder.getProperty("owning_user"); + String string = session.getUser().toString(); + if (string.equals(owning_user)) { + folder = tempfolder; + folderName = folder.getStringProperty("object_name"); + System.out.println("找到文件夹" + folderName); + break; + } + } + } + }else { + folder = session.getUser().getHomeFolder(); + folderName = folder.getStringProperty("object_name"); + } + folder.add("contents", newItem); + MessageBox.post("创建成功,对象放入文件夹——" + folderName,"提示",2); + } catch (TCException | SQLException e) { + e.printStackTrace(); + } + } + + } + + /** + * 得到工装对象的新ID + * @throws TCException + * @throws SQLException + */ + private String getNewID() throws TCException, SQLException { + /** + * 3)基于对象派生的工装ZF6_GZRevision的item_id为工装代号-机床代号-派生源对象item_id-工装模具代号-2n, + * 如派生的源对象id为515020-01,则派生出的对象ID为C-SY-515020-01-R-02, + * 相应的选择可为空,为空时则取消“-代号”即可,如C-515020-01-R-02; + */ + String gzdh = gzdhMap.get(gzdhBox.getSelectedItem().toString()); + String jcdh = jcdhMap.get(jcdhBox.getSelectedItem().toString()); + String gzmjdh = gzmjdhMap.get(gzmjdhBox.getSelectedItem().toString()); + String newID = ""; + if(!gzdh.isEmpty()) { + newID = gzdh + "-"; + } + if(!jcdh.isEmpty()) { + newID = newID + jcdh + "-"; + } + newID = newID + tarRevision.getStringProperty("item_id") + "-"; + if(!gzmjdh.isEmpty()) { + newID = newID + gzmjdh + "-"; + } + SqlUtilT.getTCConnection(); + String sql = String.format("select MAX(pitem_id) max from dbo.PITEM t1, dbo.PZF6_GZ t2 where t1.puid = t2.puid and pitem_id like '%s%%'", newID); + String string = ""; + ResultSet rs = SqlUtilT.read(sql); + if(rs.next()) { + string = rs.getString("max"); + } + if(string == null || string.isEmpty()) { + newID = newID + "001"; + }else { + if(string.contains("-")) { + String[] split = string.split("-"); + DecimalFormat df = new DecimalFormat("000"); + String format = df.format(Integer.parseInt(split[split.length-1]) + 1); + newID = newID + format; + } + } + return newID; + } +} diff --git a/src/com/connor/zf/plm003/CreateToolingHandler.java b/src/com/connor/zf/plm003/CreateToolingHandler.java new file mode 100644 index 0000000..992e1dd --- /dev/null +++ b/src/com/connor/zf/plm003/CreateToolingHandler.java @@ -0,0 +1,29 @@ +package com.connor.zf.plm003; + +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 CreateToolingHandler extends AbstractHandler{ + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + String preValue = session.getPreferenceService().getStringValue("ZF6_GZSJ_Type"); + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + if(!preValue.contains(targetComponent.getType())) { + MessageBox.post("请选中可以派生工装的对象版本!!!", "错误", MessageBox.ERROR); + return null; + } + + new CreateToolingDialog(session, targetComponent); + return null; + } + +} diff --git a/src/com/connor/zf/plm003/Test.java b/src/com/connor/zf/plm003/Test.java new file mode 100644 index 0000000..fee5674 --- /dev/null +++ b/src/com/connor/zf/plm003/Test.java @@ -0,0 +1,43 @@ +package com.connor.zf.plm003; + +import java.io.IOException; +import java.util.HashMap; +import java.util.List; + +import javax.xml.bind.JAXBException; + +import com.connor.zf.plm.xmlUtil.CNCompontent; +import com.connor.zf.plm.xmlUtil.CNPart; +import com.connor.zf.plm.xmlUtil.CNPartList; +import com.connor.zf.plm.xmlUtil.CNProperty; +import com.connor.zf.plm.xmlUtil.CNXmlUtil; + + +public class Test { + public static void main(String[] args) throws JAXBException, IOException { + String filePath = "C:\\Users\\admin\\Desktop\\测试\\XML测试\\编码器属性配置.xml"; + Object object = CNXmlUtil.xmlToBean(filePath, CNPartList.class); + CNPartList parts = (CNPartList) object; + List partList = parts.getPartList(); + + for (int i = 0; i < partList.size(); i++) { + System.out.println(partList.get(i).getType()); + for (CNCompontent comp : partList.get(i).getCompontentList()) { + System.out.println(comp.getType()); + System.out.println(comp.getCompententType()); + for (CNProperty prop : comp.getPropertyList()) { + System.out.println(prop.getDisplayName()); + } + } + } + + String newSeq = "001000"; + newSeq = newSeq.replaceFirst("^0*", ""); + System.out.println(newSeq); + + HashMap itemProMap = new HashMap(); + itemProMap.put("1", ""); + itemProMap.put("2", ""); + System.out.println(itemProMap.get("1")); + } +} diff --git a/src/com/connor/zf/util/ClassPropBean.java b/src/com/connor/zf/util/ClassPropBean.java new file mode 100644 index 0000000..96df882 --- /dev/null +++ b/src/com/connor/zf/util/ClassPropBean.java @@ -0,0 +1,44 @@ +package com.connor.zf.util; + +public class ClassPropBean { + private String id; + private String name; + private String value; + + public ClassPropBean(String id, String name, String value) { + super(); + this.id = id; + this.name = name; + this.value = value; + } + + public String getId() { + return id; + } + + @Override + public String toString() { + return name; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + +} diff --git a/src/com/connor/zf/util/ClassProperty.java b/src/com/connor/zf/util/ClassProperty.java new file mode 100644 index 0000000..bb5d908 --- /dev/null +++ b/src/com/connor/zf/util/ClassProperty.java @@ -0,0 +1,42 @@ +package com.connor.zf.util; + +/** + * @copyRight 浙江康勒科技有限公司 + * @author 作者 E-mail:hub@connor.net.cn + * @date 创建时间:2017-7-3 下午11:47:03 + * @version v1.0 + * @parameter + * @since + * @return + */ + +public class ClassProperty { + private int propertyID; + private String value; + + public ClassProperty() { + + } + + public ClassProperty(int propertyID, String value) { + this.propertyID = propertyID; + this.value = value; + } + + public int getPropertyID() { + return propertyID; + } + + public void setPropertyID(int propertyID) { + this.propertyID = propertyID; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + +} diff --git a/src/com/connor/zf/util/JDMethodUtil.java b/src/com/connor/zf/util/JDMethodUtil.java new file mode 100644 index 0000000..8d5eef4 --- /dev/null +++ b/src/com/connor/zf/util/JDMethodUtil.java @@ -0,0 +1,47 @@ +package com.connor.zf.util; + +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; + +public class JDMethodUtil { + + public static TCPreferenceService service; + public static TCUserService userservice; + + /** + * + * + * @param prefName + * @return + */ + public static String getPrefStr(String prefName, TCSession session) { + if (service == null) { + service = session.getPreferenceService(); + } + String str = service.getString(TCPreferenceService.TC_preference_site, prefName); + if (str == null) { + str = new String(""); + } + return str; + } + + /** + * + * + * @param prefName + * @return + */ + public static String[] getPrefStrArray(String prefName, TCSession session) { + if (service == null) { + service = session.getPreferenceService(); + } + String[] strs = service.getStringArray(TCPreferenceService.TC_preference_site, prefName); + service.getStringValues(prefName); + service.getStringValue(prefName); + if (strs == null) { + strs = new String[] { "" }; + } + return strs; + } +} diff --git a/src/com/connor/zf/util/SoaServerUtil.java b/src/com/connor/zf/util/SoaServerUtil.java new file mode 100644 index 0000000..3001588 --- /dev/null +++ b/src/com/connor/zf/util/SoaServerUtil.java @@ -0,0 +1,343 @@ +package com.connor.zf.util; + +import java.util.List; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.om.OMNamespace; +import org.apache.axis2.AxisFault; +import org.apache.axis2.addressing.EndpointReference; +import org.apache.axis2.client.Options; +import org.apache.axis2.client.ServiceClient; +import org.apache.axis2.transport.http.HTTPConstants; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCAccessControlService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCComponentUserType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; + +//import net.sf.json.JSONArray; + +/** + * 发送分类Util类 + * @author 61666 + * + */ +public class SoaServerUtil { + + public static void sendToClass(String wsoPUID, String classID, String json, String url) { + // AbstractAIFApplication app; + // app=AIFUtility.getCurrentApplication(); + // TCSession session; + // session=(TCSession) app.getSession(); + // TCPreferenceService preferenceService; + // preferenceService=session.getPreferenceService(); + // String account=preferenceService.getStringValue("Autocode_PriverUser_ID"); + // String url; + // url = preferenceService.getStringValue("Autocode_SendClassServer_URL"); + try { + ServiceClient sc = new ServiceClient(); + Options opts = new Options(); + // url = "http://10.201.5.203:19090/ErpWebService.asmx?WSDL"; + EndpointReference end = new EndpointReference(url); + opts.setTo(end); + opts.setAction("SendToClass"); + sc.setOptions(opts); + + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", ""); + OMElement method = fac.createOMElement("SendToClass", omNs); + OMElement value = fac.createOMElement("wsoPuiid", omNs); + value.setText(wsoPUID); + OMElement value1 = fac.createOMElement("classID", omNs); + value1.setText(classID); + OMElement value2 = fac.createOMElement("JsonContainer", omNs); + // "[{\"value\":\"1\",\"propertyID\":-500003},{\"value\":\"1\",\"propertyID\":-500011}]" + value2.setText(json); + + method.addChild(value); + method.addChild(value1); + method.addChild(value2); + + OMElement res = sc.sendReceive(method); + res.getFirstElement().getText(); + System.out.println(res.getFirstElement().getText()); + } catch (AxisFault e) { + e.printStackTrace(); + } + + } + + public static String updateToClass(String wsoPUID, String classID, String json, String url, String icoUid) { + // AbstractAIFApplication app; + // app=AIFUtility.getCurrentApplication(); + // TCSession session; + // session=(TCSession) app.getSession(); + // TCPreferenceService preferenceService; + // preferenceService=session.getPreferenceService(); + // String account=preferenceService.getStringValue("Autocode_PriverUser_ID"); + // String url; + // url = preferenceService.getStringValue("Autocode_SendClassServer_URL"); + String reMsgString=""; + try { + ServiceClient sc = new ServiceClient(); + Options opts = new Options(); + // url = "http://10.201.5.203:19090/ErpWebService.asmx?WSDL"; + EndpointReference end = new EndpointReference(url); + opts.setTo(end); + opts.setAction("UpdateToClass"); + sc.setOptions(opts); + + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", ""); + OMElement method = fac.createOMElement("UpdateToClass", omNs); + OMElement value = fac.createOMElement("wsoPuiid", omNs); + value.setText(wsoPUID); + OMElement value1 = fac.createOMElement("classID", omNs); + value1.setText(classID); + OMElement value2 = fac.createOMElement("JsonContainer", omNs); + + OMElement value3 = fac.createOMElement("icoPUID", omNs); + // "[{\"value\":\"1\",\"propertyID\":-500003},{\"value\":\"1\",\"propertyID\":-500011}]" + value2.setText(json); + value3.setText(icoUid); + + method.addChild(value); + method.addChild(value1); + method.addChild(value2); + method.addChild(value3); + OMElement res = sc.sendReceive(method); + reMsgString=res.getFirstElement().getText(); + System.out.println(res.getFirstElement().getText()); + + } catch (AxisFault e) { + e.printStackTrace(); + } + + return reMsgString; + + } + public static void deleteAndSendToClass(String icoPUID,String wsoPUID, String classID, String json, String url) { + // AbstractAIFApplication app; + // app=AIFUtility.getCurrentApplication(); + // TCSession session; + // session=(TCSession) app.getSession(); + // TCPreferenceService preferenceService; + // preferenceService=session.getPreferenceService(); + // String account=preferenceService.getStringValue("Autocode_PriverUser_ID"); + // String url; + // url = preferenceService.getStringValue("Autocode_SendClassServer_URL"); + try { + ServiceClient sc = new ServiceClient(); + Options opts = new Options(); + // url = "http://10.201.5.203:19090/ErpWebService.asmx?WSDL"; + EndpointReference end = new EndpointReference(url); + opts.setTo(end); + opts.setAction("SendToClass"); + sc.setOptions(opts); + + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", ""); + OMElement method = fac.createOMElement("editToClass", omNs); + OMElement icovalue = fac.createOMElement("icoPUID", omNs); + icovalue.setText(icoPUID); + OMElement value = fac.createOMElement("wsoPuiid", omNs); + value.setText(wsoPUID); + OMElement value1 = fac.createOMElement("classID", omNs); + value1.setText(classID); + OMElement value2 = fac.createOMElement("JsonContainer", omNs); + // "[{\"value\":\"1\",\"propertyID\":-500003},{\"value\":\"1\",\"propertyID\":-500011}]" + value2.setText(json); + method.addChild(icovalue); + method.addChild(value); + method.addChild(value1); + method.addChild(value2); + + OMElement res = sc.sendReceive(method); + res.getFirstElement().getText(); + System.out.println(res.getFirstElement().getText()); + } catch (AxisFault e) { + e.printStackTrace(); + } + + } + // public static void main(String[] args) { + // deleteClass("1111", ""); + // } + // 分类库中删除临时物料 + public static void deleteClass(String icoPUID, String url) { + try { + ServiceClient sc = new ServiceClient(); + Options opts = new Options(); + // url = "http://10.201.5.203:19090/ErpWebService.asmx?WSDL";//TODO + // 首选项Autocode_SendClassServer_URL + // url = preferenceService.getStringValue("Autocode_SendClassServer_URL");//TODO + // 首选项Autocode_SendClassServer_URL + EndpointReference end = new EndpointReference(url); + opts.setTo(end); + opts.setAction("DeleteClass"); + opts.setProperty(HTTPConstants.CHUNKED, "false"); + sc.setOptions(opts); + + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", ""); + OMElement method = fac.createOMElement("DeleteClass", omNs); + OMElement value = fac.createOMElement("icoPuid", omNs); + value.setText(icoPUID); + // OMElement value1 = fac.createOMElement("classID", omNs); + //// value1.setText(classID); + // OMElement value2 = fac.createOMElement("JsonContainer", omNs); + // "[{\"value\":\"1\",\"propertyID\":-500003},{\"value\":\"1\",\"propertyID\":-500011}]" + // value2.setText(json); + + method.addChild(value); + // method.addChild(value1); + // method.addChild(value2); + + OMElement res = sc.sendReceive(method); + res.getFirstElement().getText(); + System.out.println(res.getFirstElement().getText()); + } catch (AxisFault e) { + e.printStackTrace(); + } + + } + +// public static String objectToJson(List props) { +// String str = null; +// try { +// JSONArray json = JSONArray.fromObject(props);// 将java对象转换为json对象 +// str = json.toString();// 将json对象转换为字符串 +// } catch (Exception e) { +// e.printStackTrace(); +// } +// System.out.println("JSON =>" + str); +// return str; +// } + + public static void grantReadPrivilege(TCSession tcSession, TCComponent tccomponent) { + AbstractAIFApplication app; + app = AIFUtility.getCurrentApplication(); + TCSession session; + session = (TCSession) app.getSession(); + TCPreferenceService preferenceService; + preferenceService = session.getPreferenceService(); + String account = preferenceService.getStringValue("Autocode_PriverUser_ID"); + try { + TCAccessControlService accessControlService = tcSession.getTCAccessControlService(); + TCComponentUserType type = (TCComponentUserType) tcSession.getTypeComponent("User"); + TCComponentUser user = type.find(account); + + if (user == null) { + return; + } + if (tcSession.getUser().equals(user)) { + return; + } + + String[] as2 = new String[] { "READ" }; + + if (tccomponent instanceof TCComponentItemRevision) { + TCComponentItem tempItem = ((TCComponentItemRevision) tccomponent).getItem(); + openByPass(tcSession); + accessControlService.grantPrivilege(tempItem, user, as2); + closeByPass(tcSession); + + openByPass(tcSession); + accessControlService.grantPrivilege(tccomponent, user, as2); + closeByPass(tcSession); + } else { + openByPass(tcSession); + accessControlService.grantPrivilege(tccomponent, user, as2); + closeByPass(tcSession); + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + public static void grantWritePrivilege(TCSession tcSession, TCComponent tccomponent) { + AbstractAIFApplication app; + app = AIFUtility.getCurrentApplication(); + TCSession session; + session = (TCSession) app.getSession(); + TCPreferenceService preferenceService; + preferenceService = session.getPreferenceService(); + String account = preferenceService.getStringValue("Autocode_PriverUser_ID"); + try { + TCAccessControlService accessControlService = tcSession.getTCAccessControlService(); + TCComponentUserType type = (TCComponentUserType) tcSession.getTypeComponent("User"); + + TCComponentUser user = type.find(account); + if (user == null) { + return; + } + if (tcSession.getUser().equals(user)) { + return; + } + + String[] as2 = new String[] { "READ", "WRITE", "DELETE" }; + + if (tccomponent instanceof TCComponentItemRevision) { + TCComponentItem tempItem = ((TCComponentItemRevision) tccomponent).getItem(); + setByPass(true,tcSession); + accessControlService.grantPrivilege(tempItem, user, as2); + setByPass(false,tcSession); + + setByPass(true,tcSession); + accessControlService.grantPrivilege(tccomponent, user, as2); + setByPass(false,tcSession); + } else { + setByPass(true,tcSession); + accessControlService.grantPrivilege(tccomponent, user, as2); + setByPass(false,tcSession); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public static void openByPass(TCSession session) throws TCException { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[1]; + obj[0] = ""; + userservice.call("Connor_set_bypass", obj); + } + + public static void closeByPass(TCSession session) throws TCException { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[1]; + obj[0] = ""; + userservice.call("Connor_close_bypass", obj); + +// session.getUserService().call("Connor_set_bypass", new Object[]{});//开bypass +// session.getUserService().call("Connor_close_bypass", new Object[]{});//关bypass + } + public static void setByPass(boolean val,TCSession session) throws TCException { + TCUserService userservice = session.getUserService(); + if (userservice == null) { + userservice = session.getUserService(); + } + Object[] obj = new Object[1]; + obj[0] = "origin"; + if (val) { +// userservice.call("ORIGIN_set_bypass", obj); + userservice.call("Connor_set_bypass", obj); + } else { +// userservice.call("ORIGIN_close_bypass", obj); + userservice.call("Connor_close_bypass", obj); + } + } + +} + diff --git a/src/com/connor/zf/util/StringCreateUtil.java b/src/com/connor/zf/util/StringCreateUtil.java new file mode 100644 index 0000000..0d31ff0 --- /dev/null +++ b/src/com/connor/zf/util/StringCreateUtil.java @@ -0,0 +1,21 @@ +package com.connor.zf.util; + +public class StringCreateUtil { + public static String createBlank(int num) { + StringBuilder sb = new StringBuilder(); + while (num > 0) { + sb.append(" "); + num--; + } + return sb.toString(); + } + + public static String createPoint(int num) { + StringBuilder sb = new StringBuilder(); + while (num > 0) { + sb.append("."); + num--; + } + return sb.toString(); + } +} diff --git a/src/com/connor/zf/utils/CheckBoxTableHeaderRenderer.java b/src/com/connor/zf/utils/CheckBoxTableHeaderRenderer.java new file mode 100644 index 0000000..c32ae35 --- /dev/null +++ b/src/com/connor/zf/utils/CheckBoxTableHeaderRenderer.java @@ -0,0 +1,67 @@ +package com.connor.zf.utils; + + +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +import javax.swing.BorderFactory; +import javax.swing.JCheckBox; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JTable; +import javax.swing.SwingConstants; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableCellRenderer; + +public class CheckBoxTableHeaderRenderer implements TableCellRenderer{ + + private JTableHeader tableHeader; + private JCheckBox selectBox; + //checkbox所在的列 + private int IND_BOOLEAN; + //背景颜色 + private static final Color BG=new Color(53,53,53); + + public CheckBoxTableHeaderRenderer(final JTable table,int IND_BOOLEAN1,JCheckBox check) { + this.tableHeader = table.getTableHeader(); + this.IND_BOOLEAN=IND_BOOLEAN1; + this.selectBox = check; + tableHeader.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() > 0) { + // 获得选中列 + int selectColumn = tableHeader.columnAtPoint(e.getPoint()); + if (selectColumn == IND_BOOLEAN) { + boolean value = !selectBox.isSelected(); + selectBox.setSelected(value); + for(int index = 0; index < table.getRowCount(); index ++){ + table.setValueAt(value, index, IND_BOOLEAN); + } + tableHeader.repaint(); + } + } + } + }); + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + String valueStr = (String) value; + JLabel label = new JLabel(valueStr); + label.setHorizontalAlignment(SwingConstants.CENTER); // 表头标签居中 + selectBox.setHorizontalAlignment(SwingConstants.CENTER);// 表头标签居中 + selectBox.setBorderPainted(true); + JComponent component = (column == IND_BOOLEAN) ? selectBox : label; + component.setOpaque(true); + component.setForeground(Color.WHITE); + component.setBackground(BG); + component.setFont(tableHeader.getFont()); + component.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, Color.WHITE)); + component.setPreferredSize(new Dimension(component.getPreferredSize().width,25)); + return component; + } + +} \ No newline at end of file diff --git a/src/com/connor/zf/utils/CreateNewBOHandler.java b/src/com/connor/zf/utils/CreateNewBOHandler.java new file mode 100644 index 0000000..1abfaf8 --- /dev/null +++ b/src/com/connor/zf/utils/CreateNewBOHandler.java @@ -0,0 +1,209 @@ +package com.connor.zf.utils; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExecutableExtension; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.handlers.HandlerUtil; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.jface.wizard.WizardDialog; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.aifrcp.SelectionHelper; +import com.teamcenter.rac.kernel.TCSession; + +import com.teamcenter.rac.ui.commands.Messages; +import com.teamcenter.rac.ui.commands.RACUICommandsActivator; +import com.teamcenter.rac.ui.commands.create.bo.NewBOModel; +import com.teamcenter.rac.ui.commands.create.bo.NewBOWizard; +import com.teamcenter.rac.ui.commands.handlers.NewBOHandler; + +import com.teamcenter.rac.util.SWTUIUtilities; +import com.teamcenter.rac.util.UIUtilities; +import com.teamcenter.rac.util.wizard.extension.BaseExternalWizardDialog; +import com.teamcenter.rac.util.wizard.extension.WizardExtensionHelper; + +/** + * Our sample handler extends AbstractHandler, an IHandler base class. + * + * @see org.eclipse.core.commands.IHandler + * @see org.eclipse.core.commands.AbstractHandler + */ +public class CreateNewBOHandler extends AbstractHandler implements +IExecutableExtension { +private String itemtype; + +public CreateNewBOHandler(String itemtype) { +this.itemtype = itemtype; +} + +private class CreateNewBOSWTDialog implements Runnable { + +public void run() { + NewBOWizard newbowizard = (NewBOWizard) getWizard(); + if (newbowizard == null) + newbowizard = new NewBOWizard(wizardId); + m_boModel.setSession(session); + m_boModel.reInitializeTransientData(); + newbowizard.setBOModel(m_boModel); + newbowizard.setShell(m_shell); + newbowizard.setParentFrame(AIFUtility.getActiveDesktop()); + newbowizard.setTargetArray(selectedCmps); + newbowizard.setCurrentSelection(m_currentSelection); + newbowizard.setWindowTitle(getWizardTitle()); + newbowizard.setRevisionFlag(m_revisionFlag); + newbowizard.setDefaultType(m_type); + m_boModel.setRevisionFlag(m_revisionFlag); + // newbowizard.setWizardId("123"); + Shell shell = UIUtilities.getCurrentModalShell(); + dialog = new BaseExternalWizardDialog(m_shell, newbowizard); + dialog.create(); + +// dialog. + newbowizard.retrievePersistedDialogSettings(dialog); + newbowizard.setWizardDialog(dialog); + UIUtilities.setCurrentModalShell(dialog.getShell()); + dialog.open(); +// InterfaceAIFComponent[] aifComponent = m_boModel.getTargetArray(); +// if(aifComponent != null && aifComponent.length > 0) +// { +// com.teamcenter.rac.common.Activator.getDefault() +// .openPerspective("com.teamcenter.rac.cme.mpp.MSEPerspective"); +// com.teamcenter.rac.common.Activator.getDefault().openComponents( +// "com.teamcenter.rac.cme.mpp.MSEPerspective", +// aifComponent); +// } + dialog = null; + m_boModel = null; + UIUtilities.setCurrentModalShell(shell); + System.out.println("关闭"); +} + +private final Shell m_shell; +private boolean m_revisionFlag = false; +private final String m_type; +final CreateNewBOHandler this$0; + +private CreateNewBOSWTDialog(Shell shell, boolean flag, String s) { + super(); + this$0 = CreateNewBOHandler.this; + m_shell = shell; + m_revisionFlag = flag; + m_type = s; +} + +CreateNewBOSWTDialog(Shell shell, boolean flag, String s, + CreateNewBOSWTDialog createnewboswtdialog) { + this(shell, flag, s); +} +} + +public Object execute(ExecutionEvent executionevent) + throws ExecutionException { + + + +if (executionevent == null) + throw new IllegalArgumentException("Event can't be null"); +boolean flag = false; +if (executionevent.getParameters() != null + && executionevent.getParameters().containsKey("selection")) { + Object obj = executionevent.getParameters().get("selection"); + if (obj instanceof InterfaceAIFComponent[]) { + selectedCmps = (InterfaceAIFComponent[]) obj; + m_currentSelection = new StructuredSelection(selectedCmps); + flag = true; + } +} +if (!flag) { + m_currentSelection = HandlerUtil + .getCurrentSelection(executionevent); + selectedCmps = SelectionHelper + .getTargetComponents(m_currentSelection); +} +m_boModel = getBOModel(); +try { + session = (TCSession) RACUICommandsActivator.getDefault() + .getSession(); +} catch (Exception _ex) { + session = (TCSession) AIFUtility.getDefaultSession(); +} +launchWizard(executionevent); +return null; +} + +public void setInitializationData( + IConfigurationElement iconfigurationelement, String s, Object obj) + throws CoreException { +} + +protected NewBOModel getBOModel() { +if (m_boModel == null) + m_boModel = new NewBOModel(this); +return m_boModel; +} + +public Wizard getWizard() { +if (wizardId == null || wizardId.length() == 0) + wizardId = "com.teamcenter.rac.ui.commands.create.bo.NewBOWizard"; +return WizardExtensionHelper.getWizard(wizardId); +} + +public String getWizardTitle() { +return Messages.getString("wizard.TITLE"); +} + +public void launchWizard() { +launchWizard(null); +} + +public void launchWizard(ExecutionEvent executionevent) { +boolean flag = false; +// String s = "RT4Item"; +if (executionevent != null && executionevent.getParameters() != null) { + if (executionevent.getParameters().containsKey("revisionFlag")) + flag = ((Boolean) executionevent.getParameters().get( + "revisionFlag")).booleanValue(); + // s = (String)executionevent.getParameters().get("objectType"); + if (executionevent.getParameters().containsKey("pasteRelation")) { + String s1 = (String) executionevent.getParameters().get( + "pasteRelation"); + if (s1 != null) { + String as[] = null; + as = s1.split(","); + m_boModel.setRelType(as[0]); + m_boModel.setPreAssignedRelType(as); + } + } +} + + +AIFDesktop aifdesktop = AIFUtility.getActiveDesktop(); +Shell shell = aifdesktop.getShell(); +if (shell != null) + // if(itemtype!=null) + SWTUIUtilities.asyncExec(new CreateNewBOSWTDialog(shell, flag, + itemtype, null)); +} + +protected void readDisplayParameters(NewBOWizard newbowizard, + WizardDialog wizarddialog) { +newbowizard.retrievePersistedDialogSettings(wizarddialog); +} + +protected InterfaceAIFComponent selectedCmps[]; +protected ISelection m_currentSelection; +protected String wizardId; +protected BaseExternalWizardDialog dialog; +protected TCSession session; +protected NewBOModel m_boModel; +} diff --git a/src/com/connor/zf/utils/JAutoCompleteComboBox.java b/src/com/connor/zf/utils/JAutoCompleteComboBox.java new file mode 100644 index 0000000..9ce0dc3 --- /dev/null +++ b/src/com/connor/zf/utils/JAutoCompleteComboBox.java @@ -0,0 +1,155 @@ +package com.connor.zf.utils; + +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.util.List; +import java.util.Vector; + +import javax.swing.ComboBoxModel; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JComboBox; +import javax.swing.JTextField; + +public class JAutoCompleteComboBox extends JComboBox { + private AutoCompleter completer; + + public JAutoCompleteComboBox() { + super(); + addCompleter(); + } + + public JAutoCompleteComboBox(ComboBoxModel cm) { + super(cm); + addCompleter(); + } + + public JAutoCompleteComboBox(Object[] items) { + super(items); + addCompleter(); + } + + public JAutoCompleteComboBox(List v) { + super((Vector) v); + addCompleter(); + } + + private void addCompleter() { + setEditable(true); + completer = new AutoCompleter(this); + } + + public void autoComplete(String str) { + this.completer.autoComplete(str, str.length()); + } + + public String getText() { + return ((JTextField) getEditor().getEditorComponent()).getText(); + } + + public void setText(String text) { + ((JTextField) getEditor().getEditorComponent()).setText(text); + } + + public boolean containsItem(String itemString) { + for (int i = 0; i < this.getModel().getSize(); i++) { + String _item = " " + this.getModel().getElementAt(i); + if (_item.equals(itemString)) + return true; + } + return false; + } + +} + +class AutoCompleter implements KeyListener, ItemListener { + + private JComboBox owner = null; + private JTextField editor = null; + + private ComboBoxModel model = null; + + public AutoCompleter(JComboBox comboBox) { + owner = comboBox; + editor = (JTextField) comboBox.getEditor().getEditorComponent(); + editor.addKeyListener(this); + model = comboBox.getModel(); + owner.addItemListener(this); + } + + public void keyTyped(KeyEvent e) { + } + + public void keyPressed(KeyEvent e) { + } + + public void keyReleased(KeyEvent e) { + char ch = e.getKeyChar(); + // if (ch == KeyEvent.CHAR_UNDEFINED || Character.isISOControl(ch) + // || ch == KeyEvent.VK_DELETE) + // return; + if (e.getKeyCode() == KeyEvent.VK_ENTER) { + int caretPosition = editor.getCaretPosition(); + String str = editor.getText(); + if (str.length() == 0) + return; + autoComplete(str, caretPosition); + } + } + + protected void autoComplete(String strf, int caretPosition) { + Object[] opts; + opts = getMatchingOptions(strf.substring(0, caretPosition)); + if (owner != null) { + model = new DefaultComboBoxModel(opts); + owner.setModel(model); + } + if (opts.length > 0) { + String str = opts[0].toString(); + editor.setCaretPosition(caretPosition); + if (owner != null) { + try { + owner.showPopup(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + } + } + + protected Object[] getMatchingOptions(String str) { + List v = new Vector(); + List v1 = new Vector(); + //v.add(str); + for (int k = 0; k < model.getSize(); k++) { + Object itemObj = model.getElementAt(k); + if (itemObj != null) { + String item = itemObj.toString().toLowerCase(); + if (item.indexOf((str.toLowerCase())) > -1) + v.add(model.getElementAt(k)); + else + v1.add(model.getElementAt(k)); + } else + v1.add(model.getElementAt(k)); + } + for (int i = 0; i < v1.size(); i++) { + v.add(v1.get(i)); + } + // if (v.isEmpty()) + return v.toArray(); + } + + public void itemStateChanged(ItemEvent event) { + if (event.getStateChange() == ItemEvent.SELECTED) { + int caretPosition = editor.getCaretPosition(); + if (caretPosition != -1) { + try { + editor.moveCaretPosition(caretPosition); + } catch (IllegalArgumentException ex) { + ex.printStackTrace(); + } + } + } + } +} \ No newline at end of file diff --git a/src/com/connor/zf/utils/JFomMethodUtil.java b/src/com/connor/zf/utils/JFomMethodUtil.java new file mode 100644 index 0000000..16617a1 --- /dev/null +++ b/src/com/connor/zf/utils/JFomMethodUtil.java @@ -0,0 +1,125 @@ +package com.connor.zf.utils; + +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.List; + +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentFormType; +import com.teamcenter.rac.kernel.TCComponentItemRevisionType; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.FileUtility; + +public class JFomMethodUtil { + + + /** + * 下载文件 + * + * @param comps + * @return + * @throws TCException + * @throws IOException + */ + public static String downLoadFile(TCComponent comp) { + if (comp == null) { + return ""; + } + String value = ""; + String tempPath = System.getenv("TEMP"); + // MessageBox.post(" tempPath = + // "+tempPath,"INFO",MessageBox.INFORMATION); + if (tempPath == null) { + tempPath = ""; + } else if (!tempPath.endsWith("\\")) { + tempPath = tempPath + "\\"; + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); + // for(TCComponent comp : comps){ + try { + if (comp instanceof TCComponentDataset) { + TCComponentTcFile[] tcFiles = ((TCComponentDataset) comp) + .getTcFiles(); + File file = null; + if (tcFiles != null && tcFiles.length != 0) { + file = tcFiles[0].getFmsFile(); + String fileName = file.getName(); + String fileDix = fileName.substring( + fileName.lastIndexOf("."), fileName.length()); + fileName = tempPath + sdf.format(new Date()) + fileDix; + File dirFile = new File(fileName); + FileUtility.copyFile(file, dirFile); + + return fileName; + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // } + return value; + } + + /** + * 获取首选项的值 + * @param prefName + * @param session + * @return + */ + public static String getOptionValue(String prefName, TCSession session) { + String value = null; + TCPreferenceService service = session.getPreferenceService(); + value = service.getString(TCPreferenceService.TC_preference_site, prefName); + + return value; + } + + /** + * 获取首选项的值 + * @param prefName + * @param session + * @return + */ + public static String[] getOptionValues(String prefName, TCSession session) { + String[] values = null; + TCPreferenceService service = session.getPreferenceService(); + values = service.getStringValues(prefName); + + return values; + } + + /** + * 获取mapping表 + * name:value + * @param prefName + * @param session + * @return + */ + public static HashMap getMapping(String prefName, TCSession session) { + HashMap map = new HashMap(); + TCPreferenceService service = session.getPreferenceService(); + String[] prefValues = service.getStringArray(TCPreferenceService.TC_preference_site, prefName); + if (prefValues != null) { + for (String value : prefValues) { + String[] values = value.split("\\:"); + if (values != null && values.length == 2) + map.put(values[0], values[1]); + } + } + return map; + } + +} diff --git a/src/com/connor/zf/utils/SqlUtilT.java b/src/com/connor/zf/utils/SqlUtilT.java new file mode 100644 index 0000000..c3af12d --- /dev/null +++ b/src/com/connor/zf/utils/SqlUtilT.java @@ -0,0 +1,756 @@ +package com.connor.zf.utils; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +/** + * 防止误继承因此是final类,防止误建对象因此用私有构造方法,为方便使用类名短小, PreparedStatement对象名和ResultSet对象名短小 + * + * @author hub 2015-02-06 + */ +public final class SqlUtilT { + public static Connection connection = null; + public static PreparedStatement ps = null; + public static ResultSet rs = null; + + // private static Registry reg = Registry.getRegistry(SqlUtilT.class); + /** + * 私有构造器不能new对象,防止误用对象 + */ + private SqlUtilT() { + + } + + static { + String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; // Util.getProperties("DRIVER"); + if (driver == null) { + driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; + } + + System.out.println("driver " + driver); + try { + Class.forName(driver); + } catch (ClassNotFoundException e) { + System.out.println("SQLSERVER DRIVER IS EXCEPTION"); + e.printStackTrace(); + } + } + + /** + * 链接数据库 + */ + public static Connection getConnectionTC13() { + try { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + TCPreferenceService service = session.getPreferenceService(); + String[] array = service.getStringArray( + TCPreferenceService.TC_preference_site, "TC13_SqlServer_MSG"); + String driver_temp = null; + String url = null; + String dbName = null; + String dbPassword = null; + if (array != null) + for (String str : array) { + System.out.println(" ORACLE = " + str); + if (str != null && str.startsWith("SQL_DRIVER=")) { + driver_temp = str.substring(str.indexOf("=") + 1, + str.length()); + } else if (str != null && str.startsWith("SQL_URL=")) { + url = str.substring(str.indexOf("=") + 1, str.length()); + } else if (str != null && str.startsWith("SQL_NAME=")) { + dbName = str.substring(str.indexOf("=") + 1, + str.length()); + } else if (str != null + && str.startsWith("SQL_PASSWORD=")) { + dbPassword = str.substring(str.indexOf("=") + 1, + str.length()); + } + } + + if (driver_temp == null || url == null || dbName == null + || dbPassword == null) { + MessageBox.post("请检查数据库首选项是否配置正确", "错误提示", MessageBox.ERROR); + } + System.out.println(url + dbName + dbPassword); + connection = DriverManager.getConnection(url, dbName, dbPassword); + connection.setAutoCommit(false); + } catch (SQLException e) { + System.out.println("ORACEL CONNECT EXCEPTION"); + e.printStackTrace(); + return null; + } + return connection; + } + + /** + * 链接数据库 + */ + public static Connection getConnectionTC12() { + try { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + TCPreferenceService service = session.getPreferenceService(); + String[] array = service.getStringArray( + TCPreferenceService.TC_preference_site, "TC12_Oracle_MSG"); + String driver_temp = null; + String url = null; + String dbName = null; + String dbPassword = null; + if (array != null) + for (String str : array) { + System.out.println(" ORACLE = " + str); + if (str != null && str.startsWith("ORACEL_DRIVER=")) { + driver_temp = str.substring(str.indexOf("=") + 1, + str.length()); + } else if (str != null && str.startsWith("ORACEL_URL=")) { + url = str.substring(str.indexOf("=") + 1, str.length()); + } else if (str != null && str.startsWith("ORACEL_NAME=")) { + dbName = str.substring(str.indexOf("=") + 1, + str.length()); + } else if (str != null + && str.startsWith("ORACEL_PASSWORD=")) { + dbPassword = str.substring(str.indexOf("=") + 1, + str.length()); + } + } + // String driver_temp = reg.getString("ORACEL_DRIVER"); + // String url = reg.getString("ORACEL_URL");// getProperties("URL"); + // String dbName = reg.getString("ORACEL_NAME");// + // Util.getProperties("dbName"); + // String dbPassword = reg.getString("ORACEL_PASSWORD");// + // Util.getProperties("dbPassword"); + + if (driver_temp == null || url == null || dbName == null + || dbPassword == null) { + + MessageBox.post("请检查数据库首选项是否配置正确", "错误提示", MessageBox.ERROR); + + } + // else{ + // MessageBox.post(driver_temp+" | "+url+" | "+dbName+" | "+dbPassword,"错误提示",MessageBox.ERROR); + // + // } + System.out.println(url + dbName + dbPassword); + connection = DriverManager.getConnection(url, dbName, dbPassword); + connection.setAutoCommit(false); + } catch (SQLException e) { + System.out.println("ORACEL CONNECT EXCEPTION"); + e.printStackTrace(); + return null; + // MessageBox.post("ORACEL CONNECT EXCEPTION \n"+e.getMessage(),"ERROR",MessageBox.ERROR); + } + return connection; + } + + /** + * 链接数据库 + */ + public static Connection getConnectionTC() { + try { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + TCPreferenceService service = session.getPreferenceService(); + String[] array = service.getStringArray( + TCPreferenceService.TC_preference_site, "TC_Oracel_MSG"); + String driver_temp = null; + String url = null; + String dbName = null; + String dbPassword = null; + if (array != null) + for (String str : array) { + System.out.println(" ORACLE = " + str); + if (str != null && str.startsWith("ORACEL_DRIVER=")) { + driver_temp = str.substring(str.indexOf("=") + 1, + str.length()); + } else if (str != null && str.startsWith("ORACEL_URL=")) { + url = str.substring(str.indexOf("=") + 1, str.length()); + } else if (str != null && str.startsWith("ORACEL_NAME=")) { + dbName = str.substring(str.indexOf("=") + 1, + str.length()); + } else if (str != null + && str.startsWith("ORACEL_PASSWORD=")) { + dbPassword = str.substring(str.indexOf("=") + 1, + str.length()); + } + } + // String driver_temp = reg.getString("ORACEL_DRIVER"); + // String url = reg.getString("ORACEL_URL");// getProperties("URL"); + // String dbName = reg.getString("ORACEL_NAME");// + // Util.getProperties("dbName"); + // String dbPassword = reg.getString("ORACEL_PASSWORD");// + // Util.getProperties("dbPassword"); + + if (driver_temp == null || url == null || dbName == null + || dbPassword == null) { + + MessageBox.post("请检查数据库首选项是否配置正确", "错误提示", MessageBox.ERROR); + + } + // else{ + // MessageBox.post(driver_temp+" | "+url+" | "+dbName+" | "+dbPassword,"错误提示",MessageBox.ERROR); + // + // } + System.out.println(url + dbName + dbPassword); + connection = DriverManager.getConnection(url, dbName, dbPassword); + connection.setAutoCommit(false); + } catch (SQLException e) { + System.out.println("ORACEL CONNECT EXCEPTION"); + e.printStackTrace(); + return null; + // MessageBox.post("ORACEL CONNECT EXCEPTION \n"+e.getMessage(),"ERROR",MessageBox.ERROR); + } + return connection; + } + + /** + * 链接数据库 + */ + public static Connection getConnection() { + try { + String driver_temp = "oracle.jdbc.driver.OracleDriver"; + String url = "jdbc:oracle:thin:@192.168.1.248:1521:TOPPROD";// getProperties("URL"); + String dbName = "jfgroup";// Util.getProperties("dbName"); + String dbPassword = "jfgroup";// Util.getProperties("dbPassword"); + + /* + * if(driver_temp == null ||url==null|| dbName == null ||dbPassword + * == null ){ + * + * MessageBox.post("请检查数据库首选项是否配置正确","错误提示",MessageBox.ERROR); + * + * } + */ + System.out.println(url + dbName + dbPassword); + connection = DriverManager.getConnection(url, dbName, dbPassword); + connection.setAutoCommit(false); + } catch (SQLException e) { + System.out.println("ORACEL CONNECT EXCEPTION"); + e.printStackTrace(); + return null; + // MessageBox.post("ORACEL CONNECT EXCEPTION \n"+e.getMessage(),"ERROR",MessageBox.ERROR); + } + return connection; + } + + /** + * 链接数据库 + */ + public static Connection getConnection(String url, String dbName, + String dbPassword) { + try { + String driver_temp = "oracle.jdbc.driver.OracleDriver"; + + System.out.println(url + dbName + dbPassword); + connection = DriverManager.getConnection(url, dbName, dbPassword); + connection.setAutoCommit(false); + } catch (SQLException e) { + // MessageBox.post("MSG ==>"+url + dbName + dbPassword,"",1); + System.out.println("ORACEL CONNECT EXCEPTION"); + e.printStackTrace(); + MessageBox.post(" MSG = >" + e.getMessage(), "222", 1); + // MessageBox.post("ORACEL CONNECT EXCEPTION \n"+e.getMessage(),"ERROR",MessageBox.ERROR); + return null; + } + return connection; + } + + /** + * 链接TC数据库 + */ + public static Connection getTCConnection() { + try { + if(connection == null || connection.isClosed()) + { + SqlUtilT.getConnectionTC13(); +// SqlUtilT.getConnectionTC12(); +// SqlUtilT.getConnection("jdbc:Oracle:thin:@localhost:1521:TC10","tc10", "infodba"); + } + } catch (Exception e) { + // MessageBox.post("MSG ==>"+url + dbName + dbPassword,"",1); + System.out.println("ORACEL CONNECT EXCEPTION"); + e.printStackTrace(); + MessageBox.post(" MSG = >" + e.getMessage(), "222", 1); + // MessageBox.post("ORACEL CONNECT EXCEPTION \n"+e.getMessage(),"ERROR",MessageBox.ERROR); + return null; + } + return connection; + } + + /** + * 拼接SELECT 语句 + * + * @param tableName + * @param selectElement + * @param args + * @return + */ + public static String getSelectSql(String tableName, String[] selectElement, + String... args) { + StringBuffer valuesSB = new StringBuffer("SELECT "); + if (selectElement != null) { + for (String element : selectElement) { + valuesSB.append(element).append(","); + } + valuesSB.delete(valuesSB.length() - 1, valuesSB.length()); + } + valuesSB.append(" FROM "); + valuesSB.append(tableName); + valuesSB.append(" WHERE"); + for (int i = 0; i < args.length; i++) { + valuesSB.append(" "); + valuesSB.append(args[i]); + valuesSB.append("=? "); + valuesSB.append("AND"); + } + + valuesSB.delete(valuesSB.length() - 3, valuesSB.length()); + return valuesSB.toString(); + } + + /** + * 拼接SELECT 语句 + * + * @param tableName + * @param args + * @return + */ + public static String getSelectSql(String tableName, String... args) { + StringBuffer valuesSB = new StringBuffer("SELECT * FROM "); + valuesSB.append(tableName); + valuesSB.append(" WHERE"); + for (int i = 0; i < args.length; i++) { + valuesSB.append(" "); + valuesSB.append(args[i]); + valuesSB.append("=? "); + valuesSB.append("AND"); + } + + valuesSB.delete(valuesSB.length() - 3, valuesSB.length()); + return valuesSB.toString(); + } + + /** + * 拼接更新语句 + * + * @param tableName + * @param args + * @param args2 + * @return + */ + public static String getUpdataSQL(String tableName, String[] args, + String[] args2) { + StringBuffer updateSB = new StringBuffer("UPDATE "); + updateSB.append(tableName); + updateSB.append(" SET "); + // 拼接更新语句 + for (int i = 0; i < args.length; i++) { + if (args[i].toUpperCase().equals("CREATED_DATE") + || args[i].toUpperCase().equals("LAST_UPDATE_DATE")) { + updateSB.append(args[i]).append( + "=to_date(?,'yyyy-MM-dd HH24:mi:ss') ,"); + } else { + updateSB.append(args[i]).append("=? ,"); + } + } + updateSB.delete(updateSB.length() - 2, updateSB.length()); + ; + updateSB.append(" WHERE "); + for (int i = 0; i < args2.length; i++) { + updateSB.append(args2[i]).append("=? AND "); + } + updateSB.delete(updateSB.length() - 4, updateSB.length()); + return updateSB.toString(); + } + + /** + * 拼接SQL的insert语句 + * + * @param tableName + * @param args + * @return + */ + public static String getInsertSql(String tableName, String... args) { + StringBuffer insertSql = new StringBuffer("insert into "); + StringBuffer values = new StringBuffer("values("); + + if (tableName != null && args != null && args.length > 0) { + insertSql.append(tableName); + insertSql.append("("); + for (int i = 0; i < args.length; i++) { + insertSql.append(args[i]); + insertSql.append(", "); + if (args[i].toUpperCase().equals("LAST_UPDATE_DATE") + || args[i].toUpperCase().equals("CREATED_DATE")) { + values.append("to_date(?,'yyyy-MM-dd HH24:mi:ss'), "); + } else { + values.append("?, "); + } + + } + } else { + return null; + } + insertSql.delete(insertSql.length() - 2, insertSql.length()); + values.delete(values.length() - 2, values.length()); + insertSql.append(") ").append(values).append(")"); + return insertSql.toString(); + } + + /** + * 得到创建表格数据库语句 + * + * @param tableName + * @param args + * 参数的名称 + * @param args2 + * 参数的类型 + * @return 拼接后的创建数据库的语句 + */ + public final static String GetCreateTableSQL(String tableName, + String[] args, String[] args2) { + + if (args == null || args2 == null || args.length != args2.length) { + System.out.println("THE INPUT PRAGREMS IS ERROR"); + return null; + } + StringBuffer createSQL = new StringBuffer("create table "); + createSQL.append(tableName); + createSQL.append("("); + for (int i = 0; i < args.length; i++) { + createSQL.append(args[i] + " "); + createSQL.append(args2[i] + ", "); + } + createSQL.delete(createSQL.length() - 2, createSQL.length()); + createSQL.append(")"); + return createSQL.toString(); + } + + /** + * 得到Statement + */ + public final static PreparedStatement getPs(String sql) throws SQLException { + return getPs(sql, null); + } + + /** + * 得到Statement + */ + public final static PreparedStatement getPs(Object[] argments, String sql) + throws SQLException { + return getPs(sql, argments); + } + + /** + * 得到Statement + */ + public final static PreparedStatement getPs(String sql, Object[] argments) + throws SQLException { + SqlUtilT.ps = SqlUtilT.connection.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY); + SqlUtilT.ps.setFetchSize(1000); + SqlUtilT.ps.setFetchDirection(ResultSet.FETCH_REVERSE); + + if (argments != null) { + for (int i = 0; i < argments.length; i++) { + SqlUtilT.ps.setObject(i + 1, argments[i]); + } + } + return SqlUtilT.ps; + } + + /** + * 增加 + */ + public final static int write(String sql) { + return write(sql, null); + } + + /** + * 增加 + */ + public final static int write(Object[] argments, String sql) { + return write(sql, argments); + } + + /** + * 增加 + */ + public final static int write2(Object[] argments, String sql) { + return write2(sql, argments); + } + + /** + * 增加 + */ + public final static int write(String sql, Object[] argments) { + + return update(sql, argments); + } + + /** + * 增加 + */ + public final static int write2(String sql, Object[] argments) { + + return update2(sql, argments); + } + + /** + * 删除 + */ + public final static int delete(String sql) { + return delete(sql, null); + } + + /** + * 删除 + */ + public final static int delete(Object[] argments, String sql) { + return delete(sql, argments); + } + + /** + * 删除 + */ + public final static int delete(String sql, Object[] argments) { + return update(sql, argments); + } + + /** + * 删除 + */ + public final static int delete2(String sql) { + int i = -1; + try { + i = SqlUtilT.getPs(null,sql).executeUpdate(); + SqlUtilT.connection.commit(); + } catch (SQLException e) { + e.printStackTrace(); + } + return i; + } + + /** + * 修改 + */ + public final static int update(String sql) { + return update(sql, null); + } + + /** + * 修改 + */ + public final static int update(String[] argments, String sql) { + return update(sql, argments); + } + + /** + * 修改(增删改最终都要调用此方法,此处进行异常处理,关闭除Connection以外的对象),不提交事务 + */ + public final static int update2(String sql, Object[] argments) { + int i = -1; + try { + PreparedStatement statement=null; + while(statement==null) { + statement=SqlUtilT.getPs(argments, sql); + if(statement==null) { + getTCConnection(); + System.out.println("+++++++++++++++++statement为空"); + } + } + i = statement.executeUpdate(); + //i = SqlUtilT.getPs(argments, sql).executeUpdate(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + free(SqlUtilT.rs, SqlUtilT.ps); + } + return i; + } + + /** + * 修改(增删改最终都要调用此方法,此处进行异常处理,关闭除Connection以为的对象) + */ + public final static int update(String sql, Object[] argments) { + int i = -1; + try { + PreparedStatement statement=null; + while(statement==null) { + statement=SqlUtilT.getPs(argments, sql); + if(statement==null) { + getTCConnection(); + System.out.println("+++++++++++++++++statement为空"); + } + } + i = statement.executeUpdate(); + //i = SqlUtilT.getPs(argments, sql).executeUpdate(); + SqlUtilT.connection.commit(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + free(SqlUtilT.rs, SqlUtilT.ps); + } + return i; + } + + /** + * 查询 + */ + public final static ResultSet read(String sql) throws SQLException { + return read(sql, null); + } + + /** + * 查询 + */ + public final static ResultSet read(Object[] argments, String sql) + throws SQLException { + return read(sql, argments); + } + + /** + * 查询(所有查询最终都要调用此方法,方法里面不处理异常,抛出后由调用者处理,方便在finally语句中释放资源) + * + * @throws SQLException + */ + public final static ResultSet read(String sql, Object[] argments) + throws SQLException { + return SqlUtilT.rs = SqlUtilT.getPs(argments, sql).executeQuery(); + } + + /** + * 创建表 + */ + public final static boolean createTable(String sql) { + return go(sql, null); + } + + /** + * 删除表 + */ + public final static boolean dropTable(String sql) { + return go(sql, null); + } + + /** + * 修改表 + */ + public final static boolean alterTable(String sql) { + return go(sql, null); + } + + /** + * 此方法用来执行DDL语句(创建表,修改表,删除表) + */ + private final static boolean go(String sql, Object[] argments) { + boolean flag = false; + try { + flag = SqlUtilT.getPs(sql, argments).execute(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + free(SqlUtilT.rs, SqlUtilT.ps); + } + if (flag) { + try { + SqlUtilT.connection.commit(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + return flag; + } + + /** + * 释放资源 + */ + public final static void free(ResultSet resultSet) { + free(resultSet, null, null); + } + + /** + * 释放资源 + */ + public final static void free(Statement statement) { + free(null, statement, null); + } + + /** + * 释放资源 + */ + public final static void free(Connection connection) { + free(null, null, connection); + } + + /** + * 释放资源 + */ + public final static void free(ResultSet resultSet, Statement statement) { + free(resultSet, statement, null); + } + + /** + * 释放资源 + */ + public final static void free(Statement statement, Connection connection) { + free(null, statement, connection); + } + + /** + * 释放资源(不传参数默认部分) + */ + public final static void free() { + free(SqlUtilT.rs, SqlUtilT.ps); + } + + /** + * 释放资源(全部释放) + */ + public final static void freeAll() { + free(SqlUtilT.rs, SqlUtilT.ps, SqlUtilT.connection); + } + + /** + * 释放资源(传满参数也要全部释放) + */ + public final static void free(ResultSet resultSet, Statement statement, + Connection connection) { + try { + if (resultSet != null) { + try { + resultSet.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } finally { + try { + if (statement != null) { + try { + statement.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } finally { + if (connection != null) { + try { + connection.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + } + } +} diff --git a/src/com/connor/zf/utils/TCUtil.java b/src/com/connor/zf/utils/TCUtil.java new file mode 100644 index 0000000..e9dbc7b --- /dev/null +++ b/src/com/connor/zf/utils/TCUtil.java @@ -0,0 +1,454 @@ +package com.connor.zf.utils; + +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Toolkit; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Vector; + +import javax.swing.JFileChooser; +import javax.swing.JTable; +import javax.swing.filechooser.FileNameExtensionFilter; +import javax.swing.filechooser.FileSystemView; + +import org.apache.poi.xwpf.usermodel.XWPFDocument; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.commands.open.OpenFormDialog; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentContextList; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCComponentPseudoFolder; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCQueryClause; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TCUtil { + public static final int MINWIDTH = 1280; + public static final int MINHEIGHT = 768; + + public static 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 static 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 static TCComponentBOMWindow getWindow(TCSession session) throws Exception{ + TCComponentBOMWindow window = null; + TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + window = bomWinType.create(null); + return window; + } + + @SuppressWarnings("deprecation") + public static TCComponentBOMLine getBOMLine(TCSession session,TCComponentBOMWindow window, TCComponentItemRevision revision) + throws Exception { + window.lock(); + TCComponentBOMLine bomLine = window.setWindowTopLine(null, revision, null, null); + window.save(); + window.unlock(); + return bomLine; + } + public static TCComponentPseudoFolder getPseudoFolder(TCComponent parent, String relation) + throws Exception { + TCComponentPseudoFolder pseudoFolder = null; + AIFComponentContext[] comps = parent.getChildren(); + if (comps != null && comps.length > 0 && comps[0] != null) { + for (int i = 0; i < comps.length; i++) { + TCComponent comp = (TCComponent) comps[i].getComponent(); + if (comp instanceof TCComponentPseudoFolder) { + if (comp.isTypeOf("PseudoFolder")) { +// System.out.println("PseudoFolder type:" + comp.getDefaultPasteRelation()); + if (comp.getDefaultPasteRelation().equalsIgnoreCase(relation)) { + pseudoFolder = (TCComponentPseudoFolder) comp; + break; + } + } + } + } + } + return pseudoFolder; + } + public static TCComponentForm getItemRevisionMasterForm(TCComponentItemRevision revision) throws Exception { + if (revision != null) { + AIFComponentContext[] contexts = revision.getChildren("IMAN_master_form_rev"); + if (contexts != null && contexts.length > 0) { + InterfaceAIFComponent component = contexts[0].getComponent(); + if (component instanceof TCComponentForm) { + return (TCComponentForm) component; + } + } + } + return null; + } + public static TCComponentItemRevision getRevisionFromMaster(TCComponentForm form) throws Exception { + if (form != null) { + AIFComponentContext[] contexts = form.whereReferencedByTypeRelation(null, new String[] { "IMAN_master_form_rev" }); + if (contexts != null && contexts.length > 0) { + InterfaceAIFComponent component = contexts[0].getComponent(); + if (component instanceof TCComponentItemRevision) { + return (TCComponentItemRevision) component; + } + } + } + return null; + } + + public static LinkedHashMap getlovValues(TCSession session, String lovName) throws TCException { + LinkedHashMap lovVal = new LinkedHashMap(); + TCComponentListOfValuesType lovType = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValues"); + TCComponentListOfValues[] lovs = lovType.find(lovName); + if (lovs != null && lovs.length > 0) { + TCComponentListOfValues lov = lovs[0]; + ListOfValuesInfo lovInfo = lov.getListOfValues(); + String[] code = lovInfo.getStringListOfValues(); + String[] name = lovInfo.getLOVDisplayValues(); + if (code != null && name != null) { + for (int i = 0; i < code.length; i++) { + // System.out.printf("code[%d]=%s name[%d]=%s \n", i, code[i], i, name[i]); + lovVal.put(code[i], name[i]); + } + } + return lovVal; + } + return null; + } + + public static String getTableValue(JTable table, int row, int col){ + Object val = table.getValueAt(row, col); + if(val==null) + return ""; + else + return val.toString(); + } + public static TCComponent[] query(TCSession session, String queryName, String[] aKey, String[] aVal) throws Exception { + TCComponentQueryType imanQueryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery imancomponentquery = (TCComponentQuery) imanQueryType.find(queryName); + if (imancomponentquery == null) { + throw new Exception("未找到查询构建器 " + queryName + "!"); + } + aKey = session.getTextService().getTextValues(aKey); +// for (int i = 0; i < aKey.length; i++) { +// System.out.println(aKey[i] + "===============" + aVal[i]); +// } + TCComponentContextList componentContextList = imancomponentquery.getExecuteResultsList(aKey, aVal); + return componentContextList.toTCComponentArray(); + } + public static TCComponent[] query(TCSession session, String queryName, Vector Keys, Vector Vals) throws Exception { + TCComponentQueryType imanQueryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery imancomponentquery = (TCComponentQuery) imanQueryType.find(queryName); + if (imancomponentquery == null) { + System.out.println("未找到查询构建器" + queryName); + throw new Exception("Query:"+queryName+" cannot find"); + } + TCQueryClause[] qc = imancomponentquery.describe(); +// for(TCQueryClause c : qc) { +// String key = c.getUserEntryNameDisplay(); +// String value = c.getDefaultValue(); +// if(!value.trim().isEmpty() && !Keys.contains(key)) { +// if(key.isEmpty()) +// Keys.add(c.getAttributeName()); +// else +// Keys.add(key); +// Vals.add(value); +// } +// } + int size = Keys.size(); + String[] keyA = new String[size]; + String[] valueA = new String[size]; + for(int i=0; i 0) { + Integer maxId = 0; + for (TCComponent comp : comps) { + String pid = comp.getProperty("item_id"); + System.out.println("pid:" + pid); + String pidSuffix = pid.substring(pid.length() - 3); + if (Integer.parseInt(pidSuffix) > maxId) { + maxId = Integer.parseInt(pidSuffix); + } + } + return String.format("%03d", maxId + 1); + } + return "001"; + } + + public static File saveExcelChooser() { + File dir = null; + JFileChooser chooser = new JFileChooser(); + chooser.setAcceptAllFileFilterUsed(false); +// File currentDir = FileSystemView.getFileSystemView().getDefaultDirectory(); + File desktopDir = FileSystemView.getFileSystemView().getHomeDirectory(); + chooser.setCurrentDirectory(desktopDir); + String saveType[] = { "xlsx" }; + chooser.setFileFilter(new FileNameExtensionFilter("Excel工作簿", saveType)); + int returnVal = chooser.showSaveDialog(new Frame()); + if (returnVal == JFileChooser.APPROVE_OPTION) { + dir = chooser.getSelectedFile(); + String path = dir.getPath(); + if(!path.toLowerCase().endsWith(".xlsx")) { + path += ".xlsx"; + dir = new File(path); + } + System.out.println("saveExcelChooser1:" + path); + } + return dir; + } + + public static File saveExcelChooser(String defaultFile) { + File dir = null; + JFileChooser chooser = new JFileChooser(); + chooser.setAcceptAllFileFilterUsed(false); +// File currentDir = FileSystemView.getFileSystemView().getDefaultDirectory(); + File desktopDir = FileSystemView.getFileSystemView().getHomeDirectory(); + chooser.setCurrentDirectory(desktopDir); + chooser.setSelectedFile(new File(defaultFile)); + String saveType[] = { "xlsx" }; + chooser.setFileFilter(new FileNameExtensionFilter("Excel工作簿", saveType)); + int returnVal = chooser.showSaveDialog(new Frame()); + if (returnVal == JFileChooser.APPROVE_OPTION) { + dir = chooser.getSelectedFile(); + String path = dir.getPath(); + if(!path.toLowerCase().endsWith(".xlsx")) { + path += ".xlsx"; + dir = new File(path); + } + if(dir.exists()) + dir.delete(); +// System.out.println("saveExcelChooser1:" + dir.getPath()); + } + return dir; + } + + public static boolean contains(String[] array, String str) { + for(String s : array) { +// System.out.println("contains:"+s+"="+str); + if(s.equals(str)) + return true; + } + return false; + } + + public static Map executeToMap(InputStream in){ + System.out.println("Read properties file"); + try { + BufferedReader reader = new BufferedReader(new InputStreamReader(in, "utf-8")); + String line = null; + Map resultMap = new LinkedHashMap<>(16); + if (reader.ready()) { + while (null != (line = reader.readLine())) { + if (line.length() <= 0 || line.contains("#") || !line.contains("=")) { + continue; + } + resultMap.put(line.substring(0, line.indexOf("=")), line.substring(line.indexOf("=") + 1)); + } + } + in.close(); + reader.close(); + return resultMap; + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post("Find properties file failed", "ERROR", MessageBox.ERROR); + } + return null; + } + + public static TCComponentDataset createExcelDataset(TCSession session, File file, String datasetName) throws Exception { + String refType = null, objType = null, fileName = null; + fileName = file.getName().toLowerCase(); + if (fileName.endsWith("xls")) { + refType = "excel"; + objType = "MSExcel"; + } else if (fileName.endsWith("xlsx")) { + refType = "excel"; + objType = "MSExcelX"; + } + TCComponentDatasetType compType = (TCComponentDatasetType) session.getTypeService().getTypeComponent("Dataset"); + TCComponentDataset dataset = compType.create(datasetName, "description", objType); + dataset.setFiles(new String[] { file.getAbsolutePath() }, new String[] { refType }); + return dataset; + } + + public static Vector getChildren(TCComponent parent, String relation, String name) throws Exception { + Vector result = new Vector<>(); + AIFComponentContext[] children; + if(relation==null || relation.isEmpty()) + children = parent.getChildren(); + else + children = parent.getChildren(relation); + for(AIFComponentContext c : children) { + TCComponent comp = (TCComponent) c.getComponent(); + if(comp.getProperty("object_name").equals(name)) + result.add(comp); + } + return result; + } + + /** + * 为查询结果重新排序 + * TCComponent:查询结果数组 property:按照该属性排序 + */ + public static TCComponent[] TCsort(TCComponent[] TCComponent, String property, int desc) { + 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()) * desc; + } + }); + TCComponent = new TCComponent[count]; + int i=0; + for(Map.Entry mapping : list) { + TCComponent[i] = mapping.getKey(); + i++; + } + return TCComponent; + } + public static TCComponent[] TCsort(TCComponent[] TCComponent, int[] desc, String... property) { + HashMap map = new HashMap<>(); + int count = TCComponent.length; + for(TCComponent Component : TCComponent) { + try { + String[] values = new String[property.length]; + for(int i=0; i> list = new ArrayList>(map.entrySet()); + // 通过比较器实现比较排序 + Collections.sort(list, new Comparator>() { + public int compare(Map.Entry mapping1, Map.Entry mapping2) { + String[] v1 = mapping1.getValue(), v2 = mapping2.getValue(); + for(int i=0; i mapping : list) { + TCComponent[i] = mapping.getKey(); + i++; + } + return TCComponent; + } + + public static void deleteWarning(File file) throws Exception { + FileInputStream input = null; + FileOutputStream output = null; + try { + input = new FileInputStream(file); + XWPFDocument doc = new XWPFDocument(input); +// XWPFParagraph para = doc.getParagraphs().get(0); +// System.out.println("para.getRuns:"+para.getRuns().size()); +// for(XWPFRun run : para.getRuns()) { +// System.out.println("run:"+run.getText(0)); +// } + doc.removeBodyElement(0); +// para.removeRun(0); +// System.out.println("para.getRuns:"+para.getRuns().size()+" getParagraphs:"+doc.getParagraphs().get(0).getText()); +// para.setPageBreak(false); + output = new FileOutputStream(file.getPath()); + doc.write(output); + }catch (Exception e) { + throw e; + }finally { + if(input!=null) + input.close(); + if(output!=null) + output.close(); + } + } +} \ No newline at end of file diff --git a/src/com/connor/zf/utils/TMomFinalUtil.java b/src/com/connor/zf/utils/TMomFinalUtil.java new file mode 100644 index 0000000..74789a7 --- /dev/null +++ b/src/com/connor/zf/utils/TMomFinalUtil.java @@ -0,0 +1,106 @@ +package com.connor.zf.utils; + +public class TMomFinalUtil { + // ---------------ALL---------------------------------------------- + public static final String PROCESS_MODEL_FILE = "PROCESS_MODEL_FILE";// 工艺模板文件 + // ---------------TMom001---------------------------------------------- + public static final int CX_INSTRUCTION = 0;// 成形作业指导书代号 + public static final int ZX_INSTRUCTION = 1;// 整形作业指导书代号 + public static final int SJ_INSTRUCTION = 2;// 烧结作业指导书代号 + public static final int PS_INSTRUCTION = 3;// 喷砂作业指导书代号 + public static final int GS_INSTRUCTION = 4;// 光饰作业指导书代号 + public static final int ST_INSTRUCTION = 5;// ST处理作业指导书代号 + + public static final int ELDECRCL_INSTRUCTION = 6;// Eldec热处理工艺指导书代号 + public static final int BZDXMJ_INSTRUCTION = 7;// 半自动修毛机工艺指导书代号 + public static final int GSJ_INSTRUCTION = 8;// 攻丝机工艺指导书 + public static final int JJG_INSTRUCTION = 9;// 机加工工艺指导书代号 + public static final int PTRCL_INSTRUCTION = 10;// 普通热处理工艺指导书代号 + public static final int TZ_INSTRUCTION = 11;// 台钻工艺指导书代号 + public static final int TGSXMJ_INSTRUCTION = 12;// 通过式修毛机工艺指导书代号 + public static final int TYMC_INSTRUCTION = 13;// 通用磨床工艺指导书代号 + public static final int WXM_INSTRUCTION = 14;// 无心磨工艺指导书代号 + public static final int YZ_INSTRUCTION = 15;// 压装工艺指导书代号 + public static final int TS_INSTRUCTION = 16;//探伤作业指导书 + public static final int CC_INSTRUCTION = 9;//车床工艺指导书 + public static final int JGZX_INSTRUCTION = 9;//加工中心工艺指导书 + + public static final int WG_INSTRUCTION = 17;//外观作业指导书 + + + // ---------------TMom002---------------------------------------------- + public static final int GY_CODE = 0;// 工艺代号 + public static final int HISGY_CODE = 2;// 历史工艺代号 + public static final int GX_CODE = 1;// 工序代号 + public static final int GYTZ_CODE = 3;//工艺图纸代号 + public static final int BZGX_CODE = 4;// 工序代号 + + public static final String GY_TYPE_DIS = "工艺";// 工艺类型 + public static final String GY_TYPE = "MEProcess"; + + public static final String HISGY_TYPE_DIS = "工艺";// 工艺类型 + public static final String HISGY_TYPE = "MEProcess"; + + public static final String GX_TYPE_DIS = "工序";// 工序类型 + public static final String GX_TYPE = "MEOP"; + + public static final String GYTZ_TYPE = "RB3_TEdrawing";//工艺图纸类型 + public static final String GYTZ_TYPE_DIS = "工艺图纸"; + + public static final String GY_ITEM_NAMES = "GY_ITEM_NAMES";// 工艺对象名称下拉列表 + public static final String GX_ITEM_NAMES = "GX_ITEM_NAMES";// 工序对象名称下拉列表 + + // ---------------TMom014---------------------------------------------- + public static final int CXSJTY_CHECKTABLE = 0; //成形首检调试记录表(通用) 烧结首件 200 AjQtFS$T4iZo5B 工序质量检查表(烧结) + public static final int CXSJCNCZY_CHECKTABLE = 0; //成形首检调试记录表(CNC专用) + public static final int CXGCJ_CHECKTABLE = 1; //成形工序过程自检记录表(操作工) 整形工序过程自检记录表(操作工) 101 + public static final int CXMJ_CHECKTABLE = 2; //成形末件记录表 整形末件记录表 102 + public static final int CXXJ_CHECKTABLE = 3; //成形工序巡检检查表 整形工序巡检检查表 103 + public static final int ZX_CHECKTABLE = 4; //精整工序产品批量生产记录单(批准单) + public static final int JJGSJ_CHECKTABLE = 5; //机加工科产品首件检查表 + public static final int JJGGCJ_CHECKTABLE = 6; //机加工科产品过程质量检查表 + public static final int JJGMJ_CHECKTABLE = 7; //机加工科产品末件检查表 + public static final int MKSJ_CHECKTABLE = 8; //盲孔感应淬火批次首件批准单 + public static final int MKGCJ_CHECKTABLE = 9; //盲孔感应淬火过程检验记录表 + public static final int MKMJ_CHECKTABLE = 10;//盲孔感应淬火批次末件记录单 + public static final int GXZL_CHECKTABLE = 11;//工序质量检查表-按时间 + public static final int ZZ_CHECKTABLE = 12;//最终检查表 + public static final int CPZL_CHECKTABLE = 13;//产品质量检查表 + public static final int JJGHDSJ_CHECKTABLE = 14;//机加工换刀首检验检查表 + public static final int JJGHDMJ_CHECKTABLE = 15;//机加工换刀末检验检查表 + public static final int GXZLPC_CHECKTABLE = 16;//工序质量检查表-按批次 + + + // ---------------TMom017---------------------------------------------- + public static final String BZFS_COMBOBOX_VALUES = "BZFS_COMBOBOX_VALUES"; //包装方式下拉菜单 + public static final String QYFS_COMBOBOX_VALUES = "QYFS_COMBOBOX_VALUES"; //油方式下拉菜单 + public static final String OUTERBOX_COMBOBOX_VALUESS = "OUTERBOX_COMBOBOX_VALUESS";//外箱标签下拉菜单 + public static final String STORAGETRAY_COMBOBOX_VALUES = "STORAGETRAY_COMBOBOX_VALUES";//入库托盘下拉菜单 + public static final String CARRIAGEPACK_COMBOBOX_VALUES = "CARRIAGEPACK_COMBOBOX_VALUES";//运输包装类型下拉菜单 + public static final String PACKAGING_COMBOBOX_VALUES = "PACKAGING_COMBOBOX_VALUES";//打包方式下拉列表框 + public static final String PALLETSPEC_COMBOBOX_VALUES = "PALLETSPEC_COMBOBOX_VALUES";//托盘规格下拉列表框 + public static final String METHODSREINFORCEMENT_COMBOBOX_VALUES = "METHODSREINFORCEMENT_COMBOBOX_VALUES";//加固方式下拉列表框 + + //---------------TMom019----------------------------------------------- + //public static final int AIXING_CONTROL = 0;// 爱信控制计划代号 + public static final int AIXING_CHINESE_CONTROL = 0;// 爱信中文控制计划代号 + public static final int AIXING_ENGLISH_CONTROL = 1;// 爱信英文控制计划代号 + public static final int AIXING_CHINESE_ENGLISH_CONTROL = 2;// 爱信中英文控制计划代号 + //public static final int BOGEHUALAEN_CONTROL = 1;// 英文博格华纳控制计划代号 + public static final int BOGEHUALAEN_CHINESE_CONTROL = 3;// 博格华纳中文控制计划代号 + public static final int BOGEHUALAEN_ENGLISH_CONTROL = 4;// 博格华纳英文控制计划代号 + public static final int BOGEHUALAEN_CHINESE_ENGLISH_CONTROL = 5;// 博格华纳中英文控制计划代号 + //public static final int BOGEHUALAZH_CONTROL = 2;// 中午博格华纳控制计划代号 + //public static final int MAIGELA_CONTROL = 3;// 麦格纳控制计划代号 + public static final int MAIGELA_CHINESE_CONTROL = 6;// 麦格纳中文控制计划代号 + public static final int MAIGELA_ENGLISH_CONTROL = 7;// 麦格纳英文控制计划代号 + public static final int MAIGELA_CHINESE_ENGLISH_CONTROL = 8;// 麦格纳中英文控制计划代号 + + public static final int NBTM_CHINESE_CONTROL = 9;//东睦中文控制计划代号 + public static final int NBTM_ENGLISH_CONTROL = 10;// 东睦英文控制计划代号 + public static final int NBTM_CHINESE_ENGLISH_CONTROL = 11;// 东睦中英文控制计划代号 + + + + +} diff --git a/src/com/connor/zf/utils/TMomMethodUtil.java b/src/com/connor/zf/utils/TMomMethodUtil.java new file mode 100644 index 0000000..47099f1 --- /dev/null +++ b/src/com/connor/zf/utils/TMomMethodUtil.java @@ -0,0 +1,1386 @@ +package com.connor.zf.utils; + +import java.io.File; +import java.io.IOException; +import java.text.DecimalFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.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.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentProcess; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCComponentType; +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.TCQueryClause; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTextService; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.util.FileUtility; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.services.rac.core.DataManagementService; + +public class TMomMethodUtil { + + private static List> bomPropertyList = new ArrayList>(); + + public static void main(String[] args) { + String str = "123|1234|123124"; + System.out.println(str.split("\\|").length); + } + + /** + * 判断获取的对象是否全部为ITEM + * + * @param comps + * 需要判断的目标对象 + * @param isNotIgor + * 是否需要忽略,如果TRUE 则不能忽略,如果FALSE 则可以忽略 + * + * @param isSameType + * 是否要求是相同的类型,如果TRUE 要求必须是相同的类型 + * @return + */ + public static List getItemList( + InterfaceAIFComponent[] comps, Boolean isNotIgor, Boolean isSameType) { + if (comps == null) { + + return null; + } + List itemList = new ArrayList(); + String type = null; + for (int i = 0; i < comps.length; i++) { + if (comps[i] instanceof TCComponentItem) { + if (isSameType) { + if (type == null) { + type = comps[i].getType(); + } else if (!type.equals(comps[i].getType())) { + return null; + } + } + itemList.add((TCComponentItem) comps[i]); + } else if (isNotIgor) { + return null; + } + } + return itemList; + } + + /** + * 获取模板文件 + * @param session session + * @param fileName 文件名 + * @param Filetype 文件类型 + * @return + */ + public static File getFile(TCSession session,String fileName,String Filetype) { + // TODO Auto-generated method stub + try { + TCPreferenceService service = session.getPreferenceService(); + String[] modelFiles = service.getStringValues(TMomFinalUtil.PROCESS_MODEL_FILE); + if (modelFiles == null) + { + System.out.println("未找到首选项"); + return null; + } + String puid = ""; + for (int i = 0; i < modelFiles.length; i++) { + if(modelFiles[i].split("-")[0].equals(fileName)) + { + puid = modelFiles[i].split("-")[1]; + } + } + TCComponentItem fileItem = (TCComponentItem)session + .stringToComponent(puid); + TCComponentDataset dat = null; + TCComponentItemRevision fileItemLastRev = getLastItemRevision(fileItem); + TCComponent[] comps = fileItemLastRev.getReferenceListProperty("IMAN_specification"); + System.out.println("count =" + comps == null ? "null" + : comps.length); + // 遍历TC_Attaches关系下的所有对象 + for (TCComponent compt : comps) { + // 获取对象类型 + String type = compt.getType(); + System.out.println(" TYPE = " + type); + // 判断类型 + if (type.equals(type)) { + dat = (TCComponentDataset)compt; + } + } + TCComponentTcFile[] tcFile = dat.getTcFiles(); + if(tcFile != null && tcFile.length == 0) + { + System.out.println("未找到配置文件"); + } + else + { + return tcFile[0].getFmsFile(); + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return null; + } + /** + * 获取最新的已发布的版本 + * @param item + * @return + */ + public static TCComponentItemRevision getLastItemRevision(TCComponentItem item) { + // TODO Auto-generated method stub + try { + TCComponentItemRevision[] items = item.getReleasedItemRevisions(); + int revId = 0; + TCComponentItemRevision itemRevision = null; + for (int i = 0; i < items.length; i++) { + String revisionId = items[i].getStringProperty("item_revision_id"); + if(letterToNumber(revisionId) >= revId ) + { + itemRevision = items[i]; + revId = letterToNumber(revisionId); + } + } + return itemRevision; + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + public static int letterToNumber(String letter) { + int length = letter.length(); + int num = 0; + int number = 0; + for(int i = 0; i < length; i++) { + char ch = letter.charAt(length - i - 1); + num = (int)(ch - 'A' + 1) ; + num *= Math.pow(26, i); + number += num; + } + return number; + } + + + + /** + * 获取版本对象 + * + * @param comps + * 需要判断的目标对象 + * @param isNotIgor + * 是否需要忽略,如果TRUE 则不能忽略,如果FALSE 则可以忽略 + * + * @param isSameType + * 是否要求是相同的类型,如果TRUE 要求必须是相同的类型 + * @return + */ + public static List getItemRevList( + InterfaceAIFComponent[] comps, Boolean isNotIgor, Boolean isSameType) { + if (comps == null) { + + return null; + } + List itemList = new ArrayList(); + + String type = null; + for (int i = 0; i < comps.length; i++) { + if (comps[i] instanceof TCComponentItemRevision) { + + if (isSameType) { + if (type == null) { + type = comps[i].getType(); + } else if (!type.equals(comps[i].getType())) { + return null; + } + } + itemList.add((TCComponentItemRevision) comps[i]); + } else if (isNotIgor) { + return null; + } + } + return itemList; + } + + /** + * 获取存放的文件夹 + * + * @param item + * @param name + * @return + */ + public static TCComponentFolder getParentFolder(TCComponentItem item, + String name) { + TCComponentFolder folder = null; + try { + AIFComponentContext[] comtexts = item.whereReferenced(); + if (comtexts != null) { + for (int i = 0; i < comtexts.length; i++) { + if (comtexts[i].getComponent() instanceof TCComponentFolder) { + String nameT = ((TCComponentFolder) comtexts[i] + .getComponent()) + .getStringProperty("object_name"); + if (name.equals("工艺图纸") && nameT.equals("工艺图纸")) { + folder = (TCComponentFolder) comtexts[i] + .getComponent(); + } + else if(nameT.equals(name)) + { + folder = (TCComponentFolder) comtexts[i] + .getComponent(); + } + } + } + } + } catch (TCException e) { + e.printStackTrace(); + } + return folder; + } + + /** + * 获取存在的ITEM的个数 + * + * @param session + * 会话 + * @param oldItemID + * 旧编码 + * @return + */ + public static Integer getItemCount(TCSession session, String oldItemID) { + Integer count = 0; + InterfaceAIFComponent[] comps = searchComponentsCollection(session, + "Connor_TMom_Query_Item", new String[] { "item_id" }, + new String[] { oldItemID }); + if (comps == null) { + return null; + } + count = comps.length; + return count; + } + + /** + * 根据规则获取ID + * + * @param oldItemID + * 旧的ID + * @return 新的ID + */ + public static String getRuleItemID(TCSession session, String oldItemID, + String typeID, int operateCode) { + String newId = null; + // 调用查询 Connor_TMom_Query_Item item_id + // 添加规则 + switch (operateCode) { + case TMomFinalUtil.GY_CODE: + newId = getGyRuleID(session, oldItemID); + break; + case TMomFinalUtil.HISGY_CODE: + newId = getGyRuleID(session, oldItemID); + break; + case TMomFinalUtil.GX_CODE: + newId = getGxRuleID(session, oldItemID); + break; + default: + break; + } + return newId; + } + +// /** +// * 工艺生成新的ID +// * +// * @param oldItemID +// * @return +// */ +// public static String getGyRuleID(TCSession session, String oldItemID) { +// DecimalFormat df = new DecimalFormat("00"); +// String newID = oldItemID + "_MEP01"; +// Integer count = 0; +// // String idTemp = +// TCComponentItemType tccomponentitemtype; +// try { +// tccomponentitemtype = (TCComponentItemType) (session +// .getTypeComponent("Item")); +// +// tccomponentitemtype.getNewID(); +// int i = 1; +// while (tccomponentitemtype.find(newID) != null) { +// i++; +// newID = oldItemID + "_MEP" + df.format(i); +// } +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// return newID; +// } + /** + * 工艺生成新的ID + * + * @param oldItemID + * @return + */ + public static String getGyRuleID(TCSession session, String oldItemID) { + DecimalFormat df = new DecimalFormat("000"); + String newID = oldItemID + "_P001"; + Integer count = 0; + // String idTemp = + TCComponentItemType tccomponentitemtype; + try { + tccomponentitemtype = (TCComponentItemType) (session + .getTypeComponent("Item")); + + tccomponentitemtype.getNewID(); + int i = 1; + //setByPass(session,true); + while (tccomponentitemtype.find(newID) != null) { + i++; + newID = oldItemID + "_P" + df.format(i); + } + // setByPass(session,false); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return newID; + } + +// /** +// * 工序生成新ID +// * +// * @param oldItemID +// * @return +// */ +// public static String getGxRuleID(TCSession session, String oldItemID) { +// DecimalFormat df = new DecimalFormat("000"); +// String newID = oldItemID.substring( +// 0, +// oldItemID.indexOf("_") > 0 ? oldItemID.indexOf("_") : oldItemID +// .length()) +// + "_MEOP001"; +// Integer count = 0; +// // String idTemp = +// TCComponentItemType tccomponentitemtype; +// try { +// tccomponentitemtype = (TCComponentItemType) (session +// .getTypeComponent("Item")); +// int i = 0; +// while (tccomponentitemtype.find(newID) != null) { +// i++; +// newID = oldItemID.substring(0, +// oldItemID.indexOf("_") > 0 ? oldItemID.indexOf("_") +// : oldItemID.length()) +// + "_MEOP" + df.format(i); +// } +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// return newID; +// } + + /** + * 工序生成新ID + * + * @param oldItemID + * @return + */ + public static String getGxRuleID(TCSession session, String oldItemID) { + // DecimalFormat df = new DecimalFormat("000"); + // String newID = oldItemID.substring( +// 0, +// oldItemID.indexOf("_") > 0 ? oldItemID.indexOf("_") : oldItemID +// .length()) +// + "_MEOP001"; + // Integer count = 0; + // String idTemp = + TCComponentItemType tccomponentitemtype; + try { + tccomponentitemtype = (TCComponentItemType) (session + .getTypeComponent("MEOP")); + + return tccomponentitemtype.getNewID(); + // int i = 0; + // while (tccomponentitemtype.find(newID) != null) { +// i++; +// newID = oldItemID.substring(0, +// oldItemID.indexOf("_") > 0 ? oldItemID.indexOf("_") +// : oldItemID.length()) +// + "_MEOP" + df.format(i); + // } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return ""; + } + /** + * 通过SOA创建ITEM对象 + * + * @param session + * 会话 + * @param itemID + * 创建对象的ID + * @param itemRev + * 创建对象的版本 + * @param itemType + * 创建对象的类型 + * @param itemName + * 创建对象的名称 + * @param itemDesc + * 创建对象的描述 + * @param unit + * 创建对象的单位 + * @param itemPropMap + * 创建对象的ITEM属性 + * @param itemRevPropMap + * 创建对象的版本属性 + * @param itemRevMasterPropMap + * 创建对象的版本表单属性 + */ + public static TCComponentItem createNewItemSoa(TCSession session, + String itemID, String itemRev, String itemType, String itemName, + String itemDesc, String unit, Map itemPropMap, + Map itemRevPropMap, + Map itemRevMasterPropMap) { + TCComponentItem newComp = null; + try { + DataManagementService datamanagementservice = DataManagementService + .getService(session); + com.teamcenter.services.rac.core._2006_03.DataManagement.CreateItemsResponse createitemsresponse = null; + // 设置创建对象的主要属性 + com.teamcenter.services.rac.core._2006_03.DataManagement.ItemProperties aitemproperties[] = new com.teamcenter.services.rac.core._2006_03.DataManagement.ItemProperties[1]; + aitemproperties[0] = new com.teamcenter.services.rac.core._2006_03.DataManagement.ItemProperties(); + aitemproperties[0].clientId = Integer.toString(1); + aitemproperties[0].description = itemDesc; + aitemproperties[0].itemId = itemID; + aitemproperties[0].name = itemName; + aitemproperties[0].revId = itemRev; + aitemproperties[0].type = itemType; + aitemproperties[0].uom = unit;// == null ? "" : uomComp.toString(); + // 设置扩展属性 + // com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes + // extendedattributes[] = new + // com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes[3]; + ArrayList list = new ArrayList(); + // 设置item对象的扩展属性 + if (itemPropMap != null) { + com.teamcenter.services.rac.core._2006_03.DataManagement.RevisionIds revids = null; + com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes extendedattributesItem = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes(); + extendedattributesItem = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes(); + extendedattributesItem.objectType = itemType; + extendedattributesItem.attributes = itemPropMap; + list.add(extendedattributesItem); + } + // 设置REV的扩展属性 + if (itemRevPropMap != null) { + com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes extendedattributesRev = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes(); + extendedattributesRev = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes(); + extendedattributesRev.objectType = itemType + "Revision"; + extendedattributesRev.attributes = itemRevPropMap; + list.add(extendedattributesRev); + } + // 设置REVMASTER的扩展属性 + if (itemRevMasterPropMap != null) { + com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes extendedattributesRevMaster = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes(); + extendedattributesRevMaster = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes(); + extendedattributesRevMaster.objectType = itemType + + "RevisionMaster"; + extendedattributesRevMaster.attributes = itemRevMasterPropMap; + list.add(extendedattributesRevMaster); + } + // 添加扩展属性 + if (list.size() != 0) { + com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes extendedattributes[] = null; + extendedattributes = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes[list + .size()]; + for (int i = 0; i < list.size(); i++) { + extendedattributes[i] = list.get(i); + } + aitemproperties[0].extendedAttributes = extendedattributes; + } + TCComponent tccomponent1 = null; + String s1 = ""; + createitemsresponse = datamanagementservice.createItems( + aitemproperties, tccomponent1, s1); + if (createitemsresponse.serviceData.sizeOfPartialErrors() == 0) { + newComp = createitemsresponse.output[0].item; + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + System.out.println("创建对象[item_id= " + itemID + " / rev =" + itemRev + + " / name= " + itemName + "]失败"); + } + return newComp; + } + + /** + * 通过查询,查找符合条件的版本 + * + * @param session + * 会话 + * @param searchName + * 查询名称 + * @param keys + * 查询关键字 + * @param values + * 查询值 + * @return + */ + public static InterfaceAIFComponent[] searchComponentsCollection( + TCSession session, String searchName, String[] keys, String[] values) { + // 信息输出 + InterfaceAIFComponent[] result = new InterfaceAIFComponent[0]; + + try { + TCTextService textService = session.getTextService(); + TCComponentQueryType querytype = (TCComponentQueryType) session + .getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) querytype + .find(searchName); + if (query == null) { + MessageBox.post("通过查询构建器" + searchName + "不存在", "错误", 1); + return null; + } + querytype.clearCache(); + String[] as = new String[keys.length]; + for (int i = 0; i < keys.length; i++) { + as[i] = textService.getTextValue(keys[i]); + } + + String[] as1 = new String[values.length]; + for (int i = 0; i < values.length; i++) { + as1[i] = textService.getTextValue(values[i]); + + } + + query.clearCache(); + TCQueryClause[] clauses = query.describe(); + TCComponentContextList list = query.getExecuteResultsList(as, as1); + + if (list != null) { + int count = list.getListCount(); + result = new InterfaceAIFComponent[count]; + + for (int i = 0; i < count; i++) { + result[i] = list.get(i).getComponent(); + } + } + } catch (TCException e) { + e.printStackTrace(); + MessageBox.post("通过查询构建器" + searchName + "查询发生错误.", "错误", 1); + } + + return result; + } + /** + * 自定义文件名下载文件 + * + * @param comps + * @return + * @throws TCException + * @throws IOException + */ + + public static String downLoadFiles(TCComponent comp,String Titles,String URL,Boolean flag) { + if (comp == null) { + return ""; + } + String value = ""; + String tempPath = System.getenv("TEMP"); + // MessageBox.post(" tempPath = + // "+tempPath,"INFO",MessageBox.INFORMATION); + if (tempPath == null) { + tempPath = ""; + } else if (!tempPath.endsWith("\\")) { + tempPath = tempPath + "\\"; + } + + // MessageBox.post(" tempPath = "+tempPath,"INFO",MessageBox.INFORMATION); + // MessageBox.post(" URL = "+URL,"INFO",MessageBox.INFORMATION); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); + // for(TCComponent comp : comps){ + try { + if (comp instanceof TCComponentDataset) { + TCComponentTcFile[] tcFiles = ((TCComponentDataset) comp) + .getTcFiles(); + File file = null; + if (tcFiles != null && tcFiles.length != 0) { + file = tcFiles[0].getFmsFile(); + String fileName = file.getName(); + String fileDix = fileName.substring( + fileName.lastIndexOf("."), fileName.length()); + if (flag == true) + { + if ((URL != "")&&(URL != " ")&&(URL != null)) + { + fileName = URL + Titles + fileDix; + } + else + { + fileName = tempPath + Titles + fileDix; + } + } + else + { + fileName = tempPath + sdf.format(new Date()) + fileDix; + } + File dirFile = new File(fileName); + FileUtility.copyFile(file, dirFile); + + return fileName; + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // } + return value; + } + + + + + + /** + * 下载文件 + * + * @param comps + * @return + * @throws TCException + * @throws IOException + */ + public static String downLoadFile(TCComponent comp) { + if (comp == null) { + return ""; + } + String value = ""; + String tempPath = System.getenv("TEMP"); + // MessageBox.post(" tempPath = + // "+tempPath,"INFO",MessageBox.INFORMATION); + if (tempPath == null) { + tempPath = ""; + } else if (!tempPath.endsWith("\\")) { + tempPath = tempPath + "\\"; + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); + // for(TCComponent comp : comps){ + try { + if (comp instanceof TCComponentDataset) { + TCComponentTcFile[] tcFiles = ((TCComponentDataset) comp) + .getTcFiles(); + File file = null; + if (tcFiles != null && tcFiles.length != 0) { + file = tcFiles[0].getFmsFile(); + String fileName = file.getName(); + String fileDix = fileName.substring( + fileName.lastIndexOf("."), fileName.length()); + fileName = tempPath + sdf.format(new Date()) + fileDix; + File dirFile = new File(fileName); + FileUtility.copyFile(file, dirFile); + + return fileName; + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // } + return value; + } + + /*** + * 获取首选项 + * + * @param session + * 会话 + * @param preferenceName + * 首选项名称 + * @return + */ + public static String[] getPreferenceValues(String preferenceName) { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + if (preferenceName == null || session == null) { + System.out.println(""); + return null; + } + String[] values = null; + TCPreferenceService service = session.getPreferenceService(); + values = service.getStringArray(TCPreferenceService.TC_preference_site, + preferenceName); + String[] resultValues = new String[values.length]; + for (int i = 0; i < values.length; i++) { + if(values[i].indexOf("\\n") >= 0) + { + resultValues[i] = values[i].replace("\\n", "\n"); + } + else + { + resultValues[i] = values[i]; + } + } + return resultValues; + } + + /** + * 删除文件 + * + * @param filePathList + * 文件地址 + */ + public static void deleteFile(List filePathList) { + for (int i = 0; i < filePathList.size(); i++) { + File file = new File(filePathList.get(i)); + if (file.exists() && file.isFile()) { + if (file.delete()) { + System.out.println("文件" + filePathList.get(i) + "已删除!"); + } + } + } + } + + /** + * 旁路 + * + * @param session + * @param val + * @throws TCException + */ + public static void setByPass(TCSession session, boolean val) + throws TCException { + + TCUserService userservice = session.getUserService(); + + Object[] obj = new Object[1]; + obj[0] = ""; + if (val) { + userservice.call("Connor_set_bypass", obj); + } else { + userservice.call("Connor_close_bypass", obj); + } + } + /** + * 转换合并单元格 + * @param regionCell + * @param row + * @return + */ + public static String getCombineCell(Map regionCell, int row) { + Iterator> it = regionCell.entrySet().iterator(); + StringBuffer sb = new StringBuffer(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + StringBuffer rowSb = new StringBuffer(); + StringBuffer columnSb = new StringBuffer(); + for (int k = 0; k < entry.getKey().length; k++) { + rowSb.append(entry.getKey()[k]); + rowSb.append(","); + } + for (int k = 0; k < entry.getValue().length; k++) { + columnSb.append(entry.getValue()[k]); + columnSb.append(","); + } + if (entry.getKey()[0] == row) { + sb.append(rowSb.substring(0, rowSb.length() - 1)+ "/"+ columnSb.substring(0,columnSb.length() - 1)+"-"); + } + } + if(sb.length() > 0) + { + return sb.toString().substring(0, sb.length()-1); + } + else + { + return ""; + } + } + + /** + * 通知流程 + * + * @param session + * @param val + * @throws TCException + */ + public static void setProcess(TCSession session, + TCComponentProcess process, TCComponentUser user) + throws TCException { + + TCUserService userservice = session.getUserService(); + + Object[] obj = new Object[2]; + obj[0] = process; + obj[1] = user; + userservice.call("TMOM_meop_tongzhi", obj); + } + + /** + * 获取PFMEA BOM属性 + */ + public static List> getPFMEABomPropertys(TCSession session, TCComponentItem item) { + // TODO Auto-generated method stub + //获取BOM + TCComponentBOMWindow bomWindow = null; + bomPropertyList.clear(); + try { + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topBomLine = bomWindow.setWindowTopLine(item, + item.getLatestItemRevision(), null, null); + //获取工艺下的控制计划对象 + TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); + List itme = new ArrayList(); + for (int i = 0; i < kzjh.length; i++) { + if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) + { + itme.add((TCComponentItem)kzjh[i]); + } + } + getBomPropertys(topBomLine, true); + return bomPropertyList; + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return null; + } +// public static List> getPFMEABomPropertys(TCSession session, TCComponentItem item) { +// // TODO Auto-generated method stub +// //获取BOM +// TCComponentBOMWindow bomWindow = null; +// try { +// TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session +// .getTypeComponent("BOMWindow"); +// bomWindow = bomWindowType.create(null); +// TCComponentBOMLine topBomLine = bomWindow.setWindowTopLine(item, +// item.getLatestItemRevision(), null, null); +// //获取工艺下的控制计划对象 +// TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); +// List itme = new ArrayList(); +// for (int i = 0; i < kzjh.length; i++) { +// if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) +// { +// itme.add((TCComponentItem)kzjh[i]); +// } +// } +// // 获取工序对象 +// AIFComponentContext aif[] = topBomLine.getChildren(); +// List> properties = new ArrayList>(); +// for (int i = 0; i < aif.length; i++) { +// TCComponentBOMLine subline = (TCComponentBOMLine) aif[i] +// .getComponent(); +// if(subline.getStringProperty("RB3_is_hide") != null && subline.getStringProperty("RB3_is_hide").equals("true")) +// { +// continue; +// } +// List propertie = new ArrayList(); +// propertie +// .add(subline.getStringProperty("bl_indented_title") +// .split("/")[0]); +// propertie.add(subline.getStringProperty("bl_sequence_no")); +// propertie +// .add(subline +// .getStringProperty("bl_item_object_name") == null ? "" +// : subline +// .getStringProperty("bl_item_object_name")); +// //获取工序下的BOM +// List equipmentNameList = new ArrayList(); +// if(subline.getChildren().length>0) +// { +// for (int j = 0; j < subline.getChildren().length; j++) { +// TCComponentBOMLine subChildrenline = (TCComponentBOMLine) subline.getChildren()[j] +// .getComponent(); +// System.out.println(subChildrenline.getType()); +// if(subChildrenline.getType().indexOf("Equipment") >= 0) +// { +// TCComponentICO[] icos = subChildrenline.getItem().getLatestItemRevision() +// .getClassificationObjects(); +// if (icos.length > 0) { +// ICSProperty[] descriptions = icos[0] +// .getICSProperties(true); +// for (int k = 0; k < descriptions.length; k++) { +// if (descriptions[k].getId() == 1004 && descriptions[k].getValue() != null +// && !descriptions[k].getValue().equals("")) { +// System.out.println(equipmentNameList.toString()); +// if(!equipmentNameList.contains(descriptions[k].getValue())) +// { +// equipmentNameList.add(descriptions[k].getValue()); +// } +// System.out.println(equipmentNameList.toString()); +// //sb.append(descriptions[k].getValue()+","); +// +// } +// } +// } +// } +// } +// } +// if(equipmentNameList.size() > 0) +// { +// propertie.add(equipmentNameList.toString().substring(1, equipmentNameList.toString().length()-1)); +// } +// else +// { +// propertie.add(""); +// } +// properties.add(propertie); +// } +// return properties; +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// return null; +// } + + /** + * 获取BOM属性 + */ + public static List> getBomPropertys(TCSession session, TCComponentItem item) { + // TODO Auto-generated method stub + bomPropertyList.clear(); + //获取BOM + TCComponentBOMWindow bomWindow = null; + try { + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topBomLine = bomWindow.setWindowTopLine(item, + item.getLatestItemRevision(), null, null); + //获取工艺下的控制计划对象 + TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); + List itme = new ArrayList(); + for (int i = 0; i < kzjh.length; i++) { + if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) + { + itme.add((TCComponentItem)kzjh[i]); + } + } + getBomPropertys(topBomLine, false); + return bomPropertyList; + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return null; + } +// public static List> getBomPropertys(TCSession session, TCComponentItem item) { +// // TODO Auto-generated method stub +// //获取BOM +// TCComponentBOMWindow bomWindow = null; +// try { +// TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session +// .getTypeComponent("BOMWindow"); +// bomWindow = bomWindowType.create(null); +// TCComponentBOMLine topBomLine = bomWindow.setWindowTopLine(item, +// item.getLatestItemRevision(), null, null); +// //获取工艺下的控制计划对象 +// TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); +// List itme = new ArrayList(); +// for (int i = 0; i < kzjh.length; i++) { +// if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) +// { +// itme.add((TCComponentItem)kzjh[i]); +// } +// } +// // 获取工序对象 +// AIFComponentContext aif[] = topBomLine.getChildren(); +// List> properties = new ArrayList>(); +// for (int i = 0; i < aif.length; i++) { +// TCComponentBOMLine subline = (TCComponentBOMLine) aif[i] +// .getComponent(); +// List propertie = new ArrayList(); +// propertie +// .add(subline.getStringProperty("bl_indented_title") +// .split("/")[0]); +// propertie.add(subline.getStringProperty("bl_sequence_no")); +// propertie +// .add(subline +// .getStringProperty("bl_item_object_name") == null ? "" +// : subline +// .getStringProperty("bl_item_object_name")); +// //获取工序下的BOM +// List equipmentNameList = new ArrayList(); +// if(subline.getChildren().length>0) +// { +// for (int j = 0; j < subline.getChildren().length; j++) { +// TCComponentBOMLine subChildrenline = (TCComponentBOMLine) subline.getChildren()[j] +// .getComponent(); +// System.out.println(subChildrenline.getType()); +// if(subChildrenline.getType().indexOf("Equipment") >= 0) +// { +// TCComponentICO[] icos = subChildrenline.getItem().getLatestItemRevision() +// .getClassificationObjects(); +// if (icos.length > 0) { +// ICSProperty[] descriptions = icos[0] +// .getICSProperties(true); +// for (int k = 0; k < descriptions.length; k++) { +// if (descriptions[k].getId() == 1004 && descriptions[k].getValue() != null +// && !descriptions[k].getValue().equals("")) { +// System.out.println(equipmentNameList.toString()); +// if(!equipmentNameList.contains(descriptions[k].getValue())) +// { +// equipmentNameList.add(descriptions[k].getValue()); +// } +// System.out.println(equipmentNameList.toString()); +// //sb.append(descriptions[k].getValue()+","); +// +// } +// } +// } +// } +// } +// } +// if(equipmentNameList.size() > 0) +// { +// propertie.add(equipmentNameList.toString().substring(1, equipmentNameList.toString().length()-1)); +// } +// else +// { +// propertie.add(""); +// } +// properties.add(propertie); +// } +// return properties; +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// return null; +// } + /** + * 获取插入到权限表的BOM行 + * @param session + * @param item + * @return + */ + public static List> getPermissionsBomPropertys(TCSession session, TCComponentItem item) { + // TODO Auto-generated method stub + //获取BOM + TCComponentBOMWindow bomWindow = null; + + try { + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topBomLine = bomWindow.setWindowTopLine(item, + item.getLatestItemRevision(), null, null); + //获取工艺下的控制计划对象 + TCComponent[] kzjh = item.getRelatedComponents("IMAN_reference"); + List itme = new ArrayList(); + for (int i = 0; i < kzjh.length; i++) { + if(kzjh[i].getType().toUpperCase().indexOf("KZJH") >= 0) + { + itme.add((TCComponentItem)kzjh[i]); + } + } + // 获取工序对象 + AIFComponentContext aif[] = topBomLine.getChildren(); + List> properties = new ArrayList>(); + for (int i = 0; i < aif.length; i++) { + if(((TCComponentBOMLine)aif[i].getComponent()).getItem().getType().equals("MEProcess")) + { + continue; + } + TCComponentBOMLine subline = (TCComponentBOMLine) aif[i] + .getComponent(); + List propertie = new ArrayList(); + propertie + .add(subline.getStringProperty("bl_indented_title") + .split("/")[0]); + propertie.add(subline.getStringProperty("bl_sequence_no")); + + String objectName = subline.getStringProperty("bl_item_object_name") == null ? "" + : subline.getStringProperty("bl_item_object_name"); + if(objectName.indexOf("/") >= 0) + { + propertie.add(objectName.split("/")[0]); + } + else + { + propertie.add(objectName); + } + //+++获取工序号 + propertie.add(subline.getStringProperty("RB3_GXH")); + //+++ + //获取工序下的BOM + List equipmentNameList = new ArrayList(); + if(subline.getChildren().length>0) + { + for (int j = 0; j < subline.getChildren().length; j++) { + TCComponentBOMLine subChildrenline = (TCComponentBOMLine) subline.getChildren()[j] + .getComponent(); + System.out.println(subChildrenline.getType()); + //if(subChildrenline.getType().indexOf("Equipment") >= 0) + //{ + equipmentNameList.add(subChildrenline.getItem().getStringProperty("item_id")); +// TCComponentICO[] icos = subChildrenline.getItem().getLatestItemRevision() +// .getClassificationObjects(); +// +// if (icos.length > 0) { +// ICSProperty[] descriptions = icos[0] +// .getICSProperties(true); +// for (int k = 0; k < descriptions.length; k++) { +// if (descriptions[k].getId() == 1004 && descriptions[k].getValue() != null +// && !descriptions[k].getValue().equals("")) { +// System.out.println(equipmentNameList.toString()); +// if(!equipmentNameList.contains(descriptions[k].getValue())) +// { +// equipmentNameList.add(descriptions[k].getValue()); +// } +// System.out.println(equipmentNameList.toString()); +// //sb.append(descriptions[k].getValue()+","); +// +// } +// } +// } + //} + } + } + if(equipmentNameList.size() > 0) + { + propertie.add(equipmentNameList.toString().substring(1, equipmentNameList.toString().length()-1)); + } + else + { + propertie.add(""); + } + properties.add(propertie); + } + return properties; + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return null; + } + + /** + * 获取BOM信息 + * @param meprocess 工艺BOMLINE + * @param isMeop 是否是PFEMA + * + */ + public static void getBomPropertys(TCComponentBOMLine meprocessBomLine, boolean isPFEMA) + { + try { + //获取工艺下的BOM + AIFComponentContext aif[] = meprocessBomLine.getChildren(); + for (int i = 0; i < aif.length; i++) { + if(aif[i]==null) {//防止 + continue; + } + TCComponentBOMLine subline = (TCComponentBOMLine) aif[i] + .getComponent(); + if(subline==null) { + continue; + } + TCComponentItem item = subline.getItem(); + //判断是否是工艺 + if(item.getType().equals("MEProcess")) + { + getBomPropertys(subline, isPFEMA); + } + else if(item.getType().equals("MEOP")) + { + List propertie = new ArrayList(); + //String ss = subline.getStringProperty("bl_indented_title"); + propertie + .add(subline.getStringProperty("bl_indented_title") + .split("/")[0]); + //控制计划中的零件/工艺编号改为工序号 + //propertie.add(subline.getStringProperty("bl_sequence_no")); + propertie.add(subline.getStringProperty("RB3_GXH")==null ? "": + subline.getStringProperty("RB3_GXH")); + propertie + .add(subline + .getStringProperty("bl_item_object_name") == null ? "" + : subline + .getStringProperty("bl_item_object_name")); + + //获取工序下的BOM的资源,机器设备。PFMEA跳过 + if(isPFEMA) + { + propertie.add(""); + }else { + List equipmentNameList = new ArrayList(); + if(subline.getChildren().length>0) + { + for (int j = 0; j < subline.getChildren().length; j++) { + TCComponentBOMLine subChildrenline = (TCComponentBOMLine) subline.getChildren()[j] + .getComponent(); + if(subChildrenline.toString().equals("<<无法读取>>")&&subChildrenline!=null) {//防止工艺资源出错,无权限读取 + continue; + } + System.out.println(subChildrenline.getType()); + String ClassID=subChildrenline.getItemRevision().getClassificationClass(); + if(ClassID!=null&&!ClassID.equals("")&&ClassID.length()>2) { + if(ClassID.substring(0,2).equals("15")) { + equipmentNameList.add(subChildrenline.getItem().getStringProperty("object_name")); + } + } + + } + } + if(equipmentNameList.size() > 0) + { + propertie.add(equipmentNameList.toString().substring(1, equipmentNameList.toString().length()-1)); + } + else + { + propertie.add(""); + } + } + propertie.add(subline.getStringProperty("bl_sequence_no")); + bomPropertyList.add(propertie); + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + /*** + * 根据正则表达式提取括号中的内容 + * @param value + * @return + */ + public static List getListByRegular(String value) + { + List resultList = new ArrayList(); + Pattern p = Pattern.compile("(\\[[^\\]]*\\])"); + Matcher m = p.matcher(value); + while(m.find()) + { + resultList.add(m.group().substring(1, m.group().length() - 1)); + } + return resultList; + } + + public static int getDays(String dateStr1, String dateStr2, String dateFormat) { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormat); + Date date1 = null; + Date date2 = null; + try { + date1 = simpleDateFormat.parse(dateStr1); + date2 = simpleDateFormat.parse(dateStr2); + } catch (ParseException e) { + e.printStackTrace(); + } + + String year1 = String.format("%tY", date1); + String mon1 = String.format("%tm", date1); + String day1 = String.format("%td", date1); + int y1 = Integer.valueOf(year1); + int m1 = Integer.valueOf(mon1); + int d1 = Integer.valueOf(day1); + int days1 = getRecentYearDays(y1, m1, d1); + System.out.println(days1); + + String year2 = String.format("%tY", date2); + String mon2 = String.format("%tm", date2); + String day2 = String.format("%td", date2); + int y2 = Integer.valueOf(year2); + int m2 = Integer.valueOf(mon2); + int d2 = Integer.valueOf(day2); + int days2 = getRecentYearDays(y2, m2, d2); + System.out.println(days2); + + int count = 0; + for (int i = y1; i < y2; i++) { + if ((i % 4 == 0 && i % 100 != 0) || i % 400 == 0) { + count += 366; + } else { + count += 365; + } + } + count = count + days2 - days1; + + return count; + } + + public static int getRecentYearDays(int y, int m, int d) { + + int count = 0; + + switch (m - 1) { + case 1: + count += 31; + break; + case 2: + count += 31 + 28; + break; + case 3: + count += 31 + 28 + 31; + break; + case 4: + count += 31 + 28 + 31 + 30; + break; + case 5: + count += 31 + 28 + 31 + 30 + 31; + break; + case 6: + count += 31 + 28 + 31 + 30 + 31 + 30; + break; + case 7: + count += 31 + 28 + 31 + 30 + 31 + 30 + 31; + break; + case 8: + count += 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31; + break; + case 9: + count += 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30; + break; + case 10: + count += 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31; + break; + case 11: + count += 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30; + break; + } + if (((y % 4 == 0 && y % 100 != 0) || y % 400 == 0) && m > 2) + count++; + return count + d; + } + + + +} diff --git a/src/com/connor/zf/zygyk/Adapter.java b/src/com/connor/zf/zygyk/Adapter.java new file mode 100644 index 0000000..bbc8900 --- /dev/null +++ b/src/com/connor/zf/zygyk/Adapter.java @@ -0,0 +1,299 @@ +package com.connor.zf.zygyk; + +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.StringSelection; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.util.ArrayList; +import java.util.List; +import java.util.StringTokenizer; + +import javax.swing.JComponent; +import javax.swing.JOptionPane; +import javax.swing.JTable; +import javax.swing.KeyStroke; + +/** + * Adapter 实现 JTables 中的复制粘贴 剪贴板功能。 适配器所用的剪贴板数据格式 与 Excel 所用的剪贴板格式兼容。这提供了 + * 支持的 JTables 和 Excel 间的互操作。 + */ +public class Adapter implements ActionListener { + private String rowstring, value; + private Clipboard system; + private StringSelection stsel; + private JTable jTable1; + private List> selectValue = new ArrayList>(); + + /** + * Excel 适配器由 JTable 构成, 它实现了 JTable 上的复制粘贴 功能,并充当剪贴板监听程序。 + */ + + public Adapter(JTable myJTable) { + jTable1 = myJTable; + KeyStroke copy = KeyStroke.getKeyStroke(KeyEvent.VK_C, + ActionEvent.CTRL_MASK, false); + + // 确定复制按键用户可以对其进行修改 + // 以实现其它按键组合的复制功能。 + KeyStroke paste = KeyStroke.getKeyStroke(KeyEvent.VK_V, + ActionEvent.CTRL_MASK, false); + + // 确定粘贴按键用户可以对其进行修改 + // 以实现其它按键组合的复制功能。 + + jTable1.registerKeyboardAction(this, "Copy", copy, + JComponent.WHEN_FOCUSED); + + jTable1.registerKeyboardAction(this, "Paste", paste, + JComponent.WHEN_FOCUSED); + + system = Toolkit.getDefaultToolkit().getSystemClipboard(); + } + + /** + * 此适配器运行图表的公共读方法。 + */ + public JTable getJTable() { + return jTable1; + } + + public void setJTable(JTable jTable1) { + this.jTable1 = jTable1; + } + + /** + * 在我们监听此实现的按键上激活这种方法。 此处,它监听复制和粘贴 ActionCommands。 包含不相邻单元格的选择导致选择无效, + * 而且此后复制动作无法执行。 粘贴的方法是将选定内容的左上角与 JTable 的当前选定内容的第一个元素对齐。 + */ + public void actionPerformed(ActionEvent e) { + if (e.getActionCommand().compareTo("Copy") == 0) { + StringBuffer sbf = new StringBuffer(); + + selectValue.clear(); + // 检查以确保我们仅选择了单元格的 + // 相邻块 + int numcols = jTable1.getSelectedColumnCount(); + int numrows = jTable1.getSelectedRowCount(); + int[] rowsselected = jTable1.getSelectedRows(); + int[] colsselected = jTable1.getSelectedColumns(); + +// if (!((numrows - 1 == rowsselected[rowsselected.length - 1] +// - rowsselected[0] && numrows == rowsselected.length) && (numcols - 1 == colsselected[colsselected.length - 1] +// - colsselected[0] && numcols == colsselected.length))) { +// JOptionPane.showMessageDialog(null, "Invalid Copy Selection", +// "Invalid Copy Selection", JOptionPane.ERROR_MESSAGE); +// +// return; +// } + + for (int i=0;i= 0) + { + sbf.append("\""); + sbf.append(jTable1.getValueAt(rowsselected[i],colsselected[j])); + sbf.append("\""); + } + else if(jTable1.getValueAt(rowsselected[i],colsselected[j]) == null) + { + sbf.append(""); + } + else + { + sbf.append(jTable1.getValueAt(rowsselected[i],colsselected[j])); + } + if (j= 0) + { + sb.append(values[i].replace("\n", " $")); + } + else + { + sb.append(values[i]); + } + //System.out.println(i+s[i]); + } + System.out.println("sb======"+sb.toString()); + String copyValue = sb.toString(); + String[] st1=copyValue.split("\\$"); //new StringTokenizer(sb.toString(),"$".toString()); + + + + int[] rows = jTable1.getSelectedRows(); + int[] columns = jTable1.getSelectedColumns(); + int startRow = rows[0]; + int startCol = columns[0]; + if(rows.length ==1 ) + { + for(int i=0;i= 0) + { + String[] cellValue = rowstring.split("\t"); + for(int j=0;j= 0) + { + String[] cellValue = rowstring.split("\t"); + for (int k = 0; k < cellValue.length; k++) { + value=(String)cellValue[k]; + System.out.println("value============"+value); + jTable1.setValueAt(value.trim(),rows[i],startCol+k); + System.out.println("Putting "+ value+"atrow="+startRow+i+"column="+startCol+k); + } + } + else + { + jTable1.setValueAt(rowstring.trim(),rows[i],startCol); + } + //} + //} + } + } + else //写入选中行内容 + { + for(int i=0;i= 0) + { + String[] cellValue = rowstring.split("\t"); + for(int j=0;j st1.length) + { + for (int i = 0; i < rows.length; i++) { + for (int j = 0; j < columns.length; j++) { + rowstring=st1[(i+st1.length)%st1.length]; + System.out.println("rowstring============"+rowstring); + if(rowstring.indexOf("\t") >= 0) + { + String[] cellValue = rowstring.split("\t"); + for (int k = 0; k < cellValue.length; k++) { + value=(String)cellValue[(j+cellValue.length)%cellValue.length]; + System.out.println("value============"+value); + jTable1.setValueAt(value.trim(),rows[i],columns[j]); + System.out.println("Putting "+ value+"atrow="+startRow+i+"column="+startCol+k); + } + } + else + { + jTable1.setValueAt(rowstring.trim(),rows[i],columns[j]); + } + } + } + } + else + { + for (int i = 0; i < st1.length; i++) { + for (int j = 0; j < columns.length; j++) { + rowstring=st1[(i+st1.length)%st1.length]; + System.out.println("rowstring============"+rowstring); + if(rowstring.indexOf("\t") >= 0) + { + String[] cellValue = rowstring.split("\t"); + for (int k = 0; k < cellValue.length; k++) { + value=(String)cellValue[(j+cellValue.length)%cellValue.length]; + System.out.println("value============"+value); + jTable1.setValueAt(value.trim(),startRow+i,columns[j]); + System.out.println("Putting "+ value+"atrow="+startRow+i+"column="+startCol+k); + } + } + else + { + jTable1.setValueAt(rowstring.trim(),startRow+i,columns[j]); + } + } + } + } + } + } catch (Exception ex) { + ex.printStackTrace(); + } + + } + } +} \ No newline at end of file diff --git a/src/com/connor/zf/zygyk/CTMap.java b/src/com/connor/zf/zygyk/CTMap.java new file mode 100644 index 0000000..bc444e9 --- /dev/null +++ b/src/com/connor/zf/zygyk/CTMap.java @@ -0,0 +1,323 @@ +package com.connor.zf.zygyk; + +import java.awt.Dimension; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.util.List; +import java.util.Vector; + +import javax.swing.event.TableModelEvent; +import javax.swing.table.DefaultTableModel; + +import com.teamcenter.rac.util.MessageBox; + +public class CTMap extends DefaultTableModel implements CellSpan { + protected int rowSize; + protected int columnSize; + protected int[][][] span; // CellSpan + protected boolean isEditable = true; + + private int row = -1; + private int column = -1; + + public int getRow() { + return row; + } + + public void setRow(int row) { + this.row = row; + } + + public int getColumn() { + return column; + } + + public void setColumn(int column) { + this.column = column; + } + + public void setEditable(boolean isEditable) { + this.isEditable = isEditable; + } + + private List processRowList; + + public List getProcessRowList() { + return processRowList; + } + + public void setProcessRowList(List processRowList) { + this.processRowList = processRowList; + } + + @Override + public void removeRow(int row) { + // 将可修改的行-1 + if (processRowList != null && processRowList.size() > 0) { + for (int i = processRowList.size() - 1; i >= 0; i--) { + if (processRowList.get(i) != null + && processRowList.get(i) == row) { + processRowList.remove(i); + } else if (processRowList.get(i) != null + && processRowList.get(i) > row) { + processRowList.set(i, processRowList.get(i) - 1); + } + } + } + super.removeRow(row); + } + + @Override + public int[] getSpan(int row, int column) { + // TODO Auto-generated method stub + if (isOutOfBounds(row, column)) { + int[] ret_code = { 1, 1 }; + return ret_code; + } + return span[row][column]; + } + + @Override + public void setSpan(int[] span, int row, int column) { + // TODO Auto-generated method stub + if (isOutOfBounds(row, column)) + return; + this.span[row][column] = span; + } + + @Override + public boolean isVisible(int row, int column) { + // TODO Auto-generated method stub + if (isOutOfBounds(row, column)) + return false; + if ((span[row][column][CellSpan.COLUMN] < 1) + || (span[row][column][CellSpan.ROW] < 1)) + return false; + return true; + } + + @Override + public void combine(int[] rows, int[] columns) { + // TODO Auto-generated method stub + + int rowSpan = rows.length; + int columnSpan = columns.length; + int startRow = rows[0]; + int startColumn = columns[0]; + for (int i = 0; i < rowSpan; i++) { + for (int j = 0; j < columnSpan; j++) { + if ((span[startRow + i][startColumn + j][CellSpan.COLUMN] != 1) + || (span[startRow + i][startColumn + j][CellSpan.ROW] != 1)) { + // System.out.println("can't combine"); + return; + } + } + } + for (int i = 0, ii = 0; i < rowSpan; i++, ii--) { + for (int j = 0, jj = 0; j < columnSpan; j++, jj--) { + span[startRow + i][startColumn + j][CellSpan.COLUMN] = jj; + span[startRow + i][startColumn + j][CellSpan.ROW] = ii; + // System.out.println("r " +ii +" c " +jj); + } + } + span[startRow][startColumn][CellSpan.COLUMN] = columnSpan; + span[startRow][startColumn][CellSpan.ROW] = rowSpan; + } + + @Override + public boolean isCellEditable(int arg0, int arg1) { + if (arg0 == row && arg1 == column) { + return this.isEditable; + } else { + return false; + } + } + + public void setSize(Dimension size) { + columnSize = size.width; + rowSize = size.height; + span = new int[rowSize][columnSize][2]; // 2: COLUMN,ROW + initValue(); + } + + protected boolean isOutOfBounds(int row, int column) { + if ((row < 0) || (rowSize <= row) || (column < 0) + || (columnSize <= column)) { + return true; + } + return false; + } + + public void addRow() { + + Vector newData = new Vector(getColumnCount()); + dataVector.add(newData); + + // + newRowsAdded(new TableModelEvent(this, getRowCount() - 1, + getRowCount() - 1, TableModelEvent.ALL_COLUMNS, + TableModelEvent.INSERT)); + int[][][] oldSpan = span; + int numRows = oldSpan.length; + int numColumns = oldSpan[0].length; + span = new int[numRows + 1][numColumns][2]; + System.arraycopy(oldSpan, 0, span, 0, numRows); + for (int i = 0; i < numColumns; i++) { + span[numRows][i][CellSpan.COLUMN] = 1; + span[numRows][i][CellSpan.ROW] = 1; + } + rowSize = span.length; + } + + public void addColumn(Object columnName) { + + int[][][] oldSpan = span; + int numRows = oldSpan.length; + int numColumns = oldSpan[0].length; + span = new int[numRows][numColumns + 1][2]; + for (int i = 0; i < span.length; i++) { + for (int j = 0; j < span[0].length; j++) { + span[i][j][CellSpan.COLUMN] = 1; + span[i][j][CellSpan.ROW] = 1; + } + } + + columnSize = span[0].length; + addColumn(columnName, (Vector) null); + } + + public void insertRow(int row) { + Vector rowData = new Vector(getColumnCount()); + int index = 0; + + dataVector.insertElementAt(rowData, row); + System.out.println("size:" + dataVector.size()); + + // + newRowsAdded(new TableModelEvent(this, row, row, + TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT)); + int[][][] newSpan = new int[span.length + 1][span[0].length][2]; + + int numRows = span.length; + int numColumns = span[0].length; + for (int i = 0; i < newSpan.length; i++) { + if (i < row) { + for (int j = 0; j < numColumns; j++) { + newSpan[i][j][0] = span[i][j][0]; + newSpan[i][j][1] = span[i][j][1]; + // newSpan[i][j][0] = 1; + // newSpan[i][j][1] = 1; + } + } else if (i == row) { + for (int j = 0; j < numColumns; j++) { + newSpan[i][j][0] = 1; + newSpan[i][j][1] = 1; + } + } else { + for (int j = 0; j < numColumns; j++) { + newSpan[i][j][0] = span[i - 1][j][0]; + newSpan[i][j][1] = span[i - 1][j][1]; + // newSpan[i][j][0] = 1; + // newSpan[i][j][1] = 1; + } + } + } + span = newSpan; + rowSize = span.length;// 将可修改的行+1 + if (processRowList != null && processRowList.size() > 0) { + + for (int i = processRowList.size() - 1; i >= 0; i--) { + if (!processRowList.contains(row) + && processRowList.get(i) != null + && processRowList.get(i) == row - 1) { + index = i + 1; + processRowList.add(i + 1, row); + } else if (processRowList.get(i) != null + && processRowList.get(i) == row) { + index = i + 1; + processRowList.add(i + 1, row + 1); + } else if (processRowList.get(i) != null && i > index + && processRowList.get(i) >= row) { + processRowList.set(i, processRowList.get(i) + 1); + } + } + + // if (processRowList.contains(row)) { + // for (int i = 0; i < processRowList.size(); i++) { + // if(processRowList.get(i) != null && processRowList.get(i) == row) + // { + // index = i+1; + // processRowList.add(i+1, row+1); + // } + // else if(processRowList.get(i) != null && i > index && + // processRowList.get(i) >= row+1) + // { + // processRowList.set(i, processRowList.get(i)+1); + // } + // } + // } + // else + // { + // for (int i = 0; i < processRowList.size(); i++) { + // if(processRowList.get(i) != null && processRowList.get(i) == + // row-1) + // { + // index = i+1; + // processRowList.add(i+1, row); + // } + // else if(processRowList.get(i) != null && i > index && + // processRowList.get(i) >= row) + // { + // processRowList.set(i, processRowList.get(i)+1); + // } + // } + // } + + } + + } + + public CTMap(int numRows, int numColumns) { + Vector names = new Vector(numColumns); + names.setSize(numColumns); + setColumnIdentifiers(names); + dataVector = new Vector(); + setNumRows(numRows); + setSize(new Dimension(numColumns, numRows)); + } + + protected void initValue() { + System.out.println(span.length); + for (int i = 0; i < span.length; i++) { + for (int j = 0; j < span[i].length; j++) { + span[i][j][CellSpan.COLUMN] = 1; + span[i][j][CellSpan.ROW] = 1; + } + } + } + + public void split(int row, int column) { + if (isOutOfBounds(row, column)) + return; + int columnSpan = span[row][column][CellSpan.COLUMN]; + int rowSpan = span[row][column][CellSpan.ROW]; + for (int i = 0; i < rowSpan; i++) { + for (int j = 0; j < columnSpan; j++) { + span[row + i][column + j][CellSpan.COLUMN] = 1; + span[row + i][column + j][CellSpan.ROW] = 1; + } + } + } + + public void removeCol() { + + columnIdentifiers.removeElementAt(columnIdentifiers.size() - 1); + dataVector.setSize(getRowCount()); + + for (int i = 0; i < getRowCount() - 1; i++) { + + ((Vector) dataVector.elementAt(i)).setSize(getColumnCount()); + } + fireTableStructureChanged(); + } +} diff --git a/src/com/connor/zf/zygyk/CTUI.java b/src/com/connor/zf/zygyk/CTUI.java new file mode 100644 index 0000000..378cbe9 --- /dev/null +++ b/src/com/connor/zf/zygyk/CTUI.java @@ -0,0 +1,107 @@ +package com.connor.zf.zygyk; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Point; +import java.awt.Rectangle; + +import javax.swing.JComponent; +import javax.swing.plaf.basic.BasicTableUI; +import javax.swing.table.TableCellRenderer; + +public class CTUI extends BasicTableUI { + + public void paint(Graphics g, JComponent c) { + Rectangle oldClipBounds = g.getClipBounds(); + Rectangle clipBounds = new Rectangle(oldClipBounds); + int tableWidth = ((CTable) table).getColumnModel() + .getTotalColumnWidth(); + clipBounds.width = Math.min(clipBounds.width, tableWidth); + g.setClip(clipBounds); + + int firstIndex = ((CTable) table) + .rowAtPoint(new Point(0, clipBounds.y)); + int lastIndex = ((CTable) table).getRowCount() - 1; + Rectangle rowRect = new Rectangle(0, 0, tableWidth, + ((CTable) table).getRowHeight() + + ((CTable) table).getRowMargin()); + rowRect.y = firstIndex * rowRect.height; + for (int index = firstIndex; index <= lastIndex; index++) { + if (rowRect.intersects(clipBounds)) { + // System.out.println(); // debug + // System.out.print("" + index +": "); // row + paintRow(g, index); + } + rowRect.y += rowRect.height; + } + g.setClip(oldClipBounds); + } + + private void paintRow(Graphics g, int row) { + Rectangle rect = g.getClipBounds(); + boolean drawn = false; + CellSpan cellAtt = (CellSpan) ((CTable) table).getModel(); + int numColumns = ((CTable) table).getColumnCount(); + + for (int column = 0; column < numColumns; column++) { + Rectangle cellRect = ((CTable) table) + .getCellRect(row, column, true); + + int cellRow, cellColumn; + if (cellAtt.isVisible(row, column)) { + cellRow = row; + cellColumn = column; + // System.out.print(" "+column+" "); // debug + } else { + cellRow = row + cellAtt.getSpan(row, column)[CellSpan.ROW]; + cellColumn = column + + cellAtt.getSpan(row, column)[CellSpan.COLUMN]; + // System.out.print(" ("+column+")"); // debug + } + if (cellRect.intersects(rect)) { + drawn = true; + paintCell(g, cellRect, cellRow, cellColumn); + } else { + if (drawn) + break; + } + } + + } + + private void paintCell(Graphics g, Rectangle cellRect, int row, int column) { + int spacingHeight = ((CTable) table).getRowMargin(); + int spacingWidth = ((CTable) table).getColumnModel().getColumnMargin(); + // System.out.println("X:"+cellRect.x+"Y:"+cellRect.y); + Color c = g.getColor(); + g.setColor(((CTable) table).getGridColor()); + g.drawRect(cellRect.x, cellRect.y, cellRect.width - 1, + cellRect.height - 1); + g.setColor(c); + + cellRect.setBounds(cellRect.x + spacingWidth / 2, cellRect.y + + spacingHeight / 2, cellRect.width - spacingWidth, + cellRect.height - spacingHeight); + + if (((CTable) table).isEditing() + && ((CTable) table).getEditingRow() == row + && ((CTable) table).getEditingColumn() == column) { + Component component = ((CTable) table).getEditorComponent(); + component.setBounds(cellRect); + component.validate(); + } else { + TableCellRenderer renderer = ((CTable) table).getCellRenderer(row, + column); + Component component = ((CTable) table).prepareRenderer(renderer, + row, column); + + if (component.getParent() == null) { + rendererPane.add(component); + } + rendererPane.paintComponent(g, component, ((CTable) table), + cellRect.x, cellRect.y, cellRect.width, cellRect.height, + true); + } + } +} \ No newline at end of file diff --git a/src/com/connor/zf/zygyk/CTable.java b/src/com/connor/zf/zygyk/CTable.java new file mode 100644 index 0000000..f18fc49 --- /dev/null +++ b/src/com/connor/zf/zygyk/CTable.java @@ -0,0 +1,234 @@ +package com.connor.zf.zygyk; + +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.event.MouseEvent; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.JTable; +import javax.swing.ListSelectionModel; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.TableModelListener; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableModel; + + +public class CTable extends JTable implements TableModelListener{ + Map map; + TableCellTextAreaRenderer renderer = new TableCellTextAreaRenderer(); + TextAreaCellEditor cellEditor = new TextAreaCellEditor(); + ComboBoxCellEditor comboBoxCellEditor = new ComboBoxCellEditor(new Object[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }); + + CheckBoxCellEditor checkBoxCellEditor = new CheckBoxCellEditor(this); + TableCellCheckboxRenderer checkboxRenderer = new TableCellCheckboxRenderer(this); + +// @Override +// public java.awt.Component prepareRenderer(javax.swing.table.TableCellRenderer renderer, int row, int column) { +// int modelRow = convertRowIndexToModel(row); +// int modelColumn = convertColumnIndexToModel(column); +// java.awt.Component comp = super.prepareRenderer(renderer, row, column); +// if (!isRowSelected(modelRow)) { +// if (modelRow == 1 && modelColumn == 1) //此处加入条件判断 +// comp.setBackground(Color.GRAY); +// else //不符合条件的保持原表格样式 +// comp.setBackground(Color.WHITE); +// } +// return comp; +// } + public CTable(TableModel model) { + super(model); + setUI(new CTUI()); + getTableHeader().setReorderingAllowed(false); + setCellSelectionEnabled(true); + setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); + map = new HashMap(); + } + + public String getToolTipText(MouseEvent e) { + int row = this.rowAtPoint(e.getPoint()); + int col = this.columnAtPoint(e.getPoint()); + String tiptextString = null; + if (row > -1 && col > -1) { + Object value = this.getValueAt(row, col); + if (null != value && !"".equals(value)) + tiptextString = value.toString();// 悬浮显示单元格内容 + } + return tiptextString; + } + + // @Override + // protected void processKeyEvent(KeyEvent keyevent) { + // // TODO Auto-generated method stub + // if(keyevent.getKeyCode()==KeyEvent.VK_ENTER){ + // if(keyevent.isControlDown()) + // { + // System.out.println(1); + // } + // this.editCellAt(this.getSelectedRow(),this.getSelectedColumn()); + // } + // } + + public Rectangle getCellRect(int row, int column, boolean includeSpacing) { + Rectangle sRect = super.getCellRect(row, column, includeSpacing); + if ((row < 0) || (column < 0) || (getRowCount() <= row) || (getColumnCount() <= column)) { + return sRect; + } + CellSpan cellAtt = (CellSpan) getModel(); + if (!cellAtt.isVisible(row, column)) { + int temp_row = row; + int temp_column = column; + row += cellAtt.getSpan(temp_row, temp_column)[CellSpan.ROW]; + column += cellAtt.getSpan(temp_row, temp_column)[CellSpan.COLUMN]; + } + int[] n = cellAtt.getSpan(row, column); + + int index = 0; + int columnMargin = getColumnModel().getColumnMargin(); + Rectangle cellFrame = new Rectangle(); + int aCellHeight = rowHeight + rowMargin; + cellFrame.y = row * aCellHeight; + cellFrame.height = n[CellSpan.ROW] * aCellHeight; + + Enumeration eeration = getColumnModel().getColumns(); + while (eeration.hasMoreElements()) { + TableColumn aColumn = (TableColumn) eeration.nextElement(); + cellFrame.width = aColumn.getWidth(); + if (index == column) + break; + cellFrame.x += cellFrame.width; + index++; + } + for (int i = 0; i < n[CellSpan.COLUMN] - 1; i++) { + TableColumn aColumn = (TableColumn) eeration.nextElement(); + cellFrame.width += aColumn.getWidth() + columnMargin; + } + + if (!includeSpacing) { + Dimension spacing = getIntercellSpacing(); + cellFrame.setBounds(cellFrame.x + spacing.width / 2, cellFrame.y + spacing.height / 2, + cellFrame.width - spacing.width, cellFrame.height - spacing.height); + } + return cellFrame; + } + + // 隐藏列 + public void HiddenCell(int column) { + TableColumn tc = this.getTableHeader().getColumnModel().getColumn(column); + tc.setMaxWidth(0); + tc.setPreferredWidth(0); + tc.setWidth(0); + tc.setMinWidth(0); + this.getTableHeader().getColumnModel().getColumn(column).setMaxWidth(0); + this.getTableHeader().getColumnModel().getColumn(column).setMinWidth(0); + } + + private int[] rowColumnAtPoint(Point point) { + int[] retValue = { -1, -1 }; + int row = point.y / (rowHeight + rowMargin); + if ((row < 0) || (getRowCount() <= row)) + return retValue; + int column = getColumnModel().getColumnIndexAtX(point.x); + + CellSpan cellAtt = (CellSpan) getModel(); + + if (cellAtt.isVisible(row, column)) { + retValue[CellSpan.COLUMN] = column; + retValue[CellSpan.ROW] = row; + return retValue; + } + retValue[CellSpan.COLUMN] = column + cellAtt.getSpan(row, column)[CellSpan.COLUMN]; + retValue[CellSpan.ROW] = row + cellAtt.getSpan(row, column)[CellSpan.ROW]; + return retValue; + } + + public int rowAtPoint(Point point) { + return rowColumnAtPoint(point)[CellSpan.ROW]; + } + + public int columnAtPoint(Point point) { + return rowColumnAtPoint(point)[CellSpan.COLUMN]; + } + + public void columnSelectionChanged(ListSelectionEvent e) { + repaint(); + } + + public void valueChanged(ListSelectionEvent e) { + int firstIndex = e.getFirstIndex(); + int lastIndex = e.getLastIndex(); + if (firstIndex == -1 && lastIndex == -1) { // Selection cleared. + repaint(); + } + Rectangle dirtyRegion = getCellRect(firstIndex, 0, false); + int numCoumns = getColumnCount(); + int index = firstIndex; + for (int i = 0; i < numCoumns; i++) { + dirtyRegion.add(getCellRect(index, i, false)); + } + index = lastIndex; + for (int i = 0; i < numCoumns; i++) { + dirtyRegion.add(getCellRect(index, i, false)); + } + repaint(dirtyRegion.x, dirtyRegion.y, dirtyRegion.width, dirtyRegion.height); + } + + public void setCombo(int row, int col, TableCellEditor ce) { + map.put(new Point(row, col), ce); + } + + @Override + public TableCellEditor getCellEditor(int row, int column) { + if (this.getColumnName(column).equals("严重度S") || this.getColumnName(column).equals("频度数O") + || this.getColumnName(column).equals("探测度D")) { + return comboBoxCellEditor; + } else if (this.getColumnName(column).equals("4")||this.getColumnName(column).equals("二")) { + return checkBoxCellEditor; + } else { + return cellEditor; + } + } + + @Override + public TableCellRenderer getCellRenderer(int row, int column) { + // TODO Auto-generated method stub + if (this.getColumnName(column).equals("严重度S") || this.getColumnName(column).equals("频度数O") + || this.getColumnName(column).equals("探测度D")) { + return super.getCellRenderer(row, column); + } else if (this.getColumnName(column).equals("4")||this.getColumnName(column).equals("二")) { + return checkboxRenderer; + } else { + return renderer; + } + + } + + public void setRowHeight(int row, int rowHeight) { + super.setRowHeight(row, rowHeight); + } + + public void selectAllOrNull(String value) { + // Select All. The last column + for (int index = 0; index < getRowCount(); index++) { + this.setValueAt(value, index, this.getColumnCount() - 3); + } + } + + // @Override + // public boolean isCellSelected(int i, int j) { + // if( i == 1 || i == 3) + // { + // //this.clearSelection(); + // return false; + // } + // else + // { + // return super.isCellSelected(i, j); + // } + // } + +} \ No newline at end of file diff --git a/src/com/connor/zf/zygyk/CellSpan.java b/src/com/connor/zf/zygyk/CellSpan.java new file mode 100644 index 0000000..7cec91a --- /dev/null +++ b/src/com/connor/zf/zygyk/CellSpan.java @@ -0,0 +1,15 @@ +package com.connor.zf.zygyk; + +interface CellSpan { + public final int ROW = 0; + public final int COLUMN = 1; + + public int[] getSpan(int row, int column); + + public void setSpan(int[] span, int row, int column); + + public boolean isVisible(int row, int column); + + public void combine(int[] rows, int[] columns); + +} \ No newline at end of file diff --git a/src/com/connor/zf/zygyk/CheckBoxCellEditor.java b/src/com/connor/zf/zygyk/CheckBoxCellEditor.java new file mode 100644 index 0000000..3e8153b --- /dev/null +++ b/src/com/connor/zf/zygyk/CheckBoxCellEditor.java @@ -0,0 +1,117 @@ +package com.connor.zf.zygyk; + +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.EventObject; + +import javax.swing.JCheckBox; +import javax.swing.JTable; +import javax.swing.SwingConstants; +import javax.swing.event.CellEditorListener; +import javax.swing.event.ChangeEvent; +import javax.swing.event.EventListenerList; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableCellEditor; + +public class CheckBoxCellEditor extends JCheckBox implements TableCellEditor { + + protected EventListenerList listenerList = new EventListenerList(); + protected ChangeEvent changeEvent = new ChangeEvent(this); + private JTableHeader tableHeader; + private CTMap tableModel; + + public CheckBoxCellEditor(final CTable table) { + super(); + this.tableModel = (CTMap) table.getModel(); + this.tableHeader = table.getTableHeader(); + this.setName("4"); + // selectBox = new JCheckBox(tableModel.getColumnName(1)); + this.setSelected(false); + tableHeader.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() > 0) { + // 获得选中列 + int selectColumn = tableHeader.columnAtPoint(e.getPoint()); + if (table.getColumnName(selectColumn).equals("4")) { + boolean value = !CheckBoxCellEditor.this.isSelected(); + CheckBoxCellEditor.this.setSelected(value); + table.selectAllOrNull(value ? "1" : "0"); + tableHeader.repaint(); + } + } + } + }); + addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent event) { + fireEditingStopped(); + } + }); + } + + public void addCellEditorListener(CellEditorListener listener) { + listenerList.add(CellEditorListener.class, listener); + } + + public void removeCellEditorListener(CellEditorListener listener) { + listenerList.remove(CellEditorListener.class, listener); + } + + protected void fireEditingStopped() { + System.out.println(this.isSelected() ? "1" : "0"); + CellEditorListener listener; + Object[] listeners = listenerList.getListenerList(); + for (int i = 0; i < listeners.length; i++) { + if (listeners[i] == CellEditorListener.class) { + listener = (CellEditorListener) listeners[i + 1]; + listener.editingStopped(changeEvent); + } + } + } + + protected void fireEditingCanceled() { + CellEditorListener listener; + Object[] listeners = listenerList.getListenerList(); + for (int i = 0; i < listeners.length; i++) { + if (listeners[i] == CellEditorListener.class) { + listener = (CellEditorListener) listeners[i + 1]; + listener.editingCanceled(changeEvent); + } + } + } + + public void cancelCellEditing() { + fireEditingCanceled(); + } + + public boolean stopCellEditing() { + // this.addItem(this.getSelectedItem()); + fireEditingStopped(); + return true; + } + + public boolean isCellEditable(EventObject event) { + return true; + } + + public boolean shouldSelectCell(EventObject event) { + return true; + } + + public Object getCellEditorValue() { + return this.isSelected() ? "1" : "0"; + } + + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + +// String valueStr = (String) value; +// JLabel label = new JLabel(valueStr); +// label.setHorizontalAlignment(SwingConstants.CENTER); // 表头标签剧中 + this.setHorizontalAlignment(SwingConstants.CENTER);// 表头标签剧中 + this.setBorderPainted(true); + this.setSelected(value.toString().equals("1")); + return this; + } +} \ No newline at end of file diff --git a/src/com/connor/zf/zygyk/ComboBoxCellEditor.java b/src/com/connor/zf/zygyk/ComboBoxCellEditor.java new file mode 100644 index 0000000..a48d476 --- /dev/null +++ b/src/com/connor/zf/zygyk/ComboBoxCellEditor.java @@ -0,0 +1,88 @@ +package com.connor.zf.zygyk; + +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.EventObject; + +import javax.swing.JComboBox; +import javax.swing.JTable; +import javax.swing.event.CellEditorListener; +import javax.swing.event.ChangeEvent; +import javax.swing.event.EventListenerList; +import javax.swing.table.TableCellEditor; + +public class ComboBoxCellEditor extends JComboBox implements TableCellEditor { + + protected EventListenerList listenerList = new EventListenerList(); + protected ChangeEvent changeEvent = new ChangeEvent(this); + + public ComboBoxCellEditor(Object[] itmes) { + super(); + for (int i = 0; i < itmes.length; i++) { + addItem(itmes[i]); + } + addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent event) { + fireEditingStopped(); + } + }); + } + + public void addCellEditorListener(CellEditorListener listener) { + listenerList.add(CellEditorListener.class, listener); + } + + public void removeCellEditorListener(CellEditorListener listener) { + listenerList.remove(CellEditorListener.class, listener); + } + + protected void fireEditingStopped() { + CellEditorListener listener; + Object[] listeners = listenerList.getListenerList(); + for (int i = 0; i < listeners.length; i++) { + if (listeners[i] == CellEditorListener.class) { + listener = (CellEditorListener) listeners[i + 1]; + listener.editingStopped(changeEvent); + } + } + } + + protected void fireEditingCanceled() { + CellEditorListener listener; + Object[] listeners = listenerList.getListenerList(); + for (int i = 0; i < listeners.length; i++) { + if (listeners[i] == CellEditorListener.class) { + listener = (CellEditorListener) listeners[i + 1]; + listener.editingCanceled(changeEvent); + } + } + } + + public void cancelCellEditing() { + fireEditingCanceled(); + } + + public boolean stopCellEditing() { + fireEditingStopped(); + return true; + } + + public boolean isCellEditable(EventObject event) { + return true; + } + + public boolean shouldSelectCell(EventObject event) { + return true; + } + + public Object getCellEditorValue() { + return getSelectedItem(); + } + + public Component getTableCellEditorComponent(JTable table, Object value, + boolean isSelected, int row, int column) { + this.setSelectedItem(value); + return this; + } +} \ No newline at end of file diff --git a/src/com/connor/zf/zygyk/CreateZYGYKHandler.java b/src/com/connor/zf/zygyk/CreateZYGYKHandler.java new file mode 100644 index 0000000..18330e7 --- /dev/null +++ b/src/com/connor/zf/zygyk/CreateZYGYKHandler.java @@ -0,0 +1,378 @@ +package com.connor.zf.zygyk; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.util.CreateNewBOHandler; +import com.connor.zf.editClassAttr.JAutoCompleteComboBox; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentNameRule; +import com.teamcenter.rac.kernel.TCComponentNameRuleType; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentRevisionRule; +import com.teamcenter.rac.kernel.TCComponentRevisionRuleType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +import java.awt.Dimension; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.util.Arrays; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JTextField; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; + +import org.eclipse.core.commands.AbstractHandler; + +public class CreateZYGYKHandler extends AbstractHandler{ // implements DocumentListener + + private TCComponentItemRevision itemRevision; + private JLabel revLabel;//工艺卡类型 + private JAutoCompleteComboBox revField; + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + + + + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + + TCSession session =(TCSession) app.getSession(); + + String type = targetComponent.getType(); + + if(type.equals("ZF6_ZCTRevision")) { + + itemRevision = (TCComponentItemRevision)targetComponent; + + new Thread() { + + public void run() { + + JFrame frame = new JFrame(); + + frame.setLayout(new PropertyLayout()); + + frame.setPreferredSize(new Dimension(450,170)); + + JTextField textField = new JTextField(); +// textName.setEditable(false); + textField.setPreferredSize(new Dimension(300,20)); + JButton btn = new JButton("指派"); + frame.add("1.1.left.center",new JLabel (" ID: ")); + frame.add("1.2.left.center",textField); + frame.add("1.3.left.center",btn); +// btn.add +// btn.getDocument().addDocumentListener(this); + btn.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + try { + String zctId = itemRevision.getStringProperty("item_id"); + + TCComponentItemType itemTypeComp = (TCComponentItemType) session.getTypeComponent("ZF6_ZYGYK"); + + String pfmeaId = "HZF-TE-"+zctId+"-"; + + + int ids = getItemRevision(session,pfmeaId); + + while(true) { + + ids = ids+1; + + String format = String.format("%03d", ids); + + String idString = pfmeaId+format; + + TCComponentItem find = itemTypeComp.find(idString); + + if(find==null) { + pfmeaId = idString; + break; + } + + } + + textField.setText(pfmeaId); + textField.setEditable(false); + + } catch (Exception er) { + // TODO Auto-generated catch block + er.printStackTrace(); + } + } + }); + frame.add("2.1.left.center",new JLabel (" 名称: ")); + + JTextField textField2 = new JTextField(); +// textName.setEditable(false); + textField2.setPreferredSize(new Dimension(300,20)); + frame.add("2.2.left.center",textField2); + + //版本号 + TCPreferenceService service = session.getPreferenceService(); + String[] strs = service.getStringValues("ZF_Revision_Rule"); + frame.add("3.1.left.center",new JLabel (" 版本: ")); + //revLabel.setPreferredSize(new Dimension(80, 30)); + revField = new JAutoCompleteComboBox(); + revField.setPreferredSize(new Dimension(300, 30)); + revField.setSelectedItem((strs==null||strs.length==0?"":strs[0]));//默认添加第一个 + revField.setEditable(false); + for (String str : strs) { + revField.addItem(str); + } + frame.add("3.2.left.center",revField); + + + + + JButton btn1 = new JButton("完成"); + btn1.setEnabled(false); + textField2.getDocument().addDocumentListener(new DocumentListener() { + + @Override + public void removeUpdate(DocumentEvent e) { + // TODO Auto-generated method stub + if(!textField2.getText().trim().equals("")) { + btn1.setEnabled(true); + }else { + btn1.setEnabled(false); + } + } + + @Override + public void insertUpdate(DocumentEvent e) { + // TODO Auto-generated method stub + if(!textField2.getText().trim().equals("")) { + btn1.setEnabled(true); + }else { + btn1.setEnabled(false); + } + } + + @Override + public void changedUpdate(DocumentEvent e) { + // TODO Auto-generated method stub + if(!textField2.getText().trim().equals("")) { + btn1.setEnabled(true); + }else { + btn1.setEnabled(false); + } + } + }); + + + btn1.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + try { + revField.setEditable(true); + String revNo=revField.getText(); + revField.setEditable(false); + TCComponentItemType itemTypeComp = (TCComponentItemType) session.getTypeComponent("ZF6_ZYGYK"); +// /itemTypeComp.getNewRev(null) + TCComponentItem create = itemTypeComp.create(textField.getText(), revNo ,"ZF6_ZYGYK",textField2.getText() , "", null); + String obName = create.getStringProperty("object_string"); + textField.setText(""); + textField2.setText(""); + btn1.setEnabled(false); + Boolean flag = false; + String folderName = ""; +// MessageBox.post("创建完成","提示",2); + String userId = session.getUser().getUserId(); + AIFComponentContext[] whereReferenced = itemRevision.getItem().whereReferenced(); + for(AIFComponentContext context:whereReferenced) { + + InterfaceAIFComponent component = context.getComponent(); + + if(component instanceof TCComponentFolder) { + + TCComponentFolder folder = (TCComponentFolder)component; + + String userName = folder.getReferenceProperty("owning_user") + .getStringProperty("user_id"); + if(userId.equals(userName)) { + flag = true; + folderName = folder.getStringProperty("object_name"); + folder.add("contents", create); + break; + } + } + } + + if(flag) { + MessageBox.post(obName+"创建到了"+folderName+"文件夹下","提示",2); + }else { + session.getUser().getHomeFolder().add("contents", create); + MessageBox.post(obName+"创建到了HOME下","提示",2); + } + + + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + } + }); + JButton btn2 = new JButton("取消"); + btn2.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + +// try { +//// TCComponentRevisionRuleType revisionRuleType = (TCComponentRevisionRuleType) session.getTypeComponent("RevisionRule"); +//// String[] revs = revisionRuleType.getRevisionNamingRule(); +//// System.out.println("revs====>"+Arrays.toString(revs)); +//// System.out.println("======="+revisionRuleType.getPasteRelationNames()); +// TCComponentNameRuleType nameRuleType = (TCComponentNameRuleType) session.getTypeComponent("RevisionRule"); +// if(nameRuleType!=null) { +// TCComponentNameRule nameRule = nameRuleType.find("ZF6_TZ"); +// if(nameRule!=null) { +// String[] patterns = nameRule.getPatterns(); +// System.out.println("revs1====>"+Arrays.toString(patterns)); +// } +// } +// TCComponentNameRuleType nameRuleType2 = (TCComponentNameRuleType) session.getTypeComponent("RevisionNameRule"); +// if(nameRuleType2!=null) { +// TCComponentNameRule nameRule2 = nameRuleType2.find("ZF6_TZ"); +// if(nameRule2!=null) { +// String[] patterns = nameRule2.getPatterns(); +// System.out.println("revs2====>"+Arrays.toString(patterns)); +// } +// } +//// //TCComponentRevisionRule revisionRule=revisionRuleType..find("ZF6_ZYGYK"); +//// TCComponentNameRuleType nameRuleType = (TCComponentNameRuleType) session.getTypeComponent("NameRule"); +//// TCComponentNameRule nameRule = nameRuleType.find("ZF6_TZ"); +//// String[] patterns = nameRule.getPatterns(); +//// System.out.println("revs====>"+Arrays.toString(patterns)); +// } catch (TCException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } + + // TODO Auto-generated method stub + frame.dispose(); + + } + }); + frame.add("4.1.left.center",btn1); + frame.add("4.2.left.center",btn2); + Toolkit toolkit = Toolkit.getDefaultToolkit(); + + int x = (int)(toolkit.getScreenSize().getWidth()-frame.getWidth())/2; + + int y = (int)(toolkit.getScreenSize().getHeight()-frame.getHeight())/2; + + frame.setLocation(x, y); + frame.pack(); + frame.setResizable(false); + frame.show(); + + } + + + }.start(); + + +// CreateNewBOHandler handler = new CreateNewBOHandler("ZF6_ZYGYK"); +// handler.execute(arg0); + + + }else { + MessageBox.post("请选中ZF6_ZCTRevision对象","提示",2); + } + + + return null; + } + public static int getItemRevision(TCSession session, String itemId) throws Exception { + System.out.println("Search Revision: " + itemId ); + if (isEmpty(itemId)) { + return 0; + } else { + String queryName = "Item Revision..."; + String[] keys = new String[]{getText(session, "ItemID")}; + String[] vals = new String[]{itemId}; + TCComponent[] res = query(session, queryName, keys, vals); + + if(res==null) { + return 0; + } + + return res.length; + + } + } + public static boolean isEmpty(String str) { + return str == null || "".equals(str.trim()); + } + public static String getText(TCSession session, String str) throws Exception { + if (isEmpty(str)) { + return str; + } else { + String res = session.getTextService().getTextValue(str); + return !isEmpty(res) ? res : str; + } + } + public static TCComponent[] query(TCSession session, String queryName, String[] keys, String[] vals) + throws Exception { + System.out.println("Query: " + queryName); + System.out.println("keys = " + Arrays.toString(keys)); + System.out.println("vals = " + Arrays.toString(vals)); + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + System.out.println("null"+queryName); + } else { + query.clearCache(); + query.refresh(); + return query.execute(keys, vals); + } + return null; + } +// @Override +// public void insertUpdate(DocumentEvent e) { +// // TODO Auto-generated method stub +// +// } +// @Override +// public void removeUpdate(DocumentEvent e) { +// // TODO Auto-generated method stub +// +// } +// @Override +// public void changedUpdate(DocumentEvent e) { +// // TODO Auto-generated method stub +// +// } +} diff --git a/src/com/connor/zf/zygyk/TableCellCheckboxRenderer.java b/src/com/connor/zf/zygyk/TableCellCheckboxRenderer.java new file mode 100644 index 0000000..c4b0f8f --- /dev/null +++ b/src/com/connor/zf/zygyk/TableCellCheckboxRenderer.java @@ -0,0 +1,121 @@ +package com.connor.zf.zygyk; + +import java.awt.Checkbox; +import java.awt.Color; +import java.awt.Component; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.List; + +import javax.swing.JCheckBox; +import javax.swing.JLabel; +import javax.swing.JTable; +import javax.swing.JTextPane; +import javax.swing.SwingConstants; +import javax.swing.event.ChangeEvent; +import javax.swing.event.EventListenerList; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableCellRenderer; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.StyleConstants; + +import com.teamcenter.rac.util.MessageBox; + +public class TableCellCheckboxRenderer extends JCheckBox implements + TableCellRenderer { + private List processRows; + protected EventListenerList listenerList = new EventListenerList(); + protected ChangeEvent changeEvent = new ChangeEvent(this); + private CTMap tableModel; + private JTableHeader tableHeader; + + public List getProcessRows() { + return processRows; + } + + public void setProcessRows(List processRows) { + this.processRows = processRows; + } + + public TableCellCheckboxRenderer(final CTable table) { + this.tableModel = (CTMap) table.getModel(); + this.tableHeader = table.getTableHeader(); + this.setName("4"); + // selectBox = new JCheckBox(tableModel.getColumnName(1)); + this.setSelected(false); + tableHeader.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() > 0) { + // 获得选中列 + int selectColumn = tableHeader.columnAtPoint(e.getPoint()); + if (table.getColumnName(selectColumn).equals("4")) { + boolean value = !TableCellCheckboxRenderer.this.isSelected(); + TableCellCheckboxRenderer.this.setSelected(value); + table.selectAllOrNull(value ? "1" : "0"); + tableHeader.repaint(); + } + } + } + }); + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + // TODO Auto-generated method stub +// if(value != null) +// { +// String valueStr = (boolean)value ? "true" : "false"; +// //System.out.println(valueStr); +// JLabel label = new JLabel(valueStr); +// label.setHorizontalAlignment(SwingConstants.CENTER); // 表头标签剧中 +// this.setHorizontalAlignment(SwingConstants.CENTER);// 表头标签剧中 +// this.setBorderPainted(true); +// this.setSelected((boolean)value); +// } +// else +// { +// String valueStr = (String) value; +// JLabel label = new JLabel(valueStr); +// label.setHorizontalAlignment(SwingConstants.CENTER); // 表头标签剧中 +// this.setHorizontalAlignment(SwingConstants.CENTER);// 表头标签剧中 +// this.setBorderPainted(true); +// this.setSelected(false); +// } +// String valueStr = (String) value; +// JLabel label = new JLabel(valueStr); +// label.setHorizontalAlignment(SwingConstants.CENTER); // 表头标签剧中 + this.setHorizontalAlignment(SwingConstants.CENTER);// 表头标签剧中 + this.setBorderPainted(true); + if(value != null) + { + this.setSelected(value.toString().equals("1")); + } + else + { + this.setSelected(false); + } +// if() +// String valueStr = (String) value; +// JLabel label = new JLabel(valueStr); +// label.setHorizontalAlignment(SwingConstants.CENTER); // 表头标签剧中 +// this.setHorizontalAlignment(SwingConstants.CENTER);// 表头标签剧中 +// this.setBorderPainted(true); + return this; + } + /** + * 查看一个字符串是否可以转换为数字 + * @param str 字符串 + * @return true 可以; false 不可以 + */ + public boolean isStr2Num(String str) { + try { + Integer.parseInt(str); + return true; + } catch (NumberFormatException e) { + return false; + } + } +} \ No newline at end of file diff --git a/src/com/connor/zf/zygyk/TableCellTextAreaRenderer.java b/src/com/connor/zf/zygyk/TableCellTextAreaRenderer.java new file mode 100644 index 0000000..feabf25 --- /dev/null +++ b/src/com/connor/zf/zygyk/TableCellTextAreaRenderer.java @@ -0,0 +1,207 @@ +package com.connor.zf.zygyk; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.util.List; + +import javax.swing.BorderFactory; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.JTextPane; +import javax.swing.table.TableCellRenderer; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.StyleConstants; + +import org.w3c.dom.css.RGBColor; + +public class TableCellTextAreaRenderer extends JTextPane implements + TableCellRenderer { + private List processRows; + private boolean isRelease=false; + public List getProcessRows() { + return processRows; + } + public void setProcessRows(List processRows) { + this.processRows = processRows; + } + public TableCellTextAreaRenderer() { + // setLineWrap(true);//自动换行 + // setWrapStyleWord(true); + } + + public void setIsRelease(boolean isRelease) { + this.isRelease=isRelease; + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + // TODO Auto-generated method stub + int maxPreferredHeight = 0; + if (table.getColumnName(column).equals("RPN")) { + // 5,9,11 + String yzd = table.getValueAt(row, 7) == null ? "0" : table + .getValueAt(row, 7).toString(); + String pds = table.getValueAt(row, 11) == null ? "0" : table + .getValueAt(row, 11).toString(); + String tcd = table.getValueAt(row, 13) == null ? "0" : table + .getValueAt(row, 13).toString(); + int rpn = Integer.parseInt(yzd) * Integer.parseInt(pds) + * Integer.parseInt(tcd); + if (rpn == 0) { + table.setValueAt("", row, column); + setText(""); + } else { + table.setValueAt(String.valueOf(rpn), row, column); + setText(String.valueOf(rpn)); + } + } else { + setText(value == null ? "" : value.toString()); + } + // 特殊符号 + // setText(value == null ? "" : value.toString()); + // if(table.getValueAt(row, table.getColumnCount()-1) == null) + // { + // return this; + // } + // String special = table.getValueAt(row, + // table.getColumnCount()-1).toString(); + // if(special.indexOf("|") >= 0) + // { + // String[] specials = special.split("\\|"); + // for (int i = 0; i < specials.length; i++) { + // if(specials[i].indexOf("-") >= 0) + // { + // String[] columnName = specials[i].split("-"); + // if(table.getColumnName(column).equals(columnName[0])) + // { + // setTextFont(value.toString(),Integer.parseInt(columnName[1]) + // ,"Y14.5M"); + // } + // } + // } + // } + // else if(special.indexOf("-") >= 0) + // { + // String[] columnName = special.split("-"); + // if(table.getColumnName(column).equals(columnName[0])) + // { + // setTextFont(value.toString(),Integer.parseInt(columnName[1]) + // ,"Y14.5M"); + // } + // } + // if(value!=null) + // { + // if(column == 1) + // { + // setTextFont(value.toString(),"Y14.5M"); + // } + // } + + for (int i = 0; i < table.getColumnCount(); i++) { + setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + maxPreferredHeight = Math.max(maxPreferredHeight, + getPreferredSize().height); + } + if (table.getColumnName(column).equals("RPN") && value != null + && !value.equals("") + && Integer.parseInt(value.toString()) >= 100) { + setBackground(Color.RED); + setForeground(Color.black); + } + else if (isRelease) { + setBackground(new Color(220,220,220)); + setForeground(Color.black); + } + + else { + setBackground(Color.white); + setForeground(Color.black); + } + if (isSelected) { + setBackground(new Color(184,184,184)); + setForeground(Color.black); + } + if (table.getRowHeight(row) != maxPreferredHeight)// 少了这行则处理器瞎忙 + { + table.setRowHeight(row, maxPreferredHeight); + } + return this; + } + + // 设置字体,如一个字符串中需要包含多个字体样式,可创建多个SimpleAttributeSet,并将字符串拆分开,按顺序使用Document的insertString方法插入 + private void setTextFont(String value, int index, String font) { + // TODO Auto-generated method stub + SimpleAttributeSet set = new SimpleAttributeSet(); + // StyleConstants.setForeground(set, Color.red);//设置文字颜色 + StyleConstants.setFontFamily(set, font);// 设置字体样式 + SimpleAttributeSet set2 = new SimpleAttributeSet(); + // StyleConstants.setForeground(set, Color.red);//设置文字颜色 + StyleConstants.setFontFamily(set2, "Courier New");// 设置字体样式 + // StyleConstants.setFontSize(set2, 10); + Document doc = this.getStyledDocument(); + try { + // 插入前需要先删除 + doc.remove(0, value.toString().length()); + value = value.replaceAll(" ", ""); + doc.insertString(doc.getLength(), + value.toString().substring(0, index), set2); + doc.insertString(doc.getLength(), + value.toString().substring(index, index + 1), set); + doc.insertString( + doc.getLength(), + value.toString().substring(index + 1, + value.toString().length()), set2); + if (value.toString() + .substring(index + 1, value.toString().length()) == null + || value.toString() + .substring(index + 1, value.toString().length()) + .equals("")) { + doc.insertString(doc.getLength(), " ", set2); + } + } catch (BadLocationException e) { + e.printStackTrace(); + } finally { + set = null; + doc = null; + System.gc(); + } + } + // + // @Override + // public Component getTableCellRendererComponent(JTable table, Object + // value, boolean isSelected, boolean hasFocus, + // int row, int column) { + // // TODO Auto-generated method stub + // int maxPreferredHeight = 0; + // for (int i = 0; i < table.getColumnCount(); i++) { + // setText("" + table.getValueAt(row, i)); + // setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + // maxPreferredHeight = Math.max(maxPreferredHeight, + // getPreferredSize().height); + // } + // setBorder(BorderFactory.createLineBorder(Color.white)); + // setBackground(Color.white); + // setForeground(Color.black); + // if(isSelected){ + // setBackground(new Color(0, 120, 215)); + // setForeground(Color.white); + // } + // String val=(String) table.getValueAt(row, column); + // int w=0; + // if(val!=null){ + // w=val.length()*6/table.getColumn(table.getColumnName(column)).getWidth(); + // } + // if(w!=0){ + // //System.out.println("height:"+table.getRowHeight()*(w+1)); + // table.setRowHeight(row,table.getRowHeight()*(w+1)); + // } + // + // + // setText(value == null ? "" : value.toString()); + // return this; + // } +} \ No newline at end of file diff --git a/src/com/connor/zf/zygyk/TextAreaCellEditor.java b/src/com/connor/zf/zygyk/TextAreaCellEditor.java new file mode 100644 index 0000000..4e5e8ed --- /dev/null +++ b/src/com/connor/zf/zygyk/TextAreaCellEditor.java @@ -0,0 +1,204 @@ +package com.connor.zf.zygyk; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Event; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.io.UnsupportedEncodingException; +import java.util.EventObject; + +import javax.swing.DefaultCellEditor; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.JTextPane; +import javax.swing.event.CaretEvent; +import javax.swing.event.CaretListener; +import javax.swing.event.CellEditorListener; +import javax.swing.event.ChangeEvent; +import javax.swing.event.EventListenerList; +import javax.swing.table.TableCellEditor; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.StyleConstants; + +public class TextAreaCellEditor extends JTextPane implements TableCellEditor, + CaretListener { + private static final long serialVersionUID = 5860619160549087886L; + private EventListenerList listenerList = new EventListenerList(); + private ChangeEvent changeEvent = new ChangeEvent(this); + private int index;// 光标所在位置 + + public TextAreaCellEditor() { + // TODO Auto-generated constructor stub + super(); + this.addCaretListener(this); + // this.setLineWrap(true); //自动换行 + // this.setWrapStyleWord(true); + } + + public int getIndex() { + return index; + } + + @Override + public void addCellEditorListener(CellEditorListener listener) { + // TODO Auto-generated method stub + listenerList.add(CellEditorListener.class, listener); + } + + @Override + public void cancelCellEditing() { + // TODO Auto-generated method stub + System.out.println(2); + } + + @Override + public Object getCellEditorValue() { + // TODO Auto-generated method stub + // System.out.println(3); + return this.getText(); + } + + @Override + public boolean isCellEditable(EventObject arg0) { + // TODO Auto-generated method stub + return true; + } + + @Override + public void removeCellEditorListener(CellEditorListener listener) { + // TODO Auto-generated method stub + listenerList.remove(CellEditorListener.class, listener); + } + + private void fireEditingStopped() { + CellEditorListener listener; + Object[] listeners = listenerList.getListenerList(); + for (int i = 0; i < listeners.length; i++) { + if (listeners[i] == CellEditorListener.class) { + // 之所以是i+1,是因为一个为CellEditorListener.class(Class对象), + // 接着的是一个CellEditorListener的实例 + listener = (CellEditorListener) listeners[i + 1]; + // 让changeEvent去通知编辑器已经结束编辑 + // 在editingStopped方法中,JTable调用getCellEditorValue()取回单元格的值, + // 并且把这个值传递给TableValues(TableModel)的setValueAt() + try { + listener.editingStopped(changeEvent); + } catch (Exception e) { + // TODO: handle exception + System.out.println(e.toString()); + } + } + } + } + + @Override + public boolean shouldSelectCell(EventObject arg0) { + // TODO Auto-generated method stub + return true; + } + + @Override + public boolean stopCellEditing() { + // TODO Auto-generated method stub + // 可以注释掉下面的fireEditingStopped();,然后在GenderEditor的构造函数中把 + // addActionListener()的注释去掉(这时请求终止编辑操作从JComboBox获得), + // System.out.println("编辑其中一个单元格,再点击另一个单元格时,调用。"); + fireEditingStopped();// 请求终止编辑操作从JTable获得 + return true; + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, + boolean isSelect, int row, int column) { + // TODO Auto-generated method stub + setText(value == null ? "" : value.toString()); + // 特殊符号 + if (table.getValueAt(row, table.getColumnCount() - 1) == null) { + return new JScrollPane(this); + } + String special = table.getValueAt(row, table.getColumnCount() - 1) + .toString(); + if (special.indexOf("|") >= 0) { + String[] specials = special.split("\\|"); + for (int i = 0; i < specials.length; i++) { + if (specials[i].indexOf("-") >= 0) { + String[] columnName = specials[i].split("-"); + if (table.getColumnName(column).equals(columnName[0])) { + setTextFont(value.toString(), + Integer.parseInt(columnName[1]), "Y14.5M"); + } + } + } + } else if (special.indexOf("-") >= 0) { + String[] columnName = special.split("-"); + if (table.getColumnName(column).equals(columnName[0])) { + setTextFont(value.toString(), Integer.parseInt(columnName[1]), + "Y14.5M"); + } + } + // if(value!=null) + // { + // if(cloumn == 1) + // { + // setTextFont(value.toString(),"Y14.5M"); + // } + // } + // System.out.println(8) + return new JScrollPane(this); + } + + @Override + public void caretUpdate(CaretEvent caretevent) { + // TODO Auto-generated method stub + index = caretevent.getMark(); + // System.out.println(index); + } + + // 设置字体,如一个字符串中需要包含多个字体样式,可创建多个SimpleAttributeSet,并将字符串拆分开,按顺序使用Document的insertString方法插入 + private void setTextFont(String value, int index, String font) { + // TODO Auto-generated method stub + SimpleAttributeSet set = new SimpleAttributeSet(); + // StyleConstants.setForeground(set, Color.red);//设置文字颜色 + StyleConstants.setFontFamily(set, font);// 设置字体样式 + // StyleConstants.setFontSize(set, 14); + SimpleAttributeSet set2 = new SimpleAttributeSet(); + // StyleConstants.setForeground(set, Color.red);//设置文字颜色 + StyleConstants.setFontFamily(set2, "Courier New");// 设置字体样式 + // StyleConstants.setFontSize(set2, 10); + Document doc = this.getStyledDocument(); + try { + // 插入前需要先删除 + doc.remove(0, value.toString().length()); + value = value.replaceAll(" ", ""); + doc.insertString(doc.getLength(), + value.toString().substring(0, index), set2); + doc.insertString(doc.getLength(), + value.toString().substring(index, index + 1), set); + doc.insertString( + doc.getLength(), + value.toString().substring(index + 1, + value.toString().length()), set2); + if (value.toString() + .substring(index + 1, value.toString().length()) == null + || value.toString() + .substring(index + 1, value.toString().length()) + .equals("")) { + doc.insertString(doc.getLength(), " ", set2); + } + } catch (BadLocationException e) { + e.printStackTrace(); + } finally { + set = null; + doc = null; + System.gc(); + } + } +} diff --git a/src/com/connor/zf/zygyk/ZYGYKCommand.java b/src/com/connor/zf/zygyk/ZYGYKCommand.java new file mode 100644 index 0000000..816fb75 --- /dev/null +++ b/src/com/connor/zf/zygyk/ZYGYKCommand.java @@ -0,0 +1,709 @@ +package com.connor.zf.zygyk; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.Array; +import java.sql.ResultSet; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.UUID; + +import javax.xml.crypto.Data; + +import com.connor.zf.controlplan.SqlUtilT; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.commands.reserve.ReserveOperation; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentMEOPRevision; +import com.teamcenter.rac.kernel.TCComponentMEProcess; +import com.teamcenter.rac.kernel.TCComponentMEProcessRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSKeyLov; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.kernel.ics.ICSPropertyDescription; +import com.teamcenter.rac.util.MessageBox; + +public class ZYGYKCommand extends AbstractAIFCommand { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private boolean isReImport=true;//是否是重新导入,如果是重新导入true,那么数据就从控制计划获取,否则false就数据从上个版本继承 + private TCComponentItemRevision meop = null; + public ZYGYKCommand(AbstractAIFApplication app, TCSession session, + InterfaceAIFComponent comp,boolean isReImport) { + // TODO Auto-generated constructor stub + this.session = session; + this.app = app; + this.comp = comp; + this.isReImport=isReImport; + } + + @Override + public void executeModal() throws Exception { + //判断是否打开签出 + if(((TCComponent) comp).isCheckedOut()) { + MessageBox.post("作业工艺卡正在编辑!(已签出)", "错误", MessageBox.ERROR); + return; + } + //没签出则在打开时签出对象 + new ReserveOperation(new AIFComponentContext(comp, + comp, "context")).executeModeless(); + + TCComponentItemRevision itemRevision = (TCComponentItemRevision) this.comp; + + + + //判断是否是最新版本 + ResultSet rs0 = null; + ResultSet rs1 = null; + ResultSet rs2 = null; + InputStream input = null; + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + TCComponent[] Revisions=itemRevision.getReferenceListProperty("revision_list"); + String revisionID=itemRevision.getProperty("item_revision_id"); + // 获取数据库连接、 + SqlUtilT.getTCConnection(); + String sql0 = String.format(pro.getProperty("RB3_ZYGYKHEADSELECT"), comp.getUid()); + rs0 = SqlUtilT.read(sql0); + + SqlUtilT.getTCConnection(); + String sql1 = String.format(pro.getProperty("RB3_PRODUCTSELECT"), comp.getUid()); + rs1 = SqlUtilT.read(sql1); + + SqlUtilT.getTCConnection(); + String sql2 = String.format(pro.getProperty("RB3_PROCESSSELECT"), comp.getUid()); + rs2 = SqlUtilT.read(sql2); + + + + System.out.println("revisionID====>"+revisionID); + System.out.println("Revisions====>"+Revisions); + + if(Revisions.length>1&&!rs0.next()&&!rs1.next()&&!rs2.next()&&!isReImport) {//如果是重新导入则不继承 + System.out.println("不是第一版本!!!"); + List addData0=new ArrayList(); + List> addData1=new ArrayList>(); + List> addData2=new ArrayList>(); + + char revID=revisionID.toCharArray()[0]; + String lastRevID=""; + String flagTime = "2008-10-01 14:42:32"; + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date lastRevData = (Date) format.parse(flagTime); + String lastRevUid=""; + for(TCComponent rev:Revisions) { + if(rev.getProperty("release_status_list")!="") { + if(lastRevData.before(rev.getDateProperty("date_released"))) { + lastRevData=(Date) rev.getDateProperty("date_released"); + lastRevUid=rev.getUid(); + lastRevID=rev.getProperty("item_revision_id"); + } + } +// if(rev.getProperty("item_revision_id").equals(lastRevID)) { +// lastRevUid=rev.getUid(); +// break; +// } + } + System.out.println("lastRevID========>"+lastRevID); + System.out.println("lastRevUid========>"+lastRevUid); + + + try { + //获取上个版本的表头数据 + SqlUtilT.getTCConnection(); + sql0 = String.format(pro.getProperty("RB3_ZYGYKHEADSELECT"), lastRevUid); + rs0 = SqlUtilT.read(sql0); + + sql1 = String.format(pro.getProperty("RB3_PRODUCTSELECT"), lastRevUid); + rs1 = SqlUtilT.read(sql1); + + sql2 = String.format(pro.getProperty("RB3_PROCESSSELECT"), lastRevUid); + rs2 = SqlUtilT.read(sql2); + + while(rs0.next()) { + addData0.add(UUID.randomUUID().toString().replace("-", "")); + addData0.add(itemRevision.getUid()); + addData0.add(rs0.getString("GYKLX")); + addData0.add(rs0.getString("CPXH")); + addData0.add(rs0.getString("GXMC")); + addData0.add(rs0.getString("SLYSGG")); + addData0.add(rs0.getString("SLYSCZ")); + addData0.add(rs0.getString("SBXH")); + addData0.add(rs0.getString("CHSBXH")); + addData0.add(rs0.getString("YHSBXH")); + addData0.add(rs0.getString("DJDPXH")); + addData0.add(rs0.getString("LJMC")); + } + + + + while(rs1.next()) { + List dataList=new ArrayList(); + dataList.add(UUID.randomUUID().toString().replace("-", "")); + dataList.add(itemRevision.getUid()); + dataList.add(rs1.getString("NO")); + dataList.add(rs1.getString("JCXM")); + dataList.add(rs1.getString("ZYD")); + dataList.add(rs1.getString("YQ")); + dataList.add(rs1.getString("JCFF"));//5 + dataList.add(rs1.getString("SJ1")); + dataList.add(rs1.getString("ZJPC")); + dataList.add(rs1.getString("SJ2")); + dataList.add(rs1.getString("JYPC")); + dataList.add(rs1.getString("FYJH"));//10 + addData1.add(dataList); + } + + while(rs2.next()) { + List dataList=new ArrayList(); + dataList.add(UUID.randomUUID().toString().replace("-", "")); + dataList.add(itemRevision.getUid()); + dataList.add(rs2.getString("NO")); + dataList.add(rs2.getString("JCXM")); + dataList.add(rs2.getString("ZYD")); + dataList.add(rs2.getString("YQ")); + dataList.add(rs2.getString("JCFF"));//5 + dataList.add(rs2.getString("RL")); + dataList.add(rs2.getString("PL")); + dataList.add(rs2.getString("FYJH")); + addData2.add(dataList); + } + + System.out.println("插入新版本表格1数据:"+addData1); + System.out.println("插入新版本表格2数据:"+addData2); + + //插入表格1数据 + System.out.println("--------插入表格1数据-----------"); + System.out.println("addData1===>"+addData1); + for(int i=0;i dataList=new ArrayList(); + dataList=addData1.get(i); + String[] data=dataList.toArray(new String[]{}); + String insertSQL = pro.getProperty("RB3_PRODUCTINSERT"); + SqlUtilT.getTCConnection(); + SqlUtilT.write2(data, insertSQL); + + } + SqlUtilT.connection.commit(); + //插入表格2数据 + System.out.println("--------插入表格2数据-----------"); + System.out.println("addData2===>"+addData2); + for(int i=0;i dataList=new ArrayList(); + dataList=addData2.get(i); + String[] data=dataList.toArray(new String[]{}); + String insertSQL = pro.getProperty("RB3_PROCESSINSERT"); + SqlUtilT.getTCConnection(); + SqlUtilT.write2(data, insertSQL); + + } + SqlUtilT.connection.commit(); + + + //插入表头数据 + System.out.println("--------插入表头数据-----------"); + System.out.println("addData0===>"+addData0); + String[] data=addData0.toArray(new String[]{}); + System.out.println("数组data===>"+Arrays.toString(data)); + String insertSQL = "insert into ZF6_ZYGYKHEAD values(?,?,?,?,?,?,?,?,?,?,?,?)"; + SqlUtilT.write2(data, insertSQL); + SqlUtilT.connection.commit();//提交事务 + + + + + }catch (Exception e) { + MessageBox.post(e.toString(), "错误", MessageBox.ERROR); + e.printStackTrace(); + }finally { + if (rs0 != null) { + SqlUtilT.free(rs0); + } + if (rs1 != null) { + SqlUtilT.free(rs1); + } + if (rs2 != null) { + SqlUtilT.free(rs2); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + + + // TODO Auto-generated method stub + // 根据选中对象的PUID获取数据 + final List> productData = new ArrayList>(); + final List> processData = new ArrayList>(); + final List productPlmeidList = new ArrayList(); + final List processPlmeidList = new ArrayList(); + + final List headList = new ArrayList();//表头数据 + + ResultSet rs = null; + ResultSet machiningParameterRs = null; + ResultSet controlRequirementRs = null; + ResultSet headrs=null; + try { + // 获取数据库连接 + SqlUtilT.getTCConnection(); + String sql = String.format(pro.getProperty("RB3_PRODUCTSELECT"), comp.getUid()); + rs = SqlUtilT.read(sql); + while (rs.next()) { + List rowList = new ArrayList(); + rowList.add(rs.getString("PLMEID")); + rowList.add(rs.getString("NO")); + rowList.add(rs.getString("JCXM")); + rowList.add(rs.getString("ZYD")); + rowList.add(rs.getString("YQ")); + rowList.add(rs.getString("JCFF")); + rowList.add(rs.getString("SJ1")); + rowList.add(rs.getString("ZJPC")); + rowList.add(rs.getString("SJ2")); + rowList.add(rs.getString("JYPC")); + rowList.add(rs.getString("FYJH")); + productData.add(rowList); + productPlmeidList.add(rs.getString("PLMEID")); + } + SqlUtilT.getTCConnection(); + sql = String.format(pro.getProperty("RB3_PROCESSSELECT"), comp.getUid()); + machiningParameterRs = SqlUtilT.read(sql); + while (machiningParameterRs.next()) { + List rowList = new ArrayList(); + rowList.add(machiningParameterRs.getString("PLMEID")); + rowList.add(machiningParameterRs.getString("NO")); + rowList.add(machiningParameterRs.getString("JCXM")); + rowList.add(machiningParameterRs.getString("ZYD")); + rowList.add(machiningParameterRs.getString("YQ")); + rowList.add(machiningParameterRs.getString("JCFF")); + rowList.add(machiningParameterRs.getString("RL")); + rowList.add(machiningParameterRs.getString("PL")); + rowList.add(machiningParameterRs.getString("FYJH")); + processData.add(rowList); + processPlmeidList.add(machiningParameterRs.getString("PLMEID")); + } + + sql = String.format(pro.getProperty("RB3_ZYGYKHEADSELECT"), comp.getUid()); + headrs = SqlUtilT.read(sql); + while (headrs.next()) { + headList.add(headrs.getString("PLMEID")); + headList.add(headrs.getString("PUID")); + headList.add(headrs.getString("GYKLX")); + headList.add(headrs.getString("CPXH")); + headList.add(headrs.getString("GXMC")); + headList.add(headrs.getString("SLYSGG")); + headList.add(headrs.getString("SLYSCZ")); + headList.add(headrs.getString("SBXH")); + headList.add(headrs.getString("CHSBXH")); + headList.add(headrs.getString("YHSBXH")); + headList.add(headrs.getString("DJDPXH")); + headList.add(headrs.getString("LJMC")); + } + System.out.println("headList===>"+headList); + if(headList.size()==0) { + headList.add(UUID.randomUUID().toString().replace("-", "")); + headList.add(comp.getUid()); + for(int i=0;i<10;i++) { + headList.add(""); + } + + //插入表头数据 + String[] data=headList.toArray(new String[]{}); + System.out.println("数组data===>"+Arrays.toString(data)); + String insertSQL = "insert into ZF6_ZYGYKHEAD values(?,?,?,?,?,?,?,?,?,?,?,?)"; + SqlUtilT.write2(data, insertSQL); + SqlUtilT.connection.commit();//提交事务 + } + + } catch (Exception e) { + MessageBox.post(e.toString(), "错误", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (machiningParameterRs != null) { + SqlUtilT.free(machiningParameterRs); + } + if (controlRequirementRs != null) { + SqlUtilT.free(controlRequirementRs); + } + if (headrs != null) { + SqlUtilT.free(headrs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + + + + //根据当前选中对象获取工序 + //TCComponentItemRevision itemRevision = (TCComponentItemRevision)comp; + AIFComponentContext[] aifccs = itemRevision.whereReferenced(); + System.out.println("aifccs====>"+aifccs.toString()); + + for (AIFComponentContext aifcc_MEOP : aifccs) { + if (aifcc_MEOP.getComponent().getType().indexOf("ZF6_GXRevision")>=0) { + meop = (TCComponentItemRevision)aifcc_MEOP.getComponent(); + break; + } + } + + + //+++获取工艺控制计划的选择最新版本的数据给作业工艺卡作为初始数据 + if(productData.size()<=0&&processData.size()<=0) + { + //获取对象工艺 + TCComponentItemRevision meprocess = null; + System.out.println("meop===>"+meop); + if(meop != null) + { + TCComponent[] its = meop.getItem().whereUsed(TCComponent.WHERE_USED_ALL); + System.out.println("its===>"+its); + for (TCComponent tcComponent : its) { + System.out.println("tcComponent.gettype====>"+tcComponent.getType()); + if (tcComponent.getType().indexOf("ZF6_GYLXRevision")>=0) { + meprocess = (TCComponentItemRevision)tcComponent; + break; + } + } + } + System.out.println("meprocess===>"+meprocess); + if(meprocess == null) + { + MessageBox.post("未找到工艺!", "错误", MessageBox.ERROR); + return; + } + + + //String meprocessUid = meprocess.getItem().getUid(); + String meopId = meop.getItem().getStringProperty("item_id"); + //String itemType = getControlType((TCComponentItem)meprocess.getItem()); + + + TCComponent[] ControlComponents = meprocess.getReferenceListProperty("ZF6_R_KZJH"); + System.out.println("ControlComponents===>"+ControlComponents); + System.out.println("ControlComponentslength===>"+ControlComponents.length); + + String controlUid=""; + for(int i=0;i= 0) { + TCComponent[] ControlRevisions=ControlComponents[i].getReferenceListProperty("revision_list"); + + controlUid=ControlRevisions[ControlRevisions.length-1].getUid();//选择最新版本的UID + } + } + System.out.println("controlUid===>"+controlUid); + //++++ + + ResultSet rsData = null; + try { + // 获取数据库连接 + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + + + String sql = String.format(pro.getProperty("RB3_CONTROLPLANTOGYK"), controlUid,meopId); + rsData = SqlUtilT.read(sql); + System.out.println("sql===========>"+sql); + Integer rowIndexprocess = 0; + Integer rowIndexproduct = 0; + int flag=0; + int sflag=0; + int zflag=0; + int xflag=0; + int BH=1; + + + Map map=new HashMap(); + Map> maptoList=new HashMap>(); + List rowList = new ArrayList(); + //String ss=rsData.toString(); + List RowList = new ArrayList(); + System.out.print("========>"+sql); + while (rsData.next()) { + System.out.println("rsData===>"+rsData.getString("CP")); + System.out.println("rsData===>"+rsData.getString("GC")); + if(!rsData.getString("CP").equals("")) { + System.out.println("-----------获取产品数据-----------"); + //获取产品特性表的数据 + if(rsData.getString("XM").indexOf("首检")>=0) { + if(map.size()>0) { + + rowList.set(6, map.get("操作员首检")); + rowList.set(7, (map.get("自检频次")==null&& map.get("检验频次").equals("每班"))?"每班":map.get("自检频次")); + rowList.set(8, map.get("检验员首检")); + rowList.set(9, map.get("检验频次")); + System.out.println("遇到下一个首检时收集上个的数据====》"+rowList); + List row = new ArrayList(); + for(int i=0;i=0) { + System.out.println("++++++++++收集自检频次"); + map.put("自检频次", rsData.getString("RL")+"/"+rsData.getString("PL")); + }else if(rsData.getString("XM").indexOf("巡检")>=0) { + System.out.println("++++++++++收集检验员"); + map.put("检验员首检", rsData.getString("RL")); + if(rsData.getString("PL").equals("每班")) { + map.put("检验频次", rsData.getString("PL")); + }else { + map.put("检验频次", rsData.getString("RL")+"/"+rsData.getString("PL")); + } + + } +// if(map.size()==4) { +// List rowList = new ArrayList(); +// rowList.add(UUID.randomUUID().toString().replace("-", ""));//0plmeid +// rowList.add(String.valueOf(rowIndexproduct));//1NO +// rowList.add(String.valueOf(rsData.getString("CP")));//2检查项目 +// rowList.add(String.valueOf(rsData.getString("TSTXFL")));//3重要度 +// rowList.add(String.valueOf(rsData.getString("CPGC")));//4要求 +// rowList.add(String.valueOf(rsData.getString("JSCLJS")));//5检查方法 +// rowList.add(String.valueOf(map.get("操作员首检")));//6操作员首检 +// rowList.add(String.valueOf(map.get("自检频次")));//7自检频次 +// rowList.add(String.valueOf(map.get("检验员首检")));//8检验员首检 +// rowList.add(String.valueOf(map.get("检验频次")));//9检验频次 +// rowList.add(String.valueOf(rsData.getString("FYJH")));//10反应计划 +// productData.add(rowList); +// +// map.clear(); +// rowIndexproduct++; +// } + }else if(!rsData.getString("GC").equals("")) { + System.out.println("-----------获取过程数据-----------"); + if(map.size()>0) { + + rowList.set(6, map.get("操作员首检")); + rowList.set(7, map.get("自检频次")); + rowList.set(8, map.get("检验员首检")); + rowList.set(9, map.get("检验频次")); + System.out.println("===>过程数据中收集剩余产品数据:"+rowList); + List row = new ArrayList(); + for(int i=0;i rowLists = new ArrayList(); + rowLists.add(UUID.randomUUID().toString().replace("-", ""));//0plmeid + rowLists.add(String.valueOf(rowIndexprocess));//1NO + rowLists.add(String.valueOf(rsData.getString("GC")));//2检查项目 + rowLists.add(String.valueOf(rsData.getString("TSTXFL")));//3重要度 + rowLists.add(String.valueOf(rsData.getString("CPGC")));//4要求 + rowLists.add(String.valueOf(rsData.getString("JSCLJS")));//5检查方法 + rowLists.add(String.valueOf(rsData.getString("RL")));//6容量 + rowLists.add(String.valueOf(rsData.getString("PL")));//7频率 + rowLists.add(String.valueOf(rsData.getString("FYJH")));//8反应计划 + processData.add(rowLists); + + + } + + + + } + if(map.size()>0) { + System.out.println("-------最后收集数据-------"); + + rowList.set(6, map.get("操作员首检")); + rowList.set(7, map.get("自检频次")); + rowList.set(8, map.get("检验员首检")); + rowList.set(9, map.get("检验频次")); + System.out.println("rowList====>"+rowList); + List row = new ArrayList(); + for(int i=0;i"+productData); + new Thread() { + @Override + public void run() { + new ZYGYKDialog(app, session, comp, meop,productData, processData,productPlmeidList, processPlmeidList, + headList); + super.run(); + } + }.start(); + super.executeModal(); + } + + + + + + /** + * 获取最新的控制计划 + * @param item2 选中的工序 + * @return + * @throws Exception + */ + private String getControlType(TCComponentItem tccmep) throws Exception { + String kzjhType = null; + + AIFComponentContext[] tccmepChildrens = tccmep.getChildren(); + for (AIFComponentContext tccmepChildren : tccmepChildrens) { + if (tccmepChildren.getComponent() instanceof TCComponentItem) { + TCComponentItem kzjh = (TCComponentItem) tccmepChildren.getComponent(); + String itemType = kzjh.getType(); + System.out.println("kzjh=========================>"+kzjh); + if ("RB3_SCKZJH".equals(itemType)) + { + //判断是否为生产控制计划 + return itemType; + } + + if ("RB3_SSCKZJH".equals(itemType)) + { + return itemType; + } + + if ("RB3_YJKZJH".equals(itemType)) + { + return itemType; + } + } + } + return kzjhType; + } + + + //+++当属性是LOV值时,获取到的只是属性值的序号,而不是对应的属性值 +// TCComponentICO[] icos = item.getClassificationObjects();//获取到其分类 +// if (icos.length <= 0) { +// continue; +// } +// ICSProperty[] icsValues = icos[0].getICSProperties(true);//获取到分类属性的值 +// ICSPropertyDescription[] icsDNames = icos[0].getICSPropertyDescriptors();//获取分类属性的名称 +// for (ICSPropertyDescription icsName : icsDNames) { +// //获取工装名称 +// if (icsName.getName().indexOf("工装名称") >= 0 || icsName.getName().indexOf("物料名称") >= 0||icsName.getName().indexOf("砂轮形状") >= 0||icsName.getName().indexOf("油石形状") >= 0) { +// String value =""; +// for (ICSProperty icsValue : icsValues) { +// if (icsValue.getId() == icsName.getId()) { +// if(ClassID.substring(0,2).equals("13")) { +// //获取分类属性lov的值。icsValue。当icsValue.getValue()获取到的值是下拉选项的时候,getValue获取到的只是顺序号,所以只能通过getClassDisplayableValue获取 +// value = getClassDisplayableValue(icsValue.getValue(),icsName); +// }else { +// value = icsValue.getValue(); +// } +// } +// } +// values[0] = value; +// } + + + + /** + * 获取分类属性LOV显示值 + * +++key是序号,获取到的是序号,如果key和的值和value匹配,则getValueOfKey(key)获得属性的String值 + * @param icsD + * @return + */ + public static String getClassDisplayableValue(String value ,ICSPropertyDescription icsD) + { + String result = ""; + ICSKeyLov lov1 = icsD.getFormat().getKeyLov(); + if (lov1 != null) { + String[] keys = lov1.getKeys(); + for (String key : keys) { + if(value.equals(key)) + { + result = lov1.getValueOfKey(key); + return result; + } + } + } + return result; + } + +} diff --git a/src/com/connor/zf/zygyk/ZYGYKDialog.java b/src/com/connor/zf/zygyk/ZYGYKDialog.java new file mode 100644 index 0000000..e59845b --- /dev/null +++ b/src/com/connor/zf/zygyk/ZYGYKDialog.java @@ -0,0 +1,1245 @@ +package com.connor.zf.zygyk; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Properties; +import java.util.ResourceBundle; +import java.util.UUID; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.JViewport; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableColumn; + +import com.connor.zf.controlplan.MultiComboBox; +import com.connor.zf.controlplan.SqlUtilT; +import com.connor.zf.controlplan.TMomMethodUtil; +import com.connor.zf.controlplan.outPutExcel; +import com.connor.zf.editClassAttr.JAutoCompleteComboBox; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.commands.reserve.ReserveOperation; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.services.rac.core.ReservationService; + +public class ZYGYKDialog extends JFrame implements ActionListener { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCComponent form; + private TCProperty[] properties; + private TCComponentItemRevision itemRevision; + private TCComponentItemRevision meop; + private List processRows=new ArrayList();;// 当前用户可修改的行号 + + private List> productData; + private List> processData; + + private List productPlmeidList; + private List processPlmeidList; + + private List productDeleteList = new ArrayList(); + private List processDeleteList = new ArrayList(); + + private HashMap GYKLXTOUID=new HashMap(); + private List headList = new ArrayList(); + // 右键菜单 + private static JPopupMenu menu; + // 右键菜单项 + private JMenuItem addRowItem; + private JMenuItem addRowsItem; + private JMenuItem remItem; + // 界面控件 + private JLabel GYKLXLabel;//工艺卡类型 + private JAutoCompleteComboBox GYKLXField; + private JLabel CPXHLabel;//产品型号 + private JTextField CPXHField; + private JLabel GXMCLabel;//工序名称 + private JTextField GXMCField; + private JLabel SLYSGGLabel;//砂轮油石规格 + private JTextField SLYSGGField; + private JLabel SLYSCZLabel;//砂轮油石材质 + private JTextField SLYSCZField; + private JLabel SBXHLabel;//设备型号 + private JTextField SBXHField; + private JLabel CHSBXHLabel;//淬火设备型号 + private JTextField CHSBXHField; + private JLabel YHSBXHLabel;//回火设备型号 + private JTextField YHSBXHField; + private JLabel DJDPXHLabel;//刀具刀片型号 + private JTextField DJDPXHField; + private JLabel LJMCLabel;//零件名称 + private JTextField LJMCField; + + private JLabel konghang;//空行 + + + // 选项卡 + private JTabbedPane tabbedPane; + private TCComponentDataset Dataset; + private TCComponentTcFile picFile; + private String outFilePathp=null; + private TCComponent[] comps; + private PicDialog picDialog; + + private String[] productHeader = new String[] { "PLMEID", "编号", "检查项目", "重要度", "要求", "检查方法", "操作员首检", "自检频次", + "检验员首检", "检验频次", "反应计划" }; + private CTable productTable;// 产品特性 + private String[] processHeader = new String[] { "PLMEID", "编号", "检查项目", "重要度", "要求","检查方法", "容量", "频率","反应计划"}; + private CTable processTable;// 过程特性 + + // 按钮 + private JPanel rootPanel; + private JButton reImportButton; + private JButton ImportGYK; + private JButton selectPicture; + private JButton okButton; + private JButton celButton; + + public ZYGYKDialog(AbstractAIFApplication app, TCSession session, InterfaceAIFComponent comp,TCComponentItemRevision meop, + List> productData, List> processData, List productPlmeidList, + List processPlmeidList,List headList) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.comp = comp; + this.meop=meop; + this.productData = productData; + this.processData = processData; + this.processPlmeidList = processPlmeidList; + this.productPlmeidList = productPlmeidList; + this.headList=headList; + this.itemRevision= (TCComponentItemRevision) this.comp; + init(); + } + + private void init() { + //获取国际化语言 + Toolkit kit = Toolkit.getDefaultToolkit(); //定义工具包 + Dimension screenSize = kit.getScreenSize(); //获取屏幕的尺寸 + int screenWidth = screenSize.width; //获取屏幕的宽 + int screenHeight = screenSize.height; //获取屏幕的高 + this.setLocation(screenWidth / 2 - 1150 / 2, screenHeight / 2 - 650 / 2);//设置窗口居中显示 + // TODO Auto-generated method stub + this.setTitle("作业工艺卡"); + this.setPreferredSize(new Dimension(1150, 650)); + this.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + dispose(); + } + }); + this.GYKLXLabel = new JLabel("工艺卡类型"); + this.GYKLXLabel.setPreferredSize(new Dimension(80, 30)); + this.GYKLXField = new JAutoCompleteComboBox(); + this.GYKLXField.setPreferredSize(new Dimension(120, 30)); + this.GYKLXField.setSelectedItem(headList.get(2)); + TCPreferenceService service = session.getPreferenceService(); + String[] strs = service.getStringValues("ZF6_GYK_Template"); + System.out.println("工艺卡类型综合======》"+Arrays.toString(strs)); + GYKLXField.setEditable(false); + for (String str : strs) { + if(str.indexOf("工艺卡")>=0) { + GYKLXField.addItem(str.split(":")[0]); + GYKLXTOUID.put(str.split(":")[0], str.split(":")[1]); + } + } + this.CPXHLabel = new JLabel("产品型号"); + this.CPXHLabel.setPreferredSize(new Dimension(100, 30)); + this.CPXHField = new JTextField(headList.get(3)); + this.CPXHField.setPreferredSize(new Dimension(100, 30)); + this.GXMCLabel = new JLabel("工序名称"); + this.GXMCLabel.setPreferredSize(new Dimension(100, 30)); + try { + this.GXMCField = new JTextField((headList.get(4)==null||headList.get(4).equals("")?meop.getStringProperty("object_name"):headList.get(4))); + } catch (TCException e3) { + // TODO Auto-generated catch block + e3.printStackTrace(); + } + this.GXMCField.setPreferredSize(new Dimension(100, 30)); + this.SLYSGGLabel = new JLabel("砂轮/油石规格"); + this.SLYSGGLabel.setPreferredSize(new Dimension(100, 30)); + this.SLYSGGField = new JTextField(headList.get(5)); + this.SLYSGGField.setPreferredSize(new Dimension(100, 30)); + this.SLYSCZLabel = new JLabel("砂轮/油石材质"); + this.SLYSCZLabel.setPreferredSize(new Dimension(100, 30)); + this.SLYSCZField = new JTextField(headList.get(6)); + this.SLYSCZField.setPreferredSize(new Dimension(100, 30)); + this.SBXHLabel = new JLabel("设备型号"); + this.SBXHLabel.setPreferredSize(new Dimension(100, 30)); + this.SBXHField = new JTextField(headList.get(7)); + this.SBXHField.setPreferredSize(new Dimension(120, 30)); + this.CHSBXHLabel = new JLabel("淬火设备型号"); + this.CHSBXHLabel.setPreferredSize(new Dimension(100, 30)); + this.CHSBXHField = new JTextField(headList.get(8)); + this.CHSBXHField.setPreferredSize(new Dimension(100, 30)); + this.YHSBXHLabel = new JLabel("回火设备型号"); + this.YHSBXHLabel.setPreferredSize(new Dimension(100, 30)); + this.YHSBXHField = new JTextField(headList.get(9)); + this.YHSBXHField.setPreferredSize(new Dimension(100, 30)); + this.DJDPXHLabel = new JLabel("刀具、刀片型号"); + this.DJDPXHLabel.setPreferredSize(new Dimension(110, 30)); + this.DJDPXHField = new JTextField(headList.get(10)); + this.DJDPXHField.setPreferredSize(new Dimension(90, 30)); + this.LJMCLabel = new JLabel("零件名称"); + this.LJMCLabel.setPreferredSize(new Dimension(100, 30)); + this.LJMCField = new JTextField(headList.get(11)); + this.LJMCField.setPreferredSize(new Dimension(100, 30)); + + + JPanel titlePanel = new JPanel(new PropertyLayout()); + titlePanel.add("1.1.left.top", this.GYKLXLabel); + titlePanel.add("1.2.left.top", this.GYKLXField); + titlePanel.add("1.3.left.top", this.CPXHLabel); + titlePanel.add("1.4.left.top", this.CPXHField); + titlePanel.add("1.5.left.top", this.GXMCLabel); + titlePanel.add("1.6.left.top", this.GXMCField); + titlePanel.add("1.7.left.top", this.SLYSGGLabel); + titlePanel.add("1.8.left.top", this.SLYSGGField); + titlePanel.add("1.9.left.top", this.SLYSCZLabel); + titlePanel.add("1.10.left.top", this.SLYSCZField); + titlePanel.add("2.1.left.top", this.SBXHLabel); + titlePanel.add("2.2.left.top", this.SBXHField); + titlePanel.add("2.3.left.top", this.CHSBXHLabel); + titlePanel.add("2.4.left.top", this.CHSBXHField); + titlePanel.add("2.5.left.top", this.YHSBXHLabel); + titlePanel.add("2.6.left.top", this.YHSBXHField); + titlePanel.add("2.7.left.top", this.DJDPXHLabel); + titlePanel.add("2.8.left.top", this.DJDPXHField); + titlePanel.add("2.9.left.top", this.LJMCLabel); + titlePanel.add("2.10.left.top", this.LJMCField); + try { + if(comp.getProperty("release_status_list")!="") { + setPanelEnabled(titlePanel,false); + } + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + + + if (this.productData.size() > 0) { + this.productTable = getjTable(null, null, productHeader, this.productData.size()); + } else { + this.productTable = getjTable(null, null, productHeader, 1); + } + //设置表格列宽 + for(int i=0;i 0) { + this.processTable = getjTable(null, null, processHeader, + this.processData.size()); + } else { + this.processTable = getjTable(null, null, processHeader, 1); + } + + this.processTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if (mouseevent.getClickCount() == 1) { + + ((CTMap) processTable.getModel()).setRow(processTable.getSelectedRow()); + ((CTMap) processTable.getModel()).setColumn(processTable.getSelectedColumn()); + } + if (mouseevent.getButton() == MouseEvent.BUTTON3) { + menu.show(processTable, mouseevent.getX(), mouseevent.getY()); + } + } + }); + + tabbedPane = new JTabbedPane(); + + tabbedPane.addTab("产品特性", new JScrollPane(this.productTable)); + tabbedPane.addTab("过程特性", new JScrollPane(this.processTable)); + + //setText(); + setProductTable(); + setProcessTable(); + + rootPanel = new JPanel(new FlowLayout()); + this.okButton = new JButton("保存"); + this.okButton.setPreferredSize(new Dimension(100, 30)); + this.celButton = new JButton("取消"); + this.celButton.setPreferredSize(new Dimension(100, 30)); + this.ImportGYK = new JButton("导出作业工艺卡"); + this.ImportGYK.setPreferredSize(new Dimension(150, 30)); + this.reImportButton = new JButton("重新导入"); + this.reImportButton.setPreferredSize(new Dimension(120, 30)); + rootPanel.add(ImportGYK); + rootPanel.add(okButton); + rootPanel.add(celButton); + rootPanel.add(reImportButton); + + // 初始化右键菜单 + menu = new JPopupMenu(); + + addRowItem = new JMenuItem("添加行"); + addRowsItem = new JMenuItem("添加多行"); + remItem = new JMenuItem("移除行"); + + menu.add(addRowItem); + menu.add(addRowsItem); + menu.add(remItem); + + // 添加鼠标监听 + this.createActionEvent(); + this.setLayout(new BorderLayout()); + this.add(titlePanel, BorderLayout.NORTH); + this.add(tabbedPane, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + this.pack(); + this.show(); + } + +// /*** +// * 设置控件值 +// */ +// private void setText() { +// this.companyNameField.setText(this.properties[0].getStringValue()); +// this.itemIdField.setText(this.properties[1].getStringValue()); +// this.equipmentIdField.setText(this.properties[2].getStringValue()); +// this.meopField.setText(this.properties[3].getStringValue()); +// this.equipmentNameField.setText(this.properties[4].getStringValue()); +// } + + /*** + * 设置控件值 + */ + private void getText() { + headList.set(2, this.GYKLXField.getText());//工艺卡类型 + headList.set(3, this.CPXHField.getText());////产品型号 + headList.set(4, this.GXMCField.getText());//工序名称 + headList.set(5, this.SLYSGGField.getText());//砂轮油石规格 + headList.set(6, this.SLYSCZField.getText());//砂轮油石材质 + headList.set(7, this.SBXHField.getText());//设备型号 + headList.set(8, this.CHSBXHField.getText());//淬火设备型号 + headList.set(9, this.YHSBXHField.getText());//回火设备型号 + headList.set(10, this.DJDPXHField.getText());//刀具刀片型号 + headList.set(11, this.LJMCField.getText());//零件名称 + } + + private void setProductTable() { + System.out.println("初始化产品的数据=====》"+productData); + if (productData.size() > 0) { + for (int i = 0; i < productData.size(); i++) { + for (int j = 0; j < productData.get(i).size(); j++) { + productTable.setValueAt(productData.get(i).get(j), i, j); + } + } + } else { + productTable.setValueAt(UUID.randomUUID().toString().replace("-", ""), 0, 0); + } + } + + private void setProcessTable() { + if (processData.size() > 0) { + for (int i = 0; i < processData.size(); i++) { + for (int j = 0; j < processData.get(i).size(); j++) { + processTable.setValueAt(processData.get(i).get(j), i, j); + } + } + } else { + processTable.setValueAt(UUID.randomUUID().toString().replace("-", ""), 0, 0); + } + } + + + // 添加监听 + public void createActionEvent() { + this.ImportGYK.addActionListener(this); + this.okButton.addActionListener(this); + this.celButton.addActionListener(this); + this.reImportButton.addActionListener(this); + this.addRowItem.addActionListener(this); + this.addRowsItem.addActionListener(this); + this.remItem.addActionListener(this); + } + + public CTable getjTable(CTable partsTable, DefaultTableModel dtm, Object[] titleNames, int rows) { + int simpleLen = 100; + int totleLen = 1000; + if (partsTable == null) { + CTMap map = new CTMap(rows, titleNames.length); + map.setColumnIdentifiers(titleNames); + + + partsTable = new CTable(map); + Adapter adapter = new Adapter(partsTable); + // partsTable.setRowHeight(1, 50); + // partsTable.setRowHeight(2, 100); + partsTable.setRowHeight(40); + // 隐藏列 + partsTable.HiddenCell(0); +// partsTable.HiddenCell(titleNames.length - 1); +// partsTable.HiddenCell(titleNames.length - 2); + + // //设置显示器渲染 + TableCellTextAreaRenderer renderer = new TableCellTextAreaRenderer(); + for(int i=0;i= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + + + //发布了不让编辑 + try { + if(comp.getProperty("release_status_list")!="") { + partsTable.setEnabled(false); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return partsTable; + } + + + + + //设置控件权限 + public void setPanelEnabled(JPanel panel, boolean enabled) { + for (int i = 0; i < panel.getComponentCount(); i++) { + if (panel.getComponent(i) instanceof JPanel) { + JPanel chidPanel = (JPanel) panel.getComponent(i); + for (int j = 0; j < chidPanel.getComponentCount(); j++) { + + chidPanel.getComponent(j).setEnabled(enabled);//一行 + if (chidPanel.getComponent(j) instanceof MultiComboBox) { + MultiComboBox multiComboBox = (MultiComboBox) chidPanel.getComponent(j); + multiComboBox.editor.enable(enabled); + if(enabled) {multiComboBox.popup.show();}else {multiComboBox.popup.hide();} + } + if (chidPanel.getComponent(j) instanceof JScrollPane) { + JScrollPane scrollPane = (JScrollPane) chidPanel.getComponent(j); + JViewport jViewport = scrollPane.getViewport(); + jViewport.getView().setEnabled(enabled); + } + } + } + panel.getComponent(i).setEnabled(enabled); + if (panel.getComponent(i) instanceof MultiComboBox) { + MultiComboBox multiComboBox = (MultiComboBox) panel.getComponent(i); + + multiComboBox.editor.enable(enabled); + if(enabled) {multiComboBox.popup.show();}else {multiComboBox.popup.hide();} + } + if (panel.getComponent(i) instanceof JScrollPane) { + JScrollPane scrollPane = (JScrollPane) panel.getComponent(i); + JViewport jViewport = scrollPane.getViewport(); + jViewport.getView().setEnabled(enabled); + } + } + } + + + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + + if (source.equals(this.okButton)) { + + //发布对象无法编辑保存所有监听器 + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post("对象已发布,无法编辑保存!","失败",MessageBox.ERROR); + return; + } + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + if (productTable.getSelectedRow() >= 0 && productTable.getSelectedColumn() >= 0) { + (productTable.getCellEditor(productTable.getSelectedRow(), productTable.getSelectedColumn())).stopCellEditing(); + } + if (processTable.getSelectedRow() >= 0 && processTable.getSelectedColumn() >= 0) { + (processTable.getCellEditor(processTable.getSelectedRow(), processTable.getSelectedColumn())).stopCellEditing(); + } + saveEvent(true); + + }else if (source.equals(this.reImportButton)) { + System.out.println("重新导入"); + //发布对象无法编辑保存所有监听器 + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post("对象已发布,无法重新导入!","失败",MessageBox.ERROR); + return; + } + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + int i = JOptionPane.showConfirmDialog(null, "重新导入会删除现有数据,重新加载控制计划数据,请确定是否重新导入。", "重新导入", JOptionPane.YES_NO_OPTION); + if (i == JOptionPane.YES_OPTION) { + remAllRow(this.productTable,"产品特性"); + remAllRow(this.processTable,"过程特性"); + dispose(); + ZYGYKCommand command = new ZYGYKCommand(app, + session,comp,true); + try { + command.executeModal(); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } else if (i == JOptionPane.NO_OPTION) { + return; + } + } + else if (source.equals(this.ImportGYK)) { + System.out.println("导出工艺卡"); + saveEvent(false); +// //发布对象无法编辑保存所有监听器 +// try { +// if(comp.getProperty("release_status_list")!="") { +// MessageBox.post("对象已发布,请选择路径导出!","失败",MessageBox.ERROR); +// return; +// } +// } catch (Exception e2) { +// // TODO Auto-generated catch block +// e2.printStackTrace(); +// } +// try { +// ImportCard(false); +// } catch (TCException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } +// } +// else if (source.equals(this.selectPicture)) { +// //发布对象无法编辑保存所有监听器 +// try { +// if(comp.getProperty("release_status_list")!="") { +// MessageBox.post("对象已发布,无法选择","失败",MessageBox.ERROR); +// return; +// } +// } catch (Exception e2) { +// // TODO Auto-generated catch block +// e2.printStackTrace(); +// } +// if(isExsist()==0) { +// selectpictureButtonEvent(); +// }else {//当附加关系下存在有图片时,会先清空图片再添加 +// int isReplace= JOptionPane.showConfirmDialog(null, "已存在导出图,是否重新选择?", "提示", JOptionPane.YES_NO_OPTION); +// if(isReplace == JOptionPane.YES_OPTION){ +// try { +// itemRevision.remove("IMAN_specification",itemRevision.getReferenceListProperty("IMAN_specification")); +// } catch (TCException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } +// selectpictureButtonEvent(); +// }else { +// return; +// } +// } + + } + else if (source.equals(this.celButton)) { + dispose(); + } + else if (source.equals(this.addRowItem)) { + //发布对象无法编辑保存所有监听器 + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post("对象已发布,无法添加行!","失败",MessageBox.ERROR); + return; + } + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + addRow(1); + } else if (source.equals(this.addRowsItem)) { + //发布对象无法编辑保存所有监听器 + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post("对象已发布,无法添加多行!","失败",MessageBox.ERROR); + return; + } + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + new AddRowsDialog(); + + } else if (source.equals(this.remItem)) { + //发布对象无法编辑保存所有监听器 + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post("对象已发布,无法移除行!","失败",MessageBox.ERROR); + return; + } + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + remRow(); + } else { + dispose(); + } + } + + private boolean checkMust() { + // TODO Auto-generated method stub + boolean flag=false; + GYKLXField.setEditable(true); + System.out.println("checkMust===>"+GYKLXField.getText()); + if(GYKLXField.getText()==null||GYKLXField.getText().equals("")) { + flag=true; + } + return flag; + + } + + + + + private void saveEvent(boolean flag) { + if(checkMust()) { + GYKLXField.setEditable(false); + MessageBox.post("工艺卡类型未填写!","失败",MessageBox.ERROR); + return; + } + System.out.println("保存时类型:"+this.GYKLXField.getText()); + this.productData = getTableValue(this.productTable); + this.processData = getTableValue(this.processTable); + getText(); + GYKLXField.setEditable(false); + ZYGYKOperation operation = new ZYGYKOperation(app, session, comp, + productData,processData, productPlmeidList, processPlmeidList, + productDeleteList, processDeleteList, headList); + + try { + operation.executeOperation(); + setPlmeidList(productPlmeidList, productTable); + setPlmeidList(processPlmeidList, processTable); + + if(flag) { + this.rootPanel.setBackground(Color.GREEN); + new Thread() { + @Override + public void run() { + try { + this.sleep(1000); + rootPanel.setBackground(Color.WHITE); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + }.start(); + }else { + ImportCard(); + this.dispose(); + } + + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + + //导出工艺卡 + private void ImportCard() throws TCException, IOException{ + System.out.println("GYKLXField.getText()===>"+GYKLXField.getText()); + File file = TMomMethodUtil.getFile(session, GYKLXField.getText(), "MSExcelX","ZF6_GYK_Template"); + String outFileName=((TCComponentItemRevision) comp).getStringProperty("item_id") + +((TCComponentItemRevision) comp).getStringProperty("object_name"); + //System.out.println(this.tMomControlPlanBean.toString()); + String outFilePath = System.getenv("TEMP") + "\\" + outFileName + ".xlsx"; + + if(GYKLXField.getText().indexOf("装配")>=0) { + outPutExcel.writeZPGYKToExcel(session,productData,processData,headList,file,outFilePath, + ((TCComponentItemRevision) comp).getStringProperty("item_id"),((TCComponentItemRevision) comp).getStringProperty("current_revision_id")); + }else { + outPutExcel.writeGYKToExcel(session,productData,processData,headList,file,outFilePath, + ((TCComponentItemRevision) comp).getStringProperty("item_id"),((TCComponentItemRevision) comp).getStringProperty("current_revision_id"),GYKLXField.getText()); + } + + + if (outPutExcel.getExcelToItem(session, (TCComponentItemRevision) comp, + "IMAN_specification", "MSExcelX") != null) { + outPutExcel.changeDataSet( + outPutExcel.getExcelToDataset(session, itemRevision, "IMAN_specification", "MSExcelX"), + "excel", "MSExcelX", outFilePath); + new File(outFilePath).delete(); + } else { + outPutExcel.setExcelToItem(session, itemRevision, outFilePath, outFileName, "IMAN_specification", + "MSExcelX", true); + } +// if(new File(outFilePath).exists()) { +// new File(outFilePath).delete(); +// } + MessageBox.post("导出Excel成功!", "成功", MessageBox.INFORMATION); + + } + + +// //保存数据 +// private void saveData(){ +// if (toolingDetailTable.getSelectedRow() >= 0 && toolingDetailTable.getSelectedColumn() >= 0) { +// (toolingDetailTable.getCellEditor(toolingDetailTable.getSelectedRow(), toolingDetailTable.getSelectedColumn())).stopCellEditing(); +// } +// if (machiningParameterTable.getSelectedRow() >= 0 && machiningParameterTable.getSelectedColumn() >= 0) { +// (machiningParameterTable.getCellEditor(machiningParameterTable.getSelectedRow(), machiningParameterTable.getSelectedColumn())).stopCellEditing(); +// } +// if (controlRequirementTable.getSelectedRow() >= 0 && controlRequirementTable.getSelectedColumn() >= 0) { +// (controlRequirementTable.getCellEditor(controlRequirementTable.getSelectedRow(), controlRequirementTable.getSelectedColumn())).stopCellEditing(); +// } +// this.toolingDetailData = getTableValue(this.toolingDetailTable); +// this.machiningParameterData = getTableValue(this.machiningParameterTable); +// this.controlRequirementData = getTableValue(this.controlRequirementTable); +// +// List valueList = getText(); +// +// ZYGYKOperation operation = new ZYGYKOperation(app, session, comp, +// toolingDetailData, machiningParameterData, controlRequirementData, toolingDetailPlmeidList, +// machiningParameterPlmeidList, controlRequirementPlmeidList, toolingDetailDeleteList, +// machiningParameterDeleteList, controlRequirementDeleteList, form, properties, valueList); +// try { +// operation.executeOperation(); +// // 获取版本表单的属性 +// form = itemRevision.getRelatedComponent("IMAN_master_form_rev"); +// if (form != null) { +// properties = form.getTCProperties(properName); +// } +// +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// +// } +// +// private JobProcessFormBean getData() +// { +// JobProcessFormBean bean = new JobProcessFormBean(); +// bean.setGsmc(this.properties[0].getStringValue()); +// bean.setLjdh(this.properties[1].getStringValue()); +// bean.setSbxh(this.properties[2].getStringValue()); +// bean.setBgx(this.properties[3].getStringValue()); +// bean.setSbmc(this.properties[4].getStringValue()); +// bean.setToolingDetailData(toolingDetailData); +// bean.setMachiningParameterData(machiningParameterData); +// bean.setControlRequirementData(controlRequirementData); +// return bean; +// } +// + + //修改描述信息,关闭权限 + private void closePermission() { + //关闭权限修改 + if(((TCComponent) comp).isCheckedOut()) { + ReservationService service=ReservationService.getService((TCSession)app.getSession()); + service.checkin(new TCComponent[] {(TCComponent) this.comp});//签入 + } + } + + private void setPlmeidList(List plmeidList, CTable table) { + // TODO Auto-generated method stub + List> dataValeList = new ArrayList>(); + + for (int j = 0; j < table.getRowCount(); j++) { + if (!plmeidList.contains(table.getValueAt(j, 0))) { + plmeidList.add(table.getValueAt(j, 0).toString()); + } + } + } + + private List> getTableValue(CTable table) { + // TODO Auto-generated method stub + List> dataValeList = new ArrayList>(); + + CTMap map = ((CTMap) table.getModel()); + for (int j = 0; j < table.getRowCount(); j++) { + List rowValue = new ArrayList(); + for (int j2 = 0; j2 < map.getColumnCount(); j2++) { + rowValue.add((String) table.getValueAt(j, j2)); + } + dataValeList.add(rowValue); + } + return dataValeList; + } + + + @Override + public void dispose() { + // TODO Auto-generated method stub + super.dispose(); + //关闭权限修改 + closePermission(); + } + + /** + * 添加行 + */ + private void addRow(int index) { + // TODO Auto-generated method stub + CTable table = productTable; + switch (this.tabbedPane.getSelectedIndex()) { + case 1: + table = processTable; + break; + default: + break; + } + CTMap map = ((CTMap) table.getModel()); + map.insertRow(table.getSelectedRow() + index); + table.setValueAt(UUID.randomUUID().toString().replace("-", ""), table.getSelectedRow() + index, 0); + table.revalidate();//重载 + table.repaint();//重绘 + } + + + + /** + * 移除行 + */ + private void remRow() { + // TODO Auto-generated method stub + CTable table = productTable; + switch (this.tabbedPane.getSelectedIndex()) { + case 1: + table = processTable; + break; + + default: + break; + } + CTMap map = ((CTMap) table.getModel()); + + switch (this.tabbedPane.getSelectedIndex()) { + case 0: + if (map.getValueAt(table.getSelectedRow(), 0) != null + && this.productPlmeidList.contains(map.getValueAt(table.getSelectedRow(), 0))) { + this.productDeleteList.add(map.getValueAt(table.getSelectedRow(), 0).toString()); + } + + break; + case 1: + if (map.getValueAt(table.getSelectedRow(), 0) != null + && this.processPlmeidList.contains(map.getValueAt(table.getSelectedRow(), 0))) { + this.processDeleteList.add(map.getValueAt(table.getSelectedRow(), 0).toString()); + } + break; + + default: + break; + } + + map.removeRow(table.getSelectedRow()); + table.revalidate();//重载 + table.repaint();//重绘 + } + + /** + * 重新导入时移除所有行信息 + */ + private void remAllRow(CTable table,String tableName) { + List deleteAllList=new ArrayList(); + for (int j = 0; j < table.getRowCount(); j++) { + deleteAllList.add(table.getValueAt(j, 0).toString()); + } + switch (tableName) { + case "产品特性": + for(int i=0;i-1) + { + puid = modelFiles[i].split("-")[1]; + return puid; + } + } + return null; + } + public class PicDialog extends JFrame { + private CTMap pmap; + private CTable pmainTable; + private int tag; + private String pathname; + private String LibraryName; + boolean select=true; + private String[] header = new String[] { "图片列表"}; + private TCComponent[] comps; + public PicDialog(TCComponent[] comps,String pathname,String LibraryName) { + // TODO Auto-generated constructor stub + super(); + this.comps=comps; + this.pathname=pathname; + this.LibraryName=LibraryName; + pinit(); + } + private void pinit() { + this.setTitle(this.LibraryName); + this.setPreferredSize(new Dimension(500, 600)); + // TODO Auto-generated method stub + pmainTable = getNewjTable(null, null,header, 1); + pmainTable.setRowHeight(40); + pmainTable.getColumnModel().getColumn(0).setPreferredWidth(20); + JScrollPane jslp1 = new JScrollPane(); // 给jta加滚动条 + jslp1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + jslp1.setViewportView(pmainTable); + for(int i=0;i= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + + } +} + diff --git a/src/com/connor/zf/zygyk/ZYGYKHandler.java b/src/com/connor/zf/zygyk/ZYGYKHandler.java new file mode 100644 index 0000000..48d735a --- /dev/null +++ b/src/com/connor/zf/zygyk/ZYGYKHandler.java @@ -0,0 +1,58 @@ +package com.connor.zf.zygyk; + +import java.awt.Color; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import static java.awt.image.BufferedImage.TYPE_INT_ARGB; +public class ZYGYKHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + if(app.getTargetComponent()==null) { + MessageBox.post("未选中作业工艺卡版本对象,请重新选择!", "错误", MessageBox.ERROR); + return null; + } + //获取选中对象 + InterfaceAIFComponent comp = app.getTargetComponent(); + //判断选中对象是否是作业工艺卡的版本 + if(comp.getType().indexOf("ZF6_ZYGYKRevision") >=0) + { + + ZYGYKCommand command = new ZYGYKCommand(app, + session,comp,false); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("填写作业工艺卡失败!", "错误", MessageBox.ERROR); + } + } + else + { + MessageBox.post("请选中作业工艺卡版本!", "错误", MessageBox.ERROR); + } + return null; + } + +} + + diff --git a/src/com/connor/zf/zygyk/ZYGYKOperation.java b/src/com/connor/zf/zygyk/ZYGYKOperation.java new file mode 100644 index 0000000..c43ea1f --- /dev/null +++ b/src/com/connor/zf/zygyk/ZYGYKOperation.java @@ -0,0 +1,179 @@ +package com.connor.zf.zygyk; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; +import java.util.Properties; + +import com.connor.zf.controlplan.SqlUtilT; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class ZYGYKOperation extends AbstractAIFOperation { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCComponent form; + private TCProperty[] properties; + private List valueList; + + private List> productData; + private List> processData; + + private List productPlmeidList; + private List processPlmeidList; + + private List productDeleteList; + private List processDeleteList; + + public ZYGYKOperation(AbstractAIFApplication app, TCSession session, + InterfaceAIFComponent comp, List> productData, List> processData, + List productPlmeidList,List processPlmeidList, + List productDeleteList, List processDeleteList, + List valueList) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.comp = comp; + this.productData = productData; + this.processData = processData; + this.productPlmeidList = productPlmeidList; + this.processPlmeidList = processPlmeidList; + this.productDeleteList = productDeleteList; + this.processDeleteList = processDeleteList; + this.valueList = valueList; + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + // 保存数据 + InputStream input = null; + try { +// // 更新属性 +// // 判断是否是版本对象的所有者 +// String userName = ((TCComponentItemRevision) this.comp).getReferenceProperty("owning_user") +// .getStringProperty("user_id"); +// TCComponentUser user = session.getUser(); +// if (user.getUserId().equals(userName)) { +// // TMomMethodUtil.setByPass(session, true); +// this.form.lock(); +// this.properties[0].setStringValue(this.valueList.get(0)); +// this.properties[1].setStringValue(this.valueList.get(1)); +// this.properties[2].setStringValue(this.valueList.get(2)); +// this.properties[3].setStringValue(this.valueList.get(3)); +// this.properties[4].setStringValue(this.valueList.get(4)); +// this.form.save(); +// this.form.unlock(); +// this.form.refresh(); +// } + + // 获取SQL语句 + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + + //更新表头数据 + String headupdateSQL = String.format(pro.getProperty("RB3_ZYGYKHEADUPDATE"), valueList.get(0),comp.getUid()); + System.out.println("headupdateSQL===>"+headupdateSQL); + System.out.println("valueList+++++>"+valueList); + SqlUtilT.getTCConnection(); + SqlUtilT.update(new String[] { valueList.get(2), valueList.get(3), valueList.get(4),valueList.get(5), + valueList.get(6), valueList.get(7), valueList.get(8), valueList.get(9),valueList.get(10),valueList.get(11)}, + headupdateSQL); + + // 删除行 + for (int i = 0; i < this.productDeleteList.size(); i++) { + // 获取数据库连接 + String deleteSQL = String.format(pro.getProperty("RB3_PRODUCTDELETE"), + productDeleteList.get(i),comp.getUid()); + SqlUtilT.getTCConnection(); + SqlUtilT.delete(deleteSQL); + SqlUtilT.freeAll(); + } + for (int i = 0; i < this.processDeleteList.size(); i++) { + // 获取数据库连接 + String deleteSQL = String.format(pro.getProperty("RB3_PROCESSDELETE"), + processDeleteList.get(i),comp.getUid()); + SqlUtilT.getTCConnection(); + SqlUtilT.delete(deleteSQL); + SqlUtilT.freeAll(); + } + + // 获取数据库连接 + SqlUtilT.getTCConnection(); + + for (int i = 0; i < productData.size(); i++) { + List rowList = productData.get(i); + + if (rowList.get(0) != null && !rowList.get(0).equals("") + && productPlmeidList.contains(rowList.get(0))) { + // 获取数据库连接 + String updateSQL = String.format(pro.getProperty("RB3_PRODUCTUPDATE"), rowList.get(0),comp.getUid()); + SqlUtilT.getTCConnection(); + SqlUtilT.update(new String[] { rowList.get(1), rowList.get(2), rowList.get(3), rowList.get(4),rowList.get(5), + rowList.get(6), rowList.get(7), rowList.get(8), rowList.get(9),rowList.get(10)}, + updateSQL); + } else { + String insertSQL = pro.getProperty("RB3_PRODUCTINSERT"); + SqlUtilT.getTCConnection(); + SqlUtilT.write2(new String[] { rowList.get(0), comp.getUid(), rowList.get(1), rowList.get(2), + rowList.get(3), rowList.get(4),rowList.get(5), + rowList.get(6), rowList.get(7), rowList.get(8), rowList.get(9),rowList.get(10) }, insertSQL); + } + + } + + for (int i = 0; i < processData.size(); i++) { + List rowList = processData.get(i); + + if (rowList.get(0) != null && !rowList.get(0).equals("") + &&processPlmeidList.contains(rowList.get(0))) { + // 获取数据库连接 + String updateSQL = String.format(pro.getProperty("RB3_PROCESSUPDATE"), rowList.get(0),comp.getUid()); + SqlUtilT.getTCConnection(); + SqlUtilT.update(new String[] { rowList.get(1), rowList.get(2), rowList.get(3), rowList.get(4), + rowList.get(5), rowList.get(6), rowList.get(7), rowList.get(8) }, + updateSQL); + } else { + String insertSQL = pro.getProperty("RB3_PROCESSINSERT"); + SqlUtilT.getTCConnection(); + SqlUtilT.write2(new String[] { rowList.get(0), comp.getUid(), rowList.get(1), rowList.get(2), + rowList.get(3), rowList.get(4),rowList.get(5), rowList.get(6), + rowList.get(7), rowList.get(8) }, insertSQL); + } + + } + + + SqlUtilT.connection.commit(); + input.close(); + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.toString(), "错误", MessageBox.ERROR); + e.printStackTrace(); + throw e; + } finally { + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + + } + +} diff --git a/src/sql.properties b/src/sql.properties new file mode 100644 index 0000000..fc02e06 --- /dev/null +++ b/src/sql.properties @@ -0,0 +1,61 @@ +SETPFMEASELECT=SELECT * FROM AHMC_PFMEA WHERE PROCESSPUID = \'%s\' AND REVISIONID=\'%s\' ORDER BY P5,HH +PFMEALIBRARYSELECT2=SELECT * FROM AHMC_PFMEALIBRARY WHERE PUID = \'%s\' ORDER BY HHC + +BOMCHECKSAVESELECTPFMEA=SELECT MEOPID,STATION,GYBH,GCMC FROM AHMC_PFMEA WHERE PROCESSPUID = \'%s\' AND REVISIONID=\'%s\' + +BOMCHECKSAVESELECTPFMEA2=SELECT * FROM AHMC_PFMEA WHERE PROCESSPUID = \'%s\' AND MEOPID NOT IN %s + +DELETEPFMEA=DELETE FROM AHMC_PFMEA WHERE MEOPID = \'%s\' AND PROCESSPUID = \'%s\' + +INSERTPFMEA=INSERT INTO AHMC_PFMEA VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) +# ORDER BY ID +PFMEALIBRARYSELECT=SELECT * FROM AHMC_PFMEA_NODE WHERE PARENT_ID = \'%s\' ORDER BY ROWNUMD ASC +SETPFMEASELECT2=SELECT MEOPID,REQUIREMENT FROM AHMC_PFMEA WHERE PROCESSPUID = \'%s\' GROUP BY MEOPID,REQUIREMENT +SETPFMEADELETE=DELETE FROM AHMC_PFMEA WHERE PLMEID = \'%s\' + +SETPFMEAUPDATE=UPDATE AHMC_PFMEA SET GYBH = ?,GCMC = ?,STATION = ?,REQUIREMENT = ?,QZSXMS = ?,QZSXHG = ?,YZD = ?,JB = ?,QZSXQY = ?,XXGCKZYF = ?,PDS = ?,XXGCKZTC = ?,TCD = ?,RPN = ?,JYCS = ?,ZZR = ?,JHWCRQ = ?,CQDCS = ?,NEW_SEV = ?,NEW_OCC = ?,NEW_DET = ?,NEW_RPN = ?,IDEAL_STATE = ?,SPECIAL = ?,HH = ?,HBDYG = ? ,OCCURRRENCE = ?,DETECTION = ?,PRIORITY = ?,P1 = ?,P2 = ?,P3 = ?,P4 = ?,P5 = ? WHERE PLMEID = \'%s\' AND REVISIONID=\'%s\' +TM2PFMEATREESELECT=SELECT * FROM AHMC_PFMEA_TREE ORDER BY PARENT_ID,ID + +CONTROLPLANLIBRARYSELECT=SELECT * FROM AHMC_CONTROLPLAN_NODE WHERE PARENT_ID = \'%s\' ORDER BY ID + +TM2CONTROLPLANTREESELECT=SELECT * FROM AHMC_CONTROLPLAN_TREE ORDER BY PARENT_ID + +TM2THESAURUSTREESELECT=SELECT * FROM AHMC_THESAURUS_TREE ORDER BY PARENT_ID + +TM2THESAURUSNODESELECT=SELECT * FROM AHMC_THESAURUS_NODE WHERE PARENT_ID = \'%s\' ORDER BY ID + +PFMEALIBRARYUPDATE=UPDATE AHMC_PFMEA_NODE SET ID = ?,LSBG =?, STATION = ?,REQUIREMENT = ?,QZSXMS = ?,QZSXHG = ?,YZD = ?,JB = ?,QZSXQY = ?,XXGCKZYF = ?,PDS = ?,XXGCKZTC = ?,TCD = ?,RPN = ?,JYCS = ?,ZZR = ?,JHWCRQ = ?,CQDCS = ?,NEW_SEV = ?,NEW_OCC = ?,NEW_DET = ?,NEW_RPN = ?,IDEAL_STATE = ?,SPECIAL = ?,P1 = ?,P2 = ?,P3 = ?,P4 = ?,P5 = ?,P6 = ?,P7 = ?,P8 = ? , HBDYG=?, ROWNUMD=? WHERE PLMEID = \'%s\' + +PFMEALIBRARYDELETE=DELETE FROM AHMC_PFMEA_NODE WHERE PLMEID = \'%s\' +PFMENODEDELETE=DELETE FROM AHMC_PFMEA_TREE WHERE PARENT_ID = \'%s\' +PFMEALIBRARYINSERT=INSERT INTO AHMC_PFMEA_NODE VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) + +#zw +CONTROLPLANSELECT=select * from ZF6_CONTROLPLAN where PROCESSPUID = \'%s\' and PUID = \'%s\' order by CAST(NO AS INT),CAST(ZF6_HH AS INT) +CONTROLPLANUPDATE=update ZF6_CONTROLPLAN set LJGCBH = ?,GCMC = ?,JQZHJJGZ = ?,BH = ?,CP = ?,GC = ?,TSTXFL = ?,CPGC = ?,JSCLJS = ?,XM = ?,RL = ?,PL = ?,ZRR = ?,KZFF = ?,FYJH = ?,NO = ?,ZF6_HH = ?,ZF6_HBDYG = ?,ZF6_HHC = ? where PLMEID = \'%s\' and PUID=\'%s\' +CONTROLPLANOPERATIONSELECT=select ZF6_MEOPID,zf6_gybh from ZF6_CONTROLPLAN where PROCESSPUID = \'%s\' and ZF6_MEOPID is not null group by ZF6_MEOPID,zf6_gybh +CONTROLPLANOPERATIONSELECT2=select ZF6_MEOPID,NO from ZF6_CONTROLPLAN where PROCESSPUID = \'%s\' and ZF6_MEOPID is not null group by ZF6_MEOPID,NO +CONTROLPLANDELETE=delete from ZF6_CONTROLPLAN where PLMEID = \'%s\' +RB3_meopNameToID=select GCMC,PROCESSID from ZF6_CONTROLPLAN where PUID = \'%s\' GROUP BY GCMC ,PROCESSID +CONTROLPLAN_IDTONO=select PROCESSID,NO from ZF6_CONTROLPLAN where PUID = \'%s\' GROUP BY PROCESSID,NO +CONTROLPLANHEADSELECT=select * from ZF6_CONTROLPLANHEAD where PUID = \'%s\' +CONTROLPLANHEADUPDATE=update ZF6_CONTROLPLANHEAD set TYPE = ?,KZJHBH = ?,ZYLXR = ?,BZRIQ = ?,XDRQ = ?,LJBH = ?,HXXZ = ?,GKGCPZ = ?,LJMC = ?,GFPZRQ = ?,GKZLPZ = ?,ZZDM = ?,QTPZ = ?,QTPZRQ = ? where PLMEID = \'%s\' and PUID=\'%s\' +INSERTSQL=insert into ZF6_CONTROLPLAN values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) +RB3_PRODUCTSELECT=select * from ZF6_PRODUCTCHARACTER where PUID = \'%s\' order by CAST(NO AS INT) +RB3_PROCESSSELECT=select * from ZF6_PROCESSCHARACTER where PUID = \'%s\' order by CAST(NO AS INT) +RB3_CONTROLPLANTOGYK=select * from ZF6_CONTROLPLAN where PUID = \'%s\' AND PROCESSID = \'%s\' order by CAST(ZF6_HH AS INT) +RB3_ZYGYKHEADSELECT=select * from ZF6_ZYGYKHEAD where PUID = \'%s\' +RB3_PRODUCTDELETE=delete from ZF6_PRODUCTCHARACTER where PLMEID = \'%s\' AND PUID = \'%s\' +RB3_PROCESSDELETE=delete from ZF6_PROCESSCHARACTER where PLMEID = \'%s\' AND PUID = \'%s\' +RB3_PRODUCTUPDATE=update ZF6_PRODUCTCHARACTER set NO = ?,JCXM = ?,ZYD = ?,YQ = ?,JCFF = ?,SJ1 = ?,ZJPC = ?,SJ2 = ?,JYPC = ?,FYJH = ? where PLMEID = \'%s\' and PUID = \'%s\' +RB3_PROCESSUPDATE=update ZF6_PROCESSCHARACTER set NO = ?,JCXM = ?,ZYD = ?,YQ = ?,JCFF = ?,RL = ?,PL = ?,FYJH = ? where PLMEID = \'%s\' and PUID = \'%s\' +RB3_PRODUCTINSERT=insert into ZF6_PRODUCTCHARACTER values(?,?,?,?,?,?,?,?,?,?,?,?) +RB3_PROCESSINSERT=insert into ZF6_PROCESSCHARACTER values(?,?,?,?,?,?,?,?,?,?) +RB3_ZYGYKHEADUPDATE=update ZF6_ZYGYKHEAD set GYKLX = ?,CPXH = ?,GXMC = ?,SLYSGG = ?,SLYSCZ = ?,SBXH = ?,CHSBXH = ?,YHSBXH = ?,DJDPXH = ?,LJMC = ? where PLMEID = \'%s\' and PUID = \'%s\' + + + +SELECTFRAMESIZE=SELECT * FROM AHMC_PFMEAFRAME_SIZE WHERE USERNAME = \'%s\' AND TYPE = \'%s\' +FRAMESIZEINSERT=INSERT INTO AHMC_PFMEAFRAME_SIZE VALUES(?,?,?,?,?,?) +FRAMESIZEDELETE=DELETE FROM AHMC_PFMEAFRAME_SIZE WHERE USERNAME = \'%s\' AND TYPE = \'%s\' +FRAMESIZEUPDATE=UPDATE AHMC_PFMEAFRAME_SIZE SET FRAMESIZE = ?, TABLE1SIZE = ?, TABLE2SIZE = ? WHERE USERNAME = \'%s\' AND TYPE = \'%s\' \ No newline at end of file