commit bbea9de373ec07812d9a74c870ad9ad0180a6290 Author: xiongcz Date: Thu May 8 16:03:33 2025 +0800 备份 diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..a412ee6 --- /dev/null +++ b/.classpath @@ -0,0 +1,394 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.git1/.probe-3459c21c-1de9-458b-8bc7-6b979669c9f3 b/.git1/.probe-3459c21c-1de9-458b-8bc7-6b979669c9f3 new file mode 100644 index 0000000..e69de29 diff --git a/.git1/COMMIT_EDITMSG b/.git1/COMMIT_EDITMSG new file mode 100644 index 0000000..39d803e --- /dev/null +++ b/.git1/COMMIT_EDITMSG @@ -0,0 +1 @@ +20250115 \ No newline at end of file diff --git a/.git1/FETCH_HEAD b/.git1/FETCH_HEAD new file mode 100644 index 0000000..22c247b --- /dev/null +++ b/.git1/FETCH_HEAD @@ -0,0 +1 @@ +317c9cc1b5ecc3b11d832170ae5f10176fb393da not-for-merge branch 'main' of http://yunpi.tpddns.cn:3000/lijh/com.connor.ly.plm.git diff --git a/.git1/HEAD b/.git1/HEAD new file mode 100644 index 0000000..b870d82 --- /dev/null +++ b/.git1/HEAD @@ -0,0 +1 @@ +ref: refs/heads/main diff --git a/.git1/config b/.git1/config new file mode 100644 index 0000000..d21b2ec --- /dev/null +++ b/.git1/config @@ -0,0 +1,17 @@ +[core] + symlinks = false + repositoryformatversion = 0 + filemode = false + logallrefupdates = true +[remote "origin"] + url = http://yunpi.tpddns.cn:3000/lijh/com.connor.ly.plm.git + fetch = +refs/heads/ljh:refs/remotes/origin/ljh + fetch = +refs/heads/main:refs/remotes/origin/main +[branch "main"] + remote = origin + merge = refs/heads/main + rebase = false +[branch "ljh"] + remote = origin + merge = refs/heads/ljh + rebase = false diff --git a/.git1/index b/.git1/index new file mode 100644 index 0000000..2c1de30 Binary files /dev/null and b/.git1/index differ diff --git a/.git1/logs/HEAD b/.git1/logs/HEAD new file mode 100644 index 0000000..92d07c7 --- /dev/null +++ b/.git1/logs/HEAD @@ -0,0 +1,28 @@ +0000000000000000000000000000000000000000 2b243c95aa2827e1a76ef1a56b1f202e032878bb lijh 1731483843 +0800 +2b243c95aa2827e1a76ef1a56b1f202e032878bb 7d0d51792b97bed663b400172ed408b14ad20b3b lijh 1731483880 +0800 checkout: moving from main to ljh +7d0d51792b97bed663b400172ed408b14ad20b3b 2b243c95aa2827e1a76ef1a56b1f202e032878bb lijh 1731484024 +0800 merge refs/remotes/origin/main: Fast-forward +2b243c95aa2827e1a76ef1a56b1f202e032878bb 2b243c95aa2827e1a76ef1a56b1f202e032878bb lijh 1731484035 +0800 checkout: moving from ljh to main +2b243c95aa2827e1a76ef1a56b1f202e032878bb 2b243c95aa2827e1a76ef1a56b1f202e032878bb lijh 1731663736 +0800 checkout: moving from main to ljh +2b243c95aa2827e1a76ef1a56b1f202e032878bb 4fb130a2eb11993c23806615662692d18af4ec88 lijh 1731663777 +0800 commit: mpart修改 +4fb130a2eb11993c23806615662692d18af4ec88 2b243c95aa2827e1a76ef1a56b1f202e032878bb lijh 1731663792 +0800 checkout: moving from ljh to main +2b243c95aa2827e1a76ef1a56b1f202e032878bb 9845db1b4a1245e97c5be03bebb9bab715a218e7 lijh 1731663806 +0800 merge branch 'main' of http://yunpi.tpddns.cn:3000/lijh/com.connor.ly.plm.git: Fast-forward +9845db1b4a1245e97c5be03bebb9bab715a218e7 47864d8febbfacaf6524570385f919a5c6c60716 lijh 1731663847 +0800 merge refs/remotes/origin/ljh: Merge made by recursive. +47864d8febbfacaf6524570385f919a5c6c60716 4fb130a2eb11993c23806615662692d18af4ec88 lijh 1731664435 +0800 checkout: moving from main to ljh +4fb130a2eb11993c23806615662692d18af4ec88 47864d8febbfacaf6524570385f919a5c6c60716 lijh 1731664457 +0800 checkout: moving from ljh to main +47864d8febbfacaf6524570385f919a5c6c60716 47864d8febbfacaf6524570385f919a5c6c60716 lijh 1731664709 +0800 checkout: moving from main to 47864d8febbfacaf6524570385f919a5c6c60716 +47864d8febbfacaf6524570385f919a5c6c60716 47864d8febbfacaf6524570385f919a5c6c60716 lijh 1731664798 +0800 checkout: moving from 47864d8febbfacaf6524570385f919a5c6c60716 to main +47864d8febbfacaf6524570385f919a5c6c60716 53a9af372c9468bf7c16d913471ff58c7ef61704 lijh 1731665099 +0800 commit: mpart修改 +53a9af372c9468bf7c16d913471ff58c7ef61704 56cde5eaeddf79422103523a579b3892506e369a lijh 1731924184 +0800 commit: 1 +56cde5eaeddf79422103523a579b3892506e369a abc24fee89693e96c2dda6d0da181aa1065b7c1e lijh 1732521923 +0800 commit: mpart commit +abc24fee89693e96c2dda6d0da181aa1065b7c1e c54c85f5eda17551f85fa14d6557ea641647f70a lijh 1732612549 +0800 merge branch 'main' of http://yunpi.tpddns.cn:3000/lijh/com.connor.ly.plm.git: Merge made by recursive. +c54c85f5eda17551f85fa14d6557ea641647f70a abac41c5434c3d8eaaf2d7cdf133844691b41b91 lijh 1734490444 +0800 commit: 20241218 +abac41c5434c3d8eaaf2d7cdf133844691b41b91 670784ab2951fc089f9db563485c9bd66c1c3b0a lijh 1734688689 +0800 commit: 111 +670784ab2951fc089f9db563485c9bd66c1c3b0a 6276640680055868526233c1aa6ef7b9c40af93a lijh 1734688716 +0800 commit: 222 +6276640680055868526233c1aa6ef7b9c40af93a 07dfccd9b618a4fc9939ce1c5905c55c7481ade7 lijh 1734773107 +0800 commit: 20241221 +07dfccd9b618a4fc9939ce1c5905c55c7481ade7 3952e9fd98dc55d9f6e15b371e7708170d09a1a6 lijh 1734947704 +0800 commit: 20241223 +3952e9fd98dc55d9f6e15b371e7708170d09a1a6 fd63bc99fd3083eaa6bf786f64461be82ff3ad7b lijh 1735120863 +0800 commit: 20241225 +fd63bc99fd3083eaa6bf786f64461be82ff3ad7b bf5a9a54f9db73a7b48e9fde22769e76fab1215a lijh 1735810865 +0800 commit: 20250102 +bf5a9a54f9db73a7b48e9fde22769e76fab1215a 01187105a5ef6b1bd8c655a4daa545144ad444c3 lijh 1735897432 +0800 commit: 20250103 +01187105a5ef6b1bd8c655a4daa545144ad444c3 d535b6aa820b9a68864fbe3ec623d88025386477 lijh 1735977605 +0800 commit: 202501041 +d535b6aa820b9a68864fbe3ec623d88025386477 0dfbaeede601eb70c253b024cb3f9caf8e4c7d99 lijh 1736416584 +0800 commit: 20250109commit +0dfbaeede601eb70c253b024cb3f9caf8e4c7d99 04aff3093f6cca41a9be5bbd1a52ee15a88fb318 lijh 1736910841 +0800 commit: 20250115 diff --git a/.git1/logs/refs/heads/ljh b/.git1/logs/refs/heads/ljh new file mode 100644 index 0000000..cef165f --- /dev/null +++ b/.git1/logs/refs/heads/ljh @@ -0,0 +1,3 @@ +0000000000000000000000000000000000000000 7d0d51792b97bed663b400172ed408b14ad20b3b lijh 1731483879 +0800 branch: Created from branch refs/remotes/origin/ljh +7d0d51792b97bed663b400172ed408b14ad20b3b 2b243c95aa2827e1a76ef1a56b1f202e032878bb lijh 1731484024 +0800 merge refs/remotes/origin/main: Fast-forward +2b243c95aa2827e1a76ef1a56b1f202e032878bb 4fb130a2eb11993c23806615662692d18af4ec88 lijh 1731663777 +0800 commit: mpart修改 diff --git a/.git1/logs/refs/heads/main b/.git1/logs/refs/heads/main new file mode 100644 index 0000000..a736868 --- /dev/null +++ b/.git1/logs/refs/heads/main @@ -0,0 +1,18 @@ +0000000000000000000000000000000000000000 2b243c95aa2827e1a76ef1a56b1f202e032878bb lijh 1731483843 +0800 +2b243c95aa2827e1a76ef1a56b1f202e032878bb 9845db1b4a1245e97c5be03bebb9bab715a218e7 lijh 1731663806 +0800 merge branch 'main' of http://yunpi.tpddns.cn:3000/lijh/com.connor.ly.plm.git: Fast-forward +9845db1b4a1245e97c5be03bebb9bab715a218e7 47864d8febbfacaf6524570385f919a5c6c60716 lijh 1731663847 +0800 merge refs/remotes/origin/ljh: Merge made by recursive. +47864d8febbfacaf6524570385f919a5c6c60716 53a9af372c9468bf7c16d913471ff58c7ef61704 lijh 1731665099 +0800 commit: mpart修改 +53a9af372c9468bf7c16d913471ff58c7ef61704 56cde5eaeddf79422103523a579b3892506e369a lijh 1731924184 +0800 commit: 1 +56cde5eaeddf79422103523a579b3892506e369a abc24fee89693e96c2dda6d0da181aa1065b7c1e lijh 1732521923 +0800 commit: mpart commit +abc24fee89693e96c2dda6d0da181aa1065b7c1e c54c85f5eda17551f85fa14d6557ea641647f70a lijh 1732612549 +0800 merge branch 'main' of http://yunpi.tpddns.cn:3000/lijh/com.connor.ly.plm.git: Merge made by recursive. +c54c85f5eda17551f85fa14d6557ea641647f70a abac41c5434c3d8eaaf2d7cdf133844691b41b91 lijh 1734490444 +0800 commit: 20241218 +abac41c5434c3d8eaaf2d7cdf133844691b41b91 670784ab2951fc089f9db563485c9bd66c1c3b0a lijh 1734688689 +0800 commit: 111 +670784ab2951fc089f9db563485c9bd66c1c3b0a 6276640680055868526233c1aa6ef7b9c40af93a lijh 1734688716 +0800 commit: 222 +6276640680055868526233c1aa6ef7b9c40af93a 07dfccd9b618a4fc9939ce1c5905c55c7481ade7 lijh 1734773107 +0800 commit: 20241221 +07dfccd9b618a4fc9939ce1c5905c55c7481ade7 3952e9fd98dc55d9f6e15b371e7708170d09a1a6 lijh 1734947704 +0800 commit: 20241223 +3952e9fd98dc55d9f6e15b371e7708170d09a1a6 fd63bc99fd3083eaa6bf786f64461be82ff3ad7b lijh 1735120863 +0800 commit: 20241225 +fd63bc99fd3083eaa6bf786f64461be82ff3ad7b bf5a9a54f9db73a7b48e9fde22769e76fab1215a lijh 1735810865 +0800 commit: 20250102 +bf5a9a54f9db73a7b48e9fde22769e76fab1215a 01187105a5ef6b1bd8c655a4daa545144ad444c3 lijh 1735897432 +0800 commit: 20250103 +01187105a5ef6b1bd8c655a4daa545144ad444c3 d535b6aa820b9a68864fbe3ec623d88025386477 lijh 1735977605 +0800 commit: 202501041 +d535b6aa820b9a68864fbe3ec623d88025386477 0dfbaeede601eb70c253b024cb3f9caf8e4c7d99 lijh 1736416584 +0800 commit: 20250109commit +0dfbaeede601eb70c253b024cb3f9caf8e4c7d99 04aff3093f6cca41a9be5bbd1a52ee15a88fb318 lijh 1736910841 +0800 commit: 20250115 diff --git a/.git1/logs/refs/remotes/origin/ljh b/.git1/logs/refs/remotes/origin/ljh new file mode 100644 index 0000000..365584e --- /dev/null +++ b/.git1/logs/refs/remotes/origin/ljh @@ -0,0 +1,2 @@ +0000000000000000000000000000000000000000 7d0d51792b97bed663b400172ed408b14ad20b3b lijh 1731483843 +0800 fetch: created +7d0d51792b97bed663b400172ed408b14ad20b3b 4fb130a2eb11993c23806615662692d18af4ec88 lijh 1731663778 +0800 push: forced-update diff --git a/.git1/logs/refs/remotes/origin/main b/.git1/logs/refs/remotes/origin/main new file mode 100644 index 0000000..a5afd39 --- /dev/null +++ b/.git1/logs/refs/remotes/origin/main @@ -0,0 +1,15 @@ +0000000000000000000000000000000000000000 2b243c95aa2827e1a76ef1a56b1f202e032878bb lijh 1731483843 +0800 fetch: created +2b243c95aa2827e1a76ef1a56b1f202e032878bb 9845db1b4a1245e97c5be03bebb9bab715a218e7 lijh 1731663806 +0800 fetch: forced-update +9845db1b4a1245e97c5be03bebb9bab715a218e7 53a9af372c9468bf7c16d913471ff58c7ef61704 lijh 1731665099 +0800 push: forced-update +53a9af372c9468bf7c16d913471ff58c7ef61704 317c9cc1b5ecc3b11d832170ae5f10176fb393da lijh 1732612546 +0800 fetch: forced-update +317c9cc1b5ecc3b11d832170ae5f10176fb393da abac41c5434c3d8eaaf2d7cdf133844691b41b91 lijh 1734491152 +0800 push: forced-update +abac41c5434c3d8eaaf2d7cdf133844691b41b91 670784ab2951fc089f9db563485c9bd66c1c3b0a lijh 1734688693 +0800 push: forced-update +670784ab2951fc089f9db563485c9bd66c1c3b0a 6276640680055868526233c1aa6ef7b9c40af93a lijh 1734688716 +0800 push: forced-update +6276640680055868526233c1aa6ef7b9c40af93a 07dfccd9b618a4fc9939ce1c5905c55c7481ade7 lijh 1734773108 +0800 push: forced-update +07dfccd9b618a4fc9939ce1c5905c55c7481ade7 3952e9fd98dc55d9f6e15b371e7708170d09a1a6 lijh 1734947704 +0800 push: forced-update +3952e9fd98dc55d9f6e15b371e7708170d09a1a6 fd63bc99fd3083eaa6bf786f64461be82ff3ad7b lijh 1735120864 +0800 push: forced-update +fd63bc99fd3083eaa6bf786f64461be82ff3ad7b bf5a9a54f9db73a7b48e9fde22769e76fab1215a lijh 1735810865 +0800 push: forced-update +bf5a9a54f9db73a7b48e9fde22769e76fab1215a 01187105a5ef6b1bd8c655a4daa545144ad444c3 lijh 1735897437 +0800 push: forced-update +01187105a5ef6b1bd8c655a4daa545144ad444c3 d535b6aa820b9a68864fbe3ec623d88025386477 lijh 1735977607 +0800 push: forced-update +d535b6aa820b9a68864fbe3ec623d88025386477 0dfbaeede601eb70c253b024cb3f9caf8e4c7d99 lijh 1736416586 +0800 push: forced-update +0dfbaeede601eb70c253b024cb3f9caf8e4c7d99 04aff3093f6cca41a9be5bbd1a52ee15a88fb318 lijh 1736910842 +0800 push: forced-update diff --git a/.git1/objects/00/293003fef83b3aff6d4c189b3554bce404cb28 b/.git1/objects/00/293003fef83b3aff6d4c189b3554bce404cb28 new file mode 100644 index 0000000..90b2f3d Binary files /dev/null and b/.git1/objects/00/293003fef83b3aff6d4c189b3554bce404cb28 differ diff --git a/.git1/objects/01/187105a5ef6b1bd8c655a4daa545144ad444c3 b/.git1/objects/01/187105a5ef6b1bd8c655a4daa545144ad444c3 new file mode 100644 index 0000000..00a064d Binary files /dev/null and b/.git1/objects/01/187105a5ef6b1bd8c655a4daa545144ad444c3 differ diff --git a/.git1/objects/01/60b3e39625be9671714e684ea7cd87d667a3d8 b/.git1/objects/01/60b3e39625be9671714e684ea7cd87d667a3d8 new file mode 100644 index 0000000..edc78d9 Binary files /dev/null and b/.git1/objects/01/60b3e39625be9671714e684ea7cd87d667a3d8 differ diff --git a/.git1/objects/03/977b11b28c0995df4cac30217e7ca2b20c4c74 b/.git1/objects/03/977b11b28c0995df4cac30217e7ca2b20c4c74 new file mode 100644 index 0000000..c46065f Binary files /dev/null and b/.git1/objects/03/977b11b28c0995df4cac30217e7ca2b20c4c74 differ diff --git a/.git1/objects/04/5b5f33ec6470d0232746d9e57c8cdd492d3a5b b/.git1/objects/04/5b5f33ec6470d0232746d9e57c8cdd492d3a5b new file mode 100644 index 0000000..f4b5940 Binary files /dev/null and b/.git1/objects/04/5b5f33ec6470d0232746d9e57c8cdd492d3a5b differ diff --git a/.git1/objects/04/646fe8faa0ce4c483c14358e2c455fb6aa8608 b/.git1/objects/04/646fe8faa0ce4c483c14358e2c455fb6aa8608 new file mode 100644 index 0000000..ba02cf2 Binary files /dev/null and b/.git1/objects/04/646fe8faa0ce4c483c14358e2c455fb6aa8608 differ diff --git a/.git1/objects/04/aff3093f6cca41a9be5bbd1a52ee15a88fb318 b/.git1/objects/04/aff3093f6cca41a9be5bbd1a52ee15a88fb318 new file mode 100644 index 0000000..f89dac1 Binary files /dev/null and b/.git1/objects/04/aff3093f6cca41a9be5bbd1a52ee15a88fb318 differ diff --git a/.git1/objects/06/111ecb83a8663fe0ce6fb623c1d7117f0cfa09 b/.git1/objects/06/111ecb83a8663fe0ce6fb623c1d7117f0cfa09 new file mode 100644 index 0000000..17e16a9 Binary files /dev/null and b/.git1/objects/06/111ecb83a8663fe0ce6fb623c1d7117f0cfa09 differ diff --git a/.git1/objects/07/dfccd9b618a4fc9939ce1c5905c55c7481ade7 b/.git1/objects/07/dfccd9b618a4fc9939ce1c5905c55c7481ade7 new file mode 100644 index 0000000..43a13b4 Binary files /dev/null and b/.git1/objects/07/dfccd9b618a4fc9939ce1c5905c55c7481ade7 differ diff --git a/.git1/objects/09/4163950521f08f1901a360de19a2fc57e13a7d b/.git1/objects/09/4163950521f08f1901a360de19a2fc57e13a7d new file mode 100644 index 0000000..3e3b7b5 Binary files /dev/null and b/.git1/objects/09/4163950521f08f1901a360de19a2fc57e13a7d differ diff --git a/.git1/objects/0b/ec9c70ba764ffba628cfa864431f29d48799a3 b/.git1/objects/0b/ec9c70ba764ffba628cfa864431f29d48799a3 new file mode 100644 index 0000000..5f0d9e9 Binary files /dev/null and b/.git1/objects/0b/ec9c70ba764ffba628cfa864431f29d48799a3 differ diff --git a/.git1/objects/0d/fbaeede601eb70c253b024cb3f9caf8e4c7d99 b/.git1/objects/0d/fbaeede601eb70c253b024cb3f9caf8e4c7d99 new file mode 100644 index 0000000..220ecd7 --- /dev/null +++ b/.git1/objects/0d/fbaeede601eb70c253b024cb3f9caf8e4c7d99 @@ -0,0 +1,3 @@ +xM +0F] %3_*dJ+6oy}֡4) +1s L\ V3wiCWG#۹ {AGʯ]?/xomS1qj-x>hoڐ$ǥ~c@ \ No newline at end of file diff --git a/.git1/objects/0e/720a58312827ddc8c526b9e06c148d62968a85 b/.git1/objects/0e/720a58312827ddc8c526b9e06c148d62968a85 new file mode 100644 index 0000000..bd860cb Binary files /dev/null and b/.git1/objects/0e/720a58312827ddc8c526b9e06c148d62968a85 differ diff --git a/.git1/objects/0e/bef7fa933e5e31b20fc45425da0e8d16800d37 b/.git1/objects/0e/bef7fa933e5e31b20fc45425da0e8d16800d37 new file mode 100644 index 0000000..e06e6b9 Binary files /dev/null and b/.git1/objects/0e/bef7fa933e5e31b20fc45425da0e8d16800d37 differ diff --git a/.git1/objects/10/37dc4edc07948dc20304203e8dcd206401c645 b/.git1/objects/10/37dc4edc07948dc20304203e8dcd206401c645 new file mode 100644 index 0000000..6a378b8 Binary files /dev/null and b/.git1/objects/10/37dc4edc07948dc20304203e8dcd206401c645 differ diff --git a/.git1/objects/11/529333b04458c4fcb02566360bb9ee08f31164 b/.git1/objects/11/529333b04458c4fcb02566360bb9ee08f31164 new file mode 100644 index 0000000..007c9ef Binary files /dev/null and b/.git1/objects/11/529333b04458c4fcb02566360bb9ee08f31164 differ diff --git a/.git1/objects/11/711fe65ddf71e1bb4b741310e26c864ec2db7d b/.git1/objects/11/711fe65ddf71e1bb4b741310e26c864ec2db7d new file mode 100644 index 0000000..5ad1575 Binary files /dev/null and b/.git1/objects/11/711fe65ddf71e1bb4b741310e26c864ec2db7d differ diff --git a/.git1/objects/15/d3f7194a173e3226bd5e4bb1f343f69afd22d5 b/.git1/objects/15/d3f7194a173e3226bd5e4bb1f343f69afd22d5 new file mode 100644 index 0000000..555f559 Binary files /dev/null and b/.git1/objects/15/d3f7194a173e3226bd5e4bb1f343f69afd22d5 differ diff --git a/.git1/objects/16/8a51b6fe233998baf247ddf1e5c54e7e63a9e9 b/.git1/objects/16/8a51b6fe233998baf247ddf1e5c54e7e63a9e9 new file mode 100644 index 0000000..d85e5b2 Binary files /dev/null and b/.git1/objects/16/8a51b6fe233998baf247ddf1e5c54e7e63a9e9 differ diff --git a/.git1/objects/16/b1717f99b1c592a7c38dd25280da0bb17275b9 b/.git1/objects/16/b1717f99b1c592a7c38dd25280da0bb17275b9 new file mode 100644 index 0000000..8f4348a Binary files /dev/null and b/.git1/objects/16/b1717f99b1c592a7c38dd25280da0bb17275b9 differ diff --git a/.git1/objects/1b/5455935418f663a0bade62f402c6e7f98d4f92 b/.git1/objects/1b/5455935418f663a0bade62f402c6e7f98d4f92 new file mode 100644 index 0000000..cb34ba8 Binary files /dev/null and b/.git1/objects/1b/5455935418f663a0bade62f402c6e7f98d4f92 differ diff --git a/.git1/objects/1c/97374b8390923da1c9de7065b71ec2dfeb5361 b/.git1/objects/1c/97374b8390923da1c9de7065b71ec2dfeb5361 new file mode 100644 index 0000000..02e8b0a Binary files /dev/null and b/.git1/objects/1c/97374b8390923da1c9de7065b71ec2dfeb5361 differ diff --git a/.git1/objects/1c/c0c7ad6d63f8e689e97b2a9aefa5d4aad30015 b/.git1/objects/1c/c0c7ad6d63f8e689e97b2a9aefa5d4aad30015 new file mode 100644 index 0000000..d2977a5 Binary files /dev/null and b/.git1/objects/1c/c0c7ad6d63f8e689e97b2a9aefa5d4aad30015 differ diff --git a/.git1/objects/1d/384969d15d0a7a205b7f5a4d58ba4755e89a45 b/.git1/objects/1d/384969d15d0a7a205b7f5a4d58ba4755e89a45 new file mode 100644 index 0000000..db8c908 Binary files /dev/null and b/.git1/objects/1d/384969d15d0a7a205b7f5a4d58ba4755e89a45 differ diff --git a/.git1/objects/23/9a87ab76283afb95b818b9868f4a1c70798cc2 b/.git1/objects/23/9a87ab76283afb95b818b9868f4a1c70798cc2 new file mode 100644 index 0000000..410d7a9 Binary files /dev/null and b/.git1/objects/23/9a87ab76283afb95b818b9868f4a1c70798cc2 differ diff --git a/.git1/objects/26/bfac21a37d192aaa54824fca0ed7cf1947107f b/.git1/objects/26/bfac21a37d192aaa54824fca0ed7cf1947107f new file mode 100644 index 0000000..541ff48 Binary files /dev/null and b/.git1/objects/26/bfac21a37d192aaa54824fca0ed7cf1947107f differ diff --git a/.git1/objects/27/41c03c11cd325f280e0ec306bc6fc2086a5233 b/.git1/objects/27/41c03c11cd325f280e0ec306bc6fc2086a5233 new file mode 100644 index 0000000..9ff5bf8 Binary files /dev/null and b/.git1/objects/27/41c03c11cd325f280e0ec306bc6fc2086a5233 differ diff --git a/.git1/objects/29/4352f8591e3885591af6266360b905cbc8a4b1 b/.git1/objects/29/4352f8591e3885591af6266360b905cbc8a4b1 new file mode 100644 index 0000000..69e98e5 Binary files /dev/null and b/.git1/objects/29/4352f8591e3885591af6266360b905cbc8a4b1 differ diff --git a/.git1/objects/29/bc7ea5373703fc3e7ee2628413fb1deda9a574 b/.git1/objects/29/bc7ea5373703fc3e7ee2628413fb1deda9a574 new file mode 100644 index 0000000..91e5277 Binary files /dev/null and b/.git1/objects/29/bc7ea5373703fc3e7ee2628413fb1deda9a574 differ diff --git a/.git1/objects/2c/10aaff690cf72d468a4b762be655d8d5728e9b b/.git1/objects/2c/10aaff690cf72d468a4b762be655d8d5728e9b new file mode 100644 index 0000000..c124cbc Binary files /dev/null and b/.git1/objects/2c/10aaff690cf72d468a4b762be655d8d5728e9b differ diff --git a/.git1/objects/2f/eaee1022f7338e17198ebf75ba85d29d665ad1 b/.git1/objects/2f/eaee1022f7338e17198ebf75ba85d29d665ad1 new file mode 100644 index 0000000..de2b2bd Binary files /dev/null and b/.git1/objects/2f/eaee1022f7338e17198ebf75ba85d29d665ad1 differ diff --git a/.git1/objects/30/dfa715e65b99cf3f2eb40825a5d57ba1116799 b/.git1/objects/30/dfa715e65b99cf3f2eb40825a5d57ba1116799 new file mode 100644 index 0000000..694202f Binary files /dev/null and b/.git1/objects/30/dfa715e65b99cf3f2eb40825a5d57ba1116799 differ diff --git a/.git1/objects/31/0da16105aaa232276103f3c61a46a358cbf207 b/.git1/objects/31/0da16105aaa232276103f3c61a46a358cbf207 new file mode 100644 index 0000000..63aaba9 Binary files /dev/null and b/.git1/objects/31/0da16105aaa232276103f3c61a46a358cbf207 differ diff --git a/.git1/objects/31/ac6174d79108d9868e9f3befccdd2431aa647f b/.git1/objects/31/ac6174d79108d9868e9f3befccdd2431aa647f new file mode 100644 index 0000000..ca4fdc6 Binary files /dev/null and b/.git1/objects/31/ac6174d79108d9868e9f3befccdd2431aa647f differ diff --git a/.git1/objects/31/ef10e3654acb978f39e1801b250d76798dca1d b/.git1/objects/31/ef10e3654acb978f39e1801b250d76798dca1d new file mode 100644 index 0000000..d1d4d88 Binary files /dev/null and b/.git1/objects/31/ef10e3654acb978f39e1801b250d76798dca1d differ diff --git a/.git1/objects/32/fd94f6e4e2399222fefa6c84af371ccb782954 b/.git1/objects/32/fd94f6e4e2399222fefa6c84af371ccb782954 new file mode 100644 index 0000000..fced5a1 Binary files /dev/null and b/.git1/objects/32/fd94f6e4e2399222fefa6c84af371ccb782954 differ diff --git a/.git1/objects/34/485108e18ff2fd7a19b0ea77239842dd23078e b/.git1/objects/34/485108e18ff2fd7a19b0ea77239842dd23078e new file mode 100644 index 0000000..dd9be79 Binary files /dev/null and b/.git1/objects/34/485108e18ff2fd7a19b0ea77239842dd23078e differ diff --git a/.git1/objects/39/2d7b019b4da15d4d9f3177db86047715496672 b/.git1/objects/39/2d7b019b4da15d4d9f3177db86047715496672 new file mode 100644 index 0000000..312d261 Binary files /dev/null and b/.git1/objects/39/2d7b019b4da15d4d9f3177db86047715496672 differ diff --git a/.git1/objects/39/389bace6a6062cc60d28783972b45761b2125f b/.git1/objects/39/389bace6a6062cc60d28783972b45761b2125f new file mode 100644 index 0000000..f62c73c Binary files /dev/null and b/.git1/objects/39/389bace6a6062cc60d28783972b45761b2125f differ diff --git a/.git1/objects/39/52e9fd98dc55d9f6e15b371e7708170d09a1a6 b/.git1/objects/39/52e9fd98dc55d9f6e15b371e7708170d09a1a6 new file mode 100644 index 0000000..61851ac Binary files /dev/null and b/.git1/objects/39/52e9fd98dc55d9f6e15b371e7708170d09a1a6 differ diff --git a/.git1/objects/3a/84a9f8d72525e5bd3efa66f34b23aa297b3b3d b/.git1/objects/3a/84a9f8d72525e5bd3efa66f34b23aa297b3b3d new file mode 100644 index 0000000..6c05ae5 Binary files /dev/null and b/.git1/objects/3a/84a9f8d72525e5bd3efa66f34b23aa297b3b3d differ diff --git a/.git1/objects/3b/eea2d1c289ff107fad4f6f52aa13bbce18a60f b/.git1/objects/3b/eea2d1c289ff107fad4f6f52aa13bbce18a60f new file mode 100644 index 0000000..61a78a9 Binary files /dev/null and b/.git1/objects/3b/eea2d1c289ff107fad4f6f52aa13bbce18a60f differ diff --git a/.git1/objects/3d/1a3c402a333d26b10f96576bb124749f7f9942 b/.git1/objects/3d/1a3c402a333d26b10f96576bb124749f7f9942 new file mode 100644 index 0000000..5418476 Binary files /dev/null and b/.git1/objects/3d/1a3c402a333d26b10f96576bb124749f7f9942 differ diff --git a/.git1/objects/3e/7a812d5c37cc9a37677c3dc8eb27f32d021956 b/.git1/objects/3e/7a812d5c37cc9a37677c3dc8eb27f32d021956 new file mode 100644 index 0000000..919a0f1 Binary files /dev/null and b/.git1/objects/3e/7a812d5c37cc9a37677c3dc8eb27f32d021956 differ diff --git a/.git1/objects/3e/897c6e9ebba5ab405685d3fadbcfa7d0a6869e b/.git1/objects/3e/897c6e9ebba5ab405685d3fadbcfa7d0a6869e new file mode 100644 index 0000000..9874724 Binary files /dev/null and b/.git1/objects/3e/897c6e9ebba5ab405685d3fadbcfa7d0a6869e differ diff --git a/.git1/objects/40/07535d0720558d54cdbeafe49247b57248b726 b/.git1/objects/40/07535d0720558d54cdbeafe49247b57248b726 new file mode 100644 index 0000000..980fe7c Binary files /dev/null and b/.git1/objects/40/07535d0720558d54cdbeafe49247b57248b726 differ diff --git a/.git1/objects/40/b4619b0267e4f51d350fd7d1d6a2ca7ea8fcfb b/.git1/objects/40/b4619b0267e4f51d350fd7d1d6a2ca7ea8fcfb new file mode 100644 index 0000000..90a62c0 Binary files /dev/null and b/.git1/objects/40/b4619b0267e4f51d350fd7d1d6a2ca7ea8fcfb differ diff --git a/.git1/objects/41/29e7530cc38a41b008c898d28d2155f9ae5271 b/.git1/objects/41/29e7530cc38a41b008c898d28d2155f9ae5271 new file mode 100644 index 0000000..031db56 Binary files /dev/null and b/.git1/objects/41/29e7530cc38a41b008c898d28d2155f9ae5271 differ diff --git a/.git1/objects/42/b1e3346d2e1ef4a133e91da1579ef9d8664c50 b/.git1/objects/42/b1e3346d2e1ef4a133e91da1579ef9d8664c50 new file mode 100644 index 0000000..dbeefe4 Binary files /dev/null and b/.git1/objects/42/b1e3346d2e1ef4a133e91da1579ef9d8664c50 differ diff --git a/.git1/objects/43/4f010aefdd8e9f59cdeab6687a09744737d046 b/.git1/objects/43/4f010aefdd8e9f59cdeab6687a09744737d046 new file mode 100644 index 0000000..ada6f1f Binary files /dev/null and b/.git1/objects/43/4f010aefdd8e9f59cdeab6687a09744737d046 differ diff --git a/.git1/objects/43/a7f23638e1a67291c5deeeebd321aa2c600828 b/.git1/objects/43/a7f23638e1a67291c5deeeebd321aa2c600828 new file mode 100644 index 0000000..a94a5d5 Binary files /dev/null and b/.git1/objects/43/a7f23638e1a67291c5deeeebd321aa2c600828 differ diff --git a/.git1/objects/47/864d8febbfacaf6524570385f919a5c6c60716 b/.git1/objects/47/864d8febbfacaf6524570385f919a5c6c60716 new file mode 100644 index 0000000..1fd0b8f --- /dev/null +++ b/.git1/objects/47/864d8febbfacaf6524570385f919a5c6c60716 @@ -0,0 +1,2 @@ +xKN1 Y)b=E|$歪TzҏN%=̡ +" bK\IJ$SIYF_~mB> ZVX ' d1k YeRXMb;y{p^~Mzk}γW0F}GYI˻УO}VxPN}Km~fj/M] \ No newline at end of file diff --git a/.git1/objects/47/911366453508043cf7f58f377f9a067dadf230 b/.git1/objects/47/911366453508043cf7f58f377f9a067dadf230 new file mode 100644 index 0000000..324f88d Binary files /dev/null and b/.git1/objects/47/911366453508043cf7f58f377f9a067dadf230 differ diff --git a/.git1/objects/48/2ca808faf0afb048b156e3d3c1f827263b96bd b/.git1/objects/48/2ca808faf0afb048b156e3d3c1f827263b96bd new file mode 100644 index 0000000..b0bcf7f Binary files /dev/null and b/.git1/objects/48/2ca808faf0afb048b156e3d3c1f827263b96bd differ diff --git a/.git1/objects/48/78789856ceed12f9c2d89072c3773d2e34a8ec b/.git1/objects/48/78789856ceed12f9c2d89072c3773d2e34a8ec new file mode 100644 index 0000000..0ed265d Binary files /dev/null and b/.git1/objects/48/78789856ceed12f9c2d89072c3773d2e34a8ec differ diff --git a/.git1/objects/48/92cc4b10e8e8ff02deb4cfc4e81732540fb5ed b/.git1/objects/48/92cc4b10e8e8ff02deb4cfc4e81732540fb5ed new file mode 100644 index 0000000..d5f7371 Binary files /dev/null and b/.git1/objects/48/92cc4b10e8e8ff02deb4cfc4e81732540fb5ed differ diff --git a/.git1/objects/4a/a183fea1e1fdbf80138c8b12d4ded67170c186 b/.git1/objects/4a/a183fea1e1fdbf80138c8b12d4ded67170c186 new file mode 100644 index 0000000..d3a1e47 Binary files /dev/null and b/.git1/objects/4a/a183fea1e1fdbf80138c8b12d4ded67170c186 differ diff --git a/.git1/objects/4e/61eb8490fff2da904f581c4231a03e2d2ab83f b/.git1/objects/4e/61eb8490fff2da904f581c4231a03e2d2ab83f new file mode 100644 index 0000000..9c5b47f Binary files /dev/null and b/.git1/objects/4e/61eb8490fff2da904f581c4231a03e2d2ab83f differ diff --git a/.git1/objects/4e/949dd3d6bb8751fcec63ecde97fbe0bb457ebd b/.git1/objects/4e/949dd3d6bb8751fcec63ecde97fbe0bb457ebd new file mode 100644 index 0000000..44a1613 Binary files /dev/null and b/.git1/objects/4e/949dd3d6bb8751fcec63ecde97fbe0bb457ebd differ diff --git a/.git1/objects/4e/dd75806821d929a48fbc8ac8df7ff8bd45dab8 b/.git1/objects/4e/dd75806821d929a48fbc8ac8df7ff8bd45dab8 new file mode 100644 index 0000000..321c2b8 Binary files /dev/null and b/.git1/objects/4e/dd75806821d929a48fbc8ac8df7ff8bd45dab8 differ diff --git a/.git1/objects/4f/36ab3a337f68689cf32b7c929a9387f7f6d687 b/.git1/objects/4f/36ab3a337f68689cf32b7c929a9387f7f6d687 new file mode 100644 index 0000000..41bca99 Binary files /dev/null and b/.git1/objects/4f/36ab3a337f68689cf32b7c929a9387f7f6d687 differ diff --git a/.git1/objects/4f/b130a2eb11993c23806615662692d18af4ec88 b/.git1/objects/4f/b130a2eb11993c23806615662692d18af4ec88 new file mode 100644 index 0000000..5d8a033 Binary files /dev/null and b/.git1/objects/4f/b130a2eb11993c23806615662692d18af4ec88 differ diff --git a/.git1/objects/50/7ec9e9a4c6bcf9d77640f36c51c137c0d9698f b/.git1/objects/50/7ec9e9a4c6bcf9d77640f36c51c137c0d9698f new file mode 100644 index 0000000..80db4ac Binary files /dev/null and b/.git1/objects/50/7ec9e9a4c6bcf9d77640f36c51c137c0d9698f differ diff --git a/.git1/objects/52/11345cf5ad1fedae80f5bd528ad7b92312286d b/.git1/objects/52/11345cf5ad1fedae80f5bd528ad7b92312286d new file mode 100644 index 0000000..fe64be9 Binary files /dev/null and b/.git1/objects/52/11345cf5ad1fedae80f5bd528ad7b92312286d differ diff --git a/.git1/objects/52/36a7dd773895360d7fad332860550d29ec492e b/.git1/objects/52/36a7dd773895360d7fad332860550d29ec492e new file mode 100644 index 0000000..e5619da Binary files /dev/null and b/.git1/objects/52/36a7dd773895360d7fad332860550d29ec492e differ diff --git a/.git1/objects/53/0dd8bbdd351c24de922ec4faefd7df229737d6 b/.git1/objects/53/0dd8bbdd351c24de922ec4faefd7df229737d6 new file mode 100644 index 0000000..7b3bcb1 --- /dev/null +++ b/.git1/objects/53/0dd8bbdd351c24de922ec4faefd7df229737d6 @@ -0,0 +1,3 @@ +xTMo@ٿ\om@rCP?D(Dxgw w,Ǵ̛ٷ.4q6?IC+y4ZRcҁ!`O-i&hІ2{1i- k "*mK^WcJЖd=zZ9LZ<-VGQCjA-VN8 Bhm[ ׽l`%Ȫ!bpZA鋃xɐ8lpoV'f$Ǽ37'n jrG`:ى*Gp[9$ԁ +;*>ˀj,saSVy U'X Z:V.:w|Jc͵#\<&;rOb(d]n+"5ڍ X0jw4~&y]ƽ4F久S8dNXU| +bg6`TB2mi+@/4Q3,n \ No newline at end of file diff --git a/.git1/objects/53/a9af372c9468bf7c16d913471ff58c7ef61704 b/.git1/objects/53/a9af372c9468bf7c16d913471ff58c7ef61704 new file mode 100644 index 0000000..d5bb4f5 Binary files /dev/null and b/.git1/objects/53/a9af372c9468bf7c16d913471ff58c7ef61704 differ diff --git a/.git1/objects/54/44270fb67d5b1dacfcf5896c3792128bb0bfe0 b/.git1/objects/54/44270fb67d5b1dacfcf5896c3792128bb0bfe0 new file mode 100644 index 0000000..75caf3b Binary files /dev/null and b/.git1/objects/54/44270fb67d5b1dacfcf5896c3792128bb0bfe0 differ diff --git a/.git1/objects/56/cde5eaeddf79422103523a579b3892506e369a b/.git1/objects/56/cde5eaeddf79422103523a579b3892506e369a new file mode 100644 index 0000000..9b67740 Binary files /dev/null and b/.git1/objects/56/cde5eaeddf79422103523a579b3892506e369a differ diff --git a/.git1/objects/57/be3d8b227a85943525dd29a0dd741e2476bfbd b/.git1/objects/57/be3d8b227a85943525dd29a0dd741e2476bfbd new file mode 100644 index 0000000..aa38e71 Binary files /dev/null and b/.git1/objects/57/be3d8b227a85943525dd29a0dd741e2476bfbd differ diff --git a/.git1/objects/5a/391d804b5a3cc7f67f0e5ec0a4aa5f9a222592 b/.git1/objects/5a/391d804b5a3cc7f67f0e5ec0a4aa5f9a222592 new file mode 100644 index 0000000..a19702f Binary files /dev/null and b/.git1/objects/5a/391d804b5a3cc7f67f0e5ec0a4aa5f9a222592 differ diff --git a/.git1/objects/5a/77f50848a60b941f7cc5f2b5528b1cc8f49424 b/.git1/objects/5a/77f50848a60b941f7cc5f2b5528b1cc8f49424 new file mode 100644 index 0000000..d6d7f8a Binary files /dev/null and b/.git1/objects/5a/77f50848a60b941f7cc5f2b5528b1cc8f49424 differ diff --git a/.git1/objects/5e/01d71267e553becf7935b2694838a190adce88 b/.git1/objects/5e/01d71267e553becf7935b2694838a190adce88 new file mode 100644 index 0000000..78d1cf7 Binary files /dev/null and b/.git1/objects/5e/01d71267e553becf7935b2694838a190adce88 differ diff --git a/.git1/objects/5e/1946c2d92d26bb10a8f3d932182f0e9df3fb75 b/.git1/objects/5e/1946c2d92d26bb10a8f3d932182f0e9df3fb75 new file mode 100644 index 0000000..892d3cc Binary files /dev/null and b/.git1/objects/5e/1946c2d92d26bb10a8f3d932182f0e9df3fb75 differ diff --git a/.git1/objects/5e/deb49362f8278d4af943732f11fdb4f8744126 b/.git1/objects/5e/deb49362f8278d4af943732f11fdb4f8744126 new file mode 100644 index 0000000..30dd616 Binary files /dev/null and b/.git1/objects/5e/deb49362f8278d4af943732f11fdb4f8744126 differ diff --git a/.git1/objects/5f/4bb60609a1c71025b63da6874b6eedeee21f7a b/.git1/objects/5f/4bb60609a1c71025b63da6874b6eedeee21f7a new file mode 100644 index 0000000..dc933ca Binary files /dev/null and b/.git1/objects/5f/4bb60609a1c71025b63da6874b6eedeee21f7a differ diff --git a/.git1/objects/62/76640680055868526233c1aa6ef7b9c40af93a b/.git1/objects/62/76640680055868526233c1aa6ef7b9c40af93a new file mode 100644 index 0000000..2e61654 Binary files /dev/null and b/.git1/objects/62/76640680055868526233c1aa6ef7b9c40af93a differ diff --git a/.git1/objects/63/53d7fe889909241bdd54b93b12b9b21d387b3a b/.git1/objects/63/53d7fe889909241bdd54b93b12b9b21d387b3a new file mode 100644 index 0000000..1b7c3de Binary files /dev/null and b/.git1/objects/63/53d7fe889909241bdd54b93b12b9b21d387b3a differ diff --git a/.git1/objects/66/5e6c70200f2b9a66e88e7c77dbd138acb32f2b b/.git1/objects/66/5e6c70200f2b9a66e88e7c77dbd138acb32f2b new file mode 100644 index 0000000..47fafe2 Binary files /dev/null and b/.git1/objects/66/5e6c70200f2b9a66e88e7c77dbd138acb32f2b differ diff --git a/.git1/objects/67/0784ab2951fc089f9db563485c9bd66c1c3b0a b/.git1/objects/67/0784ab2951fc089f9db563485c9bd66c1c3b0a new file mode 100644 index 0000000..5a3f3e3 Binary files /dev/null and b/.git1/objects/67/0784ab2951fc089f9db563485c9bd66c1c3b0a differ diff --git a/.git1/objects/67/3bec9a62b9fa882fc977ee73cd093f28a21858 b/.git1/objects/67/3bec9a62b9fa882fc977ee73cd093f28a21858 new file mode 100644 index 0000000..0369497 Binary files /dev/null and b/.git1/objects/67/3bec9a62b9fa882fc977ee73cd093f28a21858 differ diff --git a/.git1/objects/69/55c71f429e9e5575c154393ba1ed07515c6641 b/.git1/objects/69/55c71f429e9e5575c154393ba1ed07515c6641 new file mode 100644 index 0000000..a120954 Binary files /dev/null and b/.git1/objects/69/55c71f429e9e5575c154393ba1ed07515c6641 differ diff --git a/.git1/objects/6a/7002eb5dae86825cb2c9cf5c116d034ebcef46 b/.git1/objects/6a/7002eb5dae86825cb2c9cf5c116d034ebcef46 new file mode 100644 index 0000000..f2bc87a Binary files /dev/null and b/.git1/objects/6a/7002eb5dae86825cb2c9cf5c116d034ebcef46 differ diff --git a/.git1/objects/6d/e2c21562eb3bb8123b3da29a5d507a160177b4 b/.git1/objects/6d/e2c21562eb3bb8123b3da29a5d507a160177b4 new file mode 100644 index 0000000..6de94a8 Binary files /dev/null and b/.git1/objects/6d/e2c21562eb3bb8123b3da29a5d507a160177b4 differ diff --git a/.git1/objects/6e/a2986c51f8f82cfb4dce75b241a601153603e3 b/.git1/objects/6e/a2986c51f8f82cfb4dce75b241a601153603e3 new file mode 100644 index 0000000..55c5ca0 Binary files /dev/null and b/.git1/objects/6e/a2986c51f8f82cfb4dce75b241a601153603e3 differ diff --git a/.git1/objects/6f/72a92ca8e655595d5ec6d6f9d8f769d7ef63f9 b/.git1/objects/6f/72a92ca8e655595d5ec6d6f9d8f769d7ef63f9 new file mode 100644 index 0000000..196261b Binary files /dev/null and b/.git1/objects/6f/72a92ca8e655595d5ec6d6f9d8f769d7ef63f9 differ diff --git a/.git1/objects/70/c92939b1ceedc6cb9eee280e8fa3342855fb4c b/.git1/objects/70/c92939b1ceedc6cb9eee280e8fa3342855fb4c new file mode 100644 index 0000000..fa8f348 Binary files /dev/null and b/.git1/objects/70/c92939b1ceedc6cb9eee280e8fa3342855fb4c differ diff --git a/.git1/objects/72/48d7cae98b49d8ab2ec2bc5a380e4e8fd870c8 b/.git1/objects/72/48d7cae98b49d8ab2ec2bc5a380e4e8fd870c8 new file mode 100644 index 0000000..dcdb7eb Binary files /dev/null and b/.git1/objects/72/48d7cae98b49d8ab2ec2bc5a380e4e8fd870c8 differ diff --git a/.git1/objects/72/f0e9fe9a04d2b269cc8e6f014dd0020e7379a8 b/.git1/objects/72/f0e9fe9a04d2b269cc8e6f014dd0020e7379a8 new file mode 100644 index 0000000..9999d23 Binary files /dev/null and b/.git1/objects/72/f0e9fe9a04d2b269cc8e6f014dd0020e7379a8 differ diff --git a/.git1/objects/73/0951fcaf357d11858c57ebcafa3bca3aa7fedd b/.git1/objects/73/0951fcaf357d11858c57ebcafa3bca3aa7fedd new file mode 100644 index 0000000..ae7c0c9 Binary files /dev/null and b/.git1/objects/73/0951fcaf357d11858c57ebcafa3bca3aa7fedd differ diff --git a/.git1/objects/77/2b34815597426a02f0a9ef4794948d33ba768d b/.git1/objects/77/2b34815597426a02f0a9ef4794948d33ba768d new file mode 100644 index 0000000..5e2c979 Binary files /dev/null and b/.git1/objects/77/2b34815597426a02f0a9ef4794948d33ba768d differ diff --git a/.git1/objects/77/f32c2cd2b4a8ad745ae88a0f78552abf6f073e b/.git1/objects/77/f32c2cd2b4a8ad745ae88a0f78552abf6f073e new file mode 100644 index 0000000..c8416b2 Binary files /dev/null and b/.git1/objects/77/f32c2cd2b4a8ad745ae88a0f78552abf6f073e differ diff --git a/.git1/objects/79/71ef8cbf1e3c90af318735cfb283edf84776dc b/.git1/objects/79/71ef8cbf1e3c90af318735cfb283edf84776dc new file mode 100644 index 0000000..bed35fe Binary files /dev/null and b/.git1/objects/79/71ef8cbf1e3c90af318735cfb283edf84776dc differ diff --git a/.git1/objects/7a/2546f4296105e6b7263bdcb26c0d3fcfbdc065 b/.git1/objects/7a/2546f4296105e6b7263bdcb26c0d3fcfbdc065 new file mode 100644 index 0000000..cb8f2c9 Binary files /dev/null and b/.git1/objects/7a/2546f4296105e6b7263bdcb26c0d3fcfbdc065 differ diff --git a/.git1/objects/7b/d9863f3990c3333f1307911c687bb706ca5f20 b/.git1/objects/7b/d9863f3990c3333f1307911c687bb706ca5f20 new file mode 100644 index 0000000..b8fe458 Binary files /dev/null and b/.git1/objects/7b/d9863f3990c3333f1307911c687bb706ca5f20 differ diff --git a/.git1/objects/7c/bd0e269269502c8d1f11d760927305c05f5026 b/.git1/objects/7c/bd0e269269502c8d1f11d760927305c05f5026 new file mode 100644 index 0000000..9cb0847 Binary files /dev/null and b/.git1/objects/7c/bd0e269269502c8d1f11d760927305c05f5026 differ diff --git a/.git1/objects/7d/c3156097a80de7064a3ad96da7a38acb97fe14 b/.git1/objects/7d/c3156097a80de7064a3ad96da7a38acb97fe14 new file mode 100644 index 0000000..44c80cc Binary files /dev/null and b/.git1/objects/7d/c3156097a80de7064a3ad96da7a38acb97fe14 differ diff --git a/.git1/objects/7f/722600d5878e593f6382576d4afc44a1154af0 b/.git1/objects/7f/722600d5878e593f6382576d4afc44a1154af0 new file mode 100644 index 0000000..0b48866 Binary files /dev/null and b/.git1/objects/7f/722600d5878e593f6382576d4afc44a1154af0 differ diff --git a/.git1/objects/80/17cdfc60122187698d39a88a181f2381055d01 b/.git1/objects/80/17cdfc60122187698d39a88a181f2381055d01 new file mode 100644 index 0000000..ea0a51c Binary files /dev/null and b/.git1/objects/80/17cdfc60122187698d39a88a181f2381055d01 differ diff --git a/.git1/objects/80/8b30b5f85bbfe4e80a7de05a992986a2360d47 b/.git1/objects/80/8b30b5f85bbfe4e80a7de05a992986a2360d47 new file mode 100644 index 0000000..96cadd6 Binary files /dev/null and b/.git1/objects/80/8b30b5f85bbfe4e80a7de05a992986a2360d47 differ diff --git a/.git1/objects/80/ec41c0a1e380d6e88c8ae184debee127aadc28 b/.git1/objects/80/ec41c0a1e380d6e88c8ae184debee127aadc28 new file mode 100644 index 0000000..1e499e8 Binary files /dev/null and b/.git1/objects/80/ec41c0a1e380d6e88c8ae184debee127aadc28 differ diff --git a/.git1/objects/81/3bcc1ad1047a33bf7c0f7f6c634b5b924629e7 b/.git1/objects/81/3bcc1ad1047a33bf7c0f7f6c634b5b924629e7 new file mode 100644 index 0000000..3a85a1d Binary files /dev/null and b/.git1/objects/81/3bcc1ad1047a33bf7c0f7f6c634b5b924629e7 differ diff --git a/.git1/objects/81/fbd7fde189dc357cd4245916198cea7396c165 b/.git1/objects/81/fbd7fde189dc357cd4245916198cea7396c165 new file mode 100644 index 0000000..72c0b58 Binary files /dev/null and b/.git1/objects/81/fbd7fde189dc357cd4245916198cea7396c165 differ diff --git a/.git1/objects/82/1ab6570b491ee1d3e3cf597075e38b7485885a b/.git1/objects/82/1ab6570b491ee1d3e3cf597075e38b7485885a new file mode 100644 index 0000000..50cf5ca Binary files /dev/null and b/.git1/objects/82/1ab6570b491ee1d3e3cf597075e38b7485885a differ diff --git a/.git1/objects/82/b1faf74de543b65d45278c87a3673d1043b21f b/.git1/objects/82/b1faf74de543b65d45278c87a3673d1043b21f new file mode 100644 index 0000000..7773ac8 --- /dev/null +++ b/.git1/objects/82/b1faf74de543b65d45278c87a3673d1043b21f @@ -0,0 +1,4 @@ +xSn@jғ#*8m(*퉳z7쎝ı'n\9!qf؉@37X?}B$7"+3d*q6 C/Ev-J TRaeRꌟܜ`v"RiN DLE`v(4%P]>68+wwl@-z:"5&S`7ڽ"O ,"h)kEa(b%(k!+bjRX$Q +r n`ae)=1b kpnbdZ8B3iXEȖ,يls|`М֚ b؆dU+'(z^x` wm J#S溝TCz|-I~B3EF3bE*im<괇q Zc.H8eR+Q 4 +T>kͅ{k1, 1u`7cvRyTr-`lL3V~6:Q2ʣGggސzo yX{)ڑrUJcB^ _s4WhREGG=n +zyF0ЁhoVG|8 \ No newline at end of file diff --git a/.git1/objects/84/9315da1d150d46ed86daeb387d6f19df82dbd8 b/.git1/objects/84/9315da1d150d46ed86daeb387d6f19df82dbd8 new file mode 100644 index 0000000..b6c3118 Binary files /dev/null and b/.git1/objects/84/9315da1d150d46ed86daeb387d6f19df82dbd8 differ diff --git a/.git1/objects/84/95b14c2a246421b4157d029c1f043a93f0655b b/.git1/objects/84/95b14c2a246421b4157d029c1f043a93f0655b new file mode 100644 index 0000000..82f0a3a Binary files /dev/null and b/.git1/objects/84/95b14c2a246421b4157d029c1f043a93f0655b differ diff --git a/.git1/objects/85/bbf1a629e01b027ae02a3c8ff5a5705e12ba7a b/.git1/objects/85/bbf1a629e01b027ae02a3c8ff5a5705e12ba7a new file mode 100644 index 0000000..20481cf Binary files /dev/null and b/.git1/objects/85/bbf1a629e01b027ae02a3c8ff5a5705e12ba7a differ diff --git a/.git1/objects/88/284feecf6e9fd4afaa88d9dd0675afd27deadf b/.git1/objects/88/284feecf6e9fd4afaa88d9dd0675afd27deadf new file mode 100644 index 0000000..76030d3 Binary files /dev/null and b/.git1/objects/88/284feecf6e9fd4afaa88d9dd0675afd27deadf differ diff --git a/.git1/objects/89/1d273574705a67849410dbea0182cc1acb231f b/.git1/objects/89/1d273574705a67849410dbea0182cc1acb231f new file mode 100644 index 0000000..0a7f575 Binary files /dev/null and b/.git1/objects/89/1d273574705a67849410dbea0182cc1acb231f differ diff --git a/.git1/objects/8d/87f544cfd4ef14bd376486b7a9a511c7514b07 b/.git1/objects/8d/87f544cfd4ef14bd376486b7a9a511c7514b07 new file mode 100644 index 0000000..c4b17dc Binary files /dev/null and b/.git1/objects/8d/87f544cfd4ef14bd376486b7a9a511c7514b07 differ diff --git a/.git1/objects/90/5fac0d6b3227af42fee532fd593f6d04c724b9 b/.git1/objects/90/5fac0d6b3227af42fee532fd593f6d04c724b9 new file mode 100644 index 0000000..3dc6ad1 Binary files /dev/null and b/.git1/objects/90/5fac0d6b3227af42fee532fd593f6d04c724b9 differ diff --git a/.git1/objects/92/4d2cbc38372d3e004f51e95966000eaae50b97 b/.git1/objects/92/4d2cbc38372d3e004f51e95966000eaae50b97 new file mode 100644 index 0000000..ff54377 Binary files /dev/null and b/.git1/objects/92/4d2cbc38372d3e004f51e95966000eaae50b97 differ diff --git a/.git1/objects/92/c7832382d82fd5e5678b4178738c6d88248452 b/.git1/objects/92/c7832382d82fd5e5678b4178738c6d88248452 new file mode 100644 index 0000000..b0184b0 Binary files /dev/null and b/.git1/objects/92/c7832382d82fd5e5678b4178738c6d88248452 differ diff --git a/.git1/objects/94/29d7eefe41387e01ebe3c6cf79653696cf2e09 b/.git1/objects/94/29d7eefe41387e01ebe3c6cf79653696cf2e09 new file mode 100644 index 0000000..6a72b4a Binary files /dev/null and b/.git1/objects/94/29d7eefe41387e01ebe3c6cf79653696cf2e09 differ diff --git a/.git1/objects/95/8612a6e46d0c05cac3113ddd440879e5f39e7c b/.git1/objects/95/8612a6e46d0c05cac3113ddd440879e5f39e7c new file mode 100644 index 0000000..5fa3663 Binary files /dev/null and b/.git1/objects/95/8612a6e46d0c05cac3113ddd440879e5f39e7c differ diff --git a/.git1/objects/99/44faa1bcbd5a452a3c60fd60dc512ceff383b4 b/.git1/objects/99/44faa1bcbd5a452a3c60fd60dc512ceff383b4 new file mode 100644 index 0000000..6f39917 Binary files /dev/null and b/.git1/objects/99/44faa1bcbd5a452a3c60fd60dc512ceff383b4 differ diff --git a/.git1/objects/99/97ce18937c4d065f437bf27ae196a21af45493 b/.git1/objects/99/97ce18937c4d065f437bf27ae196a21af45493 new file mode 100644 index 0000000..f6306d2 Binary files /dev/null and b/.git1/objects/99/97ce18937c4d065f437bf27ae196a21af45493 differ diff --git a/.git1/objects/9b/12aad6d7bd8c67dbfa3193a27359897f353eb5 b/.git1/objects/9b/12aad6d7bd8c67dbfa3193a27359897f353eb5 new file mode 100644 index 0000000..3610054 Binary files /dev/null and b/.git1/objects/9b/12aad6d7bd8c67dbfa3193a27359897f353eb5 differ diff --git a/.git1/objects/9b/52e009c27aa9839ca53dbc391e523c7a9c9291 b/.git1/objects/9b/52e009c27aa9839ca53dbc391e523c7a9c9291 new file mode 100644 index 0000000..5ae298f Binary files /dev/null and b/.git1/objects/9b/52e009c27aa9839ca53dbc391e523c7a9c9291 differ diff --git a/.git1/objects/9d/f6b01e5622a6bb848fe5d60cbfb6569d4c2505 b/.git1/objects/9d/f6b01e5622a6bb848fe5d60cbfb6569d4c2505 new file mode 100644 index 0000000..8c84f2b Binary files /dev/null and b/.git1/objects/9d/f6b01e5622a6bb848fe5d60cbfb6569d4c2505 differ diff --git a/.git1/objects/a0/ea2d7f06adf817e229ec6c2922593513eb26ec b/.git1/objects/a0/ea2d7f06adf817e229ec6c2922593513eb26ec new file mode 100644 index 0000000..2f687c6 Binary files /dev/null and b/.git1/objects/a0/ea2d7f06adf817e229ec6c2922593513eb26ec differ diff --git a/.git1/objects/a1/f36850a9ee9da15a0b4199e6f9e63bb9f98c69 b/.git1/objects/a1/f36850a9ee9da15a0b4199e6f9e63bb9f98c69 new file mode 100644 index 0000000..569bf94 Binary files /dev/null and b/.git1/objects/a1/f36850a9ee9da15a0b4199e6f9e63bb9f98c69 differ diff --git a/.git1/objects/a4/58303df220815945259f8a0ae68c8a0f3fe056 b/.git1/objects/a4/58303df220815945259f8a0ae68c8a0f3fe056 new file mode 100644 index 0000000..0346467 Binary files /dev/null and b/.git1/objects/a4/58303df220815945259f8a0ae68c8a0f3fe056 differ diff --git a/.git1/objects/a6/3e71be0f4aff9d3964da973503ecc331b78924 b/.git1/objects/a6/3e71be0f4aff9d3964da973503ecc331b78924 new file mode 100644 index 0000000..196752a Binary files /dev/null and b/.git1/objects/a6/3e71be0f4aff9d3964da973503ecc331b78924 differ diff --git a/.git1/objects/a6/4a55e57bd8d168e8a746ec7674b82093e79a71 b/.git1/objects/a6/4a55e57bd8d168e8a746ec7674b82093e79a71 new file mode 100644 index 0000000..aacc6c7 Binary files /dev/null and b/.git1/objects/a6/4a55e57bd8d168e8a746ec7674b82093e79a71 differ diff --git a/.git1/objects/ab/ac41c5434c3d8eaaf2d7cdf133844691b41b91 b/.git1/objects/ab/ac41c5434c3d8eaaf2d7cdf133844691b41b91 new file mode 100644 index 0000000..7ec8d9e --- /dev/null +++ b/.git1/objects/ab/ac41c5434c3d8eaaf2d7cdf133844691b41b91 @@ -0,0 +1,2 @@ +xK +1 @] CI"^%̈voxlH<  kY*ά`(T9tkk$X#֏RI1fD( 5ֽv[˫}j6&my&:#0ڰ" 7? diff --git a/.git1/objects/ab/c24fee89693e96c2dda6d0da181aa1065b7c1e b/.git1/objects/ab/c24fee89693e96c2dda6d0da181aa1065b7c1e new file mode 100644 index 0000000..cf006e8 Binary files /dev/null and b/.git1/objects/ab/c24fee89693e96c2dda6d0da181aa1065b7c1e differ diff --git a/.git1/objects/ac/e469f4aa0036e5c7bdc6600b61e20ca8af6ca6 b/.git1/objects/ac/e469f4aa0036e5c7bdc6600b61e20ca8af6ca6 new file mode 100644 index 0000000..af835cc Binary files /dev/null and b/.git1/objects/ac/e469f4aa0036e5c7bdc6600b61e20ca8af6ca6 differ diff --git a/.git1/objects/ad/1956bdf74a8384449cdfb5b316afcaa6f7afde b/.git1/objects/ad/1956bdf74a8384449cdfb5b316afcaa6f7afde new file mode 100644 index 0000000..d28a980 Binary files /dev/null and b/.git1/objects/ad/1956bdf74a8384449cdfb5b316afcaa6f7afde differ diff --git a/.git1/objects/b0/65c295f5e4edd6a8b29fa4771f4d01ea380961 b/.git1/objects/b0/65c295f5e4edd6a8b29fa4771f4d01ea380961 new file mode 100644 index 0000000..43a772c Binary files /dev/null and b/.git1/objects/b0/65c295f5e4edd6a8b29fa4771f4d01ea380961 differ diff --git a/.git1/objects/b1/59565b78ce200fef29c103783fcf5b47385f39 b/.git1/objects/b1/59565b78ce200fef29c103783fcf5b47385f39 new file mode 100644 index 0000000..8a8c4f4 Binary files /dev/null and b/.git1/objects/b1/59565b78ce200fef29c103783fcf5b47385f39 differ diff --git a/.git1/objects/b1/ee8360e0f171842794db891dd39c72d75ef3f7 b/.git1/objects/b1/ee8360e0f171842794db891dd39c72d75ef3f7 new file mode 100644 index 0000000..e286f2e Binary files /dev/null and b/.git1/objects/b1/ee8360e0f171842794db891dd39c72d75ef3f7 differ diff --git a/.git1/objects/b3/9b81d3b92ecdd2be9c9dc11b095f5e36132117 b/.git1/objects/b3/9b81d3b92ecdd2be9c9dc11b095f5e36132117 new file mode 100644 index 0000000..fe96f7c Binary files /dev/null and b/.git1/objects/b3/9b81d3b92ecdd2be9c9dc11b095f5e36132117 differ diff --git a/.git1/objects/b4/6e152513503aba7fc407715437056e99a1cb16 b/.git1/objects/b4/6e152513503aba7fc407715437056e99a1cb16 new file mode 100644 index 0000000..d8900f9 Binary files /dev/null and b/.git1/objects/b4/6e152513503aba7fc407715437056e99a1cb16 differ diff --git a/.git1/objects/b5/b73c3c32159f26f4a166aea35a844754da405e b/.git1/objects/b5/b73c3c32159f26f4a166aea35a844754da405e new file mode 100644 index 0000000..d7d4390 Binary files /dev/null and b/.git1/objects/b5/b73c3c32159f26f4a166aea35a844754da405e differ diff --git a/.git1/objects/b8/63b5bd0690f5d72a8b460ecceb75d5537c4401 b/.git1/objects/b8/63b5bd0690f5d72a8b460ecceb75d5537c4401 new file mode 100644 index 0000000..6d08d50 Binary files /dev/null and b/.git1/objects/b8/63b5bd0690f5d72a8b460ecceb75d5537c4401 differ diff --git a/.git1/objects/b9/f44b28c90f4cdc58e7c7e0e8b8e79b373eab6e b/.git1/objects/b9/f44b28c90f4cdc58e7c7e0e8b8e79b373eab6e new file mode 100644 index 0000000..33e1b8a Binary files /dev/null and b/.git1/objects/b9/f44b28c90f4cdc58e7c7e0e8b8e79b373eab6e differ diff --git a/.git1/objects/ba/ccbcdc71530825e82d3a6f77047fc499d23fb4 b/.git1/objects/ba/ccbcdc71530825e82d3a6f77047fc499d23fb4 new file mode 100644 index 0000000..342f1ea Binary files /dev/null and b/.git1/objects/ba/ccbcdc71530825e82d3a6f77047fc499d23fb4 differ diff --git a/.git1/objects/bc/c15c9d0730e9589d3ead0f3e4ca6052a365838 b/.git1/objects/bc/c15c9d0730e9589d3ead0f3e4ca6052a365838 new file mode 100644 index 0000000..7d55551 Binary files /dev/null and b/.git1/objects/bc/c15c9d0730e9589d3ead0f3e4ca6052a365838 differ diff --git a/.git1/objects/bd/1e276f010d299d4578f49c48f924dbe44f3b1a b/.git1/objects/bd/1e276f010d299d4578f49c48f924dbe44f3b1a new file mode 100644 index 0000000..51ffa8e Binary files /dev/null and b/.git1/objects/bd/1e276f010d299d4578f49c48f924dbe44f3b1a differ diff --git a/.git1/objects/bd/f28fa579bbd0ff1b82bd796e57d6c87dcf1187 b/.git1/objects/bd/f28fa579bbd0ff1b82bd796e57d6c87dcf1187 new file mode 100644 index 0000000..9fde055 Binary files /dev/null and b/.git1/objects/bd/f28fa579bbd0ff1b82bd796e57d6c87dcf1187 differ diff --git a/.git1/objects/be/930080ce1f1ff615639e993fe7caa191bf3153 b/.git1/objects/be/930080ce1f1ff615639e993fe7caa191bf3153 new file mode 100644 index 0000000..655a2f4 Binary files /dev/null and b/.git1/objects/be/930080ce1f1ff615639e993fe7caa191bf3153 differ diff --git a/.git1/objects/bf/5a9a54f9db73a7b48e9fde22769e76fab1215a b/.git1/objects/bf/5a9a54f9db73a7b48e9fde22769e76fab1215a new file mode 100644 index 0000000..cf0e640 --- /dev/null +++ b/.git1/objects/bf/5a9a54f9db73a7b48e9fde22769e76fab1215a @@ -0,0 +1,2 @@ +x +!>`gх^ё( z.?OsZ.gT!萄J-!$Bռ6m-LHK ++;шR*ALzϽ8|{˽>sj] D ԿA@h?b \ No newline at end of file diff --git a/.git1/objects/bf/b406044743ac216401c7885f347533e9010f80 b/.git1/objects/bf/b406044743ac216401c7885f347533e9010f80 new file mode 100644 index 0000000..a73921e Binary files /dev/null and b/.git1/objects/bf/b406044743ac216401c7885f347533e9010f80 differ diff --git a/.git1/objects/c2/daa6489f8e7681baef7171b43cd0cba50fa7a0 b/.git1/objects/c2/daa6489f8e7681baef7171b43cd0cba50fa7a0 new file mode 100644 index 0000000..3f8857e Binary files /dev/null and b/.git1/objects/c2/daa6489f8e7681baef7171b43cd0cba50fa7a0 differ diff --git a/.git1/objects/c2/f301a04a9efd76ca4ee961b22b5ae5ff11e8d7 b/.git1/objects/c2/f301a04a9efd76ca4ee961b22b5ae5ff11e8d7 new file mode 100644 index 0000000..e6e0ca4 Binary files /dev/null and b/.git1/objects/c2/f301a04a9efd76ca4ee961b22b5ae5ff11e8d7 differ diff --git a/.git1/objects/c5/4c85f5eda17551f85fa14d6557ea641647f70a b/.git1/objects/c5/4c85f5eda17551f85fa14d6557ea641647f70a new file mode 100644 index 0000000..000045c Binary files /dev/null and b/.git1/objects/c5/4c85f5eda17551f85fa14d6557ea641647f70a differ diff --git a/.git1/objects/c5/6a98893e314efa4c48e594a49098bc114674b8 b/.git1/objects/c5/6a98893e314efa4c48e594a49098bc114674b8 new file mode 100644 index 0000000..b52df0c Binary files /dev/null and b/.git1/objects/c5/6a98893e314efa4c48e594a49098bc114674b8 differ diff --git a/.git1/objects/c8/1c3e288a5c916f07367410d15ab7d77d81f5ec b/.git1/objects/c8/1c3e288a5c916f07367410d15ab7d77d81f5ec new file mode 100644 index 0000000..b032ab6 Binary files /dev/null and b/.git1/objects/c8/1c3e288a5c916f07367410d15ab7d77d81f5ec differ diff --git a/.git1/objects/cc/7f8b178639d360db9a13f3b7fbe8331d79922a b/.git1/objects/cc/7f8b178639d360db9a13f3b7fbe8331d79922a new file mode 100644 index 0000000..abe4fdc Binary files /dev/null and b/.git1/objects/cc/7f8b178639d360db9a13f3b7fbe8331d79922a differ diff --git a/.git1/objects/cc/dc1b5ab2a1337418ac96a09f8fc9d4e6495fb4 b/.git1/objects/cc/dc1b5ab2a1337418ac96a09f8fc9d4e6495fb4 new file mode 100644 index 0000000..346de94 Binary files /dev/null and b/.git1/objects/cc/dc1b5ab2a1337418ac96a09f8fc9d4e6495fb4 differ diff --git a/.git1/objects/cd/9ee7b4f47684e5a68c2f6e570b0b4eda0bdfa8 b/.git1/objects/cd/9ee7b4f47684e5a68c2f6e570b0b4eda0bdfa8 new file mode 100644 index 0000000..7af810f Binary files /dev/null and b/.git1/objects/cd/9ee7b4f47684e5a68c2f6e570b0b4eda0bdfa8 differ diff --git a/.git1/objects/ce/26455afb401dbb64398c9bcb6a4e30133e7537 b/.git1/objects/ce/26455afb401dbb64398c9bcb6a4e30133e7537 new file mode 100644 index 0000000..b7f6b8c Binary files /dev/null and b/.git1/objects/ce/26455afb401dbb64398c9bcb6a4e30133e7537 differ diff --git a/.git1/objects/cf/16fc1d8e85df0260f88c73e34449e2fd424319 b/.git1/objects/cf/16fc1d8e85df0260f88c73e34449e2fd424319 new file mode 100644 index 0000000..4dcdc25 Binary files /dev/null and b/.git1/objects/cf/16fc1d8e85df0260f88c73e34449e2fd424319 differ diff --git a/.git1/objects/d2/af76d30cdf38229faa099f24bac9ee810ac24c b/.git1/objects/d2/af76d30cdf38229faa099f24bac9ee810ac24c new file mode 100644 index 0000000..1662054 Binary files /dev/null and b/.git1/objects/d2/af76d30cdf38229faa099f24bac9ee810ac24c differ diff --git a/.git1/objects/d3/5f62c5a8d310677d8434cee177545a6c3b4427 b/.git1/objects/d3/5f62c5a8d310677d8434cee177545a6c3b4427 new file mode 100644 index 0000000..966fe1f Binary files /dev/null and b/.git1/objects/d3/5f62c5a8d310677d8434cee177545a6c3b4427 differ diff --git a/.git1/objects/d5/35b6aa820b9a68864fbe3ec623d88025386477 b/.git1/objects/d5/35b6aa820b9a68864fbe3ec623d88025386477 new file mode 100644 index 0000000..4120ee8 Binary files /dev/null and b/.git1/objects/d5/35b6aa820b9a68864fbe3ec623d88025386477 differ diff --git a/.git1/objects/d6/6618e8eb2a7c4e2031828dfca19ec07be7a0cb b/.git1/objects/d6/6618e8eb2a7c4e2031828dfca19ec07be7a0cb new file mode 100644 index 0000000..878969e Binary files /dev/null and b/.git1/objects/d6/6618e8eb2a7c4e2031828dfca19ec07be7a0cb differ diff --git a/.git1/objects/d6/a2473c4abe425745b5c52845264aaa01ab2bc4 b/.git1/objects/d6/a2473c4abe425745b5c52845264aaa01ab2bc4 new file mode 100644 index 0000000..a25653d Binary files /dev/null and b/.git1/objects/d6/a2473c4abe425745b5c52845264aaa01ab2bc4 differ diff --git a/.git1/objects/d7/1c07ba75330ba1b5222819bc26d9ebc5548361 b/.git1/objects/d7/1c07ba75330ba1b5222819bc26d9ebc5548361 new file mode 100644 index 0000000..ef9135b Binary files /dev/null and b/.git1/objects/d7/1c07ba75330ba1b5222819bc26d9ebc5548361 differ diff --git a/.git1/objects/d9/910cd1c21a2ac7342b3454e15d1f3cb1318d47 b/.git1/objects/d9/910cd1c21a2ac7342b3454e15d1f3cb1318d47 new file mode 100644 index 0000000..016da2f Binary files /dev/null and b/.git1/objects/d9/910cd1c21a2ac7342b3454e15d1f3cb1318d47 differ diff --git a/.git1/objects/dc/95f190f4cf56600ea24880df82fabf8ad2a176 b/.git1/objects/dc/95f190f4cf56600ea24880df82fabf8ad2a176 new file mode 100644 index 0000000..415a4e9 Binary files /dev/null and b/.git1/objects/dc/95f190f4cf56600ea24880df82fabf8ad2a176 differ diff --git a/.git1/objects/df/1a5e3aff2ae9be6a1f1c602f2eeed72ca1b935 b/.git1/objects/df/1a5e3aff2ae9be6a1f1c602f2eeed72ca1b935 new file mode 100644 index 0000000..f03a037 Binary files /dev/null and b/.git1/objects/df/1a5e3aff2ae9be6a1f1c602f2eeed72ca1b935 differ diff --git a/.git1/objects/df/24e3298aa429ffd77c0618c1b55b04c8d8d522 b/.git1/objects/df/24e3298aa429ffd77c0618c1b55b04c8d8d522 new file mode 100644 index 0000000..957fe00 Binary files /dev/null and b/.git1/objects/df/24e3298aa429ffd77c0618c1b55b04c8d8d522 differ diff --git a/.git1/objects/e1/22a092ba215941b75c401211ec0b7970a43297 b/.git1/objects/e1/22a092ba215941b75c401211ec0b7970a43297 new file mode 100644 index 0000000..3b5dac3 Binary files /dev/null and b/.git1/objects/e1/22a092ba215941b75c401211ec0b7970a43297 differ diff --git a/.git1/objects/e2/6856f85905c87d01cf78602762bf3ba12f7051 b/.git1/objects/e2/6856f85905c87d01cf78602762bf3ba12f7051 new file mode 100644 index 0000000..1295000 Binary files /dev/null and b/.git1/objects/e2/6856f85905c87d01cf78602762bf3ba12f7051 differ diff --git a/.git1/objects/e2/82d7e688085951148180e0644de8ea84c33a1e b/.git1/objects/e2/82d7e688085951148180e0644de8ea84c33a1e new file mode 100644 index 0000000..24d4d39 Binary files /dev/null and b/.git1/objects/e2/82d7e688085951148180e0644de8ea84c33a1e differ diff --git a/.git1/objects/e4/7bf98159a3f8459302ccf9a7de9786c3ac4cf5 b/.git1/objects/e4/7bf98159a3f8459302ccf9a7de9786c3ac4cf5 new file mode 100644 index 0000000..bf7b848 Binary files /dev/null and b/.git1/objects/e4/7bf98159a3f8459302ccf9a7de9786c3ac4cf5 differ diff --git a/.git1/objects/e4/a69f79f3916f84500b31e16812cbf031720f9c b/.git1/objects/e4/a69f79f3916f84500b31e16812cbf031720f9c new file mode 100644 index 0000000..09b19a1 Binary files /dev/null and b/.git1/objects/e4/a69f79f3916f84500b31e16812cbf031720f9c differ diff --git a/.git1/objects/e6/b9da67e5667c933013aa9df2cb953b134c7dfe b/.git1/objects/e6/b9da67e5667c933013aa9df2cb953b134c7dfe new file mode 100644 index 0000000..8014c63 Binary files /dev/null and b/.git1/objects/e6/b9da67e5667c933013aa9df2cb953b134c7dfe differ diff --git a/.git1/objects/e6/ef2246ee6abc1ba2bf7e6aa6685a5c6e830ea8 b/.git1/objects/e6/ef2246ee6abc1ba2bf7e6aa6685a5c6e830ea8 new file mode 100644 index 0000000..30a673c Binary files /dev/null and b/.git1/objects/e6/ef2246ee6abc1ba2bf7e6aa6685a5c6e830ea8 differ diff --git a/.git1/objects/e7/4b5f4bc18a2a8d70aa7b1cd431c685f4ce7b71 b/.git1/objects/e7/4b5f4bc18a2a8d70aa7b1cd431c685f4ce7b71 new file mode 100644 index 0000000..aa9c36d Binary files /dev/null and b/.git1/objects/e7/4b5f4bc18a2a8d70aa7b1cd431c685f4ce7b71 differ diff --git a/.git1/objects/e7/fbd7d8e0e8f2a17b5aaac55cad4084db2e90a4 b/.git1/objects/e7/fbd7d8e0e8f2a17b5aaac55cad4084db2e90a4 new file mode 100644 index 0000000..ec90cc3 Binary files /dev/null and b/.git1/objects/e7/fbd7d8e0e8f2a17b5aaac55cad4084db2e90a4 differ diff --git a/.git1/objects/e8/ae35f9331f859848fa10e351bbd25ebd4a34a0 b/.git1/objects/e8/ae35f9331f859848fa10e351bbd25ebd4a34a0 new file mode 100644 index 0000000..bf31d41 Binary files /dev/null and b/.git1/objects/e8/ae35f9331f859848fa10e351bbd25ebd4a34a0 differ diff --git a/.git1/objects/e9/60a16d4910508a44eec45f866d59004baafb3e b/.git1/objects/e9/60a16d4910508a44eec45f866d59004baafb3e new file mode 100644 index 0000000..54007e2 Binary files /dev/null and b/.git1/objects/e9/60a16d4910508a44eec45f866d59004baafb3e differ diff --git a/.git1/objects/eb/081dff9d479fe94f0f8f9822e38cceeeb78029 b/.git1/objects/eb/081dff9d479fe94f0f8f9822e38cceeeb78029 new file mode 100644 index 0000000..467317f Binary files /dev/null and b/.git1/objects/eb/081dff9d479fe94f0f8f9822e38cceeeb78029 differ diff --git a/.git1/objects/ed/0f3304edf9dff8e373eb79b80ded9d9772c2db b/.git1/objects/ed/0f3304edf9dff8e373eb79b80ded9d9772c2db new file mode 100644 index 0000000..8c2e2fa Binary files /dev/null and b/.git1/objects/ed/0f3304edf9dff8e373eb79b80ded9d9772c2db differ diff --git a/.git1/objects/f0/4710704743cfa6380bde53b7dbd98890cf0bfa b/.git1/objects/f0/4710704743cfa6380bde53b7dbd98890cf0bfa new file mode 100644 index 0000000..fcae1cc --- /dev/null +++ b/.git1/objects/f0/4710704743cfa6380bde53b7dbd98890cf0bfa @@ -0,0 +1,4 @@ +xV]#EWyX:ZT|,Y lIdJ&MUىK~_P_D_DE\g7A:|LmHw{O:U};o7}#a|F@xRɢ> i0e/$V6(wpw::D渾]$3ỡ"l,v9k)f:j-VBڊɜR &Qw]b2u;@TsZeޥ/ hk~/yg7ﯾ!(>zӢqMU׊~w~yW5s +{6:EK*'k?wsލi/Y \ No newline at end of file diff --git a/.git1/objects/f4/9c46677509fa5462a24eeecb9acb719be4a1d0 b/.git1/objects/f4/9c46677509fa5462a24eeecb9acb719be4a1d0 new file mode 100644 index 0000000..255e0ce Binary files /dev/null and b/.git1/objects/f4/9c46677509fa5462a24eeecb9acb719be4a1d0 differ diff --git a/.git1/objects/f8/6c795ca64932d81c88b08435bdcafc74772f33 b/.git1/objects/f8/6c795ca64932d81c88b08435bdcafc74772f33 new file mode 100644 index 0000000..69db4d0 Binary files /dev/null and b/.git1/objects/f8/6c795ca64932d81c88b08435bdcafc74772f33 differ diff --git a/.git1/objects/f8/b12853cfc116de55c3129c863459af1b621879 b/.git1/objects/f8/b12853cfc116de55c3129c863459af1b621879 new file mode 100644 index 0000000..b9cd407 Binary files /dev/null and b/.git1/objects/f8/b12853cfc116de55c3129c863459af1b621879 differ diff --git a/.git1/objects/fa/cdf9238b2d4e6e796fce9ca239e58d8784d579 b/.git1/objects/fa/cdf9238b2d4e6e796fce9ca239e58d8784d579 new file mode 100644 index 0000000..7a6f6f1 Binary files /dev/null and b/.git1/objects/fa/cdf9238b2d4e6e796fce9ca239e58d8784d579 differ diff --git a/.git1/objects/fb/b2b1a083ededb7d1477ba1d71c756eff0d5d9a b/.git1/objects/fb/b2b1a083ededb7d1477ba1d71c756eff0d5d9a new file mode 100644 index 0000000..0e73705 Binary files /dev/null and b/.git1/objects/fb/b2b1a083ededb7d1477ba1d71c756eff0d5d9a differ diff --git a/.git1/objects/fd/63bc99fd3083eaa6bf786f64461be82ff3ad7b b/.git1/objects/fd/63bc99fd3083eaa6bf786f64461be82ff3ad7b new file mode 100644 index 0000000..e1ca1ca Binary files /dev/null and b/.git1/objects/fd/63bc99fd3083eaa6bf786f64461be82ff3ad7b differ diff --git a/.git1/objects/fe/452ec83eedfbfc71dab4f4300cfc144a2aa8fb b/.git1/objects/fe/452ec83eedfbfc71dab4f4300cfc144a2aa8fb new file mode 100644 index 0000000..722b362 Binary files /dev/null and b/.git1/objects/fe/452ec83eedfbfc71dab4f4300cfc144a2aa8fb differ diff --git a/.git1/objects/ff/61cb656ddb72aa1f6fc2059daa255228fef054 b/.git1/objects/ff/61cb656ddb72aa1f6fc2059daa255228fef054 new file mode 100644 index 0000000..1b2b170 Binary files /dev/null and b/.git1/objects/ff/61cb656ddb72aa1f6fc2059daa255228fef054 differ diff --git a/.git1/objects/pack/pack-3e0a0c3f888d6463c6753cca8848a88918218405.idx b/.git1/objects/pack/pack-3e0a0c3f888d6463c6753cca8848a88918218405.idx new file mode 100644 index 0000000..1d9714c Binary files /dev/null and b/.git1/objects/pack/pack-3e0a0c3f888d6463c6753cca8848a88918218405.idx differ diff --git a/.git1/objects/pack/pack-3e0a0c3f888d6463c6753cca8848a88918218405.pack b/.git1/objects/pack/pack-3e0a0c3f888d6463c6753cca8848a88918218405.pack new file mode 100644 index 0000000..57406ff Binary files /dev/null and b/.git1/objects/pack/pack-3e0a0c3f888d6463c6753cca8848a88918218405.pack differ diff --git a/.git1/objects/pack/pack-b303607408af8a3c6a8bc21e704287ee08311ef8.idx b/.git1/objects/pack/pack-b303607408af8a3c6a8bc21e704287ee08311ef8.idx new file mode 100644 index 0000000..c351563 Binary files /dev/null and b/.git1/objects/pack/pack-b303607408af8a3c6a8bc21e704287ee08311ef8.idx differ diff --git a/.git1/objects/pack/pack-b303607408af8a3c6a8bc21e704287ee08311ef8.pack b/.git1/objects/pack/pack-b303607408af8a3c6a8bc21e704287ee08311ef8.pack new file mode 100644 index 0000000..49c4fd6 Binary files /dev/null and b/.git1/objects/pack/pack-b303607408af8a3c6a8bc21e704287ee08311ef8.pack differ diff --git a/.git1/objects/pack/pack-e8c827e0977841296de196bfc72d74f94ffefa47.idx b/.git1/objects/pack/pack-e8c827e0977841296de196bfc72d74f94ffefa47.idx new file mode 100644 index 0000000..f8e7b25 Binary files /dev/null and b/.git1/objects/pack/pack-e8c827e0977841296de196bfc72d74f94ffefa47.idx differ diff --git a/.git1/objects/pack/pack-e8c827e0977841296de196bfc72d74f94ffefa47.pack b/.git1/objects/pack/pack-e8c827e0977841296de196bfc72d74f94ffefa47.pack new file mode 100644 index 0000000..3b5539c Binary files /dev/null and b/.git1/objects/pack/pack-e8c827e0977841296de196bfc72d74f94ffefa47.pack differ diff --git a/.git1/packed-refs b/.git1/packed-refs new file mode 100644 index 0000000..ac212c2 --- /dev/null +++ b/.git1/packed-refs @@ -0,0 +1,3 @@ +# pack-refs with: peeled +7d0d51792b97bed663b400172ed408b14ad20b3b refs/remotes/origin/ljh +2b243c95aa2827e1a76ef1a56b1f202e032878bb refs/remotes/origin/main diff --git a/.git1/refs/heads/ljh b/.git1/refs/heads/ljh new file mode 100644 index 0000000..5bacd48 --- /dev/null +++ b/.git1/refs/heads/ljh @@ -0,0 +1 @@ +4fb130a2eb11993c23806615662692d18af4ec88 diff --git a/.git1/refs/heads/main b/.git1/refs/heads/main new file mode 100644 index 0000000..cc02580 --- /dev/null +++ b/.git1/refs/heads/main @@ -0,0 +1 @@ +04aff3093f6cca41a9be5bbd1a52ee15a88fb318 diff --git a/.git1/refs/remotes/origin/ljh b/.git1/refs/remotes/origin/ljh new file mode 100644 index 0000000..5bacd48 --- /dev/null +++ b/.git1/refs/remotes/origin/ljh @@ -0,0 +1 @@ +4fb130a2eb11993c23806615662692d18af4ec88 diff --git a/.git1/refs/remotes/origin/main b/.git1/refs/remotes/origin/main new file mode 100644 index 0000000..cc02580 --- /dev/null +++ b/.git1/refs/remotes/origin/main @@ -0,0 +1 @@ +04aff3093f6cca41a9be5bbd1a52ee15a88fb318 diff --git a/.project b/.project new file mode 100644 index 0000000..571655c --- /dev/null +++ b/.project @@ -0,0 +1,28 @@ + + + com.connor.ly.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..540b604 --- /dev/null +++ b/META-INF/MANIFEST.MF @@ -0,0 +1,54 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Performancemanagement +Bundle-SymbolicName: com.connor.ly.plm;singleton:=true +Bundle-Version: 1.0.0 +Bundle-Vendor: LANGTECH +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + com.teamcenter.rac.aifrcp;bundle-version="13000.1.0", + com.teamcenter.rac.tcapps;bundle-version="13000.1.0", + com.teamcenter.rac.ui;bundle-version="13000.1.0", + com.teamcenter.rac.ui.views;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.kernel;bundle-version="13000.1.0", + com.teamcenter.rac.external;bundle-version="13000.1.0", + TcSoaCoreRac;bundle-version="13000.1.0", + k.util;bundle-version="1.0.0" +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Automatic-Module-Name: com.langtech.plm.performancemanagement +Bundle-ClassPath: sqlServerLib/sqljdbc4.jar, + ., + sqlServerLib/swingx-1.6.1.jar, + sqlServerLib/aspose-words-17.4.0-jdk16.jar, + poi_lib/aspose-words-17.4.0-jdk16.jar, + poi_lib/commons-collections4-4.1.jar, + poi_lib/poi-3.17.jar, + poi_lib/poi-examples-3.17.jar, + poi_lib/poi-excelant-3.17.jar, + poi_lib/poi-ooxml-3.17.jar, + poi_lib/poi-ooxml-schemas-3.17.jar, + poi_lib/poi-scratchpad-3.17.jar, + poi_lib/xmlbeans-2.6.0.jar, + axis2_lib/axiom-api-1.2.13.jar, + axis2_lib/axis2-kernel-1.6.2.jar, + axis2_lib/json-lib-2.2.2-jdk15.jar, + axis2_lib/json-lib-2.2.3-jdk13.jar, + axis2_lib/commons-logging-1.1.jar, + axis2_lib/commons-collections-3.2.jar, + axis2_lib/commons-beanutils-1.7.0.jar, + axis2_lib/commons-lang-2.4.jar, + axis2_lib/ezmorph-1.0.4.jar, + axis2_lib/jdom.jar, + axis2_lib/axiom-impl-1.2.13.jar, + axis2_lib/wsdl4j-1.6.2.jar, + axis2_lib/XmlSchema-1.4.7.jar, + axis2_lib/neethi-3.0.2.jar, + axis2_lib/axis2-adb-1.6.2.jar, + axis2_lib/axis2-transport-local-1.6.2.jar, + axis2_lib/axis2-transport-http-1.6.2.jar, + axis2_lib/commons-httpclient-3.1.jar, + axis2_lib/httpcore-4.0.jar, + axis2_lib/commons-codec-1.3.jar +Import-Package: com.teamcenter.services.loose.core._2011_06 diff --git a/README.md b/README.md new file mode 100644 index 0000000..69ccaa4 --- /dev/null +++ b/README.md @@ -0,0 +1,132 @@ +功能描述 + +# 操作触发 + +选中项目文件夹,点击“绩效报表”菜单,输出该项目的绩效报表(Excel) + +# 首选项配置 + +## ld_billboards_uid + +```text +单值:报表模板的puid +``` + + + +## ld_postCoefficient + +```text +多值,描述岗位组对应的岗位系数,形式: +岗位组=岗位系数 +绘图组=1 +三维组=1.05 + +``` + + + +## ld_taskNature + +``` +多值,描述任务性质对应的任务系数,形式: +任务性质=任务系数 +全新=10 +可复制修改=5 +临时=2.5 +EC=2.5 + +``` + + + +## ld_taskDifficulty + +``` +多值,描述任务难度对应的难度系数,形式: +任务难度=难度系数 +子项目=0.1 +简单=1 +一般=1.25 +较难=1.5 +很难=2 +``` + + + +## ld_urgency + +``` +多值,描述紧急度对应的紧急系数,形式: +紧急度=紧急系数 +一般=1 +紧急=1.25 +超紧急=1.5 + +``` + + + +## ld_overtime + +``` +多值,超时扣分配置,形式: +严重程度:天数区间:扣分比例,其中"()"代表开区间,"[]"代表闭区间 +如: +一般:(0,1]:0.2 +严重:(1,2]:0.33 +超严重:(2,3]:0.5 +未定义:(3,1000):0.6 +``` + + + +## ld_processReview + +``` +多值,描述流程信息配置,用户获取特定流程节点的分派人和处理人,形式: +新品任务项名称=流程名称:审核节点名称 +铸件资料=001铸件资料流程:铸件资料审核 +``` + + + +## ld_requestTime + +``` +多值,描述任务要求完成时间对应的公式,形式: +新品任务项名称=公式,E和F必须放在运算符前面,例如 +铸件资料=E-10 +PPAP文件=F+1 +其中,E代表流程发起时间,F代表工艺程序结束时间(数据库表维护) + +``` + + + +## ld_sqlserver + +``` +多值,描述sqlserver数据库连接信息 +第一行:数据库用户名 +第二行:数据库密码 +第三行:登录url +第四行:驱动 +第五行:表名 + +infodba +infodba +jdbc:microsoft:sqlserver://10.10.22.39:1433;DatabaseName=TC13 +com.microsoft.jdbc.sqlserver.SQLServerDriver +TASK_REQUIREMENT +``` + + + +## Connor_JXFolder + +``` +多值,描述现有的项目归档文件夹与绩效管理要求的任务包对应,形式: +任务包名称=一级文件夹名称/二级文件夹名称/三级文件夹名称/……. +``` + diff --git a/axis2_lib/XmlSchema-1.4.7.jar b/axis2_lib/XmlSchema-1.4.7.jar new file mode 100644 index 0000000..79251c6 Binary files /dev/null and b/axis2_lib/XmlSchema-1.4.7.jar differ diff --git a/axis2_lib/axiom-api-1.2.13.jar b/axis2_lib/axiom-api-1.2.13.jar new file mode 100644 index 0000000..84cb42c Binary files /dev/null and b/axis2_lib/axiom-api-1.2.13.jar differ diff --git a/axis2_lib/axiom-impl-1.2.13.jar b/axis2_lib/axiom-impl-1.2.13.jar new file mode 100644 index 0000000..a959b28 Binary files /dev/null and b/axis2_lib/axiom-impl-1.2.13.jar differ diff --git a/axis2_lib/axis2-adb-1.6.2.jar b/axis2_lib/axis2-adb-1.6.2.jar new file mode 100644 index 0000000..6234fdb Binary files /dev/null and b/axis2_lib/axis2-adb-1.6.2.jar differ diff --git a/axis2_lib/axis2-kernel-1.6.2.jar b/axis2_lib/axis2-kernel-1.6.2.jar new file mode 100644 index 0000000..3ae5f7a Binary files /dev/null and b/axis2_lib/axis2-kernel-1.6.2.jar differ diff --git a/axis2_lib/axis2-transport-http-1.6.2.jar b/axis2_lib/axis2-transport-http-1.6.2.jar new file mode 100644 index 0000000..b1dad78 Binary files /dev/null and b/axis2_lib/axis2-transport-http-1.6.2.jar differ diff --git a/axis2_lib/axis2-transport-local-1.6.2.jar b/axis2_lib/axis2-transport-local-1.6.2.jar new file mode 100644 index 0000000..34a7073 Binary files /dev/null and b/axis2_lib/axis2-transport-local-1.6.2.jar differ diff --git a/axis2_lib/commons-beanutils-1.7.0.jar b/axis2_lib/commons-beanutils-1.7.0.jar new file mode 100644 index 0000000..b1b89c9 Binary files /dev/null and b/axis2_lib/commons-beanutils-1.7.0.jar differ diff --git a/axis2_lib/commons-codec-1.3.jar b/axis2_lib/commons-codec-1.3.jar new file mode 100644 index 0000000..957b675 Binary files /dev/null and b/axis2_lib/commons-codec-1.3.jar differ diff --git a/axis2_lib/commons-collections-3.2.jar b/axis2_lib/commons-collections-3.2.jar new file mode 100644 index 0000000..75580be Binary files /dev/null and b/axis2_lib/commons-collections-3.2.jar differ diff --git a/axis2_lib/commons-httpclient-3.1.jar b/axis2_lib/commons-httpclient-3.1.jar new file mode 100644 index 0000000..7c59774 Binary files /dev/null and b/axis2_lib/commons-httpclient-3.1.jar differ diff --git a/axis2_lib/commons-lang-2.4.jar b/axis2_lib/commons-lang-2.4.jar new file mode 100644 index 0000000..532939e Binary files /dev/null and b/axis2_lib/commons-lang-2.4.jar differ diff --git a/axis2_lib/commons-logging-1.1.jar b/axis2_lib/commons-logging-1.1.jar new file mode 100644 index 0000000..2ff9bbd Binary files /dev/null and b/axis2_lib/commons-logging-1.1.jar differ diff --git a/axis2_lib/ezmorph-1.0.4.jar b/axis2_lib/ezmorph-1.0.4.jar new file mode 100644 index 0000000..7625af6 Binary files /dev/null and b/axis2_lib/ezmorph-1.0.4.jar differ diff --git a/axis2_lib/httpcore-4.0.jar b/axis2_lib/httpcore-4.0.jar new file mode 100644 index 0000000..37eb7d4 Binary files /dev/null and b/axis2_lib/httpcore-4.0.jar differ diff --git a/axis2_lib/jdom.jar b/axis2_lib/jdom.jar new file mode 100644 index 0000000..65a1b3f Binary files /dev/null and b/axis2_lib/jdom.jar differ diff --git a/axis2_lib/json-lib-2.2.2-jdk15.jar b/axis2_lib/json-lib-2.2.2-jdk15.jar new file mode 100644 index 0000000..27e7c7c Binary files /dev/null and b/axis2_lib/json-lib-2.2.2-jdk15.jar differ diff --git a/axis2_lib/json-lib-2.2.3-jdk13.jar b/axis2_lib/json-lib-2.2.3-jdk13.jar new file mode 100644 index 0000000..a6513db Binary files /dev/null and b/axis2_lib/json-lib-2.2.3-jdk13.jar differ diff --git a/axis2_lib/neethi-3.0.2.jar b/axis2_lib/neethi-3.0.2.jar new file mode 100644 index 0000000..383efde Binary files /dev/null and b/axis2_lib/neethi-3.0.2.jar differ diff --git a/axis2_lib/wsdl4j-1.6.2.jar b/axis2_lib/wsdl4j-1.6.2.jar new file mode 100644 index 0000000..b9ffc36 Binary files /dev/null and b/axis2_lib/wsdl4j-1.6.2.jar differ diff --git a/bin/com/langtech/plm/batchRename/BatchRenameDialog.class b/bin/com/langtech/plm/batchRename/BatchRenameDialog.class new file mode 100644 index 0000000..f5f3854 Binary files /dev/null and b/bin/com/langtech/plm/batchRename/BatchRenameDialog.class differ diff --git a/bin/com/langtech/plm/batchRename/BatchRenameHandler.class b/bin/com/langtech/plm/batchRename/BatchRenameHandler.class new file mode 100644 index 0000000..4afb8ce Binary files /dev/null and b/bin/com/langtech/plm/batchRename/BatchRenameHandler.class differ diff --git a/bin/com/langtech/plm/createProjectStruct/CheckBoxTreeCellRenderer.class b/bin/com/langtech/plm/createProjectStruct/CheckBoxTreeCellRenderer.class new file mode 100644 index 0000000..11015a3 Binary files /dev/null and b/bin/com/langtech/plm/createProjectStruct/CheckBoxTreeCellRenderer.class differ diff --git a/bin/com/langtech/plm/createProjectStruct/CheckBoxTreeLabel.class b/bin/com/langtech/plm/createProjectStruct/CheckBoxTreeLabel.class new file mode 100644 index 0000000..42a1b26 Binary files /dev/null and b/bin/com/langtech/plm/createProjectStruct/CheckBoxTreeLabel.class differ diff --git a/bin/com/langtech/plm/createProjectStruct/CheckBoxTreeNode.class b/bin/com/langtech/plm/createProjectStruct/CheckBoxTreeNode.class new file mode 100644 index 0000000..032f306 Binary files /dev/null and b/bin/com/langtech/plm/createProjectStruct/CheckBoxTreeNode.class differ diff --git a/bin/com/langtech/plm/createProjectStruct/CheckBoxTreeNodeSelectionListener.class b/bin/com/langtech/plm/createProjectStruct/CheckBoxTreeNodeSelectionListener.class new file mode 100644 index 0000000..3201eaa Binary files /dev/null and b/bin/com/langtech/plm/createProjectStruct/CheckBoxTreeNodeSelectionListener.class differ diff --git a/bin/com/langtech/plm/createProjectStruct/CreateProjectStructDialog.class b/bin/com/langtech/plm/createProjectStruct/CreateProjectStructDialog.class new file mode 100644 index 0000000..899f273 Binary files /dev/null and b/bin/com/langtech/plm/createProjectStruct/CreateProjectStructDialog.class differ diff --git a/bin/com/langtech/plm/createProjectStruct/CreateProjectStructHandler.class b/bin/com/langtech/plm/createProjectStruct/CreateProjectStructHandler.class new file mode 100644 index 0000000..19be34c Binary files /dev/null and b/bin/com/langtech/plm/createProjectStruct/CreateProjectStructHandler.class differ diff --git a/bin/com/langtech/plm/createProjectStruct/KUtil.class b/bin/com/langtech/plm/createProjectStruct/KUtil.class new file mode 100644 index 0000000..821d635 Binary files /dev/null and b/bin/com/langtech/plm/createProjectStruct/KUtil.class differ diff --git a/bin/com/langtech/plm/mpart/CheckHeaderCellRenderer$1.class b/bin/com/langtech/plm/mpart/CheckHeaderCellRenderer$1.class new file mode 100644 index 0000000..e5d7db3 Binary files /dev/null and b/bin/com/langtech/plm/mpart/CheckHeaderCellRenderer$1.class differ diff --git a/bin/com/langtech/plm/mpart/CheckHeaderCellRenderer.class b/bin/com/langtech/plm/mpart/CheckHeaderCellRenderer.class new file mode 100644 index 0000000..97ffa78 Binary files /dev/null and b/bin/com/langtech/plm/mpart/CheckHeaderCellRenderer.class differ diff --git a/bin/com/langtech/plm/mpart/ChoosePartDialog.class b/bin/com/langtech/plm/mpart/ChoosePartDialog.class new file mode 100644 index 0000000..14b88f8 Binary files /dev/null and b/bin/com/langtech/plm/mpart/ChoosePartDialog.class differ diff --git a/bin/com/langtech/plm/mpart/DialogFrame$1.class b/bin/com/langtech/plm/mpart/DialogFrame$1.class new file mode 100644 index 0000000..2a63d6a Binary files /dev/null and b/bin/com/langtech/plm/mpart/DialogFrame$1.class differ diff --git a/bin/com/langtech/plm/mpart/DialogFrame.class b/bin/com/langtech/plm/mpart/DialogFrame.class new file mode 100644 index 0000000..2e14d07 Binary files /dev/null and b/bin/com/langtech/plm/mpart/DialogFrame.class differ diff --git a/bin/com/langtech/plm/mpart/MainFrame$1$1.class b/bin/com/langtech/plm/mpart/MainFrame$1$1.class new file mode 100644 index 0000000..f73af31 Binary files /dev/null and b/bin/com/langtech/plm/mpart/MainFrame$1$1.class differ diff --git a/bin/com/langtech/plm/mpart/MainFrame$1.class b/bin/com/langtech/plm/mpart/MainFrame$1.class new file mode 100644 index 0000000..769e77a Binary files /dev/null and b/bin/com/langtech/plm/mpart/MainFrame$1.class differ diff --git a/bin/com/langtech/plm/mpart/MainFrame.class b/bin/com/langtech/plm/mpart/MainFrame.class new file mode 100644 index 0000000..b7ff4a6 Binary files /dev/null and b/bin/com/langtech/plm/mpart/MainFrame.class differ diff --git a/bin/com/langtech/plm/mpart/MpartDialog.class b/bin/com/langtech/plm/mpart/MpartDialog.class new file mode 100644 index 0000000..ef2dbbb Binary files /dev/null and b/bin/com/langtech/plm/mpart/MpartDialog.class differ diff --git a/bin/com/langtech/plm/mpart/MpartHandler.class b/bin/com/langtech/plm/mpart/MpartHandler.class new file mode 100644 index 0000000..50635e7 Binary files /dev/null and b/bin/com/langtech/plm/mpart/MpartHandler.class differ diff --git a/bin/com/langtech/plm/mpart/TableCellCheckboxRenderer.class b/bin/com/langtech/plm/mpart/TableCellCheckboxRenderer.class new file mode 100644 index 0000000..0a0d191 Binary files /dev/null and b/bin/com/langtech/plm/mpart/TableCellCheckboxRenderer.class differ diff --git a/bin/com/langtech/plm/synchronize/SynchronizeDialog.class b/bin/com/langtech/plm/synchronize/SynchronizeDialog.class new file mode 100644 index 0000000..bb63121 Binary files /dev/null and b/bin/com/langtech/plm/synchronize/SynchronizeDialog.class differ diff --git a/bin/com/langtech/plm/synchronize/SynchronizeHandler.class b/bin/com/langtech/plm/synchronize/SynchronizeHandler.class new file mode 100644 index 0000000..a69997e Binary files /dev/null and b/bin/com/langtech/plm/synchronize/SynchronizeHandler.class differ diff --git a/bin/com/langtech/plm/template/TemplateDialog.class b/bin/com/langtech/plm/template/TemplateDialog.class new file mode 100644 index 0000000..4907859 Binary files /dev/null and b/bin/com/langtech/plm/template/TemplateDialog.class differ diff --git a/bin/com/langtech/plm/template/TemplateHandler.class b/bin/com/langtech/plm/template/TemplateHandler.class new file mode 100644 index 0000000..4db69cf Binary files /dev/null and b/bin/com/langtech/plm/template/TemplateHandler.class differ diff --git a/bin/com/langtech/plm/tqsx/Activator.class b/bin/com/langtech/plm/tqsx/Activator.class new file mode 100644 index 0000000..e3dd115 Binary files /dev/null and b/bin/com/langtech/plm/tqsx/Activator.class differ diff --git a/bin/com/langtech/plm/tqsx/DateUtil$FormatEnum.class b/bin/com/langtech/plm/tqsx/DateUtil$FormatEnum.class new file mode 100644 index 0000000..571f34a Binary files /dev/null and b/bin/com/langtech/plm/tqsx/DateUtil$FormatEnum.class differ diff --git a/bin/com/langtech/plm/tqsx/DateUtil.class b/bin/com/langtech/plm/tqsx/DateUtil.class new file mode 100644 index 0000000..3488e5c Binary files /dev/null and b/bin/com/langtech/plm/tqsx/DateUtil.class differ diff --git a/bin/com/langtech/plm/tqsx/KAction.class b/bin/com/langtech/plm/tqsx/KAction.class new file mode 100644 index 0000000..8073dff Binary files /dev/null and b/bin/com/langtech/plm/tqsx/KAction.class differ diff --git a/bin/com/langtech/plm/tqsx/KCommand.class b/bin/com/langtech/plm/tqsx/KCommand.class new file mode 100644 index 0000000..56f8d9e Binary files /dev/null and b/bin/com/langtech/plm/tqsx/KCommand.class differ diff --git a/bin/com/langtech/plm/tqsx/KHandler.class b/bin/com/langtech/plm/tqsx/KHandler.class new file mode 100644 index 0000000..aa152e8 Binary files /dev/null and b/bin/com/langtech/plm/tqsx/KHandler.class differ diff --git a/bin/com/langtech/plm/tqsx/KLocale.class b/bin/com/langtech/plm/tqsx/KLocale.class new file mode 100644 index 0000000..e7cffad Binary files /dev/null and b/bin/com/langtech/plm/tqsx/KLocale.class differ diff --git a/bin/com/langtech/plm/tqsx/KOperation.class b/bin/com/langtech/plm/tqsx/KOperation.class new file mode 100644 index 0000000..1bb2f1a Binary files /dev/null and b/bin/com/langtech/plm/tqsx/KOperation.class differ diff --git a/bin/com/langtech/plm/tqsx/KOperation2.class b/bin/com/langtech/plm/tqsx/KOperation2.class new file mode 100644 index 0000000..ba62fee Binary files /dev/null and b/bin/com/langtech/plm/tqsx/KOperation2.class differ diff --git a/bin/com/langtech/plm/tqsx/KUtil.class b/bin/com/langtech/plm/tqsx/KUtil.class new file mode 100644 index 0000000..3850b97 Binary files /dev/null and b/bin/com/langtech/plm/tqsx/KUtil.class differ diff --git a/bin/com/langtech/plm/tqsx/PropertyToWordOrExcelCommand.class b/bin/com/langtech/plm/tqsx/PropertyToWordOrExcelCommand.class new file mode 100644 index 0000000..340889d Binary files /dev/null and b/bin/com/langtech/plm/tqsx/PropertyToWordOrExcelCommand.class differ diff --git a/bin/com/langtech/plm/tqsx/PropertyToWordOrExcelOperation.class b/bin/com/langtech/plm/tqsx/PropertyToWordOrExcelOperation.class new file mode 100644 index 0000000..fa91e48 Binary files /dev/null and b/bin/com/langtech/plm/tqsx/PropertyToWordOrExcelOperation.class differ diff --git a/bin/com/langtech/plm/tqsx/WordUtils.class b/bin/com/langtech/plm/tqsx/WordUtils.class new file mode 100644 index 0000000..b83e640 Binary files /dev/null and b/bin/com/langtech/plm/tqsx/WordUtils.class differ diff --git a/bin/com/teamcenter/rac/stylesheet/stylesheet_user.properties b/bin/com/teamcenter/rac/stylesheet/stylesheet_user.properties new file mode 100644 index 0000000..93ef268 --- /dev/null +++ b/bin/com/teamcenter/rac/stylesheet/stylesheet_user.properties @@ -0,0 +1 @@ +LD6_NewProdForm.FORMJAVARENDERING=com.langtech.plm.form.LD6_NewProdForm \ No newline at end of file diff --git a/build.properties b/build.properties new file mode 100644 index 0000000..5eeeda5 --- /dev/null +++ b/build.properties @@ -0,0 +1,38 @@ +source.. = src/ +output.. = bin/ +bin.includes = plugin.xml,\ + META-INF/,\ + .,\ + icons/,\ + sqlServerLib/sqljdbc4.jar,\ + sqlServerLib/swingx-1.6.1.jar,\ + sqlServerLib/aspose-words-17.4.0-jdk16.jar,\ + poi_lib/aspose-words-17.4.0-jdk16.jar,\ + poi_lib/commons-collections4-4.1.jar,\ + poi_lib/poi-3.17.jar,\ + poi_lib/poi-examples-3.17.jar,\ + poi_lib/poi-excelant-3.17.jar,\ + poi_lib/poi-ooxml-3.17.jar,\ + poi_lib/poi-ooxml-schemas-3.17.jar,\ + poi_lib/poi-scratchpad-3.17.jar,\ + poi_lib/xmlbeans-2.6.0.jar,\ + axis2_lib/axiom-api-1.2.13.jar,\ + axis2_lib/axis2-kernel-1.6.2.jar,\ + axis2_lib/json-lib-2.2.2-jdk15.jar,\ + axis2_lib/json-lib-2.2.3-jdk13.jar,\ + axis2_lib/commons-logging-1.1.jar,\ + axis2_lib/commons-collections-3.2.jar,\ + axis2_lib/commons-beanutils-1.7.0.jar,\ + axis2_lib/commons-lang-2.4.jar,\ + axis2_lib/ezmorph-1.0.4.jar,\ + axis2_lib/jdom.jar,\ + axis2_lib/axiom-impl-1.2.13.jar,\ + axis2_lib/wsdl4j-1.6.2.jar,\ + axis2_lib/XmlSchema-1.4.7.jar,\ + axis2_lib/neethi-3.0.2.jar,\ + axis2_lib/axis2-adb-1.6.2.jar,\ + axis2_lib/axis2-transport-local-1.6.2.jar,\ + axis2_lib/axis2-transport-http-1.6.2.jar,\ + axis2_lib/commons-httpclient-3.1.jar,\ + axis2_lib/httpcore-4.0.jar,\ + axis2_lib/commons-codec-1.3.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/plugin.xml b/plugin.xml new file mode 100644 index 0000000..96ef307 --- /dev/null +++ b/plugin.xml @@ -0,0 +1,240 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/poi_lib/aspose-words-17.4.0-jdk16.jar b/poi_lib/aspose-words-17.4.0-jdk16.jar new file mode 100644 index 0000000..e8bd66c Binary files /dev/null and b/poi_lib/aspose-words-17.4.0-jdk16.jar differ diff --git a/poi_lib/commons-collections4-4.1.jar b/poi_lib/commons-collections4-4.1.jar new file mode 100644 index 0000000..43a9413 Binary files /dev/null and b/poi_lib/commons-collections4-4.1.jar differ diff --git a/poi_lib/poi-3.17.jar b/poi_lib/poi-3.17.jar new file mode 100644 index 0000000..353ce76 Binary files /dev/null and b/poi_lib/poi-3.17.jar differ diff --git a/poi_lib/poi-examples-3.17.jar b/poi_lib/poi-examples-3.17.jar new file mode 100644 index 0000000..a923b04 Binary files /dev/null and b/poi_lib/poi-examples-3.17.jar differ diff --git a/poi_lib/poi-excelant-3.17.jar b/poi_lib/poi-excelant-3.17.jar new file mode 100644 index 0000000..da9f5ed Binary files /dev/null and b/poi_lib/poi-excelant-3.17.jar differ diff --git a/poi_lib/poi-ooxml-3.17.jar b/poi_lib/poi-ooxml-3.17.jar new file mode 100644 index 0000000..68086e8 Binary files /dev/null and b/poi_lib/poi-ooxml-3.17.jar differ diff --git a/poi_lib/poi-ooxml-schemas-3.17.jar b/poi_lib/poi-ooxml-schemas-3.17.jar new file mode 100644 index 0000000..2e9b3e7 Binary files /dev/null and b/poi_lib/poi-ooxml-schemas-3.17.jar differ diff --git a/poi_lib/poi-scratchpad-3.17.jar b/poi_lib/poi-scratchpad-3.17.jar new file mode 100644 index 0000000..12ba1f1 Binary files /dev/null and b/poi_lib/poi-scratchpad-3.17.jar differ diff --git a/poi_lib/xmlbeans-2.6.0.jar b/poi_lib/xmlbeans-2.6.0.jar new file mode 100644 index 0000000..d1b6627 Binary files /dev/null and b/poi_lib/xmlbeans-2.6.0.jar differ diff --git a/sqlServerLib/poi-3.7-20101029.jar b/sqlServerLib/poi-3.7-20101029.jar new file mode 100644 index 0000000..a08d953 Binary files /dev/null and b/sqlServerLib/poi-3.7-20101029.jar differ diff --git a/sqlServerLib/poi-4.1.2.jar b/sqlServerLib/poi-4.1.2.jar new file mode 100644 index 0000000..3803353 Binary files /dev/null and b/sqlServerLib/poi-4.1.2.jar differ diff --git a/sqlServerLib/poi-examples-3.7-20101029.jar b/sqlServerLib/poi-examples-3.7-20101029.jar new file mode 100644 index 0000000..914243d Binary files /dev/null and b/sqlServerLib/poi-examples-3.7-20101029.jar differ diff --git a/sqlServerLib/poi-ooxml-3.7-20101029.jar b/sqlServerLib/poi-ooxml-3.7-20101029.jar new file mode 100644 index 0000000..5f36eb4 Binary files /dev/null and b/sqlServerLib/poi-ooxml-3.7-20101029.jar differ diff --git a/sqlServerLib/poi-ooxml-schemas-3.7-20101029.jar b/sqlServerLib/poi-ooxml-schemas-3.7-20101029.jar new file mode 100644 index 0000000..82282b5 Binary files /dev/null and b/sqlServerLib/poi-ooxml-schemas-3.7-20101029.jar differ diff --git a/sqlServerLib/sqljdbc4.jar b/sqlServerLib/sqljdbc4.jar new file mode 100644 index 0000000..d6b7f6d Binary files /dev/null and b/sqlServerLib/sqljdbc4.jar differ diff --git a/sqlServerLib/swingx-1.6.1.jar b/sqlServerLib/swingx-1.6.1.jar new file mode 100644 index 0000000..b0bcc87 Binary files /dev/null and b/sqlServerLib/swingx-1.6.1.jar differ diff --git a/src/com/langtech/plm/batchRename/BatchRenameDialog.java b/src/com/langtech/plm/batchRename/BatchRenameDialog.java new file mode 100644 index 0000000..f3c4838 --- /dev/null +++ b/src/com/langtech/plm/batchRename/BatchRenameDialog.java @@ -0,0 +1,224 @@ +package com.langtech.plm.batchRename; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.Map.Entry; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.border.EmptyBorder; +import javax.swing.table.DefaultTableModel; + +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.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +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 BatchRenameDialog extends JFrame implements ActionListener { + + private TCSession session; + protected DefaultTableModel tm_part; + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + private TCComponentScheduleTask task; + private JTextField find = new JTextField(); + private JTextField replace = new JTextField(); + private JButton okButton = new JButton("ȷ"); + private JButton concelButton = new JButton("ȡ"); + HashMap map; + HashMap objectMap = new HashMap(); + + public BatchRenameDialog(TCSession session, TCComponentScheduleTask task) throws TCException { + // TODO Auto-generated constructor stub + this.session = session; + this.task = task; + + initUI(); + } + + private void initUI() { + // TODO Auto-generated method stub + try { + find.setPreferredSize(new Dimension(200,30)); + replace.setPreferredSize(new Dimension(200,30)); + this.setTitle("޸ʱ"); + this.setLayout(new BorderLayout()); + + JPanel topPanel = getTopPanel(); + + JPanel btnPanel = getBtnPanel(); + + this.add(topPanel, BorderLayout.NORTH); + // this.add(pane,BorderLayout.CENTER); + this.add(btnPanel, BorderLayout.SOUTH); + this.setPreferredSize(new Dimension(450, 200)); + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); // ȡĻߴ + int screenWidth = screenSize.width; // ȡĻ + int screenHeight = screenSize.height; // ȡĻ߶ + int x = (screenWidth - 450) / 2; // FrameϽx + int y = (screenHeight - 200) / 2; // FrameϽy + this.setLocation(x, y); // Frameλ + + // this.setLocationRelativeTo(null); + this.createActionEvent(); + this.pack(); + + // this.validate(); + this.setVisible(true); + +// this.setAlwaysOnTop(true); + + + } catch (Exception e) { + e.printStackTrace(); + return; + } + } + + // Ӽ + public void createActionEvent() { + + this.okButton.addActionListener(this); + this.concelButton.addActionListener(this); + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + + Object source = e.getSource(); + System.out.println("source==>+" + source); + if (this.okButton.equals(source)) { + map = new HashMap(); + String fString = find.getText(); + String rString = replace.getText(); + + if(fString.isEmpty()) { + MessageBox.post("дݣ", "ʾ ", MessageBox.INFORMATION); + return; + } + + if(rString.isEmpty()) { + MessageBox.post("д滻ݣ", "ʾ ", MessageBox.INFORMATION); + return; + } + + //ȡвݵĸ + int childrenCount = 0; + try { + childrenCount = task.getChildrenCount(); + + System.out.println("childrenCount=============="+childrenCount); + //ӸΪ0 + if(childrenCount == 0) { + MessageBox.post("ʱûӶ", "ʾ ", MessageBox.INFORMATION); + return; + } + + //ݹʱ + dgSchedule(task,map,fString, rString); + + if(map.size() == 0) { + MessageBox.post("δƥ䵽вݵĶ", "ʾ ", MessageBox.INFORMATION); + return; + } + + //޸ + for (Entry tempMap : map.entrySet()) { + TCComponentScheduleTask key = tempMap.getKey(); + String value = tempMap.getValue(); + key.setProperty("object_name", value); + } + //޸Ϣ + MessageBox.post("ɹ޸"+map.size()+"", "ʾ ", MessageBox.INFORMATION); + this.dispose(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + + + + + + + + } else if (this.concelButton.equals(source)) { + this.dispose(); + } + + } + + private void dgSchedule(TCComponentScheduleTask tempTask, HashMap map,String fString,String rString) throws TCException { + // TODO Auto-generated method stub + //ȡ + AIFComponentContext[] children = tempTask.getChildren(); + + for (int i = 0; i < children.length; i++) { + InterfaceAIFComponent component = children[i].getComponent(); + if(component instanceof TCComponentScheduleTask) { + TCComponentScheduleTask scheduleTask = (TCComponentScheduleTask)component; + String objectName = scheduleTask.getStringProperty("object_name"); + if(objectName.contains(fString)) { + map.put(scheduleTask, objectName.replace(fString, rString)); + } + dgSchedule(scheduleTask,map,fString,rString); + } + } + } + + private JPanel getBtnPanel() { + JPanel topPanel = new JPanel(); + topPanel.setLayout(new PropertyLayout()); + topPanel.add("1.1.center", new JLabel("")); + topPanel.add("2.1.center", new JLabel(" ")); + topPanel.add("2.2.center", okButton); + topPanel.add("2.3.center", new JLabel("")); + topPanel.add("2.4.center", concelButton); + + return topPanel; + } + + // ѯ + private JPanel getTopPanel() { + // TODO Auto-generated method stub + JPanel topPanel = new JPanel(); + topPanel.setLayout(new PropertyLayout()); + topPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); + + topPanel.add("1.1.left.center", new JLabel("")); + topPanel.add("2.1.left.center", new JLabel("")); + topPanel.add("3.1.left.center", new JLabel("")); + topPanel.add("4.1.left.center", new JLabel(" ݣ")); + topPanel.add("4.2.left.center", find); + + topPanel.add("5.1.left.center", new JLabel("")); + topPanel.add("6.1.left.center", new JLabel("")); + topPanel.add("7.1.left.center", new JLabel("")); + topPanel.add("8.1.left.center", new JLabel(" 滻ݣ")); + + topPanel.add("8.2.left.center", replace); + + return topPanel; + } + +} diff --git a/src/com/langtech/plm/batchRename/BatchRenameHandler.java b/src/com/langtech/plm/batchRename/BatchRenameHandler.java new file mode 100644 index 0000000..9827e87 --- /dev/null +++ b/src/com/langtech/plm/batchRename/BatchRenameHandler.java @@ -0,0 +1,57 @@ +package com.langtech.plm.batchRename; + +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.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentSchedule; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class BatchRenameHandler extends AbstractHandler{ + + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + try { + + new Thread() { + @Override + public void run() { + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + + if(targetComponent instanceof TCComponentScheduleTask) { + try { + TCComponentScheduleTask task = (TCComponentScheduleTask)targetComponent; + + new BatchRenameDialog(session,task); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }else { + MessageBox.post("ʱ","ʾ",2); + return; + } + + + } + }.start(); + + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + return null; + } + + +} diff --git a/src/com/langtech/plm/bg/CheckHeaderCellRenderer.java b/src/com/langtech/plm/bg/CheckHeaderCellRenderer.java new file mode 100644 index 0000000..bdf28fa --- /dev/null +++ b/src/com/langtech/plm/bg/CheckHeaderCellRenderer.java @@ -0,0 +1,72 @@ +package com.langtech.plm.bg; + +import java.awt.Component; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +import javax.swing.JCheckBox; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JTable; +import javax.swing.SwingConstants; +import javax.swing.UIManager; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableCellRenderer; + +public class CheckHeaderCellRenderer implements TableCellRenderer { + DefaultTableModel tableModel; + JTableHeader tableHeader; + final JCheckBox selectBox; + + public CheckHeaderCellRenderer(final JTable table) { + this.tableModel = (DefaultTableModel) table.getModel(); + this.tableHeader = table.getTableHeader(); + selectBox = new JCheckBox(tableModel.getColumnName(0)); + selectBox.setSelected(false); + tableHeader.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() > 0) { + // ѡ + int selectColumn = tableHeader.columnAtPoint(e.getPoint()); + if (selectColumn == 0) { + boolean value = !selectBox.isSelected(); + selectBox.setSelected(value); +// tableModel.selectAllOrNull(value); + tableHeader.repaint(); + if(value) { + for(int i=0;i> map; + private String excelTemplateUid; + + + public ExportExcelDialog(TCSession session,Map> map,String excelTemplateUid) { + this.session = session; + this.map = map; + this.excelTemplateUid = excelTemplateUid; + initUi(); + } + + public void initializationComponent() { + selectUploadLabel = new JLabel("ѡ񵼳·"); + uploadInput = new JTextField(14); + + importButton = new JButton("ѡ"); + okButton = new JButton("ȷ"); + celButton = new JButton("ȡ"); + + SwingUtilities.getWindowAncestor(importButton); + } + + /** + * ʼ + */ + public void initUi() { + initializationComponent(); + + JDialog dialog = new JDialog((JFrame) SwingUtilities.getWindowAncestor(importButton), "ѡ񵼳·", true); + dialog.setLayout(null); + + // ǩ + selectUploadLabel.setBounds(35, 40, 110, 25); + dialog.add(selectUploadLabel); + + // + uploadInput.setBounds(135, 40, 150, 25); + dialog.add(uploadInput); + + // ѡť + importButton.setBounds(300, 40, 90, 25); + + importButton.addActionListener(e -> { + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + fileChooser.setAcceptAllFileFilterUsed(false); // ʾ "ļ" ѡ + + // Ĭϴ򿪵ļΪ + File desktopDir = new File(System.getProperty("user.home"), "Desktop"); + fileChooser.setCurrentDirectory(desktopDir); + + int result = fileChooser.showOpenDialog(dialog); + if (result == JFileChooser.APPROVE_OPTION) { + ((JTextField) uploadInput).setText(fileChooser.getSelectedFile().getAbsolutePath()); + } + }); + dialog.add(importButton, BorderLayout.EAST); + + okButton.addActionListener(e -> { + String path = ((JTextField) uploadInput).getText(); + if (path.isEmpty()) { + JOptionPane.showMessageDialog(dialog, "ѡļϴ·"); + } else { + // ļǷΪĿ¼ + File file = new File(path); + if(file.exists()){ + if (!file.isDirectory()) { + JOptionPane.showMessageDialog(dialog, "ļ·ѡһĿ¼"); + } else { + // ϴ߼ + doTask(path); + MessageBox.post("ɹ", "ʾ ", MessageBox.INFORMATION); + dialog.dispose(); + } + } + } + }); + celButton.addActionListener(e -> { + dialog.dispose(); + }); + + // ȷȡť + okButton.setBounds(90, 90, 100, 25); + celButton.setBounds(210, 90, 100, 25); + dialog.add(okButton); + dialog.add(celButton); + + // öԻСλ + dialog.pack(); + dialog.setSize(440, 190); + + // ȡ importButton ȴ + Window ancestor = SwingUtilities.getWindowAncestor(importButton); + if (ancestor instanceof JFrame) { + dialog.setLocationRelativeTo((JFrame) ancestor); + } else { + // Ȳ JFrameѡʾĻ + dialog.setLocationRelativeTo(null); + } + + dialog.setVisible(true); + } + + public String downLoadExcel(TCSession session,String excelUid,String path) { + try { + TCComponent comp = session.stringToComponent(excelUid); + if (comp instanceof TCComponentDataset) { + TCComponentDataset dataset = (TCComponentDataset) comp; + String refs = comp.getProperty("ref_names"); + String[] ref = refs.split(","); + File file = dataset.getFiles(ref[0], path)[0]; + String templateFilePath = file.getAbsolutePath(); + // ȡļľ·templateFilePath + System.out.println("filePath: " + templateFilePath); + return templateFilePath; + } + } catch (TCException e) { + e.printStackTrace(); + } + return ""; + } + + + public void doTask(String filePath) { + filePath = downLoadExcel(session,excelTemplateUid,filePath); + File file = new File(filePath); + + LocalDateTime now = LocalDateTime.now(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); + int lastDotIndex = filePath.lastIndexOf("."); + filePath = filePath.substring(0,lastDotIndex) + "-" + now.format(formatter) + filePath.substring(lastDotIndex); + System.out.println(filePath); + file.renameTo(new File(filePath)); + + // ӳ + Map letterToNumberMap = new HashMap<>(); + for (char c = 'A'; c <= 'Z'; c++) { + letterToNumberMap.put(c + "", c - 'A'); + } + for (char firstChar = 'A'; firstChar <= 'Z'; firstChar++) { + for (char secondChar = 'A'; secondChar <= 'Z'; secondChar++) { + String column = String.valueOf(firstChar) + String.valueOf(secondChar); + letterToNumberMap.put(column, (firstChar - 'A' + 1) * 26 + (secondChar - 'A')); + } + } + try (FileInputStream fis = new FileInputStream(new File(filePath)); + Workbook workbook = new XSSFWorkbook(fis)) { + + // ȡһ sheet + Sheet sheet = workbook.getSheetAt(0); + + Set keyIndex = map.keySet(); + for (Integer rowIndex : keyIndex) { + Map rowMap = map.get(rowIndex); + Row row = sheet.createRow(rowIndex); + + Set keys = rowMap.keySet(); + for (String key : keys) { + int columnIndex = letterToNumberMap.get(key); + row.createCell(columnIndex).setCellValue(rowMap.get(key)); + } + } + + fis.close(); + workbook.write(new FileOutputStream(new File(filePath))); + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/src/com/langtech/plm/bg/QDRWChooseDialog.java b/src/com/langtech/plm/bg/QDRWChooseDialog.java new file mode 100644 index 0000000..721a1b4 --- /dev/null +++ b/src/com/langtech/plm/bg/QDRWChooseDialog.java @@ -0,0 +1,184 @@ +package com.langtech.plm.bg; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.Map.Entry; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.border.EmptyBorder; +import javax.swing.table.DefaultTableModel; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class QDRWChooseDialog extends JFrame implements ActionListener { + + + private JComboBox objectComboBox = new JComboBox(); + private JButton okButton = new JButton("ȷ"); + private JButton concelButton = new JButton("ȡ"); + private String[] strings; + private AbstractAIFUIApplication app; + private HashMap> map = new HashMap>(); + public QDRWChooseDialog(String[] strings,AbstractAIFUIApplication app) { + // TODO Auto-generated constructor stub + this.strings = strings; + this.app = app; + initUI(); + } + + + + public void initUI() { + // TODO Auto-generated method stub + try { + this.setTitle("ѡģ"); + this.setLayout(new BorderLayout()); + + JPanel topPanel = getTopPanel(); + + JPanel btnPanel = getBtnPanel(); + + this.add(topPanel, BorderLayout.NORTH); + // this.add(pane,BorderLayout.CENTER); + this.add(btnPanel, BorderLayout.SOUTH); + this.setPreferredSize(new Dimension(350, 150)); + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); // ȡĻߴ + int screenWidth = screenSize.width; // ȡĻ + int screenHeight = screenSize.height; // ȡĻ߶ + int x = (screenWidth - 350) / 2; // FrameϽx + int y = (screenHeight - 150) / 2; // FrameϽy + this.setLocation(x, y); // Frameλ + + // this.setLocationRelativeTo(null); + this.createActionEvent(); + this.pack(); + + // this.validate(); + this.setVisible(true); + +// this.setAlwaysOnTop(true); + + //ֵ + for (int i = 0; i < strings.length; i++) { + String[] split = strings[i].split("="); + objectComboBox.addItem(split[0]); + ArrayList list = new ArrayList(); + list.add(split[1]); + list.add(split[2]); + list.add(split[3]); + list.add(split[4]); + map.put(split[0], list); + } + + } catch (Exception e) { + e.printStackTrace(); + return; + } + } + + // Ӽ + public void createActionEvent() { + + this.okButton.addActionListener(this); + this.concelButton.addActionListener(this); + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + + Object source = e.getSource(); + System.out.println("source==>+" + source); + if (this.okButton.equals(source)) { + TCSession session = (TCSession)app.getSession(); + String selectedItem = (String) objectComboBox.getSelectedItem(); + + String[] person = session.getPreferenceService().getStringValues("Connor_TaskFormSummary_User"); + + if(person == null || person.length <= 0) { + MessageBox.post("ѡConnor_TaskFormSummary_UserΪգ", "ʾ ", MessageBox.INFORMATION); + return; + } + + + + HashMap tempMap = new HashMap(); + for (int i = 0; i < person.length; i++) { + String[] split = person[i].split(":"); + tempMap.put(split[0],split[1]); + } + + String personId = tempMap.get(selectedItem); + String userId = ""; + try { + userId = session.getUser().getUserId(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + if(personId.contains(userId)) { + ArrayList arrayList = map.get(selectedItem); + new QDRWDialog(session,arrayList.get(0),arrayList.get(1),selectedItem,arrayList.get(2),arrayList.get(3)); + System.out.println("newnewnwenew"); + }else { + MessageBox.post("ûȨޣ", "ʾ ", MessageBox.INFORMATION); + } + + this.dispose(); + } else if (this.concelButton.equals(source)) { + this.dispose(); + } + + } + + private JPanel getBtnPanel() { + JPanel topPanel = new JPanel(); + topPanel.setLayout(new PropertyLayout()); + topPanel.add("1.1.center", new JLabel("")); + topPanel.add("2.1.center", new JLabel(" ")); + topPanel.add("2.2.center", okButton); + topPanel.add("2.3.center", new JLabel("")); + topPanel.add("2.4.center", concelButton); + topPanel.add("3.1.center", new JLabel("")); + topPanel.add("4.1.center", new JLabel("")); + return topPanel; + } + + // ѯ + private JPanel getTopPanel() { + // TODO Auto-generated method stub + JPanel topPanel = new JPanel(); + topPanel.setLayout(new PropertyLayout()); + topPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); + + topPanel.add("1.1.left.center", new JLabel("")); + topPanel.add("2.1.left.center", new JLabel("")); + topPanel.add("3.1.left.center", new JLabel("")); + topPanel.add("4.1.left.center", new JLabel("")); + + topPanel.add("5.1.left.center", new JLabel(" ģ壺")); + topPanel.add("5.2.left.center", objectComboBox); + + return topPanel; + } + +} diff --git a/src/com/langtech/plm/bg/QDRWDialog.java b/src/com/langtech/plm/bg/QDRWDialog.java new file mode 100644 index 0000000..a0ef859 --- /dev/null +++ b/src/com/langtech/plm/bg/QDRWDialog.java @@ -0,0 +1,1690 @@ +package com.langtech.plm.bg; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.ListSelectionModel; +import javax.swing.RowSorter; +import javax.swing.SwingUtilities; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableColumnModel; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; + +import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.hssf.usermodel.HSSFName; +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.util.CellReference; +import org.apache.poi.xssf.usermodel.XSSFCell; +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.langtech.plm.tqsx.KUtil; +import com.teamcenter.rac.aif.AIFDesktop; +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.TCComponentProcessType; +import com.teamcenter.rac.kernel.TCComponentTaskTemplate; +import com.teamcenter.rac.kernel.TCComponentTaskTemplateType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class QDRWDialog extends JFrame implements ActionListener { + + private Map textMap = new HashMap<>(); + private TCSession session; + private JTable table; + private String[] header; + private ArrayList gsPrefTopLine; + private LinkedHashMap colorMap = new LinkedHashMap(); + private LinkedHashMap gsPrefMap = new LinkedHashMap(); + private LinkedHashMap fieldsMap = new LinkedHashMap(); + private LinkedHashMap cfdjPref = new LinkedHashMap(); + private LinkedHashMap lovPositionMap = new LinkedHashMap(); + private LinkedHashMap positionFieldMap = new LinkedHashMap(); + private LinkedHashMap widtheMap = new LinkedHashMap(); + // public static final int[] HEADERWIDTH = new int[] { 50, 100, 200, 200, 100, + // 100, 80, 80, 100, 150, 150, 150, 150,150, 150, 150, 150, 150, 150 }; + private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + private DefaultTableModel dtm1; + private JComboBox cfdJComboBox = new JComboBox(); + private DateButton jhksB; + private DateButton jhksS; + private DateButton jhwcB; + private DateButton jhwcS; + private JTextField idField = new JTextField(30); + private JButton ssButton = new JButton(""); + private JButton ckButton = new JButton("鿴"); + private JButton qrqdButton = new JButton("ȷ"); + private JButton djggtzdButton = new JButton("֪ͨ"); + private JButton excelButton = new JButton("ԷдExcel"); + private JButton gbButton = new JButton("ر"); + private JButton exportButton = new JButton("ECִ"); + private static ArrayList dateConnList = new ArrayList(); + private String pref; + private String taskName; + private String taskNameDJ; + private ArrayList canWriteColume = new ArrayList(); + private ArrayList sqlField; + private QDRWTableColorRender QDRWTableColorRender; + LinkedHashMap>>> valueMap; + private Connection conn = null; + private String tamplateName; + private String chooseType; + + public QDRWDialog(TCSession session, String pref, String taskName, String tamplateName, String chooseType, + String taskNameDJ) { + // TODO Auto-generated constructor stub + this.session = session; + this.pref = pref; + this.taskName = taskName; + this.tamplateName = tamplateName; + this.chooseType = chooseType; + this.taskNameDJ = taskNameDJ; + initUI(); + } + + public void initUI() { + // TODO Auto-generated method stub + this.setTitle(""); + this.setLayout(new BorderLayout()); + + String[] prefs = session.getPreferenceService().getStringValues(pref); + if (prefs == null || prefs.length <= 0) { + MessageBox.post("ѡ" + pref + "δã", "ʾ ", MessageBox.INFORMATION); + return; + } + + String[] split2 = prefs[0].split(";"); + for (int j = 0; j < split2.length; j++) { + String[] split3 = split2[j].split("="); + positionFieldMap.put(split3[0], j); + if (split3.length == 3) { + + if (split3[1].contains("#")) { + String[] split = split3[1].split("#"); + fieldsMap.put(split3[0], split[1]); + colorMap.put(j + 1, split3[0]); + } else { + fieldsMap.put(split3[0], split3[1]); + } + if (split3[2].contains("%")) { + String[] split4 = split3[2].split("%"); + widtheMap.put(j + 1, Integer.parseInt(split4[0])); + canWriteColume.add(j); + } else { + widtheMap.put(j + 1, Integer.parseInt(split3[2])); + } + + } + + else if (split3.length == 4) { + fieldsMap.put(split3[0], split3[1]); + // System.out.println("split3[2]========" + split3[2]); + if (split3[2].contains("%")) { + String[] split4 = split3[2].split("%"); + widtheMap.put(j, Integer.parseInt(split4[0])); + // System.out.println("split4[0]========" + split4[0]); + canWriteColume.add(j); + } else { + widtheMap.put(j, Integer.parseInt(split3[2])); + } + lovPositionMap.put(j, split3[3]); + } + + } + + System.out.println("canWriteColume=====" + canWriteColume.size()); + System.out.println("fieldsMap=====" + fieldsMap); + System.out.println("positionMap=====" + lovPositionMap); + System.out.println("widtheMap=====" + widtheMap); + Collection valuesCollection = fieldsMap.values(); + // һµбеֵ + List valuesList = new ArrayList<>(valuesCollection); + + // бĵһλòµ String ֵ + valuesList.add(0, ""); + + // ҪԽбתؼ + Collection updatedValuesCollection = valuesList; + // תΪ + header = updatedValuesCollection.toArray(new String[0]); + System.out.println("header===============" + header.length); + + JPanel topPanel = getTopPanel(); + JScrollPane pane = getTablePanel(); + pane.setBorder(BorderFactory.createTitledBorder("")); +// JPanel btnPanel = getRightPanel(); + + JPanel bottomPane = getBottomPanel(); + this.add(topPanel, BorderLayout.NORTH); + this.add(pane, BorderLayout.CENTER); + this.add(bottomPane, BorderLayout.SOUTH); + this.createActionEvent(); + this.pack(); + this.setPreferredSize(new Dimension(1850, 1000)); + this.validate(); + this.setVisible(true); + // ôĻ +// Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize(); +// int x = (int) screensize.getWidth() / 2 - window.getWidth() / 2; +// int y = (int) screensize.getHeight() / 2 - window.getHeight() / 2; + this.setLocationRelativeTo(null); + + // п + TableColumnModel colModel = table.getColumnModel(); + for (Entry map : widtheMap.entrySet()) { + colModel.getColumn(map.getKey()).setPreferredWidth(map.getValue()); + } + + } + + public void createActionEvent() { + this.ssButton.addActionListener(this); + this.ckButton.addActionListener(this); + this.gbButton.addActionListener(this); + this.qrqdButton.addActionListener(this); + this.excelButton.addActionListener(this); + this.djggtzdButton.addActionListener(this); + this.exportButton.addActionListener(this); + } + + // ѯ + private JPanel getTopPanel() { + // TODO Auto-generated method stub + JPanel topPanel = new JPanel(); + topPanel.setLayout(new PropertyLayout()); + + jhksB = new DateButton(null, "yyyy-MM-dd", false, false, false); + jhksB.setDate("δ"); + jhksS = new DateButton(null, "yyyy-MM-dd", false, false, false); + jhksS.setDate("δ"); + jhwcB = new DateButton(null, "yyyy-MM-dd", false, false, false); + jhwcB.setDate("δ"); + jhwcS = new DateButton(null, "yyyy-MM-dd", false, false, false); + jhwcS.setDate("δ"); + topPanel.add("1.1.left.center", new JLabel("ID ")); + topPanel.add("1.2.left.center", idField); + topPanel.add("1.3.left.center", new JLabel(" ƻʼ ")); + topPanel.add("1.4.left.center", jhksB); + topPanel.add("1.5.left.center", new JLabel(" ƻʼ ")); + topPanel.add("1.6.left.center", jhksS); + topPanel.add("1.7.left.center", new JLabel(" ƻ ")); + topPanel.add("1.8.left.center", jhwcB); + topPanel.add("1.9.left.center", new JLabel(" ƻ ")); + topPanel.add("1.10.left.center", jhwcS); + topPanel.add("2.1.left.center", new JLabel(" ")); + return topPanel; + } + + // ѯ + private JPanel getBottomPanel() { + // TODO Auto-generated method stub + JPanel bottomPanel = new JPanel(); + bottomPanel.setLayout(new PropertyLayout()); + bottomPanel.add("1.1.left.center", new JLabel(" ")); + bottomPanel.add("1.2.left.center", ssButton); + bottomPanel.add("1.3.left.center", new JLabel(" ")); + bottomPanel.add("1.4.left.center", ckButton); + bottomPanel.add("1.5.left.center", new JLabel(" ")); + bottomPanel.add("1.6.left.center", qrqdButton); + bottomPanel.add("1.7.left.center", new JLabel(" ")); + bottomPanel.add("1.8.left.center", djggtzdButton); + bottomPanel.add("1.9.left.center", new JLabel(" ")); + bottomPanel.add("1.10.left.center", excelButton); + bottomPanel.add("1.11.left.center", new JLabel(" ")); + bottomPanel.add("1.12.left.center", gbButton); + bottomPanel.add("1.13.left.center", new JLabel(" ")); + bottomPanel.add("1.14.left.center", exportButton); + return bottomPanel; + } + + private JScrollPane getTablePanel() { + // TODO Auto-generated method stub + table = getjTable(null, null, header, null, false); + table.setRowHeight(30); +// table.setPreferredSize(new Dimension(1500,400)); + table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // ñԶģʽΪرԶ +// table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);//JTableпбݵĴСе +// table.setPreferredSize(new Dimension(1200,400)); + // ԶȾ + QDRWTableColorRender = new QDRWTableColorRender(); + table.setDefaultRenderer(Object.class, QDRWTableColorRender); + JScrollPane pane = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, + JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + table.getTableHeader().setDefaultRenderer(new CheckHeaderCellRenderer(table)); + table.getColumnModel().getColumn(0).setCellRenderer(new TableCellCheckboxRenderer(table)); +// for (Entry map : lovPositionMap.entrySet()) { +// JComboBox jComboBox = new JComboBox(); +// String value = map.getValue(); +// if(value.contains(",")) { +// String[] split = value.split(","); +// for (int i = 0; i < split.length; i++) { +// jComboBox.addItem(split[i]); +// } +// }else { +// jComboBox.addItem(value); +// } +// table.getColumnModel().getColumn(map.getKey()).setCellEditor(new DefaultCellEditor(jComboBox)); +// } + + SwingUtilities.invokeLater(new Runnable() { + public void run() { + // + table.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() == 2 || e.getClickCount() == 1) { + // TODO Auto-generated method stub + int selectColumn = table.getTableHeader().columnAtPoint(e.getPoint()); + int selectedRow = table.rowAtPoint(e.getPoint()); + + if (selectColumn == 0) { + Object valueAt = table.getValueAt(selectedRow, selectColumn); + if (valueAt.toString().equals("1")) { + table.setValueAt("0", selectedRow, selectColumn); + } else { + table.setValueAt("1", selectedRow, selectColumn); + } + } + } + } + }); + } + }); + + pane.setPreferredSize(new Dimension(1800, 850)); + pane.setViewportView(table);// ΪscrollPaneָʾΪtable + return pane; + } + + /*** + * Jtableͨ÷ + * + * @param partsTable + * @param dtm + * @param titleNames + * @param values + * @return + */ + public JTable getjTable(JTable partsTable, DefaultTableModel dtm, Object[] titleNames, Object[][] values, + Boolean isTable2) { +// int simpleLen = 100; +// int totleLen = 1000; + if (partsTable == null) { + partsTable = new JTable(this.getTableModel(dtm, titleNames, values)); + partsTable.setRowHeight(20); + partsTable.getTableHeader().setReorderingAllowed(false); + partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + RowSorter sorter = new TableRowSorter(partsTable.getModel()); + partsTable.setRowSorter(sorter); +// for (int i = 0; i < titleNames.length; i++) { +// if(i==2) { +// partsTable.getColumnModel().getColumn(i).setPreferredWidth(200); +// }else { +// partsTable.getColumnModel().getColumn(i).setPreferredWidth(120); +// } +// +// } + + } + return partsTable; + } + + public DefaultTableModel getTableModel(DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + + dtm1 = null; + if (dtm == null) { + dtm1 = new DefaultTableModel(values, titleNames) { + @Override + public boolean isCellEditable(int row, int column) { + if (column == 0) { + return true; + } else { + return false; + } + } + }; + } + return dtm1; + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + System.out.println("source==>+" + source); + + if (source.equals(this.gbButton)) { + dispose(); + } else if (source.equals(this.ckButton)) { + int selectedRow = table.getSelectedRow(); + if (selectedRow < 0) { + MessageBox.post("ѡijһ!", "ʾ", 2); + } + String selectId = (String) table.getValueAt(selectedRow, 1); + String selectType = (String) table.getValueAt(selectedRow, 2); + + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + try { + new QDRWRWFPDialog(session, selectType, selectId); + // d.setModal(true); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + + } else if (source.equals(this.qrqdButton)) { + + String[] value = session.getPreferenceService().getStringValues("LD_dbinfo2"); + + if (value == null || value.length == 0) { + MessageBox.post("ѡLD_dbinfo2顣", "ʾ", 2); + return; + } else { + Collections.addAll(dateConnList, value); + } + conn = getConn(); + + int count = 0; + for (int i = 0; i < table.getRowCount(); i++) { + if (table.getValueAt(i, 0).toString().equals("1")) { + + String id = table.getValueAt(i, 1).toString(); + TCComponentItemRevision rev = null; + try { + + System.out.println("id=============" + id); + TCComponent[] tcComponentsById = getTCComponentsById(session, id); + + if (tcComponentsById != null && tcComponentsById.length > 0) { + System.out.println("tcComponentsById.length=============" + tcComponentsById.length); + TCComponentItem item = (TCComponentItem) tcComponentsById[0]; + rev = item.getLatestItemRevision(); + } + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + LinkedHashMap>> linkedHashMap = valueMap.get(id); + for (Entry map : colorMap.entrySet()) { + boolean isProsess = false; + String prefValue = map.getValue(); + String[] split = prefValue.split("\\."); + ArrayList> arrayList = linkedHashMap.get(split[0]); + String RWXDSJ = ""; + String QQRW = ""; + String SFSJGG = ""; + String GGPSNR = ""; + for (int j = 0; j < arrayList.size(); j++) { + + if (arrayList.get(j).containsKey("RWXDSJ")) { + RWXDSJ = arrayList.get(j).get("RWXDSJ"); + } + if (arrayList.get(j).containsKey("QQRW")) { + QQRW = arrayList.get(j).get("QQRW"); + } + if (arrayList.get(j).containsKey("SFSJGG")) { + SFSJGG = arrayList.get(j).get("SFSJGG"); + } + + if (arrayList.get(j).containsKey("GGPSNR")) { + GGPSNR = arrayList.get(j).get("GGPSNR"); + } + } + System.out.println("RWXDSJ=======" + RWXDSJ); + System.out.println("QQRW=======" + QQRW); + System.out.println("SFSJGG=======" + SFSJGG); + + if (RWXDSJ == null || RWXDSJ.isEmpty()) { + // ȥǷ漰ΪIJ +// if (SFSJGG != null && !SFSJGG.isEmpty() && SFSJGG.equals("")) { +// isProsess = true; +// } else + if (SFSJGG != null && !SFSJGG.isEmpty() && SFSJGG.equals("") + && (QQRW == null || QQRW.isEmpty())) { + isProsess = true; + } else if (SFSJGG != null && !SFSJGG.isEmpty() && SFSJGG.equals("") + && (QQRW != null && !QQRW.isEmpty())) { + // ǰ + ArrayList judgeList = new ArrayList(); + dgRW(linkedHashMap, QQRW, judgeList); + if (judgeList.size() == 0) { + isProsess = true; + } + } + } + + System.out.println("taskName=========" + taskName); + System.out.println("isProsess========" + isProsess); + if (isProsess && taskName != null && !taskName.isEmpty() && rev != null) { + + try { + + CreateProcess(session, rev, taskName, GGPSNR, split[0], id); + + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + + } + + count++; + } + } + + if (count == 0) { + MessageBox.post("빴ѡݣ", "ʾ ", MessageBox.INFORMATION); + if (conn != null) { + try { + conn.close(); + } catch (SQLException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + return; + } + if (conn != null) { + try { + conn.close(); + } catch (SQLException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + MessageBox.post("ɣ", "ʾ ", MessageBox.INFORMATION); + } else if (source.equals(this.ssButton)) { + table.removeAll(); + dtm1.setRowCount(0); + String condition = ""; + String ids = idField.getText(); + + String jhksBStr = jhksB.getText(); + String jhksSStr = jhksS.getText(); + String jhwcBStr = jhwcB.getText(); + String jhwcSStr = jhwcS.getText(); + System.out.println("jhksBStr=======" + jhksBStr); + + if (!jhksBStr.contains("δ")) { + condition += "and JHKS >= '" + jhksBStr + "' "; + } + + if (!jhksSStr.contains("δ")) { + condition += "and JHKS <= '" + jhksSStr + "' "; + } + + if (!jhwcBStr.contains("δ")) { + condition += "and JHJS >= '" + jhwcBStr + "' "; + } + + if (!jhwcSStr.contains("δ")) { + condition += "and JHJS <= '" + jhwcSStr + "' "; + } + + if (ids != null && !ids.isEmpty()) { + if (ids.contains(";")) { + String[] split = ids.split(";"); + StringBuilder sqlIn = new StringBuilder(); + sqlIn.append("("); + for (int i = 0; i < split.length; i++) { + sqlIn.append("'" + split[i] + "',"); + } + // ȥһ + sqlIn.setLength(sqlIn.length() - 1); + sqlIn.append(")"); + System.out.println("sqlIn======================" + sqlIn.toString()); + condition += "and ID IN " + sqlIn.toString(); + } else { + condition += "and ID='" + ids + "' "; + } + } + + String[] value = session.getPreferenceService().getStringValues("LD_dbinfo2"); + + if (value == null || value.length == 0) { + MessageBox.post("ѡLD_dbinfo2顣", "ʾ", 2); + return; + } else { + Collections.addAll(dateConnList, value); + } + sqlField = new ArrayList(); + Set keySet = fieldsMap.keySet(); + String fieldsSql = ""; + for (String string : keySet) { + String[] split = string.split("\\."); + fieldsSql += split[1] + ","; + sqlField.add(split[1]); + } + fieldsSql = fieldsSql.substring(0, fieldsSql.length() - 1); + System.out.println("fieldsSql==========" + fieldsSql); + // System.out.println("condition===================" + condition); + if (condition == null || condition.isEmpty()) { + MessageBox.post("д!", "ʾ", 2); + return; + } + String sqlIdString = "SELECT ID FROM LY_CHANGETASSKFORM_DETAILS where TEMPLATENAME = '" + tamplateName + + "' and OBJECTTYPE = '" + chooseType + "' " + condition; + System.out.println("sqlIdString=========" + sqlIdString); + conn = getConn(); + PreparedStatement stmt = null; + String selectIds = ""; + String lastCondition = ""; + // ID + try { + stmt = conn.prepareStatement(sqlIdString); + ResultSet result = stmt.executeQuery(); + while (result.next()) { + String id = result.getString("ID"); + if (!selectIds.contains(id)) { + selectIds += id + ";"; + } + } + + if (selectIds != null && !selectIds.isEmpty()) { + if (selectIds.contains(";")) { + String[] split = selectIds.split(";"); + StringBuilder sqlIn = new StringBuilder(); + sqlIn.append("("); + for (int i = 0; i < split.length; i++) { + sqlIn.append("'" + split[i] + "',"); + } + // ȥһ + sqlIn.setLength(sqlIn.length() - 1); + sqlIn.append(")"); + // System.out.println("sqlIn======================" + sqlIn.toString()); + lastCondition += "and ID IN " + sqlIn.toString(); + } else { + lastCondition += "and ID='" + ids + "' "; + } + } + } catch (SQLException e1) { + e1.printStackTrace(); + } + + // ݵmap + valueMap = new LinkedHashMap>>>(); + // String sqlString = "SELECT " + fieldsSql + " FROM LY_CHANGETASSKFORM_DETAILS + // where 1=1 "+lastCondition; + String sqlString = "SELECT * FROM LY_CHANGETASSKFORM_DETAILS where 1=1 " + lastCondition; + + System.out.println("sqlString======" + sqlString); + if (lastCondition.isEmpty()) { + MessageBox.post("δ鵽ݣ", "ʾ", 2); + return; + } else { + try { + stmt = conn.prepareStatement(sqlString); + ResultSet result = stmt.executeQuery(); + ResultSetMetaData metaData = result.getMetaData(); + int columnCount = metaData.getColumnCount(); + while (result.next()) { + String id = result.getString("ID"); + String xh = result.getString("XH"); + LinkedHashMap>> tempMap1 = null; + if (valueMap.containsKey(id)) { + tempMap1 = valueMap.get(id); + } else { + tempMap1 = new LinkedHashMap>>(); + } + ArrayList> tempList = new ArrayList>(); + + LinkedHashMap rowMap = new LinkedHashMap(); + + for (int i = 1; i <= columnCount; i++) { + // ȡ + String columnName = metaData.getColumnName(i); // ȡʵʵ + + // ȡеֵ + String columnValue = result.getString(i); // ʹ getObject() ȡеֵ + rowMap.put(columnName, columnValue); + + } + + String sfsjgg = rowMap.get("SFSJGG"); + // System.out.println("sfsjgg========================================="+sfsjgg); + if (sfsjgg != null && sfsjgg.equals("")) { + for (Entry tempMap : rowMap.entrySet()) { + + LinkedHashMap fieldMap = new LinkedHashMap(); + fieldMap.put(tempMap.getKey(), tempMap.getValue() == null ? tempMap.getValue() + : validateAndFormatDate(tempMap.getValue(), true)); + tempList.add(fieldMap); + } + + } else { + for (Entry tempMap : rowMap.entrySet()) { + + LinkedHashMap fieldMap = new LinkedHashMap(); + fieldMap.put(tempMap.getKey(), tempMap.getValue() == null ? tempMap.getValue() + : validateAndFormatDate(tempMap.getValue(), false)); + tempList.add(fieldMap); + } + } + + tempMap1.put(xh, tempList); + valueMap.put(id, tempMap1); + } + // System.out.println(valueMap.toString()); + QDRWTableColorRender.valueMap = valueMap; + QDRWTableColorRender.colorMap = colorMap; + for (Entry>>> map : valueMap + .entrySet()) { + ArrayList tableList = new ArrayList(); + tableList.add("0"); + for (Entry tempMap : fieldsMap.entrySet()) { + String pref = tempMap.getKey(); + String[] split = pref.split("\\."); + LinkedHashMap>> value2 = map.getValue(); + ArrayList> arrayList = value2.get(split[0]); + if (arrayList != null) { + for (int i = 0; i < arrayList.size(); i++) { + LinkedHashMap linkedHashMap = arrayList.get(i); + if (linkedHashMap.containsKey(split[1])) { + tableList.add(linkedHashMap.get(split[1])); + } + } + } + + } + dtm1.addRow(tableList.toArray(new Object[0])); + } + } catch (SQLException e1) { + e1.printStackTrace(); + } + } + + try { + if (stmt != null) { + stmt.close(); + } + if (conn != null) { + conn.close(); + } + + } catch (SQLException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } else if (source.equals(this.djggtzdButton)) { + int count = 0; + for (int i = 0; i < table.getRowCount(); i++) { + if (table.getValueAt(i, 0).toString().equals("1")) { + + String id = table.getValueAt(i, 1).toString(); + TCComponentItemRevision rev = null; + try { + + System.out.println("id=============" + id); + TCComponent[] tcComponentsById = getTCComponentsById(session, id); + + if (tcComponentsById != null && tcComponentsById.length > 0) { + System.out.println("tcComponentsById.length=============" + tcComponentsById.length); + TCComponentItem item = (TCComponentItem) tcComponentsById[0]; + rev = item.getLatestItemRevision(); + try { + + DJCreateProcess(session, rev, taskNameDJ); + + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + count++; + } + } + if (count == 0) { + MessageBox.post("빴ѡݣ", "ʾ", 2); + } else { + MessageBox.post("֪ͨɣ", "ʾ", 2); + } + } else if (source.equals(this.excelButton)) { + + String[] names = session.getPreferenceService().getStringValues("Connor_TaskFormSummary_AttrToExcel"); + if (names == null || names.length <= 0) { + MessageBox.post("ѡConnor_TaskFormSummary_AttrToExcel", "ʾ ", MessageBox.INFORMATION); + return; + } + + HashMap nameMap = new HashMap();// ݼƺͶ(item,rev,revMaster) + for (int i = 0; i < names.length; i++) { + // Item.object_name=object_name + String[] split = names[i].split("="); + nameMap.put(split[0], split[1]); + } + + int count = 0; + for (int i = 0; i < table.getRowCount(); i++) { + if (table.getValueAt(i, 0).toString().equals("1")) { + + String id = table.getValueAt(i, 1).toString(); + String selectType = (String) table.getValueAt(i, 2); + TCComponentItemRevision rev = null; + LinkedHashMap rwfpFieldsMap = new LinkedHashMap(); + ArrayList>> bgMap = new ArrayList>>(); + try { + System.out.println("id=============" + id); + TCComponent[] tcComponentsById = getTCComponentsById(session, id); + + if (tcComponentsById != null && tcComponentsById.length > 0) { + System.out.println("tcComponentsById.length=============" + tcComponentsById.length); + TCComponentItem item = (TCComponentItem) tcComponentsById[0]; + rev = item.getLatestItemRevision(); + + // ȡ汾µݼ + TCComponent[] relatedComponents = rev.getRelatedComponents("IMAN_specification"); + if (relatedComponents == null || relatedComponents.length == 0) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ѡж IMAN_specificationϵûݼ"); + return; + } + + // ȡѡƥ + String[] fields = session.getPreferenceService() + .getStringValues("Connor_ECRECNForm_Datbase_Config"); + if (fields == null || fields.length <= 0) { + MessageBox.post("ѡConnor_ECRECNForm_Datbase_Config", "ʾ ", + MessageBox.INFORMATION); + return; + } + + for (int i1 = 0; i1 < fields.length; i1++) { + if (fields[i1].contains(selectType)) { + String[] split = fields[i1].split("\\|"); + if (split.length == 2) { + String[] split2 = split[1].split(";"); + for (int j = 0; j < split2.length; j++) { + String[] split3 = split2[j].split("="); + if (split3.length == 3) { + rwfpFieldsMap.put(split3[0], split3[1]); + } else if (split3.length == 4) { + rwfpFieldsMap.put(split3[0], split3[1]); + } + } + } + + } + } + + if (rwfpFieldsMap.size() == 0) { + + MessageBox.post("δƥ䵽ѡ", "ʾ ", MessageBox.INFORMATION); + return; + } + + Set keySet = rwfpFieldsMap.keySet(); + String fieldsSql = ""; + for (String string : keySet) { + fieldsSql += string + ","; + } + fieldsSql = fieldsSql.substring(0, fieldsSql.length() - 1); + System.out.println("fieldsSql==========" + fieldsSql); + String sqlString = "SELECT " + fieldsSql + " FROM LY_CHANGETASSKFORM_DETAILS where ID='" + + id + "'"; + System.out.println(sqlString); + Connection conn = getConn(); + PreparedStatement stmt = null; + try { + stmt = conn.prepareStatement(sqlString); + ResultSet result = stmt.executeQuery(); + while (result.next()) { + LinkedHashMap tempLinkedHashMap = new LinkedHashMap(); + LinkedHashMap tempTempLinkedHashMap = new LinkedHashMap(); + for (Entry tempMap : rwfpFieldsMap.entrySet()) { + String key = tempMap.getKey(); + + tempTempLinkedHashMap.put(key, + result.getString(key) == null ? "" : result.getString(key)); + } + + if (tempTempLinkedHashMap.containsKey("SFSJGG") + && tempTempLinkedHashMap.get("SFSJGG").equals("")) { + LinkedHashMap newMap = new LinkedHashMap(); + for (Entry rowMap : tempTempLinkedHashMap.entrySet()) { + newMap.put(rowMap.getKey(), rowMap.getValue() == null ? "" + : validateAndFormatDate(rowMap.getValue(), true)); + } + tempLinkedHashMap.put(result.getString(1), newMap); + bgMap.add(tempLinkedHashMap); + } else { + LinkedHashMap newMap = new LinkedHashMap(); + for (Entry rowMap : tempTempLinkedHashMap.entrySet()) { + newMap.put(rowMap.getKey(), rowMap.getValue() == null ? "" + : validateAndFormatDate(rowMap.getValue(), false)); + } + + tempLinkedHashMap.put(result.getString(1), newMap); + bgMap.add(tempLinkedHashMap); + } + + } + + } catch (SQLException e1) { + e1.printStackTrace(); + } + + try { + if (stmt != null) { + stmt.close(); + } + if (conn != null) { + conn.close(); + } + + } catch (SQLException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + System.out.println("bgMap=========" + bgMap.toString()); + KUtil.setByPass(true); + // ݼ + for (TCComponent tcComponent : relatedComponents) { + if (tcComponent instanceof TCComponentDataset) { + TCComponentDataset dataset = (TCComponentDataset) tcComponent; + // ߰лȡϵͳʱ· + File datasetFile = KUtil.getDatasetFile(dataset); + String type = tcComponent.getType(); + String datasetType = ""; + String newPath = ""; + if ("MSExcel".equals(type) || "MSExcelX".equals(type)) { + switch (type) { + case "MSExcel": + datasetType = "excel"; + newPath = dealExcel(datasetFile, rev, nameMap, bgMap); + break; + case "MSExcelX": + datasetType = "excel"; + newPath = dealExcelX(datasetFile, rev, nameMap, bgMap); + break; + } + // ݼµ + dataset.setFiles(new String[] { newPath }, new String[] { datasetType }); + } + } + } + KUtil.setByPass(false); + } + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + + MessageBox.post(e1.getMessage(), "ʾ", 2); + KUtil.setByPass(false); + return; + } + count++; + } + } + if (count == 0) { + MessageBox.post("빴ѡݣ", "ʾ", 2); + } else { + MessageBox.post("дExcelɣ", "ʾ", 2); + } + } else if (source.equals(this.exportButton)) { + // + if (tamplateName.contains("")) { + getExcelObject("Connor_TaskFormSummary_ECReport_JJ", "LY6_JHMECRRevision", "LY6_JHPRRevision"); + + } else if (tamplateName.contains("")) { + // + getExcelObject("Connor_TaskFormSummary_ECReport_ZZ", "LY6_JHCECRRevision", "LY6_JHPRRevision"); + } else { + MessageBox.post("ѡıģ", "ʾ", 2); + } + } + } + + public void getExcelObject(String preference, String ecrType, String prType) { + String[] templatesAndRules; + String excelTemplateUid; + + Map method1 = new HashMap(); + Map method2 = new HashMap(); + Map method3 = new HashMap(); + + templatesAndRules = session.getPreferenceService().getStringValues(preference); + if (templatesAndRules == null) { + MessageBox.post(preference + "ѡ", "ʾ", 2); + return; + } + + excelTemplateUid = templatesAndRules[0]; + for (int i = 1; i < templatesAndRules.length; i++) { + String[] colNameMethod = templatesAndRules[i].split("="); + if (colNameMethod.length <= 1) { + MessageBox.post(preference + "ѡøʽ", "ʾ", 2); + return; + } + System.out.println("ѡã " + colNameMethod[0] + " || " + colNameMethod[1]); + + String[] getMethod1 = colNameMethod[1].split("\\."); + if (getMethod1 != null && getMethod1.length >= 3) { + method1.put(colNameMethod[0], getMethod1); + continue; + } + + String[] getMethod3 = colNameMethod[1].split("#"); + if (getMethod3 != null && getMethod3.length >= 2) { + method3.put(colNameMethod[0], getMethod3); + continue; + } + + method2.put(colNameMethod[0], colNameMethod[1]); + } + + System.out.println("ѡϣʼȡݣ"); +// ѯ ID + + DefaultTableModel model = (DefaultTableModel) table.getModel(); + int rowCount = model.getRowCount(); + + String[] uid = new String[rowCount]; + for (int i = 0; i < rowCount; i++) { + uid[i] = (String) table.getValueAt(i, 1); + System.out.println("uid : " + uid[i]); + } + + Map> map = null; + try { + System.out.println("ecrType prType = " + ecrType + " || " + prType); + map = getExcelData(uid, method1, method2, method3, ecrType, prType); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + new ExportExcelDialog(session, map, excelTemplateUid); + } + + public Map> getExcelData(String[] uid, Map method1, + Map method2, Map method3, String ecrType, String prType) + throws Exception { + List tcComponents = new ArrayList(); + for (int i = 0; i < uid.length; i++) { + InterfaceAIFComponent[] tempTc = session.search(" ID", new String[] { " ID" }, + new String[] { uid[i] }); + if (tempTc.length >= 1) { + tcComponents.add(tempTc[0]); + } else { + System.out.println("ûвѯitemId : " + uid); + } + } + + Map> map = new HashMap<>(); + int i = 1; + for (InterfaceAIFComponent everyItem : tcComponents) { + System.out.println("Type : " + everyItem.getType()); + TCComponentItem item = (TCComponentItem) everyItem; + TCComponentItemRevision rev = item.getLatestItemRevision(); + TCComponent form = rev.getRelatedComponent("IMAN_master_form_rev"); + String ecnItemId = item.getProperty("item_id"); + + Map rowMap = new HashMap<>(); + // method1 + Set keySet1 = method1.keySet(); + for (String propName : keySet1) { + String[] value = method1.get(propName.trim()); + System.out.println("method1 : " + propName + " || " + Arrays.toString(value)); + if (value.length != 3) { + continue; + } + switch (value[1].trim()) { + case "Item": { + rowMap.put(propName, item.getStringProperty(value[2])); + break; + } + case "Rev": { + rowMap.put(propName, rev.getStringProperty(value[2])); + break; + } + case "Form": { + rowMap.put(propName, form.getStringProperty(value[2])); + break; + } + default: { + break; + } + } + } + + TCComponent[] relatedComponent = rev.getRelatedComponents("CMImplements"); + List prRevs = new ArrayList(); + List ecrRevs = new ArrayList(); + for (int j = 0; j < relatedComponent.length; j++) { + String type = relatedComponent[j].getStringProperty("object_type"); + System.out.println("ECNϵµĶͣ" + type); + if (type.equals(ecrType)) { + TCComponentItemRevision tempRev = (TCComponentItemRevision) relatedComponent[j]; + ecrRevs.add(tempRev); + TCComponent[] relatedComponents = tempRev.getRelatedComponents("CMImplements"); + for (TCComponent tcComponent : relatedComponents) { + String type2 = tcComponent.getStringProperty("object_type"); + System.out.println("ECRϵµĶͣ" + type2); + if (type2.equals(prType)) { + prRevs.add((TCComponentItemRevision) tcComponent); + } + } + } else if (type.equals(prType)) { + prRevs.add((TCComponentItemRevision) relatedComponent[j]); + } + } + + // method2 + Set keySet2 = method2.keySet(); + boolean ecnState = false; + String ecnName = ""; + boolean ecrState = false; + String ecrName = ""; + boolean prState = false; + String prName = ""; + for (String propName : keySet2) { + String value = method2.get(propName); + System.out.println("method2 : " + propName + " || " + value); + if (value.equals("ECN״̬")) { + ecnState = true; + ecnName = propName; + } else if (value.equals("ECR״̬")) { + ecrState = true; + ecrName = propName; + } else if (value.equals("PR״̬")) { + prState = true; + prName = propName; + } + } + for (String propName : keySet2) { + String value = method2.get(propName); + switch (value) { + case "ECNID": { + rowMap.put(propName, ecnItemId); + if (ecnState) { + rowMap.put(ecnName, rev.getProperty("date_released").isEmpty() ? "δر" : "ر"); + } + break; + } + case "ECRID": { + StringBuffer itemIds = new StringBuffer(); + StringBuffer states = new StringBuffer(); + for (TCComponentItemRevision tempRev : ecrRevs) { + itemIds.append(tempRev.getProperty("item_id")); + itemIds.append(";"); + if (ecrState) { + String released = tempRev.getProperty("date_released"); + states.append(released.isEmpty() ? "δر" : "ر"); + states.append(";"); + } + } + rowMap.put(propName, itemIds.toString().isEmpty() ? "/" : itemIds.toString()); + if (ecrState) { + rowMap.put(ecrName, states.toString().isEmpty() ? "/" : states.toString()); + } + break; + } + case "PRID": { + StringBuffer itemIds = new StringBuffer(); + StringBuffer states = new StringBuffer(); + for (TCComponentItemRevision tempRev : prRevs) { + itemIds.append(tempRev.getProperty("item_id")); + itemIds.append(";"); + if (prState) { + String released = tempRev.getProperty("date_released"); + states.append(released.isEmpty() ? "δر" : "ر"); + states.append(";"); + } + } + rowMap.put(propName, itemIds.toString().isEmpty() ? "/" : itemIds.toString()); + if (prState) { + rowMap.put(prName, states.toString().isEmpty() ? "/" : states.toString()); + } + break; + } + default: { + break; + } + } + } + + // method3 + conn = getConn(); + String sqlString = "SELECT * FROM LY_CHANGETASSKFORM_DETAILS where ID = ? AND XH = ?"; + PreparedStatement stmt = conn.prepareStatement(sqlString); + Set keySet3 = method3.keySet(); + Map isOutPutMap = new HashMap<>(); + for (String colName : keySet3) { + boolean isOutput = false; + String[] values = method3.get(colName); + if (values[1].equals("SFSJGG")) { + System.out.println("enter = SFSJGG"); + System.out.println("ѯ : " + values[1] + " || " + ecnItemId + " || " + values[0]); +// stmt.setString(1, values[1]); + stmt.setString(1, ecnItemId); + stmt.setString(2, values[0]); + + ResultSet result = stmt.executeQuery(); + while (result.next()) { + String isOutValue = result.getString(values[1]); + rowMap.put(colName, isOutValue); + if (isOutValue.equals("")) { + isOutput = true; + } + System.out.println("colName : " + colName + "-->ǷϢ : " + isOutput); + // isOutPutMap keyк valueкǷϢ + isOutPutMap.put(values[0], isOutput); + break; + } + } + } + for (String colName : keySet3) { + try { + String[] values = method3.get(colName); + String dataBaseCol = values[1].trim(); + if (isOutPutMap.containsKey(values[0])) { + boolean isOut = isOutPutMap.get(values[0]); + if (!dataBaseCol.equals("SFSJGG")) { + if (isOut) { + System.out.println("enter = SFSJGG"); + System.out.println("ѯ : " + values[1] + " || " + ecnItemId + " || " + values[0]); +// stmt.setString(1, values[1]); + stmt.setString(1, ecnItemId); + stmt.setString(2, values[0]); + + ResultSet result = stmt.executeQuery(); + while (result.next()) { + System.out.println("ݿ: " + dataBaseCol); + String colValue = result.getString(dataBaseCol); + if (dataBaseCol.equals("RWXDSJ") || dataBaseCol.equals("RWZPSJ") + || dataBaseCol.equals("SJWCSJ") || dataBaseCol.equals("JHKS") + || dataBaseCol.equals("JHJS")) { + rowMap.put(colName,(colValue == null || colValue.isEmpty())?"":colValue.substring(0, 10)); + } else { + rowMap.put(colName, colValue); + } + } + } else { + rowMap.put(colName, "/"); + } + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + if (conn != null) { + conn.close(); + } + + map.put(i++, rowMap); + } + System.out.println("map : " + map.toString()); + return map; + } + + // ȡݿ + public static Connection getConn() { + Connection conn = null; + try { + conn = DbPool.getConnection(dateConnList.get(0), dateConnList.get(1)); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return conn; + } + + public String validateAndFormatDate(String input, boolean fou) { + // ڸʽ + DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.S"); + DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + + try { + // Խʱַ + LocalDateTime dateTime = LocalDateTime.parse(input, inputFormatter); + + // תΪֻڵLocalDate + LocalDate date = dateTime.toLocalDate(); + if (date != null && fou) { + return "/"; + } + // ʽΪַ + return date.format(outputFormatter); + } catch (DateTimeParseException e) { + // ʧܣ˵벻ָʽԭʼַ + return input; + } + } + +// // ԶȾ +// static class CustomColorRenderer extends DefaultTableCellRenderer { +// public LinkedHashMap>>> valueMap; +// public LinkedHashMap colorMap; +// +// +// @Override +// public Component getTableCellRendererComponent(JTable table, Object value, +// boolean isSelected, boolean hasFocus, +// int row, int column) { +// // ø෽ȡĬȾ +// Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); +// +// String id = (String)table.getValueAt(row, 1); +// LinkedHashMap>> linkedHashMap = valueMap.get(id); +// System.out.println("colorMap======"+colorMap.toString()); +// for (Entry map : colorMap.entrySet()) { +// Integer columnColor = map.getKey(); +// if(column == 4 && row == 1) { +// System.out.println("columnColor========"+columnColor); +// String prefValue = map.getValue(); +// String[] split = prefValue.split("\\."); +// ArrayList> arrayList = linkedHashMap.get(split[0]); +// String sjwcsj = ""; +// String jhks = ""; +// String jhjs = ""; +// +// for (int i = 0; i < arrayList.size(); i++) { +// +// if(arrayList.get(i).containsKey("SJWCSJ")) { +// sjwcsj = arrayList.get(i).get("SJWCSJ"); +// } +// if(arrayList.get(i).containsKey("JHKS")) { +// jhks = arrayList.get(i).get("JHKS"); +// } +// if(arrayList.get(i).containsKey("JHJS")) { +// jhjs = arrayList.get(i).get("JHJS"); +// } +// } +// System.out.println("sjwcsj========"+sjwcsj); +// System.out.println("jhks========"+jhks); +// System.out.println("jhjs========"+jhjs); +// if(sjwcsj != null && !sjwcsj.isEmpty()) { +// c.setBackground(Color.GREEN); +// }else { +// if(jhjs != null && !jhjs.isEmpty() && jhks != null && !jhks.isEmpty()) { +// if(isNotAfterCurrentDate(jhjs)) { +// c.setBackground(Color.RED); +// +// +// System.out.println("row==="+row+"===column==="+column); +// }else { +// //setBackground(Color.YELLOW); +// c.setBackground(Color.YELLOW); +// } +// } +// } +// } +// +// } +// +// +// return c; +// } +// } +// + + public void dgRW(LinkedHashMap>> linkedHashMap, String xhs, + ArrayList judgeList) { + + if (xhs.contains(",")) { + String[] split = xhs.split(","); + for (int z = 0; z < split.length; z++) { + + ArrayList> arrayList = linkedHashMap.get(split[z]); + String SJWCSJ = ""; + String SFSJGG = ""; + String QQRW = ""; + for (int i = 0; i < arrayList.size(); i++) { + + if (arrayList.get(i).containsKey("SFSJGG")) { + SFSJGG = arrayList.get(i).get("SFSJGG"); + } + if (arrayList.get(i).containsKey("SJWCSJ")) { + SJWCSJ = arrayList.get(i).get("SJWCSJ"); + } + if (arrayList.get(i).containsKey("QQRW")) { + QQRW = arrayList.get(i).get("QQRW"); + } + + } + System.out.println("---SJWCSJ=======" + SFSJGG); + System.out.println("---SFSJGG=======" + SFSJGG); + System.out.println("---QQRW=======" + SFSJGG); + if (SFSJGG != null && !SFSJGG.isEmpty() && SFSJGG.equals("")) { + if (SJWCSJ == null || SJWCSJ.isEmpty()) { + judgeList.add(0); + } + } else if (SFSJGG != null && !SFSJGG.isEmpty() && SFSJGG.equals("") && QQRW != null + && !QQRW.isEmpty()) { + dgRW(linkedHashMap, QQRW, judgeList); + } + + } + } else { + ArrayList> arrayList = linkedHashMap.get(xhs); + String SJWCSJ = ""; + String SFSJGG = ""; + String QQRW = ""; + for (int i = 0; i < arrayList.size(); i++) { + + if (arrayList.get(i).containsKey("SFSJGG")) { + SFSJGG = arrayList.get(i).get("SFSJGG"); + } + if (arrayList.get(i).containsKey("SJWCSJ")) { + SJWCSJ = arrayList.get(i).get("SJWCSJ"); + } + if (arrayList.get(i).containsKey("QQRW")) { + QQRW = arrayList.get(i).get("QQRW"); + } + + } + System.out.println("---SJWCSJ=======" + SJWCSJ); + System.out.println("---SFSJGG=======" + SFSJGG); + System.out.println("---QQRW=======" + QQRW); + if (SFSJGG != null && !SFSJGG.isEmpty() && SFSJGG.equals("")) { + if (SJWCSJ == null || SJWCSJ.isEmpty()) { + judgeList.add(0); + } + } else if (SFSJGG != null && !SFSJGG.isEmpty() && SFSJGG.equals("") && QQRW != null && !QQRW.isEmpty()) { + dgRW(linkedHashMap, QQRW, judgeList); + } + } + } + + public void CreateProcess(TCSession session, TCComponent target, String processName, String rwmc, String xh, + String id) throws TCException { + try { + TCComponentProcessType processType = (TCComponentProcessType) session.getTypeComponent("Job"); + TCComponentTaskTemplateType taskTemplateType = (TCComponentTaskTemplateType) session + .getTypeComponent("EPMTaskTemplate"); + TCComponentTaskTemplate taskTemplate = taskTemplateType.find(processName, 0); + if (taskTemplate != null) { + String name = target.getProperty("object_string"); + TCComponent create = processType.create(processName + "" + name + "_" + rwmc, "", taskTemplate, + new TCComponent[] { target }, new int[] { 1 }); + // System.out.println("uid===================" + create.getUid()); + // System.out.println("type==" + create.getType()); + // System.out.println("type==" + create.getStringProperty("object_type")); + + String updateSql = "update LY_CHANGETASSKFORM_DETAILS set WFUID = '" + create.getUid() + + "' where ID = '" + id + "' and XH = '" + xh + "'"; + try { + PreparedStatement prepareStatement = conn.prepareStatement(updateSql); + boolean execute = prepareStatement.execute(); + System.out.println("execute==" + execute + "|updateSql====" + updateSql); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } catch (TCException var7) { + var7.printStackTrace(); + throw var7; + } + } + + public void DJCreateProcess(TCSession session, TCComponent target, String processName) throws TCException { + try { + TCComponentProcessType processType = (TCComponentProcessType) session.getTypeComponent("Job"); + TCComponentTaskTemplateType taskTemplateType = (TCComponentTaskTemplateType) session + .getTypeComponent("EPMTaskTemplate"); + TCComponentTaskTemplate taskTemplate = taskTemplateType.find(processName, 0); + if (taskTemplate != null) { + String name = target.getProperty("object_string"); + TCComponent create = processType.create(processName + "" + name, "", taskTemplate, + new TCComponent[] { target }, new int[] { 1 }); + } + } catch (TCException var7) { + var7.printStackTrace(); + throw var7; + } + } + + public static TCComponent[] getTCComponentsById(TCSession session, String id) throws Exception { + return session.search("...", new String[] { " ID" }, new String[] { id }); + } + + private String dealExcel(File datasetFile, TCComponentItemRevision revision, HashMap nameMap, + ArrayList>> bgMap) throws IOException, TCException { + FileInputStream is = new FileInputStream(datasetFile); + HSSFWorkbook workbook = new HSSFWorkbook(is); + List allNames = workbook.getAllNames(); + for (HSSFName hssfName : allNames) { + String name = hssfName.getNameName(); + // ƹѡ + if (nameMap.containsKey(name)) { + CellReference cellReference = new CellReference(hssfName.getRefersToFormula()); + HSSFSheet sheet = workbook.getSheet(cellReference.getSheetName()); + HSSFRow row = sheet.getRow(cellReference.getRow()); + HSSFCell cell = row.getCell(cellReference.getCol()); + String preConfigValue = ""; + System.out.println("nameMap.get(name)===========" + nameMap.get(name)); + if (nameMap.get(name).contains("RevMaster") || nameMap.get(name).contains("Item") + || nameMap.get(name).contains("Rev")) { + preConfigValue = getPreConfigValue(revision, nameMap, nameMap.get(name)); + } else { + String[] split = nameMap.get(name).split("\\."); + for (int i = 0; i < bgMap.size(); i++) { + LinkedHashMap> linkedHashMap = bgMap.get(i); + if (linkedHashMap.containsKey(split[0])) { + LinkedHashMap maps = linkedHashMap.get(split[0]); + preConfigValue = maps.get(split[1]) == null ? "" : maps.get(split[1]); + } + } + } + + preConfigValue = formatDateString(preConfigValue); + System.out.println("Ϊ" + cellReference.getRow() + "====" + "Ϊ" + cellReference.getCol() + "====" + + "ֵΪ " + preConfigValue); + if (cell == null) { + cell = row.createCell(cellReference.getCol()); + } + cell.setCellValue(preConfigValue); + + } + } + is.close(); + FileOutputStream os = new FileOutputStream(datasetFile); + workbook.write(os); + workbook.close(); + return datasetFile.getAbsolutePath(); + } + + private String dealExcelX(File datasetFile, TCComponentItemRevision revision, HashMap nameMap, + ArrayList>> bgMap) throws IOException, TCException { + FileInputStream is = new FileInputStream(datasetFile); + XSSFWorkbook workbook = new XSSFWorkbook(is); + List allNames = workbook.getAllNames(); + for (XSSFName xssfName : allNames) { + String name = xssfName.getNameName(); + // ƹѡ + if (nameMap.containsKey(name)) { + CellReference cellReference = new CellReference(xssfName.getRefersToFormula()); + XSSFSheet sheet = workbook.getSheet(cellReference.getSheetName()); + XSSFRow row = sheet.getRow(cellReference.getRow()); + XSSFCell cell = row.getCell(cellReference.getCol()); + + String preConfigValue = ""; + System.out.println("nameMap.get(name)===========" + nameMap.get(name)); + if (nameMap.get(name).contains("RevMaster") || nameMap.get(name).contains("Item") + || nameMap.get(name).contains("Rev")) { + preConfigValue = getPreConfigValue(revision, nameMap, nameMap.get(name)); + } else { + String[] split = nameMap.get(name).split("\\."); + for (int i = 0; i < bgMap.size(); i++) { + LinkedHashMap> linkedHashMap = bgMap.get(i); + if (linkedHashMap.containsKey(split[0])) { + LinkedHashMap maps = linkedHashMap.get(split[0]); + preConfigValue = maps.get(split[1]) == null ? "" : maps.get(split[1]); + } + } + } + + preConfigValue = formatDateString(preConfigValue); + System.out.println("Ϊ" + cellReference.getRow() + "====" + "Ϊ" + cellReference.getCol() + "====" + + "ֵΪ " + preConfigValue); + if (cell == null) { + cell = row.createCell(cellReference.getCol()); + cell.setCellValue(preConfigValue); + } else { + cell.setCellValue(preConfigValue); + } + } + } + is.close(); + FileOutputStream os = new FileOutputStream(datasetFile); + workbook.write(os); + workbook.close(); + return datasetFile.getAbsolutePath(); + } + + private String getPreConfigValue(TCComponentItemRevision revision, HashMap nameMap, String value) + throws TCException { + String[] split = value.split("\\."); + String cellValue = ""; + TCProperty property = null; + if (split.length == 2) { + switch (split[0]) { + case "Item": + property = revision.getItem().getTCProperty(split[1]); + break; + case "Rev": + property = revision.getTCProperty(split[1]); + break; + case "RevMaster": + property = revision.getRelatedComponent("IMAN_master_form_rev").getTCProperty(split[1]); + break; + default: + break; + } + } + // ȡϵļµ + else if (split.length == 3) { + String relation = split[0]; + TCComponent relatedComponent = revision.getRelatedComponent(relation); + TCComponentItemRevision centerRev = null; + if (relatedComponent instanceof TCComponentItemRevision) { + centerRev = (TCComponentItemRevision) relatedComponent; + } else if (relatedComponent instanceof TCComponentItem) { + centerRev = ((TCComponentItem) relatedComponent).getLatestItemRevision(); + } + if (centerRev != null) { + switch (split[1]) { + case "Item": + property = centerRev.getItem().getTCProperty(split[2]); + break; + case "Rev": + property = centerRev.getTCProperty(split[2]); + break; + case "RevMaster": + property = centerRev.getRelatedComponent("IMAN_master_form_rev").getTCProperty(split[2]); + break; + default: + break; + } + } + } + if (property == null) { + return ""; + } else { + cellValue = property.getDisplayValue(); + cellValue = formatDateString(cellValue); + return cellValue; + } + } + + public static String formatDateString(String input) { + // ֿܵʱʽ + // yyyy-MM-dd HH:mm:ss.S + SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + SimpleDateFormat format3 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S"); + // Ŀʽ + SimpleDateFormat targetFormat = new SimpleDateFormat("yyyy-MM-dd"); + + try { + // Խһָʽ + Date date = format1.parse(input); + // ɹĿʽַ + return targetFormat.format(date); + } catch (ParseException e1) { + try { + // Խڶָʽ + Date date = format2.parse(input); + // ɹĿʽַ + return targetFormat.format(date); + } catch (ParseException e2) { + try { + // Խڶָʽ + Date date = format3.parse(input); + // ɹĿʽַ + return targetFormat.format(date); + } catch (ParseException e3) { + // ָʽƥ䣬ԭʼַ + return input; + } + } + } + } + +} \ No newline at end of file diff --git a/src/com/langtech/plm/bg/QDRWHandler.java b/src/com/langtech/plm/bg/QDRWHandler.java new file mode 100644 index 0000000..d71c07b --- /dev/null +++ b/src/com/langtech/plm/bg/QDRWHandler.java @@ -0,0 +1,50 @@ +package com.langtech.plm.bg; + +import javax.swing.SwingUtilities; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.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 QDRWHandler extends AbstractHandler { + + private AbstractAIFUIApplication app; + private TCSession session; +// private InterfaceAIFComponent target; + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + app = AIFUtility.getCurrentApplication(); + session = (TCSession) app.getSession(); + String[] templates = session.getPreferenceService().getStringValues("Connor_TaskFormSummary_Config"); + if(templates != null && templates.length > 0) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + try { + new QDRWChooseDialog(templates,app); + //d.setModal(true); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + }else { + MessageBox.post("ѡConnor_TaskFormSummary_Config", "ʾ ", MessageBox.INFORMATION); + } + + + return null; + } + +} diff --git a/src/com/langtech/plm/bg/QDRWRWFPDialog.java b/src/com/langtech/plm/bg/QDRWRWFPDialog.java new file mode 100644 index 0000000..97470f6 --- /dev/null +++ b/src/com/langtech/plm/bg/QDRWRWFPDialog.java @@ -0,0 +1,639 @@ +package com.langtech.plm.bg; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.Vector; + +import javax.swing.BorderFactory; +import javax.swing.DefaultCellEditor; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.ListSelectionModel; +import javax.swing.RowSorter; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableColumnModel; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; + +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + + +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.soa.client.model.LovValue; + +import k.util.KOrgDialog; + +public class QDRWRWFPDialog extends JFrame implements ActionListener { + + private Map textMap = new HashMap<>(); + private TCSession session; + private JTable table; + private String[] header; + private ArrayList gsPrefTopLine; + private LinkedHashMap gsPrefMap = new LinkedHashMap(); + private LinkedHashMap fieldsMap = new LinkedHashMap(); + private LinkedHashMap cfdjPref = new LinkedHashMap(); + private LinkedHashMap lovPositionMap = new LinkedHashMap(); + private LinkedHashMap positionFieldMap = new LinkedHashMap(); + private LinkedHashMap widtheMap = new LinkedHashMap(); + // public static final int[] HEADERWIDTH = new int[] { 50, 100, 200, 200, 100, + // 100, 80, 80, 100, 150, 150, 150, 150,150, 150, 150, 150, 150, 150 }; + private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + private DefaultTableModel dtm1; + private JButton yyButton = new JButton("Ӧ"); + private JButton gbButton = new JButton("ر"); + private JComboBox cfdJComboBox = new JComboBox(); + private DateButton cfsjButton; + private JButton tzsjButton = new JButton("ʱ"); + private static ArrayList dateConnList = new ArrayList(); + private String type; + private String id; + private String objectString; + private boolean readOnly; + private ArrayList canWriteColume = new ArrayList(); + private ArrayList choosePersonColume = new ArrayList(); + public QDRWRWFPDialog(TCSession session, String type, String id) { + // TODO Auto-generated constructor stub + this.session = session; + this.type = type; + this.id = id; + //this.objectString = objectString; + //this.readOnly = readOnly; + initUI(); + } + + public void initUI() { + // TODO Auto-generated method stub + + yyButton.setEnabled(false); + tzsjButton.setEnabled(false); + + this.setTitle(objectString+""); + this.setLayout(new BorderLayout()); + + String[] cfdj = session.getPreferenceService().getStringValues("Connor_ChangeTaskForm_TriggerLevelMapping"); + if (cfdj == null || cfdj.length <= 0) { + MessageBox.post("ѡConnor_ChangeTaskForm_TriggerLevelMapping", "ʾ ", MessageBox.INFORMATION); + return; + } + + for (int i = 0; i < cfdj.length; i++) { + + String[] split = cfdj[i].split("="); + if(split[0].equals(type)) { + String[] split2 = split[1].split(";"); + for (int j = 0; j < split2.length; j++) { + String[] split3 = split2[j].split("\\|"); + cfdjPref.put(split3[0],split3[1]); + cfdJComboBox.addItem(split3[0]); + } + break; + } + + } + + //ȡѡƥ + String[] fields = session.getPreferenceService().getStringValues("Connor_ECRECNForm_Datbase_Config"); + if (fields == null || fields.length <= 0) { + MessageBox.post("ѡConnor_ECRECNForm_Datbase_Config", "ʾ ", MessageBox.INFORMATION); + return; + } + + for (int i = 0; i < fields.length; i++) { + if(fields[i].contains(type)) { + String[] split = fields[i].split("\\|"); + if(split.length == 2) { + String[] split2 = split[1].split(";"); + for (int j = 0; j < split2.length; j++) { + String[] split3 = split2[j].split("="); + positionFieldMap.put(split3[0],j); + if(split3.length == 3) { + fieldsMap.put(split3[0],split3[1]); + if(split3[2].contains("%")) { + String[] split4 = split3[2].split("%"); + widtheMap.put(j, Integer.parseInt(split4[0])); + canWriteColume.add(j); + }else if(split3[2].contains("#")) { + String[] split4 = split3[2].split("#"); + widtheMap.put(j, Integer.parseInt(split4[0])); + choosePersonColume.add(j); + canWriteColume.add(j); + }else { + widtheMap.put(j, Integer.parseInt(split3[2])); + } + + }else if(split3.length == 4) { + fieldsMap.put(split3[0],split3[1]); + System.out.println("split3[2]========"+split3[2]); + if(split3[2].contains("%")) { + String[] split4 = split3[2].split("%"); + widtheMap.put(j, Integer.parseInt(split4[0])); + System.out.println("split4[0]========"+split4[0]); + canWriteColume.add(j); + }else if(split3[2].contains("#")) { + String[] split4 = split3[2].split("#"); + widtheMap.put(j, Integer.parseInt(split4[0])); + choosePersonColume.add(j); + canWriteColume.add(j); + }else { + widtheMap.put(j, Integer.parseInt(split3[2])); + } + lovPositionMap.put(j,split3[3]); + } + } + } + + } + } + System.out.println("choosePersonColume====="+choosePersonColume.size()); + System.out.println("canWriteColume====="+canWriteColume.size()); + System.out.println("fieldsMap====="+fieldsMap); + System.out.println("positionMap====="+lovPositionMap); + System.out.println("widtheMap====="+widtheMap); + if(fieldsMap.size() == 0) { + + MessageBox.post("δƥ䵽ѡ", "ʾ ", MessageBox.INFORMATION); + return; + } + Collection valuesCollection = fieldsMap.values(); + + // תΪ + header = valuesCollection.toArray(new String[0]); + + JPanel topPanel = getTopPanel(); + + JScrollPane pane = getTablePanel(); + pane.setBorder(BorderFactory.createTitledBorder("")); +// JPanel btnPanel = getRightPanel(); + + JPanel bottomPane = getBottomPanel(); + this.add(topPanel, BorderLayout.NORTH); + this.add(pane, BorderLayout.CENTER); + this.add(bottomPane, BorderLayout.SOUTH); + this.createActionEvent(); + this.pack(); + this.setPreferredSize(new Dimension(1850, 1000)); + this.validate(); + this.setVisible(true); + // ôĻ +// Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize(); +// int x = (int) screensize.getWidth() / 2 - window.getWidth() / 2; +// int y = (int) screensize.getHeight() / 2 - window.getHeight() / 2; + this.setLocationRelativeTo(null); + + //п + TableColumnModel colModel = table.getColumnModel(); + for (Entry map : widtheMap.entrySet()) { + colModel.getColumn(map.getKey()).setPreferredWidth(map.getValue()); + } + + + + + String[] value = session.getPreferenceService().getStringValues("LD_dbinfo2"); + + if (value == null || value.length == 0) { + MessageBox.post("ѡLD_dbinfo2顣", "ʾ", 2); + return; + } else { + Collections.addAll(dateConnList, value); + } + + Set keySet = fieldsMap.keySet(); + String fieldsSql = ""; + for (String string : keySet) { + fieldsSql += string + ","; + } + fieldsSql = fieldsSql.substring(0, fieldsSql.length() - 1); + System.out.println("fieldsSql=========="+fieldsSql); + String sqlString = "SELECT " + fieldsSql + " FROM LY_CHANGETASSKFORM_DETAILS where ID='" + id + "' ORDER BY XH ASC"; + System.out.println(sqlString); + Connection conn = getConn(); + PreparedStatement stmt = null; + try{ + stmt = conn.prepareStatement(sqlString); + ResultSet result = stmt.executeQuery(); + while (result.next()) { + ArrayList arList = new ArrayList(); + for (int i = 0; i < fieldsMap.size(); i++) { + //System.out.println("result.getString(i+1)==========="+result.getString(i+1)); + arList.add(result.getString(i+1) == null? result.getString(i+1) : validateAndFormatDate(result.getString(i+1))); + } + dtm1.addRow(arList.toArray(new Object[0])); + } + + } catch (SQLException e1) { + e1.printStackTrace(); + } + + try { + if(stmt != null) { + stmt.close(); + } + if(conn != null) { + conn.close(); + } + + + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public void createActionEvent() { + this.yyButton.addActionListener(this); + this.gbButton.addActionListener(this); + this.tzsjButton.addActionListener(this); + } + + // ѯ + private JPanel getTopPanel() { + // TODO Auto-generated method stub + JPanel topPanel = new JPanel(); + topPanel.setLayout(new PropertyLayout()); + + topPanel.add("1.1.left.center", new JLabel("ȼ ")); + topPanel.add("1.2.left.center", cfdJComboBox); + topPanel.add("1.3.left.center", new JLabel(" ʱ ")); + + cfsjButton = new DateButton(null, "yyyy-MM-dd", false, false, false); + cfsjButton.setDate("δ"); + + topPanel.add("1.4.left.center", cfsjButton); + topPanel.add("1.5.left.center", new JLabel(" ")); + topPanel.add("1.6.left.center", tzsjButton); + topPanel.add("2.1.left.center", new JLabel(" ")); + return topPanel; + } + + // ѯ + private JPanel getBottomPanel() { + // TODO Auto-generated method stub + JPanel bottomPanel = new JPanel(); + bottomPanel.setLayout(new PropertyLayout()); + bottomPanel.add("1.1.left.center", new JLabel(" ")); + bottomPanel.add("1.2.left.center", yyButton); + bottomPanel.add("1.3.left.center", new JLabel(" ")); + bottomPanel.add("1.4.left.center", gbButton); + return bottomPanel; + } + + private JScrollPane getTablePanel() { + // TODO Auto-generated method stub + table = getjTable(null, null, header, null, false); + table.setRowHeight(30); +// table.setPreferredSize(new Dimension(1500,400)); + table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // ñԶģʽΪرԶ +// table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);//JTableпбݵĴСе +// table.setPreferredSize(new Dimension(1200,400)); + JScrollPane pane = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, + JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + for (Entry map : lovPositionMap.entrySet()) { + JComboBox jComboBox = new JComboBox(); + String value = map.getValue(); + if (value.contains(",")) { + String[] split = value.split(","); + for (int i = 0; i < split.length; i++) { + jComboBox.addItem(split[i]); + } + } else { + jComboBox.addItem(value); + } + table.getColumnModel().getColumn(map.getKey()).setCellEditor(new DefaultCellEditor(jComboBox)); + } + table.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() == 2 || e.getClickCount() == 1) { // жǷ˫ڵڶ + int row = table.rowAtPoint(e.getPoint()); + int column = table.columnAtPoint(e.getPoint()); + System.out.println("column========"+column); + if (choosePersonColume.contains(column)) { + System.out.println("1111111111111111111111111111111"); + try { + TCComponentUser user = new KOrgDialog("").getUser(); + System.out.println("user============"+user.getUserName()); + table.setValueAt(user.getUserName()+"("+user.getUserId()+")", row, column); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } + } + }); + + pane.setPreferredSize(new Dimension(1800, 850)); + pane.setViewportView(table);// ΪscrollPaneָʾΪtable + return pane; + } + + /*** + * Jtableͨ÷ + * + * @param partsTable + * @param dtm + * @param titleNames + * @param values + * @return + */ + public JTable getjTable(JTable partsTable, DefaultTableModel dtm, Object[] titleNames, Object[][] values, + Boolean isTable2) { +// int simpleLen = 100; +// int totleLen = 1000; + if (partsTable == null) { + partsTable = new JTable(this.getTableModel(dtm, titleNames, values)); + partsTable.setRowHeight(20); + partsTable.getTableHeader().setReorderingAllowed(false); + partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + RowSorter sorter = new TableRowSorter(partsTable.getModel()); + partsTable.setRowSorter(sorter); +// for (int i = 0; i < titleNames.length; i++) { +// if(i==2) { +// partsTable.getColumnModel().getColumn(i).setPreferredWidth(200); +// }else { +// partsTable.getColumnModel().getColumn(i).setPreferredWidth(120); +// } +// +// } + + } + return partsTable; + } + + public DefaultTableModel getTableModel(DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + + dtm1 = null; + if (dtm == null) { + dtm1 = new DefaultTableModel(values, titleNames) { + @Override + public boolean isCellEditable(int row, int column) { + if (canWriteColume.size() > 0) { + for (int i = 0; i < canWriteColume.size(); i++) { + if (canWriteColume.get(i) == column) { + return true; + } + } + } + return false; + + } + }; + } + return dtm1; + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + System.out.println("source==>+" + source); + + if (source.equals(this.gbButton)) { + dispose(); + } else if (source.equals(this.yyButton)) { + // + Connection conn = getConn(); + PreparedStatement stmt = null; + + //һжǷ漰 + Integer sfsjgg = positionFieldMap.get("SFSJGG"); + for (int i = 0; i < table.getRowCount(); i++) { + String valueAt = (String)table.getValueAt(i, sfsjgg); + System.out.println("valueAt============="+valueAt); + if(valueAt == null || valueAt.isEmpty()) { + int row = i+1; + MessageBox.post(""+row+"еǷ漰δд", "ʾ", 2); + return; + } + } + + for (int i = 0; i < table.getRowCount(); i++) { + StringBuilder updateSql = new StringBuilder(); + updateSql.append("update LY_CHANGETASSKFORM_DETAILS set "); + for (Entry map : positionFieldMap.entrySet()) { + updateSql.append(map.getKey()); + String valueAt = (String) table.getValueAt(i, map.getValue()); + if (valueAt == null || valueAt.isEmpty()) { + updateSql.append("="); + updateSql.append("null,"); + } else { + updateSql.append("='"); + updateSql.append(table.getValueAt(i, map.getValue())); + updateSql.append("',"); + } + } + // ȥһ, + updateSql.deleteCharAt(updateSql.length() - 1); + updateSql.append(" where ID='" + id + "' and XH='" + table.getValueAt(i, 0) + "'"); + try { + stmt = conn.prepareStatement(updateSql.toString()); + System.out.println("updateSql=========" + updateSql.toString()); + stmt.execute(); + } catch (SQLException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + } + + try { + if (stmt != null) { + stmt.close(); + } + if (conn != null) { + conn.close(); + } + + } catch (SQLException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + MessageBox.post("Ӧɣ", "ʾ", 2); + } else if (source.equals(this.tzsjButton)) { + gsPrefTopLine = new ArrayList(); + String selectedItem = (String) cfdJComboBox.getSelectedItem(); + if (selectedItem == null || selectedItem.isEmpty()) { + MessageBox.post("ѡ񴥷ȼ", "ʾ", 2); + return; + } + + Date date = cfsjButton.getDate(); + + if (date == null) { + MessageBox.post("ѡ񴥷ʱ䣡", "ʾ", 2); + return; + } + String cfsjDate = dateFormat.format(date); + String pref = cfdjPref.get(selectedItem); + if (pref == null || pref.isEmpty()) { + MessageBox.post("δôȼصѡ", "ʾ", 2); + return; + } + + String[] calculateTime = session.getPreferenceService().getStringValues(pref); + if (calculateTime == null || calculateTime.length <= 0) { + MessageBox.post("ѡ" + pref + "", "ʾ ", MessageBox.INFORMATION); + return; + } + + for (int i = 0; i < calculateTime.length; i++) { + String[] split = calculateTime[i].split("\\|"); + if (i == 0) { + + for (int j = 0; j < split.length; j++) { + gsPrefTopLine.add(split[j]); + } + } else { + gsPrefMap.put(split[0], calculateTime[i]); + } + + } + + System.out.println(positionFieldMap + "==================positionFieldMap"); + System.out.println("gsPrefTopLine----------------" + gsPrefTopLine.size()); + Integer xh = positionFieldMap.get(gsPrefTopLine.get(0)); + // table ʼ + for (int i = 0; i < table.getRowCount(); i++) { + String xhStr = table.getValueAt(i, xh).toString(); + String gsStr = gsPrefMap.get(xhStr); + if (gsStr != null && !gsStr.isEmpty()) { + String[] split = gsStr.split("\\|"); + for (int j = 1; j < gsPrefTopLine.size(); j++) { + // ֵ + System.out.println("gsPrefTopLine.get(j)========" + gsPrefTopLine.get(j)); + Integer colume = positionFieldMap.get(gsPrefTopLine.get(j)); + if (colume != null) { + System.out.println(positionFieldMap.get(gsPrefTopLine.get(j)) + + "=================positionFieldMap.get(gsPrefTopLine.get(j))"); + // ʽ + String gs = split[j]; + System.out.println("gs========" + gs); + if (gs.equals("N")) { + table.setValueAt(cfsjDate, i, colume); + } else { + String[] split2 = gs.split("N"); + String time = calculateDate(cfsjDate, Integer.parseInt(split2[1])); + System.out.println("time============" + time); + table.setValueAt(time, i, colume); + } + } + + } + } + + } + // Ӧðť + yyButton.doClick(); + MessageBox.post("ʱɣ", "ʾ", 2); + } + + } + + // ȡݿ + public static Connection getConn() { + Connection conn = null; + try { + conn = DbPool.getConnection(dateConnList.get(0), dateConnList.get(1)); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return conn; + } + + public static String calculateDate(String dateString, int daysToAdd) { + // ڸʽ + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + + // ַ + LocalDate date; + try { + date = LocalDate.parse(dateString, formatter); + } catch (DateTimeParseException e) { + throw new IllegalArgumentException("Invalid date format. Please use yyyy-MM-dd.", e); + } + + // ӻ + LocalDate resultDate = date.plusDays(daysToAdd); + + // ʽΪַ + return resultDate.format(formatter); + } + + public String validateAndFormatDate(String input) { + // ڸʽ + DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.S"); + DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + + try { + // Խʱַ + LocalDateTime dateTime = LocalDateTime.parse(input, inputFormatter); + + // תΪֻڵLocalDate + LocalDate date = dateTime.toLocalDate(); + + // ʽΪַ + return date.format(outputFormatter); + } catch (DateTimeParseException e) { + // ʧܣ˵벻ָʽԭʼַ + return input; + } + } + +} \ No newline at end of file diff --git a/src/com/langtech/plm/bg/QDRWTableColorRender.java b/src/com/langtech/plm/bg/QDRWTableColorRender.java new file mode 100644 index 0000000..e02f662 --- /dev/null +++ b/src/com/langtech/plm/bg/QDRWTableColorRender.java @@ -0,0 +1,105 @@ +package com.langtech.plm.bg; + +import java.awt.Color; +import java.awt.Component; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.Map.Entry; + +import javax.swing.JTable; + + +public class QDRWTableColorRender extends TableColorRender { + public LinkedHashMap>>> valueMap; + public LinkedHashMap colorMap; + + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + Component renderer = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + + + String id = (String)table.getValueAt(row, 1); + LinkedHashMap>> linkedHashMap = valueMap.get(id); + //System.out.println("colorMap======"+colorMap.toString()); + for (Entry map : colorMap.entrySet()) { + Integer columnColor = map.getKey(); + if(column == columnColor) { + //System.out.println("columnColor========"+columnColor); + String prefValue = map.getValue(); + String[] split = prefValue.split("\\."); + ArrayList> arrayList = linkedHashMap.get(split[0]); + String sjwcsj = ""; + String RWXDSJ = ""; + String jhjs = ""; + String sfsjgg = ""; + for (int i = 0; i < arrayList.size(); i++) { + + if(arrayList.get(i).containsKey("SJWCSJ")) { + sjwcsj = arrayList.get(i).get("SJWCSJ"); + } + if(arrayList.get(i).containsKey("RWXDSJ")) { + RWXDSJ = arrayList.get(i).get("RWXDSJ"); + } + if(arrayList.get(i).containsKey("JHJS")) { + jhjs = arrayList.get(i).get("JHJS"); + } + + if(arrayList.get(i).containsKey("SFSJGG")) { + sfsjgg = arrayList.get(i).get("SFSJGG"); + } + } + //System.out.println("sjwcsj========"+sjwcsj); + //System.out.println("jhks========"+jhks); + //System.out.println("jhjs========"+jhjs); + + if(sfsjgg != null && sfsjgg.equals("")) { + if(sjwcsj != null && !sjwcsj.isEmpty()) { + renderer.setBackground(Color.GREEN); + }else { + if(jhjs != null && !jhjs.isEmpty() && RWXDSJ != null && !RWXDSJ.isEmpty()) { + if(isNotAfterCurrentDate(jhjs)) { + renderer.setBackground(Color.RED); + + + // System.out.println("row==="+row+"===column==="+column); + }else { + //setBackground(Color.YELLOW); + renderer.setBackground(Color.GRAY); + } + } + } + }else if(sfsjgg != null && sfsjgg.equals("")) { + renderer.setBackground(Color.GREEN); + } + + + + } + + } + return renderer; + } + + + public static boolean isNotAfterCurrentDate(String dateStr) { + // ڸʽ + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + + try { + // ַΪ LocalDate + LocalDate inputDate = LocalDate.parse(dateStr, formatter); + // ȡǰ + LocalDate currentDate = LocalDate.now(); + + // Ƚ + return !inputDate.isAfter(currentDate); // true <= ǰ + + } catch (DateTimeParseException e) { + // 쳣 + System.out.println("Invalid date format: " + e.getMessage()); + return false; // Ҳѡ׳쳣߸ + } + } +} \ No newline at end of file diff --git a/src/com/langtech/plm/bg/RWFPDialog.java b/src/com/langtech/plm/bg/RWFPDialog.java new file mode 100644 index 0000000..a748e5b --- /dev/null +++ b/src/com/langtech/plm/bg/RWFPDialog.java @@ -0,0 +1,1060 @@ +package com.langtech.plm.bg; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.text.DecimalFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.Vector; + +import javax.swing.BorderFactory; +import javax.swing.DefaultCellEditor; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.ListSelectionModel; +import javax.swing.RowSorter; +import javax.swing.event.TableModelEvent; +import javax.swing.event.TableModelListener; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableColumnModel; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; + +import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.hssf.usermodel.HSSFName; +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.util.CellReference; +import org.apache.poi.xssf.usermodel.XSSFCell; +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.langtech.plm.tqsx.KUtil; +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.soa.client.model.LovValue; + +import k.util.KOrgDialog; + +public class RWFPDialog extends JFrame implements ActionListener { + + private Map textMap = new HashMap<>(); + private TCSession session; + private JTable table; + private String[] header; + private ArrayList gsPrefTopLine; + private LinkedHashMap gsPrefMap = new LinkedHashMap(); + private LinkedHashMap fieldsMap = new LinkedHashMap(); + private LinkedHashMap cfdjPref = new LinkedHashMap(); + private LinkedHashMap lovPositionMap = new LinkedHashMap(); + private LinkedHashMap positionFieldMap = new LinkedHashMap(); + private LinkedHashMap widtheMap = new LinkedHashMap(); + // public static final int[] HEADERWIDTH = new int[] { 50, 100, 200, 200, 100, + // 100, 80, 80, 100, 150, 150, 150, 150,150, 150, 150, 150, 150, 150 }; + private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + private DefaultTableModel dtm1; + private JButton yyButton = new JButton("Ӧ"); + private JButton gbButton = new JButton("ر"); + private JComboBox cfdJComboBox = new JComboBox(); + private DateButton cfsjButton; + private JButton tzsjButton = new JButton("ʱ"); + private static ArrayList dateConnList = new ArrayList(); + private String type; + private String id; + private String objectString; + private boolean readOnly; + private ArrayList canWriteColume = new ArrayList(); + private ArrayList choosePersonColume = new ArrayList(); + private JButton excelButton = new JButton("дExcel"); + public RWFPDialog(TCSession session, String type, String id, String objectString, boolean readOnly) { + // TODO Auto-generated constructor stub + this.session = session; + this.type = type; + this.id = id; + this.objectString = objectString; + this.readOnly = readOnly; + initUI(); + } + + public void initUI() { + // TODO Auto-generated method stub + + if(readOnly) { + yyButton.setEnabled(false); + tzsjButton.setEnabled(false); + excelButton.setEnabled(false); + } + + this.setTitle(objectString+""); + this.setLayout(new BorderLayout()); + + String[] cfdj = session.getPreferenceService().getStringValues("Connor_ChangeTaskForm_TriggerLevelMapping"); + if (cfdj == null || cfdj.length <= 0) { + MessageBox.post("ѡConnor_ChangeTaskForm_TriggerLevelMapping", "ʾ ", MessageBox.INFORMATION); + return; + } + + for (int i = 0; i < cfdj.length; i++) { + + String[] split = cfdj[i].split("="); + if(split[0].equals(type)) { + String[] split2 = split[1].split(";"); + for (int j = 0; j < split2.length; j++) { + String[] split3 = split2[j].split("\\|"); + cfdjPref.put(split3[0],split3[1]); + cfdJComboBox.addItem(split3[0]); + } + break; + } + + } + + //ȡѡƥ + String[] fields = session.getPreferenceService().getStringValues("Connor_ECRECNForm_Datbase_Config"); + if (fields == null || fields.length <= 0) { + MessageBox.post("ѡConnor_ECRECNForm_Datbase_Config", "ʾ ", MessageBox.INFORMATION); + return; + } + + for (int i = 0; i < fields.length; i++) { + if(fields[i].contains(type)) { + String[] split = fields[i].split("\\|"); + if(split.length == 2) { + String[] split2 = split[1].split(";"); + for (int j = 0; j < split2.length; j++) { + String[] split3 = split2[j].split("="); + positionFieldMap.put(split3[0],j); + if(split3.length == 3) { + fieldsMap.put(split3[0],split3[1]); + if(split3[2].contains("%")) { + String[] split4 = split3[2].split("%"); + widtheMap.put(j, Integer.parseInt(split4[0])); + canWriteColume.add(j); + }else if(split3[2].contains("#")) { + String[] split4 = split3[2].split("#"); + widtheMap.put(j, Integer.parseInt(split4[0])); + choosePersonColume.add(j); + canWriteColume.add(j); + }else { + widtheMap.put(j, Integer.parseInt(split3[2])); + } + + }else if(split3.length == 4) { + fieldsMap.put(split3[0],split3[1]); + System.out.println("split3[2]========"+split3[2]); + if(split3[2].contains("%")) { + String[] split4 = split3[2].split("%"); + widtheMap.put(j, Integer.parseInt(split4[0])); + System.out.println("split4[0]========"+split4[0]); + canWriteColume.add(j); + }else if(split3[2].contains("#")) { + String[] split4 = split3[2].split("#"); + widtheMap.put(j, Integer.parseInt(split4[0])); + choosePersonColume.add(j); + canWriteColume.add(j); + }else { + widtheMap.put(j, Integer.parseInt(split3[2])); + } + lovPositionMap.put(j,split3[3]); + } + } + } + + } + } + System.out.println("choosePersonColume====="+choosePersonColume.size()); + System.out.println("canWriteColume====="+canWriteColume.size()); + System.out.println("fieldsMap====="+fieldsMap); + System.out.println("positionMap====="+lovPositionMap); + System.out.println("widtheMap====="+widtheMap); + if(fieldsMap.size() == 0) { + + MessageBox.post("δƥ䵽ѡ", "ʾ ", MessageBox.INFORMATION); + return; + } + Collection valuesCollection = fieldsMap.values(); + + // תΪ + header = valuesCollection.toArray(new String[0]); + + JPanel topPanel = getTopPanel(); + + JScrollPane pane = getTablePanel(); + pane.setBorder(BorderFactory.createTitledBorder("")); +// JPanel btnPanel = getRightPanel(); + + JPanel bottomPane = getBottomPanel(); + this.add(topPanel, BorderLayout.NORTH); + this.add(pane, BorderLayout.CENTER); + this.add(bottomPane, BorderLayout.SOUTH); + this.createActionEvent(); + this.pack(); + this.setPreferredSize(new Dimension(1850, 1000)); + this.validate(); + this.setVisible(true); + // ôĻ +// Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize(); +// int x = (int) screensize.getWidth() / 2 - window.getWidth() / 2; +// int y = (int) screensize.getHeight() / 2 - window.getHeight() / 2; + this.setLocationRelativeTo(null); + + //п + TableColumnModel colModel = table.getColumnModel(); + for (Entry map : widtheMap.entrySet()) { + colModel.getColumn(map.getKey()).setPreferredWidth(map.getValue()); + } + + + + + String[] value = session.getPreferenceService().getStringValues("LD_dbinfo2"); + + if (value == null || value.length == 0) { + MessageBox.post("ѡLD_dbinfo2顣", "ʾ", 2); + return; + } else { + Collections.addAll(dateConnList, value); + } + + Set keySet = fieldsMap.keySet(); + String fieldsSql = ""; + for (String string : keySet) { + fieldsSql += string + ","; + } + fieldsSql = fieldsSql.substring(0, fieldsSql.length() - 1); + System.out.println("fieldsSql=========="+fieldsSql); + String sqlString = "SELECT " + fieldsSql + " FROM LY_CHANGETASSKFORM_DETAILS where ID='" + id + "' ORDER BY XH ASC"; + System.out.println(sqlString); + Connection conn = getConn(); + PreparedStatement stmt = null; + try{ + stmt = conn.prepareStatement(sqlString); + ResultSet result = stmt.executeQuery(); + while (result.next()) { + ArrayList arList = new ArrayList(); + for (int i = 0; i < fieldsMap.size(); i++) { + //System.out.println("result.getString(i+1)==========="+result.getString(i+1)); + arList.add(result.getString(i+1) == null? result.getString(i+1) : validateAndFormatDate(result.getString(i+1))); + } + dtm1.addRow(arList.toArray(new Object[0])); + } + + } catch (SQLException e1) { + e1.printStackTrace(); + } + + try { + if(stmt != null) { + stmt.close(); + } + if(conn != null) { + conn.close(); + } + + + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public void createActionEvent() { + this.yyButton.addActionListener(this); + this.gbButton.addActionListener(this); + this.tzsjButton.addActionListener(this); + this.excelButton.addActionListener(this); + } + + // ѯ + private JPanel getTopPanel() { + // TODO Auto-generated method stub + JPanel topPanel = new JPanel(); + topPanel.setLayout(new PropertyLayout()); + + topPanel.add("1.1.left.center", new JLabel("ȼ ")); + topPanel.add("1.2.left.center", cfdJComboBox); + topPanel.add("1.3.left.center", new JLabel(" ʱ ")); + + cfsjButton = new DateButton(null, "yyyy-MM-dd", false, false, false); + cfsjButton.setDate("δ"); + + topPanel.add("1.4.left.center", cfsjButton); + topPanel.add("1.5.left.center", new JLabel(" ")); + topPanel.add("1.6.left.center", tzsjButton); + topPanel.add("2.1.left.center", new JLabel(" ")); + return topPanel; + } + + // ѯ + private JPanel getBottomPanel() { + // TODO Auto-generated method stub + JPanel bottomPanel = new JPanel(); + bottomPanel.setLayout(new PropertyLayout()); + bottomPanel.add("1.1.left.center", new JLabel(" ")); + bottomPanel.add("1.2.left.center", yyButton); + bottomPanel.add("1.3.left.center", new JLabel(" ")); + bottomPanel.add("1.4.left.center", gbButton); + bottomPanel.add("1.5.left.center", new JLabel(" ")); + bottomPanel.add("1.6.left.center", excelButton); + return bottomPanel; + } + + private JScrollPane getTablePanel() { + // TODO Auto-generated method stub + table = getjTable(null, null, header, null, false); + table.setRowHeight(30); +// table.setPreferredSize(new Dimension(1500,400)); + table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // ñԶģʽΪرԶ +// table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);//JTableпбݵĴСе +// table.setPreferredSize(new Dimension(1200,400)); + JScrollPane pane = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, + JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + for (Entry map : lovPositionMap.entrySet()) { + JComboBox jComboBox = new JComboBox(); + String value = map.getValue(); + if (value.contains(",")) { + String[] split = value.split(","); + for (int i = 0; i < split.length; i++) { + jComboBox.addItem(split[i]); + } + } else { + jComboBox.addItem(value); + } + table.getColumnModel().getColumn(map.getKey()).setCellEditor(new DefaultCellEditor(jComboBox)); + } + table.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() == 2 || e.getClickCount() == 1) { // жǷ˫ڵڶ + int row = table.rowAtPoint(e.getPoint()); + int column = table.columnAtPoint(e.getPoint()); + System.out.println("column========"+column); + if (choosePersonColume.contains(column)) { + System.out.println("1111111111111111111111111111111"); + try { + TCComponentUser user = new KOrgDialog("").getUser(); + System.out.println("user============"+user.getUserName()); + table.setValueAt(user.getUserName()+"("+user.getUserId()+")", row, column); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } + } + }); + + pane.setPreferredSize(new Dimension(1800, 850)); + pane.setViewportView(table);// ΪscrollPaneָʾΪtable + return pane; + } + + /*** + * Jtableͨ÷ + * + * @param partsTable + * @param dtm + * @param titleNames + * @param values + * @return + */ + public JTable getjTable(JTable partsTable, DefaultTableModel dtm, Object[] titleNames, Object[][] values, + Boolean isTable2) { +// int simpleLen = 100; +// int totleLen = 1000; + if (partsTable == null) { + partsTable = new JTable(this.getTableModel(dtm, titleNames, values)); + partsTable.setRowHeight(20); + partsTable.getTableHeader().setReorderingAllowed(false); + partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + RowSorter sorter = new TableRowSorter(partsTable.getModel()); + partsTable.setRowSorter(sorter); +// for (int i = 0; i < titleNames.length; i++) { +// if(i==2) { +// partsTable.getColumnModel().getColumn(i).setPreferredWidth(200); +// }else { +// partsTable.getColumnModel().getColumn(i).setPreferredWidth(120); +// } +// +// } + + } + return partsTable; + } + + public DefaultTableModel getTableModel(DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + + dtm1 = null; + if (dtm == null) { + dtm1 = new DefaultTableModel(values, titleNames) { + @Override + public boolean isCellEditable(int row, int column) { + if (canWriteColume.size() > 0) { + for (int i = 0; i < canWriteColume.size(); i++) { + if (canWriteColume.get(i) == column) { + return true; + } + } + } + return false; + + } + }; + } + return dtm1; + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + System.out.println("source==>+" + source); + + if (source.equals(this.gbButton)) { + dispose(); + } else if (source.equals(this.yyButton)) { + // + Connection conn = getConn(); + PreparedStatement stmt = null; + + //һжǷ漰 + Integer sfsjgg = positionFieldMap.get("SFSJGG"); + for (int i = 0; i < table.getRowCount(); i++) { + String valueAt = (String)table.getValueAt(i, sfsjgg); + System.out.println("valueAt============="+valueAt); + int row = i+1; + if(valueAt == null || valueAt.isEmpty()) { + + MessageBox.post(""+row+"еǷ漰δд", "ʾ", 2); + return; + }else { + if(valueAt.equals("")) { + Integer fzr = positionFieldMap.get("FZR"); + String fzrStr = (String)table.getValueAt(i, fzr); + if(fzrStr == null || fzrStr.equals("/") || fzrStr.isEmpty()) { + MessageBox.post(""+row+"иΪջΪ/棡", "ʾ", 2); + return; + } + }else if(valueAt.equals("")){ + Integer fzr = positionFieldMap.get("FZR"); + table.setValueAt("/", i, fzr); + } + } + } + + for (int i = 0; i < table.getRowCount(); i++) { + StringBuilder updateSql = new StringBuilder(); + updateSql.append("update LY_CHANGETASSKFORM_DETAILS set "); + for (Entry map : positionFieldMap.entrySet()) { + updateSql.append(map.getKey()); + String valueAt = (String) table.getValueAt(i, map.getValue()); + if (valueAt == null || valueAt.isEmpty()) { + updateSql.append("="); + updateSql.append("null,"); + } else { + updateSql.append("='"); + updateSql.append(table.getValueAt(i, map.getValue())); + updateSql.append("',"); + } + } + // ȥһ, + updateSql.deleteCharAt(updateSql.length() - 1); + updateSql.append(" where ID='" + id + "' and XH='" + table.getValueAt(i, 0) + "'"); + try { + stmt = conn.prepareStatement(updateSql.toString()); + System.out.println("updateSql=========" + updateSql.toString()); + stmt.execute(); + } catch (SQLException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + } + + try { + if (stmt != null) { + stmt.close(); + } + if (conn != null) { + conn.close(); + } + + } catch (SQLException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + MessageBox.post("Ӧɣ", "ʾ", 2); + } else if (source.equals(this.tzsjButton)) { + gsPrefTopLine = new ArrayList(); + String selectedItem = (String) cfdJComboBox.getSelectedItem(); + if (selectedItem == null || selectedItem.isEmpty()) { + MessageBox.post("ѡ񴥷ȼ", "ʾ", 2); + return; + } + + Date date = cfsjButton.getDate(); + + if (date == null) { + MessageBox.post("ѡ񴥷ʱ䣡", "ʾ", 2); + return; + } + String cfsjDate = dateFormat.format(date); + String pref = cfdjPref.get(selectedItem); + if (pref == null || pref.isEmpty()) { + MessageBox.post("δôȼصѡ", "ʾ", 2); + return; + } + + String[] calculateTime = session.getPreferenceService().getStringValues(pref); + if (calculateTime == null || calculateTime.length <= 0) { + MessageBox.post("ѡ" + pref + "", "ʾ ", MessageBox.INFORMATION); + return; + } + + for (int i = 0; i < calculateTime.length; i++) { + String[] split = calculateTime[i].split("\\|"); + if (i == 0) { + + for (int j = 0; j < split.length; j++) { + gsPrefTopLine.add(split[j]); + } + } else { + gsPrefMap.put(split[0], calculateTime[i]); + } + + } + + System.out.println(positionFieldMap + "==================positionFieldMap"); + System.out.println("gsPrefTopLine----------------" + gsPrefTopLine.size()); + Integer xh = positionFieldMap.get(gsPrefTopLine.get(0)); + // table ʼ + for (int i = 0; i < table.getRowCount(); i++) { + String xhStr = table.getValueAt(i, xh).toString(); + String gsStr = gsPrefMap.get(xhStr); + if (gsStr != null && !gsStr.isEmpty()) { + String[] split = gsStr.split("\\|"); + for (int j = 1; j < gsPrefTopLine.size(); j++) { + // ֵ + System.out.println("gsPrefTopLine.get(j)========" + gsPrefTopLine.get(j)); + Integer colume = positionFieldMap.get(gsPrefTopLine.get(j)); + if (colume != null) { + System.out.println(positionFieldMap.get(gsPrefTopLine.get(j)) + + "=================positionFieldMap.get(gsPrefTopLine.get(j))"); + // ʽ + String gs = split[j]; + System.out.println("gs========" + gs); + if (gs.equals("N")) { + table.setValueAt(cfsjDate, i, colume); + } else { + String[] split2 = gs.split("N"); + String time = calculateDate(cfsjDate, Integer.parseInt(split2[1])); + System.out.println("time============" + time); + table.setValueAt(time, i, colume); + } + } + + } + } + + } + // Ӧðť + yyButton.doClick(); + MessageBox.post("ʱɣ", "ʾ", 2); + }else if (source.equals(this.excelButton)) { + + +// String[] names = session.getPreferenceService().getStringValues("Connor_ViewTaskForm_AttrToExcel"); +// if (names == null || names.length <= 0) { +// MessageBox.post("ѡConnor_ViewTaskForm_AttrToExcel", "ʾ ", MessageBox.INFORMATION); +// return; +// } + String[] names = session.getPreferenceService().getStringValues("Connor_ViewTaskForm_AttrToExcel"); + if (names == null || names.length <= 0) { + MessageBox.post("ѡConnor_ViewTaskForm_AttrToExcel", "ʾ ", MessageBox.INFORMATION); + return; + } + HashMap nameMap = new HashMap();// ݼƺͶ(item,rev,revMaster) + for (int i = 0; i < names.length; i++) { + // Item.object_name=object_name + String[] split = names[i].split("="); + nameMap.put(split[0], split[1]); + } + + TCComponentItemRevision rev = null; + LinkedHashMap rwfpFieldsMap = new LinkedHashMap(); + ArrayList>> bgMap = new ArrayList>>(); + try { + System.out.println("id=============" + id); + TCComponent[] tcComponentsById = getTCComponentsById(session, id); + + if (tcComponentsById != null && tcComponentsById.length > 0) { + System.out.println("tcComponentsById.length=============" + tcComponentsById.length); + TCComponentItem item = (TCComponentItem) tcComponentsById[0]; + rev = item.getLatestItemRevision(); + + // ȡ汾µݼ + TCComponent[] relatedComponents = rev.getRelatedComponents("IMAN_specification"); + if (relatedComponents == null || relatedComponents.length == 0) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ѡж IMAN_specificationϵûݼ"); + return; + } + + // ȡѡƥ + String[] fields = session.getPreferenceService() + .getStringValues("Connor_ECRECNForm_Datbase_Config"); + if (fields == null || fields.length <= 0) { + MessageBox.post("ѡConnor_ECRECNForm_Datbase_Config", "ʾ ", + MessageBox.INFORMATION); + return; + } + + for (int i1 = 0; i1 < fields.length; i1++) { + if (fields[i1].contains(type)) { + String[] split = fields[i1].split("\\|"); + if (split.length == 2) { + String[] split2 = split[1].split(";"); + for (int j = 0; j < split2.length; j++) { + String[] split3 = split2[j].split("="); + if (split3.length == 3) { + rwfpFieldsMap.put(split3[0], split3[1]); + } else if (split3.length == 4) { + rwfpFieldsMap.put(split3[0], split3[1]); + } + } + } + + } + } + + if (rwfpFieldsMap.size() == 0) { + + MessageBox.post("δƥ䵽ѡ", "ʾ ", MessageBox.INFORMATION); + return; + } + + Set keySet = rwfpFieldsMap.keySet(); + String fieldsSql = ""; + for (String string : keySet) { + fieldsSql += string + ","; + } + fieldsSql = fieldsSql.substring(0, fieldsSql.length() - 1); + System.out.println("fieldsSql==========" + fieldsSql); + String sqlString = "SELECT " + fieldsSql + " FROM LY_CHANGETASSKFORM_DETAILS where ID='" + + id + "'"; + System.out.println(sqlString); + Connection conn = getConn(); + PreparedStatement stmt = null; + try { + stmt = conn.prepareStatement(sqlString); + ResultSet result = stmt.executeQuery(); + while (result.next()) { + LinkedHashMap tempLinkedHashMap = new LinkedHashMap(); + LinkedHashMap tempTempLinkedHashMap = new LinkedHashMap(); + for (Entry tempMap : rwfpFieldsMap.entrySet()) { + String key = tempMap.getKey(); + + tempTempLinkedHashMap.put(key, + result.getString(key) == null ? "" : result.getString(key)); + } + + if (tempTempLinkedHashMap.containsKey("SFSJGG") + && tempTempLinkedHashMap.get("SFSJGG").equals("")) { + LinkedHashMap newMap = new LinkedHashMap(); + for (Entry rowMap : tempTempLinkedHashMap.entrySet()) { + newMap.put(rowMap.getKey(), rowMap.getValue() == null ? "" + : validateAndFormatDate(rowMap.getValue(), true)); + } + tempLinkedHashMap.put(result.getString(1), newMap); + bgMap.add(tempLinkedHashMap); + } else { + LinkedHashMap newMap = new LinkedHashMap(); + for (Entry rowMap : tempTempLinkedHashMap.entrySet()) { + newMap.put(rowMap.getKey(), rowMap.getValue() == null ? "" + : validateAndFormatDate(rowMap.getValue(), false)); + } + tempLinkedHashMap.put(result.getString(1), newMap); + bgMap.add(tempLinkedHashMap); + } + + } + + } catch (SQLException e1) { + e1.printStackTrace(); + } + + try { + if (stmt != null) { + stmt.close(); + } + if (conn != null) { + conn.close(); + } + + } catch (SQLException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + System.out.println("bgMap=========" + bgMap.toString()); + KUtil.setByPass(true); + // ݼ + for (TCComponent tcComponent : relatedComponents) { + if (tcComponent instanceof TCComponentDataset) { + TCComponentDataset dataset = (TCComponentDataset) tcComponent; + // ߰лȡϵͳʱ· + File datasetFile = KUtil.getDatasetFile(dataset); + String type = tcComponent.getType(); + String datasetType = ""; + String newPath = ""; + if ("MSExcel".equals(type) || "MSExcelX".equals(type)) { + switch (type) { + case "MSExcel": + datasetType = "excel"; + newPath = dealExcel(datasetFile, rev, nameMap, bgMap); + break; + case "MSExcelX": + datasetType = "excel"; + newPath = dealExcelX(datasetFile, rev, nameMap, bgMap); + break; + } + // ݼµ + dataset.setFiles(new String[] { newPath }, new String[] { datasetType }); + } + } + } + KUtil.setByPass(false); + } + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + + MessageBox.post(e1.getMessage(), "ʾ", 2); + KUtil.setByPass(false); + return; + } + + MessageBox.post("дExcelɣ", "ʾ", 2); + + } + + } + + // ȡݿ + public static Connection getConn() { + Connection conn = null; + try { + conn = DbPool.getConnection(dateConnList.get(0), dateConnList.get(1)); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return conn; + } + + public static String calculateDate(String dateString, int daysToAdd) { + // ڸʽ + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + + // ַ + LocalDate date; + try { + date = LocalDate.parse(dateString, formatter); + } catch (DateTimeParseException e) { + throw new IllegalArgumentException("Invalid date format. Please use yyyy-MM-dd.", e); + } + + // ӻ + LocalDate resultDate = date.plusDays(daysToAdd); + + // ʽΪַ + return resultDate.format(formatter); + } + + public String validateAndFormatDate(String input) { + // ڸʽ + DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.S"); + DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + + try { + // Խʱַ + LocalDateTime dateTime = LocalDateTime.parse(input, inputFormatter); + + // תΪֻڵLocalDate + LocalDate date = dateTime.toLocalDate(); + + // ʽΪַ + return date.format(outputFormatter); + } catch (DateTimeParseException e) { + // ʧܣ˵벻ָʽԭʼַ + return input; + } + } + + + public static TCComponent[] getTCComponentsById(TCSession session, String id) throws Exception { + return session.search("...", new String[] { " ID" }, new String[] { id }); + } + + public String validateAndFormatDate(String input, boolean fou) { + // ڸʽ + DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.S"); + DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + + try { + // Խʱַ + LocalDateTime dateTime = LocalDateTime.parse(input, inputFormatter); + + // תΪֻڵLocalDate + LocalDate date = dateTime.toLocalDate(); + if (date != null && fou) { + return "/"; + } + // ʽΪַ + return date.format(outputFormatter); + } catch (DateTimeParseException e) { + // ʧܣ˵벻ָʽԭʼַ + return input; + } + } + + + private String dealExcel(File datasetFile, TCComponentItemRevision revision, HashMap nameMap, + ArrayList>> bgMap) throws IOException, TCException { + FileInputStream is = new FileInputStream(datasetFile); + HSSFWorkbook workbook = new HSSFWorkbook(is); + List allNames = workbook.getAllNames(); + for (HSSFName hssfName : allNames) { + String name = hssfName.getNameName(); + // ƹѡ + if (nameMap.containsKey(name)) { + CellReference cellReference = new CellReference(hssfName.getRefersToFormula()); + HSSFSheet sheet = workbook.getSheet(cellReference.getSheetName()); + HSSFRow row = sheet.getRow(cellReference.getRow()); + HSSFCell cell = row.getCell(cellReference.getCol()); + String preConfigValue = ""; + System.out.println("nameMap.get(name)===========" + nameMap.get(name)); + if (nameMap.get(name).contains("RevMaster") || nameMap.get(name).contains("Item") + || nameMap.get(name).contains("Rev")) { + preConfigValue = getPreConfigValue(revision, nameMap, nameMap.get(name)); + } else { + String[] split = nameMap.get(name).split("\\."); + for (int i = 0; i < bgMap.size(); i++) { + LinkedHashMap> linkedHashMap = bgMap.get(i); + if (linkedHashMap.containsKey(split[0])) { + LinkedHashMap maps = linkedHashMap.get(split[0]); + preConfigValue = maps.get(split[1]) == null ? "" : maps.get(split[1]); + } + } + } + + preConfigValue = formatDateString(preConfigValue); + System.out.println("Ϊ" + cellReference.getRow() + "====" + "Ϊ" + cellReference.getCol() + "====" + + "ֵΪ " + preConfigValue); + if (cell == null) { + cell = row.createCell(cellReference.getCol()); + } + cell.setCellValue(preConfigValue); + + } + } + is.close(); + FileOutputStream os = new FileOutputStream(datasetFile); + workbook.write(os); + workbook.close(); + return datasetFile.getAbsolutePath(); + } + + private String dealExcelX(File datasetFile, TCComponentItemRevision revision, HashMap nameMap, + ArrayList>> bgMap) throws IOException, TCException { + FileInputStream is = new FileInputStream(datasetFile); + XSSFWorkbook workbook = new XSSFWorkbook(is); + List allNames = workbook.getAllNames(); + for (XSSFName xssfName : allNames) { + String name = xssfName.getNameName(); + // ƹѡ + if (nameMap.containsKey(name)) { + CellReference cellReference = new CellReference(xssfName.getRefersToFormula()); + XSSFSheet sheet = workbook.getSheet(cellReference.getSheetName()); + XSSFRow row = sheet.getRow(cellReference.getRow()); + XSSFCell cell = row.getCell(cellReference.getCol()); + + String preConfigValue = ""; + System.out.println("nameMap.get(name)===========" + nameMap.get(name)); + if (nameMap.get(name).contains("RevMaster") || nameMap.get(name).contains("Item") + || nameMap.get(name).contains("Rev")) { + preConfigValue = getPreConfigValue(revision, nameMap, nameMap.get(name)); + } else { + String[] split = nameMap.get(name).split("\\."); + for (int i = 0; i < bgMap.size(); i++) { + LinkedHashMap> linkedHashMap = bgMap.get(i); + if (linkedHashMap.containsKey(split[0])) { + LinkedHashMap maps = linkedHashMap.get(split[0]); + preConfigValue = maps.get(split[1]) == null ? "" : maps.get(split[1]); + } + } + } + + preConfigValue = formatDateString(preConfigValue); + System.out.println("Ϊ" + cellReference.getRow() + "====" + "Ϊ" + cellReference.getCol() + "====" + + "ֵΪ " + preConfigValue); + if (cell == null) { + cell = row.createCell(cellReference.getCol()); + cell.setCellValue(preConfigValue); + } else { + cell.setCellValue(preConfigValue); + } + } + } + is.close(); + FileOutputStream os = new FileOutputStream(datasetFile); + workbook.write(os); + workbook.close(); + return datasetFile.getAbsolutePath(); + } + + + + private String getPreConfigValue(TCComponentItemRevision revision, HashMap nameMap, String value) + throws TCException { + String[] split = value.split("\\."); + String cellValue = ""; + TCProperty property = null; + if (split.length == 2) { + switch (split[0]) { + case "Item": + property = revision.getItem().getTCProperty(split[1]); + break; + case "Rev": + property = revision.getTCProperty(split[1]); + break; + case "RevMaster": + property = revision.getRelatedComponent("IMAN_master_form_rev").getTCProperty(split[1]); + break; + default: + break; + } + } + // ȡϵļµ + else if (split.length == 3) { + String relation = split[0]; + TCComponent relatedComponent = revision.getRelatedComponent(relation); + TCComponentItemRevision centerRev = null; + if (relatedComponent instanceof TCComponentItemRevision) { + centerRev = (TCComponentItemRevision) relatedComponent; + } else if (relatedComponent instanceof TCComponentItem) { + centerRev = ((TCComponentItem) relatedComponent).getLatestItemRevision(); + } + if (centerRev != null) { + switch (split[1]) { + case "Item": + property = centerRev.getItem().getTCProperty(split[2]); + break; + case "Rev": + property = centerRev.getTCProperty(split[2]); + break; + case "RevMaster": + property = centerRev.getRelatedComponent("IMAN_master_form_rev").getTCProperty(split[2]); + break; + default: + break; + } + } + } + if (property == null) { + return ""; + } else { + cellValue = property.getDisplayValue(); + cellValue = formatDateString(cellValue); + return cellValue; + } + } + + + public static String formatDateString(String input) { + // ֿܵʱʽ + // yyyy-MM-dd HH:mm:ss.S + SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + SimpleDateFormat format3 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S"); + // Ŀʽ + SimpleDateFormat targetFormat = new SimpleDateFormat("yyyy-MM-dd"); + + try { + // Խһָʽ + Date date = format1.parse(input); + // ɹĿʽַ + return targetFormat.format(date); + } catch (ParseException e1) { + try { + // Խڶָʽ + Date date = format2.parse(input); + // ɹĿʽַ + return targetFormat.format(date); + } catch (ParseException e2) { + try { + // Խڶָʽ + Date date = format3.parse(input); + // ɹĿʽַ + return targetFormat.format(date); + } catch (ParseException e3) { + // ָʽƥ䣬ԭʼַ + return input; + } + } + } + } +} \ No newline at end of file diff --git a/src/com/langtech/plm/bg/RWFPHandler.java b/src/com/langtech/plm/bg/RWFPHandler.java new file mode 100644 index 0000000..9b52e00 --- /dev/null +++ b/src/com/langtech/plm/bg/RWFPHandler.java @@ -0,0 +1,114 @@ +package com.langtech.plm.bg; + +import javax.swing.SwingUtilities; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.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 RWFPHandler extends AbstractHandler { + + private AbstractAIFUIApplication app; + private TCSession session; +// private InterfaceAIFComponent target; + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + app = AIFUtility.getCurrentApplication(); + session = (TCSession) app.getSession(); +// target = app.getTargetComponent(); +// if (target == null || !(target instanceof TCComponentFolder)) { +// MessageBox.post(app.getDesktop(), "ѡϵͳĿ¼ļне룡", "λѡ", MessageBox.WARNING); +// return null; +// } + + //жǷɱ༭ + boolean readOnly = true; + String userId = ""; + try { + userId = session.getUser().getUserId(); + } catch (TCException e3) { + // TODO Auto-generated catch block + e3.printStackTrace(); + } + String[] templates = session.getPreferenceService().getStringValues("Connor_TaskForm_ChangeDateButton_User"); + if(templates != null && templates.length > 0 && userId != null && !userId.isEmpty()) { + if(templates[0].contains(userId)) { + readOnly = false; + } + } + final boolean readOnlyFinal = readOnly; + InterfaceAIFComponent target = app.getTargetComponent(); + if(target instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem)target; + String type = item.getType(); + try { + String id = item.getStringProperty("item_id"); + String objectString = item.getStringProperty("object_string"); + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + try { + new RWFPDialog(session,type,id,objectString,readOnlyFinal); + //d.setModal(true); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + }else if(target instanceof TCComponentItemRevision){ + + TCComponentItemRevision rev = (TCComponentItemRevision)target; + TCComponentItem item = null; + try { + item = rev.getItem(); + } catch (TCException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + String type = item.getType(); + try { + String id = item.getStringProperty("item_id"); + String objectString = item.getStringProperty("object_string"); + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + try { + new RWFPDialog(session,type,id,objectString,readOnlyFinal); + //d.setModal(true); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + }else { + MessageBox.post(app.getDesktop(), "ѡȷ", "ʾ", MessageBox.WARNING); + return null; + } + + + return null; + } + +} diff --git a/src/com/langtech/plm/bg/TableCellCheckboxRenderer.java b/src/com/langtech/plm/bg/TableCellCheckboxRenderer.java new file mode 100644 index 0000000..82b1faf --- /dev/null +++ b/src/com/langtech/plm/bg/TableCellCheckboxRenderer.java @@ -0,0 +1,54 @@ +package com.langtech.plm.bg; + +import java.awt.Component; +import java.util.List; + +import javax.swing.JCheckBox; +import javax.swing.JRadioButton; +import javax.swing.JTable; +import javax.swing.SwingConstants; +import javax.swing.event.ChangeEvent; +import javax.swing.event.EventListenerList; +import javax.swing.table.TableCellRenderer; + +import com.teamcenter.rac.treetable.JTreeTable; + + +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 JTable table) { + } + public TableCellCheckboxRenderer(final JTreeTable table) { + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + // TODO Auto-generated method stub + this.setHorizontalAlignment(SwingConstants.CENTER);// ͷǩ +// this.setBorderPainted(true); + + if(value != null) + { + this.setSelected(value.toString().equals("1")); + } + else + { + this.setSelected(false); + } + return this; + } +} \ No newline at end of file diff --git a/src/com/langtech/plm/bg/TableColorRender.java b/src/com/langtech/plm/bg/TableColorRender.java new file mode 100644 index 0000000..3beea2d --- /dev/null +++ b/src/com/langtech/plm/bg/TableColorRender.java @@ -0,0 +1,71 @@ +package com.langtech.plm.bg; + +import java.awt.Color; +import java.awt.Component; +import java.util.HashMap; + +import javax.swing.JTable; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.TableCellRenderer; + +public class TableColorRender implements TableCellRenderer { + // + public static final DefaultTableCellRenderer DEFAULT_RENDERER = new DefaultTableCellRenderer(); + + //Integer Stringʶ Colorɫ + public HashMap> allForegroundInfos = new HashMap>(); + public HashMap allFColorColumn = new HashMap(); + + //Integer Stringʶ Colorɫ + public HashMap> allBackgroundInfos = new HashMap>(); + public HashMap allBColorColumn = new HashMap(); + + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + Component renderer = DEFAULT_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + + if (value != null && value instanceof String) { + Color foreground = table.getForeground(); + Color background = table.getBackground(); + if (isSelected) { + background = new Color(10, 36, 106); + } + + Boolean bSetFG = false; + Integer infoCol = allFColorColumn.get(column); + if (infoCol != null) { + HashMap fgc = allForegroundInfos.get(infoCol); + if (fgc != null) { + String infoValue = table.getValueAt(row, infoCol).toString(); + Color color = fgc.get(infoValue); + if (color != null) { + foreground = color; + bSetFG = true; + } + } + } + + Boolean bSetBG = false; + infoCol = allBColorColumn.get(column); + if (infoCol != null) { + HashMap bgc = allBackgroundInfos.get(infoCol); + if (bgc != null) { + String infoValue = table.getValueAt(row, infoCol).toString(); + Color color = bgc.get(infoValue); + if (color != null) { + background = color; + bSetBG = true; + } + } + } + + if (!bSetFG && !bSetBG && isSelected) { + foreground = Color.WHITE; + } + + renderer.setForeground(foreground); + renderer.setBackground(background); + } + + return renderer; + } +} \ No newline at end of file diff --git a/src/com/langtech/plm/calculateMaterialsAndWork/CalculateDialog.java b/src/com/langtech/plm/calculateMaterialsAndWork/CalculateDialog.java new file mode 100644 index 0000000..ba61001 --- /dev/null +++ b/src/com/langtech/plm/calculateMaterialsAndWork/CalculateDialog.java @@ -0,0 +1,811 @@ +package com.langtech.plm.calculateMaterialsAndWork; + +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.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentMEOP; +import com.teamcenter.rac.kernel.TCComponentMEOPRevision; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.UIUtilities; + +public class CalculateDialog extends JFrame implements ActionListener { + /** + * + */ + private static final long serialVersionUID = 1L; + + private AbstractAIFApplication application; + private TCComponentMEOPRevision meop; + private TCSession session; + + TCComponentItemRevision rawMaterialRevision; + + //ӡؼ + //ͼֱֽD + private JLabel zjdLabel; + private JTextField zjdTextField; + //ͼֽ + private JLabel lkcLabel; + private JTextField lkcTextField; + //жó + private JLabel qdycdLabel; + private JTextField qdycdTextField; + //ó + private JLabel cdmycdLabel; + private JTextField cdmycdTextField; + //ͷó + private JLabel jtycdLabel; + private JTextField jtycdTextField; + // + private JLabel kzljsLabel; + private JTextField kzljsTextField; + // + private JLabel ggLabel; + private JTextField ggTextField; + //ƺ + private JLabel clphLabel; + private JTextField clphTextField; + + //ؼ + //ܳ + private JLabel zcLabel; + private JTextField zcTextField; + // + private JLabel djcdLabel; + private JTextField djcdTextField; + // + private JLabel djzlLabel; + private JTextField djzlTextField; + //׼ʱ + private JLabel bzgsLabel; + private JTextField bzgsTextField; + //ʱ + private JLabel fzgsLabel; + private JTextField fzgsTextField; + + //㰴ť + private JButton calculateButton; + //ͬť + private JButton syncButton; + //ȡť + private JButton celButton; + + //ܶ + private String density; + // + private String crossSection; + //ʱ + private String auxiliaryTime; + //̶ʱ + private String fixedTime; + //иʱ + private String cuttingTime; + + private boolean isGZ; + + + public CalculateDialog(AbstractAIFApplication application,TCComponentMEOPRevision meop) throws TCException { + this.application = application; + this.meop = meop; + this.session = (TCSession) application.getSession(); + initUI(); + getProperties(this.meop); + } + + + private JPanel getTopPanel() { + JPanel centerPanel = new JPanel(new PropertyLayout()); + centerPanel.add("1.1.left.top",this.zjdLabel); + centerPanel.add("1.2.left.top",this.zjdTextField); + centerPanel.add("2.1.left.top",this.lkcLabel); + centerPanel.add("2.2.left.top",this.lkcTextField); + centerPanel.add("3.1.left.top",this.qdycdLabel); + centerPanel.add("3.2.left.top",this.qdycdTextField); + centerPanel.add("4.1.left.top",this.cdmycdLabel); + centerPanel.add("4.2.left.top",this.cdmycdTextField); + centerPanel.add("5.1.left.top",this.jtycdLabel); + centerPanel.add("5.2.left.top",this.jtycdTextField); + centerPanel.add("6.1.left.top",this.kzljsLabel); + centerPanel.add("6.2.left.top",this.kzljsTextField); + centerPanel.add("7.1.left.top",this.ggLabel); + centerPanel.add("7.2.left.top",this.ggTextField); + centerPanel.add("8.1.left.top",this.clphLabel); + centerPanel.add("8.2.left.top",this.clphTextField); + + centerPanel.add("1.3.left.top",this.zcLabel); + centerPanel.add("1.4.left.top",this.zcTextField); + centerPanel.add("2.3.left.top",this.djcdLabel); + centerPanel.add("2.4.left.top",this.djcdTextField); + centerPanel.add("3.3.left.top",this.djzlLabel); + centerPanel.add("3.4.left.top",this.djzlTextField); + centerPanel.add("4.3.left.top",this.bzgsLabel); + centerPanel.add("4.4.left.top",this.bzgsTextField); + centerPanel.add("5.3.left.top",this.fzgsLabel); + centerPanel.add("5.4.left.top",this.fzgsTextField); + centerPanel.add("6.3.left.top",this.calculateButton); + + return centerPanel; + } + + /** + * ýĿ + */ + private void setPanelProperties() { + this.zjdLabel = new JLabel("ͼֱֽD"); + this.lkcLabel = new JLabel("ͼֽ"); + this.qdycdLabel = new JLabel("жó"); + this.cdmycdLabel = new JLabel("ó"); + this.jtycdLabel = new JLabel("ͷó"); + this.kzljsLabel = new JLabel(""); + this.ggLabel = new JLabel(""); + this.clphLabel = new JLabel("ƺ"); + this.zcLabel = new JLabel("ܳ"); + this.djcdLabel = new JLabel(""); + this.djzlLabel = new JLabel(""); + this.bzgsLabel = new JLabel("׼ʱ"); + this.fzgsLabel = new JLabel("ʱ"); + + this.zjdTextField = new JTextField(32); + this.lkcTextField = new JTextField(32); + this.qdycdTextField = new JTextField(32); + this.cdmycdTextField = new JTextField(32); + this.jtycdTextField = new JTextField(32); + this.kzljsTextField = new JTextField(32); + this.ggTextField = new JTextField(32); + this.ggTextField.setEditable(false); + this.ggTextField.setBackground(new Color(200, 200, 200)); + this.clphTextField = new JTextField(32); + this.clphTextField.setEditable(false); + this.ggTextField.setBackground(new Color(200, 200, 200)); + this.zcTextField = new JTextField(32); + this.djcdTextField = new JTextField(32); + this.djzlTextField = new JTextField(32); + this.bzgsTextField = new JTextField(32); + this.fzgsTextField = new JTextField(32); + + this.calculateButton = new JButton(""); + this.syncButton = new JButton("ͬ"); + this.celButton = new JButton("ȡ"); + } + + /** + * ȡײť + * @return + */ + private JPanel getButtomPanel() { + JPanel bottomPanel = new JPanel(new FlowLayout(1)); +// bottomPanel.add(this.calculateButton); + bottomPanel.add(this.syncButton); + bottomPanel.add(this.celButton); + + return bottomPanel; + } + + /** + * ʼͼν + */ + private void initUI() { + this.setTitle("϶ʱ"); + this.setSize(500, 500); + this.setLayout(new BorderLayout()); + + setPanelProperties(); + + JPanel centerPanel = getTopPanel(); + + JPanel bottomPanel = getButtomPanel(); + + this.add(centerPanel,BorderLayout.CENTER); + this.add(bottomPanel,BorderLayout.SOUTH); + + //¼ + this.calculateButton.addActionListener(this); + this.syncButton.addActionListener(this); + this.celButton.addActionListener(this); + + //ŵĻ + UIUtilities.centerToScreen(this); + this.setVisible(true); + + } + + /** + * ȡѡMEOPԣֵ + * @param meop + * @throws TCException + */ + private void getProperties(TCComponentMEOPRevision meop) throws TCException { + String outlineDiameter = meop.getStringProperty("ly6_outlineDiameter"); + String outlineLength = meop.getStringProperty("ly6_outlineLength"); + String cuttingLength = meop.getStringProperty("ly6_cuttingLength"); + String transverseLength = meop.getStringProperty("ly6_transverseLength"); + String colletLength = meop.getStringProperty("ly6_colletLength"); + String manufacturingQuantity =meop.getStringProperty("ly6_manufacturableQuantity"); + //ƺŵbomlineµȡã + String specifications = null; + String brandNum = null; +// String specifications = meop.getStringProperty("ly6_specifications"); +// String brandNum = meop.getStringProperty("ly6_material"); + TCComponentItem item = meop.getItem(); + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + // ͼ-汾򣨾ȷ״̬ȡĬϹ + TCComponentBOMWindow view = winType.create(null); + // BOMBOMitem͵BOMΪһBOM args:item 汾 ... + TCComponentBOMLine topBomLine = view.setWindowTopLine(item, meop, null, null); + topBomLine.lock(); + if (topBomLine.hasChildren()) { + System.out.println("dialogǰbomУ"); + AIFComponentContext[] childrens = topBomLine.getChildren(); + int tag = 0; + for (AIFComponentContext children : childrens) { + TCComponentBOMLine bomLine = (TCComponentBOMLine)children.getComponent(); + TCComponentItemRevision itemRevision = bomLine.getItemRevision(); + String childType = itemRevision.getType(); + System.out.println("ǰͨbomlineȡͣ"+childType); + if (childType.equals("LY6_RawMaterial") || childType.equals("LY6_RawMaterialRevision")) { + System.out.println("ɹȡǰġԭϡ"); + specifications = itemRevision.getStringProperty("ly6_specifications"); + brandNum = itemRevision.getStringProperty("ly6_material"); + System.out.println("ȡ"+specifications); + System.out.println("ȡƺţ"+brandNum); + tag ++; + break; + } + } + if (tag == 0) {//bomlineûΪLY6_RawMaterialRevisionĶ + MessageBox.post("δԭ϶","ʾ",MessageBox.INFORMATION); + //todo burangjisuan + topBomLine.unlock(); + view.close(); + //ر + this.setVisible(false); + //ͷ + this.dispose(); + return; + } + }else { + MessageBox.post("δԭ϶","ʾ",MessageBox.INFORMATION); + //todo burangjisuan + topBomLine.unlock(); + view.close(); + //ر + this.setVisible(false); + //ͷ + this.dispose(); + return; + } + topBomLine.unlock(); + view.close(); + + this.zjdTextField.setText(outlineDiameter != null ? outlineDiameter : ""); + this.lkcTextField.setText(outlineLength != null ? outlineLength : ""); + this.qdycdTextField.setText(cuttingLength != null ? cuttingLength : ""); + this.cdmycdTextField.setText(transverseLength != null ? transverseLength : ""); + this.jtycdTextField.setText(colletLength != null ? colletLength : ""); + this.kzljsTextField.setText(manufacturingQuantity != null ? manufacturingQuantity : ""); + this.ggTextField.setText(specifications != null ? specifications : ""); + this.clphTextField.setText(brandNum != null ? brandNum : ""); + } + + + /** + * ܳ + * @return + */ + private String calculateTotalLength() { + // ȡ TextField + String lkcText = this.lkcTextField.getText(); + String qdycdText = this.qdycdTextField.getText(); + String cdmycdText = this.cdmycdTextField.getText(); + String kzljsText = this.kzljsTextField.getText(); + String jtycdText = this.jtycdTextField.getText(); + + // ַתΪֵ + double lkcValue = Double.parseDouble(lkcText); + double qdycdValue = Double.parseDouble(qdycdText); + double cdmycdValue = Double.parseDouble(cdmycdText); + double kzljsValue = Double.parseDouble(kzljsText); + double jtycdValue = Double.parseDouble(jtycdText); + + // + double result = (lkcValue + qdycdValue + cdmycdValue) * kzljsValue + jtycdValue; + System.out.println("ͼֽ"+lkcValue+"жóȣ"+qdycdValue+"óȣ"+cdmycdValue+""+kzljsValue+"ͷóȣ"+jtycdValue); +// double cm = result / 10.0; + String formattedCm = String.format("%.2f", result); + return formattedCm; + } + + /** + * 㵥 + * @return + */ + private String calculateSingleLength(){ + String zcText = this.zcTextField.getText(); + String kzljsText = this.kzljsTextField.getText(); + + double zcValue = Double.parseDouble(zcText); + double kzljsValue = Double.parseDouble(kzljsText); + if (kzljsValue == 0){ + System.out.println(" is 0"); + } + double result = zcValue / kzljsValue; + System.out.println("ܳ"+zcValue+""+kzljsValue); +// double cm = result / 10.0; + String format = String.format("%.2f", result); + return format; + } + + private void downLoadFile(File file) throws Exception { + FileInputStream inputStream = new FileInputStream(file); + // ָļı· + String localFilePath = "C:\\"+file.getName(); + + try { + // Ŀ· + Path path = Paths.get(localFilePath); + + // д뵽ļ + Files.copy(inputStream, path); + + System.out.println("ļѳɹ: "+localFilePath); + } catch (Exception e) { + e.printStackTrace(); + System.out.println("ļʱ"); + } finally { + // رͷԴ + if (inputStream != null) { + try { + inputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + + /** + * ѡеuidȡݼEXCEL + * uidȡitem󣬻ȡöµ + * ݡֱȡEXCELвıҪĿʱͱ׼ʱ + * @throws Exception + */ + private void getDataset(){ + System.out.println("getDataset"); + TCPreferenceService preferenceService = session.getPreferenceService(); + String itemId = preferenceService.getStringValue("LY6_MEOPTypeTime"); + + InterfaceAIFComponent[] resultComponents; + try { + resultComponents = session.search("...", new String[] {" ID"}, new String[] {itemId}); + + InterfaceAIFComponent component = resultComponents[0]; + if (component instanceof TCComponentItem){ + TCComponentItem item = (TCComponentItem) component; + //ȡitemѷ°汾淶ϵµMSEXCELݼ + TCComponentItemRevision[] releasedItemRevisions = item.getReleasedItemRevisions(); + int releaseRevNum = releasedItemRevisions.length; + if (releaseRevNum == 0) { + System.out.println("󣺵ǰ²ڷ汾"); + } + TCComponentItemRevision tcComponentItemRevision = releasedItemRevisions[releaseRevNum - 1]; + + //ȡǰ汾Ĺ淶ϵµݼ + TCComponent[] referenceListProperty = tcComponentItemRevision.getReferenceListProperty("IMAN_specification"); + if(referenceListProperty.length>0) { + System.out.println("淶ϵµݼ"+referenceListProperty.length); + //ȡһݼ¾ļ + TCComponentTcFile[] tcFiles = ((TCComponentDataset)referenceListProperty[0]).getTcFiles(); + if (tcFiles.length > 0) { +// System.out.println("ݼļ" + tcFiles.length); + File file = tcFiles[0].getFmsFile(); +// if (file.exists()) { +// System.out.println("ʼأ"); +// downLoadFile(file); +// } + System.out.println("ȡݼļ"+file.getName()); + // ݺȡݼ-excelУӦĿݣʱ䡢̶ʱ䡢иʱ + FileInputStream fis = new FileInputStream(file); + Workbook workbook = new HSSFWorkbook(fis); + Sheet sheet = workbook.getSheetAt(0); + //ӵ3ʼ(ǰDZ) + for (int i = 2; i < sheet.getPhysicalNumberOfRows(); i++) { + Row row = sheet.getRow(i); + //ȡÿеĵһֱֵ +// double diam = row.getCell(0).getNumericCellValue(); + String diam = row.getCell(0).getStringCellValue(); + // ݹƥݼеֱ + if (diam.equals(this.ggTextField.getText())){ +// if (diam == Double.parseDouble(this.ggTextField.getText())){ + System.out.println("=========ֱƥɹʼȡʱͱ׼ʱ"+"=========ǰкţ"+(i+1)+"ǰеֱ"+diam); + //ȡ11еֵ׼ʱ + this.bzgsTextField.setText(row.getCell(10).getStringCellValue()); + //ȡ12еֵʱ + this.fzgsTextField.setText(row.getCell(11).getStringCellValue()); + break; + } + } + workbook.close(); + }else { + System.out.println("ȡݼļʧܣ"); + } + + } + } + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + } + + /** + * 㸨ʱ + * @return + */ + private String calculateAssistTime() { + String result = null; + double kzljsNum = Double.parseDouble(this.kzljsTextField.getText()); + if (kzljsNum > 0){ + double auxiliaryTimeNum = Double.parseDouble(this.auxiliaryTime); + double fixedTimeNum = Double.parseDouble(this.fixedTime); + + double resultNum = Math.round((auxiliaryTimeNum + fixedTimeNum) / kzljsNum / 60 * 100.0) / 100.0; + System.out.println("ʱ䣺"+auxiliaryTimeNum+"̶ʱ䣺"+fixedTimeNum+""+kzljsNum); + result = String.valueOf(resultNum); + + } + return result; + + } + + /** + * ׼ʱ + * @return + */ + private String calculateStandardTime() { + String result = null; + double kzljsNum = Double.parseDouble(this.kzljsTextField.getText()); + if (kzljsNum > 0){ + System.out.println("=========>ȡиʱ䣺"+this.cuttingTime); + double cuttingTimeNum = Double.parseDouble(this.cuttingTime); + + double resultNum = Math.round((cuttingTimeNum / kzljsNum / 60) * 100.0) / 100.0; + System.out.println("иʱ䣺"+cuttingTimeNum+""+kzljsNum); + result = String.valueOf(resultNum); + } + return result; + } + + /** + * ȡܶȺͽ + * @throws TCException + */ + private void getDensityAndCrossSection() throws TCException { + System.out.println("=========>ʼȡܶȺͺ棺getDensityAndCrossSection"); + +// 1.ȡǰѡMEOPBOM + TCComponentMEOP meopItem = (TCComponentMEOP) meop.getItem(); + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) this.session.getTypeComponent("BOMWindow"); + TCComponentBOMWindow view = winType.create(null); + TCComponentBOMLine bomLine = view.setWindowTopLine(meopItem, meop, null, null); +// 2.BOMУݡ񡱺͡ϡҪΨһԭ϶ + throughBomline(bomLine); + + view.close(); + } + + /** + * ѭǰbomline¹УȡҪbomӦԭ϶󣬲ȡӦܶȺͺ + * @param topBomLine ǰBOM + */ + private void throughBomline(TCComponentBOMLine topBomLine) throws TCException{ + // 3.ȡԭ϶ܶȺͺ + boolean hasChildren = topBomLine.hasChildren(); + if (hasChildren) { + AIFComponentContext[] childrens = topBomLine.getChildren(); + for (AIFComponentContext children : childrens) { + TCComponentBOMLine bomLine = (TCComponentBOMLine) children.getComponent(); + //ȡǰbomͣͶϣ򵽵ǰbomӦԭ϶ + String propertyValue = bomLine.getProperty("bl_occ_type"); + if ("Ͷ".equals(propertyValue)) { + //ͨԭ϶ȡܶȺͺ + this.rawMaterialRevision = bomLine.getItemRevision(); + String densityString = rawMaterialRevision.getProperty("ly6_density"); + String crossSectionString = rawMaterialRevision.getProperty("ly6_crossSection"); + System.out.println("==========ɹȡõǰԭ϶Ӧܶȣ"+densityString+"棺"+crossSectionString); + + this.density = densityString != null ? densityString : ""; + this.crossSection = crossSectionString != null ? crossSectionString : ""; + System.out.println("000"); + break; + } + throughBomline(bomLine); + } + } + + } + + + /** + * 㵥 + * @return + * @throws TCException + */ + private String calculateWeight(){ + System.out.println("calculateWeight"); + //ͨȡǰѡжbom¹ԭ϶󣬻ȡܶȺͺ + try { + getDensityAndCrossSection(); + } catch (TCException e) { + e.printStackTrace(); + } + //ȡܶȡȣ㵥 + double crossSectionNum = Double.parseDouble(this.crossSection); + double densityNum = 0; + if (this.density.contentEquals("")) { + densityNum = 0; + }else { + densityNum = Double.parseDouble(this.density); + } + double siglengthNum = Double.parseDouble(this.djcdTextField.getText()); + double result = crossSectionNum * densityNum * siglengthNum; + System.out.println("棺"+crossSectionNum+"ܶȣ"+densityNum+"ȣ"+siglengthNum); + double kg = result / 10000.0; + String formattedKg = String.format("%.2f", kg); + return formattedKg; + } + + /** + * дԵӦĶ + * @throws TCException + */ + private void saveProperty() throws TCException { + System.out.println("saveProperty~ʼд"); + try { + meop.setProperty("ly6_specifications", this.ggTextField.getText() == null ? "" : this.ggTextField.getText()); +// rawMaterialRevision.setProperty("ly6_specifications", this.ggTextField.getText() == null ? "" : this.ggTextField.getText()); + meop.setProperty("ly6_totalLenght", this.zcTextField.getText() == null ? "" : this.zcTextField.getText()); + meop.setProperty("ly6_singleLength", this.djcdTextField.getText() == null ? "" : this.djcdTextField.getText()); + meop.setProperty("ly6_weight", this.djzlTextField.getText() == null ? "" : this.djzlTextField.getText()); + meop.setProperty("ly6_standardTime", this.bzgsTextField.getText() == null ? "" : this.bzgsTextField.getText()); + meop.setProperty("ly6_auxiliaryTime", this.fzgsTextField.getText() == null ? "" : this.fzgsTextField.getText()); +// rawMaterialRevision.setProperty("ly6_material", this.clphTextField.getText() == null ? "" : this.clphTextField.getText()); + meop.setProperty("ly6_brandNum", this.clphTextField.getText() == null ? "" : this.clphTextField.getText()); + meop.setProperty("ly6_outlineDiameter", this.zjdTextField.getText() == null ? "" : this.zjdTextField.getText()); + meop.setProperty("ly6_outlineLength", this.lkcTextField.getText() == null ? "" : this.lkcTextField.getText()); + meop.setProperty("ly6_cuttingLength", this.qdycdTextField.getText() == null ? "" : this.qdycdTextField.getText()); + meop.setProperty("ly6_transverseLength", this.cdmycdTextField.getText()== null ? "" : this.cdmycdTextField.getText()); + meop.setProperty("ly6_colletLength", this.jtycdTextField.getText() == null ? "" : this.jtycdTextField.getText()); + meop.setProperty("ly6_manufacturableQuantity", this.kzljsTextField.getText() == null ? "" : this.kzljsTextField.getText()); + }catch (Exception e){ + System.out.println(e.getMessage()); + e.printStackTrace(); + } + } + + /** + * MǷѾԭ + * @throws TCException + */ + private int checkMaterial() throws TCException { + try { + System.out.println("ʼMµĹ"); + this.isGZ=false; + TCComponent[] whereUsed = meop.whereUsed((short) 0); + for (TCComponent tcComponent : whereUsed) { + //ȡǰĸ-tcComponent + String mepRevisionType = tcComponent.getStringProperty("object_type"); + //ȡѡеĹնͣƥ + TCSession session = (TCSession) this.application.getSession(); + TCPreferenceService preferenceService = session.getPreferenceService(); + //ѡ-C8MyPreference,ȡѡֵ + String value = preferenceService.getStringValue("LY6_MEPType"); + String[] strings = value.split(","); + for (int i = 0; i < whereUsed.length; i++) { + //նƥ䣬Уԭ϶ȶ + if (strings[i].equals(mepRevisionType)) { + System.out.println("========>ƥɹ"); + if (tcComponent instanceof TCComponentItemRevision) { + System.out.println("====>ȡĹն"+tcComponent.getObjectString()); + TCComponentItemRevision mepRevision = (TCComponentItemRevision) tcComponent; + //ȡնµ/:relatedRevision\\relatedItem + TCComponent relatedComponent = mepRevision.getRelatedComponent("IMAN_METarget"); + TCComponentItemRevision relatedRevision = (TCComponentItemRevision) relatedComponent; + TCComponentItem relatedItem = relatedRevision.getItem(); + + //鵱ǰ϶Ƿԭ϶ + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + TCComponentBOMWindow view = winType.create(null); + //ȡ϶/Ӧbomline + TCComponentBOMLine bomLine = view.setWindowTopLine(relatedItem, relatedRevision, null, null); + bomLine.lock(); + //bomlineǷԭ϶ + System.out.println("1"); + int setResult = setBomLineProperty(bomLine, this.rawMaterialRevision); + System.out.println("2"); + if (setResult == 0) {//¹ͬ͵ֹ + MessageBox.post("Ŀѹԭ", "ʾ", MessageBox.INFORMATION); + return 0; + } + + //M϶ûйԭ϶ + if (!this.isGZ) { + System.out.println("M϶ûйԭ϶󣬿ʼء"); + view.lock(); + TCComponentItem materialItem = this.rawMaterialRevision.getItem(); + bomLine.add(materialItem,this.rawMaterialRevision,null,false,""); + //2025.1.20εǰMûйEԭϣصͬʱEbomline-bl_quantityΪеġ + System.out.println("M϶ûйͬ͵ԭ϶õǰԭEӦbomlinebl_quantity"); + + bomLine.save(); +// System.out.println("3"); +// setBomLineProperty(bomLine,this.rawMaterialRevision); +// System.out.println("4"); + bomLine.unlock(); + + view.save(); + view.unlock(); + //=================سɹΪȥbomlineֵ + view.lock(); + bomLine.lock(); + System.out.println("3"); + setBomLineProperty(bomLine,this.rawMaterialRevision); + System.out.println("4"); + bomLine.save(); + bomLine.unlock(); + view.unlock(); + + } + // BOMWindowرգ + view.close(); + }else { + System.out.println("ǰ汾쳣"); + } + break; + } + } + } + + }catch (Exception e){ + e.printStackTrace(); + System.out.println(e.getMessage()); + } + saveProperty(); + MessageBox.post("ͬɹ", "", MessageBox.INFORMATION); + return 1; + } + + /** + * жbomLineǷrawMaterialRev˸öøöbomlinebl_quantityΪϵġ + * ûйصǰrawMaterialRev󣬵ȴͬ͵򵯴ʾֹ + * @param bomLine + * @param rawMaterialRev + * @throws TCException + * return 1سɹִУ0ͬ͵childֹ + * ֵжǷҪֹ0һ㷽ֱreturnټִкķ + */ + public int setBomLineProperty(TCComponentBOMLine bomLine,TCComponentItemRevision rawMaterialRev) throws TCException { + System.out.println("setBomLineProperty~"); + if (bomLine.hasChildren()) { + System.out.println("ǰbomline˶"); + AIFComponentContext[] childrens = bomLine.getChildren(); + for(AIFComponentContext children:childrens) { + TCComponentBOMLine childrenBomLine = (TCComponentBOMLine) children.getComponent(); + TCComponentItemRevision itemRevision = childrenBomLine.getItemRevision(); + String uidTag = itemRevision.getUid(); + String materialRevUid = this.rawMaterialRevision.getUid(); + if (uidTag.equals(materialRevUid)) { + System.out.println("M϶Ѿصǰԭ϶󡤡"); + //2025.1.20εM¹˵ǰEEbomline-bl_quantity޸Ϊеġ + System.out.println("M϶Ѿصǰԭ϶: ["+childrenBomLine.getProperty("bl_line_name")+"]õǰԭEӦbomlinebl_quantity="+this.djzlTextField.getText()); + childrenBomLine.lock(); + childrenBomLine.setProperty("bl_quantity", this.djzlTextField.getText()); + childrenBomLine.save(); + childrenBomLine.unlock(); + //M϶¹ԭ϶ + this.isGZ = true; + break; + }else { + System.out.println("M¹صĴchildBom󣬲ǵǰԭ϶"); + String rawMaterialType = this.rawMaterialRevision.getType(); + String ChildType = itemRevision.getType(); + if (ChildType.equals(rawMaterialType)) { + + System.out.println("뵱ǰԭ϶-["+rawMaterialRevision.getProperty("object_name")+"]ͬ͵BOMLine-["+childrenBomLine.getProperty("bl_line_name")+"]"); + //Ѿͬ͵ԭ϶ҲԼ򲻹زʾĿѹԭϡ + this.isGZ = true; + return 0; + } + } + } + }else { + System.out.println("ǰbomlineδκζ"); + } + return 1; + } + + /** + * ¼ťĵ¼ + */ + @Override + public void actionPerformed(ActionEvent e) { + Object sourceObject = e.getSource(); + //㡱ť + if(sourceObject.equals(this.calculateButton)) { + try { + //ȼ + this.zcTextField.setText(calculateTotalLength()); + this.djcdTextField.setText(calculateSingleLength()); + // + this.djzlTextField.setText(calculateWeight()); + // ʱ + getDataset(); +// this.bzgsTextField.setText(calculateStandardTime()); +// this.fzgsTextField.setText(calculateAssistTime()); + }catch (Exception e1){ + MessageBox.post("ʧܣԻֶά", "ʾ", MessageBox.ERROR); + e1.printStackTrace(); + } + } else if (sourceObject.equals(this.syncButton)) { + //ͬťԷд + try { + //鲢ͬϢ + int checkMaterial = checkMaterial(); + if (checkMaterial != 0) { + this.setVisible(false); + this.dispose(); + } + } catch (TCException e1) { + e1.printStackTrace(); + } + }else { + //ȡť + //ر + this.setVisible(false); + //ͷ + this.dispose(); + } + } +} diff --git a/src/com/langtech/plm/calculateMaterialsAndWork/CalculateHandler.java b/src/com/langtech/plm/calculateMaterialsAndWork/CalculateHandler.java new file mode 100644 index 0000000..bfa749c --- /dev/null +++ b/src/com/langtech/plm/calculateMaterialsAndWork/CalculateHandler.java @@ -0,0 +1,121 @@ +package com.langtech.plm.calculateMaterialsAndWork; + +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.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentMEOP; +import com.teamcenter.rac.kernel.TCComponentMEOPRevision; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +import java.sql.SQLOutput; +import java.util.ArrayList; +import java.util.List; + +public class CalculateHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + + try { + new Thread(){ + @Override + public void run() { +// TODO 1.ȡѡжͺ͹ + //ȡѡжƴַ + InterfaceAIFComponent selectComponent = app.getTargetContext().getComponent(); +// ȡѡжͺ + String type = selectComponent.getType(); + String name; + boolean existTag = false; + InterfaceAIFComponent[] resultComponents = null; + System.out.println("ǰѡжtype"+type); + + try { + //TODO ȡѡжtypeMfg0BvrOperation˵ǹչµĶ󣬿ͨʵƣbl_item_item_idȡѡжIDԴ˻ø + if (type.equals("Mfg0BvrOperation")) { + List entryNames = new ArrayList(); + List entryValues = new ArrayList(); + String lzj_id = selectComponent.getProperty("bl_item_item_id"); + String lzj_rev = selectComponent.getProperty("bl_rev_item_revision_id"); + System.out.println("չѡжID="+lzj_id); + entryNames.add(" ID"); + entryNames.add("汾"); + entryValues.add(lzj_id); + entryValues.add(lzj_rev); + resultComponents = session.search( + "汾...", + entryNames.toArray(new String[entryNames.size()]), + entryValues.toArray(new String[entryNames.size()])); + if(resultComponents != null) { + type = resultComponents[0].getType(); + System.out.println("ȡ칤չ滮¶="+type); + + }else { + MessageBox.post("ûвѯ칤չ滮¶Ӧ","ѯ",MessageBox.INFORMATION); + } + } + + name = selectComponent.getProperty("object_name"); +// 2.ȡѡַ飬Ƚϣǰѡж+ƴַ + TCPreferenceService preferenceService = session.getPreferenceService(); + + //ѡ-C8MyPreference,ȡѡֵ + String[] preferenceValues = preferenceService.getStringValues("LY6_MEOPType"); + if (preferenceValues == null) { + MessageBox.post("ѡΪգѡ","ʾ",MessageBox.INFORMATION); + } + for (String string : preferenceValues){ + System.out.println("ѡLY6_MEOPTypeõϢstring"+string); + if (type.equals(string)){ + System.out.println("ǰѡжѡƥ䣺"+type+"==>"+string); + existTag = true; + break; + } + } + + if (!existTag){ + //3.ѡеֵƥ䣬򵯳ʾʾͲȷ + System.out.println("Ͳȷǰѡжtype="+type); + MessageBox.post("Ͳȷ","ʾ",MessageBox.INFORMATION); + }else { + System.out.println("ѡжƥ䣡"); + TCComponentMEOPRevision rev = null; + if(selectComponent.getType().equals("Mfg0BvrOperation")) { + rev = (TCComponentMEOPRevision)resultComponents[0]; + }else { + //жѡжitemǰ汾itemȡ°汾 + if (selectComponent instanceof TCComponentMEOP) { +// System.out.println("ǰѡжΪTCComponentMEOP"); + TCComponentMEOP meopType = (TCComponentMEOP) selectComponent; + rev = (TCComponentMEOPRevision) meopType.getLatestItemRevision(); + }else if (selectComponent instanceof TCComponentMEOPRevision) { +// System.out.println("ǰѡжΪTCComponentMEOPRevision"); + rev = (TCComponentMEOPRevision) selectComponent; + } + } +// System.out.println("========ѡеĶͣ"+type); + new CalculateDialog(app,rev); + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + }.start(); + } catch (Exception e) { + e.printStackTrace(); + } + + return null; + } + +} diff --git a/src/com/langtech/plm/classification/ClassPropBean.java b/src/com/langtech/plm/classification/ClassPropBean.java new file mode 100644 index 0000000..3835a2f --- /dev/null +++ b/src/com/langtech/plm/classification/ClassPropBean.java @@ -0,0 +1,44 @@ +package com.langtech.plm.classification; + +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/langtech/plm/classification/ClassProperty.java b/src/com/langtech/plm/classification/ClassProperty.java new file mode 100644 index 0000000..b79d22a --- /dev/null +++ b/src/com/langtech/plm/classification/ClassProperty.java @@ -0,0 +1,42 @@ +package com.langtech.plm.classification; + +/** + * @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/langtech/plm/classification/ClassificationProEditHandler.java b/src/com/langtech/plm/classification/ClassificationProEditHandler.java new file mode 100644 index 0000000..c029945 --- /dev/null +++ b/src/com/langtech/plm/classification/ClassificationProEditHandler.java @@ -0,0 +1,24 @@ +package com.langtech.plm.classification; + +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 ClassificationProEditHandler 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/langtech/plm/classification/EditClassificationDialog.java b/src/com/langtech/plm/classification/EditClassificationDialog.java new file mode 100644 index 0000000..b6a7be3 --- /dev/null +++ b/src/com/langtech/plm/classification/EditClassificationDialog.java @@ -0,0 +1,432 @@ +package com.langtech.plm.classification; + +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.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.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aifrcp.AIFUtility; +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.ICSKeyLov; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.kernel.ics.ICSPropertyDescription; +import com.teamcenter.rac.util.MessageBox; +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; + + public EditClassificationDialog(AbstractAIFApplication app) throws TCException { +// this.app = app; + this.session = (TCSession) app.getSession(); +// this.myService = session.getClassificationService(); + this.target = (TCComponent) AIFUtility.getCurrentApplication().getTargetComponent(); + 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); + 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; + } + + @SuppressWarnings("unchecked") + private void initUI() { + this.setTitle("޸ķ"); + + JPanel rootPanel = new JPanel(); + rootPanel.setLayout(null); + 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()) { + 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) { + 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); + rootPanel.add(okBtn); + rootPanel.add(cancelBtn); + this.add(rootPanel); + 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(); + } + }; + } + + @SuppressWarnings("unchecked") + private boolean saveClassification(TCComponentItemRevision rev) { + + try { + TCComponentForm form = (TCComponentForm) rev.getRelatedComponents("IMAN_master_form_rev")[0]; + TCComponent[] status = form.getRelatedComponents("release_status_list"); + for (TCComponent comp : status) { + if (comp.getProperty("object_name").contains("ʽ")) { + JOptionPane.showMessageDialog(this, "汾ʽ޸ķ", "ʾ", JOptionPane.WARNING_MESSAGE); + return false; + } + } + TCComponentICO[] icoS = rev.getClassificationObjects(); + System.out.println("======>ȡķ:" + icoS.length); + String classID = rev.getClassificationClass(); + if (icoS == null || icoS.length == 0) { + return false; + } + for (int i = 0; i < icoS.length;) { + List propList = new ArrayList<>(); + TCComponentICO ico = icoS[i]; + ICSPropertyDescription[] desc = ico.getICSPropertyDescriptors(); + ICSProperty[] oldICSProps = ico.getICSProperties(true); + ids = new int[oldICSProps.length]; + values = new String[oldICSProps.length]; + names = new String[oldICSProps.length]; + for (int j = 0; j < oldICSProps.length; j++) { + ids[j] = oldICSProps[j].getId(); + if (propMap.get(desc[j].getName()) instanceof JComboBox) { + ClassPropBean bean = (ClassPropBean) ((JComboBox) propMap.get(desc[j].getName())).getSelectedItem(); + String str = bean.getId(); + values[j] = " ".equals(str) ? "" : str; + } else { + values[j] = ((JTextField) propMap.get(desc[j].getName())).getText(); + } + names[j] = desc[j].getName(); + ClassProperty prop = new ClassProperty(ids[j], values[j]); + propList.add(prop); + } + String json = objectToJson(propList); + System.out.println("classID=" + classID); + System.out.println("json=" + json); + System.out.println("ɾ..."); + try { + deleteClass(getICO(rev, classID).getUid()); + } catch (Exception e) { + e.printStackTrace(); + } + System.out.println("ͷ..."); + if (sendToClass(rev.getUid(), classID, json)) { + return true; + } else { + return false; + } + } + } catch (TCException e1) { + e1.printStackTrace(); + JOptionPane.showMessageDialog(null, e1, "", JOptionPane.ERROR_MESSAGE); + return false; + } + return true; + } + + 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 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/langtech/plm/classification/JAutoCompleteComboBox.java b/src/com/langtech/plm/classification/JAutoCompleteComboBox.java new file mode 100644 index 0000000..19a71e4 --- /dev/null +++ b/src/com/langtech/plm/classification/JAutoCompleteComboBox.java @@ -0,0 +1,160 @@ +package com.langtech.plm.classification; + +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/langtech/plm/classification/JDMethodUtil.java b/src/com/langtech/plm/classification/JDMethodUtil.java new file mode 100644 index 0000000..a515027 --- /dev/null +++ b/src/com/langtech/plm/classification/JDMethodUtil.java @@ -0,0 +1,47 @@ +package com.langtech.plm.classification; + +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/langtech/plm/classification/StringCreateUtil.java b/src/com/langtech/plm/classification/StringCreateUtil.java new file mode 100644 index 0000000..2025450 --- /dev/null +++ b/src/com/langtech/plm/classification/StringCreateUtil.java @@ -0,0 +1,21 @@ +package com.langtech.plm.classification; + +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/langtech/plm/createProjectStruct/CheckBoxTreeCellRenderer.java b/src/com/langtech/plm/createProjectStruct/CheckBoxTreeCellRenderer.java new file mode 100644 index 0000000..ac0862f --- /dev/null +++ b/src/com/langtech/plm/createProjectStruct/CheckBoxTreeCellRenderer.java @@ -0,0 +1,84 @@ +package com.langtech.plm.createProjectStruct; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; + +import javax.swing.JCheckBox; +import javax.swing.JPanel; +import javax.swing.JTree; +import javax.swing.UIManager; +import javax.swing.plaf.ColorUIResource; +import javax.swing.tree.TreeCellRenderer; + +public class CheckBoxTreeCellRenderer extends JPanel implements TreeCellRenderer +{ + protected JCheckBox check; + protected CheckBoxTreeLabel label; + + public CheckBoxTreeCellRenderer() + { + setLayout(null); + add(check = new JCheckBox()); + add(label = new CheckBoxTreeLabel()); + check.setBackground(UIManager.getColor("Tree.textBackground")); + label.setForeground(UIManager.getColor("Tree.textForeground")); + } + + + @Override + public Component getTreeCellRendererComponent(JTree tree, Object value, + boolean selected, boolean expanded, boolean leaf, int row, + boolean hasFocus) + { + String stringValue = tree.convertValueToText(value, selected, expanded, leaf, row, hasFocus); + setEnabled(tree.isEnabled()); + check.setSelected(((CheckBoxTreeNode)value).isSelected()); + label.setFont(tree.getFont()); + label.setText(stringValue); + label.setSelected(selected); + label.setFocus(hasFocus); + if(leaf) + //label.setIcon(UIManager.getIcon("Tree.leafIcon")); + label.setIcon(UIManager.getIcon("Tree.openIcon")); + else if(expanded) + label.setIcon(UIManager.getIcon("Tree.openIcon")); + else + label.setIcon(UIManager.getIcon("Tree.closedIcon")); + + return this; + } + + @Override + public Dimension getPreferredSize() + { + Dimension dCheck = check.getPreferredSize(); + Dimension dLabel = label.getPreferredSize(); + return new Dimension(dCheck.width + dLabel.width, dCheck.height < dLabel.height ? dLabel.height: dCheck.height); + } + + @Override + public void doLayout() + { + Dimension dCheck = check.getPreferredSize(); + Dimension dLabel = label.getPreferredSize(); + int yCheck = 0; + int yLabel = 0; + if(dCheck.height < dLabel.height) + yCheck = (dLabel.height - dCheck.height) / 2; + else + yLabel = (dCheck.height - dLabel.height) / 2; + check.setLocation(0, yCheck); + check.setBounds(0, yCheck, dCheck.width, dCheck.height); + label.setLocation(dCheck.width, yLabel); + label.setBounds(dCheck.width, yLabel, dLabel.width, dLabel.height); + } + + @Override + public void setBackground(Color color) + { + if(color instanceof ColorUIResource) + color = null; + super.setBackground(color); + } +} \ No newline at end of file diff --git a/src/com/langtech/plm/createProjectStruct/CheckBoxTreeLabel.java b/src/com/langtech/plm/createProjectStruct/CheckBoxTreeLabel.java new file mode 100644 index 0000000..e60b2be --- /dev/null +++ b/src/com/langtech/plm/createProjectStruct/CheckBoxTreeLabel.java @@ -0,0 +1,75 @@ +package com.langtech.plm.createProjectStruct; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; + +import javax.swing.Icon; +import javax.swing.JLabel; +import javax.swing.UIManager; +import javax.swing.plaf.ColorUIResource; + +public class CheckBoxTreeLabel extends JLabel +{ + private boolean isSelected; + private boolean hasFocus; + + public CheckBoxTreeLabel() + { + } + + @Override + public void setBackground(Color color) + { + if(color instanceof ColorUIResource) + color = null; + super.setBackground(color); + } + + @Override + public void paint(Graphics g) + { + String str; + if((str = getText()) != null) + { + if(0 < str.length()) + { + if(isSelected) + g.setColor(UIManager.getColor("Tree.selectionBackground")); + else + g.setColor(UIManager.getColor("Tree.textBackground")); + Dimension d = getPreferredSize(); + int imageOffset = 0; + Icon currentIcon = getIcon(); + if(currentIcon != null) + imageOffset = currentIcon.getIconWidth() + Math.max(0, getIconTextGap() - 1); + g.fillRect(imageOffset, 0, d.width - 1 - imageOffset, d.height); + if(hasFocus) + { + g.setColor(UIManager.getColor("Tree.selectionBorderColor")); + g.drawRect(imageOffset, 0, d.width - 1 - imageOffset, d.height - 1); + } + } + } + super.paint(g); + } + + @Override + public Dimension getPreferredSize() + { + Dimension retDimension = super.getPreferredSize(); + if(retDimension != null) + retDimension = new Dimension(retDimension.width + 3, retDimension.height); + return retDimension; + } + + public void setSelected(boolean isSelected) + { + this.isSelected = isSelected; + } + + public void setFocus(boolean hasFocus) + { + this.hasFocus = hasFocus; + } +} + diff --git a/src/com/langtech/plm/createProjectStruct/CheckBoxTreeNode.java b/src/com/langtech/plm/createProjectStruct/CheckBoxTreeNode.java new file mode 100644 index 0000000..3c8d676 --- /dev/null +++ b/src/com/langtech/plm/createProjectStruct/CheckBoxTreeNode.java @@ -0,0 +1,85 @@ +package com.langtech.plm.createProjectStruct; + +import javax.swing.tree.DefaultMutableTreeNode; + +public class CheckBoxTreeNode extends DefaultMutableTreeNode { + protected boolean isSelected; + + public CheckBoxTreeNode() { + this(null); + } + + public CheckBoxTreeNode(Object userObject) { + this(userObject, true, false); + } + + public CheckBoxTreeNode(Object userObject, boolean allowsChildren, boolean isSelected) { + super(userObject, allowsChildren); + this.isSelected = isSelected; + } + + public boolean isSelected() { + return isSelected; + } + + public void setSelected(boolean _isSelected) { + this.isSelected = _isSelected; + + if (_isSelected) { + // ѡУеӽ㶼ѡ + if (children != null) { + for (Object obj : children) { + CheckBoxTreeNode node = (CheckBoxTreeNode) obj; + if (_isSelected != node.isSelected()) + node.setSelected(_isSelected); + } + } + // ϼ飬ӽ㶼ѡУôҲѡ + CheckBoxTreeNode pNode = (CheckBoxTreeNode) parent; + // ʼpNodeӽڵǷ񶼱ѡ + if (pNode != null) { + int index = 0; + for (; index < pNode.children.size(); ++index) { + CheckBoxTreeNode pChildNode = (CheckBoxTreeNode) pNode.children.get(index); + if (!pChildNode.isSelected()) + break; + } + /* + * pNodeӽ㶼ѾѡУѡи㣬 ÷һݹ鷽ڴ˲ҪеΪ ѡи󣬸㱾ϼġ + */ + if (index == pNode.children.size()) { + if (pNode.isSelected() != _isSelected) + pNode.setSelected(_isSelected); + } + } + } else { + /* + * ȡ㵼ӽȡôʱеӽ㶼Ӧѡϵģ ӽȡ¸ȡȻ󸸽ȡҪȡӽ㣬 + * ʱDzҪȡӽġ + */ + if (children != null) { + int index = 0; + for (; index < children.size(); ++index) { + CheckBoxTreeNode childNode = (CheckBoxTreeNode) children.get(index); + if (!childNode.isSelected()) + break; + } + // ȡʱ + if (index == children.size()) { + for (int i = 0; i < children.size(); ++i) { + CheckBoxTreeNode node = (CheckBoxTreeNode) children.get(i); + if (node.isSelected() != _isSelected) + node.setSelected(_isSelected); + } + } + } + + // ȡֻҪһӽڵ㲻ѡϵģôڵͲӦñѡϡ + CheckBoxTreeNode pNode = (CheckBoxTreeNode) parent; + /* + * if (pNode != null && pNode.isSelected() != _isSelected) + * pNode.setSelected(_isSelected); + */ + } + } +} \ No newline at end of file diff --git a/src/com/langtech/plm/createProjectStruct/CheckBoxTreeNodeSelectionListener.java b/src/com/langtech/plm/createProjectStruct/CheckBoxTreeNodeSelectionListener.java new file mode 100644 index 0000000..ace469f --- /dev/null +++ b/src/com/langtech/plm/createProjectStruct/CheckBoxTreeNodeSelectionListener.java @@ -0,0 +1,34 @@ +package com.langtech.plm.createProjectStruct; + +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +import javax.swing.JTree; +import javax.swing.tree.TreePath; +import javax.swing.tree.DefaultTreeModel; + +public class CheckBoxTreeNodeSelectionListener extends MouseAdapter +{ + @Override + public void mouseClicked(MouseEvent event) + { + JTree tree = (JTree)event.getSource(); + int x = event.getX(); + int y = event.getY(); + int row = tree.getRowForLocation(x, y); + TreePath path = tree.getPathForRow(row); + System.out.println(path); + if(path != null) + { + CheckBoxTreeNode node = (CheckBoxTreeNode)path.getLastPathComponent(); + System.out.println(node); + if(node != null) + { + + boolean isSelected = !node.isSelected(); + node.setSelected(isSelected); + ((DefaultTreeModel)tree.getModel()).nodeStructureChanged(node); + } + } + } +} \ No newline at end of file diff --git a/src/com/langtech/plm/createProjectStruct/CreateProjectStructDialog.java b/src/com/langtech/plm/createProjectStruct/CreateProjectStructDialog.java new file mode 100644 index 0000000..392d7b0 --- /dev/null +++ b/src/com/langtech/plm/createProjectStruct/CreateProjectStructDialog.java @@ -0,0 +1,267 @@ +package com.langtech.plm.createProjectStruct; + + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.MouseListener; +import java.util.ArrayList; +import java.util.HashMap; + +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.swing.JTree; +import javax.swing.UIManager; +import javax.swing.tree.DefaultTreeModel; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentFolderType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.services.rac.core.ReservationService; + + + + +@SuppressWarnings("serial") +public class CreateProjectStructDialog extends AbstractAIFDialog{ + + protected TCSession session; + private TCComponent target; + private JLabel modelLabel; + private JComboBox modelBox; + private JTextField nameField; + private JLabel nameLabel; + private JTree jtree; + private JButton okButton; + private JButton celButton; + private HashMap> preMap = new HashMap>(); + + public static final String preName = "connor_LY6_FolderTemp"; + + public CreateProjectStructDialog(AbstractAIFApplication app) { + super(false); + this.session = (TCSession) app.getSession(); + this.target = (TCComponent) app.getTargetComponent(); + try { + initUI(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Override + public void run() { + try { + initUI(); + //UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); + UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); + } catch (Exception e) { + e.printStackTrace(); + } + } + + private void initUI() throws Exception { + this.setTitle("ģ崴ļ"); + Dimension dim = new Dimension(950, 600); + this.setPreferredSize(new Dimension(1000, 600)); + this.setMinimumSize(dim); + this.setLayout(new BorderLayout()); + modelLabel = new JLabel("ģ壺"); + modelBox = new JComboBox(); + modelBox.setPreferredSize(new Dimension(200,30)); + String[] prefVals = KUtil.getPrefVals(session, preName); + if(prefVals == null) { + MessageBox.post("ѡ " + preName + " ڻֵΪ", "ʾ ", MessageBox.INFORMATION); + return; + } + else { + for(String prefVal : prefVals) { + if(prefVal.contains("=")) { + String[] split = prefVal.split("="); + modelBox.addItem(split[0]); + ArrayList arrayList = new ArrayList(); + arrayList.add(split[1]); + arrayList.add(split[2]); + arrayList.add(split[3]); + preMap.put(split[0], arrayList); + } + } + } + nameLabel = new JLabel("Ŀƣ"); + nameField = new JTextField(); + nameField.setPreferredSize(new Dimension(200,30)); + JPanel topPanel = new JPanel(); + topPanel.add(modelLabel); + topPanel.add(modelBox); + topPanel.add(nameLabel); + topPanel.add(nameField); + + //String lookAndFeel = "com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel"; + //String lookAndFeel = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"; + String lookAndFeel = "javax.swing.plaf.metal.MetalLookAndFeel"; + UIManager.setLookAndFeel(lookAndFeel); + + jtree = new JTree(); + initTree(jtree); + JScrollPane centerPane = new JScrollPane(jtree); + + JPanel buttonPanel = new JPanel(); + okButton = new JButton(""); + celButton = new JButton("ȡ"); + buttonPanel.add(okButton); + buttonPanel.add(celButton); + + this.add(BorderLayout.NORTH,topPanel); + this.add(BorderLayout.CENTER,centerPane); + this.add(BorderLayout.SOUTH,buttonPanel); + + addListeners(); + showDialog(); + } + + /** + * + * @param tree + */ + private void initTree(JTree tree){ + ArrayList list = preMap.get(modelBox.getSelectedItem()); + String puid = list.get(0); + TCComponent component; + try { + component = session.stringToComponent(puid); + if(component == null || !(component instanceof TCComponentFolder)) { + MessageBox.post(puid + " puidTCвڶ߸puidӦIJǡļС", "쳣", MessageBox.ERROR); + return; + } + else { + CheckBoxTreeNode rootNode = new CheckBoxTreeNode(component.getStringProperty("object_name")); + buildTree(component,rootNode); + DefaultTreeModel model = new DefaultTreeModel(rootNode); + tree.addMouseListener(new CheckBoxTreeNodeSelectionListener()); + tree.setModel(model); + tree.setCellRenderer(new CheckBoxTreeCellRenderer()); + //չнڵ㲢ѡ + for (int i = 0; i < tree.getRowCount(); i++) { + tree.expandRow(i); + } + rootNode.setSelected(true); + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + /** + * ݹ鴴ӽڵ + * @param component + * @param rootNode + * @throws TCException + */ + private void buildTree(TCComponent component, CheckBoxTreeNode rootNode) throws TCException { + TCComponent[] relatedComponent = component.getRelatedComponents("contents"); + if(relatedComponent != null) { + for (TCComponent child : relatedComponent) { + CheckBoxTreeNode childNode = new CheckBoxTreeNode(child.getStringProperty("object_name")); + rootNode.add(childNode); + buildTree(child,childNode); + } + } + + } + + /** + * ݹ½ļнṹ + * @param root ڵ + * @param folder ڵɵļ + * @param folderType + * @throws Exception + */ + private void createFolderStruct(CheckBoxTreeNode root, TCComponentFolder parentFolder, + TCComponentFolderType folderType,boolean ifTop) throws Exception { + if(root.isSelected()) { + if(ifTop) { + for (int i = 0; i < root.getChildCount(); i++) { + CheckBoxTreeNode child = (CheckBoxTreeNode) root.getChildAt(i); + createFolderStruct(child,parentFolder,folderType,false); + } + } + else { + TCComponentFolder folder = KUtil.createFolderBySOA(folderType.getTypeName(), root.toString()); + parentFolder.add("contents", folder); + for (int i = 0; i < root.getChildCount(); i++) { + CheckBoxTreeNode child = (CheckBoxTreeNode) root.getChildAt(i); + createFolderStruct(child,folder,folderType,false); + } + } + } + + } + + private void addListeners() { + this.celButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + this.okButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + String name = nameField.getText(); + ArrayList list = preMap.get(modelBox.getSelectedItem()); + if (name.isEmpty()) { + MessageBox.post("дĿƣ", "ʾ ", MessageBox.INFORMATION); + } else { + TCComponentFolderType folderType; + try { + KUtil.setByPass(true); + folderType = (TCComponentFolderType) session.getTypeComponent(list.get(1)); + TCComponentFolder folder = KUtil.createFolderBySOA(folderType.getTypeName(), name); + //TCComponentFolder folder = folderType.create(name, "", "LD6_CusProdFolder"); + target.add("contents", folder); + CheckBoxTreeNode root = (CheckBoxTreeNode) jtree.getModel().getRoot(); + createFolderStruct(root,folder,(TCComponentFolderType) session.getTypeComponent(list.get(2)),true); + KUtil.setByPass(false); + disposeDialog(); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + } + }); + this.modelBox.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent event) { + if(event.getStateChange() == ItemEvent.SELECTED) { + //ˢ + jtree.setModel(null); + // ȡƳе MouseListener + MouseListener[] mouseListeners = jtree.getMouseListeners(); + for (MouseListener listener : mouseListeners) { + jtree.removeMouseListener(listener); + } + + // ֤ػ + jtree.revalidate(); + jtree.repaint(); + initTree(jtree); + }else if(event.getStateChange() == ItemEvent.DESELECTED){ + + } + } + }); + } + +} diff --git a/src/com/langtech/plm/createProjectStruct/CreateProjectStructHandler.java b/src/com/langtech/plm/createProjectStruct/CreateProjectStructHandler.java new file mode 100644 index 0000000..69bf121 --- /dev/null +++ b/src/com/langtech/plm/createProjectStruct/CreateProjectStructHandler.java @@ -0,0 +1,51 @@ +package com.langtech.plm.createProjectStruct; + +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.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class CreateProjectStructHandler extends AbstractHandler{ + + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + try { + + new Thread() { + @Override + public void run() { + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + + if(targetComponent instanceof TCComponentFolder) { + new CreateProjectStructDialog(app); + } + else { + MessageBox.post("ѡһͻļУ", "ʾ ", MessageBox.INFORMATION); + } + + + + } + }.start(); + + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + return null; + } + + +} diff --git a/src/com/langtech/plm/createProjectStruct/KUtil.java b/src/com/langtech/plm/createProjectStruct/KUtil.java new file mode 100644 index 0000000..afadcad --- /dev/null +++ b/src/com/langtech/plm/createProjectStruct/KUtil.java @@ -0,0 +1,2238 @@ +package com.langtech.plm.createProjectStruct; + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.Window; +import java.io.BufferedWriter; +import java.io.EOFException; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileWriter; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.time.Instant; +import java.time.LocalDate; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JDialog; +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.filechooser.FileNameExtensionFilter; +import javax.swing.filechooser.FileSystemView; + +import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.WorkbookFactory; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Shell; + + +import com.teamcenter.rac.aif.commands.open.OpenCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.common.lov.view.components.LOVDisplayer; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentContextList; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentGroupMember; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemRevisionType; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCComponentManager; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentRole; +import com.teamcenter.rac.kernel.TCComponentSchedule; +import com.teamcenter.rac.kernel.TCComponentScheduleDeliverable; +import com.teamcenter.rac.kernel.TCComponentTCCalendar; +import com.teamcenter.rac.kernel.TCComponentTaskDeliverable; +import com.teamcenter.rac.kernel.TCComponentType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCPropertyDescriptor; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTextService; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.schedule.calendar.TCCalendar; +import com.teamcenter.rac.schedule.componentutils.CalendarHelper; +import com.teamcenter.rac.ui.common.RACUIUtil; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.Registry; +import com.teamcenter.rac.util.UIUtilities; +import com.teamcenter.services.rac.core.DataManagementService; +import com.teamcenter.services.rac.core.LOVService; +import com.teamcenter.services.rac.core._2006_03.DataManagement.Relationship; +import com.teamcenter.services.rac.core._2007_01.DataManagement.WhereReferencedInfo; +import com.teamcenter.services.rac.core._2007_01.DataManagement.WhereReferencedOutput; +import com.teamcenter.services.rac.core._2007_01.DataManagement.WhereReferencedResponse; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateIn; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateInput; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateOut; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateResponse; +import com.teamcenter.services.rac.core._2013_05.LOV.InitialLovData; +import com.teamcenter.services.rac.core._2013_05.LOV.LOVSearchResults; +import com.teamcenter.services.rac.core._2013_05.LOV.LOVValueRow; +import com.teamcenter.services.rac.core._2013_05.LOV.LovFilterData; +import com.teamcenter.soa.client.model.LovValue; +import com.teamcenter.soa.client.model.ServiceData; + +import k.KLocale; + +@SuppressWarnings("deprecation") +public class KUtil { + + public static final TCSession session; + public static final TCTextService textService; +// public static final Registry REG = Registry.getRegistry(KUtil.class); + public static final ZoneId zoneId = ZoneId.systemDefault(); +// public static final Registry reg = Registry.getRegistry(KUtil.class); + +// public static String getRegString(String title) { +// String res = reg.getString(title); +// if (KUtil.isEmpty(res)) { +// return title; +// } +// return res; +// } + + static { + session = (TCSession) AIFUtility.getCurrentApplication().getSession(); + textService = session.getTextService(); + } + + public static void setTCPropertyValue(TCComponent item, String propertyName, Object value) { + try { + TCProperty tcProperty = item.getTCProperty(propertyName); + switch (tcProperty.getPropertyType()) { + case TCProperty.PROP_double: + if (value instanceof Double) { + tcProperty.setDoubleValue((double) value); + } else { + tcProperty.setDoubleValue(Double.parseDouble(value.toString())); + } + break; + case TCProperty.PROP_int: + if (value instanceof Integer) { + tcProperty.setDoubleValue((int) value); + } else { + tcProperty.setDoubleValue(Integer.parseInt(value.toString())); + } + break; + case TCProperty.PROP_string: + tcProperty.setStringValue(value.toString()); + break; + case TCProperty.PROP_date: + if (value instanceof Date) { + tcProperty.setDateValue((Date) value); + } else { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-dd HH:mm"); + tcProperty.setDateValue(sdf.parse(value.toString())); + } + break; + default: + break; + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static Object getTCPropertyValue(TCComponent item, String propertyName) { + Object result = ""; + try { + TCProperty tcProperty = item.getTCProperty(propertyName); + if (tcProperty == null) { + System.out.println("δȡԣ" + propertyName); + return result; + } + switch (tcProperty.getPropertyType()) { + case TCProperty.PROP_double: + result = tcProperty.getDoubleValue(); + break; + case TCProperty.PROP_int: + result = tcProperty.getIntValue(); + break; + case TCProperty.PROP_string: + result = tcProperty.getStringValue(); + break; + case TCProperty.PROP_date: + result = tcProperty.getDateValue(); + break; + case TCProperty.PROP_logical: + result = tcProperty.getLogicalValue(); + break; + default: + break; + } + } catch (TCException e) { + e.printStackTrace(); + } + return result; + } + + public static String getCellValue(Cell c) { + if (c == null) { + return ""; + } + String value = ""; + if (c.getCellType() == CellType.NUMERIC.getCode()) { + DecimalFormat df = new DecimalFormat("0"); + String whatYourWant = df.format(c.getNumericCellValue()); + return whatYourWant; + } + switch (c.getCellType()) { + case HSSFCell.CELL_TYPE_NUMERIC:// + value = (c.getNumericCellValue() + "").split("\\.")[0]; + break; + case HSSFCell.CELL_TYPE_STRING:// ַ + value = c.getStringCellValue(); + break; + case HSSFCell.CELL_TYPE_BOOLEAN:// boolean + value = c.getBooleanCellValue() + ""; + break; + case HSSFCell.CELL_TYPE_FORMULA:// ʽ + value = c.getCellFormula() + ""; + break; + case HSSFCell.CELL_TYPE_BLANK:// ֵ + value = ""; + break; + case HSSFCell.CELL_TYPE_ERROR: + value = "Ƿַ"; + break; + default: + value = "δ֪"; + break; + } + return value; + } + + /** + * õʵ + * + * @param sheet + * @param flag ҪдݿExcelԪöŸ Excel5еԪ4 + * Ҫ⣬2вҪ⣬flagʹ [0,2,3,4] + * @return + * @throws Exception + * + */ + public static int findRealRows(Sheet sheet, int... flag) throws Exception { + int row_real = 0; + int rows = sheet.getPhysicalNumberOfRows();// ˴ͳд, + try { + + for (int i = 1; i < rows; i++) { + Row row = sheet.getRow(i); + int total = 0; + ArrayList blank = new ArrayList(); + int type = -1; + String s = null; + for (int j : flag) { + if (!(row.getCell(j) == null) && row.getCell(j).getCellType() < 2) { + type = row.getCell(j).getCellType(); + row.getCell(j).setCellType(1); + } + + if (row.getCell(j) == null || row.getCell(j).getStringCellValue().matches("^\\s+$") + || row.getCell(j).getCellType() > 2) { + total++; + + if (!(row.getCell(j) == null) && row.getCell(j).getCellType() < 2) { + row.getCell(j).setCellType(type); + } + blank.add(j); + + } + } + System.out.println(s + ""); + // 4жǿ˵͸÷ + if (total == flag.length) { + + return row_real; + } else if (total == 0) { + row_real++; + + } else { + String h = ""; + for (Integer b : blank) { + + h = h + "" + (b + 1) + "" + " "; + } + throw new Exception("" + (i + 1) + "" + h + "Ϊ"); + } + + } + } catch (NullPointerException e) { + throw new Exception("excelʽ쳣,excelʽȱʧ,Ч!"); + } + return row_real; + } + + public static Workbook getWorkbook(File file) throws Exception { + Workbook workbook = null; + FileInputStream in = new FileInputStream(file); + if (file.getName().endsWith("xlsx")) { + System.out.println("ȡģ:" + file.getName()); + try { + workbook = WorkbookFactory.create(in); + } catch (EOFException e) { + e.printStackTrace(); + } +// workbook = new XSSFWorkbook(in); + } else { + System.out.println("ʽ"); + } + in.close(); + return workbook; + } + + public static void removeEnd(StringBuilder sb, int len) { + if (sb == null || len <= 0) { + return; + } + if (sb.length() >= len) { + sb.setLength(sb.length() - len); + } + } + + public static TCComponent[] getComponentsByItemType(TCComponent comp, String type, String relation) + throws TCException { + TCComponent[] comps1 = comp.getRelatedComponents(relation); + if (comps1 == null || comps1.length < 1) { + return null; + } + ArrayList list = new ArrayList(); + for (TCComponent comp1 : comps1) { + if (comp1.getType().equals(type)) { + list.add(comp1); + } + } + return list.toArray(new TCComponent[] {}); + } + + public static TCComponentContextList objectsInProject(String type, String projId) throws Exception { + if (KUtil.isEmpty(type) || KUtil.isEmpty(projId)) { + return null; + } + String queryName = "Objects in Projects"; + String[] keys = new String[] { KUtil.getText("Type"), KUtil.getText("ProjectID") }; + String[] vals = new String[] { type, projId }; + return KUtil.query(KUtil.session, queryName, keys, vals); + } + + public static TCComponentContextList objectsInProject(String type, String projId, String name) throws Exception { + if (KUtil.isEmpty(type) || KUtil.isEmpty(projId) || KUtil.isEmpty(name)) { + return null; + } + String queryName = "Objects in Projects"; + String[] keys = new String[] { KUtil.getText("Name"), KUtil.getText("Type"), KUtil.getText("ProjectID") }; + String[] vals = new String[] { name, type, projId }; + return KUtil.query(KUtil.session, queryName, keys, vals); + } + + public static boolean checkGMPrivilegeFromPref(String prefName) throws Exception { + boolean validityCanEdit = false; + String validRoles = KUtil.getPrefVal(KUtil.session, prefName); + System.out.println(">> Check GroupMember Priv: " + validRoles); + if (!KUtil.isEmpty(validRoles)) { + List groups = new ArrayList(); + List roles = new ArrayList(); + String[] split = validRoles.split(":"); + for (String string : split) { + if (string.startsWith("G.")) { + groups.add(string.substring(2)); + } else if (string.startsWith("R.")) { + roles.add(string.substring(2)); + } + } + TCComponentUser currentUser = KUtil.session.getUser(); + System.out.println(">> Current User: " + currentUser); + TCComponentGroupMember[] gms = currentUser.getGroupMembers(); + System.out.println(">> Current GroupMembers: " + Arrays.toString(gms)); + int len = KUtil.getLen(gms); + for (int i = 0; i < len; i++) { + TCComponentGroupMember gm = gms[i]; + TCComponentGroup g = gm.getGroup(); + TCComponentRole r = gm.getRole(); + String gName = g.getGroupName(); + String rName = r.getRoleName(); + System.out.println((i + 1) + ". " + gName + " - " + rName); + if (groups.contains(gName) && roles.contains(rName)) { + validityCanEdit = true; + // break; + } + } + } + return validityCanEdit; + } + + public static boolean compare(String str1, String str2) { + if (str1 == null) { + str1 = ""; + } + if (str2 == null) { + str2 = ""; + } + return str1.equals(str2); + } + + public static boolean compare(Object str1, Object str2) { + if (str1 == null) { + return str2 == null; + } + return str1.equals(str2); + } + + public static TCComponentItem createItem(TCComponentItemType itemType, String itemName) throws Exception { + if (itemType == null) { + return null; + } + String id = itemType.getNewID(); + String rev = itemType.getNewRev(null); + return itemType.create(id, rev, itemType.getName(), itemName, "", null); + } + + public static void setByPass(boolean val) { + try { + TCUserService userservice = session.getUserService(); + userservice.call(val ? "CONNOR_open_bypass" : "CONNOR_close_bypass", new Object[] { "" }); + System.out.println(val ? "Open Bypass" : "Close Bypass"); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static TCComponentItem createItemBySOA(String itemTypeName, String revTypeName, String revMasterTypeName, + String itemId, String revId, String name, Map stringProps, Map dateProps) + throws Exception { + if (KUtil.isEmpty(itemTypeName) || KUtil.isEmpty(revTypeName) || KUtil.isEmpty(revMasterTypeName)) { + return null; + } + CreateInput revMasterInput = new CreateInput(); + revMasterInput.boName = revMasterTypeName; + if (stringProps != null) { + revMasterInput.stringProps = stringProps; + } + if (dateProps != null) { + revMasterInput.dateProps = dateProps; + } + CreateInput revInput = new CreateInput(); + revInput.boName = revTypeName; + Map revPropMap = new HashMap<>(); + if (!KUtil.isEmpty(revId)) { + revPropMap.put("item_revision_id", revId); + } + revInput.stringProps = revPropMap; + Map revMasterInfoMap = new HashMap<>(); + revMasterInfoMap.put("IMAN_master_form_rev", new CreateInput[] { revMasterInput }); + revInput.compoundCreateInput = revMasterInfoMap; + // create rev + CreateInput itemInput = new CreateInput(); + itemInput.boName = itemTypeName; + Map itemPropMap = new HashMap<>(); + if (!KUtil.isEmpty(itemId)) { + itemPropMap.put("item_id", itemId); + } + if (!KUtil.isEmpty(name)) { + itemPropMap.put("object_name", name); + } + itemInput.stringProps = itemPropMap; + Map revInfoMap = new HashMap<>(); + revInfoMap.put("revision", new CreateInput[] { revInput }); + itemInput.compoundCreateInput = revInfoMap; + // create info + CreateIn cI = new CreateIn(); + cI.clientId = "CreateItem"; + cI.data = itemInput; + // service + DataManagementService service = DataManagementService.getService(session); + // create + CreateResponse resp = service.createObjects(new CreateIn[] { cI }); + throwServiceDataError(resp.serviceData); + CreateOut[] cOs = resp.output; + if (cOs.length > 0) { + for (TCComponent s : cOs[0].objects) { + if (s instanceof TCComponentItem) { + return (TCComponentItem) s; + } + } + } + return null; + } + + public static TCComponentFolder createFolderBySOA(String folderTypeName, String folderName) throws Exception { + if (KUtil.isEmpty(folderTypeName)) { + return null; + } + CreateInput itemInput = new CreateInput(); + itemInput.boName = folderTypeName; + Map itemPropMap = new HashMap<>(); + itemPropMap.put("object_name", folderName); + itemInput.stringProps = itemPropMap; + // create info + CreateIn cI = new CreateIn(); + cI.clientId = "CreateFolder"; + cI.data = itemInput; + // service + DataManagementService service = DataManagementService.getService(session); + // create + CreateResponse resp = service.createObjects(new CreateIn[] { cI }); + throwServiceDataError(resp.serviceData); + CreateOut[] cOs = resp.output; + if (cOs.length > 0) { + for (TCComponent s : cOs[0].objects) { + if (s instanceof TCComponentFolder) { + return (TCComponentFolder) s; + } + } + } + return null; + } + + public static void throwServiceDataError(ServiceData serviceData) throws Exception { + if (serviceData.sizeOfPartialErrors() > 0) { + StringBuilder errInfo = new StringBuilder(); + for (int i = 0; i < serviceData.sizeOfPartialErrors(); i++) { + for (String msg : serviceData.getPartialError(i).getMessages()) { + errInfo.append(msg + "\n"); + } + } + // System.out.println(errInfo.toString()); + throw new Exception(errInfo.toString()); + } + } + + public static void throwServiceDataError(ServiceData serviceData, String defaultErrorMsg) throws Exception { + if (serviceData.sizeOfPartialErrors() > 0) { + StringBuilder errInfo = new StringBuilder(); + for (int i = 0; i < serviceData.sizeOfPartialErrors(); i++) { + for (String msg : serviceData.getPartialError(i).getMessages()) { + errInfo.append(msg + "\n"); + } + } + // System.out.println(errInfo.toString()); + if (KUtil.isEmpty(errInfo.toString())) { + throw new Exception(defaultErrorMsg); + } + throw new Exception(errInfo.toString()); + } + } + + public static Date localDateToDate(LocalDate localDate) { + if (localDate == null) { + return null; + } + ZonedDateTime zdt = localDate.atStartOfDay(zoneId); + Date date = Date.from(zdt.toInstant()); + return date; + } + + public static LocalDate dateToLocalDate(Date date) { + if (date == null) { + return null; + } + Instant instant = date.toInstant(); + LocalDate localDate = instant.atZone(zoneId).toLocalDate(); + return localDate; + } + + public static TCComponent stringToComponent(String uid) throws Exception { + if (KUtil.isEmpty(uid)) { + return null; + } + return session.stringToComponent(uid); + } + + public static String getText(String str) throws Exception { + if (KUtil.isEmpty(str)) { + return str; + } + String res = textService.getTextValue(str); + if (!KUtil.isEmpty(res)) { + return res; + } + return str; + } + + public static void sendTo(TCComponent comp, String perspectiveId) { + if (comp == null) { + return; + } + if (KUtil.isEmpty(perspectiveId)) { + perspectiveId = "com.teamcenter.rac.ui.perspectives.navigatorPerspective"; + } + com.teamcenter.rac.common.Activator.getDefault().openPerspective(perspectiveId); + com.teamcenter.rac.common.Activator.getDefault().openComponents(perspectiveId, new TCComponent[] { comp }); + } + + public static void open(TCComponent comp) { + if (comp == null) { + return; + } + if (comp instanceof TCComponentScheduleDeliverable) { + System.out.println(">> Open Schedule Deliverable: " + comp); + try { + comp = comp.getReferenceProperty("deliverable_inst"); + System.out.println(">> Open Schedule Deliverable Inst: " + comp); + if (comp == null) { + return; + } + } catch (Exception e) { + e.printStackTrace(); + } + } else if (comp instanceof TCComponentTaskDeliverable) { + System.out.println(">> Open Task Deliverable: " + comp); + try { + comp = comp.getReferenceProperty("fnd0DeliverableInstance"); + System.out.println(">> Open Task Deliverable Inst: " + comp); + if (comp == null) { + return; + } + } catch (Exception e) { + e.printStackTrace(); + } + } + try { + Registry localRegistry = Registry.getRegistry("com.teamcenter.rac.commands.open.open"); + OpenCommand localOpenCommand = (OpenCommand) localRegistry.newInstanceForEx("openCommand", + new Object[] { AIFUtility.getActiveDesktop(), comp }); + localOpenCommand.executeModeless(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static JButton getImageBtn(String iconName) { + ImageIcon icon = new ImageIcon(KUtil.class.getResource("/icons/" + iconName)); + JButton btn = new JButton(icon); + btn.setPreferredSize(new Dimension(26, 26)); + btn.setContentAreaFilled(true); + btn.setFocusPainted(false); + btn.setBorderPainted(true); + // btn.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + return btn; + } + + public static void info(Window dialog, String msg) { + MessageBox.post(dialog, msg, "", MessageBox.INFORMATION); + } + + public static void warn(Window dialog, String msg) { + MessageBox.post(dialog, msg, "", MessageBox.WARNING); + } + + public static void error(Window dialog, String msg) { + MessageBox.post(dialog, msg, "", MessageBox.ERROR); + } + + public static void error(Window dialog, String msg, String title) { + MessageBox.post(dialog, msg, title, MessageBox.ERROR); + } + + public static void showScrollDialog(Window dialog, String text, String title) { + if (dialog == null) { + dialog = UIUtilities.getCurrentModalDialog(); + } + JTextArea textArea = new JTextArea(text); + textArea.setEditable(false); + JScrollPane scrollPane = new JScrollPane(textArea); + textArea.setLineWrap(true); + textArea.setWrapStyleWord(true); + scrollPane.setPreferredSize(new Dimension(500, 300)); + JOptionPane.showMessageDialog(dialog, scrollPane, title, JOptionPane.INFORMATION_MESSAGE); + } + + public static void showScrollDialogWithExport(Window dialog, String text, String title, String exportFileName) { + if (dialog == null) { + dialog = UIUtilities.getCurrentModalDialog(); + } + JTextArea textArea = new JTextArea(text); + textArea.setEditable(false); + JScrollPane scrollPane = new JScrollPane(textArea); + textArea.setLineWrap(true); + textArea.setWrapStyleWord(true); + scrollPane.setPreferredSize(new Dimension(500, 300)); + String yesOption = KLocale.getString("ok"); + String exportOption = KLocale.getString("export"); + int op = JOptionPane.showOptionDialog(dialog, scrollPane, title, JOptionPane.YES_NO_OPTION, + JOptionPane.INFORMATION_MESSAGE, null, new String[] { yesOption, exportOption }, yesOption); + if (op == 1) { + System.out.println("Export"); + File saveFile = KUtil.chooseSaveFile(dialog, exportFileName, "txt"); + if (saveFile != null) { + try { + BufferedWriter writer = new BufferedWriter(new FileWriter(saveFile, false)); + writer.write(text); + writer.flush(); + writer.close(); + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post(dialog, e); + } + } + } + } + + public static void errorSWT(Shell shell, String message, String title) { + showDialog(shell, message, title, SWT.ICON_ERROR); + } + + public static void showDialog(Shell shell, String message, String title, int type) { + org.eclipse.swt.widgets.MessageBox dialog = new org.eclipse.swt.widgets.MessageBox(shell, SWT.OK | type); + dialog.setText(title); + dialog.setMessage(message); + dialog.open(); + } + + public static String[] getPrefVals(TCSession session, String prefName) throws Exception { + if (KUtil.isEmpty(prefName)) { + return null; + } + return session.getPreferenceService().getStringValues(prefName); + } + + public static String getPrefVal(TCSession session, String prefName) throws Exception { + if (KUtil.isEmpty(prefName)) { + return null; + } + return session.getPreferenceService().getStringValue(prefName); + } + + public static String getReg(Registry reg, String name) { + String val = reg.getString(name); + // System.out.println("Read REG: " + name + " = " + val); + return val; + } + +// public static String getReg(String name) { +// return getReg(REG, name); +// } + + public static void newRow(JPanel panel, Component comp, GridBagConstraints s, int width) { + newRow(panel, comp, s, width, 0); + } + + public static void newRow(JPanel panel, Component comp, GridBagConstraints s, int width, double weightx) { + s.weightx = weightx; + s.gridwidth = width; + s.gridx = 0; + s.gridy++; + panel.add(comp, s); + } + + public static void newRow(JDialog panel, Component comp, GridBagConstraints s, int width) { + s.weightx = 0; + s.gridwidth = width; + s.gridx = 0; + s.gridy++; + panel.add(comp, s); + } + + public static void addCol(JPanel panel, Component comp, GridBagConstraints s, int width, double weightx) { + s.gridx++; + s.gridwidth = width; + s.weightx = weightx; + panel.add(comp, s); + } + + public static TCComponentDataset getDataset(TCComponent rev, String dsType, String dsName, String rel) + throws Exception { + if (rev == null || KUtil.isEmpty(dsName)) { + return null; + } + rev.refresh(); + TCComponent[] kids = rev.getRelatedComponents(rel); + for (TCComponent c : kids) { + if (c.getType().equals(dsType) && c.toString().equals(dsName)) { + return (TCComponentDataset) c; + } + } + return null; + } + + public static List getDatasets(TCComponent rev, String dsType, String rel) throws Exception { + if (rev == null) { + return null; + } + rev.refresh(); + List res = new ArrayList(); + TCComponent[] kids = rev.getRelatedComponents(rel); + for (TCComponent c : kids) { + if (c.getType().equals(dsType)) { + res.add((TCComponentDataset) c); + } + } + return res; + } + + public static List getChildComponents(TCComponent rev, String dsType, String rel, String dsNamePrefix) + throws Exception { + if (rev == null) { + return null; + } + rev.refresh(); + List res = new ArrayList(); + TCComponent[] kids = rev.getRelatedComponents(rel); + for (TCComponent c : kids) { + if (c.getType().equals(dsType) && c.getProperty("object_name").startsWith(dsNamePrefix)) { + res.add(c); + } + } + return res; + } + + public static List getChildComponentsContainsStr(TCComponent rev, String dsType, String rel, + String dsNameSubStr) throws Exception { + if (rev == null) { + return null; + } + if (dsNameSubStr == null) { + dsNameSubStr = ""; + } + rev.refresh(); + List res = new ArrayList(); + TCComponent[] kids = rev.getRelatedComponents(rel); + for (TCComponent c : kids) { + if (c.getType().equals(dsType) && c.getProperty("object_name").contains(dsNameSubStr)) { + res.add(c); + } + } + return res; + } + + public static List getChildComponents(TCComponent rev, String dsType, String rel) throws Exception { + if (rev == null) { + return null; + } + rev.refresh(); + List res = new ArrayList(); + TCComponent[] kids = rev.getRelatedComponents(rel); + for (TCComponent c : kids) { + if (c.getType().equals(dsType)) { + res.add(c); + } + } + return res; + } + + public static TCComponentFolder getChildFolder(TCComponentFolder folder, String cFolderName) throws Exception { + if (folder == null || cFolderName == null) { + return null; + } + AIFComponentContext[] cc = folder.getChildren(); + int len = KUtil.getLen(cc); + for (int i = 0; i < len; i++) { + InterfaceAIFComponent c = cc[i].getComponent(); + if ((c instanceof TCComponentFolder) && cFolderName.equals(c.getProperty("object_name"))) { + return (TCComponentFolder) c; + } + } + return null; + } + + public static TCComponentDataset uploadFile(TCSession session, TCComponent rev, File newFile, String dsName, + String dsTypeName, String refName, String rel) throws Exception { + TCComponentDataset ds = getDataset(rev, dsTypeName, dsName, rel); + if (ds == null) { + TCComponentDatasetType dsType = (TCComponentDatasetType) session.getTypeComponent(dsTypeName); + ds = dsType.create(dsName, "", dsTypeName); + if (rev != null) { + rev.add(rel, ds); + rev.refresh(); + } + } + setDsFile(ds, refName, newFile); + return ds; + } + + public static void setDsFile(TCComponentDataset ds, String refName, File newFile) throws Exception { + if (ds.isCheckedOut()) { + throw new Exception(String.format(KLocale.getString("uploadfilewhencheckout.ERROR1"), ds.toString())); + } + String[] refs = new String[] { refName }; + String[] files = new String[] { newFile.getAbsolutePath() }; + ds.setFiles(files, refs); + // ds.save(); + ds.refresh(); + } + + public static void setDsFile2(TCComponentDataset ds, String refName, File newFile) throws Exception { + String[] refs = new String[] { refName }; + String[] files = new String[] { newFile.getAbsolutePath() }; + ds.setFiles(files, refs); + // ds.save(); + ds.refresh(); + } + + public static boolean isEmpty(String str) { + return str == null || "".equals(str.trim()); + } + + public static int inArray(int target, int[] arr) { + int len = arr == null ? 0 : arr.length; + for (int i = 0; i < len; i++) { + if (target == arr[i]) { + return i; + } + } + return -1; + } + + public static boolean inArray(String str, String arr, String splitter) { + if (KUtil.isEmpty(arr) || KUtil.isEmpty(splitter)) { + return false; + } + if (KUtil.isEmpty(str)) { + return true; + } + return inArray(str, arr.split(splitter)) >= 0; + } + + public static int inArray(String target, String[] arr) { + int len = arr == null ? 0 : arr.length; + for (int i = 0; i < len; i++) { + if (target.equals(arr[i])) { + return i; + } + } + return -1; + } + + public static int getNextColNumber(int currentIndex, int[] skipColIndex, int cols) { + int res = currentIndex; + for (int i = 0; i < cols; i++) { + res++; + if (inArray(res, skipColIndex) >= 0) { + i--; + } + } + return res; + } + + public static List> groupList(List originList, int maxCount, int gap, E gapFiller) { + List> res = new ArrayList>(); + int cnt = originList == null ? 0 : originList.size(); + List list = new ArrayList(); + for (int i = 0; i < cnt; i++) { + list.add(originList.get(i)); + if (i != cnt - 1) {// add gap + for (int j = 0; j < gap; j++) { + list.add(gapFiller); + } + } + } + cnt = list == null ? 0 : list.size(); + if (maxCount <= 0) { + maxCount = cnt; + } + int pageCounter = 0; + List cList = new ArrayList(); + res.add(cList); + for (int i = 0; i < cnt; i++) { + if (pageCounter == maxCount) { + cList = new ArrayList<>(); + res.add(cList); + pageCounter = 0; + } + if (cList != null) { + E item = list.get(i); + if (cList.size() == 0 && item == gapFiller) { + continue; + } + cList.add(list.get(i)); + pageCounter++; + } + } + list.clear(); + list = null; + return res; + } + + public static List> groupListWithGapAdded(List list, int maxCount, E gapFiller) { + List> res = new ArrayList>(); + int cnt = list == null ? 0 : list.size(); + if (maxCount <= 0) { + maxCount = cnt; + } + int pageCounter = 0; + List cList = new ArrayList(); + res.add(cList); + for (int i = 0; i < cnt; i++) { + if (pageCounter == maxCount) { + cList = new ArrayList<>(); + res.add(cList); + pageCounter = 0; + } + if (cList != null) { + E item = list.get(i); + if (cList.size() == 0 && item == gapFiller) { + continue; + } + cList.add(list.get(i)); + pageCounter++; + } + } + list.clear(); + list = null; + return res; + } + + public static List>> groupList(List> originList, int maxCount, int gap, + Map gapFiller, String gapKey) { + List>> res = new ArrayList>>(); + int cnt = originList == null ? 0 : originList.size(); + List> list = new ArrayList>(); + boolean addGap = false; + for (int i = 0; i < cnt; i++) { + Map item = originList.get(i); + list.add(item); + if (i != cnt - 1) {// add gap + Map nextItem = originList.get(i + 1); + addGap = KUtil.isEmpty(gapKey) || (nextItem != null && nextItem.containsKey(gapKey)); + for (int j = 0; j < gap; j++) { + if (addGap) { + list.add(gapFiller); + } + } + } + } + cnt = list == null ? 0 : list.size(); + if (maxCount <= 0) { + maxCount = cnt; + } + int pageCounter = 0; + List> cList = new ArrayList>(); + res.add(cList); + for (int i = 0; i < cnt; i++) { + if (pageCounter == maxCount) { + cList = new ArrayList<>(); + res.add(cList); + pageCounter = 0; + } + if (cList != null) { + Map item = list.get(i); + if (cList.size() == 0 && item == gapFiller) { + continue; + } + cList.add(list.get(i)); + pageCounter++; + } + } + list.clear(); + list = null; + return res; + } + + public static File getFileFromDataset(TCSession session, String dsType, String uid, String prefName) + throws Exception { + TCComponent comp = null; + try { + comp = session.stringToComponent(uid); + } catch (Exception e) { + e.printStackTrace(); + } + if (comp == null) { + throw new Exception(String.format(KLocale.getString("dsuidinpref.ERROR1"), prefName)); + } + String type = comp.getType(); + System.out.println("Dataset: " + comp + "|Type: " + type); + if (!dsType.equals(type)) { + throw new Exception(String.format(KLocale.getString("dsuidinpref.ERROR1"), prefName)); + } + TCComponentDataset tDataset = (TCComponentDataset) comp; + return getDatasetFile(tDataset); + } + + public static File getDatasetFile(TCComponentDataset dataset) throws Exception { + File[] files = dataset.getFiles("", System.getenv("TEMP")); + if (files == null || files.length == 0) { + throw new Exception(String.format(KLocale.getString("norefindataset.ERROR1"), dataset.toString())); + } + System.out.println(">> Download file (" + files.length + "): " + files[0].getAbsolutePath()); + return files[0]; + } + + public static File getDatasetFile(File dir, TCComponentDataset dataset) throws Exception { + if (dir == null || !dir.isDirectory()) { + throw new Exception("Directory not found."); + } + File[] files = dataset.getFiles("", dir.getAbsolutePath()); + if (files == null || files.length == 0) { + throw new Exception(String.format(KLocale.getString("norefindataset.ERROR1"), dataset.toString())); + } + System.out.println(">> Download file (" + files.length + "): " + files[0].getAbsolutePath()); + return files[0]; + } + + public static String[] getStringArrayProp(TCComponentForm form, String propName) throws Exception { + if (form == null) { + return null; + } + TCProperty prop = form.getFormTCProperty(propName); + if (prop == null) { + throw new java.lang.Exception( + String.format(KLocale.getString("nopropintype.ERROR2"), form.getDisplayType(), propName)); + } + return prop.getStringArrayValue(); + } + + public static File chooseDirectory(Component parent) { + FileSystemView fsv = FileSystemView.getFileSystemView(); + String deskPath = fsv.getHomeDirectory().getPath(); + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setCurrentDirectory(new File(deskPath)); + fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + int state = fileChooser.showOpenDialog(parent); + if (state == 1) { + return null; + } + return fileChooser.getSelectedFile(); + } + + public static boolean addReleaseStatus(TCSession session, String uid, String status) throws Exception { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[2]; + obj[0] = uid; + obj[1] = status; + Object res = userservice.call("K_add_release_status", obj); + if (res != null && res.toString().equalsIgnoreCase("true")) { + return true; + } + return false; + } + + /** + * ֻԵֵ + * + * @param session + * @param propName + * @param propValue + * @param comp + * @return + * @throws Exception + */ + public static boolean setPropValue(TCSession session, String propName, String propValue, TCComponent comp) + throws Exception { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[3]; + obj[0] = propName; + obj[1] = propValue; + obj[2] = comp; + Object res = userservice.call("Connor_Set_Prop_Value", obj); + if (res != null && res.toString().equalsIgnoreCase("true")) { + return true; + } + return false; + } + + public static File chooseFile(Component parent) { + FileSystemView fsv = FileSystemView.getFileSystemView(); + String deskPath = fsv.getHomeDirectory().getPath(); + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setCurrentDirectory(new File(deskPath)); + fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + FileNameExtensionFilter filter = new FileNameExtensionFilter("*.xlsx", "xlsx"); + fileChooser.setFileFilter(filter); + int state = fileChooser.showOpenDialog(parent); + if (state == 1) { + return null; + } + return fileChooser.getSelectedFile(); + } + + public static File chooseSaveFile(Component parent, String defaultFile) { + FileSystemView fsv = FileSystemView.getFileSystemView(); + String deskPath = fsv.getHomeDirectory().getPath(); + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setCurrentDirectory(new File(deskPath)); + fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + FileNameExtensionFilter filter = new FileNameExtensionFilter("*.xlsx", "xlsx"); + fileChooser.setFileFilter(filter); + fileChooser.setSelectedFile(new File(defaultFile)); + int state = fileChooser.showSaveDialog(parent); + if (state == 1) { + return null; + } + return fileChooser.getSelectedFile(); + } + + public static File chooseSaveFile(Component parent, String defaultFile, String ext) { + FileSystemView fsv = FileSystemView.getFileSystemView(); + String deskPath = fsv.getHomeDirectory().getPath(); + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setCurrentDirectory(new File(deskPath)); + fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + if (!KUtil.isEmpty(ext)) { + FileNameExtensionFilter filter = new FileNameExtensionFilter("*." + ext, ext); + fileChooser.setFileFilter(filter); + } + fileChooser.setSelectedFile(new File(defaultFile)); + int state = fileChooser.showSaveDialog(parent); + if (state == 1) { + return null; + } + return fileChooser.getSelectedFile(); + } + + public static File getNewFile(File folder, String fileName, String ext) { + File file = new File(folder.getAbsolutePath() + "\\" + fileName + "." + ext); + int index = 1; + while (file.exists()) { + file = new File(folder.getAbsolutePath() + "\\" + fileName + "(" + (index++) + ")." + ext); + } + return file; + } + + public static String getDateStr(Date date, String format) { + String res = ""; + try { + SimpleDateFormat sdf = new SimpleDateFormat(format); + res = sdf.format(date); + } catch (Exception e) { + e.printStackTrace(); + } + return res; + } + + public static TCComponentContextList query(TCSession session, String queryName, Map fields) + throws Exception { + String[] keys = fields.keySet().toArray(new String[] {}); + String[] vals = fields.values().toArray(new String[] {}); + return query(session, queryName, keys, vals); + } + + public static TCComponentContextList query(TCSession session, String queryName, String[] keys, String[] vals) + throws Exception { + System.out.println("Query: " + queryName); + System.out.println("keys = " + Arrays.toString(keys)); + System.out.println("vals = " + Arrays.toString(vals)); + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + throw new Exception(String.format(KLocale.getString("querynotexist.ERROR1"), queryName)); + } + queryType.clearCache(); + query.clearCache(); + query.refresh(); + return query.getExecuteResultsList(keys, vals); + } + + public static TCComponent[] query2(TCSession session, String queryName, String[] keys, String[] vals) + throws Exception { + System.out.println("Query: " + queryName); + System.out.println("keys = " + Arrays.toString(keys)); + System.out.println("vals = " + Arrays.toString(vals)); + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + throw new Exception(String.format(KLocale.getString("querynotexist.ERROR1"), queryName)); + } + queryType.clearCache(); + query.clearCache(); + query.refresh(); + return query.execute(keys, vals); + } + + public static TCComponentContextList combineContext(TCSession session, TCComponentQuery query, + TCComponentContextList... contexts) throws Exception { + Class c = TCComponentContextList.class; + Field f1 = c.getDeclaredField("m_compUids"); + f1.setAccessible(true); + List compUids = new ArrayList<>(); + for (TCComponentContextList cc : contexts) { + String[] u1 = (String[]) f1.get(cc); + System.out.println(Arrays.toString(u1)); + compUids.addAll(Arrays.asList(u1)); + } + Constructor constructor = c.getDeclaredConstructor(TCComponentManager.class, TCComponent.class, + String[].class, String[].class, String.class); + constructor.setAccessible(true); + TCComponentContextList res = (TCComponentContextList) constructor.newInstance(new TCComponentManager(session), + query, compUids.toArray(new String[] {}), null, ""); + return res; + } + + public static int getLen(Object[] arr) { + return arr == null ? 0 : arr.length; + } + + public static String getValueInArray(String[] arr, int index) { + int len = arr == null ? 0 : arr.length; + if (index >= len) { + return ""; + } + return arr[index]; + } + + public static String getValueInArray(String arrStr, int index, String splitter) { + if (KUtil.isEmpty(arrStr)) { + return ""; + } + String[] split = arrStr.split(splitter, -1); + int len = getLen(split); + if (len > index && index >= 0) { + return split[index]; + } + return ""; + } + + public static String getTypeNames(TCSession session, Object[] types) { + int len = types == null ? 0 : types.length; + if (len == 0) { + return ""; + } + String[] names = new String[len]; + for (int i = 0; i < len; i++) { + try { + if ("TC_Project".equals(types[i].toString())) { + names[i] = KLocale.getString("project"); + } else { + names[i] = session.getTypeComponent(types[i].toString()).getDisplayTypeName(); + } + } catch (Exception e) { + e.printStackTrace(); + } + if (names[i] == null) { + names[i] = types[i].toString(); + } + } + return Arrays.toString(names); + } + + public static String getTypeName(TCSession session, String type) { + if (KUtil.isEmpty(type)) { + return ""; + } + try { + if ("TC_Project".equals(type)) { + return KLocale.getString("project"); + } else { + return session.getTypeComponent(type).getDisplayTypeName(); + } + } catch (Exception e) { + e.printStackTrace(); + } + return type; + } + + public static boolean isReleased(TCComponent comp) throws Exception { + TCComponent[] status = comp.getReferenceListProperty("release_status_list"); + if (status == null || status.length == 0) { + return false; + } + return true; + } + + public static TCComponentUser getUserFromStr(String str) throws Exception { + System.out.println("Search User: " + str); + if (KUtil.isEmpty(str)) { + return null; + } + int ind1 = str.lastIndexOf('('); + int ind2 = str.lastIndexOf(')'); + TCComponentUser user = null; + if (ind1 > 0 && ind2 > ind1) { + String userId = str.substring(ind1 + 1, ind2); + if (KUtil.isEmpty(userId)) { + System.out.println("No Id between '(' and ')'"); + user = null; + } else { + user = queryUserById(userId); + } + } else { + user = queryUserById(str); + if (user == null) { + user = queryUserByName(str); + } + } + return user; + } + + public static TCComponentUser queryUserById(String userId) throws Exception { + System.out.println("Search User By Id: " + userId); + if (KUtil.isEmpty(userId)) { + return null; + } + String queryName = "Admin - Employee Information"; + String[] keys = new String[] { KUtil.getText("UserId") }; + String[] vals = new String[] { userId }; + TCComponentContextList res = KUtil.query(KUtil.session, queryName, keys, vals); + if (res.getListCount() == 0) { + return null; + } + if (res.getListCount() > 1) { + throw new Exception(String.format(KLocale.getString("multiuserbyid.ERROR1"), userId)); + } + return (TCComponentUser) res.get(0).getComponent(); + } + + public static TCComponentUser queryUserByName(String userName) throws Exception { + System.out.println("Search User By Name: " + userName); + if (KUtil.isEmpty(userName)) { + return null; + } + String queryName = "Admin - Employee Information"; + String[] keys = new String[] { KUtil.getText("PersonName") }; + String[] vals = new String[] { userName }; + TCComponentContextList res = KUtil.query(KUtil.session, queryName, keys, vals); + if (res.getListCount() == 0) { + return null; + } + if (res.getListCount() > 1) { + throw new Exception(String.format(KLocale.getString("multiuserbyname.ERROR1"), userName)); + } + return (TCComponentUser) res.get(0).getComponent(); + } + + public static TCComponent[] getGroupMember(List privMembers) throws Exception { + if (privMembers == null) { + return null; + } + List res = new ArrayList<>(); + for (TCComponentUser user : privMembers) { + TCComponentGroupMember[] gms = user.getGroupMembers(); + int len = KUtil.getLen(gms); + for (int i = 0; i < len; i++) { + TCComponentGroupMember gm = gms[i]; + if (KUtil.isEmpty(gm.toString())) { + continue; + } + /* + * if(!gm.isActive()) { System.out.println("���Ա�ǻ�?"+gm); continue; } + */ + if (!res.contains(gm)) { + System.out.println("Add Group Member: " + gm); + res.add(gm); + } else { + System.out.println("Added: " + gm); + } + } + } + return res.toArray(new TCComponent[] {}); + } + + public static int compareWBS(String wbsCode, String wbsCode2) { + if (KUtil.isEmpty(wbsCode) && KUtil.isEmpty(wbsCode2)) { + return 0; + } + if (KUtil.isEmpty(wbsCode)) { + return -1; + } + if (KUtil.isEmpty(wbsCode2)) { + return 1; + } + String[] a = wbsCode.split("\\."); + String[] b = wbsCode2.split("\\."); + int lenA = a.length; + int lenB = b.length; + for (int i = 0; i < lenA && i < lenB; i++) { + String aa = a[i]; + String bb = b[i]; + int ai = 0; + int bi = 0; + try { + ai = Integer.parseInt(aa); + bi = Integer.parseInt(bb); + } catch (Exception e) { + e.printStackTrace(); + } + if (ai != bi) { + return ai - bi; + } + } + return lenA - lenB; + } + + public static TCComponentListOfValues getLov(String lovName) { + TCComponentListOfValuesType lovType; + try { + lovType = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValues"); + TCComponentListOfValues[] lov = lovType.find(lovName); + if (lov.length > 0) + return lov[0]; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + public static String[] getDynamicLOV(String s) { + TCComponentListOfValues lov = null; + List lovDisplayValueList = new ArrayList<>(); + lovDisplayValueList.add(""); + List lovValueList = new ArrayList<>(); + lov = TCComponentListOfValuesType.findLOVByName(s); + try { + if ("Fnd0ListOfValuesDynamic".equals(lov.getProperty("lov_type"))) { + LOVService lovService = LOVService.getService(RACUIUtil.getTCSession()); + InitialLovData input = new InitialLovData(); + LovFilterData filter = new LovFilterData(); + filter.sortPropertyName = "object_name"; + filter.order = 1; + filter.numberToReturn = 100; + filter.maxResults = 100; + + input.lov = lov; + input.filterData = filter; + LOVSearchResults result = lovService.getInitialLOVValues(input); + StringBuffer sb = new StringBuffer(); + sb.append(">>"); + for (LOVValueRow row : result.lovValues) { + Map map = row.propDisplayValues; + Map realmap = row.propInternalValues; + + for (String key : map.keySet()) { + sb.append("UID:" + row.uid + ",key:" + key + "value:" + map.get(key)[0]); + sb.append("\n"); + + lovDisplayValueList.add(map.get(key)[0]); + lovValueList.add(realmap.get(key)[0]); + } + } + } + } catch (TCException e) { + e.printStackTrace(); + } + return lovDisplayValueList.toArray(new String[lovDisplayValueList.size()]); + } + + public static String getLovValue(TCComponentListOfValues lov, String str) throws Exception { + return getLovValue(lov, str, true); + } + + public static String getLovValue(TCComponentListOfValues lov, String str, boolean translate) throws Exception { + if (lov == null || KUtil.isEmpty(str)) { + return str; + } + if (translate) { + String prefName = "LOV_TRANS_" + lov.getStringProperty(TCComponentListOfValues.PROP_LOV_NAME); + String[] prefVals = KUtil.getPrefVals(KUtil.session, prefName); + int len = KUtil.getLen(prefVals); + for (int i = 0; i < len; i++) { + String pref = prefVals[i]; + int ind = pref.indexOf('='); + if (ind > 0) { + String realVal = pref.substring(0, ind); + String disVal = pref.substring(ind + 1); + if (str.equals(realVal) || str.equals(disVal)) { + return realVal; + } + } + } + } + ListOfValuesInfo info = lov.getListOfValues(); + if (info == null) { + return str; + } + List v = info.getValues(); + int size = v == null ? 0 : v.size(); + for (int i = 0; i < size; i++) { + LovValue vv = v.get(i); + String realValue = vv.getValue() == null ? "" : vv.getValue().toString(); + if (str.equals(realValue)) { + return str; + } + String disValue = vv.getDisplayValue(); + if (str.equals(disValue)) { + return realValue; + } + } + throw new Exception(String.format(KLocale.getString("valuenotinlov.ERROR2"), lov.toString(), str)); + } + + public static String getLovDisplayableValue(TCComponentListOfValues lov, String str) throws Exception { + if (lov == null || KUtil.isEmpty(str)) { + return str; + } + ListOfValuesInfo info = lov.getListOfValues(); + if (info == null) { + return str; + } + List v = info.getValues(); + int size = v == null ? 0 : v.size(); + for (int i = 0; i < size; i++) { + LovValue vv = v.get(i); + String realValue = vv.getValue() == null ? "" : vv.getValue().toString(); + if (str.equals(realValue)) { + return vv.getDisplayValue(); + } + String disValue = vv.getDisplayValue(); + if (str.equals(disValue)) { + return str; + } + } + throw new Exception(String.format(KLocale.getString("valuenotinlov.ERROR2"), lov.toString(), str)); + } + + public static void openFile(File file) { + try { + if (file != null && file.exists()) { + Runtime.getRuntime().exec("cmd /c start /b call \"" + file.getAbsolutePath() + "\""); + } + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post(e); + } + } + + public static void importDataset(TCComponent parent, String rel, File f, String dsType, String refName) + throws Exception { + if (f == null || !f.exists() || KUtil.isEmpty(dsType) || KUtil.isEmpty(refName)) { + return; + } + TCComponentDatasetType datasetType = (TCComponentDatasetType) session.getTypeComponent(dsType); + TCComponentDataset dataset = datasetType.create(f.getName(), "", dsType); + String paths[] = { f.getAbsolutePath() }; + String refs[] = { refName }; + dataset.setFiles(paths, refs); + if (parent != null && !KUtil.isEmpty(rel)) { + parent.add(rel, dataset); + } + } + + public static void initPropMap(String propConfig, String value, Map itemPropMap, + Map itemMasterPropMap, Map revPropMap, Map revMasterPropMap) + throws Exception { + initPropMap(propConfig, value, itemPropMap, itemMasterPropMap, revPropMap, revMasterPropMap, null); + } + + public static void initPropMap(String propConfig, String value, Map itemPropMap, + Map itemMasterPropMap, Map revPropMap, Map revMasterPropMap, + Map bomlinePropMap) throws Exception { + if (KUtil.isEmpty(propConfig)) { + return; + } + String propFrom = null, propName = null; + String[] split = propConfig.split("\\."); + if (KUtil.getLen(split) == 2) { + propFrom = split[0].trim().toUpperCase(); + propName = split[1].trim(); + } + if (KUtil.isEmpty(propFrom) || KUtil.isEmpty(propName)) { + return; + } + Map target; + if ("ITEM".equals(propFrom)) { + target = itemPropMap; + System.out.println(">> ITEM PROP: " + propName + " = " + value); + } else if ("REV".equals(propFrom)) { + System.out.println(">> REV PROP: " + propName + " = " + value); + target = revPropMap; + } else if ("ITEMMASTER".equals(propFrom)) { + System.out.println(">> ITEMMASTER PROP: " + propName + " = " + value); + target = itemMasterPropMap; + } else if ("REVMASTER".equals(propFrom)) { + System.out.println(">> REVMASTER PROP: " + propName + " = " + value); + target = revMasterPropMap; + } else if ("BOMLINE".equals(propFrom)) { + System.out.println(">> BOMLINE PROP: " + propName + " = " + value); + target = bomlinePropMap; + } else { + throw new Exception(String.format(KLocale.getString("proplocationnotdefined.ERROR1"), propFrom)); + } + if (target == null) { + return; + } + target.put(propName, value); + } + + public static String getMarkedPropValue(String config, Map markedComponents) throws Exception { + return getMarkedPropValue(config, markedComponents, null); + } + + public static String getMarkedPropValue(String config, Map markedComponents, + Map> relatedComponents) throws Exception { + if (markedComponents == null || KUtil.isEmpty(config)) { + return ""; + } + StringBuilder res = new StringBuilder(); + String[] propConfigSplit = config.split("\\+"); + int len = KUtil.getLen(propConfigSplit); + for (int i = 0; i < len; i++) { + String propConfig = propConfigSplit[i]; + String propFrom = null, propName = null; + String defaultValue = ""; + String[] split = propConfig.split("\\."); + if (KUtil.getLen(split) >= 2) { + propFrom = split[0].trim().toUpperCase(); + propName = split[1].trim(); + } + if (KUtil.getLen(split) >= 3) { + defaultValue = split[2].trim(); + } + if (KUtil.isEmpty(propFrom) || KUtil.isEmpty(propName)) { + if (propConfig.contains("\\n")) { + propConfig = propConfig.replace("\\n", "\n"); + } + res.append(propConfig); + continue; + } + if (!markedComponents.containsKey(propFrom)) { + if (propFrom.startsWith("T")) { + return ""; + } + continue; + } + TCComponent comp = markedComponents.get(propFrom); + // λ.-[-ӷ] + int ind = propName.indexOf('-'); + if (ind > 0) { + String tableProp = propName.substring(0, ind).trim(); + String tableRowProp = propName.substring(ind + 1).trim(); + if (!KUtil.isEmpty(tableProp) && !KUtil.isEmpty(tableRowProp)) { + TCProperty prop = comp.getTCProperty(tableProp.trim()); + if (prop == null) { + throw new Exception(String.format(KLocale.getString("propnotdefinedintype.ERROR2"), + comp.getType(), propName)); + } + String rowSplitter = "#ROW#"; + ind = tableRowProp.indexOf('-'); + if (ind > 0) { + rowSplitter = tableRowProp.substring(ind + 1); + tableRowProp = tableRowProp.substring(0, ind); + } + TCComponent[] tableRows = prop.getReferenceValueArray(); + int rowCnt = KUtil.getLen(tableRows); + String[] value = new String[rowCnt]; + for (int j = 0; j < rowCnt; j++) { + value[j] = tableRows[j].getPropertyDisplayableValue(tableRowProp); + } + res.append(String.join(rowSplitter, value)); + } + continue; + } + TCProperty prop = comp.getTCProperty(propName.trim()); + if (prop == null) { + throw new Exception( + String.format(KLocale.getString("propnotdefinedintype.ERROR2"), comp.getType(), propName)); + } + String value = prop.getDisplayableValue(); + if ("NAME".equalsIgnoreCase(defaultValue)) { + value = prop.getPropertyDisplayName(); + } else if (value == null || "".equals(value)) { + value = defaultValue; + } + res.append(value); + } + return res.toString(); + } + + public static TCComponent getLatestComponent(List comps) { + int size = comps == null ? 0 : comps.size(); + if (size == 0) { + return null; + } + if (size == 1) { + return comps.get(0); + } + TCComponent res = comps.get(0); + try { + Date maxDate = res.getDateProperty("creation_date"); + for (int i = 1; i < size; i++) { + TCComponent temp = comps.get(i); + Date tempDate = temp.getDateProperty("creation_date"); + if (tempDate.after(maxDate)) { + maxDate = tempDate; + res = temp; + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return res; + } + + public static TCComponentType[] getComponentTypes(String itemTypeName) throws Exception { + TCComponentItemType itemType = null; + try { + itemType = (TCComponentItemType) session.getTypeComponent(itemTypeName); + } catch (Exception e) { + e.printStackTrace(); + } + if (itemType == null) { + throw new Exception(String.format(KLocale.getString("typenotfound.ERROR1"), itemTypeName)); + } + TCComponentItemRevisionType revType = itemType.getItemRevisionType(); + if (revType == null) { + throw new Exception(String.format(KLocale.getString("typenotfound.ERROR1"), itemTypeName + "Revision")); + } + TCComponentType itemMasterType = null; + try { + itemMasterType = session.getTypeComponent(itemTypeName + "Master"); + } catch (Exception e) { + e.printStackTrace(); + } + if (itemMasterType == null) { + try { + itemMasterType = session.getTypeComponent(itemTypeName + " Master"); + } catch (Exception e) { + e.printStackTrace(); + } + } + if (itemMasterType == null) { + throw new Exception(String.format(KLocale.getString("typenotfound.ERROR1"), itemTypeName + "Master")); + } + TCComponentType revMasterType = null; + try { + revMasterType = session.getTypeComponent(revType.getTypeName() + "Master"); + } catch (Exception e) { + e.printStackTrace(); + } + if (revMasterType == null) { + try { + revMasterType = session.getTypeComponent(revType.getTypeName() + " Master"); + } catch (Exception e) { + e.printStackTrace(); + } + } + if (revMasterType == null) { + throw new Exception( + String.format(KLocale.getString("typenotfound.ERROR1"), revType.getTypeName() + "Master")); + } + return new TCComponentType[] { itemType, revType, itemMasterType, revMasterType }; + } + + public static String getPropertyDisplayName(TCComponentType type, String propName) throws Exception { + if (type == null || KUtil.isEmpty(propName)) { + return propName; + } + TCPropertyDescriptor desc = type.getPropDesc(propName); + if (desc == null) { + throw new Exception(String.format(KLocale.getString("propnotdefinedintype.ERROR2"), + type.getDisplayTypeName(), propName)); + } + return desc.getDisplayName(); + } + + public static String getConfigPropValue(TCComponentItemRevision rev, String propConfigStr) throws Exception { + if (rev == null || KUtil.isEmpty(propConfigStr)) { + return ""; + } + StringBuilder res = new StringBuilder(); + String[] propConfigSplit = propConfigStr.split("\\+"); + int len = KUtil.getLen(propConfigSplit); + for (int i = 0; i < len; i++) { + String propConfig = propConfigSplit[i]; + String propFrom = null, propName = null; + String[] split = propConfig.split("\\."); + if (KUtil.getLen(split) == 2) { + propFrom = split[0].trim().toUpperCase(); + propName = split[1].trim(); + } + if (KUtil.isEmpty(propFrom) || KUtil.isEmpty(propName)) { + res.append(propConfig); + continue; + } + TCComponent target; + if ("ITEM".equals(propFrom)) { + target = rev.getItem(); + } else if ("REV".equals(propFrom)) { + target = rev; + } else if ("ITEMMASTER".equals(propFrom)) { + target = rev.getItem().getRelatedComponent("IMAN_master_form"); + } else if ("REVMASTER".equals(propFrom)) { + target = rev.getRelatedComponent("IMAN_master_form_rev"); + } else { + throw new Exception(String.format(KLocale.getString("proplocationnotdefined.ERROR1"), propFrom)); + } + TCProperty prop = target.getTCProperty(propName.trim()); + if (prop == null) { + throw new Exception( + String.format(KLocale.getString("propnotdefinedintype.ERROR2"), target.getType(), propName)); + } + res.append(prop.getStringValue()); + } + return res.toString(); + } + + public static String getConfigPropDisplayableValue(TCComponentItemRevision rev, String propConfigStr) + throws Exception { + if (rev == null || KUtil.isEmpty(propConfigStr)) { + return ""; + } + StringBuilder res = new StringBuilder(); + String[] propConfigSplit = propConfigStr.split("\\+"); + int len = KUtil.getLen(propConfigSplit); + for (int i = 0; i < len; i++) { + String propConfig = propConfigSplit[i]; + String propFrom = null, propName = null; + String[] split = propConfig.split("\\."); + if (KUtil.getLen(split) == 2) { + propFrom = split[0].trim().toUpperCase(); + propName = split[1].trim(); + } + if (KUtil.isEmpty(propFrom) || KUtil.isEmpty(propName)) { + res.append(propConfig); + continue; + } + TCComponent target; + if ("ITEM".equals(propFrom)) { + target = rev.getItem(); + } else if ("REV".equals(propFrom)) { + target = rev; + } else if ("ITEMMASTER".equals(propFrom)) { + target = rev.getItem().getRelatedComponent("IMAN_master_form"); + } else if ("REVMASTER".equals(propFrom)) { + target = rev.getRelatedComponent("IMAN_master_form_rev"); + } else { + throw new Exception(String.format(KLocale.getString("proplocationnotdefined.ERROR1"), propFrom)); + } + TCProperty prop = target.getTCProperty(propName.trim()); + if (prop == null) { + throw new Exception( + String.format(KLocale.getString("propnotdefinedintype.ERROR2"), target.getType(), propName)); + } + res.append(prop.getDisplayableValue()); + } + return res.toString(); + } + + public static void removeAllParents(DataManagementService dm, TCComponent comp) throws Exception { + comp.refresh(); + System.out.println("Remove from parent: " + comp); + WhereReferencedResponse refResp = dm.whereReferenced(new TCComponent[] { comp }, 1); + KUtil.throwServiceDataError(refResp.serviceData); + int len = KUtil.getLen(refResp.output); + List datas = new ArrayList(); + for (int i = 0; i < len; i++) { + WhereReferencedOutput ref = refResp.output[i]; + int cnt = KUtil.getLen(ref.info); + for (int j = 0; j < cnt; j++) { + WhereReferencedInfo info = ref.info[j]; + Relationship data = new Relationship(); + data.primaryObject = info.referencer; + data.secondaryObject = comp; + data.relationType = info.relation; + System.out.println(">> " + info.relation + " | " + info.referencer); + datas.add(data); + } + } + ServiceData resp = dm.deleteRelations(datas.toArray(new Relationship[] {})); + KUtil.throwServiceDataError(resp); + } + + public static TCComponent newTableRow(DataManagementService dmService, String type, + Map rowStringProps, Map rowDateProps) throws Exception { + CreateIn rowIn = new CreateIn(); + CreateInput rowInput = new CreateInput(); + rowInput.boName = type; + if (rowStringProps != null) { + rowInput.stringProps = rowStringProps; + } + if (rowDateProps != null) { + rowInput.dateProps = rowDateProps; + } + rowIn.data = rowInput; + CreateResponse res = dmService.createObjects(new CreateIn[] { rowIn }); + KUtil.throwServiceDataError(res.serviceData); + if (res.serviceData.sizeOfCreatedObjects() > 0) { + return res.serviceData.getCreatedObject(0); + } + return null; + } + + public static Date addDay(Date day, int cnt) { + if (day == null) { + return null; + } + Calendar c = Calendar.getInstance(); + c.setTime(day); + c.add(Calendar.DATE, cnt); + return c.getTime(); + } + + public static Date calTime(TCCalendar calendar, Date date, int minutes) { + if (calendar == null || date == null) { + return null; + } + int diff = minutes > 0 ? 1 : -1; + if (minutes < 0) { + minutes = -minutes; + } + Calendar c = Calendar.getInstance(); + c.setTime(date); + int counter = 0; + while (counter < minutes) { + counter += calendar.getMinutesOnDay(c); + c.add(Calendar.DATE, diff); + } + return c.getTime(); + } + + public static int getMinutesBetween(TCCalendar calendar, Date start, Date end) { + if (calendar == null || start == null || end == null) { + return 0; + } + Calendar c = Calendar.getInstance(); + c.setTime(start); + int res = 0; + while (c.getTime().before(end)) { + res += calendar.getMinutesOnDay(c); + // System.out.println(calendar.getMinutesOnDay(c)+" > "+c.getTime()); + c.add(Calendar.DATE, 1); + } + return res; + } + + public static TCComponentTCCalendar getScheduleCalendar(TCComponentSchedule schedule) throws Exception { + if (schedule == null) { + return null; + } + return CalendarHelper.getScheduleCalendar(schedule, session); + } + + public static void dealSpecialModelValue(ArrayList specialList, String prefName, String prop, int ind) { + int index = 0; + + try { + String[] prefVals = KUtil.getPrefVals(session, prefName); + String puid = prefVals[ind]; + TCComponent component = session.stringToComponent(puid); + if (component instanceof TCComponentForm) { + + TCComponentForm form = (TCComponentForm) component; + + TCComponent[] tables = form.getReferenceListProperty("ld6_ChangeTable"); + for (int j = 0; j < tables.length; j++) { + + String change = tables[j].getStringProperty(prop); + if (change.equals("")) { + specialList.add(j); + } + } + + } + +// +// Set>> entrySet = map.entrySet(); +// for (Entry> entry : entrySet) { +// ArrayList list = entry.getValue(); +// String value = list.get(2); +// System.out.println("ǰֵΪ" + value); +// if(value != null && value.equals("")) { +// specialList.add(index); +// } +// index++; +// } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + /** + * õģֵ + * + * @param map + * @throws Exception + */ +// public static void getModelVale(LinkedHashMap> map,String prefName,int index) throws Exception { +// AbstractAIFApplication application = AIFUtility.getCurrentApplication(); +// TCSession session = (TCSession) application.getSession(); +// String[] prefVals = KUtil.getPrefVals(session, prefName); +// String puid = prefVals[index]; +// TCComponentDataset component = (TCComponentDataset) session.stringToComponent(puid); +// TCComponentTcFile[] tcFiles = component.getTcFiles(); +// File datasetFile = null; +// String name = ""; +// if (tcFiles != null && tcFiles.length != 0) { +// TCComponentTcFile tcComponentTcFile = tcFiles[0]; +// File fmsFile = tcComponentTcFile.getFmsFile(); +// name = tcComponentTcFile.getStringProperty("original_file_name"); +// datasetFile = new File(System.getenv("TEMP")+"\\"+name); +// FileUtility.copyFile(fmsFile, datasetFile); +// +// } +// XSSFWorkbook wb = new XSSFWorkbook(new FileInputStream(datasetFile)); +// XSSFSheet sheet = wb.getSheetAt(0); +// for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) { +// XSSFRow row = sheet.getRow(i); +// for (int j = 0; j < 5; j++) { +// XSSFCell cell = row.getCell(j); +// if(cell != null) { +// String cellValue = KUtil.getCellValue(cell); +// if(j == 0 && cellValue.isEmpty()) { +// break; +// } +// if(j == 0 ) { +// if(map.containsKey(cellValue)) { +// break; +// }else { +// map.put(cellValue, null); +// } +// }else { +// String key = KUtil.getCellValue(row.getCell(0)); +// ArrayList arrayList = map.get(key); +// if(arrayList != null) { +// arrayList.add(cellValue); +// }else { +// ArrayList list = new ArrayList(); +// list.add(cellValue); +// map.put(key, list); +// } +// } +// +// } +// } +// } +// wb.close(); +// datasetFile.delete(); +// } + /** + * õģֵ + * + * @param map + * @throws Exception + */ + public static void getModelVale(LinkedHashMap> map, TCComponent forms, + ArrayList specialList, String[] propNames) throws Exception { +// AbstractAIFApplication application = AIFUtility.getCurrentApplication(); +// TCSession session = (TCSession) application.getSession(); +// String[] prefVals = KUtil.getPrefVals(session, prefName); +// String puid = prefVals[index]; +// TCComponent component = session.stringToComponent(puid); + int t = 1; + if (forms instanceof TCComponentForm) { + + TCComponentForm form = (TCComponentForm) forms; + TCComponent[] tables = form.getReferenceListProperty("ld6_ChangeTable"); + for (int j = 0; j < tables.length; j++) { + ArrayList tableValue = new ArrayList(); + + for (String propName : propNames) { + System.out.println("ǰΪ" + propName); + String prop = tables[j].getTCProperty(propName).getDisplayableValue(); + if (propName.equals("ld6_YNChange") && prop.equals("")) { +// specialList.add(j); + } + tableValue.add(prop == null ? "" : prop.trim()); + } + + map.put(String.valueOf(t), tableValue); +// tableValue + + t = t + 1; + } + + } + + } + + /** + * õlovʵֵʾֵ + * + * @param lovMap + * @param comboBox + * @throws TCException + */ + public static void getLov(HashMap lovMap, String lovName, JComboBox comboBox) + throws TCException { + if (comboBox != null) { + comboBox.addItem(""); + } +// for (LovValue lovV : lovValueList) { +// map.put(lovV.getDisplayValue(), lovV.getStringValue()); +// comboBox.addItem(lovV.getDisplayValue()); +// System.out.println(lovV.getDisplayValue() + "===" + lovV.getStringValue()); +// } + + TCComponentListOfValues lov = TCComponentListOfValuesType.findLOVByName(lovName); + if ("Fnd0ListOfValuesDynamic".equals(lov.getProperty("lov_type"))) { + System.out.println("̬lovName=" + lovName); + LOVService lovService = LOVService.getService(RACUIUtil.getTCSession()); + InitialLovData input = new InitialLovData(); + LovFilterData filter = new LovFilterData(); + if ("LD6_TecDoc_TypeLOV".equals(lovName)) { + filter.sortPropertyName = "fnd0StringValues"; // lovĺֵ̨ + } else { + filter.sortPropertyName = "object_name"; // lovĺֵ̨ + } + + filter.order = 1; + filter.numberToReturn = 2000; + filter.maxResults = 2000; + + input.lov = lov; + input.filterData = filter; + LOVSearchResults result = lovService.getInitialLOVValues(input); + // System.out.println("111==="+result.toString()); + + for (LOVValueRow row : result.lovValues) { + Map map = row.propDisplayValues; + Map realmap = row.propInternalValues; +// for (String key : map.keySet()) { +// System.out.println("key=" + key + ",value=" + map.get(key)[0]); +// } +// for (String key : realmap.keySet()) { +// System.out.println("key2=" + key + ",value2=" + map.get(key)[0]); +// } + String disval = ""; + String val = ""; + String key1 = "object_name";// ʵֵ ʾֵһ + if ("LD6_TecDoc_TypeLOV".equals(lovName)) { + key1 = "fnd0StringValues"; // lovĺֵ̨ + } + // String key2 = "object_desc";// ʾֵڶ + if (map.containsKey(key1)) { + val = realmap.get(key1)[0]; + disval = map.get(key1)[0]; + } + if (!val.equals("")) { + lovMap.put(disval, val); + if (comboBox != null) { + comboBox.addItem(disval); + } + } + + } + + } else { + ListOfValuesInfo info = lov.getListOfValues(); + info.getLOVDisplayValues(); + List lovValueList = info.getValues(); + for (LovValue lovV : lovValueList) { + lovMap.put(lovV.getDisplayValue(), lovV.getStringValue()); + if (comboBox != null) { + comboBox.addItem(lovV.getDisplayValue()); + } + } + } + + } + + + +} diff --git a/src/com/langtech/plm/modifyEffectiveTime/DatePickerEditor.java b/src/com/langtech/plm/modifyEffectiveTime/DatePickerEditor.java new file mode 100644 index 0000000..0029cd4 --- /dev/null +++ b/src/com/langtech/plm/modifyEffectiveTime/DatePickerEditor.java @@ -0,0 +1,94 @@ +package com.langtech.plm.modifyEffectiveTime; + +import org.jdesktop.swingx.JXDatePicker; + +import javax.swing.*; +import javax.swing.table.TableCellEditor; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.EventObject; + +public class DatePickerEditor extends AbstractCellEditor implements TableCellEditor { + + private JXDatePicker datePicker; + private JTable table; + private int row; + private int column; + + public DatePickerEditor() { + datePicker = new JXDatePicker(); + // ڸʽ + datePicker.setFormats(new SimpleDateFormat("yyyy-MM-dd")); + datePicker.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + fireEditingStopped(); + } + }); + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + this.table = table; + this.row = row; + this.column = column; + + System.out.println("getTableCellEditorComponent: "+value); + if (value instanceof Date) { + datePicker.setDate((Date) value); + } else { + datePicker.setDate(null); + } + return datePicker; + } + + @Override + public Object getCellEditorValue() { + try { + // ȡûı + String text = datePicker.getEditor().getText(); + + if (text.trim().isEmpty()) { + return null; + } + + // ԽΪ + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + format.setLenient(false); // ϸڸʽ + return format.parse(text); + } catch (Exception e) { + // ʧܣӡϢصǰѡֵ + System.err.println("Invalid date format: " + e.getMessage()); + } + + // ѡǰֵ + return datePicker.getDate(); + } + + + + @Override + public boolean isCellEditable(EventObject anEvent) { + return true; + } + + @Override + public boolean stopCellEditing() { + System.out.println("stopCellEditing: " + datePicker.getDate()); + fireEditingStopped(); + return true; + } + + @Override + public boolean shouldSelectCell(EventObject anEvent) { + return true; + } + + @Override + public void cancelCellEditing() { + super.cancelCellEditing(); + } +} diff --git a/src/com/langtech/plm/modifyEffectiveTime/ModifyEffectiveTimeDialog.java b/src/com/langtech/plm/modifyEffectiveTime/ModifyEffectiveTimeDialog.java new file mode 100644 index 0000000..4b68bf4 --- /dev/null +++ b/src/com/langtech/plm/modifyEffectiveTime/ModifyEffectiveTimeDialog.java @@ -0,0 +1,265 @@ +package com.langtech.plm.modifyEffectiveTime; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.List; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.SwingConstants; +import javax.swing.border.EmptyBorder; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumnModel; + +import org.jdesktop.swingx.JXDatePicker; + +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.util.MessageBox; + +public class ModifyEffectiveTimeDialog extends JFrame implements Runnable { + private JTable table; + + private JButton okButton; + private boolean flag; + + private final String title; + private final String[] columnNames; + private Object[][] data; + private int[] dateIndex; + private boolean pass; + + public static void main(String[] args) { + + } + + public ModifyEffectiveTimeDialog(String title, Object... args) { + this.title = title; + this.columnNames = (String[]) args[0]; + this.data = (Object[][]) args[1]; + this.dateIndex = (int[]) args[2]; + this.pass = (boolean) args[3]; + } + + @Override + public void run() { + // TODO Auto-generated method stub + initUI(); + } + + public void setWithHeight(int with, int height) { + this.setSize(with, height); + } + + public void initUI() { + this.setTitle(title); + // ʼϢ + initializationComponent(); + + // ݵJFrame λ + JPanel bottomPanel = getBottomPanel(); + // ͹ + JPanel tableScrollPane = createTable(); + tableScrollPane.setPreferredSize(new Dimension(700, 200)); // ùĴС + + this.getContentPane().add(tableScrollPane, BorderLayout.CENTER); + this.getContentPane().add(bottomPanel, BorderLayout.SOUTH); + // ôھ + this.setLocationRelativeTo(null); + this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + // ÿɼ + this.setVisible(true); + } + + public void initializationComponent() { + okButton = new JButton("Ӧ"); + okButton.setEnabled(pass); + } + + public JPanel createTable() { + JPanel panel = new JPanel(new BorderLayout(10, 10)); + panel.setBorder(new EmptyBorder(20, 20, 10, 20)); + + // DefaultTableModel ʵ + DefaultTableModel model = new DefaultTableModel(data, columnNames) { + @Override + public boolean isCellEditable(int row, int column) { + if (column == 0) { + return false; + } + return true; + } + + @Override + public Class getColumnClass(int columnIndex) { + if (columnIndex == 1) { + return Date.class; + } + return super.getColumnClass(columnIndex); + } + }; + table = new JTable(model); + + // и + table.setRowHeight(25); // иΪ30 + table.setFont(new Font("΢ź", Font.PLAIN, 12)); + // + table.getTableHeader().setReorderingAllowed(false); + // Զп +// table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + // ñӿڸ߶ +// table.setFillsViewportHeight(true); + + // п + TableColumnModel columnModel = table.getColumnModel(); + columnModel.getColumn(0).setPreferredWidth(300); + columnModel.getColumn(1).setPreferredWidth(143); + + table.removeColumn(columnModel.getColumn(columnModel.getColumnCount() - 1)); + + // ԶȾʹож + DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer() { + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, + boolean hasFocus, int row, int column) { + Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + ((JLabel) c).setHorizontalAlignment(SwingConstants.CENTER); // ıж + return c; + } + }; + + // ӦþжȾ + for (int i = 0; i < columnModel.getColumnCount(); i++) { + columnModel.getColumn(i).setCellRenderer(centerRenderer); + } + + // ԶȾ + TableCellRenderer dateRenderer = (JTable table, Object value, boolean isSelected, boolean hasFocus, int row, + int column) -> { + JXDatePicker datePicker = new JXDatePicker(); + if (value instanceof Date) { + datePicker.setFormats(new SimpleDateFormat("yyyy-MM-dd")); + datePicker.setDate((Date) value); + } + return datePicker; + }; + // Զ༭ + TableCellEditor dateEditor = new DatePickerEditor(); + + // Ϊ IssueDate MaterialDeliveryTime ѡ + for (int index : dateIndex) { + // Ⱦͱ༭ + table.getColumnModel().getColumn(index).setCellRenderer(dateRenderer); + table.getColumnModel().getColumn(index).setCellEditor(dateEditor); + } + + // JScrollPane ˮƽʼտɼ + JScrollPane scrollPane = new JScrollPane(table); +// scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + + // ӱ + panel.add(scrollPane, BorderLayout.CENTER); + return panel; + } + + public JPanel getBottomPanel() { + // TODO Auto-generated method stub + JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 70, 10)); + bottomPanel.setBorder(BorderFactory.createEmptyBorder(-10, 0, 10, 0)); + bottomPanel.add(this.okButton); + // Ӽ + okButton.addActionListener(e -> { + flag = true; + List tableData = getTableData(); + if (tableData != null) { + tableData.forEach(rowData -> { + System.out.println(Arrays.toString(rowData)); + }); + } + + if (flag) { + MessageBox.post("޸ijɹ! ", "Info", MessageBox.INFORMATION); + this.dispose(); // رմ + } else { + MessageBox.post("Чʱ䲻", "Error", MessageBox.ERROR); + } + }); + return bottomPanel; + } + + public List getTableData() { + DefaultTableModel model = (DefaultTableModel) table.getModel(); + int rowCount = model.getRowCount(); + int columnCount = model.getColumnCount(); + + List tableData = new ArrayList<>(); + + int count = 0; + for (int row = 0; row < rowCount; row++) { + Object obj = model.getValueAt(row, 1); + if (obj instanceof Date && obj != null) { + count++; + if (count == 3) { + flag = false; + return null; + } + } + } + + setByPass(true); + try { + for (int row = 0; row < rowCount; row++) { + String name = (String) model.getValueAt(row, 0); + Object obj = model.getValueAt(row, 1); + System.out.println("name: " + name + " || date: " + obj); + TCComponentItemRevision rev = (TCComponentItemRevision) model.getValueAt(row, 2); + rev.setDateProperty("ly6_deadline", (Date) obj); + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + MessageBox.post(e.getMessage(), "Error", MessageBox.ERROR); + } + setByPass(false); + return tableData; + } + + @SuppressWarnings("deprecation") + public void setByPass(boolean pass) { + TCUserService userservice = null; + if (userservice == null) { + userservice = ((TCSession) AIFUtility.getCurrentApplication().getSession()).getUserService(); + } + Object[] obj = new Object[1]; + obj[0] = "origin"; + try { + if (pass) { + userservice.call("CONNOR_open_bypass", obj); + System.out.println("·ѿ"); + } else { + userservice.call("CONNOR_close_bypass", obj); + System.out.println("·ѹر"); + } + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/com/langtech/plm/modifyEffectiveTime/ModifyEffectiveTimeHandler.java b/src/com/langtech/plm/modifyEffectiveTime/ModifyEffectiveTimeHandler.java new file mode 100644 index 0000000..7b68ad5 --- /dev/null +++ b/src/com/langtech/plm/modifyEffectiveTime/ModifyEffectiveTimeHandler.java @@ -0,0 +1,165 @@ +package com.langtech.plm.modifyEffectiveTime; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.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.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class ModifyEffectiveTimeHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + + TCPreferenceService preferenceService = session.getPreferenceService(); + String[] preValues = preferenceService.getStringValues("LY__FormulaDeadLine_Config"); + if ((preValues != null && preValues.length < 3) || preValues == null) { + MessageBox.post("LY__FormulaDeadLine_Configô", "Error", MessageBox.ERROR); + return null; + } + + String[] types = preValues[0].split(";"); + String[] childTypes = preValues[1].split(";"); + String[] permissionPeo = preValues[2].split(";"); + + TCComponent targetComponent = (TCComponent)app.getTargetComponent(); + + String targetType = ""; + try { + if(targetComponent instanceof TCComponentItemRevision) { + targetType = targetComponent.getType(); + }else if(targetComponent instanceof TCComponentBOMLine) { + targetType = ((TCComponentBOMLine) targetComponent).getItemRevision().getType(); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + boolean isExist = false; + System.out.println("ǰͣ" + targetType); + for (String type : types) { + System.out.println("ǰͣ" + type); + if (type.equals(targetType)) { + isExist = true; + break; + } + } + if (!isExist) { + MessageBox.post("ѡָ͵ƺŰ汾ִ޸䷽Чڹ", "Error", MessageBox.ERROR); + return null; + } + + boolean pass = false; + String userName = session.getUserName(); + System.out.println("ǰû" + userName); + for (String name : permissionPeo) { + System.out.println("ǰû" + name); + if (userName.equals(name)) { + pass = true; + break; + } + } + + Object[][] data = null; + try { + List revList = getChildBom(session, targetComponent, childTypes); + data = new Object[revList.size()][]; + + for (int i = 0; i < revList.size(); i++) { + TCComponentItemRevision tempRev = revList.get(i); + Object[] tempData = new Object[3]; + tempData[0] = tempRev.getProperty("object_string"); + tempData[1] = parseDate(tempRev.getProperty("ly6_deadline")); + tempData[2] = tempRev; + + data[i] = tempData; + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + // б + String[] columnNames = new String[] { "", "Чʱ", "TCComponent" }; + int[] dateIndex = new int[] { 1 }; + ModifyEffectiveTimeDialog dialog = new ModifyEffectiveTimeDialog("޸䷽Чʱ", columnNames, data, dateIndex, + pass); + dialog.setWithHeight(500, 300); + + new Thread(dialog).start(); + + return null; + } + + public List getChildBom(TCSession session, TCComponent targetComponent, + String[] childTypes) throws TCException { + // TODO Auto-generated method stub + TCComponentBOMLine topLine = null; + if (targetComponent instanceof TCComponentItemRevision) { + TCComponentItemRevision rev = (TCComponentItemRevision) targetComponent; + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + TCComponentBOMWindow view = winType.create(null); + topLine = view.setWindowTopLine(rev.getItem(), rev, null, null); + } else if (targetComponent instanceof TCComponentBOMLine) { + topLine = ((TCComponentBOMLine) targetComponent); + } + + boolean hasChildren = topLine.hasChildren(); + List revList = new ArrayList(); + if (!hasChildren) { + return revList; + } + + String revType = ""; + AIFComponentContext[] childrena = topLine.getChildren(); + for (AIFComponentContext children : childrena) { + TCComponentBOMLine component = (TCComponentBOMLine) children.getComponent(); + TCComponentItemRevision itemRevision = component.getItemRevision(); +// revType = itemRevision.getProperty("object_type"); + revType = itemRevision.getType(); + System.out.println("getType()ȡֵ" + revType); + for (String type : childTypes) { + System.out.println("öͣ" + type); + if (revType.equals(type)) { + revList.add(itemRevision); + break; + } + } + } + return revList; + } + + public Date parseDate(String dateString) { + if (dateString == null || dateString.isEmpty()) { + return null; + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + try { + return sdf.parse(dateString); + } catch (ParseException e) { + e.printStackTrace(); + return null; + } + } + +} diff --git a/src/com/langtech/plm/mpart/CheckHeaderCellRenderer.java b/src/com/langtech/plm/mpart/CheckHeaderCellRenderer.java new file mode 100644 index 0000000..5a77f50 --- /dev/null +++ b/src/com/langtech/plm/mpart/CheckHeaderCellRenderer.java @@ -0,0 +1,79 @@ +package com.langtech.plm.mpart; + +import java.awt.Component; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +import javax.swing.JCheckBox; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JTable; +import javax.swing.SwingConstants; +import javax.swing.UIManager; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableCellRenderer; + +public class CheckHeaderCellRenderer implements TableCellRenderer { + DefaultTableModel tableModel; + JTableHeader tableHeader; + final JCheckBox selectBox; + + public CheckHeaderCellRenderer(final JTable table) { + this.tableModel = (DefaultTableModel) table.getModel(); + this.tableHeader = table.getTableHeader(); + selectBox = new JCheckBox(tableModel.getColumnName(0)); + selectBox.setSelected(false); + tableHeader.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() > 0) { + // ѡ + int selectColumn = tableHeader.columnAtPoint(e.getPoint()); + if (selectColumn == 0) { + System.out.println("selectColumn == 0selectColumn == 0selectColumn == 0"); + boolean value = !selectBox.isSelected(); + selectBox.setSelected(value); +// tableModel.selectAllOrNull(value); + tableHeader.repaint(); + if(value) { + for(int i=0;i objectComboBox; + private JButton okButton = new JButton("ȷ"); + private JButton concelButton = new JButton("ȡ"); + private HashMap fieldMap = new HashMap(); + private String revType = ""; + HashMap objectMap = new HashMap(); + + public ChoosePartDialog(JComboBox objectComboBox,AIFDesktop aifDesktop) { + // TODO Auto-generated constructor stub + this.objectComboBox = objectComboBox; + initUI(); + } + + private void initUI() { + // TODO Auto-generated method stub + try { + this.setTitle("ѡBOM"); + this.setLayout(new BorderLayout()); + + JPanel topPanel = getTopPanel(); + + JPanel btnPanel = getBtnPanel(); + + this.add(topPanel, BorderLayout.NORTH); + // this.add(pane,BorderLayout.CENTER); + this.add(btnPanel, BorderLayout.SOUTH); + this.setPreferredSize(new Dimension(550, 200)); + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); // ȡĻߴ + int screenWidth = screenSize.width; // ȡĻ + int screenHeight = screenSize.height; // ȡĻ߶ + int x = (screenWidth - 550) / 2; // FrameϽx + int y = (screenHeight - 300) / 2; // FrameϽy + this.setLocation(x, y); // Frameλ + + // this.setLocationRelativeTo(null); + this.createActionEvent(); + this.pack(); + + // this.validate(); + this.setVisible(true); + +// this.setAlwaysOnTop(true); + + + + } catch (Exception e) { + e.printStackTrace(); + return; + } + } + + // Ӽ + public void createActionEvent() { + + this.okButton.addActionListener(this); + this.concelButton.addActionListener(this); + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + + Object source = e.getSource(); + System.out.println("source==>+" + source); + if (this.okButton.equals(source)) { + this.dispose(); + + } else if (this.concelButton.equals(source)) { + this.dispose(); + } + + } + + private JPanel getBtnPanel() { + JPanel topPanel = new JPanel(); + topPanel.setLayout(new PropertyLayout()); + topPanel.add("1.1.center", new JLabel("")); + topPanel.add("2.1.center", new JLabel(" ")); + topPanel.add("2.2.center", okButton); + topPanel.add("2.3.center", new JLabel("")); + topPanel.add("2.4.center", concelButton); + + return topPanel; + } + + // ѯ + private JPanel getTopPanel() { + // TODO Auto-generated method stub + JPanel topPanel = new JPanel(); + topPanel.setLayout(new PropertyLayout()); + topPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); + + topPanel.add("1.1.left.center", new JLabel("")); + topPanel.add("2.1.left.center", new JLabel("")); + topPanel.add("3.1.left.center", new JLabel("")); + topPanel.add("4.1.left.center", new JLabel("")); + topPanel.add("5.1.left.center", new JLabel("")); + topPanel.add("6.1.left.center", new JLabel("")); + topPanel.add("7.1.left.center", new JLabel("ѡԴ")); + topPanel.add("7.2.left.center", objectComboBox); + + return topPanel; + } + +} diff --git a/src/com/langtech/plm/mpart/DialogFrame.java b/src/com/langtech/plm/mpart/DialogFrame.java new file mode 100644 index 0000000..a64a55e --- /dev/null +++ b/src/com/langtech/plm/mpart/DialogFrame.java @@ -0,0 +1,50 @@ +package com.langtech.plm.mpart; +import javax.swing.*; + +import com.sun.scenario.effect.impl.hw.d3d.D3DShaderSource; +import com.teamcenter.rac.util.MessageBox; + +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.LinkedHashMap; + +public class DialogFrame extends JDialog { + + private JComboBox comboBox; + private Object syncObject; + public DialogFrame(JFrame owner,JComboBox comboBox,ArrayList list) { + super(owner, "ѡM", true); // ģ̬Ի + this.comboBox = comboBox; + this.syncObject = syncObject; + JButton button = new JButton("ȷ"); + button.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + String selectedItem =(String) comboBox.getSelectedItem(); + if(selectedItem == null || selectedItem.isEmpty()) { + MessageBox.post("ѡݣ", "ʾ ", MessageBox.INFORMATION); + }else { + + System.out.println("Selected Item: " + selectedItem); + list.add(selectedItem); + dispose(); // رնԻ + + } + + } + }); + this.setPreferredSize(new Dimension(300,100)); + JPanel panel = new JPanel(); + panel.setLayout(new FlowLayout()); + panel.add(new JLabel("ѡ")); + panel.add(comboBox); + panel.add(button); + + this.add(panel); + this.pack(); + this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); + this.setLocationRelativeTo(owner); // ʾ + } +} \ No newline at end of file diff --git a/src/com/langtech/plm/mpart/MainFrame.java b/src/com/langtech/plm/mpart/MainFrame.java new file mode 100644 index 0000000..835c141 --- /dev/null +++ b/src/com/langtech/plm/mpart/MainFrame.java @@ -0,0 +1,95 @@ +package com.langtech.plm.mpart; +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; + +public class MainFrame extends JFrame { + + private JTextField textField; + private Object syncObject = new Object(); + public MainFrame() { + super("Main Window"); + + textField = new JTextField(20); + JButton button = new JButton("Open Dialog"); + ArrayList childrenList = new ArrayList(); + button.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // ʾģ̬Ի + JComboBox a = new JComboBox(); + a.addItem("1"); + System.out.println("0"); + System.out.println(syncObject); + + + + for (int i = 0; i < 5; i++) { + DialogFrame dialog = new DialogFrame(MainFrame.this,a,childrenList); + dialog.setVisible(true); + // ȴԻرպִеIJ + dialog.addWindowListener(new java.awt.event.WindowAdapter() { + @Override + public void windowClosed(java.awt.event.WindowEvent e) { + + System.out.println("21121212"); + } + }); + } + + + System.out.println("2"); + + System.out.println(childrenList.size()); + + + +// DialogFrame dialog = new DialogFrame(MainFrame.this,a,syncObject); +// dialog.setVisible(true); +// // ȴԻرպִеIJ +// dialog.addWindowListener(new java.awt.event.WindowAdapter() { +// @Override +// public void windowClosed(java.awt.event.WindowEvent e) { +// +// System.out.println("1"); +// } +// }); +// System.out.println("2"); +// synchronized (syncObject) { +// +// try { +// // Wait until notified +// System.out.println("4"); +// syncObject.wait(); +// +// } catch (InterruptedException ex) { +// Thread.currentThread().interrupt(); // Restore interrupted status +// System.err.println("Thread was interrupted."); +// } +// System.out.println("2"); +// +// } + System.out.println("3"); + } + }); + + JPanel panel = new JPanel(); + panel.setLayout(new FlowLayout()); + panel.add(textField); + panel.add(button); + + this.add(panel); + this.pack(); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + this.setLocationRelativeTo(null); // ʾ + } + + public static void main(String[] args) { + EventQueue.invokeLater(() -> { + MainFrame frame = new MainFrame(); + frame.setVisible(true); + }); + } +} \ No newline at end of file diff --git a/src/com/langtech/plm/mpart/MpartDialog.java b/src/com/langtech/plm/mpart/MpartDialog.java new file mode 100644 index 0000000..7cb422d --- /dev/null +++ b/src/com/langtech/plm/mpart/MpartDialog.java @@ -0,0 +1,1320 @@ +package com.langtech.plm.mpart; + +/** + * =============================================================================== + * Copyright (c) 2012-2024 CONNOR lijh. Unpublished - All Rights Reserved + * =============================================================================== + * File description: Mpart + * + * =============================================================================== + * DATE Name Description of Change + * + * =============================================================================== + */ + + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map.Entry; + +import javax.swing.BorderFactory; +import javax.swing.DefaultCellEditor; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.SwingUtilities; +import javax.swing.border.EmptyBorder; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; + +import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; + +import com.langtech.plm.createProjectStruct.KUtil; +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentProcessType; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +import com.teamcenter.rac.kernel.TCComponentTaskTemplate; +import com.teamcenter.rac.kernel.TCComponentTaskTemplateType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +import k.util.KOrgDialog; + +public class MpartDialog extends JFrame implements ActionListener { + + private TCSession session; + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + private ArrayList list; + private JTextField find = new JTextField(); + private JTextField replace = new JTextField(); + private JButton xrButton = new JButton("ѡ"); + private JButton createButton = new JButton("Mpartֹ"); + private JButton viewlButton = new JButton("鿴M"); + private JTable t_part; + private JComboBox gsdwComboBox = new JComboBox(); + protected DefaultTableModel tm_part; + public static final String[] HEADER = new String[] { "", "", "ID", "", "", "Ƿ", "ǷM", "λ","" }; + public static final int[] HEADERWIDTH = new int[] { 30, 40, 60, 120, 100, 60, 60, 60, 100 }; + private JTable t_part2; + protected DefaultTableModel tm_part2; + public static final String[] HEADER2 = new String[] { "", "" }; + public static final int[] HEADERWIDTH2 = new int[] { 10, 100 }; + private ArrayList> valueList = new ArrayList>(); + private HashMap objectMap = new HashMap(); + private ArrayList table2RevList = new ArrayList(); + TCComponentBOMWindowType viewType; + TCComponentBOMWindow view; + TCComponentItemType type; + private String[] groupSplit; + private HashMap fieldsMap = new HashMap(); + private HashMap typesMap = new HashMap(); + private boolean isInitialized = false; + //static TCComponentGroup group; + //static TCComponentUser user; + + public MpartDialog(TCSession session, ArrayList list) throws TCException { + // TODO Auto-generated constructor stub + this.session = session; + this.list = list; + viewType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + view = viewType.create(null); + initUI(); + } + + private void initUI() { + // TODO Auto-generated method stub + try { + + String[] fields = session.getPreferenceService().getStringValues("LY6_EPartToMPartType"); + for (int i = 0; i < fields.length; i++) { + String[] split = fields[i].split("="); + fieldsMap.put(split[0], split[1]); + + String[] split2 = split[0].split(":"); + typesMap.put(split2[0], split2[1]); + } + gsdwComboBox.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + if (!isInitialized) { + // ûгʼɣֱӷأִк + return; + } + if (e.getStateChange() == ItemEvent.SELECTED) { + String selectedItem = (String) gsdwComboBox.getSelectedItem(); + System.out.println("Selected Item: " + selectedItem); + // ִ + int count = 0; + System.out.println("==========tm_part.getRowCount()=========="+tm_part.getRowCount()); + for (int i = 0; i < tm_part.getRowCount(); i++) { + System.out.println("tm_part.getValueAt(i, 0).toString()========"+tm_part.getValueAt(i, 0).toString()); + if (tm_part.getValueAt(i, 0).toString().equals("1")) { + tm_part.setValueAt(selectedItem, i, 7); + count++; + } + } + if (count == 0) { + MessageBox.post("빴ѡݣ", "ʾ ", MessageBox.INFORMATION); + return; + } + } + } + }); + find.setPreferredSize(new Dimension(200, 30)); + replace.setPreferredSize(new Dimension(200, 30)); + this.setTitle("Mpart"); + this.setLayout(new BorderLayout()); + + JPanel topPanel = getTopPanel(); + + JPanel btnPanel = getBtnPanel(); + + this.add(topPanel, BorderLayout.NORTH); + // this.add(pane,BorderLayout.CENTER); + this.add(btnPanel, BorderLayout.SOUTH); + this.setPreferredSize(new Dimension(1400, 730)); + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); // ȡĻߴ + int screenWidth = screenSize.width; // ȡĻ + int screenHeight = screenSize.height; // ȡĻ߶ + int x = (screenWidth - 1400) / 2; // FrameϽx + int y = (screenHeight - 800) / 2; // FrameϽy + this.setLocation(x, y); // Frameλ + + // this.setLocationRelativeTo(null); + this.createActionEvent(); + this.pack(); + + // this.validate(); + this.setVisible(true); + String groupID = getGroupID(); + System.out.println("groupID==========" + groupID); + String factory = ""; + // gsdwComboBox.addItem("ѡ..."); + String[] userCompany = session.getPreferenceService().getStringValues("LY6_UserCompany"); + for (int i = 0; i < userCompany.length; i++) { + String[] split = userCompany[i].split("="); + if (split[0].equals(groupID)) { + factory = split[1]; + } + + } + gsdwComboBox.addItem(""); + if (factory != null && !factory.isEmpty()) { + groupSplit = factory.split(";"); + for (int j = 0; j < groupSplit.length; j++) { + gsdwComboBox.addItem(groupSplit[j]); + } + + } + +// this.setAlwaysOnTop(true); + + // ֵ + // ȡǰ + + for (int i = 0; i < list.size(); i++) { + ArrayList tempList = new ArrayList(); + tempList.add(0); + tempList.add(i + 1); + TCComponentItemRevision tcComponentItemRevision = list.get(i); + String revId = tcComponentItemRevision.getStringProperty("item_id"); + String object_name = tcComponentItemRevision.getStringProperty("object_name"); + String ly6_partNum = tcComponentItemRevision.getStringProperty("ly6_partNum"); + String ly6_homemadeStatus = tcComponentItemRevision.getStringProperty("ly6_homemadeStatus"); + tempList.add(revId); + tempList.add(object_name); + tempList.add(ly6_partNum); + tempList.add(ly6_homemadeStatus); + if (factory != null && !factory.isEmpty()) { + ArrayList mrevList = new ArrayList(); + + String[] split = factory.split(";"); + + for (int j = 0; j < split.length; j++) { + + TCComponent[] search = session.search("_SearchMFKProperties", new String[] { "ID", "" }, + new String[] { revId, split[j] }); + if (search.length > 0) { + + for (int k = 0; k < search.length; k++) { + TCComponentItem item = (TCComponentItem) search[k]; + mrevList.add(item.getLatestItemRevision()); + } + } + } + if (mrevList.size() <= 0) { + tempList.add(""); + tempList.add(""); + tempList.add(null); + tempList.add(tcComponentItemRevision); + } else { + tempList.add(""); + tempList.add(""); + tempList.add(mrevList); + tempList.add(tcComponentItemRevision); + } + } else { + tempList.add(""); + tempList.add(""); + tempList.add(null); + tempList.add(tcComponentItemRevision); + } + System.out.println("tempList.size============" + tempList.size()); + valueList.add(tempList); + } + + System.out.println("valueList================" + valueList.size()); + for (int j = 0; j < valueList.size(); j++) { + ArrayList arrayList = valueList.get(j); + + tm_part.addRow(new Object[] { arrayList.get(0), arrayList.get(1), arrayList.get(2), arrayList.get(3), + arrayList.get(4), arrayList.get(5), arrayList.get(6), arrayList.get(7), "", "" }); + } + isInitialized = true; + } catch (Exception e) { + e.printStackTrace(); + return; + } + } + + // Ӽ + public void createActionEvent() { + + this.createButton.addActionListener(this); + this.viewlButton.addActionListener(this); + this.xrButton.addActionListener(this); + this.gsdwComboBox.addActionListener(this); + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + + Object source = e.getSource(); + System.out.println("source==>+" + source); + if (this.createButton.equals(source)) { + + // ѡȡģ + String[] workflows = session.getPreferenceService().getStringValues("LY6_EPartToMPartWorkflow"); + String workflowTemplate = ""; + if (workflows != null && workflows.length > 0) { + workflowTemplate = workflows[0]; + } else { + MessageBox.post("ѡLY6_EPartToMPartWorkflow", "ʾ ", MessageBox.INFORMATION); + return; + } + // жǷ //ѭ + int count = 0; + + // ѭһж λ + for (int i = 0; i < tm_part.getRowCount(); i++) { + if (tm_part.getValueAt(i, 0).toString().equals("1")) { + if (tm_part.getValueAt(i, 7) == null || tm_part.getValueAt(i, 7).toString().isEmpty()) { + MessageBox.post("д" + (i + 1) + "йλ", "ʾ ", MessageBox.INFORMATION); + return; + } + + if (tm_part.getValueAt(i, 8) == null || tm_part.getValueAt(i, 8).toString().isEmpty()) { + MessageBox.post("д" + (i + 1) + "ˣ", "ʾ ", MessageBox.INFORMATION); + return; + } + count++; + } + } + if (count == 0) { + MessageBox.post("빴ѡݣ", "ʾ ", MessageBox.INFORMATION); + return; + } + KUtil.setByPass(true); + for (int i = 0; i < tm_part.getRowCount(); i++) { + if (tm_part.getValueAt(i, 0).toString().equals("1")) { + try { + ArrayList arrayList = valueList.get(i); + TCComponentItemRevision rev = (TCComponentItemRevision) arrayList.get(9); + TCComponentItem eItem = rev.getItem(); + String eType = eItem.getType(); + System.out.println("etype=============" + eType); + type = (TCComponentItemType) session.getTypeComponent(typesMap.get(eType)); + TCComponentBOMLine topLine = view.setWindowTopLine(rev.getItem(), rev, null, null); + int childrenCount = topLine.getChildrenCount(); + System.out.println("childrenCount========" + childrenCount); + TCComponent[] searchLs = session.search("_SearchMFKProperties", new String[] { "ID", "" }, + new String[] { (String) arrayList.get(2), (String) tm_part.getValueAt(i, 7) }); + + String ly6_sequenceNum = "0"; + // ȥòѯ鿴ùˮ +// if(searchLs != null && searchLs.length > 0) { +// TCComponentItem mItem = (TCComponentItem)searchLs[0]; +// ly6_sequenceNum = mItem.getStringProperty("ly6_sequenceNum"); +// System.out.println("ly6_sequenceNum==="+ly6_sequenceNum); +// System.out.println("pxuid==========="+mItem.getUid()); +// } +// + for (int j = 0; j < searchLs.length; j++) { + TCComponentItem mItem = (TCComponentItem) searchLs[j]; + System.out.println(mItem.getUid() + "===========mItem.uid"); + String num = mItem.getStringProperty("ly6_sequenceNum"); + System.out.println("num===" + num); + System.out.println("ly6_sequenceNum===" + ly6_sequenceNum); + ly6_sequenceNum = getLargerNumber(num, ly6_sequenceNum); + } + + if (childrenCount == 0) { + // ֱӴ + String newID = (String) arrayList.get(2); + String newRev = type.getNewRev(null); + + TCComponentItem item = type.create(newID, newRev, typesMap.get(eType), "", "", null); + TCComponentItemRevision mRev = item.getLatestItemRevision(); + item.setProperty("ly6_company", tm_part.getValueAt(i, 7).toString()); + System.out.println("itemUid2============" + item.getUid()); + if (ly6_sequenceNum.isEmpty() || ly6_sequenceNum.equals("0")) { + item.setProperty("ly6_sequenceNum", "01"); + } else { + item.setProperty("ly6_sequenceNum", incrementNumber(ly6_sequenceNum)); + System.out.println("itemUid3============" + item.getUid()); + } + + // ɾǰ + TCComponent delItem1 = session.stringToComponent((String) arrayList.get(2)); + + if (delItem1 != null) { + System.out.println("delItem1.getUid()====" + delItem1.getUid()); + delItem1.delete(); + + } + + TCComponent delItem2 = session + .stringToComponent((String) arrayList.get(2) + (String) tm_part.getValueAt(i, 7)); + + if (delItem1 != null) { + System.out.println("delItem2.getUid()====" + delItem2.getUid()); + delItem2.delete(); + } + + // Ըֵ + String fiedsStr = fieldsMap.get(eType + ":" + typesMap.get(eType)); + System.out.println("fiedsStr===================" + fiedsStr); + if (fiedsStr != null && !fiedsStr.isEmpty()) { + if (fiedsStr.contains(",")) { + String[] split = fiedsStr.split(","); + System.out.println("split.length===========" + split.length); + for (int j = 0; j < split.length; j++) { + // :ָ + String[] split2 = split[j].split(":"); + System.out.println("split2.length=================" + split2.length); + if (split2.length == 2) { + // .ָ + String[] split3 = split2[0].split("\\."); + System.out.println("split3.length=================" + split3.length); + if (split3.length == 2) { + if (split3[0].equals("item")) { + String[] split4 = split2[1].split("\\."); + if (split4.length == 2) { + if (split4[0].equals("item")) { + System.out.println("split4[1]========" + split4[1] + + "split3[1]======" + split3[1]); + + item.setProperty(split4[1], eItem.getProperty(split3[1])); + } else if (split4[0].equals("rev")) { + System.out.println("split4[1]========" + split4[1] + + "split3[1]======" + split3[1]); + mRev.setProperty(split4[1], eItem.getProperty(split3[1])); + } + } + + } else if (split3[0].equals("rev")) { + String[] split4 = split2[1].split("\\."); + if (split4.length == 2) { + if (split4[0].equals("item")) { + System.out.println("split4[1]========" + split4[1] + + "split3[1]======" + split3[1]); + item.setProperty(split4[1], rev.getProperty(split3[1])); + } else if (split4[0].equals("rev")) { + System.out.println("split4[1]========" + split4[1] + + "split3[1]======" + split3[1]); + System.out.println("value==========================="+rev.getProperty(split3[1])); + mRev.setProperty(split4[1], rev.getProperty(split3[1])); + } + } + } + } + } + } + } else { + + // :ָ + String[] split2 = fiedsStr.split(":"); + if (split2.length == 2) { + // .ָ + String[] split3 = split2[0].split("\\."); + System.out.println("split3.length=================" + split3.length); + if (split3.length == 2) { + if (split3[0].equals("item")) { + String[] split4 = split2[1].split("\\."); + if (split4.length == 2) { + if (split4[0].equals("item")) { + System.out.println("split4[1]========" + split4[1] + + "split3[1]======" + split3[1]); + item.setProperty(split4[1], eItem.getProperty(split3[1])); + } else if (split4[0].equals("rev")) { + System.out.println("split4[1]========" + split4[1] + + "split3[1]======" + split3[1]); + mRev.setProperty(split4[1], eItem.getProperty(split3[1])); + } + } + + } else if (split3[0].equals("rev")) { + String[] split4 = split2[1].split("\\."); + if (split4.length == 2) { + if (split4[0].equals("item")) { + System.out.println("split4[1]========" + split4[1] + + "split3[1]======" + split3[1]); + item.setProperty(split4[1], rev.getProperty(split3[1])); + } else if (split4[0].equals("rev")) { + System.out.println("split4[1]========" + split4[1] + + "split3[1]======" + split3[1]); + mRev.setProperty(split4[1], rev.getProperty(split3[1])); + } + } + } + } + } + } + } + // ly6_homemadeStatus + mRev.setProperty("ly6_homemadeStatus", ""); + String personId = tm_part.getValueAt(i, 8).toString(); + String[] split = personId.split("_"); + System.out.println("personId========"+split[1]); + mRev.setProperty("ly6_assignUser", split[1] == null || split[1].isEmpty() ? "" : split[1]); + + // + if (workflowTemplate != null || !workflowTemplate.isEmpty()) { + CreateProcess(session, mRev, workflowTemplate); + } + + // Ѷŵļ + rev.add("LY6_relatedMPart", item); + TCComponent[] relatedComponents = rev.getRelatedComponents("TC_Is_Represented_By"); + for (int j = 0; j < relatedComponents.length; j++) { + relatedComponents[j].add("representation_for",mRev); + } + item.getLatestItemRevision().refresh(); + } else { + AIFComponentContext[] children = topLine.getChildren(); + + //ArrayList addList = new ArrayList();// mbom + LinkedHashMap addList = new LinkedHashMap(); + ArrayList childrenList = new ArrayList();// ѡеֵ + HashMap> revMap = new HashMap>();// object_String + + StringBuilder errMsg = new StringBuilder(); + for (int j = 0; j < children.length; j++) { + TCComponentBOMLine eLine = (TCComponentBOMLine) children[j].getComponent(); + // жǷ + TCComponentItemRevision eRev = eLine.getItemRevision(); + String tcProperty = eRev.getTCProperty("ly6_homemadeStatus").toString(); + System.out.println("ly6_homemadeStatus=======" + tcProperty); + String eId = eRev.getStringProperty("item_id"); + + + if (tcProperty.equals("")) { + // жemǷΨһ + + + //ѭһжû mpart + ArrayList list = new ArrayList(); + + for (int k = 0; k < groupSplit.length; k++) { + TCComponent[] search = session.search("_SearchMFKProperties", + new String[] { "ID", "" }, new String[] { eId, groupSplit[k] }); + + for (int l = 0; l < search.length; l++) { + TCComponentItem tempItem = (TCComponentItem) search[l]; + list.add(tempItem.getLatestItemRevision()); + } + } + + + if (list.size() == 0) { + errMsg.append(eId + "δMPart"+System.lineSeparator()); + } + + } + + } + if(errMsg.length() > 0) { + MessageBox.post(errMsg.toString(), "ʾ ", MessageBox.INFORMATION); + KUtil.setByPass(false); + return; + } + + + // ͶӦ汾 + for (int j = 0; j < children.length; j++) { + + TCComponentBOMLine eLine = (TCComponentBOMLine) children[j].getComponent(); + + //ȡ + String sl = eLine.getProperty("bl_quantity"); + + + // жǷ + TCComponentItemRevision eRev = eLine.getItemRevision(); + String tcProperty = eRev.getTCProperty("ly6_homemadeStatus").toString(); + System.out.println("ly6_homemadeStatus=======" + tcProperty); + String eId = eRev.getStringProperty("item_id"); + if (tcProperty.equals("")) { + + //ѭ ѡmpart + ArrayList tempMrevList = new ArrayList(); + + for (int k = 0; k < groupSplit.length; k++) { + TCComponent[] search = session.search("_SearchMFKProperties", + new String[] { "ID", "" }, new String[] { eId, groupSplit[k] }); + + for (int l = 0; l < search.length; l++) { + TCComponentItem tempItem = (TCComponentItem) search[l]; + tempMrevList.add(tempItem.getLatestItemRevision()); + } + } + +// if (tempMrevList.size() == 0) { +// MessageBox.post(eId + "δMPart", "ʾ ", MessageBox.INFORMATION); +// return; +// } else + if (tempMrevList.size() == 1) { + // Mbom + addList.put(tempMrevList.get(0),sl); + } else if (tempMrevList.size() > 1) { + // ûѡһMbom + + JComboBox jComboBox = new JComboBox(); + for (int k = 0; k < tempMrevList.size(); k++) { + String stringProperty = tempMrevList.get(k) + .getStringProperty("object_string"); + ArrayList tempList = new ArrayList(); + tempList.add(tempMrevList.get(k)); + tempList.add(sl); + //tempList.add("1"); + revMap.put(stringProperty, tempList); + jComboBox.addItem(stringProperty); + } + + // ʾģ̬Ի + DialogFrame dialog = new DialogFrame(MpartDialog.this, jComboBox, childrenList); + dialog.setVisible(true); + + // ȴԻرպִеIJ + dialog.addWindowListener(new java.awt.event.WindowAdapter() { + @Override + public void windowClosed(java.awt.event.WindowEvent e) { + + } + }); + + } + + } else { + // ΪֱӽEPartMBOM + addList.put(eRev,sl); + + } + } + + + + // ֱӴ + String newID = (String) arrayList.get(2); + String newRev = type.getNewRev(null); + + TCComponentItem item = type.create(newID, newRev, typesMap.get(eType), "", "", null); + TCComponentItemRevision mRev = item.getLatestItemRevision(); + item.setProperty("ly6_company", tm_part.getValueAt(i, 7).toString()); + if (ly6_sequenceNum.isEmpty() || ly6_sequenceNum.equals("0")) { + item.setProperty("ly6_sequenceNum", "01"); + } else { + item.setProperty("ly6_sequenceNum", incrementNumber(ly6_sequenceNum)); + } + + // ɾǰ + TCComponent delItem1 = session.stringToComponent((String) arrayList.get(2)); + if (delItem1 != null) { + System.out.println("delItem1.getUid()====" + delItem1.getUid()); + delItem1.delete(); + } + TCComponent delItem2 = session + .stringToComponent((String) arrayList.get(2) + (String) tm_part.getValueAt(i, 7)); + if (delItem1 != null) { + System.out.println("delItem2.getUid()====" + delItem2.getUid()); + delItem2.delete(); + } + + + // Ըֵ + String fiedsStr = fieldsMap.get(eType + ":" + typesMap.get(eType)); + System.out.println("fiedsStr===================" + fiedsStr); + if (fiedsStr != null && !fiedsStr.isEmpty()) { + if (fiedsStr.contains(",")) { + String[] split = fiedsStr.split(","); + System.out.println("split.length===========" + split.length); + for (int j = 0; j < split.length; j++) { + // :ָ + String[] split2 = split[j].split(":"); + System.out.println("split2.length=================" + split2.length); + if (split2.length == 2) { + // .ָ + String[] split3 = split2[0].split("\\."); + System.out.println("split3.length=================" + split3.length); + if (split3.length == 2) { + if (split3[0].equals("item")) { + String[] split4 = split2[1].split("\\."); + if (split4.length == 2) { + if (split4[0].equals("item")) { + System.out.println("split4[1]========" + split4[1] + + "split3[1]======" + split3[1]); + + item.setProperty(split4[1], eItem.getProperty(split3[1])); + } else if (split4[0].equals("rev")) { + System.out.println("split4[1]========" + split4[1] + + "split3[1]======" + split3[1]); + mRev.setProperty(split4[1], eItem.getProperty(split3[1])); + } + } + + } else if (split3[0].equals("rev")) { + String[] split4 = split2[1].split("\\."); + if (split4.length == 2) { + if (split4[0].equals("item")) { + System.out.println("split4[1]========" + split4[1] + + "split3[1]======" + split3[1]); + item.setProperty(split4[1], rev.getProperty(split3[1])); + } else if (split4[0].equals("rev")) { + System.out.println("split4[1]========" + split4[1] + + "split3[1]======" + split3[1]); + System.out.println("value==========================="+rev.getProperty(split3[1])); + mRev.setProperty(split4[1], rev.getProperty(split3[1])); + } + } + } + } + } + } + } else { + + // :ָ + String[] split2 = fiedsStr.split(":"); + if (split2.length == 2) { + // .ָ + String[] split3 = split2[0].split("\\."); + System.out.println("split3.length=================" + split3.length); + if (split3.length == 2) { + if (split3[0].equals("item")) { + String[] split4 = split2[1].split("\\."); + if (split4.length == 2) { + if (split4[0].equals("item")) { + System.out.println("split4[1]========" + split4[1] + + "split3[1]======" + split3[1]); + item.setProperty(split4[1], eItem.getProperty(split3[1])); + } else if (split4[0].equals("rev")) { + System.out.println("split4[1]========" + split4[1] + + "split3[1]======" + split3[1]); + mRev.setProperty(split4[1], eItem.getProperty(split3[1])); + } + } + + } else if (split3[0].equals("rev")) { + String[] split4 = split2[1].split("\\."); + if (split4.length == 2) { + if (split4[0].equals("item")) { + System.out.println("split4[1]========" + split4[1] + + "split3[1]======" + split3[1]); + item.setProperty(split4[1], rev.getProperty(split3[1])); + } else if (split4[0].equals("rev")) { + System.out.println("split4[1]========" + split4[1] + + "split3[1]======" + split3[1]); + mRev.setProperty(split4[1], rev.getProperty(split3[1])); + } + } + } + } + } + } + } + // ly6_homemadeStatus + mRev.setProperty("ly6_homemadeStatus", ""); + String personId = tm_part.getValueAt(i, 8).toString(); + String[] split = personId.split("_"); + System.out.println("personId========"+split[1]); + mRev.setProperty("ly6_assignUser", split[1] == null || split[1].isEmpty() ? "" : split[1]); + + + // Ѷŵļ + rev.add("LY6_relatedMPart", item); + TCComponent[] relatedComponents = rev.getRelatedComponents("TC_Is_Represented_By"); + for (int j = 0; j < relatedComponents.length; j++) { + relatedComponents[j].add("representation_for",mRev); + } + item.getLatestItemRevision().refresh(); + // mBOM + TCComponentBOMWindowType viewType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + TCComponentBOMWindow view = viewType.create(null); + TCComponentBOMLine mTopLine = view.setWindowTopLine(item, item.getLatestItemRevision(), + null, null); + + + + + + + + + System.out.println("childrenList.size()=======" + childrenList.size()); + for (int j = 0; j < childrenList.size(); j++) { + ArrayList temp = revMap.get(childrenList.get(j)); + TCComponentItemRevision object = (TCComponentItemRevision)temp.get(0); + String tempSl = (String)temp.get(1); + addList.put(object,tempSl); + } + + System.out.println("addList.size()============" + addList.size()); + + for (Entry tempAddList : addList.entrySet()) { + TCComponentItemRevision key = tempAddList.getKey(); + String value = tempAddList.getValue(); + if(value != null && value.equals("1")) { + mTopLine.add(key.getItem(), key, null, false, ""); + }else { + TCComponentBOMLine add = mTopLine.add(key.getItem(), key, null, false, ""); + System.out.println("add=================="+add.getUid()); + add.setProperty("bl_quantity", value); + } + + } + + + + + mTopLine.save(); + view.save(); + view.close(); + // + if (workflowTemplate != null || !workflowTemplate.isEmpty()) { + CreateProcess(session, mRev, workflowTemplate); + } + + } + + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + + } + + MessageBox.post("ɹ", "ʾ ", MessageBox.INFORMATION); + KUtil.setByPass(false); + } else if (this.viewlButton.equals(source)) { + // 򿪶󵽽ṹ + + System.out.println("ѡе===" + t_part2.getSelectedRow()); + if (t_part2.getSelectedRow() == -1) { + MessageBox.post("ұѡҪ򿪵ĶУ", "ʾ ", MessageBox.INFORMATION); + return; + } else { + if (table2RevList != null && table2RevList.size() > 0) { + ArrayList arrayList = valueList.get(t_part.getSelectedRow()); + Object object = arrayList.get(8); + com.teamcenter.rac.common.Activator.getDefault() + .openPerspective("com.teamcenter.rac.pse.PSEPerspective"); + try { + com.teamcenter.rac.common.Activator.getDefault().openComponents( + "com.teamcenter.rac.pse.PSEPerspective", + new InterfaceAIFComponent[] { table2RevList.get(t_part2.getSelectedRow()).getItem() }); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } + + } else if (this.xrButton.equals(source)) { + //KOrgDialog kOrgDialog = new KOrgDialog(""); + TCComponentUser user = new KOrgDialog("").getUser(); +// TCComponentGroup group = kOrgDialog.getGroup(); + //user = kOrgDialog.getUser(); + //group = kOrgDialog.getGroup(); + //System.out.println("Select User: " + user + "group===" + group); + String userName = ""; + try { + userName = user.getUserName()+"_"+user.getUserId(); + } catch (TCException e1) { + // TODO Auto-generated catch block + MessageBox.post("ѡû", "ʾ ", MessageBox.INFORMATION); + return; + } + int count = 0; + for (int i = 0; i < tm_part.getRowCount(); i++) { + if (tm_part.getValueAt(i, 0).toString().equals("1")) { + tm_part.setValueAt(userName, i, 8); + count++; + } + + } + if (count == 0) { + MessageBox.post("빴ѡݣ", "ʾ ", MessageBox.INFORMATION); + return; + } + } + + } + + private JPanel getBtnPanel() { + JPanel topPanel = new JPanel(); + topPanel.setLayout(new PropertyLayout()); + topPanel.add("1.1.center", new JLabel(" ")); + topPanel.add("2.1.center", xrButton); + topPanel.add("2.2.center", new JLabel(" ")); + topPanel.add("2.3.center", new JLabel("λ")); + topPanel.add("2.4.center", new JLabel(" ")); + topPanel.add("2.5.center", gsdwComboBox); + topPanel.add("2.6.center", new JLabel(" ")); + topPanel.add("2.7.center", createButton); + topPanel.add("2.8.center", new JLabel(" ")); + topPanel.add("2.9.center", viewlButton); + topPanel.add("3.1.center", new JLabel(" ")); + + return topPanel; + } + + // ѯ + private JPanel getTopPanel() { + // TODO Auto-generated method stub + JPanel topPanel = new JPanel(); + topPanel.setLayout(new BorderLayout()); + topPanel.add(getTablePanel(), BorderLayout.WEST); + topPanel.add(getTablePanel2(), BorderLayout.CENTER); + return topPanel; + } + + private JPanel getTablePanel() { + JPanel panel = new JPanel(new BorderLayout()); + panel.setPreferredSize(new Dimension(1100, 600)); + tm_part = new DefaultTableModel(); + t_part = new JTable(tm_part) { + /** + * + */ + private static final long serialVersionUID = 1L; + + @Override + public boolean isCellEditable(int row, int column) { + // Ʋɱ༭ + String value = (String) getValueAt(row, 5); + System.out.println("value==========" + value); + if (value.equals("")) { + if (column == 5) {// ɱ༭ + + return true; + } else { + return false; + } + } else { + + if (column == 5) {// ɱ༭ + + return true; + } else { + return false; + } + } + + } + + }; + + SwingUtilities.invokeLater(new Runnable() { + public void run() { + // + t_part.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() == 2 || e.getClickCount() == 1) { + // TODO Auto-generated method stub + int selectColumn = t_part.getTableHeader().columnAtPoint(e.getPoint()); + int selectedRow = t_part.rowAtPoint(e.getPoint()); + + if (selectColumn != 0) { + t_part2.removeAll(); + tm_part2.setRowCount(0); + table2RevList.clear(); + ArrayList arrayList = valueList.get(selectedRow); + Object object = arrayList.get(8); + + if (object != null) { + + ArrayList tempList = (ArrayList) object; + for (int i = 0; i < tempList.size(); i++) { + table2RevList.add(tempList.get(i)); + } + System.out.println("tempList======" + tempList.size()); + for (int i = 0; i < tempList.size(); i++) { + TCComponentItemRevision tcComponentItemRevision = tempList.get(i); + try { +// String id = tcComponentItemRevision.getStringProperty("item_id"); +// System.out.println("item_id======" + id); + String objectName = tcComponentItemRevision + .getStringProperty("object_string"); + tm_part2.addRow(new Object[] { i + 1, objectName }); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } + } else { + + if (t_part.getValueAt(selectedRow, 5).equals("")) { + Object valueAt = t_part.getValueAt(selectedRow, selectColumn); + if (valueAt.toString().equals("1")) { + t_part.setValueAt("0", selectedRow, selectColumn); + } else { + t_part.setValueAt("1", selectedRow, selectColumn); + } + } + + } + } + } + }); + } + }); + +// t_part.addMouseListener(new MouseListener() { +// +// @Override +// public void mouseReleased(MouseEvent e) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mousePressed(MouseEvent e) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mouseExited(MouseEvent e) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mouseEntered(MouseEvent e) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mouseClicked(MouseEvent e) { +// // TODO Auto-generated method stub +// int selectColumn = t_part.getTableHeader().columnAtPoint(e.getPoint()); +// int selectedRow = t_part.rowAtPoint(e.getPoint()); +// +// if(selectColumn != 0) +// { +// t_part2.removeAll(); +// tm_part2.setRowCount(0); +// table2RevList.clear(); +// ArrayList arrayList = valueList.get(selectedRow); +// Object object = arrayList.get(8); +// System.out.println("11111111111111111111111111111111"); +// if(object != null) { +// +// ArrayList tempList = (ArrayList)object; +// for (int i = 0; i < tempList.size(); i++) { +// table2RevList.add(tempList.get(i)); +// } +// System.out.println("tempList======"+tempList.size()); +// for (int i = 0; i < tempList.size(); i++) { +// TCComponentItemRevision tcComponentItemRevision = tempList.get(i); +// try { +// String id = tcComponentItemRevision.getStringProperty("item_id"); +// System.out.println("item_id======"+id); +// String objectName = tcComponentItemRevision.getStringProperty("object_name"); +// tm_part2.addRow(new Object[] {i+1,id+"_"+objectName}); +// } catch (TCException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } +// } +// } +// }else { +// Object valueAt = t_part.getValueAt(selectedRow, selectColumn); +// if(valueAt.toString().equals("1")) { +// t_part.setValueAt("0", selectedRow, selectColumn); +// }else { +// t_part.setValueAt("1", selectedRow, selectColumn); +// } +// } +// } +// }); + + tm_part.setDataVector(null, HEADER); + t_part.getTableHeader().setReorderingAllowed(false); // вƶᷢת󣨵У + this.t_part.setRowHeight(30); + + TableColumnModel colModel = this.t_part.getColumnModel(); + int colCnt = HEADERWIDTH.length; + for (int i = 0; i < colCnt; i++) { + colModel.getColumn(i).setPreferredWidth(HEADERWIDTH[i]); + } + t_part.getTableHeader().setDefaultRenderer(new CheckHeaderCellRenderer(t_part)); + t_part.getColumnModel().getColumn(0).setCellRenderer(new TableCellCheckboxRenderer(t_part)); + JComboBox jComboBox1 = new JComboBox(); + jComboBox1.addItem("⹺"); + jComboBox1.addItem(""); + t_part.getColumnModel().getColumn(5).setCellEditor(new DefaultCellEditor(jComboBox1)); + // ȡѡֵ +// String[] ld_taskNature = session.getPreferenceService().getStringValues("ld_taskNature");// +// String[] ld_taskDifficulty = session.getPreferenceService().getStringValues("ld_taskDifficulty");// ׳̶ +// String[] ld_urgency = session.getPreferenceService().getStringValues("ld_urgency");// ̶ +// +// Map ld_taskNatureMap = new HashMap(); +// Map ld_taskDifficultyMap = new HashMap(); +// Map ld_urgencyMap = new HashMap(); + + // ֵ + +// for (int i = 0; i < ld_taskNature.length; i++) { +// String[] split = ld_taskNature[i].split("="); +// ld_taskNatureMap.put(split[0], Double.parseDouble(split[1])); +// jComboBox1.addItem(split[0]); +// } +// +// for (int i = 0; i < ld_taskDifficulty.length; i++) { +// String[] split = ld_taskDifficulty[i].split("="); +// ld_taskDifficultyMap.put(split[0], Double.parseDouble(split[1])); +// jComboBox2.addItem(split[0]); +// } +// +// for (int i = 0; i < ld_urgency.length; i++) { +// String[] split = ld_urgency[i].split("="); +// ld_urgencyMap.put(split[0], Double.parseDouble(split[1])); +// jComboBox3.addItem(split[0]); +// } + +// +// // +// t_part.addMouseListener(new MouseAdapter() { +// @Override +// public void mouseClicked(MouseEvent e) { +// if (e.getClickCount() == 2 && t_part.columnAtPoint(e.getPoint()) == 2) { // жǷ˫ڵڶ +// int row = t_part.rowAtPoint(e.getPoint()); +// int column = t_part.columnAtPoint(e.getPoint()); +// if (column == 2) { +// // ȡ˫ĵԪ +// String value = (String) t_part.getModel().getValueAt(row, column); +// // ﴦ˫¼ +// System.out.println("Double-clicked on cell: Row=" + row + ", Column=" + column + ", Value=" + value); +// // Ӹ߼˫¼ +// +// } +// +// } +// } +// }); + + // this.t_part.getTableHeader().setBackground(Color.blue); + + JScrollPane scroll = new JScrollPane(t_part); + panel.add(BorderLayout.CENTER, scroll); + + panel.setBorder(BorderFactory.createLoweredBevelBorder()); + return panel; + } + + //ȡұߵpanel + private JPanel getTablePanel2() { + JPanel panel = new JPanel(new BorderLayout()); + panel.setPreferredSize(new Dimension(200, 600)); + tm_part2 = new DefaultTableModel(); + t_part2 = new JTable(tm_part2) { + /** + * + */ + + @Override + public boolean isCellEditable(int row, int column) { + if (column == 0) {// ɱ༭ + return true; + } else { + return false; + } + + } + + }; + tm_part2.setDataVector(null, HEADER2); + t_part2.getTableHeader().setReorderingAllowed(false); // вƶᷢת󣨵У + this.t_part2.setRowHeight(23); + TableColumnModel colModel = this.t_part2.getColumnModel(); + int colCnt = HEADERWIDTH2.length; + for (int i = 0; i < colCnt; i++) { + colModel.getColumn(i).setPreferredWidth(HEADERWIDTH2[i]); + } + // t_part2.getTableHeader().setDefaultRenderer(new + // CheckHeaderCellRenderer(t_part2)); + // t_part2.getColumnModel().getColumn(0).setCellRenderer(new + // TableCellCheckboxRenderer(t_part2)); +// t_part2.addMouseListener(new MouseListener() { +// +// @Override +// public void mouseReleased(MouseEvent e) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mousePressed(MouseEvent e) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mouseExited(MouseEvent e) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mouseEntered(MouseEvent e) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mouseClicked(MouseEvent e) { +// // TODO Auto-generated method stub +// int selectColumn = t_part2.getTableHeader().columnAtPoint(e.getPoint()); +// int selectedRow = t_part2.rowAtPoint(e.getPoint()); +//// System.out.println("selectColumn==>"+selectColumn); +// if(selectColumn != 0) +// { +// return; +// }else { +// Object valueAt = t_part2.getValueAt(selectedRow, selectColumn); +// if(valueAt.toString().equals("1")) { +// t_part2.setValueAt("0", selectedRow, selectColumn); +// }else { +// t_part2.setValueAt("1", selectedRow, selectColumn); +// } +// } +// } +// }); + // õһеĵԪȾͱ༭ + +// +// // +// t_part.addMouseListener(new MouseAdapter() { +// @Override +// public void mouseClicked(MouseEvent e) { +// if (e.getClickCount() == 2 && t_part.columnAtPoint(e.getPoint()) == 2) { // жǷ˫ڵڶ +// int row = t_part.rowAtPoint(e.getPoint()); +// int column = t_part.columnAtPoint(e.getPoint()); +// if (column == 2) { +// // ȡ˫ĵԪ +// String value = (String) t_part.getModel().getValueAt(row, column); +// // ﴦ˫¼ +// System.out.println("Double-clicked on cell: Row=" + row + ", Column=" + column + ", Value=" + value); +// // Ӹ߼˫¼ +// +// } +// +// } +// } +// }); + + // this.t_part2.getTableHeader().setBackground(Color.blue); + + JScrollPane scroll = new JScrollPane(t_part2); + panel.add(BorderLayout.CENTER, scroll); + + panel.setBorder(BorderFactory.createLoweredBevelBorder()); + return panel; + } + + public String getGroupID() throws TCException { + TCComponentGroup group = session.getCurrentGroup(); + String name = group.getTCProperty("full_name").getStringValue(); + if (name.contains(".")) { + String[] split = name.split("\\."); + name = split[split.length - 1]; + System.out.println("name==============" + name); + } + return name; + } + + /** + * ַʾ10µּ1ؼ1ַ + * + * @param numberStr ַʽΪ "01", "02", ..., "10" + * @return 1ַʽֲ + */ + public String incrementNumber(String numberStr) { + // ַ֤ǷԤڸʽ + if (!numberStr.matches("^0[1-9]|10$")) { + throw new IllegalArgumentException("Input must be a string representing a number between 01 and 10."); + } + + // ַתΪ + int number = Integer.parseInt(numberStr); + + // 1 + number++; + + // ʽ + String formattedNumber = String.format("%02d", number); + + return formattedNumber; + } + + // + public static void CreateProcess(TCSession session, TCComponent target, String processName) throws TCException { + try { + TCComponentProcessType processType = (TCComponentProcessType) session.getTypeComponent("Job"); + TCComponentTaskTemplateType taskTemplateType = (TCComponentTaskTemplateType) session + .getTypeComponent("EPMTaskTemplate"); + TCComponentTaskTemplate taskTemplate = taskTemplateType.find(processName, 0); + if (taskTemplate != null) { + String name = target.getProperty("object_string"); + TCComponent create = processType.create(processName + "" + name, "", taskTemplate, + new TCComponent[] { target }, new int[] { 1 }); + System.out.println("uid===================" + create.getUid()); + System.out.println("type==" + create.getType()); + System.out.println("type==" + create.getStringProperty("object_type")); + } + } catch (TCException var7) { + var7.printStackTrace(); + throw var7; + } + } + + public String getLargerNumber(String num1, String num2) { + if (num1 == null || num1.isEmpty()) { + return num2; + } + // ַתΪ + int n1 = Integer.parseInt(num1); + int n2 = Integer.parseInt(num2); + + // Ƚؽϴһַʽ + if (n1 > n2) { + return num1; + } else { + return num2; + } + } +} diff --git a/src/com/langtech/plm/mpart/MpartHandler.java b/src/com/langtech/plm/mpart/MpartHandler.java new file mode 100644 index 0000000..b5b73c3 --- /dev/null +++ b/src/com/langtech/plm/mpart/MpartHandler.java @@ -0,0 +1,116 @@ +package com.langtech.plm.mpart; + +import java.util.ArrayList; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentSchedule; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +import com.teamcenter.rac.kernel.TCComponentTask; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class MpartHandler extends AbstractHandler{ + + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + try { + + new Thread() { + @Override + public void run() { + InterfaceAIFComponent[] targetComponent = app.getTargetComponents(); + ArrayList arrayList = new ArrayList(); + String[] types = session.getPreferenceService().getStringValues("LY6_EPartType"); + if(types != null && types.length > 0) { + for (int i = 0; i < targetComponent.length; i++) { + InterfaceAIFComponent component = targetComponent[i]; + if(component instanceof TCComponentItemRevision) { + String type = component.getType(); + System.out.println("type================"+type); + if(types[0].contains(type)) { + arrayList.add((TCComponentItemRevision)component); + } + + }else if(component instanceof TCComponentTask) { + TCComponentTask task = (TCComponentTask)component; + try { + TCComponent[] targets = task.getRelatedComponents("root_target_attachments"); + for(TCComponent attachment:targets) { + + if(attachment instanceof TCComponentItemRevision) { + + String type = attachment.getType(); + System.out.println("type================"+type); + if(types[0].contains(type)) { + arrayList.add((TCComponentItemRevision)attachment); + } + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }else if(component instanceof TCComponentBOMLine) { + TCComponentBOMLine bomLine = (TCComponentBOMLine)component; + try { + TCComponentItemRevision itemRevision = bomLine.getItemRevision(); + String type = itemRevision.getType(); + System.out.println("type2================"+type); + if(types[0].contains(type)) { + arrayList.add((TCComponentItemRevision)itemRevision); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + System.out.println("arrayList.size()==========="+arrayList.size()); + + if(arrayList.size() > 0) { + try { + new MpartDialog(session,arrayList); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }else { + MessageBox.post("δȡ", "ʾ ", MessageBox.INFORMATION); + return; + } + + }else { + MessageBox.post("ѡLY6_EPartType", "ʾ ", MessageBox.INFORMATION); + return; + } + + + + + } + }.start(); + + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + return null; + } + + +} diff --git a/src/com/langtech/plm/mpart/TableCellCheckboxRenderer.java b/src/com/langtech/plm/mpart/TableCellCheckboxRenderer.java new file mode 100644 index 0000000..e7fbd7d --- /dev/null +++ b/src/com/langtech/plm/mpart/TableCellCheckboxRenderer.java @@ -0,0 +1,54 @@ +package com.langtech.plm.mpart; + +import java.awt.Component; +import java.util.List; + +import javax.swing.JCheckBox; +import javax.swing.JRadioButton; +import javax.swing.JTable; +import javax.swing.SwingConstants; +import javax.swing.event.ChangeEvent; +import javax.swing.event.EventListenerList; +import javax.swing.table.TableCellRenderer; + +import com.teamcenter.rac.treetable.JTreeTable; + + +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 JTable table) { + } + public TableCellCheckboxRenderer(final JTreeTable table) { + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + // TODO Auto-generated method stub + this.setHorizontalAlignment(SwingConstants.CENTER);// ͷǩ +// this.setBorderPainted(true); + System.out.println("valuevaluevalue==="+value); + 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/langtech/plm/project/CalculateDialog.java b/src/com/langtech/plm/project/CalculateDialog.java new file mode 100644 index 0000000..bcaf88c --- /dev/null +++ b/src/com/langtech/plm/project/CalculateDialog.java @@ -0,0 +1,743 @@ +package com.langtech.plm.project; + +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.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentMEOP; +import com.teamcenter.rac.kernel.TCComponentMEOPRevision; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.UIUtilities; + +public class CalculateDialog extends JFrame implements ActionListener { + /** + * + */ + private static final long serialVersionUID = 1L; + + private AbstractAIFApplication application; + private TCComponentMEOPRevision meop; + private TCSession session; + + TCComponentItemRevision rawMaterialRevision; + + //ӡؼ + //ͼֱֽD + private JLabel zjdLabel; + private JTextField zjdTextField; + //ͼֽ + private JLabel lkcLabel; + private JTextField lkcTextField; + //жó + private JLabel qdycdLabel; + private JTextField qdycdTextField; + //ó + private JLabel cdmycdLabel; + private JTextField cdmycdTextField; + //ͷó + private JLabel jtycdLabel; + private JTextField jtycdTextField; + // + private JLabel kzljsLabel; + private JTextField kzljsTextField; + // + private JLabel ggLabel; + private JTextField ggTextField; + //ƺ + private JLabel clphLabel; + private JTextField clphTextField; + + //ؼ + //ܳ + private JLabel zcLabel; + private JTextField zcTextField; + // + private JLabel djcdLabel; + private JTextField djcdTextField; + // + private JLabel djzlLabel; + private JTextField djzlTextField; + //׼ʱ + private JLabel bzgsLabel; + private JTextField bzgsTextField; + //ʱ + private JLabel fzgsLabel; + private JTextField fzgsTextField; + + //㰴ť + private JButton calculateButton; + //ͬť + private JButton syncButton; + //ȡť + private JButton celButton; + + //ܶ + private String density; + // + private String crossSection; + //ʱ + private String auxiliaryTime; + //̶ʱ + private String fixedTime; + //иʱ + private String cuttingTime; + + + public CalculateDialog(AbstractAIFApplication application,TCComponentMEOPRevision meop) throws TCException { + this.application = application; + this.meop = meop; + this.session = (TCSession) application.getSession(); + initUI(); + getProperties(this.meop); + } + + + private JPanel getTopPanel() { + JPanel centerPanel = new JPanel(new PropertyLayout()); + centerPanel.add("1.1.left.top",this.zjdLabel); + centerPanel.add("1.2.left.top",this.zjdTextField); + centerPanel.add("2.1.left.top",this.lkcLabel); + centerPanel.add("2.2.left.top",this.lkcTextField); + centerPanel.add("3.1.left.top",this.qdycdLabel); + centerPanel.add("3.2.left.top",this.qdycdTextField); + centerPanel.add("4.1.left.top",this.cdmycdLabel); + centerPanel.add("4.2.left.top",this.cdmycdTextField); + centerPanel.add("5.1.left.top",this.jtycdLabel); + centerPanel.add("5.2.left.top",this.jtycdTextField); + centerPanel.add("6.1.left.top",this.kzljsLabel); + centerPanel.add("6.2.left.top",this.kzljsTextField); + centerPanel.add("7.1.left.top",this.ggLabel); + centerPanel.add("7.2.left.top",this.ggTextField); + centerPanel.add("8.1.left.top",this.clphLabel); + centerPanel.add("8.2.left.top",this.clphTextField); + + centerPanel.add("1.3.left.top",this.zcLabel); + centerPanel.add("1.4.left.top",this.zcTextField); + centerPanel.add("2.3.left.top",this.djcdLabel); + centerPanel.add("2.4.left.top",this.djcdTextField); + centerPanel.add("3.3.left.top",this.djzlLabel); + centerPanel.add("3.4.left.top",this.djzlTextField); + centerPanel.add("4.3.left.top",this.bzgsLabel); + centerPanel.add("4.4.left.top",this.bzgsTextField); + centerPanel.add("5.3.left.top",this.fzgsLabel); + centerPanel.add("5.4.left.top",this.fzgsTextField); + centerPanel.add("6.3.left.top",this.calculateButton); + + return centerPanel; + } + + /** + * ýĿ + */ + private void setPanelProperties() { + this.zjdLabel = new JLabel("ͼֱֽD"); + this.lkcLabel = new JLabel("ͼֽ"); + this.qdycdLabel = new JLabel("жó"); + this.cdmycdLabel = new JLabel("ó"); + this.jtycdLabel = new JLabel("ͷó"); + this.kzljsLabel = new JLabel(""); + this.ggLabel = new JLabel(""); + this.clphLabel = new JLabel("ƺ"); + this.zcLabel = new JLabel("ܳ"); + this.djcdLabel = new JLabel(""); + this.djzlLabel = new JLabel(""); + this.bzgsLabel = new JLabel("׼ʱ"); + this.fzgsLabel = new JLabel("ʱ"); + + this.zjdTextField = new JTextField(32); + this.lkcTextField = new JTextField(32); + this.qdycdTextField = new JTextField(32); + this.cdmycdTextField = new JTextField(32); + this.jtycdTextField = new JTextField(32); + this.kzljsTextField = new JTextField(32); + this.ggTextField = new JTextField(32); + this.ggTextField.setEditable(false); + this.ggTextField.setBackground(new Color(200, 200, 200)); + this.clphTextField = new JTextField(32); + this.clphTextField.setEditable(false); + this.ggTextField.setBackground(new Color(200, 200, 200)); + this.zcTextField = new JTextField(32); + this.djcdTextField = new JTextField(32); + this.djzlTextField = new JTextField(32); + this.bzgsTextField = new JTextField(32); + this.fzgsTextField = new JTextField(32); + + this.calculateButton = new JButton(""); + this.syncButton = new JButton("ͬ"); + this.celButton = new JButton("ȡ"); + } + + /** + * ȡײť + * @return + */ + private JPanel getButtomPanel() { + JPanel bottomPanel = new JPanel(new FlowLayout(1)); +// bottomPanel.add(this.calculateButton); + bottomPanel.add(this.syncButton); + bottomPanel.add(this.celButton); + + return bottomPanel; + } + + /** + * ʼͼν + */ + private void initUI() { + this.setTitle("϶ʱ"); + this.setSize(500, 500); + this.setLayout(new BorderLayout()); + + setPanelProperties(); + + JPanel centerPanel = getTopPanel(); + + JPanel bottomPanel = getButtomPanel(); + + this.add(centerPanel,BorderLayout.CENTER); + this.add(bottomPanel,BorderLayout.SOUTH); + + //¼ + this.calculateButton.addActionListener(this); + this.syncButton.addActionListener(this); + this.celButton.addActionListener(this); + + //ŵĻ + UIUtilities.centerToScreen(this); + this.setVisible(true); + + } + + /** + * ȡѡMEOPԣֵ + * @param meop + * @throws TCException + */ + private void getProperties(TCComponentMEOPRevision meop) throws TCException { + String outlineDiameter = meop.getStringProperty("ly6_outlineDiameter"); + String outlineLength = meop.getStringProperty("ly6_outlineLength"); + String cuttingLength = meop.getStringProperty("ly6_cuttingLength"); + String transverseLength = meop.getStringProperty("ly6_transverseLength"); + String colletLength = meop.getStringProperty("ly6_colletLength"); + String manufacturingQuantity =meop.getStringProperty("ly6_manufacturableQuantity"); + //ƺŵbomlineµȡã + String specifications = null; + String brandNum = null; +// String specifications = meop.getStringProperty("ly6_specifications"); +// String brandNum = meop.getStringProperty("ly6_material"); + TCComponentItem item = meop.getItem(); + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + // ͼ-汾򣨾ȷ״̬ȡĬϹ + TCComponentBOMWindow view = winType.create(null); + // BOMBOMitem͵BOMΪһBOM args:item 汾 ... + TCComponentBOMLine topBomLine = view.setWindowTopLine(item, meop, null, null); + topBomLine.lock(); + if (topBomLine.hasChildren()) { + System.out.println("dialogǰbomУ"); + AIFComponentContext[] childrens = topBomLine.getChildren(); + int tag = 0; + for (AIFComponentContext children : childrens) { + TCComponentBOMLine bomLine = (TCComponentBOMLine)children.getComponent(); + TCComponentItemRevision itemRevision = bomLine.getItemRevision(); + String childType = itemRevision.getType(); + System.out.println("ǰͨbomlineȡͣ"+childType); + if (childType.equals("LY6_RawMaterial") || childType.equals("LY6_RawMaterialRevision")) { + System.out.println("ɹȡǰġԭϡ"); + specifications = itemRevision.getStringProperty("ly6_specifications"); + brandNum = itemRevision.getStringProperty("ly6_material"); + System.out.println("ȡ"+specifications); + System.out.println("ȡƺţ"+brandNum); + tag ++; + break; + } + } + if (tag == 0) {//bomlineûΪLY6_RawMaterialRevisionĶ + MessageBox.post("δԭ϶","ʾ",MessageBox.INFORMATION); + //todo burangjisuan + topBomLine.unlock(); + view.close(); + //ر + this.setVisible(false); + //ͷ + this.dispose(); + return; + } + }else { + MessageBox.post("δԭ϶","ʾ",MessageBox.INFORMATION); + //todo burangjisuan + topBomLine.unlock(); + view.close(); + //ر + this.setVisible(false); + //ͷ + this.dispose(); + return; + } + topBomLine.unlock(); + view.close(); + + this.zjdTextField.setText(outlineDiameter != null ? outlineDiameter : ""); + this.lkcTextField.setText(outlineLength != null ? outlineLength : ""); + this.qdycdTextField.setText(cuttingLength != null ? cuttingLength : ""); + this.cdmycdTextField.setText(transverseLength != null ? transverseLength : ""); + this.jtycdTextField.setText(colletLength != null ? colletLength : ""); + this.kzljsTextField.setText(manufacturingQuantity != null ? manufacturingQuantity : ""); + this.ggTextField.setText(specifications != null ? specifications : ""); + this.clphTextField.setText(brandNum != null ? brandNum : ""); + } + + + /** + * ܳ + * @return + */ + private String calculateTotalLength() { + // ȡ TextField + String lkcText = this.lkcTextField.getText(); + String qdycdText = this.qdycdTextField.getText(); + String cdmycdText = this.cdmycdTextField.getText(); + String kzljsText = this.kzljsTextField.getText(); + String jtycdText = this.jtycdTextField.getText(); + + // ַתΪֵ + double lkcValue = Double.parseDouble(lkcText); + double qdycdValue = Double.parseDouble(qdycdText); + double cdmycdValue = Double.parseDouble(cdmycdText); + double kzljsValue = Double.parseDouble(kzljsText); + double jtycdValue = Double.parseDouble(jtycdText); + + // + double result = (lkcValue + qdycdValue + cdmycdValue) * kzljsValue + jtycdValue; + System.out.println("ͼֽ"+lkcValue+"жóȣ"+qdycdValue+"óȣ"+cdmycdValue+""+kzljsValue+"ͷóȣ"+jtycdValue); +// double cm = result / 10.0; + String formattedCm = String.format("%.2f", result); + return formattedCm; + } + + /** + * 㵥 + * @return + */ + private String calculateSingleLength(){ + String zcText = this.zcTextField.getText(); + String kzljsText = this.kzljsTextField.getText(); + + double zcValue = Double.parseDouble(zcText); + double kzljsValue = Double.parseDouble(kzljsText); + if (kzljsValue == 0){ + System.out.println(" is 0"); + } + double result = zcValue / kzljsValue; + System.out.println("ܳ"+zcValue+""+kzljsValue); +// double cm = result / 10.0; + String format = String.format("%.2f", result); + return format; + } + + private void downLoadFile(File file) throws Exception { + FileInputStream inputStream = new FileInputStream(file); + // ָļı· + String localFilePath = "C:\\"+file.getName(); + + try { + // Ŀ· + Path path = Paths.get(localFilePath); + + // д뵽ļ + Files.copy(inputStream, path); + + System.out.println("ļѳɹ: "+localFilePath); + } catch (Exception e) { + e.printStackTrace(); + System.out.println("ļʱ"); + } finally { + // رͷԴ + if (inputStream != null) { + try { + inputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + + /** + * ѡеuidȡݼEXCEL + * uidȡitem󣬻ȡöµ + * ݡֱȡEXCELвıҪĿʱͱ׼ʱ + * @throws Exception + */ + private void getDataset(){ + System.out.println("getDataset"); + TCPreferenceService preferenceService = session.getPreferenceService(); + String itemId = preferenceService.getStringValue("LY6_MEOPTypeTime"); + + InterfaceAIFComponent[] resultComponents; + try { + resultComponents = session.search("...", new String[] {" ID"}, new String[] {itemId}); + + InterfaceAIFComponent component = resultComponents[0]; + if (component instanceof TCComponentItem){ + TCComponentItem item = (TCComponentItem) component; + //ȡitemѷ°汾淶ϵµMSEXCELݼ + TCComponentItemRevision[] releasedItemRevisions = item.getReleasedItemRevisions(); + int releaseRevNum = releasedItemRevisions.length; + if (releaseRevNum == 0) { + System.out.println("󣺵ǰ²ڷ汾"); + } + TCComponentItemRevision tcComponentItemRevision = releasedItemRevisions[releaseRevNum - 1]; + + //ȡǰ汾Ĺ淶ϵµݼ + TCComponent[] referenceListProperty = tcComponentItemRevision.getReferenceListProperty("IMAN_specification"); + if(referenceListProperty.length>0) { + System.out.println("淶ϵµݼ"+referenceListProperty.length); + //ȡһݼ¾ļ + TCComponentTcFile[] tcFiles = ((TCComponentDataset)referenceListProperty[0]).getTcFiles(); + if (tcFiles.length > 0) { +// System.out.println("ݼļ" + tcFiles.length); + File file = tcFiles[0].getFmsFile(); +// if (file.exists()) { +// System.out.println("ʼأ"); +// downLoadFile(file); +// } + System.out.println("ȡݼļ"+file.getName()); + // ݺȡݼ-excelУӦĿݣʱ䡢̶ʱ䡢иʱ + FileInputStream fis = new FileInputStream(file); + Workbook workbook = new HSSFWorkbook(fis); + Sheet sheet = workbook.getSheetAt(0); + //ӵ3ʼ(ǰDZ) + for (int i = 2; i < sheet.getPhysicalNumberOfRows(); i++) { + Row row = sheet.getRow(i); + //ȡÿеĵһֱֵ +// double diam = row.getCell(0).getNumericCellValue(); + String diam = row.getCell(0).getStringCellValue(); + // ݹƥݼеֱ + if (diam.equals(this.ggTextField.getText())){ +// if (diam == Double.parseDouble(this.ggTextField.getText())){ + System.out.println("=========ֱƥɹʼȡʱͱ׼ʱ"+"=========ǰкţ"+(i+1)+"ǰеֱ"+diam); + //ȡ11еֵ׼ʱ + this.bzgsTextField.setText(row.getCell(10).getStringCellValue()); + //ȡ12еֵʱ + this.fzgsTextField.setText(row.getCell(11).getStringCellValue()); + break; + } + } + workbook.close(); + }else { + System.out.println("ȡݼļʧܣ"); + } + + } + } + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + } + + /** + * 㸨ʱ + * @return + */ + private String calculateAssistTime() { + String result = null; + double kzljsNum = Double.parseDouble(this.kzljsTextField.getText()); + if (kzljsNum > 0){ + double auxiliaryTimeNum = Double.parseDouble(this.auxiliaryTime); + double fixedTimeNum = Double.parseDouble(this.fixedTime); + + double resultNum = Math.round((auxiliaryTimeNum + fixedTimeNum) / kzljsNum / 60 * 100.0) / 100.0; + System.out.println("ʱ䣺"+auxiliaryTimeNum+"̶ʱ䣺"+fixedTimeNum+""+kzljsNum); + result = String.valueOf(resultNum); + + } + return result; + + } + + /** + * ׼ʱ + * @return + */ + private String calculateStandardTime() { + String result = null; + double kzljsNum = Double.parseDouble(this.kzljsTextField.getText()); + if (kzljsNum > 0){ + System.out.println("=========>ȡиʱ䣺"+this.cuttingTime); + double cuttingTimeNum = Double.parseDouble(this.cuttingTime); + + double resultNum = Math.round((cuttingTimeNum / kzljsNum / 60) * 100.0) / 100.0; + System.out.println("иʱ䣺"+cuttingTimeNum+""+kzljsNum); + result = String.valueOf(resultNum); + } + return result; + } + + /** + * ȡܶȺͽ + * @throws TCException + */ + private void getDensityAndCrossSection() throws TCException { + System.out.println("=========>ʼȡܶȺͺ棺getDensityAndCrossSection"); + +// 1.ȡǰѡMEOPBOM + TCComponentMEOP meopItem = (TCComponentMEOP) meop.getItem(); + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) this.session.getTypeComponent("BOMWindow"); + TCComponentBOMWindow view = winType.create(null); + TCComponentBOMLine bomLine = view.setWindowTopLine(meopItem, meop, null, null); +// 2.BOMУݡ񡱺͡ϡҪΨһԭ϶ + throughBomline(bomLine); + + view.close(); + } + + /** + * ѭǰbomline¹УȡҪbomӦԭ϶󣬲ȡӦܶȺͺ + * @param topBomLine ǰBOM + */ + private void throughBomline(TCComponentBOMLine topBomLine) throws TCException{ + // 3.ȡԭ϶ܶȺͺ + boolean hasChildren = topBomLine.hasChildren(); + if (hasChildren) { + AIFComponentContext[] childrens = topBomLine.getChildren(); + for (AIFComponentContext children : childrens) { + TCComponentBOMLine bomLine = (TCComponentBOMLine) children.getComponent(); + //ȡǰbomͣͶϣ򵽵ǰbomӦԭ϶ + String propertyValue = bomLine.getProperty("bl_occ_type"); + if ("Ͷ".equals(propertyValue)) { + //ͨԭ϶ȡܶȺͺ + this.rawMaterialRevision = bomLine.getItemRevision(); + String densityString = rawMaterialRevision.getProperty("ly6_density"); + String crossSectionString = rawMaterialRevision.getProperty("ly6_crossSection"); + System.out.println("==========ɹȡõǰԭ϶Ӧܶȣ"+densityString+"棺"+crossSectionString); + + this.density = densityString != null ? densityString : ""; + this.crossSection = crossSectionString != null ? crossSectionString : ""; + System.out.println("000"); + break; + } + throughBomline(bomLine); + } + } + + } + + + /** + * 㵥 + * @return + * @throws TCException + */ + private String calculateWeight(){ + System.out.println("calculateWeight"); + //ͨȡǰѡжbom¹ԭ϶󣬻ȡܶȺͺ + try { + getDensityAndCrossSection(); + } catch (TCException e) { + e.printStackTrace(); + } + //ȡܶȡȣ㵥 + double crossSectionNum = Double.parseDouble(this.crossSection); + double densityNum = 0; + if (this.density.contentEquals("")) { + densityNum = 0; + }else { + densityNum = Double.parseDouble(this.density); + } + double siglengthNum = Double.parseDouble(this.djcdTextField.getText()); + double result = crossSectionNum * densityNum * siglengthNum; + System.out.println("棺"+crossSectionNum+"ܶȣ"+densityNum+"ȣ"+siglengthNum); + double kg = result / 10000.0; + String formattedKg = String.format("%.2f", kg); + return formattedKg; + } + + /** + * дԵӦĶ + * @throws TCException + */ + private void saveProperty() throws TCException { + try { + meop.setProperty("ly6_specifications", this.ggTextField.getText() == null ? "" : this.ggTextField.getText()); +// rawMaterialRevision.setProperty("ly6_specifications", this.ggTextField.getText() == null ? "" : this.ggTextField.getText()); + meop.setProperty("ly6_totalLenght", this.zcTextField.getText() == null ? "" : this.zcTextField.getText()); + meop.setProperty("ly6_singleLength", this.djcdTextField.getText() == null ? "" : this.djcdTextField.getText()); + meop.setProperty("ly6_weight", this.djzlTextField.getText() == null ? "" : this.djzlTextField.getText()); + meop.setProperty("ly6_standardTime", this.bzgsTextField.getText() == null ? "" : this.bzgsTextField.getText()); + meop.setProperty("ly6_auxiliaryTime", this.fzgsTextField.getText() == null ? "" : this.fzgsTextField.getText()); +// rawMaterialRevision.setProperty("ly6_material", this.clphTextField.getText() == null ? "" : this.clphTextField.getText()); + meop.setProperty("ly6_brandNum", this.clphTextField.getText() == null ? "" : this.clphTextField.getText()); + meop.setProperty("ly6_outlineDiameter", this.zjdTextField.getText() == null ? "" : this.zjdTextField.getText()); + meop.setProperty("ly6_outlineLength", this.lkcTextField.getText() == null ? "" : this.lkcTextField.getText()); + meop.setProperty("ly6_cuttingLength", this.qdycdTextField.getText() == null ? "" : this.qdycdTextField.getText()); + meop.setProperty("ly6_transverseLength", this.cdmycdTextField.getText()== null ? "" : this.cdmycdTextField.getText()); + meop.setProperty("ly6_colletLength", this.jtycdTextField.getText() == null ? "" : this.jtycdTextField.getText()); + meop.setProperty("ly6_manufacturableQuantity", this.kzljsTextField.getText() == null ? "" : this.kzljsTextField.getText()); + }catch (Exception e){ + System.out.println(e.getMessage()); + e.printStackTrace(); + } + } + + /** + * MǷѾԭ + * @throws TCException + */ + private void checkMaterial() throws TCException { + try { + System.out.println("ʼMµĹ"); + boolean isGZ=false; + TCComponent[] whereUsed = meop.whereUsed((short) 0); + for (TCComponent tcComponent : whereUsed) { + //ȡǰĸ-tcComponent + String mepRevisionType = tcComponent.getStringProperty("object_type"); + //ȡѡеĹնͣƥ + TCSession session = (TCSession) this.application.getSession(); + TCPreferenceService preferenceService = session.getPreferenceService(); + //ѡ-C8MyPreference,ȡѡֵ + String value = preferenceService.getStringValue("LY6_MEPType"); + String[] strings = value.split(","); + for (int i = 0; i < whereUsed.length; i++) { + //նƥ䣬Уԭ϶ȶ + if (strings[i].equals(mepRevisionType)) { + System.out.println("========>ƥɹ"); + if (tcComponent instanceof TCComponentItemRevision) { + System.out.println("====>ȡĹն"+tcComponent.getObjectString()); + TCComponentItemRevision mepRevision = (TCComponentItemRevision) tcComponent; + //ȡնµ/:relatedRevision\\relatedItem + TCComponent relatedComponent = mepRevision.getRelatedComponent("IMAN_METarget"); + TCComponentItemRevision relatedRevision = (TCComponentItemRevision) relatedComponent; + TCComponentItem relatedItem = relatedRevision.getItem(); + + //鵱ǰ϶Ƿԭ϶ + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + TCComponentBOMWindow view = winType.create(null); + //ȡ϶/Ӧbomline + TCComponentBOMLine bomLine = view.setWindowTopLine(relatedItem, relatedRevision, null, null); + //bomlineǷԭ϶ + if (bomLine.hasChildren()) { + AIFComponentContext[] childrens = bomLine.getChildren(); + for(AIFComponentContext children:childrens) { + TCComponentBOMLine childrenBomLine = (TCComponentBOMLine) children.getComponent(); + TCComponentItemRevision itemRevision = childrenBomLine.getItemRevision(); + String uidTag = itemRevision.getUid(); + String materialRevUid = this.rawMaterialRevision.getUid(); + if (uidTag.equals(materialRevUid)) { + System.out.println("M϶Ѿԭ϶󡤡"); + //M϶¹ԭ϶ + isGZ = true; + break; + } + } + } + //M϶ûйԭ϶ + if (!isGZ) { + System.out.println("M϶ûйԭ϶󣬿ʼء"); + view.lock(); + TCComponentItem materialItem = this.rawMaterialRevision.getItem(); + bomLine.add(materialItem,this.rawMaterialRevision,null,false,""); + bomLine.save(); + view.unlock(); + } + // BOMWindowرգ + view.close(); + }else { + System.out.println("ǰ汾쳣"); + } + break; + } + } + } + }catch (Exception e){ + e.printStackTrace(); + System.out.println(e.getMessage()); + } + } + + /** + * ¼ťĵ¼ + */ + @Override + public void actionPerformed(ActionEvent e) { + Object sourceObject = e.getSource(); + //㡱ť + if(sourceObject.equals(this.calculateButton)) { + try { + //ȼ + this.zcTextField.setText(calculateTotalLength()); + this.djcdTextField.setText(calculateSingleLength()); + // + this.djzlTextField.setText(calculateWeight()); + // ʱ + getDataset(); +// this.bzgsTextField.setText(calculateStandardTime()); +// this.fzgsTextField.setText(calculateAssistTime()); + }catch (Exception e1){ + MessageBox.post("ʧܣԻֶά", "ʾ", MessageBox.ERROR); + e1.printStackTrace(); + } + } else if (sourceObject.equals(this.syncButton)) { + //ͬťԷд + try { + saveProperty(); + //M + checkMaterial(); + MessageBox.post("ͬɹ", "", MessageBox.INFORMATION); + + this.setVisible(false); + this.dispose(); + } catch (TCException e1) { + e1.printStackTrace(); + } + }else { + //ȡť + //ر + this.setVisible(false); + //ͷ + this.dispose(); + } + } +} diff --git a/src/com/langtech/plm/project/CalculateHandler.java b/src/com/langtech/plm/project/CalculateHandler.java new file mode 100644 index 0000000..891d273 --- /dev/null +++ b/src/com/langtech/plm/project/CalculateHandler.java @@ -0,0 +1,121 @@ +package com.langtech.plm.project; + +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.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentMEOP; +import com.teamcenter.rac.kernel.TCComponentMEOPRevision; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +import java.sql.SQLOutput; +import java.util.ArrayList; +import java.util.List; + +public class CalculateHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + + try { + new Thread(){ + @Override + public void run() { +// TODO 1.ȡѡжͺ͹ + //ȡѡжƴַ + InterfaceAIFComponent selectComponent = app.getTargetContext().getComponent(); +// ȡѡжͺ + String type = selectComponent.getType(); + String name; + boolean existTag = false; + InterfaceAIFComponent[] resultComponents = null; + System.out.println("ǰѡжtype"+type); + + try { + //TODO ȡѡжtypeMfg0BvrOperation˵ǹչµĶ󣬿ͨʵƣbl_item_item_idȡѡжIDԴ˻ø + if (type.equals("Mfg0BvrOperation")) { + List entryNames = new ArrayList(); + List entryValues = new ArrayList(); + String lzj_id = selectComponent.getProperty("bl_item_item_id"); + String lzj_rev = selectComponent.getProperty("bl_rev_item_revision_id"); + System.out.println("չѡжID="+lzj_id); + entryNames.add(" ID"); + entryNames.add("汾"); + entryValues.add(lzj_id); + entryValues.add(lzj_rev); + resultComponents = session.search( + "汾...", + entryNames.toArray(new String[entryNames.size()]), + entryValues.toArray(new String[entryNames.size()])); + if(resultComponents != null) { + type = resultComponents[0].getType(); + System.out.println("ȡ칤չ滮¶="+type); + + }else { + MessageBox.post("ûвѯ칤չ滮¶Ӧ","ѯ",MessageBox.INFORMATION); + } + } + + name = selectComponent.getProperty("object_name"); +// 2.ȡѡַ飬Ƚϣǰѡж+ƴַ + TCPreferenceService preferenceService = session.getPreferenceService(); + + //ѡ-C8MyPreference,ȡѡֵ + String[] preferenceValues = preferenceService.getStringValues("LY6_MEOPType"); + if (preferenceValues == null) { + MessageBox.post("ѡΪգѡ","ʾ",MessageBox.INFORMATION); + } + for (String string : preferenceValues){ + System.out.println("ѡLY6_MEOPTypeõϢstring"+string); + if (type.equals(string)){ + System.out.println("ǰѡжѡƥ䣺"+type+"==>"+string); + existTag = true; + break; + } + } + + if (!existTag){ + //3.ѡеֵƥ䣬򵯳ʾʾͲȷ + System.out.println("Ͳȷǰѡжtype="+type); + MessageBox.post("Ͳȷ","ʾ",MessageBox.INFORMATION); + }else { + System.out.println("ѡжƥ䣡"); + TCComponentMEOPRevision rev = null; + if(selectComponent.getType().equals("Mfg0BvrOperation")) { + rev = (TCComponentMEOPRevision)resultComponents[0]; + }else { + //жѡжitemǰ汾itemȡ°汾 + if (selectComponent instanceof TCComponentMEOP) { +// System.out.println("ǰѡжΪTCComponentMEOP"); + TCComponentMEOP meopType = (TCComponentMEOP) selectComponent; + rev = (TCComponentMEOPRevision) meopType.getLatestItemRevision(); + }else if (selectComponent instanceof TCComponentMEOPRevision) { +// System.out.println("ǰѡжΪTCComponentMEOPRevision"); + rev = (TCComponentMEOPRevision) selectComponent; + } + } +// System.out.println("========ѡеĶͣ"+type); + new CalculateDialog(app,rev); + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + }.start(); + } catch (Exception e) { + e.printStackTrace(); + } + + return null; + } + +} diff --git a/src/com/langtech/plm/synchronize/SynchronizeDialog.java b/src/com/langtech/plm/synchronize/SynchronizeDialog.java new file mode 100644 index 0000000..e6b9da6 --- /dev/null +++ b/src/com/langtech/plm/synchronize/SynchronizeDialog.java @@ -0,0 +1,840 @@ +package com.langtech.plm.synchronize; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.Map.Entry; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.border.EmptyBorder; +import javax.swing.table.DefaultTableModel; + +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class SynchronizeDialog extends JFrame implements ActionListener { + + private TCSession session; + protected DefaultTableModel tm_part; + private static ArrayList dateConnList = new ArrayList(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + private TCComponentItemRevision rev; + private JComboBox objectComboBox = new JComboBox(); + private JButton okButton = new JButton("ȷ"); + private JButton concelButton = new JButton("ȡ"); + private HashMap fieldMap = new HashMap(); + private String revType = ""; + HashMap objectMap = new HashMap(); + + public SynchronizeDialog(TCSession session, TCComponentItemRevision rev) { + // TODO Auto-generated constructor stub + this.session = session; + this.rev = rev; + initUI(); + } + + private void initUI() { + // TODO Auto-generated method stub + try { + this.setTitle("ͬ"); + this.setLayout(new BorderLayout()); + + JPanel topPanel = getTopPanel(); + + JPanel btnPanel = getBtnPanel(); + + this.add(topPanel, BorderLayout.NORTH); + // this.add(pane,BorderLayout.CENTER); + this.add(btnPanel, BorderLayout.SOUTH); + this.setPreferredSize(new Dimension(550, 200)); + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); // ȡĻߴ + int screenWidth = screenSize.width; // ȡĻ + int screenHeight = screenSize.height; // ȡĻ߶ + int x = (screenWidth - 550) / 2; // FrameϽx + int y = (screenHeight - 300) / 2; // FrameϽy + this.setLocation(x, y); // Frameλ + + // this.setLocationRelativeTo(null); + this.createActionEvent(); + this.pack(); + + // this.validate(); + this.setVisible(true); + +// this.setAlwaysOnTop(true); + + // ȡѡ + String[] relations = session.getPreferenceService().getStringValues("LY6_CopyAttributeRelation"); + String[] fields = session.getPreferenceService().getStringValues("LY6_CopyAttribute"); + if (relations == null || relations.length <= 0) { + MessageBox.post("LY6_CopyAttributeRelation", "ʾ", 2); + return; + } + + if (fields == null || fields.length <= 0) { + MessageBox.post("LY6_CopyAttribute", "ʾ", 2); + return; + } + + for (int i = 0; i < fields.length; i++) { + String[] split = fields[i].split("="); + fieldMap.put(split[0], split[1]); + } + + HashMap relationsMap = new HashMap(); + for (int i = 0; i < relations.length; i++) { + String[] split = relations[i].split("="); + relationsMap.put(split[0], split[1]); + } + // ȡ汾 + revType = rev.getStringProperty("object_type"); + String relation = relationsMap.get(revType); + if (relation == null || relation.isEmpty()) { + MessageBox.post("ѡδƥ䵽ϵ", "ʾ", 2); + return; + } + // ȡϵµĶ + if (relation.contains(",")) { + String[] split = relation.split(","); + for (int i = 0; i < split.length; i++) { + TCComponent[] components = rev.getRelatedComponents(split[i]); + for (int j = 0; j < components.length; j++) { + if (components[j] instanceof TCComponentItemRevision) { + TCComponentItemRevision relationRev = (TCComponentItemRevision) components[j]; + String object_string = relationRev.getStringProperty("object_string"); + String object_type = relationRev.getStringProperty("object_type"); + objectMap.put(object_string + "-" + object_type, relationRev); + } + } + } + } else { + TCComponent[] components = rev.getRelatedComponents(relation); + for (int j = 0; j < components.length; j++) { + if (components[j] instanceof TCComponentItemRevision) { + TCComponentItemRevision relationRev = (TCComponentItemRevision) components[j]; + String object_string = relationRev.getStringProperty("object_string"); + String object_type = relationRev.getStringProperty("object_type"); + objectMap.put(object_string + "-" + object_type, relationRev); + } + } + } + + // ֵ + for (Entry map : objectMap.entrySet()) { + objectComboBox.addItem(map.getKey()); + } + + } catch (Exception e) { + e.printStackTrace(); + return; + } + } + + // Ӽ + public void createActionEvent() { + + this.okButton.addActionListener(this); + this.concelButton.addActionListener(this); + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + + Object source = e.getSource(); + System.out.println("source==>+" + source); + if (this.okButton.equals(source)) { + // ȡѡĶ + + try { + String selectedItem = (String) objectComboBox.getSelectedItem(); + TCComponentItemRevision selectRev = objectMap.get(selectedItem); + String selectRevType = selectRev.getStringProperty("object_type"); + String field = fieldMap.get(revType + ":" + selectRevType); + // ȡ item form + TCComponentItem revItem = rev.getItem(); + TCComponentForm revForm = (TCComponentForm) rev.getReferenceListProperty("IMAN_master_form_rev")[0]; + + TCComponentItem selectRevItem = selectRev.getItem(); + TCComponentForm selectRevForm = (TCComponentForm) selectRev + .getReferenceListProperty("IMAN_master_form_rev")[0]; + + if (field == null || field.isEmpty()) { + field = fieldMap.get("ͨ"); + // + System.out.println("field==="+field); + if (field.contains(",")) {// жǷ + String[] split = field.split(","); + for (int i = 0; i < split.length; i++) { + String[] split2 = split[i].split(":"); + String[] selectSplit = split2[1].split("\\."); + System.out.println("selectSplit[0]==="+selectSplit[0]); + System.out.println("--------------------------------"); + if (selectSplit[0].equals("item")) { + String value = ""; + Date dateValue = null; + Double doubleValue = 0d; + if (selectSplit[2].equals("string") || selectSplit[2].equals("lov")) { + value = selectRevItem.getStringProperty(selectSplit[1]); + System.out.println("value===="+value); + } else if (selectSplit[2].contains("double")) { + String[] wsSplit = selectSplit[2].split("#"); + Double tempDoubleValue = selectRevItem.getDoubleProperty(selectSplit[1]); + doubleValue = truncateDouble(Integer.parseInt(wsSplit[1]),tempDoubleValue); + }else if (selectSplit[2].equals("date")) { + dateValue = selectRevItem.getDateProperty(selectSplit[1]); + } + + // ȡĿҪĸ + String[] targetSplit = split2[0].split("\\."); + if (targetSplit[0].equals("item")) { + if (targetSplit[2].equals("string") || targetSplit[2].equals("lov")) { + revItem.setProperty(targetSplit[1], value); + } else if (targetSplit[2].equals("date")) { + revItem.setDateProperty(targetSplit[1], dateValue); + }else if (targetSplit[2].contains("double")) { + revItem.setDoubleProperty(targetSplit[1], doubleValue); + } + + } else if (targetSplit[0].equals("rev")) { + if (targetSplit[2].equals("string") || targetSplit[2].equals("lov")) { + rev.setProperty(targetSplit[1], value); + } else if (targetSplit[2].equals("date")) { + rev.setDateProperty(targetSplit[1], dateValue); + }else if (targetSplit[2].contains("double")) { + rev.setDoubleProperty(targetSplit[1], doubleValue); + } + + } else if (targetSplit[0].equals("rm")) { + + if (targetSplit[2].equals("string") || targetSplit[2].equals("lov")) { + revForm.setProperty(targetSplit[1], value); + } else if (targetSplit[2].equals("date")) { + revForm.setDateProperty(targetSplit[1], dateValue); + }else if (targetSplit[2].contains("double")) { + revForm.setDoubleProperty(targetSplit[1], doubleValue); + } + } + }else if (selectSplit[0].equals("rev")) { + System.out.println("0000000000000000000000000"); + String value = ""; + Date dateValue = null; + Double doubleValue = 0d; + System.out.println("selectSplit[2]====================="+selectSplit[2]); + if (selectSplit[2].equals("string") || selectSplit[2].equals("lov")) { + value = selectRev.getStringProperty(selectSplit[1]); + } else if (selectSplit[2].equals("date")) { + dateValue = selectRev.getDateProperty(selectSplit[1]); + }else if (selectSplit[2].contains("double")) { + String[] wsSplit = selectSplit[2].split("#"); + System.out.println("1111111111111111111111"); + Double tempDoubleValue = selectRev.getDoubleProperty(selectSplit[1]); + doubleValue = truncateDouble(Integer.parseInt(wsSplit[1]),tempDoubleValue); + } + + // ȡĿҪĸ + String[] targetSplit = split2[0].split("\\."); + if (targetSplit[0].equals("item")) { + if (targetSplit[2].equals("string") || targetSplit[2].equals("lov")) { + revItem.setProperty(targetSplit[1], value); + } else if (targetSplit[2].equals("date")) { + revItem.setDateProperty(targetSplit[1], dateValue); + }else if (targetSplit[2].contains("double")) { + revItem.setDoubleProperty(targetSplit[1], doubleValue); + } + + } else if (targetSplit[0].equals("rev")) { + if (targetSplit[2].equals("string") || targetSplit[2].equals("lov")) { + rev.setProperty(targetSplit[1], value); + } else if (targetSplit[2].equals("date")) { + rev.setDateProperty(targetSplit[1], dateValue); + }else if (targetSplit[2].contains("double")) { + rev.setDoubleProperty(targetSplit[1], doubleValue); + } + + } else if (targetSplit[0].equals("rm")) { + + if (targetSplit[2].equals("string") || targetSplit[2].equals("lov")) { + revForm.setProperty(targetSplit[1], value); + } else if (targetSplit[2].equals("date")) { + revForm.setDateProperty(targetSplit[1], dateValue); + }else if (targetSplit[2].contains("double")) { + revForm.setDoubleProperty(targetSplit[1], doubleValue); + } + } + + } else if (selectSplit[0].equals("rm")) { + + String value = ""; + Date dateValue = null; + Double doubleValue = 0d; + if (selectSplit[2].equals("string") || selectSplit[2].equals("lov")) { + value = selectRevForm.getStringProperty(selectSplit[1]); + } else if (selectSplit[2].equals("date")) { + dateValue = selectRevForm.getDateProperty(selectSplit[1]); + }else if (selectSplit[2].contains("double")) { + String[] wsSplit = selectSplit[2].split("#"); + Double tempDoubleValue = selectRevForm.getDoubleProperty(selectSplit[1]); + doubleValue = truncateDouble(Integer.parseInt(wsSplit[1]),tempDoubleValue); + } + + // ȡĿҪĸ + String[] targetSplit = split2[0].split("\\."); + if (targetSplit[0].equals("item")) { + if (targetSplit[2].equals("string") || targetSplit[2].equals("lov")) { + revItem.setProperty(targetSplit[1], value); + } else if (targetSplit[2].equals("date")) { + revItem.setDateProperty(targetSplit[1], dateValue); + }else if (targetSplit[2].contains("double")) { + revItem.setDoubleProperty(targetSplit[1], doubleValue); + } + + } else if (targetSplit[0].equals("rev")) { + if (targetSplit[2].equals("string") || targetSplit[2].equals("lov")) { + rev.setProperty(targetSplit[1], value); + } else if (targetSplit[2].equals("date")) { + rev.setDateProperty(targetSplit[1], dateValue); + }else if (targetSplit[2].contains("double")) { + rev.setDoubleProperty(targetSplit[1], doubleValue); + } + + } else if (targetSplit[0].equals("rm")) { + + if (targetSplit[2].equals("string") || targetSplit[2].equals("lov")) { + revForm.setProperty(targetSplit[1], value); + } else if (targetSplit[2].equals("date")) { + revForm.setDateProperty(targetSplit[1], dateValue); + }else if (targetSplit[2].contains("double")) { + revForm.setDoubleProperty(targetSplit[1], doubleValue); + } + } + + } + } + } else { + + String[] split2 = field.split(":"); + String[] selectSplit = split2[1].split("\\."); + System.out.println("selectSplit[0]==="+selectSplit[0]); + System.out.println("--------------------------------"); + if (selectSplit[0].equals("item")) { + String value = ""; + Date dateValue = null; + Double doubleValue = 0d; + if (selectSplit[2].equals("string") || selectSplit[2].equals("lov")) { + value = selectRevItem.getStringProperty(selectSplit[1]); + System.out.println("value===="+value); + } else if (selectSplit[2].contains("double")) { + String[] wsSplit = selectSplit[2].split("#"); + Double tempDoubleValue = selectRevItem.getDoubleProperty(selectSplit[1]); + doubleValue = truncateDouble(Integer.parseInt(wsSplit[1]),tempDoubleValue); + }else if (selectSplit[2].equals("date")) { + dateValue = selectRevItem.getDateProperty(selectSplit[1]); + } + + // ȡĿҪĸ + String[] targetSplit = split2[0].split("\\."); + if (targetSplit[0].equals("item")) { + if (targetSplit[2].equals("string") || targetSplit[2].equals("lov")) { + revItem.setProperty(targetSplit[1], value); + } else if (targetSplit[2].equals("date")) { + revItem.setDateProperty(targetSplit[1], dateValue); + }else if (targetSplit[2].contains("double")) { + revItem.setDoubleProperty(targetSplit[1], doubleValue); + } + + } else if (targetSplit[0].equals("rev")) { + if (targetSplit[2].equals("string") || targetSplit[2].equals("lov")) { + rev.setProperty(targetSplit[1], value); + } else if (targetSplit[2].equals("date")) { + rev.setDateProperty(targetSplit[1], dateValue); + }else if (targetSplit[2].contains("double")) { + rev.setDoubleProperty(targetSplit[1], doubleValue); + } + + } else if (targetSplit[0].equals("rm")) { + + if (targetSplit[2].equals("string") || targetSplit[2].equals("lov")) { + revForm.setProperty(targetSplit[1], value); + } else if (targetSplit[2].equals("date")) { + revForm.setDateProperty(targetSplit[1], dateValue); + }else if (targetSplit[2].contains("double")) { + revForm.setDoubleProperty(targetSplit[1], doubleValue); + } + } + }else if (selectSplit[0].equals("rev")) { + System.out.println("0000000000000000000000000"); + String value = ""; + Date dateValue = null; + Double doubleValue = 0d; + System.out.println("selectSplit[2]====================="+selectSplit[2]); + if (selectSplit[2].equals("string") || selectSplit[2].equals("lov")) { + value = selectRev.getStringProperty(selectSplit[1]); + } else if (selectSplit[2].equals("date")) { + dateValue = selectRev.getDateProperty(selectSplit[1]); + }else if (selectSplit[2].contains("double")) { + String[] wsSplit = selectSplit[2].split("#"); + System.out.println("1111111111111111111111"); + Double tempDoubleValue = selectRev.getDoubleProperty(selectSplit[1]); + doubleValue = truncateDouble(Integer.parseInt(wsSplit[1]),tempDoubleValue); + } + + // ȡĿҪĸ + String[] targetSplit = split2[0].split("\\."); + if (targetSplit[0].equals("item")) { + if (targetSplit[2].equals("string") || targetSplit[2].equals("lov")) { + revItem.setProperty(targetSplit[1], value); + } else if (targetSplit[2].equals("date")) { + revItem.setDateProperty(targetSplit[1], dateValue); + }else if (targetSplit[2].contains("double")) { + revItem.setDoubleProperty(targetSplit[1], doubleValue); + } + + } else if (targetSplit[0].equals("rev")) { + if (targetSplit[2].equals("string") || targetSplit[2].equals("lov")) { + rev.setProperty(targetSplit[1], value); + } else if (targetSplit[2].equals("date")) { + rev.setDateProperty(targetSplit[1], dateValue); + }else if (targetSplit[2].contains("double")) { + rev.setDoubleProperty(targetSplit[1], doubleValue); + } + + } else if (targetSplit[0].equals("rm")) { + + if (targetSplit[2].equals("string") || targetSplit[2].equals("lov")) { + revForm.setProperty(targetSplit[1], value); + } else if (targetSplit[2].equals("date")) { + revForm.setDateProperty(targetSplit[1], dateValue); + }else if (targetSplit[2].contains("double")) { + revForm.setDoubleProperty(targetSplit[1], doubleValue); + } + } + + } else if (selectSplit[0].equals("rm")) { + + String value = ""; + Date dateValue = null; + Double doubleValue = 0d; + if (selectSplit[2].equals("string") || selectSplit[2].equals("lov")) { + value = selectRevForm.getStringProperty(selectSplit[1]); + } else if (selectSplit[2].equals("date")) { + dateValue = selectRevForm.getDateProperty(selectSplit[1]); + }else if (selectSplit[2].contains("double")) { + String[] wsSplit = selectSplit[2].split("#"); + Double tempDoubleValue = selectRevForm.getDoubleProperty(selectSplit[1]); + doubleValue = truncateDouble(Integer.parseInt(wsSplit[1]),tempDoubleValue); + } + + // ȡĿҪĸ + String[] targetSplit = split2[0].split("\\."); + if (targetSplit[0].equals("item")) { + if (targetSplit[2].equals("string") || targetSplit[2].equals("lov")) { + revItem.setProperty(targetSplit[1], value); + } else if (targetSplit[2].equals("date")) { + revItem.setDateProperty(targetSplit[1], dateValue); + }else if (targetSplit[2].contains("double")) { + revItem.setDoubleProperty(targetSplit[1], doubleValue); + } + + } else if (targetSplit[0].equals("rev")) { + if (targetSplit[2].equals("string") || targetSplit[2].equals("lov")) { + rev.setProperty(targetSplit[1], value); + } else if (targetSplit[2].equals("date")) { + rev.setDateProperty(targetSplit[1], dateValue); + }else if (targetSplit[2].contains("double")) { + rev.setDoubleProperty(targetSplit[1], doubleValue); + } + + } else if (targetSplit[0].equals("rm")) { + + if (targetSplit[2].equals("string") || targetSplit[2].equals("lov")) { + revForm.setProperty(targetSplit[1], value); + } else if (targetSplit[2].equals("date")) { + revForm.setDateProperty(targetSplit[1], dateValue); + }else if (targetSplit[2].contains("double")) { + revForm.setDoubleProperty(targetSplit[1], doubleValue); + } + } + + } + + + } + } else { + // + System.out.println("field==="+field); + if (field.contains(",")) {// жǷ + String[] split = field.split(","); + for (int i = 0; i < split.length; i++) { + String[] split2 = split[i].split(":"); + String[] selectSplit = split2[1].split("\\."); + System.out.println("selectSplit[0]==="+selectSplit[0]); + System.out.println("--------------------------------"); + if (selectSplit[0].equals("item")) { + String value = ""; + Date dateValue = null; + Double doubleValue = 0d; + if (selectSplit[2].equals("string") || selectSplit[2].equals("lov")) { + value = selectRevItem.getStringProperty(selectSplit[1]); + System.out.println("value===="+value); + } else if (selectSplit[2].contains("double")) { + String[] wsSplit = selectSplit[2].split("#"); + Double tempDoubleValue = selectRevItem.getDoubleProperty(selectSplit[1]); + doubleValue = truncateDouble(Integer.parseInt(wsSplit[1]),tempDoubleValue); + }else if (selectSplit[2].equals("date")) { + dateValue = selectRevItem.getDateProperty(selectSplit[1]); + } + + // ȡĿҪĸ + String[] targetSplit = split2[0].split("\\."); + if (targetSplit[0].equals("item")) { + if (targetSplit[2].equals("string") || targetSplit[2].equals("lov")) { + revItem.setProperty(targetSplit[1], value); + } else if (targetSplit[2].equals("date")) { + revItem.setDateProperty(targetSplit[1], dateValue); + }else if (targetSplit[2].contains("double")) { + revItem.setDoubleProperty(targetSplit[1], doubleValue); + } + + } else if (targetSplit[0].equals("rev")) { + if (targetSplit[2].equals("string") || targetSplit[2].equals("lov")) { + rev.setProperty(targetSplit[1], value); + } else if (targetSplit[2].equals("date")) { + rev.setDateProperty(targetSplit[1], dateValue); + }else if (targetSplit[2].contains("double")) { + rev.setDoubleProperty(targetSplit[1], doubleValue); + } + + } else if (targetSplit[0].equals("rm")) { + + if (targetSplit[2].equals("string") || targetSplit[2].equals("lov")) { + revForm.setProperty(targetSplit[1], value); + } else if (targetSplit[2].equals("date")) { + revForm.setDateProperty(targetSplit[1], dateValue); + }else if (targetSplit[2].contains("double")) { + revForm.setDoubleProperty(targetSplit[1], doubleValue); + } + } + }else if (selectSplit[0].equals("rev")) { + System.out.println("0000000000000000000000000"); + String value = ""; + Date dateValue = null; + Double doubleValue = 0d; + System.out.println("selectSplit[2]====================="+selectSplit[2]); + if (selectSplit[2].equals("string") || selectSplit[2].equals("lov")) { + value = selectRev.getStringProperty(selectSplit[1]); + } else if (selectSplit[2].equals("date")) { + dateValue = selectRev.getDateProperty(selectSplit[1]); + }else if (selectSplit[2].contains("double")) { + String[] wsSplit = selectSplit[2].split("#"); + System.out.println("1111111111111111111111"); + Double tempDoubleValue = selectRev.getDoubleProperty(selectSplit[1]); + doubleValue = truncateDouble(Integer.parseInt(wsSplit[1]),tempDoubleValue); + } + + // ȡĿҪĸ + String[] targetSplit = split2[0].split("\\."); + if (targetSplit[0].equals("item")) { + if (targetSplit[2].equals("string") || targetSplit[2].equals("lov")) { + revItem.setProperty(targetSplit[1], value); + } else if (targetSplit[2].equals("date")) { + revItem.setDateProperty(targetSplit[1], dateValue); + }else if (targetSplit[2].contains("double")) { + revItem.setDoubleProperty(targetSplit[1], doubleValue); + } + + } else if (targetSplit[0].equals("rev")) { + if (targetSplit[2].equals("string") || targetSplit[2].equals("lov")) { + rev.setProperty(targetSplit[1], value); + } else if (targetSplit[2].equals("date")) { + rev.setDateProperty(targetSplit[1], dateValue); + }else if (targetSplit[2].contains("double")) { + rev.setDoubleProperty(targetSplit[1], doubleValue); + } + + } else if (targetSplit[0].equals("rm")) { + + if (targetSplit[2].equals("string") || targetSplit[2].equals("lov")) { + revForm.setProperty(targetSplit[1], value); + } else if (targetSplit[2].equals("date")) { + revForm.setDateProperty(targetSplit[1], dateValue); + }else if (targetSplit[2].contains("double")) { + revForm.setDoubleProperty(targetSplit[1], doubleValue); + } + } + + } else if (selectSplit[0].equals("rm")) { + + String value = ""; + Date dateValue = null; + Double doubleValue = 0d; + if (selectSplit[2].equals("string") || selectSplit[2].equals("lov")) { + value = selectRevForm.getStringProperty(selectSplit[1]); + } else if (selectSplit[2].equals("date")) { + dateValue = selectRevForm.getDateProperty(selectSplit[1]); + }else if (selectSplit[2].contains("double")) { + String[] wsSplit = selectSplit[2].split("#"); + Double tempDoubleValue = selectRevForm.getDoubleProperty(selectSplit[1]); + doubleValue = truncateDouble(Integer.parseInt(wsSplit[1]),tempDoubleValue); + } + + // ȡĿҪĸ + String[] targetSplit = split2[0].split("\\."); + if (targetSplit[0].equals("item")) { + if (targetSplit[2].equals("string") || targetSplit[2].equals("lov")) { + revItem.setProperty(targetSplit[1], value); + } else if (targetSplit[2].equals("date")) { + revItem.setDateProperty(targetSplit[1], dateValue); + }else if (targetSplit[2].contains("double")) { + revItem.setDoubleProperty(targetSplit[1], doubleValue); + } + + } else if (targetSplit[0].equals("rev")) { + if (targetSplit[2].equals("string") || targetSplit[2].equals("lov")) { + rev.setProperty(targetSplit[1], value); + } else if (targetSplit[2].equals("date")) { + rev.setDateProperty(targetSplit[1], dateValue); + }else if (targetSplit[2].contains("double")) { + rev.setDoubleProperty(targetSplit[1], doubleValue); + } + + } else if (targetSplit[0].equals("rm")) { + + if (targetSplit[2].equals("string") || targetSplit[2].equals("lov")) { + revForm.setProperty(targetSplit[1], value); + } else if (targetSplit[2].equals("date")) { + revForm.setDateProperty(targetSplit[1], dateValue); + }else if (targetSplit[2].contains("double")) { + revForm.setDoubleProperty(targetSplit[1], doubleValue); + } + } + + } + } + } else { + + String[] split2 = field.split(":"); + String[] selectSplit = split2[1].split("\\."); + System.out.println("selectSplit[0]==="+selectSplit[0]); + System.out.println("--------------------------------"); + if (selectSplit[0].equals("item")) { + String value = ""; + Date dateValue = null; + Double doubleValue = 0d; + if (selectSplit[2].equals("string") || selectSplit[2].equals("lov")) { + value = selectRevItem.getStringProperty(selectSplit[1]); + System.out.println("value===="+value); + } else if (selectSplit[2].contains("double")) { + String[] wsSplit = selectSplit[2].split("#"); + Double tempDoubleValue = selectRevItem.getDoubleProperty(selectSplit[1]); + doubleValue = truncateDouble(Integer.parseInt(wsSplit[1]),tempDoubleValue); + }else if (selectSplit[2].equals("date")) { + dateValue = selectRevItem.getDateProperty(selectSplit[1]); + } + + // ȡĿҪĸ + String[] targetSplit = split2[0].split("\\."); + if (targetSplit[0].equals("item")) { + if (targetSplit[2].equals("string") || targetSplit[2].equals("lov")) { + revItem.setProperty(targetSplit[1], value); + } else if (targetSplit[2].equals("date")) { + revItem.setDateProperty(targetSplit[1], dateValue); + }else if (targetSplit[2].contains("double")) { + revItem.setDoubleProperty(targetSplit[1], doubleValue); + } + + } else if (targetSplit[0].equals("rev")) { + if (targetSplit[2].equals("string") || targetSplit[2].equals("lov")) { + rev.setProperty(targetSplit[1], value); + } else if (targetSplit[2].equals("date")) { + rev.setDateProperty(targetSplit[1], dateValue); + }else if (targetSplit[2].contains("double")) { + rev.setDoubleProperty(targetSplit[1], doubleValue); + } + + } else if (targetSplit[0].equals("rm")) { + + if (targetSplit[2].equals("string") || targetSplit[2].equals("lov")) { + revForm.setProperty(targetSplit[1], value); + } else if (targetSplit[2].equals("date")) { + revForm.setDateProperty(targetSplit[1], dateValue); + }else if (targetSplit[2].contains("double")) { + revForm.setDoubleProperty(targetSplit[1], doubleValue); + } + } + }else if (selectSplit[0].equals("rev")) { + System.out.println("0000000000000000000000000"); + String value = ""; + Date dateValue = null; + Double doubleValue = 0d; + System.out.println("selectSplit[2]====================="+selectSplit[2]); + if (selectSplit[2].equals("string") || selectSplit[2].equals("lov")) { + value = selectRev.getStringProperty(selectSplit[1]); + } else if (selectSplit[2].equals("date")) { + dateValue = selectRev.getDateProperty(selectSplit[1]); + }else if (selectSplit[2].contains("double")) { + String[] wsSplit = selectSplit[2].split("#"); + System.out.println("1111111111111111111111"); + Double tempDoubleValue = selectRev.getDoubleProperty(selectSplit[1]); + doubleValue = truncateDouble(Integer.parseInt(wsSplit[1]),tempDoubleValue); + } + + // ȡĿҪĸ + String[] targetSplit = split2[0].split("\\."); + if (targetSplit[0].equals("item")) { + if (targetSplit[2].equals("string") || targetSplit[2].equals("lov")) { + revItem.setProperty(targetSplit[1], value); + } else if (targetSplit[2].equals("date")) { + revItem.setDateProperty(targetSplit[1], dateValue); + }else if (targetSplit[2].contains("double")) { + revItem.setDoubleProperty(targetSplit[1], doubleValue); + } + + } else if (targetSplit[0].equals("rev")) { + if (targetSplit[2].equals("string") || targetSplit[2].equals("lov")) { + rev.setProperty(targetSplit[1], value); + } else if (targetSplit[2].equals("date")) { + rev.setDateProperty(targetSplit[1], dateValue); + }else if (targetSplit[2].contains("double")) { + rev.setDoubleProperty(targetSplit[1], doubleValue); + } + + } else if (targetSplit[0].equals("rm")) { + + if (targetSplit[2].equals("string") || targetSplit[2].equals("lov")) { + revForm.setProperty(targetSplit[1], value); + } else if (targetSplit[2].equals("date")) { + revForm.setDateProperty(targetSplit[1], dateValue); + }else if (targetSplit[2].contains("double")) { + revForm.setDoubleProperty(targetSplit[1], doubleValue); + } + } + + } else if (selectSplit[0].equals("rm")) { + + String value = ""; + Date dateValue = null; + Double doubleValue = 0d; + if (selectSplit[2].equals("string") || selectSplit[2].equals("lov")) { + value = selectRevForm.getStringProperty(selectSplit[1]); + } else if (selectSplit[2].equals("date")) { + dateValue = selectRevForm.getDateProperty(selectSplit[1]); + }else if (selectSplit[2].contains("double")) { + String[] wsSplit = selectSplit[2].split("#"); + Double tempDoubleValue = selectRevForm.getDoubleProperty(selectSplit[1]); + doubleValue = truncateDouble(Integer.parseInt(wsSplit[1]),tempDoubleValue); + } + + // ȡĿҪĸ + String[] targetSplit = split2[0].split("\\."); + if (targetSplit[0].equals("item")) { + if (targetSplit[2].equals("string") || targetSplit[2].equals("lov")) { + revItem.setProperty(targetSplit[1], value); + } else if (targetSplit[2].equals("date")) { + revItem.setDateProperty(targetSplit[1], dateValue); + }else if (targetSplit[2].contains("double")) { + revItem.setDoubleProperty(targetSplit[1], doubleValue); + } + + } else if (targetSplit[0].equals("rev")) { + if (targetSplit[2].equals("string") || targetSplit[2].equals("lov")) { + rev.setProperty(targetSplit[1], value); + } else if (targetSplit[2].equals("date")) { + rev.setDateProperty(targetSplit[1], dateValue); + }else if (targetSplit[2].contains("double")) { + rev.setDoubleProperty(targetSplit[1], doubleValue); + } + + } else if (targetSplit[0].equals("rm")) { + + if (targetSplit[2].equals("string") || targetSplit[2].equals("lov")) { + revForm.setProperty(targetSplit[1], value); + } else if (targetSplit[2].equals("date")) { + revForm.setDateProperty(targetSplit[1], dateValue); + }else if (targetSplit[2].contains("double")) { + revForm.setDoubleProperty(targetSplit[1], doubleValue); + } + } + + } + + + } + } + MessageBox.post("޸ijɹ", "ʾ", 2); + this.dispose(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + } else if (this.concelButton.equals(source)) { + this.dispose(); + } + + } + + private JPanel getBtnPanel() { + JPanel topPanel = new JPanel(); + topPanel.setLayout(new PropertyLayout()); + topPanel.add("1.1.center", new JLabel("")); + topPanel.add("2.1.center", new JLabel(" ")); + topPanel.add("2.2.center", okButton); + topPanel.add("2.3.center", new JLabel("")); + topPanel.add("2.4.center", concelButton); + + return topPanel; + } + + // ѯ + private JPanel getTopPanel() { + // TODO Auto-generated method stub + JPanel topPanel = new JPanel(); + topPanel.setLayout(new PropertyLayout()); + topPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); + + topPanel.add("1.1.left.center", new JLabel("")); + topPanel.add("2.1.left.center", new JLabel("")); + topPanel.add("3.1.left.center", new JLabel("")); + topPanel.add("4.1.left.center", new JLabel("")); + topPanel.add("5.1.left.center", new JLabel("")); + topPanel.add("6.1.left.center", new JLabel("")); + topPanel.add("7.1.left.center", new JLabel("ѡԴ")); + topPanel.add("7.2.left.center", objectComboBox); + + return topPanel; + } + + public double truncateDouble(int scale,double value) { + // ʹ BigDecimal оȷ + System.out.println("value========"+value); + System.out.println("scale=========="+scale); + BigDecimal bd = new BigDecimal(Double.toString(value)); + + // Сλʹ RoundingMode.DOWN нض + bd = bd.setScale(scale, RoundingMode.DOWN); + + // ظʽ double ֵ + System.out.println("bd.doubleValue()============"+bd.doubleValue()); + return bd.doubleValue(); + } + +} diff --git a/src/com/langtech/plm/synchronize/SynchronizeHandler.java b/src/com/langtech/plm/synchronize/SynchronizeHandler.java new file mode 100644 index 0000000..475f696 --- /dev/null +++ b/src/com/langtech/plm/synchronize/SynchronizeHandler.java @@ -0,0 +1,53 @@ +package com.langtech.plm.synchronize; + +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.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class SynchronizeHandler extends AbstractHandler{ + + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + try { + + new Thread() { + @Override + public void run() { + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + if(targetComponent instanceof TCComponentItemRevision) { + try { + TCComponentItemRevision rev = (TCComponentItemRevision)targetComponent; + new SynchronizeDialog(session,rev); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }else { + MessageBox.post("ѡ汾","ʾ",2); + return; + } + + + } + }.start(); + + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + return null; + } + + +} diff --git a/src/com/langtech/plm/template/TemplateDialog.java b/src/com/langtech/plm/template/TemplateDialog.java new file mode 100644 index 0000000..e122a09 --- /dev/null +++ b/src/com/langtech/plm/template/TemplateDialog.java @@ -0,0 +1,270 @@ +package com.langtech.plm.template; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.Map.Entry; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.border.EmptyBorder; +import javax.swing.table.DefaultTableModel; + +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.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +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 TemplateDialog extends JFrame implements ActionListener { + + private TCSession session; + protected DefaultTableModel tm_part; + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + private TCComponentItemRevision rev; + private JComboBox company = new JComboBox(); + private JComboBox template = new JComboBox(); + private JButton okButton = new JButton("ȷ"); + private JButton concelButton = new JButton("ȡ"); + private HashMap map = new HashMap(); + HashMap objectMap = new HashMap(); + private String type; + + public TemplateDialog(TCSession session, TCComponentItemRevision rev, String type) throws TCException { + // TODO Auto-generated constructor stub + this.session = session; + this.rev = rev; + this.type = type; + initUI(); + } + + private void initUI() { + // TODO Auto-generated method stub + try { + company.setPreferredSize(new Dimension(200, 30)); + template.setPreferredSize(new Dimension(200, 30)); + this.setTitle("ģ"); + this.setLayout(new BorderLayout()); + + JPanel topPanel = getTopPanel(); + + JPanel btnPanel = getBtnPanel(); + + this.add(topPanel, BorderLayout.NORTH); + // this.add(pane,BorderLayout.CENTER); + this.add(btnPanel, BorderLayout.SOUTH); + this.setPreferredSize(new Dimension(450, 200)); + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); // ȡĻߴ + int screenWidth = screenSize.width; // ȡĻ + int screenHeight = screenSize.height; // ȡĻ߶ + int x = (screenWidth - 450) / 2; // FrameϽx + int y = (screenHeight - 200) / 2; // FrameϽy + this.setLocation(x, y); // Frameλ + + // this.setLocationRelativeTo(null); + this.createActionEvent(); + this.pack(); + + // this.validate(); + this.setVisible(true); + +// this.setAlwaysOnTop(true); + + String[] pref = session.getPreferenceService().getStringValues("LY6_MEOP_TemplateType"); + for (int i = 0; i < pref.length; i++) { + + if (pref[i].contains(type)) { + System.out.println("pref[i]======="+pref[i]+"type========="+type); + String[] split10 = pref[i].split("\\|"); + System.out.println("split10========"+split10.length); + if (split10.length == 2) { + String[] split11 = split10[1].split(";"); + System.out.println("split11==============="+split11.length); + for (int j = 0; j < split11.length; j++) { + String[] split = split11[j].split(":"); + System.out.println("split=============="+split.length); + company.addItem(split[0]); + map.put(split[0], split[1]); + } + } + } + + } + + String mrselectitem = (String) company.getSelectedItem(); + String mrValue = map.get(mrselectitem); + String[] split = mrValue.split(","); + for (int i = 0; i < split.length; i++) { + template.addItem(split[i]); + } + + // ֵ + company.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + if (e.getStateChange() == ItemEvent.SELECTED) { + template.removeAllItems(); + String selectedItem = (String) company.getSelectedItem(); + System.out.println("Selected Item: " + selectedItem); + // ִ + String value = map.get(selectedItem); + String[] split = value.split(","); + for (int i = 0; i < split.length; i++) { + template.addItem(split[i]); + } + } + } + }); + + } catch (Exception e) { + e.printStackTrace(); + return; + } + } + + // Ӽ + public void createActionEvent() { + + this.okButton.addActionListener(this); + this.concelButton.addActionListener(this); + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + + Object source = e.getSource(); + System.out.println("source==>+" + source); + if (this.okButton.equals(source)) { + String templateString = (String) template.getSelectedItem(); + String companyString = (String) company.getSelectedItem(); + System.out.println("templateString===" + templateString); + System.out.println("companyString===" + companyString); + if (companyString.isEmpty()) { + MessageBox.post("ѡ˾", "ʾ ", MessageBox.INFORMATION); + return; + } + + if (templateString.isEmpty()) { + MessageBox.post("ѡģ壡", "ʾ ", MessageBox.INFORMATION); + return; + } + + // òѯȡģdwgݼ + try { + TCComponent[] items = session.search("...", new String[] { " ID" }, + new String[] { templateString }); + System.out.println("items.length====" + items.length); + TCComponentItem item = null; + + if (items.length > 0) { + item = (TCComponentItem) items[0]; + } + TCComponentItemRevision latestItemRevision = item.getLatestItemRevision(); + TCComponent[] relatedComponent = latestItemRevision.getRelatedComponents("IMAN_specification"); + System.out.println("relatedComponent========" + relatedComponent.length); + String name = rev.getStringProperty("item_id")+"_"+rev.getStringProperty("object_name")+"_.dwg"; + System.out.println("name================"+name); + for (int i = 0; i < relatedComponent.length; i++) { + if(relatedComponent[i] instanceof TCComponentDataset) { + TCComponentDataset dataset = (TCComponentDataset)relatedComponent[i]; +// TCComponentDataset saveAs = dataset.saveAs(name); +// +// TCComponent datasetref_c = dataset.getRelatedComponent("ref_list"); +// System.out.println("datasetref_c==============="+datasetref_c.getUid()); + TCComponent ref_c = dataset.getRelatedComponent("ref_list"); +// System.out.println("ref_c====="+ref_c.getUid()); + + File fmsFile = dataset.getTcFiles()[0].getFmsFile(); + System.out.println("fmsFile================"+fmsFile.getAbsolutePath()); + TCComponentDataset createDataset = createDataset(name,fmsFile.getAbsolutePath(),session,"LD6_CAD2","LD6_cad2"); + //String original_file_name = ref_c.getStringProperty("original_file_name"); + //String[] split = original_file_name.split("\\."); + createDataset.getRelatedComponent("ref_list").setProperty("original_file_name", name); + rev.add("IMAN_specification", createDataset); + } + + + } + MessageBox.post("ģɹ", "ʾ ", MessageBox.INFORMATION); + this.dispose(); + return; + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + // ݼ + } else if (this.concelButton.equals(source)) { + this.dispose(); + } + + } + + private JPanel getBtnPanel() { + JPanel topPanel = new JPanel(); + topPanel.setLayout(new PropertyLayout()); + topPanel.add("1.1.center", new JLabel("")); + topPanel.add("2.1.center", new JLabel(" ")); + topPanel.add("2.2.center", okButton); + topPanel.add("2.3.center", new JLabel("")); + topPanel.add("2.4.center", concelButton); + + return topPanel; + } + + // ѯ + private JPanel getTopPanel() { + // TODO Auto-generated method stub + JPanel topPanel = new JPanel(); + topPanel.setLayout(new PropertyLayout()); + topPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); + + topPanel.add("1.1.left.center", new JLabel("")); + topPanel.add("2.1.left.center", new JLabel("")); + topPanel.add("3.1.left.center", new JLabel("")); + topPanel.add("4.1.left.center", new JLabel(" ˾")); + topPanel.add("4.2.left.center", company); + + topPanel.add("5.1.left.center", new JLabel("")); + topPanel.add("6.1.left.center", new JLabel("")); + topPanel.add("7.1.left.center", new JLabel("")); + topPanel.add("8.1.left.center", new JLabel(" ģ壺")); + + topPanel.add("8.2.left.center", template); + + return topPanel; + } + + public static TCComponentDataset createDataset(String datasetName, String path, TCSession session, String type, + String ref) throws TCException { + TCComponentDatasetType tccomponentDatasetType = (TCComponentDatasetType) session.getTypeComponent("Dataset"); + TCComponentDataset tccomponentDataset = tccomponentDatasetType.create(datasetName, "", type); + tccomponentDataset.lock(); + tccomponentDataset.setFiles(new String[] { path }, new String[] { ref }); + tccomponentDataset.save(); + tccomponentDataset.unlock(); + return tccomponentDataset; + } +} diff --git a/src/com/langtech/plm/template/TemplateHandler.java b/src/com/langtech/plm/template/TemplateHandler.java new file mode 100644 index 0000000..9429d7e --- /dev/null +++ b/src/com/langtech/plm/template/TemplateHandler.java @@ -0,0 +1,115 @@ +package com.langtech.plm.template; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentSchedule; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TemplateHandler extends AbstractHandler{ + + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + try { + + + + new Thread() { + @Override + public void run() { + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + + String type = targetComponent.getType(); + System.out.println("type==========="+type); + if(targetComponent instanceof TCComponentItemRevision) { + try { + String[] pref = session.getPreferenceService().getStringValues("LY6_MEOP_TemplateObject"); + String types = ""; + if(pref.length > 0) { + types = pref[0]; + }else { + MessageBox.post("ѡLY6_MEOP_TemplateObject","ʾ",2); + return; + } + + TCComponentItemRevision rev = (TCComponentItemRevision)targetComponent; + String object_type = rev.getStringProperty("object_type"); + if(types.contains(object_type)) { + new TemplateDialog(session,rev,object_type); + }else { + MessageBox.post("ѡѡLY6_MEOP_TemplateObjectƥĶ","ʾ",2); + return; + } + + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }else if(type.equals("Mfg0BvrOperation")){ + TCComponent com = (TCComponent) targetComponent; + try { + TCComponent rev = com.getRelatedComponent("bl_line_object"); + if(rev instanceof TCComponentItemRevision) { + try { + String[] pref = session.getPreferenceService().getStringValues("LY6_MEOP_TemplateObject"); + String types = ""; + if(pref.length > 0) { + types = pref[0]; + }else { + MessageBox.post("ѡLY6_MEOP_TemplateObject","ʾ",2); + return; + } + + TCComponentItemRevision revision = (TCComponentItemRevision)rev; + String object_type = rev.getStringProperty("object_type"); + if(types.contains(object_type)) { + new TemplateDialog(session,revision,object_type); + }else { + MessageBox.post("ѡѡLY6_MEOP_TemplateObjectƥĶ","ʾ",2); + return; + } + + + + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }else { + MessageBox.post("ѡ汾","ʾ",2); + return; + } + + + } + }.start(); + + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + return null; + } + + +} diff --git a/src/com/langtech/plm/tqsx/Activator.java b/src/com/langtech/plm/tqsx/Activator.java new file mode 100644 index 0000000..303ada3 --- /dev/null +++ b/src/com/langtech/plm/tqsx/Activator.java @@ -0,0 +1,44 @@ +package com.langtech.plm.tqsx; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "cn.net.connor.ml.plm"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + @Override + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + +} diff --git a/src/com/langtech/plm/tqsx/DateUtil.java b/src/com/langtech/plm/tqsx/DateUtil.java new file mode 100644 index 0000000..4585c06 --- /dev/null +++ b/src/com/langtech/plm/tqsx/DateUtil.java @@ -0,0 +1,603 @@ +package com.langtech.plm.tqsx; + +import java.time.*; +import java.time.format.DateTimeFormatter; +import java.util.Date; + +public class DateUtil { + private static final String HYPHEN = "-"; + private static final String COLON = ":"; + + /* ʱʽ DateTimeFormatter (Java8) */ + enum FormatEnum { + /** + * DateTimeFormatter "yyyy-MM-dd HH:mm:ss" ʱʽ + */ + FORMAT_DATA_TIME(DateTimeFormatter.ofPattern(DATE_TIME_FORMAT)), + + /** + * DateTimeFormatter "yyyyMMddHHmmss"ʱʽ + */ + FORMAT_DATA_TIME_NO_SYMBOL(DateTimeFormatter.ofPattern(DATETIME_FORMAT)), + + /** + * DateTimeFormatter "yyyy-MM-dd"ʱʽ + */ + FORMAT_DATE(DateTimeFormatter.ofPattern(DATE_FORMAT)), + + /** + * DateTimeFormatter "HH:mm:ss"ʱʽ + */ + FORMAT_TIME(DateTimeFormatter.ofPattern(TIME_FORMAT)); + + private DateTimeFormatter value; + + FormatEnum(DateTimeFormatter format) { + this.value = format; + } + } + /* ʱʽ DateTimeFormatter (Java8) */ + + /* ʱʽ ַ */ + + /** + * ʱʽ + *
+ * "yyyy" ַ + */ + public static final String YEAR_FORMAT = "yyyy"; + + /** + * µʱʽ + *
+ * "MM" ַ + */ + public static final String MONTH_FORMAT = "MM"; + + /** + * յʱʽ + *
+ * "dd" ַ + */ + public static final String DAY_FORMAT = "dd"; + + /** + * ʱʱʽ + *
+ * "HH" ַ + */ + public static final String HOUR_FORMAT = "HH"; + + /** + * ֵʱʽ + *
+ * "mm" ַ + */ + public static final String MINUTE_FORMAT = "mm"; + + /** + * ʱʽ + *
+ * "ss" ַ + */ + public static final String SECOND_FORMAT = "ss"; + + /** + * --ʱʽ + *
+ * "yyyy-MM-dd" ַ + */ + public static final String DATE_FORMAT = YEAR_FORMAT + HYPHEN + MONTH_FORMAT + HYPHEN + DAY_FORMAT; + + /** + * ʱ::ʱʽ + *
+ * "HH:mm:ss" ַ + */ + public static final String TIME_FORMAT = HOUR_FORMAT + COLON + MINUTE_FORMAT + COLON + SECOND_FORMAT; + + /** + * -- ʱ::ʱʽ + *
+ * "yyyy-MM-dd HH:mm:ss" ַ + */ + public static final String DATE_TIME_FORMAT = DATE_FORMAT + " " + TIME_FORMAT; + + /** + * ʱʱʽ޷ţ + *
+ * "yyyyMMddHHmmss" ַ + */ + public static final String DATETIME_FORMAT = YEAR_FORMAT + MONTH_FORMAT + DAY_FORMAT + HOUR_FORMAT + MINUTE_FORMAT + SECOND_FORMAT; + + /* ʱʽ ַ */ + + + + /* ʱ */ + + /** + * ȡ뼶ʱ + */ + public static Long epochSecond() { + return localDateTime().toEpochSecond(ZoneOffset.of("+8")); + } + + /** + * ȡ뼶ʱ + */ + public static Long epochMilli() { + return localDateTime().toInstant(ZoneOffset.of("+8")).toEpochMilli(); + } + + /* ʱ */ + + + /* ǰʱ */ + + /** + * ȡǰϸʱ䣬like 2018-08-27 17:20:06 + */ + public static String dateTime() { + return localDateTime().format(FormatEnum.FORMAT_DATA_TIME.value); + } + + /** + * ȡǰϸʱ䣬like 20180827172006 + */ + public static String dateTimeNoSymbol() { + return localDateTime().format(FormatEnum.FORMAT_DATA_TIME_NO_SYMBOL.value); + } + + /** + * ȡǰڣlike 2018-08-27 + */ + public static String date() { + return localDate() + ""; + } + + /** + * ȡǰʱ䣬like 17:20:06 + */ + public static String time() { + return localTime().format(FormatEnum.FORMAT_TIME.value); + } + + /** + * ȡǰ + */ + public static Integer year() { + return localDate().getYear(); + } + + /** + * ȡǰ + */ + public static int month() { + return localDate().getMonthValue(); + } + + /** + * ȡǰе + */ + public static Integer dayOfYear() { + return localDate().getDayOfYear(); + } + + /** + * ȡǰе + */ + public static Integer dayOfMonth() { + return localDate().getDayOfMonth(); + } + + /** + * ȡǰе + */ + public static Integer dayOfWeek() { + return localDate().getDayOfWeek().getValue(); + } + + /** + * ȡǰСʱ + */ + public static Integer hour() { + return localTime().getHour(); + } + + /** + * ȡǰ + */ + public static Integer minute() { + return localTime().getMinute(); + } + + /** + * ȡǰ + */ + public static Integer second() { + return localTime().getSecond(); + } + + /* ǰʱ */ + + + + /* δʷʱ */ + + /** + * ȡǰ ǰ + *

+ * + * @param years ǰ + * @param formatEnum ʽ + * @return ǰ ǰ Ӧ ʽ + */ + public static String minusYears(Long years, FormatEnum formatEnum) { + return minusOrPlusYears(-years, formatEnum); + } + + /** + * ȡǰ + *

+ * + * @param years + * @param formatEnum ʽ + * @return ǰ Ӧ ʽ + */ + public static String plusYears(Long years, FormatEnum formatEnum) { + return minusOrPlusYears(years, formatEnum); + } + + /** + * ȡǰµ ǰ + * + * @param months ǰ + * @param formatEnum ʽ + * @return ǰµ ǰ Ӧ ʽ + */ + public static String minusMonths(Long months, FormatEnum formatEnum) { + return minusOrPlusMonths(-months, formatEnum); + } + + /** + * ȡǰµ + * + * @param months + * @param formatEnum ʽ + * @return ǰµ Ӧ ʽ + */ + public static String plusMonths(Long months, FormatEnum formatEnum) { + return minusOrPlusMonths(months, formatEnum); + } + + /** + * ȡǰյ ǰ + * + * @param days ǰ + * @param formatEnum ʽ + * @return ǰյ ǰ Ӧ ʽ + */ + public static String minusDays(Long days, FormatEnum formatEnum) { + return minusOrPlusDays(-days, formatEnum); + } + + /** + * ȡǰյ + * + * @param days + * @param formatEnum ʽ + * @return ǰյ Ӧ ʽ + */ + public static String plusDays(Long days, FormatEnum formatEnum) { + return minusOrPlusDays(days, formatEnum); + } + + /** + * ȡǰڵ ǰ + * + * @param weeks ǰ + * @param formatEnum ʽ + * @return ǰڵ ǰ Ӧ ʽ + */ + public static String minusWeeks(Long weeks, FormatEnum formatEnum) { + return minusOrPlusWeeks(-weeks, formatEnum); + } + + /** + * ȡǰڵ + * + * @param weeks + * @param formatEnum ʽ + * @return ǰڵ Ӧ ʽ + */ + public static String plusWeeks(Long weeks, FormatEnum formatEnum) { + return minusOrPlusWeeks(weeks, formatEnum); + } + + /** + * ȡǰСʱ ǰСʱ + * + * @param hours ǰСʱ + * @param formatEnum ʽ + * @return ǰСʱ ǰСʱ Ӧ ʽ + */ + public static String minusHours(Long hours, FormatEnum formatEnum) { + return minusOrPlusHours(-hours, formatEnum); + } + + /** + * ȡǰСʱ Сʱ + * + * @param hours Сʱ + * @param formatEnum ʽ + * @return ǰСʱ Сʱ Ӧ ʽ + */ + public static String plusHours(Long hours, FormatEnum formatEnum) { + return minusOrPlusHours(hours, formatEnum); + } + + /** + * ȡǰӵ ǰ + * + * @param minutes ǰ + * @param formatEnum ʽ + * @return ǰӵ ǰ Ӧ ʽ + */ + public static String minusMinutes(Long minutes, FormatEnum formatEnum) { + return minusOrPlusMinutes(-minutes, formatEnum); + } + + /** + * ȡǰӵ 󼸷 + * + * @param minutes 󼸷 + * @param formatEnum ʽ + * @return ǰӵ 󼸷 Ӧ ʽ + */ + public static String plusMinutes(Long minutes, FormatEnum formatEnum) { + return minusOrPlusMinutes(minutes, formatEnum); + } + + /** + * ȡǰ ǰ + * + * @param seconds ǰ + * @param formatEnum ʽ + * @return ǰ ǰ Ӧ ʽ + */ + public static String minusSeconds(Long seconds, FormatEnum formatEnum) { + return minusOrPlusSeconds(-seconds, formatEnum); + } + + /** + * ȡǰ ǰ/ + * + * @param seconds + * @param formatEnum ʽ + * @return ǰ Ӧ ʽ + */ + public static String plusSeconds(Long seconds, FormatEnum formatEnum) { + return minusOrPlusSeconds(seconds, formatEnum); + } + + /* δʷʱ */ + + + /* ʱת */ + + /** + * DateתLocalDateTime + *

+ * + * @param date dateʱ + * @return LocalDateTime + */ + public static LocalDateTime toLocalDateTime(Date date) { + return LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault()); + } + + /** + * DateתLocalDate + *

+ * + * @param date dateʱ + * @return LocalDate + */ + public static LocalDate toLocalDate(Date date) { + return toLocalDateTime(date).toLocalDate(); + } + + /** + * DateתLocalTime + *

+ * + * @param date dateʱ + * @return LocalTime + */ + public static LocalTime toLocalTime(Date date) { + return toLocalDateTime(date).toLocalTime(); + } + + /** + * LocalDateTime ת Date + * + * @param localDateTime localDateTime + * @return תDate + */ + public static Date toDate(LocalDateTime localDateTime) { + return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant()); + } + + /** + * LocalDateתDate + * + * @param localDate localDate + * @return תDate + */ + public static Date toDate(LocalDate localDate) { + return toDate(localDate.atStartOfDay()); + } + + /** + * LocalTimeתDate + * + * @param localTime localTime + * @return תDate + */ + public static Date toDate(LocalTime localTime) { + return toDate(LocalDateTime.of(localDate(), localTime)); + } + + /* ʱת */ + + + /* ʱ */ + + /** + * ȡ endDate-startDate ʱ + *
ˣ leigq + *
ʱ䣺 2018-11-07 09:55 + *
+ * + * @param startDate ʼʱ + * @param endDate ʱ + * @return ʱ + */ + public static Long daysInterval(LocalDate startDate, LocalDate endDate) { + return endDate.toEpochDay() - startDate.toEpochDay(); + } + + /** + * ȡ endDate-startDate ʱ + *
ˣ leigq + *
ʱ䣺 2018-11-07 09:55 + *
+ * + * @param startDate ʼʱ + * @param endDate ʱ + * @return ʱ + */ + public static Long daysInterval(String startDate, String endDate) { + return daysInterval(LocalDateTime.parse(endDate, FormatEnum.FORMAT_DATA_TIME.value).toLocalDate(), + LocalDateTime.parse(startDate, FormatEnum.FORMAT_DATA_TIME.value).toLocalDate()); + } + + /** + * ȡ endDate-startDate ʱ + *
ˣ leigq + *
ʱ䣺 2018-11-07 09:55 + *
+ * + * @param startDate ʼʱ + * @param endDate ʱ + * @return ʱ + */ + public static Long daysInterval(LocalDateTime startDate, LocalDateTime endDate) { + return daysInterval(startDate.toLocalDate(), endDate.toLocalDate()); + } + + /* ʱ */ + + /*ֻá*/ + + /** + * ȡ ǰ ǰ/ + *

+ * + * @param yearsToAddOrSubtract 괫ǰ괫 + * @param formatEnum ʽ + * @return ǰǰ/ĶӦ ʽ + */ + private static String minusOrPlusYears(Long yearsToAddOrSubtract, FormatEnum formatEnum) { + return localDateTime().plusYears(yearsToAddOrSubtract).format(formatEnum.value); + } + + /** + * ȡ ǰ ǰ/µ + * + * @param monthsToAddOrSubtract ´ǰ´ + * @param formatEnum ʽ + * @return ǰµǰ/µĶӦ ʽ + */ + private static String minusOrPlusMonths(Long monthsToAddOrSubtract, FormatEnum formatEnum) { + return localDateTime().plusMonths(monthsToAddOrSubtract).format(formatEnum.value); + } + + /** + * ȡ ǰ ǰ/յ + * + * @param daysToAddOrSubtract մǰմ + * @param formatEnum ʽ + * @return ǰյǰ/յ Ӧ ʽ + */ + private static String minusOrPlusDays(Long daysToAddOrSubtract, FormatEnum formatEnum) { + return localDateTime().plusDays(daysToAddOrSubtract).format(formatEnum.value); + } + + /** + * ȡǰڵǰ/ڵ + * + * @param weeksToAddOrSubtract ڴǰڴ + * @param formatEnum ʽ + * @return ǰڵǰ/ڵ Ӧ ʽ + */ + private static String minusOrPlusWeeks(Long weeksToAddOrSubtract, FormatEnum formatEnum) { + return localDateTime().plusWeeks(weeksToAddOrSubtract).format(formatEnum.value); + } + + /** + * ȡǰСʱǰСʱ/Сʱ + * + * @param hoursToAddOrSubtract СʱǰСʱ + * @param formatEnum ʽ + * @return ǰСʱǰСʱ/Сʱ Ӧ ʽ + */ + private static String minusOrPlusHours(Long hoursToAddOrSubtract, FormatEnum formatEnum) { + return localDateTime().plusHours(hoursToAddOrSubtract).format(formatEnum.value); + } + + /** + * ȡǰӵǰ/󼸷ӵ + * + * @param minutesToAddOrSubtract 󼸷ӴǰӴ + * @param formatEnum ʽ + * @return ǰӵǰ/󼸷ӵ Ӧ ʽ + */ + private static String minusOrPlusMinutes(Long minutesToAddOrSubtract, FormatEnum formatEnum) { + return localDateTime().plusMinutes(minutesToAddOrSubtract).format(formatEnum.value); + } + + /** + * ȡǰǰ/ + * + * @param secondsToAddOrSubtract 봫ǰ봫 + * @param formatEnum ʽ + * @return ǰǰ/ Ӧ ʽ + */ + private static String minusOrPlusSeconds(Long secondsToAddOrSubtract, FormatEnum formatEnum) { + return localDateTime().plusSeconds(secondsToAddOrSubtract).format(formatEnum.value); + } + + /** + * ȡ LocalDate + */ + private static LocalDate localDate() { + return localDateTime().toLocalDate(); + } + + /** + * ȡ LocalTime + */ + private static LocalTime localTime() { + return localDateTime().toLocalTime(); + } + + /** + * ȡ LocalDateTime + */ + private static LocalDateTime localDateTime() { + return LocalDateTime.now(); + } + +} diff --git a/src/com/langtech/plm/tqsx/KAction.java b/src/com/langtech/plm/tqsx/KAction.java new file mode 100644 index 0000000..b2700d2 --- /dev/null +++ b/src/com/langtech/plm/tqsx/KAction.java @@ -0,0 +1,37 @@ +package com.langtech.plm.tqsx; + +import java.lang.reflect.Constructor; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; +import com.teamcenter.rac.util.MessageBox; + + +public class KAction extends AbstractAIFAction { + + + KAction(AbstractAIFUIApplication app, String string) { + super(app,string); + } + + @Override + public void run() { + try { + int ind = actionName.indexOf('#'); + String action=actionName; + String actionData=""; + if(ind>0) { + action=actionName.substring(0,ind); + actionData=actionName.substring(ind+1); + } + Class c = Class.forName(action); + Constructor constructor = c.getConstructor(AbstractAIFApplication.class, String.class,String.class); + KCommand command = (KCommand) constructor.newInstance(this.application, action, actionData); + command.executeModal(); + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post(e.toString(),KLocale.getString("error"),MessageBox.ERROR); + } + } +} diff --git a/src/com/langtech/plm/tqsx/KCommand.java b/src/com/langtech/plm/tqsx/KCommand.java new file mode 100644 index 0000000..744f790 --- /dev/null +++ b/src/com/langtech/plm/tqsx/KCommand.java @@ -0,0 +1,16 @@ +package com.langtech.plm.tqsx; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; + +public abstract class KCommand extends AbstractAIFCommand { + + protected AbstractAIFApplication app; + protected String actionInfo; + + public KCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + this.app = app; + this.actionInfo = actionInfo; + } + +} diff --git a/src/com/langtech/plm/tqsx/KHandler.java b/src/com/langtech/plm/tqsx/KHandler.java new file mode 100644 index 0000000..0d6563e --- /dev/null +++ b/src/com/langtech/plm/tqsx/KHandler.java @@ -0,0 +1,24 @@ +package com.langtech.plm.tqsx; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; + +/** + * Add following config to MANIFEST.MF + * Eclipse-RegisterBuddy: k.util + * @author Administrator + * + */ +public class KHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + new Thread(new KAction(app,arg0.getCommand().getId())).start(); + return null; + } + +} diff --git a/src/com/langtech/plm/tqsx/KLocale.java b/src/com/langtech/plm/tqsx/KLocale.java new file mode 100644 index 0000000..76adff7 --- /dev/null +++ b/src/com/langtech/plm/tqsx/KLocale.java @@ -0,0 +1,22 @@ +package com.langtech.plm.tqsx; + +import com.teamcenter.rac.util.Registry; + + +public class KLocale { + + public static final Registry reg = Registry.getRegistry(KLocale.class); + + public static String getString(String title) { + if (isEmpty(title)) { + return ""; + } else { + String res = reg.getString(title); + return isEmpty(res) ? title : res; + } + } + + private static boolean isEmpty(String title) { + return title == null || "".equals(title.trim()); + } +} diff --git a/src/com/langtech/plm/tqsx/KOperation.java b/src/com/langtech/plm/tqsx/KOperation.java new file mode 100644 index 0000000..704bb53 --- /dev/null +++ b/src/com/langtech/plm/tqsx/KOperation.java @@ -0,0 +1,54 @@ +package com.langtech.plm.tqsx; + +import java.awt.Dimension; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.kernel.TCSession; + +import k.util.ProgressBar; + +/* + * do not call executeOperation yourself + * use session.performOperation + */ +public abstract class KOperation extends AbstractAIFOperation { + + protected AbstractAIFApplication app; + protected TCSession session; + public String messageLabel; + + public KOperation(AbstractAIFApplication app, String opName, String messageLabel) { + super(opName, true); + this.app = app; + this.session = (TCSession) app.getSession(); + this.messageLabel = messageLabel;// Ϣ + setSession(session); + } + + public abstract boolean init() throws Exception; + + public abstract void execute() throws Exception; + + @Override + public void executeOperation() { + ProgressBar pb = new ProgressBar(new Dimension(250, 50), true); + try { + pb.showDialog(); + pb.setText(messageLabel); + setStatus("Checking Data..."); + if (!init()) { + pb.disposeDialog(); + return; + } + setStatus("Execute..."); + pb.setText(messageLabel); + execute(); + pb.disposeDialog(); + } catch (Exception e) { + pb.disposeDialog(); + KUtil.error(getCurrentDesktop(), "쳣\n" + e.getMessage()); + e.printStackTrace(); + } + } +} diff --git a/src/com/langtech/plm/tqsx/KOperation2.java b/src/com/langtech/plm/tqsx/KOperation2.java new file mode 100644 index 0000000..f9f3b90 --- /dev/null +++ b/src/com/langtech/plm/tqsx/KOperation2.java @@ -0,0 +1,53 @@ +package com.langtech.plm.tqsx; + +import java.awt.Dimension; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.kernel.TCSession; + +import k.util.ProgressBar; + +/* + * do not call executeOperation yourself + * use session.performOperation + */ +public abstract class KOperation2 extends AbstractAIFOperation { + + protected AbstractAIFApplication app; + protected TCSession session; + protected ProgressBar pb; + + public KOperation2(AbstractAIFApplication app, String opName) { + super(opName, true); + this.app = app; + this.session = (TCSession) app.getSession(); + setSession(session); + } + + public abstract boolean init() throws Exception; + + public abstract void execute() throws Exception; + + @Override + public void executeOperation() { + pb = new ProgressBar(new Dimension(250, 50), true); + try { + pb.showDialog(); + setStatus(KLocale.getString("initop.STATUS")); + if (!init()) { + pb.disposeDialog(); + return; + } + setStatus(KLocale.getString("exeop.STATUS")); + execute(); + KUtil.setByPass(false); + pb.disposeDialog(); + } catch (Exception e) { + pb.disposeDialog(); + KUtil.setByPass(false); + KUtil.error(getCurrentDesktop(), "쳣\n" + e); + e.printStackTrace(); + } + } +} diff --git a/src/com/langtech/plm/tqsx/KUtil.java b/src/com/langtech/plm/tqsx/KUtil.java new file mode 100644 index 0000000..21c5ee5 --- /dev/null +++ b/src/com/langtech/plm/tqsx/KUtil.java @@ -0,0 +1,2348 @@ +package com.langtech.plm.tqsx; + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.Window; +import java.io.BufferedWriter; +import java.io.EOFException; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileWriter; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.time.Instant; +import java.time.LocalDate; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JDialog; +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.filechooser.FileNameExtensionFilter; +import javax.swing.filechooser.FileSystemView; + +import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.WorkbookFactory; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Shell; + + +import com.teamcenter.rac.aif.commands.open.OpenCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.common.lov.view.components.LOVDisplayer; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentContextList; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentGroupMember; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemRevisionType; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCComponentManager; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentRole; +import com.teamcenter.rac.kernel.TCComponentSchedule; +import com.teamcenter.rac.kernel.TCComponentScheduleDeliverable; +import com.teamcenter.rac.kernel.TCComponentTCCalendar; +import com.teamcenter.rac.kernel.TCComponentTaskDeliverable; +import com.teamcenter.rac.kernel.TCComponentType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCPropertyDescriptor; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTextService; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.schedule.calendar.TCCalendar; +import com.teamcenter.rac.schedule.componentutils.CalendarHelper; +import com.teamcenter.rac.ui.common.RACUIUtil; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.Registry; +import com.teamcenter.rac.util.UIUtilities; +import com.teamcenter.services.rac.core.DataManagementService; +import com.teamcenter.services.rac.core.LOVService; +import com.teamcenter.services.rac.core._2006_03.DataManagement.Relationship; +import com.teamcenter.services.rac.core._2007_01.DataManagement.WhereReferencedInfo; +import com.teamcenter.services.rac.core._2007_01.DataManagement.WhereReferencedOutput; +import com.teamcenter.services.rac.core._2007_01.DataManagement.WhereReferencedResponse; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateIn; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateInput; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateOut; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateResponse; +import com.teamcenter.services.rac.core._2013_05.LOV.InitialLovData; +import com.teamcenter.services.rac.core._2013_05.LOV.LOVSearchResults; +import com.teamcenter.services.rac.core._2013_05.LOV.LOVValueRow; +import com.teamcenter.services.rac.core._2013_05.LOV.LovFilterData; +import com.teamcenter.soa.client.model.LovValue; +import com.teamcenter.soa.client.model.ServiceData; + +@SuppressWarnings("deprecation") +public class KUtil { + + public static final TCSession session; + public static final TCTextService textService; +// public static final Registry REG = Registry.getRegistry(KUtil.class); + public static final ZoneId zoneId = ZoneId.systemDefault(); +// public static final Registry reg = Registry.getRegistry(KUtil.class); + +// public static String getRegString(String title) { +// String res = reg.getString(title); +// if (KUtil.isEmpty(res)) { +// return title; +// } +// return res; +// } + + static { + session = (TCSession) AIFUtility.getCurrentApplication().getSession(); + textService = session.getTextService(); + } + + public static void setTCPropertyValue(TCComponent item, String propertyName, Object value) { + try { + TCProperty tcProperty = item.getTCProperty(propertyName); + switch (tcProperty.getPropertyType()) { + case TCProperty.PROP_double: + if (value instanceof Double) { + tcProperty.setDoubleValue((double) value); + } else { + tcProperty.setDoubleValue(Double.parseDouble(value.toString())); + } + break; + case TCProperty.PROP_int: + if (value instanceof Integer) { + tcProperty.setDoubleValue((int) value); + } else { + tcProperty.setDoubleValue(Integer.parseInt(value.toString())); + } + break; + case TCProperty.PROP_string: + tcProperty.setStringValue(value.toString()); + break; + case TCProperty.PROP_date: + if (value instanceof Date) { + tcProperty.setDateValue((Date) value); + } else { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-dd HH:mm"); + tcProperty.setDateValue(sdf.parse(value.toString())); + } + break; + default: + break; + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static Object getTCPropertyValue(TCComponent item, String propertyName) { + Object result = ""; + try { + TCProperty tcProperty = item.getTCProperty(propertyName); + if (tcProperty == null) { + System.out.println("δȡԣ" + propertyName); + return result; + } + switch (tcProperty.getPropertyType()) { + case TCProperty.PROP_double: + result = tcProperty.getDoubleValue(); + break; + case TCProperty.PROP_int: + result = tcProperty.getIntValue(); + break; + case TCProperty.PROP_string: + result = tcProperty.getStringValue(); + break; + case TCProperty.PROP_date: + result = tcProperty.getDateValue(); + break; + case TCProperty.PROP_logical: + result = tcProperty.getLogicalValue(); + break; + default: + break; + } + } catch (TCException e) { + e.printStackTrace(); + } + return result; + } + + public static String getCellValue(Cell c) { + if (c == null) { + return ""; + } + String value = ""; + if (c.getCellType() == CellType.NUMERIC.getCode()) { + DecimalFormat df = new DecimalFormat("0"); + String whatYourWant = df.format(c.getNumericCellValue()); + return whatYourWant; + } + switch (c.getCellType()) { + case HSSFCell.CELL_TYPE_NUMERIC:// + value = (c.getNumericCellValue() + "").split("\\.")[0]; + break; + case HSSFCell.CELL_TYPE_STRING:// ַ + value = c.getStringCellValue(); + break; + case HSSFCell.CELL_TYPE_BOOLEAN:// boolean + value = c.getBooleanCellValue() + ""; + break; + case HSSFCell.CELL_TYPE_FORMULA:// ʽ + value = c.getCellFormula() + ""; + break; + case HSSFCell.CELL_TYPE_BLANK:// ֵ + value = ""; + break; + case HSSFCell.CELL_TYPE_ERROR: + value = "Ƿַ"; + break; + default: + value = "δ֪"; + break; + } + return value; + } + + /** + * õʵ + * + * @param sheet + * @param flag ҪдݿExcelԪöŸ Excel5еԪ4 + * Ҫ⣬2вҪ⣬flagʹ [0,2,3,4] + * @return + * @throws Exception + * + */ + public static int findRealRows(Sheet sheet, int... flag) throws Exception { + int row_real = 0; + int rows = sheet.getPhysicalNumberOfRows();// ˴ͳд, + try { + + for (int i = 1; i < rows; i++) { + Row row = sheet.getRow(i); + int total = 0; + ArrayList blank = new ArrayList(); + int type = -1; + String s = null; + for (int j : flag) { + if (!(row.getCell(j) == null) && row.getCell(j).getCellType() < 2) { + type = row.getCell(j).getCellType(); + row.getCell(j).setCellType(1); + } + + if (row.getCell(j) == null || row.getCell(j).getStringCellValue().matches("^\\s+$") + || row.getCell(j).getCellType() > 2) { + total++; + + if (!(row.getCell(j) == null) && row.getCell(j).getCellType() < 2) { + row.getCell(j).setCellType(type); + } + blank.add(j); + + } + } + System.out.println(s + ""); + // 4жǿ˵͸÷ + if (total == flag.length) { + + return row_real; + } else if (total == 0) { + row_real++; + + } else { + String h = ""; + for (Integer b : blank) { + + h = h + "" + (b + 1) + "" + " "; + } + throw new Exception("" + (i + 1) + "" + h + "Ϊ"); + } + + } + } catch (NullPointerException e) { + throw new Exception("excelʽ쳣,excelʽȱʧ,Ч!"); + } + return row_real; + } + + public static Workbook getWorkbook(File file) throws Exception { + Workbook workbook = null; + FileInputStream in = new FileInputStream(file); + if (file.getName().endsWith("xlsx")) { + System.out.println("ȡģ:" + file.getName()); + try { + workbook = WorkbookFactory.create(in); + } catch (EOFException e) { + e.printStackTrace(); + } +// workbook = new XSSFWorkbook(in); + } else { + System.out.println("ʽ"); + } + in.close(); + return workbook; + } + + public static void removeEnd(StringBuilder sb, int len) { + if (sb == null || len <= 0) { + return; + } + if (sb.length() >= len) { + sb.setLength(sb.length() - len); + } + } + + public static TCComponent[] getComponentsByItemType(TCComponent comp, String type, String relation) + throws TCException { + TCComponent[] comps1 = comp.getRelatedComponents(relation); + if (comps1 == null || comps1.length < 1) { + return null; + } + ArrayList list = new ArrayList(); + for (TCComponent comp1 : comps1) { + if (comp1.getType().equals(type)) { + list.add(comp1); + } + } + return list.toArray(new TCComponent[] {}); + } + + public static TCComponentContextList objectsInProject(String type, String projId) throws Exception { + if (KUtil.isEmpty(type) || KUtil.isEmpty(projId)) { + return null; + } + String queryName = "Objects in Projects"; + String[] keys = new String[] { KUtil.getText("Type"), KUtil.getText("ProjectID") }; + String[] vals = new String[] { type, projId }; + return KUtil.query(KUtil.session, queryName, keys, vals); + } + + public static TCComponentContextList objectsInProject(String type, String projId, String name) throws Exception { + if (KUtil.isEmpty(type) || KUtil.isEmpty(projId) || KUtil.isEmpty(name)) { + return null; + } + String queryName = "Objects in Projects"; + String[] keys = new String[] { KUtil.getText("Name"), KUtil.getText("Type"), KUtil.getText("ProjectID") }; + String[] vals = new String[] { name, type, projId }; + return KUtil.query(KUtil.session, queryName, keys, vals); + } + + public static boolean checkGMPrivilegeFromPref(String prefName) throws Exception { + boolean validityCanEdit = false; + String validRoles = KUtil.getPrefVal(KUtil.session, prefName); + System.out.println(">> Check GroupMember Priv: " + validRoles); + if (!KUtil.isEmpty(validRoles)) { + List groups = new ArrayList(); + List roles = new ArrayList(); + String[] split = validRoles.split(":"); + for (String string : split) { + if (string.startsWith("G.")) { + groups.add(string.substring(2)); + } else if (string.startsWith("R.")) { + roles.add(string.substring(2)); + } + } + TCComponentUser currentUser = KUtil.session.getUser(); + System.out.println(">> Current User: " + currentUser); + TCComponentGroupMember[] gms = currentUser.getGroupMembers(); + System.out.println(">> Current GroupMembers: " + Arrays.toString(gms)); + int len = KUtil.getLen(gms); + for (int i = 0; i < len; i++) { + TCComponentGroupMember gm = gms[i]; + TCComponentGroup g = gm.getGroup(); + TCComponentRole r = gm.getRole(); + String gName = g.getGroupName(); + String rName = r.getRoleName(); + System.out.println((i + 1) + ". " + gName + " - " + rName); + if (groups.contains(gName) && roles.contains(rName)) { + validityCanEdit = true; + // break; + } + } + } + return validityCanEdit; + } + + public static boolean compare(String str1, String str2) { + if (str1 == null) { + str1 = ""; + } + if (str2 == null) { + str2 = ""; + } + return str1.equals(str2); + } + + public static boolean compare(Object str1, Object str2) { + if (str1 == null) { + return str2 == null; + } + return str1.equals(str2); + } + + public static TCComponentItem createItem(TCComponentItemType itemType, String itemName) throws Exception { + if (itemType == null) { + return null; + } + String id = itemType.getNewID(); + String rev = itemType.getNewRev(null); + return itemType.create(id, rev, itemType.getName(), itemName, "", null); + } + + public static void setByPass(boolean val) { + try { + TCUserService userservice = session.getUserService(); + userservice.call(val ? "CONNOR_open_bypass" : "CONNOR_close_bypass", new Object[] { "" }); + System.out.println(val ? "Open Bypass" : "Close Bypass"); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static TCComponentItem createItemBySOA(String itemTypeName, String revTypeName, String revMasterTypeName, + String itemId, String revId, String name, Map stringProps, Map dateProps) + throws Exception { + if (KUtil.isEmpty(itemTypeName) || KUtil.isEmpty(revTypeName) || KUtil.isEmpty(revMasterTypeName)) { + return null; + } + CreateInput revMasterInput = new CreateInput(); + revMasterInput.boName = revMasterTypeName; + if (stringProps != null) { + revMasterInput.stringProps = stringProps; + } + if (dateProps != null) { + revMasterInput.dateProps = dateProps; + } + CreateInput revInput = new CreateInput(); + revInput.boName = revTypeName; + Map revPropMap = new HashMap<>(); + if (!KUtil.isEmpty(revId)) { + revPropMap.put("item_revision_id", revId); + } + revInput.stringProps = revPropMap; + Map revMasterInfoMap = new HashMap<>(); + revMasterInfoMap.put("IMAN_master_form_rev", new CreateInput[] { revMasterInput }); + revInput.compoundCreateInput = revMasterInfoMap; + // create rev + CreateInput itemInput = new CreateInput(); + itemInput.boName = itemTypeName; + Map itemPropMap = new HashMap<>(); + if (!KUtil.isEmpty(itemId)) { + itemPropMap.put("item_id", itemId); + } + if (!KUtil.isEmpty(name)) { + itemPropMap.put("object_name", name); + } + itemInput.stringProps = itemPropMap; + Map revInfoMap = new HashMap<>(); + revInfoMap.put("revision", new CreateInput[] { revInput }); + itemInput.compoundCreateInput = revInfoMap; + // create info + CreateIn cI = new CreateIn(); + cI.clientId = "CreateItem"; + cI.data = itemInput; + // service + DataManagementService service = DataManagementService.getService(session); + // create + CreateResponse resp = service.createObjects(new CreateIn[] { cI }); + throwServiceDataError(resp.serviceData); + CreateOut[] cOs = resp.output; + if (cOs.length > 0) { + for (TCComponent s : cOs[0].objects) { + if (s instanceof TCComponentItem) { + return (TCComponentItem) s; + } + } + } + return null; + } + + public static TCComponentFolder createFolderBySOA(String folderTypeName, String folderName) throws Exception { + if (KUtil.isEmpty(folderTypeName)) { + return null; + } + CreateInput itemInput = new CreateInput(); + itemInput.boName = folderTypeName; + Map itemPropMap = new HashMap<>(); + itemPropMap.put("object_name", folderName); + itemInput.stringProps = itemPropMap; + // create info + CreateIn cI = new CreateIn(); + cI.clientId = "CreateFolder"; + cI.data = itemInput; + // service + DataManagementService service = DataManagementService.getService(session); + // create + CreateResponse resp = service.createObjects(new CreateIn[] { cI }); + throwServiceDataError(resp.serviceData); + CreateOut[] cOs = resp.output; + if (cOs.length > 0) { + for (TCComponent s : cOs[0].objects) { + if (s instanceof TCComponentFolder) { + return (TCComponentFolder) s; + } + } + } + return null; + } + + public static void throwServiceDataError(ServiceData serviceData) throws Exception { + if (serviceData.sizeOfPartialErrors() > 0) { + StringBuilder errInfo = new StringBuilder(); + for (int i = 0; i < serviceData.sizeOfPartialErrors(); i++) { + for (String msg : serviceData.getPartialError(i).getMessages()) { + errInfo.append(msg + "\n"); + } + } + // System.out.println(errInfo.toString()); + throw new Exception(errInfo.toString()); + } + } + + public static void throwServiceDataError(ServiceData serviceData, String defaultErrorMsg) throws Exception { + if (serviceData.sizeOfPartialErrors() > 0) { + StringBuilder errInfo = new StringBuilder(); + for (int i = 0; i < serviceData.sizeOfPartialErrors(); i++) { + for (String msg : serviceData.getPartialError(i).getMessages()) { + errInfo.append(msg + "\n"); + } + } + // System.out.println(errInfo.toString()); + if (KUtil.isEmpty(errInfo.toString())) { + throw new Exception(defaultErrorMsg); + } + throw new Exception(errInfo.toString()); + } + } + + public static Date localDateToDate(LocalDate localDate) { + if (localDate == null) { + return null; + } + ZonedDateTime zdt = localDate.atStartOfDay(zoneId); + Date date = Date.from(zdt.toInstant()); + return date; + } + + public static LocalDate dateToLocalDate(Date date) { + if (date == null) { + return null; + } + Instant instant = date.toInstant(); + LocalDate localDate = instant.atZone(zoneId).toLocalDate(); + return localDate; + } + + public static TCComponent stringToComponent(String uid) throws Exception { + if (KUtil.isEmpty(uid)) { + return null; + } + return session.stringToComponent(uid); + } + + public static String getText(String str) throws Exception { + if (KUtil.isEmpty(str)) { + return str; + } + String res = textService.getTextValue(str); + if (!KUtil.isEmpty(res)) { + return res; + } + return str; + } + + public static void sendTo(TCComponent comp, String perspectiveId) { + if (comp == null) { + return; + } + if (KUtil.isEmpty(perspectiveId)) { + perspectiveId = "com.teamcenter.rac.ui.perspectives.navigatorPerspective"; + } + com.teamcenter.rac.common.Activator.getDefault().openPerspective(perspectiveId); + com.teamcenter.rac.common.Activator.getDefault().openComponents(perspectiveId, new TCComponent[] { comp }); + } + + public static void open(TCComponent comp) { + if (comp == null) { + return; + } + if (comp instanceof TCComponentScheduleDeliverable) { + System.out.println(">> Open Schedule Deliverable: " + comp); + try { + comp = comp.getReferenceProperty("deliverable_inst"); + System.out.println(">> Open Schedule Deliverable Inst: " + comp); + if (comp == null) { + return; + } + } catch (Exception e) { + e.printStackTrace(); + } + } else if (comp instanceof TCComponentTaskDeliverable) { + System.out.println(">> Open Task Deliverable: " + comp); + try { + comp = comp.getReferenceProperty("fnd0DeliverableInstance"); + System.out.println(">> Open Task Deliverable Inst: " + comp); + if (comp == null) { + return; + } + } catch (Exception e) { + e.printStackTrace(); + } + } + try { + Registry localRegistry = Registry.getRegistry("com.teamcenter.rac.commands.open.open"); + OpenCommand localOpenCommand = (OpenCommand) localRegistry.newInstanceForEx("openCommand", + new Object[] { AIFUtility.getActiveDesktop(), comp }); + localOpenCommand.executeModeless(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static JButton getImageBtn(String iconName) { + ImageIcon icon = new ImageIcon(KUtil.class.getResource("/icons/" + iconName)); + JButton btn = new JButton(icon); + btn.setPreferredSize(new Dimension(26, 26)); + btn.setContentAreaFilled(true); + btn.setFocusPainted(false); + btn.setBorderPainted(true); + // btn.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + return btn; + } + + public static void info(Window dialog, String msg) { + MessageBox.post(dialog, msg, "", MessageBox.INFORMATION); + } + + public static void warn(Window dialog, String msg) { + MessageBox.post(dialog, msg, "", MessageBox.WARNING); + } + + public static void error(Window dialog, String msg) { + MessageBox.post(dialog, msg, "", MessageBox.ERROR); + } + + public static void error(Window dialog, String msg, String title) { + MessageBox.post(dialog, msg, title, MessageBox.ERROR); + } + + public static void showScrollDialog(Window dialog, String text, String title) { + if (dialog == null) { + dialog = UIUtilities.getCurrentModalDialog(); + } + JTextArea textArea = new JTextArea(text); + textArea.setEditable(false); + JScrollPane scrollPane = new JScrollPane(textArea); + textArea.setLineWrap(true); + textArea.setWrapStyleWord(true); + scrollPane.setPreferredSize(new Dimension(500, 300)); + JOptionPane.showMessageDialog(dialog, scrollPane, title, JOptionPane.INFORMATION_MESSAGE); + } + + public static void showScrollDialogWithExport(Window dialog, String text, String title, String exportFileName) { + if (dialog == null) { + dialog = UIUtilities.getCurrentModalDialog(); + } + JTextArea textArea = new JTextArea(text); + textArea.setEditable(false); + JScrollPane scrollPane = new JScrollPane(textArea); + textArea.setLineWrap(true); + textArea.setWrapStyleWord(true); + scrollPane.setPreferredSize(new Dimension(500, 300)); + String yesOption = KLocale.getString("ok"); + String exportOption = KLocale.getString("export"); + int op = JOptionPane.showOptionDialog(dialog, scrollPane, title, JOptionPane.YES_NO_OPTION, + JOptionPane.INFORMATION_MESSAGE, null, new String[] { yesOption, exportOption }, yesOption); + if (op == 1) { + System.out.println("Export"); + File saveFile = KUtil.chooseSaveFile(dialog, exportFileName, "txt"); + if (saveFile != null) { + try { + BufferedWriter writer = new BufferedWriter(new FileWriter(saveFile, false)); + writer.write(text); + writer.flush(); + writer.close(); + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post(dialog, e); + } + } + } + } + + public static void errorSWT(Shell shell, String message, String title) { + showDialog(shell, message, title, SWT.ICON_ERROR); + } + + public static void showDialog(Shell shell, String message, String title, int type) { + org.eclipse.swt.widgets.MessageBox dialog = new org.eclipse.swt.widgets.MessageBox(shell, SWT.OK | type); + dialog.setText(title); + dialog.setMessage(message); + dialog.open(); + } + + public static String[] getPrefVals(TCSession session, String prefName) throws Exception { + if (KUtil.isEmpty(prefName)) { + return null; + } + return session.getPreferenceService().getStringValues(prefName); + } + + public static String getPrefVal(TCSession session, String prefName) throws Exception { + if (KUtil.isEmpty(prefName)) { + return null; + } + return session.getPreferenceService().getStringValue(prefName); + } + + public static String getReg(Registry reg, String name) { + String val = reg.getString(name); + // System.out.println("Read REG: " + name + " = " + val); + return val; + } + +// public static String getReg(String name) { +// return getReg(REG, name); +// } + + public static void newRow(JPanel panel, Component comp, GridBagConstraints s, int width) { + newRow(panel, comp, s, width, 0); + } + + public static void newRow(JPanel panel, Component comp, GridBagConstraints s, int width, double weightx) { + s.weightx = weightx; + s.gridwidth = width; + s.gridx = 0; + s.gridy++; + panel.add(comp, s); + } + + public static void newRow(JDialog panel, Component comp, GridBagConstraints s, int width) { + s.weightx = 0; + s.gridwidth = width; + s.gridx = 0; + s.gridy++; + panel.add(comp, s); + } + + public static void addCol(JPanel panel, Component comp, GridBagConstraints s, int width, double weightx) { + s.gridx++; + s.gridwidth = width; + s.weightx = weightx; + panel.add(comp, s); + } + + public static TCComponentDataset getDataset(TCComponent rev, String dsType, String dsName, String rel) + throws Exception { + if (rev == null || KUtil.isEmpty(dsName)) { + return null; + } + rev.refresh(); + TCComponent[] kids = rev.getRelatedComponents(rel); + for (TCComponent c : kids) { + if (c.getType().equals(dsType) && c.toString().equals(dsName)) { + return (TCComponentDataset) c; + } + } + return null; + } + + public static List getDatasets(TCComponent rev, String dsType, String rel) throws Exception { + if (rev == null) { + return null; + } + rev.refresh(); + List res = new ArrayList(); + TCComponent[] kids = rev.getRelatedComponents(rel); + for (TCComponent c : kids) { + if (c.getType().equals(dsType)) { + res.add((TCComponentDataset) c); + } + } + return res; + } + + public static List getChildComponents(TCComponent rev, String dsType, String rel, String dsNamePrefix) + throws Exception { + if (rev == null) { + return null; + } + rev.refresh(); + List res = new ArrayList(); + TCComponent[] kids = rev.getRelatedComponents(rel); + for (TCComponent c : kids) { + if (c.getType().equals(dsType) && c.getProperty("object_name").startsWith(dsNamePrefix)) { + res.add(c); + } + } + return res; + } + + public static List getChildComponentsContainsStr(TCComponent rev, String dsType, String rel, + String dsNameSubStr) throws Exception { + if (rev == null) { + return null; + } + if (dsNameSubStr == null) { + dsNameSubStr = ""; + } + rev.refresh(); + List res = new ArrayList(); + TCComponent[] kids = rev.getRelatedComponents(rel); + for (TCComponent c : kids) { + if (c.getType().equals(dsType) && c.getProperty("object_name").contains(dsNameSubStr)) { + res.add(c); + } + } + return res; + } + + public static List getChildComponents(TCComponent rev, String dsType, String rel) throws Exception { + if (rev == null) { + return null; + } + rev.refresh(); + List res = new ArrayList(); + TCComponent[] kids = rev.getRelatedComponents(rel); + for (TCComponent c : kids) { + if (c.getType().equals(dsType)) { + res.add(c); + } + } + return res; + } + + public static TCComponentFolder getChildFolder(TCComponentFolder folder, String cFolderName) throws Exception { + if (folder == null || cFolderName == null) { + return null; + } + AIFComponentContext[] cc = folder.getChildren(); + int len = KUtil.getLen(cc); + for (int i = 0; i < len; i++) { + InterfaceAIFComponent c = cc[i].getComponent(); + if ((c instanceof TCComponentFolder) && cFolderName.equals(c.getProperty("object_name"))) { + return (TCComponentFolder) c; + } + } + return null; + } + + public static TCComponentDataset uploadFile(TCSession session, TCComponent rev, File newFile, String dsName, + String dsTypeName, String refName, String rel) throws Exception { + TCComponentDataset ds = getDataset(rev, dsTypeName, dsName, rel); + if (ds == null) { + TCComponentDatasetType dsType = (TCComponentDatasetType) session.getTypeComponent(dsTypeName); + ds = dsType.create(dsName, "", dsTypeName); + if (rev != null) { + rev.add(rel, ds); + rev.refresh(); + } + } + setDsFile(ds, refName, newFile); + return ds; + } + + public static void setDsFile(TCComponentDataset ds, String refName, File newFile) throws Exception { + if (ds.isCheckedOut()) { + throw new Exception(String.format(KLocale.getString("uploadfilewhencheckout.ERROR1"), ds.toString())); + } + String[] refs = new String[] { refName }; + String[] files = new String[] { newFile.getAbsolutePath() }; + ds.setFiles(files, refs); + // ds.save(); + ds.refresh(); + } + + public static void setDsFile2(TCComponentDataset ds, String refName, File newFile) throws Exception { + String[] refs = new String[] { refName }; + String[] files = new String[] { newFile.getAbsolutePath() }; + ds.setFiles(files, refs); + // ds.save(); + ds.refresh(); + } + + public static boolean isEmpty(String str) { + return str == null || "".equals(str.trim()); + } + + public static int inArray(int target, int[] arr) { + int len = arr == null ? 0 : arr.length; + for (int i = 0; i < len; i++) { + if (target == arr[i]) { + return i; + } + } + return -1; + } + + public static boolean inArray(String str, String arr, String splitter) { + if (KUtil.isEmpty(arr) || KUtil.isEmpty(splitter)) { + return false; + } + if (KUtil.isEmpty(str)) { + return true; + } + return inArray(str, arr.split(splitter)) >= 0; + } + + public static int inArray(String target, String[] arr) { + int len = arr == null ? 0 : arr.length; + for (int i = 0; i < len; i++) { + if (target.equals(arr[i])) { + return i; + } + } + return -1; + } + + public static int getNextColNumber(int currentIndex, int[] skipColIndex, int cols) { + int res = currentIndex; + for (int i = 0; i < cols; i++) { + res++; + if (inArray(res, skipColIndex) >= 0) { + i--; + } + } + return res; + } + + public static List> groupList(List originList, int maxCount, int gap, E gapFiller) { + List> res = new ArrayList>(); + int cnt = originList == null ? 0 : originList.size(); + List list = new ArrayList(); + for (int i = 0; i < cnt; i++) { + list.add(originList.get(i)); + if (i != cnt - 1) {// add gap + for (int j = 0; j < gap; j++) { + list.add(gapFiller); + } + } + } + cnt = list == null ? 0 : list.size(); + if (maxCount <= 0) { + maxCount = cnt; + } + int pageCounter = 0; + List cList = new ArrayList(); + res.add(cList); + for (int i = 0; i < cnt; i++) { + if (pageCounter == maxCount) { + cList = new ArrayList<>(); + res.add(cList); + pageCounter = 0; + } + if (cList != null) { + E item = list.get(i); + if (cList.size() == 0 && item == gapFiller) { + continue; + } + cList.add(list.get(i)); + pageCounter++; + } + } + list.clear(); + list = null; + return res; + } + + public static List> groupListWithGapAdded(List list, int maxCount, E gapFiller) { + List> res = new ArrayList>(); + int cnt = list == null ? 0 : list.size(); + if (maxCount <= 0) { + maxCount = cnt; + } + int pageCounter = 0; + List cList = new ArrayList(); + res.add(cList); + for (int i = 0; i < cnt; i++) { + if (pageCounter == maxCount) { + cList = new ArrayList<>(); + res.add(cList); + pageCounter = 0; + } + if (cList != null) { + E item = list.get(i); + if (cList.size() == 0 && item == gapFiller) { + continue; + } + cList.add(list.get(i)); + pageCounter++; + } + } + list.clear(); + list = null; + return res; + } + + public static List>> groupList(List> originList, int maxCount, int gap, + Map gapFiller, String gapKey) { + List>> res = new ArrayList>>(); + int cnt = originList == null ? 0 : originList.size(); + List> list = new ArrayList>(); + boolean addGap = false; + for (int i = 0; i < cnt; i++) { + Map item = originList.get(i); + list.add(item); + if (i != cnt - 1) {// add gap + Map nextItem = originList.get(i + 1); + addGap = KUtil.isEmpty(gapKey) || (nextItem != null && nextItem.containsKey(gapKey)); + for (int j = 0; j < gap; j++) { + if (addGap) { + list.add(gapFiller); + } + } + } + } + cnt = list == null ? 0 : list.size(); + if (maxCount <= 0) { + maxCount = cnt; + } + int pageCounter = 0; + List> cList = new ArrayList>(); + res.add(cList); + for (int i = 0; i < cnt; i++) { + if (pageCounter == maxCount) { + cList = new ArrayList<>(); + res.add(cList); + pageCounter = 0; + } + if (cList != null) { + Map item = list.get(i); + if (cList.size() == 0 && item == gapFiller) { + continue; + } + cList.add(list.get(i)); + pageCounter++; + } + } + list.clear(); + list = null; + return res; + } + + public static File getFileFromDataset(TCSession session, String dsType, String uid, String prefName) + throws Exception { + TCComponent comp = null; + try { + comp = session.stringToComponent(uid); + } catch (Exception e) { + e.printStackTrace(); + } + if (comp == null) { + throw new Exception(String.format(KLocale.getString("dsuidinpref.ERROR1"), prefName)); + } + String type = comp.getType(); + System.out.println("Dataset: " + comp + "|Type: " + type); + if (!dsType.equals(type)) { + throw new Exception(String.format(KLocale.getString("dsuidinpref.ERROR1"), prefName)); + } + TCComponentDataset tDataset = (TCComponentDataset) comp; + return getDatasetFile(tDataset); + } + + public static File getDatasetFile(TCComponentDataset dataset) throws Exception { + File[] files = dataset.getFiles("", System.getenv("TEMP")); + if (files == null || files.length == 0) { + throw new Exception(String.format(KLocale.getString("norefindataset.ERROR1"), dataset.toString())); + } + System.out.println(">> Download file (" + files.length + "): " + files[0].getAbsolutePath()); + return files[0]; + } + + public static File getDatasetFile(File dir, TCComponentDataset dataset) throws Exception { + if (dir == null || !dir.isDirectory()) { + throw new Exception("Directory not found."); + } + File[] files = dataset.getFiles("", dir.getAbsolutePath()); + if (files == null || files.length == 0) { + throw new Exception(String.format(KLocale.getString("norefindataset.ERROR1"), dataset.toString())); + } + System.out.println(">> Download file (" + files.length + "): " + files[0].getAbsolutePath()); + return files[0]; + } + + public static String[] getStringArrayProp(TCComponentForm form, String propName) throws Exception { + if (form == null) { + return null; + } + TCProperty prop = form.getFormTCProperty(propName); + if (prop == null) { + throw new java.lang.Exception( + String.format(KLocale.getString("nopropintype.ERROR2"), form.getDisplayType(), propName)); + } + return prop.getStringArrayValue(); + } + + public static File chooseDirectory(Component parent) { + FileSystemView fsv = FileSystemView.getFileSystemView(); + String deskPath = fsv.getHomeDirectory().getPath(); + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setCurrentDirectory(new File(deskPath)); + fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + int state = fileChooser.showOpenDialog(parent); + if (state == 1) { + return null; + } + return fileChooser.getSelectedFile(); + } + + public static boolean addReleaseStatus(TCSession session, String uid, String status) throws Exception { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[2]; + obj[0] = uid; + obj[1] = status; + Object res = userservice.call("K_add_release_status", obj); + if (res != null && res.toString().equalsIgnoreCase("true")) { + return true; + } + return false; + } + + /** + * ֻԵֵ + * + * @param session + * @param propName + * @param propValue + * @param comp + * @return + * @throws Exception + */ + public static boolean setPropValue(TCSession session, String propName, String propValue, TCComponent comp) + throws Exception { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[3]; + obj[0] = propName; + obj[1] = propValue; + obj[2] = comp; + Object res = userservice.call("Connor_Set_Prop_Value", obj); + if (res != null && res.toString().equalsIgnoreCase("true")) { + return true; + } + return false; + } + + public static File chooseFile(Component parent) { + FileSystemView fsv = FileSystemView.getFileSystemView(); + String deskPath = fsv.getHomeDirectory().getPath(); + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setCurrentDirectory(new File(deskPath)); + fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + FileNameExtensionFilter filter = new FileNameExtensionFilter("*.xlsx", "xlsx"); + fileChooser.setFileFilter(filter); + int state = fileChooser.showOpenDialog(parent); + if (state == 1) { + return null; + } + return fileChooser.getSelectedFile(); + } + + public static File chooseSaveFile(Component parent, String defaultFile) { + FileSystemView fsv = FileSystemView.getFileSystemView(); + String deskPath = fsv.getHomeDirectory().getPath(); + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setCurrentDirectory(new File(deskPath)); + fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + FileNameExtensionFilter filter = new FileNameExtensionFilter("*.xlsx", "xlsx"); + fileChooser.setFileFilter(filter); + fileChooser.setSelectedFile(new File(defaultFile)); + int state = fileChooser.showSaveDialog(parent); + if (state == 1) { + return null; + } + return fileChooser.getSelectedFile(); + } + + public static File chooseSaveFile(Component parent, String defaultFile, String ext) { + FileSystemView fsv = FileSystemView.getFileSystemView(); + String deskPath = fsv.getHomeDirectory().getPath(); + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setCurrentDirectory(new File(deskPath)); + fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + if (!KUtil.isEmpty(ext)) { + FileNameExtensionFilter filter = new FileNameExtensionFilter("*." + ext, ext); + fileChooser.setFileFilter(filter); + } + fileChooser.setSelectedFile(new File(defaultFile)); + int state = fileChooser.showSaveDialog(parent); + if (state == 1) { + return null; + } + return fileChooser.getSelectedFile(); + } + + public static File getNewFile(File folder, String fileName, String ext) { + File file = new File(folder.getAbsolutePath() + "\\" + fileName + "." + ext); + int index = 1; + while (file.exists()) { + file = new File(folder.getAbsolutePath() + "\\" + fileName + "(" + (index++) + ")." + ext); + } + return file; + } + + public static String getDateStr(Date date, String format) { + String res = ""; + try { + SimpleDateFormat sdf = new SimpleDateFormat(format); + res = sdf.format(date); + } catch (Exception e) { + e.printStackTrace(); + } + return res; + } + + public static TCComponentContextList query(TCSession session, String queryName, Map fields) + throws Exception { + String[] keys = fields.keySet().toArray(new String[] {}); + String[] vals = fields.values().toArray(new String[] {}); + return query(session, queryName, keys, vals); + } + + public static TCComponentContextList query(TCSession session, String queryName, String[] keys, String[] vals) + throws Exception { + System.out.println("Query: " + queryName); + System.out.println("keys = " + Arrays.toString(keys)); + System.out.println("vals = " + Arrays.toString(vals)); + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + throw new Exception(String.format(KLocale.getString("querynotexist.ERROR1"), queryName)); + } + queryType.clearCache(); + query.clearCache(); + query.refresh(); + return query.getExecuteResultsList(keys, vals); + } + + public static TCComponent[] query2(TCSession session, String queryName, String[] keys, String[] vals) + throws Exception { + System.out.println("Query: " + queryName); + System.out.println("keys = " + Arrays.toString(keys)); + System.out.println("vals = " + Arrays.toString(vals)); + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + throw new Exception(String.format(KLocale.getString("querynotexist.ERROR1"), queryName)); + } + queryType.clearCache(); + query.clearCache(); + query.refresh(); + return query.execute(keys, vals); + } + + public static TCComponentContextList combineContext(TCSession session, TCComponentQuery query, + TCComponentContextList... contexts) throws Exception { + Class c = TCComponentContextList.class; + Field f1 = c.getDeclaredField("m_compUids"); + f1.setAccessible(true); + List compUids = new ArrayList<>(); + for (TCComponentContextList cc : contexts) { + String[] u1 = (String[]) f1.get(cc); + System.out.println(Arrays.toString(u1)); + compUids.addAll(Arrays.asList(u1)); + } + Constructor constructor = c.getDeclaredConstructor(TCComponentManager.class, TCComponent.class, + String[].class, String[].class, String.class); + constructor.setAccessible(true); + TCComponentContextList res = (TCComponentContextList) constructor.newInstance(new TCComponentManager(session), + query, compUids.toArray(new String[] {}), null, ""); + return res; + } + + public static int getLen(Object[] arr) { + return arr == null ? 0 : arr.length; + } + + public static String getValueInArray(String[] arr, int index) { + int len = arr == null ? 0 : arr.length; + if (index >= len) { + return ""; + } + return arr[index]; + } + + public static String getValueInArray(String arrStr, int index, String splitter) { + if (KUtil.isEmpty(arrStr)) { + return ""; + } + String[] split = arrStr.split(splitter, -1); + int len = getLen(split); + if (len > index && index >= 0) { + return split[index]; + } + return ""; + } + + public static String getTypeNames(TCSession session, Object[] types) { + int len = types == null ? 0 : types.length; + if (len == 0) { + return ""; + } + String[] names = new String[len]; + for (int i = 0; i < len; i++) { + try { + if ("TC_Project".equals(types[i].toString())) { + names[i] = KLocale.getString("project"); + } else { + names[i] = session.getTypeComponent(types[i].toString()).getDisplayTypeName(); + } + } catch (Exception e) { + e.printStackTrace(); + } + if (names[i] == null) { + names[i] = types[i].toString(); + } + } + return Arrays.toString(names); + } + + public static String getTypeName(TCSession session, String type) { + if (KUtil.isEmpty(type)) { + return ""; + } + try { + if ("TC_Project".equals(type)) { + return KLocale.getString("project"); + } else { + return session.getTypeComponent(type).getDisplayTypeName(); + } + } catch (Exception e) { + e.printStackTrace(); + } + return type; + } + + public static boolean isReleased(TCComponent comp) throws Exception { + TCComponent[] status = comp.getReferenceListProperty("release_status_list"); + if (status == null || status.length == 0) { + return false; + } + return true; + } + + public static TCComponentUser getUserFromStr(String str) throws Exception { + System.out.println("Search User: " + str); + if (KUtil.isEmpty(str)) { + return null; + } + int ind1 = str.lastIndexOf('('); + int ind2 = str.lastIndexOf(')'); + TCComponentUser user = null; + if (ind1 > 0 && ind2 > ind1) { + String userId = str.substring(ind1 + 1, ind2); + if (KUtil.isEmpty(userId)) { + System.out.println("No Id between '(' and ')'"); + user = null; + } else { + user = queryUserById(userId); + } + } else { + user = queryUserById(str); + if (user == null) { + user = queryUserByName(str); + } + } + return user; + } + + public static TCComponentUser queryUserById(String userId) throws Exception { + System.out.println("Search User By Id: " + userId); + if (KUtil.isEmpty(userId)) { + return null; + } + String queryName = "Admin - Employee Information"; + String[] keys = new String[] { KUtil.getText("UserId") }; + String[] vals = new String[] { userId }; + TCComponentContextList res = KUtil.query(KUtil.session, queryName, keys, vals); + if (res.getListCount() == 0) { + return null; + } + if (res.getListCount() > 1) { + throw new Exception(String.format(KLocale.getString("multiuserbyid.ERROR1"), userId)); + } + return (TCComponentUser) res.get(0).getComponent(); + } + + public static TCComponentUser queryUserByName(String userName) throws Exception { + System.out.println("Search User By Name: " + userName); + if (KUtil.isEmpty(userName)) { + return null; + } + String queryName = "Admin - Employee Information"; + String[] keys = new String[] { KUtil.getText("PersonName") }; + String[] vals = new String[] { userName }; + TCComponentContextList res = KUtil.query(KUtil.session, queryName, keys, vals); + if (res.getListCount() == 0) { + return null; + } + if (res.getListCount() > 1) { + throw new Exception(String.format(KLocale.getString("multiuserbyname.ERROR1"), userName)); + } + return (TCComponentUser) res.get(0).getComponent(); + } + + public static TCComponent[] getGroupMember(List privMembers) throws Exception { + if (privMembers == null) { + return null; + } + List res = new ArrayList<>(); + for (TCComponentUser user : privMembers) { + TCComponentGroupMember[] gms = user.getGroupMembers(); + int len = KUtil.getLen(gms); + for (int i = 0; i < len; i++) { + TCComponentGroupMember gm = gms[i]; + if (KUtil.isEmpty(gm.toString())) { + continue; + } + /* + * if(!gm.isActive()) { System.out.println("���Ա�ǻ�?"+gm); continue; } + */ + if (!res.contains(gm)) { + System.out.println("Add Group Member: " + gm); + res.add(gm); + } else { + System.out.println("Added: " + gm); + } + } + } + return res.toArray(new TCComponent[] {}); + } + + public static int compareWBS(String wbsCode, String wbsCode2) { + if (KUtil.isEmpty(wbsCode) && KUtil.isEmpty(wbsCode2)) { + return 0; + } + if (KUtil.isEmpty(wbsCode)) { + return -1; + } + if (KUtil.isEmpty(wbsCode2)) { + return 1; + } + String[] a = wbsCode.split("\\."); + String[] b = wbsCode2.split("\\."); + int lenA = a.length; + int lenB = b.length; + for (int i = 0; i < lenA && i < lenB; i++) { + String aa = a[i]; + String bb = b[i]; + int ai = 0; + int bi = 0; + try { + ai = Integer.parseInt(aa); + bi = Integer.parseInt(bb); + } catch (Exception e) { + e.printStackTrace(); + } + if (ai != bi) { + return ai - bi; + } + } + return lenA - lenB; + } + + public static TCComponentListOfValues getLov(String lovName) { + TCComponentListOfValuesType lovType; + try { + lovType = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValues"); + TCComponentListOfValues[] lov = lovType.find(lovName); + if (lov.length > 0) + return lov[0]; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + public static String[] getDynamicLOV(String s) { + TCComponentListOfValues lov = null; + List lovDisplayValueList = new ArrayList<>(); + lovDisplayValueList.add(""); + List lovValueList = new ArrayList<>(); + lov = TCComponentListOfValuesType.findLOVByName(s); + try { + if ("Fnd0ListOfValuesDynamic".equals(lov.getProperty("lov_type"))) { + LOVService lovService = LOVService.getService(RACUIUtil.getTCSession()); + InitialLovData input = new InitialLovData(); + LovFilterData filter = new LovFilterData(); + filter.sortPropertyName = "object_name"; + filter.order = 1; + filter.numberToReturn = 100; + filter.maxResults = 100; + + input.lov = lov; + input.filterData = filter; + LOVSearchResults result = lovService.getInitialLOVValues(input); + StringBuffer sb = new StringBuffer(); + sb.append(">>"); + for (LOVValueRow row : result.lovValues) { + Map map = row.propDisplayValues; + Map realmap = row.propInternalValues; + + for (String key : map.keySet()) { + sb.append("UID:" + row.uid + ",key:" + key + "value:" + map.get(key)[0]); + sb.append("\n"); + + lovDisplayValueList.add(map.get(key)[0]); + lovValueList.add(realmap.get(key)[0]); + } + } + } + } catch (TCException e) { + e.printStackTrace(); + } + return lovDisplayValueList.toArray(new String[lovDisplayValueList.size()]); + } + + public static String getLovValue(TCComponentListOfValues lov, String str) throws Exception { + return getLovValue(lov, str, true); + } + + public static String getLovValue(TCComponentListOfValues lov, String str, boolean translate) throws Exception { + if (lov == null || KUtil.isEmpty(str)) { + return str; + } + if (translate) { + String prefName = "LOV_TRANS_" + lov.getStringProperty(TCComponentListOfValues.PROP_LOV_NAME); + String[] prefVals = KUtil.getPrefVals(KUtil.session, prefName); + int len = KUtil.getLen(prefVals); + for (int i = 0; i < len; i++) { + String pref = prefVals[i]; + int ind = pref.indexOf('='); + if (ind > 0) { + String realVal = pref.substring(0, ind); + String disVal = pref.substring(ind + 1); + if (str.equals(realVal) || str.equals(disVal)) { + return realVal; + } + } + } + } + ListOfValuesInfo info = lov.getListOfValues(); + if (info == null) { + return str; + } + List v = info.getValues(); + int size = v == null ? 0 : v.size(); + for (int i = 0; i < size; i++) { + LovValue vv = v.get(i); + String realValue = vv.getValue() == null ? "" : vv.getValue().toString(); + if (str.equals(realValue)) { + return str; + } + String disValue = vv.getDisplayValue(); + if (str.equals(disValue)) { + return realValue; + } + } + throw new Exception(String.format(KLocale.getString("valuenotinlov.ERROR2"), lov.toString(), str)); + } + + public static String getLovDisplayableValue(TCComponentListOfValues lov, String str) throws Exception { + if (lov == null || KUtil.isEmpty(str)) { + return str; + } + ListOfValuesInfo info = lov.getListOfValues(); + if (info == null) { + return str; + } + List v = info.getValues(); + int size = v == null ? 0 : v.size(); + for (int i = 0; i < size; i++) { + LovValue vv = v.get(i); + String realValue = vv.getValue() == null ? "" : vv.getValue().toString(); + if (str.equals(realValue)) { + return vv.getDisplayValue(); + } + String disValue = vv.getDisplayValue(); + if (str.equals(disValue)) { + return str; + } + } + throw new Exception(String.format(KLocale.getString("valuenotinlov.ERROR2"), lov.toString(), str)); + } + + public static void openFile(File file) { + try { + if (file != null && file.exists()) { + Runtime.getRuntime().exec("cmd /c start /b call \"" + file.getAbsolutePath() + "\""); + } + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post(e); + } + } + + public static void importDataset(TCComponent parent, String rel, File f, String dsType, String refName) + throws Exception { + if (f == null || !f.exists() || KUtil.isEmpty(dsType) || KUtil.isEmpty(refName)) { + return; + } + TCComponentDatasetType datasetType = (TCComponentDatasetType) session.getTypeComponent(dsType); + TCComponentDataset dataset = datasetType.create(f.getName(), "", dsType); + String paths[] = { f.getAbsolutePath() }; + String refs[] = { refName }; + dataset.setFiles(paths, refs); + if (parent != null && !KUtil.isEmpty(rel)) { + parent.add(rel, dataset); + } + } + + public static void initPropMap(String propConfig, String value, Map itemPropMap, + Map itemMasterPropMap, Map revPropMap, Map revMasterPropMap) + throws Exception { + initPropMap(propConfig, value, itemPropMap, itemMasterPropMap, revPropMap, revMasterPropMap, null); + } + + public static void initPropMap(String propConfig, String value, Map itemPropMap, + Map itemMasterPropMap, Map revPropMap, Map revMasterPropMap, + Map bomlinePropMap) throws Exception { + if (KUtil.isEmpty(propConfig)) { + return; + } + String propFrom = null, propName = null; + String[] split = propConfig.split("\\."); + if (KUtil.getLen(split) == 2) { + propFrom = split[0].trim().toUpperCase(); + propName = split[1].trim(); + } + if (KUtil.isEmpty(propFrom) || KUtil.isEmpty(propName)) { + return; + } + Map target; + if ("ITEM".equals(propFrom)) { + target = itemPropMap; + System.out.println(">> ITEM PROP: " + propName + " = " + value); + } else if ("REV".equals(propFrom)) { + System.out.println(">> REV PROP: " + propName + " = " + value); + target = revPropMap; + } else if ("ITEMMASTER".equals(propFrom)) { + System.out.println(">> ITEMMASTER PROP: " + propName + " = " + value); + target = itemMasterPropMap; + } else if ("REVMASTER".equals(propFrom)) { + System.out.println(">> REVMASTER PROP: " + propName + " = " + value); + target = revMasterPropMap; + } else if ("BOMLINE".equals(propFrom)) { + System.out.println(">> BOMLINE PROP: " + propName + " = " + value); + target = bomlinePropMap; + } else { + throw new Exception(String.format(KLocale.getString("proplocationnotdefined.ERROR1"), propFrom)); + } + if (target == null) { + return; + } + target.put(propName, value); + } + + public static String getMarkedPropValue(String config, Map markedComponents) throws Exception { + return getMarkedPropValue(config, markedComponents, null); + } + + public static String getMarkedPropValue(String config, Map markedComponents, + Map> relatedComponents) throws Exception { + if (markedComponents == null || KUtil.isEmpty(config)) { + return ""; + } + StringBuilder res = new StringBuilder(); + String[] propConfigSplit = config.split("\\+"); + int len = KUtil.getLen(propConfigSplit); + for (int i = 0; i < len; i++) { + String propConfig = propConfigSplit[i]; + String propFrom = null, propName = null; + String defaultValue = ""; + String[] split = propConfig.split("\\."); + if (KUtil.getLen(split) >= 2) { + propFrom = split[0].trim().toUpperCase(); + propName = split[1].trim(); + } + if (KUtil.getLen(split) >= 3) { + defaultValue = split[2].trim(); + } + if (KUtil.isEmpty(propFrom) || KUtil.isEmpty(propName)) { + if (propConfig.contains("\\n")) { + propConfig = propConfig.replace("\\n", "\n"); + } + res.append(propConfig); + continue; + } + if (!markedComponents.containsKey(propFrom)) { + if (propFrom.startsWith("T")) { + return ""; + } + continue; + } + TCComponent comp = markedComponents.get(propFrom); + // λ.-[-ӷ] + int ind = propName.indexOf('-'); + if (ind > 0) { + String tableProp = propName.substring(0, ind).trim(); + String tableRowProp = propName.substring(ind + 1).trim(); + if (!KUtil.isEmpty(tableProp) && !KUtil.isEmpty(tableRowProp)) { + TCProperty prop = comp.getTCProperty(tableProp.trim()); + if (prop == null) { + throw new Exception(String.format(KLocale.getString("propnotdefinedintype.ERROR2"), + comp.getType(), propName)); + } + String rowSplitter = "#ROW#"; + ind = tableRowProp.indexOf('-'); + if (ind > 0) { + rowSplitter = tableRowProp.substring(ind + 1); + tableRowProp = tableRowProp.substring(0, ind); + } + TCComponent[] tableRows = prop.getReferenceValueArray(); + int rowCnt = KUtil.getLen(tableRows); + String[] value = new String[rowCnt]; + for (int j = 0; j < rowCnt; j++) { + value[j] = tableRows[j].getPropertyDisplayableValue(tableRowProp); + } + res.append(String.join(rowSplitter, value)); + } + continue; + } + TCProperty prop = comp.getTCProperty(propName.trim()); + if (prop == null) { + throw new Exception( + String.format(KLocale.getString("propnotdefinedintype.ERROR2"), comp.getType(), propName)); + } + String value = prop.getDisplayableValue(); + if ("NAME".equalsIgnoreCase(defaultValue)) { + value = prop.getPropertyDisplayName(); + } else if (value == null || "".equals(value)) { + value = defaultValue; + } + res.append(value); + } + return res.toString(); + } + + public static TCComponent getLatestComponent(List comps) { + int size = comps == null ? 0 : comps.size(); + if (size == 0) { + return null; + } + if (size == 1) { + return comps.get(0); + } + TCComponent res = comps.get(0); + try { + Date maxDate = res.getDateProperty("creation_date"); + for (int i = 1; i < size; i++) { + TCComponent temp = comps.get(i); + Date tempDate = temp.getDateProperty("creation_date"); + if (tempDate.after(maxDate)) { + maxDate = tempDate; + res = temp; + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return res; + } + + public static TCComponentType[] getComponentTypes(String itemTypeName) throws Exception { + TCComponentItemType itemType = null; + try { + itemType = (TCComponentItemType) session.getTypeComponent(itemTypeName); + } catch (Exception e) { + e.printStackTrace(); + } + if (itemType == null) { + throw new Exception(String.format(KLocale.getString("typenotfound.ERROR1"), itemTypeName)); + } + TCComponentItemRevisionType revType = itemType.getItemRevisionType(); + if (revType == null) { + throw new Exception(String.format(KLocale.getString("typenotfound.ERROR1"), itemTypeName + "Revision")); + } + TCComponentType itemMasterType = null; + try { + itemMasterType = session.getTypeComponent(itemTypeName + "Master"); + } catch (Exception e) { + e.printStackTrace(); + } + if (itemMasterType == null) { + try { + itemMasterType = session.getTypeComponent(itemTypeName + " Master"); + } catch (Exception e) { + e.printStackTrace(); + } + } + if (itemMasterType == null) { + throw new Exception(String.format(KLocale.getString("typenotfound.ERROR1"), itemTypeName + "Master")); + } + TCComponentType revMasterType = null; + try { + revMasterType = session.getTypeComponent(revType.getTypeName() + "Master"); + } catch (Exception e) { + e.printStackTrace(); + } + if (revMasterType == null) { + try { + revMasterType = session.getTypeComponent(revType.getTypeName() + " Master"); + } catch (Exception e) { + e.printStackTrace(); + } + } + if (revMasterType == null) { + throw new Exception( + String.format(KLocale.getString("typenotfound.ERROR1"), revType.getTypeName() + "Master")); + } + return new TCComponentType[] { itemType, revType, itemMasterType, revMasterType }; + } + + public static String getPropertyDisplayName(TCComponentType type, String propName) throws Exception { + if (type == null || KUtil.isEmpty(propName)) { + return propName; + } + TCPropertyDescriptor desc = type.getPropDesc(propName); + if (desc == null) { + throw new Exception(String.format(KLocale.getString("propnotdefinedintype.ERROR2"), + type.getDisplayTypeName(), propName)); + } + return desc.getDisplayName(); + } + + public static String getConfigPropValue(TCComponentItemRevision rev, String propConfigStr) throws Exception { + if (rev == null || KUtil.isEmpty(propConfigStr)) { + return ""; + } + StringBuilder res = new StringBuilder(); + String[] propConfigSplit = propConfigStr.split("\\+"); + int len = KUtil.getLen(propConfigSplit); + for (int i = 0; i < len; i++) { + String propConfig = propConfigSplit[i]; + String propFrom = null, propName = null; + String[] split = propConfig.split("\\."); + if (KUtil.getLen(split) == 2) { + propFrom = split[0].trim().toUpperCase(); + propName = split[1].trim(); + } + if (KUtil.isEmpty(propFrom) || KUtil.isEmpty(propName)) { + res.append(propConfig); + continue; + } + TCComponent target; + if ("ITEM".equals(propFrom)) { + target = rev.getItem(); + } else if ("REV".equals(propFrom)) { + target = rev; + } else if ("ITEMMASTER".equals(propFrom)) { + target = rev.getItem().getRelatedComponent("IMAN_master_form"); + } else if ("REVMASTER".equals(propFrom)) { + target = rev.getRelatedComponent("IMAN_master_form_rev"); + } else { + throw new Exception(String.format(KLocale.getString("proplocationnotdefined.ERROR1"), propFrom)); + } + TCProperty prop = target.getTCProperty(propName.trim()); + if (prop == null) { + throw new Exception( + String.format(KLocale.getString("propnotdefinedintype.ERROR2"), target.getType(), propName)); + } + res.append(prop.getStringValue()); + } + return res.toString(); + } + + public static String getConfigPropDisplayableValue(TCComponentItemRevision rev, String propConfigStr) + throws Exception { + if (rev == null || KUtil.isEmpty(propConfigStr)) { + return ""; + } + StringBuilder res = new StringBuilder(); + String[] propConfigSplit = propConfigStr.split("\\+"); + int len = KUtil.getLen(propConfigSplit); + for (int i = 0; i < len; i++) { + String propConfig = propConfigSplit[i]; + String propFrom = null, propName = null; + String[] split = propConfig.split("\\."); + if (KUtil.getLen(split) == 2) { + propFrom = split[0].trim().toUpperCase(); + propName = split[1].trim(); + } + if (KUtil.isEmpty(propFrom) || KUtil.isEmpty(propName)) { + res.append(propConfig); + continue; + } + TCComponent target; + if ("ITEM".equals(propFrom)) { + target = rev.getItem(); + } else if ("REV".equals(propFrom)) { + target = rev; + } else if ("ITEMMASTER".equals(propFrom)) { + target = rev.getItem().getRelatedComponent("IMAN_master_form"); + } else if ("REVMASTER".equals(propFrom)) { + target = rev.getRelatedComponent("IMAN_master_form_rev"); + } else { + throw new Exception(String.format(KLocale.getString("proplocationnotdefined.ERROR1"), propFrom)); + } + TCProperty prop = target.getTCProperty(propName.trim()); + if (prop == null) { + throw new Exception( + String.format(KLocale.getString("propnotdefinedintype.ERROR2"), target.getType(), propName)); + } + res.append(prop.getDisplayableValue()); + } + return res.toString(); + } + + public static void removeAllParents(DataManagementService dm, TCComponent comp) throws Exception { + comp.refresh(); + System.out.println("Remove from parent: " + comp); + WhereReferencedResponse refResp = dm.whereReferenced(new TCComponent[] { comp }, 1); + KUtil.throwServiceDataError(refResp.serviceData); + int len = KUtil.getLen(refResp.output); + List datas = new ArrayList(); + for (int i = 0; i < len; i++) { + WhereReferencedOutput ref = refResp.output[i]; + int cnt = KUtil.getLen(ref.info); + for (int j = 0; j < cnt; j++) { + WhereReferencedInfo info = ref.info[j]; + Relationship data = new Relationship(); + data.primaryObject = info.referencer; + data.secondaryObject = comp; + data.relationType = info.relation; + System.out.println(">> " + info.relation + " | " + info.referencer); + datas.add(data); + } + } + ServiceData resp = dm.deleteRelations(datas.toArray(new Relationship[] {})); + KUtil.throwServiceDataError(resp); + } + + public static TCComponent newTableRow(DataManagementService dmService, String type, + Map rowStringProps, Map rowDateProps) throws Exception { + CreateIn rowIn = new CreateIn(); + CreateInput rowInput = new CreateInput(); + rowInput.boName = type; + if (rowStringProps != null) { + rowInput.stringProps = rowStringProps; + } + if (rowDateProps != null) { + rowInput.dateProps = rowDateProps; + } + rowIn.data = rowInput; + CreateResponse res = dmService.createObjects(new CreateIn[] { rowIn }); + KUtil.throwServiceDataError(res.serviceData); + if (res.serviceData.sizeOfCreatedObjects() > 0) { + return res.serviceData.getCreatedObject(0); + } + return null; + } + + public static Date addDay(Date day, int cnt) { + if (day == null) { + return null; + } + Calendar c = Calendar.getInstance(); + c.setTime(day); + c.add(Calendar.DATE, cnt); + return c.getTime(); + } + + public static Date calTime(TCCalendar calendar, Date date, int minutes) { + if (calendar == null || date == null) { + return null; + } + int diff = minutes > 0 ? 1 : -1; + if (minutes < 0) { + minutes = -minutes; + } + Calendar c = Calendar.getInstance(); + c.setTime(date); + int counter = 0; + while (counter < minutes) { + counter += calendar.getMinutesOnDay(c); + c.add(Calendar.DATE, diff); + } + return c.getTime(); + } + + public static int getMinutesBetween(TCCalendar calendar, Date start, Date end) { + if (calendar == null || start == null || end == null) { + return 0; + } + Calendar c = Calendar.getInstance(); + c.setTime(start); + int res = 0; + while (c.getTime().before(end)) { + res += calendar.getMinutesOnDay(c); + // System.out.println(calendar.getMinutesOnDay(c)+" > "+c.getTime()); + c.add(Calendar.DATE, 1); + } + return res; + } + + public static TCComponentTCCalendar getScheduleCalendar(TCComponentSchedule schedule) throws Exception { + if (schedule == null) { + return null; + } + return CalendarHelper.getScheduleCalendar(schedule, session); + } + + public static void dealSpecialModelValue(ArrayList specialList, String prefName, String prop, int ind) { + int index = 0; + + try { + String[] prefVals = KUtil.getPrefVals(session, prefName); + String puid = prefVals[ind]; + TCComponent component = session.stringToComponent(puid); + if (component instanceof TCComponentForm) { + + TCComponentForm form = (TCComponentForm) component; + + TCComponent[] tables = form.getReferenceListProperty("ld6_ChangeTable"); + for (int j = 0; j < tables.length; j++) { + + String change = tables[j].getStringProperty(prop); + if (change.equals("")) { + specialList.add(j); + } + } + + } + +// +// Set>> entrySet = map.entrySet(); +// for (Entry> entry : entrySet) { +// ArrayList list = entry.getValue(); +// String value = list.get(2); +// System.out.println("ǰֵΪ" + value); +// if(value != null && value.equals("")) { +// specialList.add(index); +// } +// index++; +// } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + /** + * õģֵ + * + * @param map + * @throws Exception + */ +// public static void getModelVale(LinkedHashMap> map,String prefName,int index) throws Exception { +// AbstractAIFApplication application = AIFUtility.getCurrentApplication(); +// TCSession session = (TCSession) application.getSession(); +// String[] prefVals = KUtil.getPrefVals(session, prefName); +// String puid = prefVals[index]; +// TCComponentDataset component = (TCComponentDataset) session.stringToComponent(puid); +// TCComponentTcFile[] tcFiles = component.getTcFiles(); +// File datasetFile = null; +// String name = ""; +// if (tcFiles != null && tcFiles.length != 0) { +// TCComponentTcFile tcComponentTcFile = tcFiles[0]; +// File fmsFile = tcComponentTcFile.getFmsFile(); +// name = tcComponentTcFile.getStringProperty("original_file_name"); +// datasetFile = new File(System.getenv("TEMP")+"\\"+name); +// FileUtility.copyFile(fmsFile, datasetFile); +// +// } +// XSSFWorkbook wb = new XSSFWorkbook(new FileInputStream(datasetFile)); +// XSSFSheet sheet = wb.getSheetAt(0); +// for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) { +// XSSFRow row = sheet.getRow(i); +// for (int j = 0; j < 5; j++) { +// XSSFCell cell = row.getCell(j); +// if(cell != null) { +// String cellValue = KUtil.getCellValue(cell); +// if(j == 0 && cellValue.isEmpty()) { +// break; +// } +// if(j == 0 ) { +// if(map.containsKey(cellValue)) { +// break; +// }else { +// map.put(cellValue, null); +// } +// }else { +// String key = KUtil.getCellValue(row.getCell(0)); +// ArrayList arrayList = map.get(key); +// if(arrayList != null) { +// arrayList.add(cellValue); +// }else { +// ArrayList list = new ArrayList(); +// list.add(cellValue); +// map.put(key, list); +// } +// } +// +// } +// } +// } +// wb.close(); +// datasetFile.delete(); +// } + /** + * õģֵ + * + * @param map + * @throws Exception + */ + public static void getModelVale(LinkedHashMap> map, TCComponent forms, + ArrayList specialList, String[] propNames) throws Exception { +// AbstractAIFApplication application = AIFUtility.getCurrentApplication(); +// TCSession session = (TCSession) application.getSession(); +// String[] prefVals = KUtil.getPrefVals(session, prefName); +// String puid = prefVals[index]; +// TCComponent component = session.stringToComponent(puid); + int t = 1; + if (forms instanceof TCComponentForm) { + + TCComponentForm form = (TCComponentForm) forms; + TCComponent[] tables = form.getReferenceListProperty("ld6_ChangeTable"); + for (int j = 0; j < tables.length; j++) { + ArrayList tableValue = new ArrayList(); + + for (String propName : propNames) { + System.out.println("ǰΪ" + propName); + String prop = tables[j].getTCProperty(propName).getDisplayableValue(); + if (propName.equals("ld6_YNChange") && prop.equals("")) { +// specialList.add(j); + } + tableValue.add(prop == null ? "" : prop.trim()); + } + + map.put(String.valueOf(t), tableValue); +// tableValue + + t = t + 1; + } + + } + + } + + /** + * õlovʵֵʾֵ + * + * @param lovMap + * @param comboBox + * @throws TCException + */ + public static void getLov(HashMap lovMap, String lovName, JComboBox comboBox) + throws TCException { + if (comboBox != null) { + comboBox.addItem(""); + } +// for (LovValue lovV : lovValueList) { +// map.put(lovV.getDisplayValue(), lovV.getStringValue()); +// comboBox.addItem(lovV.getDisplayValue()); +// System.out.println(lovV.getDisplayValue() + "===" + lovV.getStringValue()); +// } + + TCComponentListOfValues lov = TCComponentListOfValuesType.findLOVByName(lovName); + if ("Fnd0ListOfValuesDynamic".equals(lov.getProperty("lov_type"))) { + System.out.println("̬lovName=" + lovName); + LOVService lovService = LOVService.getService(RACUIUtil.getTCSession()); + InitialLovData input = new InitialLovData(); + LovFilterData filter = new LovFilterData(); + if ("LD6_TecDoc_TypeLOV".equals(lovName)) { + filter.sortPropertyName = "fnd0StringValues"; // lovĺֵ̨ + } else { + filter.sortPropertyName = "object_name"; // lovĺֵ̨ + } + + filter.order = 1; + filter.numberToReturn = 2000; + filter.maxResults = 2000; + + input.lov = lov; + input.filterData = filter; + LOVSearchResults result = lovService.getInitialLOVValues(input); + // System.out.println("111==="+result.toString()); + + for (LOVValueRow row : result.lovValues) { + Map map = row.propDisplayValues; + Map realmap = row.propInternalValues; +// for (String key : map.keySet()) { +// System.out.println("key=" + key + ",value=" + map.get(key)[0]); +// } +// for (String key : realmap.keySet()) { +// System.out.println("key2=" + key + ",value2=" + map.get(key)[0]); +// } + String disval = ""; + String val = ""; + String key1 = "object_name";// ʵֵ ʾֵһ + if ("LD6_TecDoc_TypeLOV".equals(lovName)) { + key1 = "fnd0StringValues"; // lovĺֵ̨ + } + // String key2 = "object_desc";// ʾֵڶ + if (map.containsKey(key1)) { + val = realmap.get(key1)[0]; + disval = map.get(key1)[0]; + } + if (!val.equals("")) { + lovMap.put(disval, val); + if (comboBox != null) { + comboBox.addItem(disval); + } + } + + } + + } else { + ListOfValuesInfo info = lov.getListOfValues(); + info.getLOVDisplayValues(); + List lovValueList = info.getValues(); + for (LovValue lovV : lovValueList) { + lovMap.put(lovV.getDisplayValue(), lovV.getStringValue()); + if (comboBox != null) { + comboBox.addItem(lovV.getDisplayValue()); + } + } + } + + } + +// public static void dealPref(String[] prefVals, InterfaceAIFComponent targetComponent, +// ArrayList beanList, StringBuffer newTypeBuffer) throws Exception { +// /** +// * LD6_PRRevision/LD6_CR|*[string]Item.item_id=; +// * *[string]Item.object_name=;*[string]Rev.ld6_processNum=;*[string]Rev.ld6_productNum=Rev.ld6_proNum +// */ +// String type = targetComponent.getType(); +// TCComponentItemRevision rev = (TCComponentItemRevision) targetComponent; +// for (String string : prefVals) { +// String[] split = string.split("\\|"); +// if (split.length == 2) { +// String[] split2 = split[0].split("/"); +// if (split2.length == 2 && type.equals(split2[0])) { +// // õ +// newTypeBuffer.append(split2[1]); +// // õĿؼ +// String[] split3 = split[1].split(";"); +// for (int i = 0; i < split3.length; i++) { +// ControlBean bean = new ControlBean(); +// if (split3[i].contains("*[")) { +// bean.setIfMust(true); +// } +// String[] split4 = split3[i].split("="); +// // жʲô͵ +// if (split4[0].contains("boolean")) { +// bean.setPropType("boolean"); +// } else if (split4[0].contains("date")) { +// bean.setPropType("date"); +// } else if (split4[0].contains("string:")) { +// bean.setPropType("lov"); +// } else if (split4[0].contains("string") && !split4[0].contains("string:")) { +// bean.setPropType("string"); +// } +// if (split4.length == 2) { +// bean.setDefaultValue(getTCPropertyValue(rev, split4[1], bean)); +// } +// String[] split5 = split4[0].split("]"); +// if (split5.length == 2) { +// String[] split6 = split5[1].split("\\."); +// bean.setPropTo(split6[0]); +// bean.setPropRelName(split6[1]); +// bean.setPropName(split6[2]); +// if ("lov".equals(bean.getPropType())) { +// // õlovlovMap +// String[] split7 = split5[0].split(":"); +// String lovName = split7[1]; +// HashMap lovMap = new LinkedHashMap(); +// // JComboBox combox = new JComboBox(); +// try { +// String desType = newTypeBuffer.toString(); +// if ("Rev".equals(bean.getPropTo())) { +// desType = desType + "Revision"; +// } else if ("Form".equals(bean.getPropTo())) { +// desType = desType + "RevisionMaster"; +// } +// TCComponentType localTCComponentType = session.getTypeComponent(desType); +// TCPropertyDescriptor descriptor = localTCComponentType +// .getPropertyDescriptor(bean.getPropRelName()); +// LOVDisplayer combo = new LOVDisplayer(descriptor); +// getLov(lovMap, lovName, null); +// bean.setCombox(combo); +// } catch (TCException e) { +// e.printStackTrace(); +// } +// bean.setLovMap(lovMap); +// // bean.setCombox(combox); +// } +// } +// beanList.add(bean); +// } +// break; +// } +// } +// } +// } + +// public static String getTCPropertyValue(TCComponentItemRevision rev, String specialValue, ControlBean bean) { +// try { +// String[] split = specialValue.split("\\."); +// TCComponent center = null; +// if (split.length == 2 || split.length == 3) { +// switch (split[0]) { +// case "Rev": +// center = rev; +// break; +// case "Item": +// center = rev.getItem(); +// break; +// case "Form": +// center = rev.getRelatedComponent("IMAN_master_form_rev"); +// break; +// default: +// break; +// } +// String value = ""; +// if ("date".equals(bean.getPropType())) { +// System.out.println("ǰʵΪ" + split[1]); +// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-dd HH:mm"); +// if (center.getDateProperty(split[1]) != null) { +// value = sdf.format(center.getDateProperty(split[1])); +// } +// } else { +// value = center.getStringProperty(split[1]); +// } +// if (split.length == 3) { +// bean.setPropName(split[2]); +// } +// return value; +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } +// return ""; +// } +} diff --git a/src/com/langtech/plm/tqsx/PropertyToWordOrExcelCommand.java b/src/com/langtech/plm/tqsx/PropertyToWordOrExcelCommand.java new file mode 100644 index 0000000..7d7e7d6 --- /dev/null +++ b/src/com/langtech/plm/tqsx/PropertyToWordOrExcelCommand.java @@ -0,0 +1,66 @@ +package com.langtech.plm.tqsx; + +import java.io.File; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; + + + +public class PropertyToWordOrExcelCommand extends KCommand{ + + final String preName = "Connor_LY6_WordExcel_Report_ItemType"; + + public PropertyToWordOrExcelCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + TCSession session = (TCSession) app.getSession(); + this.setRunnable(new PropertyToWordOrExcelOperation(app, "ȡ汾ԵWord Excel")); +// InterfaceAIFComponent targetComponent = app.getTargetComponent(); +// TCComponentItemRevision revision = (TCComponentItemRevision) targetComponent; +// try { +// String[] prefVals = KUtil.getPrefVals(session, preName); +// if(prefVals == null || prefVals.length == 0) { +// KUtil.info(AIFDesktop.getActiveDesktop(), preName + "ѡδãϵԱ"); +// return ; +// } +// String relatioin = prefVals[0]; +// TCComponent[] relatedComponents = revision.getRelatedComponents(relatioin); +// if(relatedComponents == null || relatedComponents.length == 0) { +// KUtil.info(AIFDesktop.getActiveDesktop(), "ѡж " + relatioin + " ϵûݼ"); +// return ; +// } +// for (TCComponent tcComponent : relatedComponents) { +// if (tcComponent instanceof TCComponentDataset) { +// TCComponentDataset dataset = (TCComponentDataset) tcComponent; +// File datasetFile = KUtil.getDatasetFile(dataset); +// System.out.println(); +// String type = tcComponent.getType(); +// switch (type) { +// case "MSExcel": +// +// break; +// case "MSExcelX": +// +// break; +// case "MSWord": +// +// break; +// case "MSWordX": +// +// break; +// } +// } +// } +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } + + } + +} diff --git a/src/com/langtech/plm/tqsx/PropertyToWordOrExcelOperation.java b/src/com/langtech/plm/tqsx/PropertyToWordOrExcelOperation.java new file mode 100644 index 0000000..d416de9 --- /dev/null +++ b/src/com/langtech/plm/tqsx/PropertyToWordOrExcelOperation.java @@ -0,0 +1,349 @@ +package com.langtech.plm.tqsx; + +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.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.hssf.usermodel.HSSFName; +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.util.CellReference; +import org.apache.poi.xssf.usermodel.XSSFCell; +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.aspose.words.Bookmark; +import com.aspose.words.Document; +import com.aspose.words.Field; +import com.aspose.words.SaveFormat; +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AbstractAIFSession; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.util.FileUtility; + + + +public class PropertyToWordOrExcelOperation extends KOperation { + + public PropertyToWordOrExcelOperation(AbstractAIFApplication app, String opName) { + super(app, opName, "ִС"); + } + + String preName = "Connor_LY6_WordExcel_Report_"; + + @Override + public boolean init() throws Exception { + new Thread().sleep(1000); + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + TCComponentItemRevision revision = (TCComponentItemRevision) targetComponent; + String revType = revision.getType(); + preName = preName + revType; + // ȡѡֵ + String[] prefVals = KUtil.getPrefVals(session, preName); + if(prefVals == null || prefVals.length == 0) { + KUtil.info(AIFDesktop.getActiveDesktop(), preName + "ѡδãϵԱ"); + return false; + } + String relatioin = prefVals[0]; + + // ȡ汾µݼ + TCComponent[] relatedComponents = revision.getRelatedComponents(relatioin); + if(relatedComponents == null || relatedComponents.length == 0) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ѡж " + relatioin + " ϵûݼ"); + return false; + } + //ѡ + HashMap nameMap = new HashMap();//ݼƺͶ(item,rev,revMaster) + if(prefVals.length >= 2) { + for (int i = 1; i < prefVals.length; i++) { + //Item.object_name=object_name + String[] split = prefVals[i].split("="); + nameMap.put(split[1],split[0]); + } + } + + // ݼ + for (TCComponent tcComponent : relatedComponents) { + if (tcComponent instanceof TCComponentDataset) { + TCComponentDataset dataset = (TCComponentDataset) tcComponent; + // ߰лȡϵͳʱ· + File datasetFile = KUtil.getDatasetFile(dataset); + String type = tcComponent.getType(); + String datasetType = ""; + String newPath = ""; + if("MSExcel".equals(type) || "MSExcelX".equals(type) || "MSWord".equals(type) || "MSWordX".equals(type)) { + switch (type) { + case "MSExcel": + datasetType = "excel"; + newPath = dealExcel(datasetFile,revision,nameMap); + break; + case "MSExcelX": + datasetType = "excel"; + newPath = dealExcelX(datasetFile,revision,nameMap); + break; + case "MSWord": + datasetType = "word"; + newPath = dealWord2(datasetFile,revision,nameMap,"doc"); + break; + case "MSWordX": + datasetType = "word"; + newPath = dealWord2(datasetFile,revision,nameMap,"docx"); + break; + } + //ݼµ + dataset.setFiles(new String[] {newPath}, new String[] {datasetType}); + } + } + } + KUtil.info(AIFDesktop.getActiveDesktop(), "ȡ汾ԵWord Excelִ"); + return true; + } + + @Override + public void execute() throws Exception { + + } + + private String dealExcel(File datasetFile, TCComponentItemRevision revision, HashMap nameMap) throws IOException, TCException { + FileInputStream is = new FileInputStream(datasetFile); + HSSFWorkbook workbook = new HSSFWorkbook(is); + List allNames = workbook.getAllNames(); + for (HSSFName hssfName : allNames) { + String name = hssfName.getNameName(); + //ƹѡ + if (nameMap.containsKey(name)) { + CellReference cellReference = new CellReference(hssfName.getRefersToFormula()); + HSSFSheet sheet = workbook.getSheet(cellReference.getSheetName()); + HSSFRow row = sheet.getRow(cellReference.getRow()); + HSSFCell cell = row.getCell(cellReference.getCol()); + String preConfigValue = getPreConfigValue(revision,nameMap,nameMap.get(name)); + System.out.println("Ϊ" + cellReference.getRow() + "====" + "Ϊ" + cellReference.getCol() + "====" + + "ֵΪ " + preConfigValue); + if(cell == null) { + cell = row.createCell(cellReference.getCol()); + } + cell.setCellValue(preConfigValue); + + } + } + is.close(); + FileOutputStream os = new FileOutputStream(datasetFile); + workbook.write(os); + workbook.close(); + return datasetFile.getAbsolutePath(); + } + + private String dealExcelX(File datasetFile, TCComponentItemRevision revision, HashMap nameMap) throws IOException, TCException { + FileInputStream is = new FileInputStream(datasetFile); + XSSFWorkbook workbook = new XSSFWorkbook(is); + List allNames = workbook.getAllNames(); + for (XSSFName xssfName : allNames) { + String name = xssfName.getNameName(); + //ƹѡ + if (nameMap.containsKey(name)) { + CellReference cellReference = new CellReference(xssfName.getRefersToFormula()); + XSSFSheet sheet = workbook.getSheet(cellReference.getSheetName()); + XSSFRow row = sheet.getRow(cellReference.getRow()); + XSSFCell cell = row.getCell(cellReference.getCol()); + String preConfigValue = getPreConfigValue(revision,nameMap,nameMap.get(name)); + System.out.println("Ϊ" + cellReference.getRow() + "====" + "Ϊ" + cellReference.getCol() + "====" + + "ֵΪ " + preConfigValue); + if(cell == null) { + cell = row.createCell(cellReference.getCol()); + cell.setCellValue(preConfigValue); + } + else { + cell.setCellValue(preConfigValue); + } + } + } + is.close(); + FileOutputStream os = new FileOutputStream(datasetFile); + workbook.write(os); + workbook.close(); + return datasetFile.getAbsolutePath(); + } + + private String dealWord(File datasetFile, TCComponentItemRevision revision, HashMap nameMap,String type) throws IOException, TCException { + String path = datasetFile.getAbsolutePath(); + InputStream inputStream = Files.newInputStream(Paths.get(path)); + Map dataMap = new HashMap<>(); + for(String key : nameMap.keySet()) { + String preConfigValue = getPreConfigValue(revision,nameMap,nameMap.get(key)); + dataMap.put(key, preConfigValue); + } + String newPath = ""; + if(type.equals("doc")) { + newPath = path.replace(".doc", "temp.doc"); + WordUtils.replaceBookmarksByDoc(inputStream, Files.newOutputStream(Paths.get(newPath)), dataMap); + } + else if(type.equals("docx")) { + newPath = path.replace(".docx", "temp.docx"); + WordUtils.replaceBookmarksByDocx(inputStream, Files.newOutputStream(Paths.get(newPath)), dataMap); + } + return newPath; + } + + private String dealWord2(File datasetFile, TCComponentItemRevision revision, HashMap nameMap,String type) throws FileNotFoundException, Exception { + String path = datasetFile.getAbsolutePath(); + + Document document2 = new Document(new FileInputStream(path)); + OutputStream outputStream = null; + String newPath = path.replace(".doc", "temp.doc"); + outputStream = new FileOutputStream(newPath); + Map dataMap = new HashMap<>(); + + for(String key : nameMap.keySet()) { + String preConfigValue = getPreConfigValue(revision,nameMap,nameMap.get(key)); + + System.out.println("dataMap("+key+","+preConfigValue+")"); + dataMap.put(key, preConfigValue); + } + // ĵеǩ + for (Bookmark bookmark : document2.getRange().getBookmarks()) { + String bookmarkName = bookmark.getName(); + System.out.println("ǩ"+bookmarkName); + if(dataMap.containsKey(bookmarkName)) + { + System.out.println(""); + bookmark.setText(dataMap.get(bookmarkName)); + } + } + + // ĵе + for (Field field : document2.getRange().getFields()) { + // ȡ + String fieldName = field.getFieldCode(); + System.out.println("" + fieldName); + + for(String key : dataMap.keySet()) { + // ֶͻֵ + if(fieldName.contains(key)) {// 봦 + System.out.println(""); + field.setResult(dataMap.get(key)); // ֵ + } + } + } + if(type.equals("doc")) { + document2.save(outputStream, SaveFormat.DOC); + }else if(type.equals("docx")) { + document2.save(outputStream, SaveFormat.DOCX); + } + return newPath; + } + + /** + * õѡС=߶Ӧֵ + * @param revision + * @param nameMap + * @param value + * @return + * @throws TCException + */ + private String getPreConfigValue(TCComponentItemRevision revision, HashMap nameMap,String value) throws TCException { + String[] split = value.split("\\."); + String cellValue = ""; + TCProperty property = null; + if(split.length == 2) { + switch (split[0]) { + case "Item": + property = revision.getItem().getTCProperty(split[1]); + break; + case "Rev": + property = revision.getTCProperty(split[1]); + break; + case "RevMaster": + property = revision.getRelatedComponent("IMAN_master_form_rev").getTCProperty(split[1]); + break; + default: + break; + } + } + //ȡϵļµ + else if(split.length == 3) { + String relation = split[0]; + TCComponent relatedComponent = revision.getRelatedComponent(relation); + TCComponentItemRevision centerRev = null; + if(relatedComponent instanceof TCComponentItemRevision) { + centerRev = (TCComponentItemRevision) relatedComponent; + }else if(relatedComponent instanceof TCComponentItem) { + centerRev = ((TCComponentItem) relatedComponent).getLatestItemRevision(); + } + if(centerRev != null) { + switch (split[1]) { + case "Item": + property = centerRev.getItem().getTCProperty(split[2]); + break; + case "Rev": + property = centerRev.getTCProperty(split[2]); + break; + case "RevMaster": + property = centerRev.getRelatedComponent("IMAN_master_form_rev").getTCProperty(split[2]); + break; + default: + break; + } + } + } + if(property == null) { + return ""; + } + else { + cellValue = property.getDisplayValue(); + cellValue = formatDateString(cellValue); + return cellValue; + } + } + + + public static String formatDateString(String input) { + // ֿܵʱʽ + SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + // Ŀʽ + SimpleDateFormat targetFormat = new SimpleDateFormat("yyyy-MM-dd"); + + try { + // Խһָʽ + Date date = format1.parse(input); + // ɹĿʽַ + return targetFormat.format(date); + } catch (ParseException e1) { + try { + // Խڶָʽ + Date date = format2.parse(input); + // ɹĿʽַ + return targetFormat.format(date); + } catch (ParseException e2) { + // ָʽƥ䣬ԭʼַ + return input; + } + } + } + + +} diff --git a/src/com/langtech/plm/tqsx/WordUtils.java b/src/com/langtech/plm/tqsx/WordUtils.java new file mode 100644 index 0000000..c8b7f82 --- /dev/null +++ b/src/com/langtech/plm/tqsx/WordUtils.java @@ -0,0 +1,167 @@ +package com.langtech.plm.tqsx; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.poi.hwpf.HWPFDocument; +import org.apache.poi.hwpf.usermodel.Bookmark; +import org.apache.poi.hwpf.usermodel.Bookmarks; +import org.apache.poi.hwpf.usermodel.Range; +import org.apache.poi.xwpf.usermodel.XWPFDocument; +import org.apache.poi.xwpf.usermodel.XWPFParagraph; +import org.apache.poi.xwpf.usermodel.XWPFRun; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBookmark; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP; +import org.w3c.dom.Node; + +public class WordUtils { + + public static final String RUN_NODE_NAME = "w:r"; + public static final String TEXT_NODE_NAME = "w:t"; + public static final String BOOKMARK_START_TAG = "w:bookmarkStart"; + public static final String BOOKMARK_END_TAG = "w:bookmarkEnd"; + public static final String BOOKMARK_ID_ATTR_NAME = "w:id"; + public static final String STYLE_NODE_NAME = "w:rPr"; + + public static void main(String[] args) throws IOException { + // 滻ļе bookmark + InputStream inputStream3 = Files.newInputStream(Paths.get("C:\\Users\\Administrator\\Desktop\\ļ\\22.doc")); + Map dataMap = new HashMap<>(); + dataMap.put("one", "oneoneoneoneone"); + dataMap.put("two", "twotwotwotwo"); + dataMap.put("three", "ceshi"); + replaceBookmarksByDoc(inputStream3, Files.newOutputStream(Paths.get("C:\\Users\\Administrator\\Desktop\\ļ\\33.doc")), dataMap); + } + + /** + * ȡ doc ļеǩ + * + * @param inputStream + * @throws IOException + */ + public static void getBookmarksByDoc(InputStream inputStream) throws IOException { + HWPFDocument wordDoc = new HWPFDocument(inputStream); + + Bookmarks bookmarks = wordDoc.getBookmarks(); + + for (int b = 0; b < bookmarks.getBookmarksCount(); b++) { + Bookmark bookmark = bookmarks.getBookmark(b); + String bookMarkText = new Range(bookmark.getStart(), bookmark.getEnd(), wordDoc).text(); + + System.out.println("[" + bookmark.getStart() + "; " + + bookmark.getEnd() + "]: " + bookmark.getName() + " = " + bookMarkText); + } + + } + + /** + * ȡ docx ļеǩ + * + * @param inputStream + * @throws IOException + */ + public static void getBookmarksByDocx(InputStream inputStream) throws IOException { + XWPFDocument docx = new XWPFDocument(inputStream); + + List paragraphList = docx.getParagraphs(); + for (XWPFParagraph xwpfParagraph : paragraphList) { + CTP ctp = xwpfParagraph.getCTP(); + + for (int dwI = 0; dwI < ctp.sizeOfBookmarkStartArray(); dwI++) { + CTBookmark bookmark = ctp.getBookmarkStartArray(dwI); + String bookmarkName = bookmark.getName(); + + // Ϊ docx Ľṹxmlʽ doc ĵоstartendֵλһbookmarkֵΧ + // Ҫȡ docx ĵbookmarkݣҪ bookmarkStart ڵ㿪ʼνxml + // nodeValue ֵƴӣֱȡһΪ bookmarkEnd ĽڵΪֹ + // getBookmarkTextContent() һûʵֵķҪʵ + // String bookmarkTextContent = getBookmarkTextContent(bookmark); + + System.out.println(bookmarkName); + } + } + } + + + /** + * docx ļǩ滻 + * + * @param inputStream + * @param outputStream + * @param dataMap + * @throws IOException + */ + public static void replaceBookmarksByDocx(InputStream inputStream, OutputStream outputStream, Map dataMap) throws IOException { + XWPFDocument document = new XWPFDocument(inputStream).getXWPFDocument(); + List paragraphList = document.getParagraphs(); + for (XWPFParagraph xwpfParagraph : paragraphList) { + CTP ctp = xwpfParagraph.getCTP(); + + for (int dwI = 0; dwI < ctp.sizeOfBookmarkStartArray(); dwI++) { + CTBookmark bookmark = ctp.getBookmarkStartArray(dwI); + if (dataMap.containsKey(bookmark.getName())) { + + XWPFRun run = xwpfParagraph.createRun(); + run.setText(dataMap.get(bookmark.getName())); + + Node firstNode = bookmark.getDomNode(); + Node nextNode = firstNode.getNextSibling(); + while (nextNode != null) { + // ѭҽ + String nodeName = nextNode.getNodeName(); + if (nodeName.equals(BOOKMARK_END_TAG)) { + break; + } + + // ɾмķǽڵ㣬ɾԭǩ + Node delNode = nextNode; + nextNode = nextNode.getNextSibling(); + ctp.getDomNode().removeChild(delNode); + } + + if (nextNode == null) { + // ʼҲʶģǩǰ + ctp.getDomNode().insertBefore(run.getCTR().getDomNode(), firstNode); + } else { + // ҵӵ֮ǰдbookmarkм + ctp.getDomNode().insertBefore(run.getCTR().getDomNode(), nextNode); + } + } + } + } + + document.write(outputStream); + document.close(); + } + + + /** + * doc ļǩ滻 + * + * @param inputStream + * @param outputStream + * @param dataMap + * @throws IOException + */ + public static void replaceBookmarksByDoc(InputStream inputStream, OutputStream outputStream, + Map dataMap) throws IOException { + HWPFDocument document = new HWPFDocument(inputStream); + Bookmarks bookmarks = document.getBookmarks(); + for (int dwI = 0; dwI < bookmarks.getBookmarksCount(); dwI++) { + Bookmark bookmark = bookmarks.getBookmark(dwI); + if (dataMap.containsKey(bookmark.getName())) { + Range range = new Range(bookmark.getStart(), bookmark.getEnd(), document); + range.replaceText(dataMap.get(bookmark.getName()), false); + } + } + document.write(outputStream); + } +} + + diff --git a/src/com/teamcenter/rac/stylesheet/stylesheet_user.properties b/src/com/teamcenter/rac/stylesheet/stylesheet_user.properties new file mode 100644 index 0000000..93ef268 --- /dev/null +++ b/src/com/teamcenter/rac/stylesheet/stylesheet_user.properties @@ -0,0 +1 @@ +LD6_NewProdForm.FORMJAVARENDERING=com.langtech.plm.form.LD6_NewProdForm \ No newline at end of file