commit 341ceb0e36c953cb4d4167fc8001e80886e76193 Author: lidy@connor.net.cn Date: Tue Oct 15 10:40:50 2024 +0800 20241015登录优化前代码上传 diff --git a/connor_cpzc_service/.gitignore b/connor_cpzc_service/.gitignore new file mode 100644 index 0000000..ba47137 --- /dev/null +++ b/connor_cpzc_service/.gitignore @@ -0,0 +1,37 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Custom ### +/logs/ +/gen/ diff --git a/connor_cpzc_service/.mvn/wrapper/maven-wrapper.jar b/connor_cpzc_service/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 0000000..c1dd12f Binary files /dev/null and b/connor_cpzc_service/.mvn/wrapper/maven-wrapper.jar differ diff --git a/connor_cpzc_service/.mvn/wrapper/maven-wrapper.properties b/connor_cpzc_service/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..d8bc321 --- /dev/null +++ b/connor_cpzc_service/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,2 @@ +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.3/apache-maven-3.8.3-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar diff --git a/connor_cpzc_service/lib/S8SoaBypassLoose_11000.2.0.jar b/connor_cpzc_service/lib/S8SoaBypassLoose_11000.2.0.jar new file mode 100644 index 0000000..52766b4 Binary files /dev/null and b/connor_cpzc_service/lib/S8SoaBypassLoose_11000.2.0.jar differ diff --git a/connor_cpzc_service/lib/S8SoaBypassStrong_11000.2.0.jar b/connor_cpzc_service/lib/S8SoaBypassStrong_11000.2.0.jar new file mode 100644 index 0000000..16f8087 Binary files /dev/null and b/connor_cpzc_service/lib/S8SoaBypassStrong_11000.2.0.jar differ diff --git a/connor_cpzc_service/lib/S8SoaBypassTypes_11000.2.0.jar b/connor_cpzc_service/lib/S8SoaBypassTypes_11000.2.0.jar new file mode 100644 index 0000000..aa5d1c1 Binary files /dev/null and b/connor_cpzc_service/lib/S8SoaBypassTypes_11000.2.0.jar differ diff --git a/connor_cpzc_service/lib/TcSoaClient_12000.0.0.jar b/connor_cpzc_service/lib/TcSoaClient_12000.0.0.jar new file mode 100644 index 0000000..79bf347 Binary files /dev/null and b/connor_cpzc_service/lib/TcSoaClient_12000.0.0.jar differ diff --git a/connor_cpzc_service/lib/TcSoaCommon_12000.0.0.jar b/connor_cpzc_service/lib/TcSoaCommon_12000.0.0.jar new file mode 100644 index 0000000..20a171a Binary files /dev/null and b/connor_cpzc_service/lib/TcSoaCommon_12000.0.0.jar differ diff --git a/connor_cpzc_service/lib/TcSoaCoreStrong_12000.0.0.jar b/connor_cpzc_service/lib/TcSoaCoreStrong_12000.0.0.jar new file mode 100644 index 0000000..d203b64 Binary files /dev/null and b/connor_cpzc_service/lib/TcSoaCoreStrong_12000.0.0.jar differ diff --git a/connor_cpzc_service/lib/TcSoaQueryStrong_12000.0.0.jar b/connor_cpzc_service/lib/TcSoaQueryStrong_12000.0.0.jar new file mode 100644 index 0000000..54978d1 Binary files /dev/null and b/connor_cpzc_service/lib/TcSoaQueryStrong_12000.0.0.jar differ diff --git a/connor_cpzc_service/lib/TcSoaStrongModel_12000.0.0.jar b/connor_cpzc_service/lib/TcSoaStrongModel_12000.0.0.jar new file mode 100644 index 0000000..3c34218 Binary files /dev/null and b/connor_cpzc_service/lib/TcSoaStrongModel_12000.0.0.jar differ diff --git a/connor_cpzc_service/lib/avalon-framework-4.1.5.jar b/connor_cpzc_service/lib/avalon-framework-4.1.5.jar new file mode 100644 index 0000000..a24b1c7 Binary files /dev/null and b/connor_cpzc_service/lib/avalon-framework-4.1.5.jar differ diff --git a/connor_cpzc_service/lib/commons-codec.jar b/connor_cpzc_service/lib/commons-codec.jar new file mode 100644 index 0000000..957b675 Binary files /dev/null and b/connor_cpzc_service/lib/commons-codec.jar differ diff --git a/connor_cpzc_service/lib/commons-httpclient-contrib-3.1.jar b/connor_cpzc_service/lib/commons-httpclient-contrib-3.1.jar new file mode 100644 index 0000000..af5c5de Binary files /dev/null and b/connor_cpzc_service/lib/commons-httpclient-contrib-3.1.jar differ diff --git a/connor_cpzc_service/lib/commons-logging.jar b/connor_cpzc_service/lib/commons-logging.jar new file mode 100644 index 0000000..b73a80f Binary files /dev/null and b/connor_cpzc_service/lib/commons-logging.jar differ diff --git a/connor_cpzc_service/lib/fccclient.jar b/connor_cpzc_service/lib/fccclient.jar new file mode 100644 index 0000000..5c1072b Binary files /dev/null and b/connor_cpzc_service/lib/fccclient.jar differ diff --git a/connor_cpzc_service/lib/fscclient.jar b/connor_cpzc_service/lib/fscclient.jar new file mode 100644 index 0000000..cec14cd Binary files /dev/null and b/connor_cpzc_service/lib/fscclient.jar differ diff --git a/connor_cpzc_service/lib/httpclient-4.5.2.jar b/connor_cpzc_service/lib/httpclient-4.5.2.jar new file mode 100644 index 0000000..701609f Binary files /dev/null and b/connor_cpzc_service/lib/httpclient-4.5.2.jar differ diff --git a/connor_cpzc_service/lib/httpcore-4.4.4.jar b/connor_cpzc_service/lib/httpcore-4.4.4.jar new file mode 100644 index 0000000..ac4a877 Binary files /dev/null and b/connor_cpzc_service/lib/httpcore-4.4.4.jar differ diff --git a/connor_cpzc_service/lib/jacorb.jar b/connor_cpzc_service/lib/jacorb.jar new file mode 100644 index 0000000..a01c85e Binary files /dev/null and b/connor_cpzc_service/lib/jacorb.jar differ diff --git a/connor_cpzc_service/lib/log4j.jar b/connor_cpzc_service/lib/log4j.jar new file mode 100644 index 0000000..dde9972 Binary files /dev/null and b/connor_cpzc_service/lib/log4j.jar differ diff --git a/connor_cpzc_service/lib/logkit-1.2.jar b/connor_cpzc_service/lib/logkit-1.2.jar new file mode 100644 index 0000000..67d4866 Binary files /dev/null and b/connor_cpzc_service/lib/logkit-1.2.jar differ diff --git a/connor_cpzc_service/lib/minio-8.4.5-all.jar b/connor_cpzc_service/lib/minio-8.4.5-all.jar new file mode 100644 index 0000000..0e0f57c Binary files /dev/null and b/connor_cpzc_service/lib/minio-8.4.5-all.jar differ diff --git a/connor_cpzc_service/lib/org.apache.poi.39/LICENSE b/connor_cpzc_service/lib/org.apache.poi.39/LICENSE new file mode 100644 index 0000000..acc4be5 --- /dev/null +++ b/connor_cpzc_service/lib/org.apache.poi.39/LICENSE @@ -0,0 +1,507 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +APACHE POI SUBCOMPONENTS: + +Apache POI includes subcomponents with separate copyright notices and +license terms. Your use of these subcomponents is subject to the terms +and conditions of the following licenses: + + +Office Open XML schemas (ooxml-schemas-1.1.jar) + + The Office Open XML schema definitions used by Apache POI are + a part of the Office Open XML ECMA Specification (ECMA-376, [1]). + As defined in section 9.4 of the ECMA bylaws [2], this specification + is available to all interested parties without restriction: + + 9.4 All documents when approved shall be made available to + all interested parties without restriction. + + Furthermore, both Microsoft and Adobe have granted patent licenses + to this work [3,4,5]. + + [1] http://www.ecma-international.org/publications/standards/Ecma-376.htm + [2] http://www.ecma-international.org/memento/Ecmabylaws.htm + [3] http://www.microsoft.com/interop/osp/ + [4] http://www.ecma-international.org/publications/files/ECMA-ST/Ecma%20PATENT/ECMA-376%20Edition%201%20Microsoft%20Patent%20Declaration.pdf + [5] http://www.ecma-international.org/publications/files/ECMA-ST/Ecma%20PATENT/ga-2006-191.pdf + + +DOM4J library (dom4j-1.6.1.jar) + + Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved. + + Redistribution and use of this software and associated documentation + ("Software"), with or without modification, are permitted provided + that the following conditions are met: + + 1. Redistributions of source code must retain copyright + statements and notices. Redistributions must also contain a + copy of this document. + + 2. Redistributions in binary form must reproduce the + above copyright notice, this list of conditions and the + following disclaimer in the documentation and/or other + materials provided with the distribution. + + 3. The name "DOM4J" must not be used to endorse or promote + products derived from this Software without prior written + permission of MetaStuff, Ltd. For written permission, + please contact dom4j-info@metastuff.com. + + 4. Products derived from this Software may not be called "DOM4J" + nor may "DOM4J" appear in their names without prior written + permission of MetaStuff, Ltd. DOM4J is a registered + trademark of MetaStuff, Ltd. + + 5. Due credit should be given to the DOM4J Project - + http://www.dom4j.org + + THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT + NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + OF THE POSSIBILITY OF SUCH DAMAGE. + + +JUnit test library (junit-3.8.1.jar) + + Common Public License - v 1.0 + + THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON + PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION + OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + + 1. DEFINITIONS + + "Contribution" means: + + a) in the case of the initial Contributor, the initial code and + documentation distributed under this Agreement, and + + b) in the case of each subsequent Contributor: + + i) changes to the Program, and + + ii) additions to the Program; + + where such changes and/or additions to the Program originate from + and are distributed by that particular Contributor. A Contribution + 'originates' from a Contributor if it was added to the Program by + such Contributor itself or anyone acting on such Contributor's behalf. + Contributions do not include additions to the Program which: (i) are + separate modules of software distributed in conjunction with the + Program under their own license agreement, and (ii) are not derivative + works of the Program. + + "Contributor" means any person or entity that distributes the Program. + + "Licensed Patents " mean patent claims licensable by a Contributor which + are necessarily infringed by the use or sale of its Contribution alone + or when combined with the Program. + + "Program" means the Contributions distributed in accordance with this + Agreement. + + "Recipient" means anyone who receives the Program under this Agreement, + including all Contributors. + + 2. GRANT OF RIGHTS + + a) Subject to the terms of this Agreement, each Contributor hereby grants + Recipient a non-exclusive, worldwide, royalty-free copyright license + to reproduce, prepare derivative works of, publicly display, publicly + perform, distribute and sublicense the Contribution of such + Contributor, if any, and such derivative works, in source code and + object code form. + + b) Subject to the terms of this Agreement, each Contributor hereby grants + Recipient a non-exclusive, worldwide, royalty-free patent license under + Licensed Patents to make, use, sell, offer to sell, import and + otherwise transfer the Contribution of such Contributor, if any, in + source code and object code form. This patent license shall apply to + the combination of the Contribution and the Program if, at the time + the Contribution is added by the Contributor, such addition of the + Contribution causes such combination to be covered by the Licensed + Patents. The patent license shall not apply to any other combinations + which include the Contribution. No hardware per se is licensed + hereunder. + + c) Recipient understands that although each Contributor grants the + licenses to its Contributions set forth herein, no assurances are + provided by any Contributor that the Program does not infringe the + patent or other intellectual property rights of any other entity. + Each Contributor disclaims any liability to Recipient for claims + brought by any other entity based on infringement of intellectual + property rights or otherwise. As a condition to exercising the rights + and licenses granted hereunder, each Recipient hereby assumes sole + responsibility to secure any other intellectual property rights + needed, if any. For example, if a third party patent license is + required to allow Recipient to distribute the Program, it is + Recipient's responsibility to acquire that license before + distributing the Program. + + d) Each Contributor represents that to its knowledge it has sufficient + copyright rights in its Contribution, if any, to grant the copyright + license set forth in this Agreement. + + 3. REQUIREMENTS + + A Contributor may choose to distribute the Program in object code form + under its own license agreement, provided that: + + a) it complies with the terms and conditions of this Agreement; and + + b) its license agreement: + + i) effectively disclaims on behalf of all Contributors all warranties + and conditions, express and implied, including warranties or + conditions of title and non-infringement, and implied warranties + or conditions of merchantability and fitness for a particular + purpose; + + ii) effectively excludes on behalf of all Contributors all liability + for damages, including direct, indirect, special, incidental and + consequential damages, such as lost profits; + + iii) states that any provisions which differ from this Agreement are + offered by that Contributor alone and not by any other party; and + + iv) states that source code for the Program is available from such + Contributor, and informs licensees how to obtain it in a + reasonable manner on or through a medium customarily used for + software exchange. + + When the Program is made available in source code form: + + a) it must be made available under this Agreement; and + + b) a copy of this Agreement must be included with each copy of + the Program. + + Contributors may not remove or alter any copyright notices contained + within the Program. + + Each Contributor must identify itself as the originator of its + Contribution, if any, in a manner that reasonably allows subsequent + Recipients to identify the originator of the Contribution. + + 4. COMMERCIAL DISTRIBUTION + + Commercial distributors of software may accept certain responsibilities + with respect to end users, business partners and the like. While this + license is intended to facilitate the commercial use of the Program, + the Contributor who includes the Program in a commercial product offering + should do so in a manner which does not create potential liability for + other Contributors. Therefore, if a Contributor includes the Program + in a commercial product offering, such Contributor ("Commercial + Contributor") hereby agrees to defend and indemnify every other + Contributor ("Indemnified Contributor") against any losses, damages + and costs (collectively "Losses") arising from claims, lawsuits and + other legal actions brought by a third party against the Indemnified + Contributor to the extent caused by the acts or omissions of such + Commercial Contributor in connection with its distribution of the + Program in a commercial product offering. The obligations in this + section do not apply to any claims or Losses relating to any actual + or alleged intellectual property infringement. In order to qualify, + an Indemnified Contributor must: a) promptly notify the Commercial + Contributor in writing of such claim, and b) allow the Commercial + Contributor to control, and cooperate with the Commercial Contributor + in, the defense and any related settlement negotiations. The Indemnified + Contributor may participate in any such claim at its own expense. + + For example, a Contributor might include the Program in a commercial + product offering, Product X. That Contributor is then a Commercial + Contributor. If that Commercial Contributor then makes performance + claims, or offers warranties related to Product X, those performance + claims and warranties are such Commercial Contributor's responsibility + alone. Under this section, the Commercial Contributor would have to + defend claims against the other Contributors related to those + performance claims and warranties, and if a court requires any other + Contributor to pay any damages as a result, the Commercial Contributor + must pay those damages. + + 5. NO WARRANTY + + EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED + ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER + EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR + CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR + A PARTICULAR PURPOSE. Each Recipient is solely responsible for + determining the appropriateness of using and distributing the Program + and assumes all risks associated with its exercise of rights under this + Agreement, including but not limited to the risks and costs of program + errors, compliance with applicable laws, damage to or loss of data, + programs or equipment, and unavailability or interruption of operations. + + 6. DISCLAIMER OF LIABILITY + + EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR + ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING + WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR + DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED + HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + + 7. GENERAL + + If any provision of this Agreement is invalid or unenforceable under + applicable law, it shall not affect the validity or enforceability of + the remainder of the terms of this Agreement, and without further + action by the parties hereto, such provision shall be reformed to the + minimum extent necessary to make such provision valid and enforceable. + + If Recipient institutes patent litigation against a Contributor with + respect to a patent applicable to software (including a cross-claim or + counterclaim in a lawsuit), then any patent licenses granted by that + Contributor to such Recipient under this Agreement shall terminate as of + the date such litigation is filed. In addition, if Recipient institutes + patent litigation against any entity (including a cross-claim or + counterclaim in a lawsuit) alleging that the Program itself (excluding + combinations of the Program with other software or hardware) infringes + such Recipient's patent(s), then such Recipient's rights granted under + Section 2(b) shall terminate as of the date such litigation is filed. + + All Recipient's rights under this Agreement shall terminate if it fails + to comply with any of the material terms or conditions of this Agreement + and does not cure such failure in a reasonable period of time after + becoming aware of such noncompliance. If all Recipient's rights under + this Agreement terminate, Recipient agrees to cease use and distribution + of the Program as soon as reasonably practicable. However, Recipient's + obligations under this Agreement and any licenses granted by Recipient + relating to the Program shall continue and survive. + + Everyone is permitted to copy and distribute copies of this Agreement, + but in order to avoid inconsistency the Agreement is copyrighted and may + only be modified in the following manner. The Agreement Steward reserves + the right to publish new versions (including revisions) of this Agreement + from time to time. No one other than the Agreement Steward has the right + to modify this Agreement. IBM is the initial Agreement Steward. IBM may + assign the responsibility to serve as the Agreement Steward to a suitable + separate entity. Each new version of the Agreement will be given a + distinguishing version number. The Program (including Contributions) may + always be distributed subject to the version of the Agreement under which + it was received. In addition, after a new version of the Agreement is + published, Contributor may elect to distribute the Program (including + its Contributions) under the new version. Except as expressly stated in + Sections 2(a) and 2(b) above, Recipient receives no rights or licenses + to the intellectual property of any Contributor under this Agreement, + whether expressly, by implication, estoppel or otherwise. All rights in + the Program not expressly granted under this Agreement are reserved. + + This Agreement is governed by the laws of the State of New York and the + intellectual property laws of the United States of America. No party to + this Agreement will bring a legal action under this Agreement more than + one year after the cause of action arose. Each party waives its rights + to a jury trial in any resulting litigation. diff --git a/connor_cpzc_service/lib/org.apache.poi.39/META-INF/MANIFEST.MF b/connor_cpzc_service/lib/org.apache.poi.39/META-INF/MANIFEST.MF new file mode 100644 index 0000000..5e1c0e0 --- /dev/null +++ b/connor_cpzc_service/lib/org.apache.poi.39/META-INF/MANIFEST.MF @@ -0,0 +1,256 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: org.apache.poi.39 +Bundle-SymbolicName: org.apache.poi.39 +Bundle-Version: 3.9 +Bundle-ClassPath: poi-3.9-20121203.jar, + poi-examples-3.9-20121203.jar, + poi-excelant-3.9-20121203.jar, + poi-ooxml-3.9-20121203.jar, + poi-ooxml-schemas-3.9-20121203.jar, + poi-scratchpad-3.9-20121203.jar, + dom4j-1.6.1.jar, + xmlbeans-2.3.0.jar +Bundle-Vendor: org.apache.poi +Export-Package: org.apache.poi, + org.apache.poi.common.usermodel, + org.apache.poi.ddf, + org.apache.poi.dev, + org.apache.poi.extractor, + org.apache.poi.hdf.event, + org.apache.poi.hdf.extractor, + org.apache.poi.hdf.extractor.data, + org.apache.poi.hdf.extractor.util, + org.apache.poi.hdf.model, + org.apache.poi.hdf.model.hdftypes, + org.apache.poi.hdf.model.hdftypes.definitions, + org.apache.poi.hdf.model.util, + org.apache.poi.hdgf, + org.apache.poi.hdgf.chunks, + org.apache.poi.hdgf.dev, + org.apache.poi.hdgf.exceptions, + org.apache.poi.hdgf.extractor, + org.apache.poi.hdgf.pointers, + org.apache.poi.hdgf.streams, + org.apache.poi.hmef, + org.apache.poi.hmef.attribute, + org.apache.poi.hmef.dev, + org.apache.poi.hmef.extractor, + org.apache.poi.hpbf, + org.apache.poi.hpbf.dev, + org.apache.poi.hpbf.extractor, + org.apache.poi.hpbf.model, + org.apache.poi.hpbf.model.qcbits, + org.apache.poi.hpsf, + org.apache.poi.hpsf.examples, + org.apache.poi.hpsf.extractor, + org.apache.poi.hpsf.wellknown, + org.apache.poi.hslf, + org.apache.poi.hslf.blip, + org.apache.poi.hslf.dev, + org.apache.poi.hslf.examples, + org.apache.poi.hslf.exceptions, + org.apache.poi.hslf.extractor, + org.apache.poi.hslf.model, + org.apache.poi.hslf.model.textproperties, + org.apache.poi.hslf.record, + org.apache.poi.hslf.usermodel, + org.apache.poi.hslf.util, + org.apache.poi.hsmf, + org.apache.poi.hsmf.datatypes, + org.apache.poi.hsmf.dev, + org.apache.poi.hsmf.examples, + org.apache.poi.hsmf.exceptions, + org.apache.poi.hsmf.extractor, + org.apache.poi.hsmf.parsers, + org.apache.poi.hssf, + org.apache.poi.hssf.converter, + org.apache.poi.hssf.dev, + org.apache.poi.hssf.eventmodel, + org.apache.poi.hssf.eventusermodel, + org.apache.poi.hssf.eventusermodel.dummyrecord, + org.apache.poi.hssf.eventusermodel.examples, + org.apache.poi.hssf.extractor, + org.apache.poi.hssf.model, + org.apache.poi.hssf.record, + org.apache.poi.hssf.record.aggregates, + org.apache.poi.hssf.record.cf, + org.apache.poi.hssf.record.chart, + org.apache.poi.hssf.record.common, + org.apache.poi.hssf.record.cont, + org.apache.poi.hssf.record.crypto, + org.apache.poi.hssf.record.pivottable, + org.apache.poi.hssf.usermodel, + org.apache.poi.hssf.usermodel.examples, + org.apache.poi.hssf.util, + org.apache.poi.hssf.view, + org.apache.poi.hssf.view.brush, + org.apache.poi.hwpf, + org.apache.poi.hwpf.converter, + org.apache.poi.hwpf.dev, + org.apache.poi.hwpf.extractor, + org.apache.poi.hwpf.model, + org.apache.poi.hwpf.model.io, + org.apache.poi.hwpf.model.types, + org.apache.poi.hwpf.sprm, + org.apache.poi.hwpf.usermodel, + org.apache.poi.openxml4j.exceptions, + org.apache.poi.openxml4j.opc, + org.apache.poi.openxml4j.opc.internal, + org.apache.poi.openxml4j.opc.internal.marshallers, + org.apache.poi.openxml4j.opc.internal.signature, + org.apache.poi.openxml4j.opc.internal.unmarshallers, + org.apache.poi.openxml4j.opc.signature, + org.apache.poi.openxml4j.util, + org.apache.poi.poifs.common, + org.apache.poi.poifs.crypt, + org.apache.poi.poifs.dev, + org.apache.poi.poifs.eventfilesystem, + org.apache.poi.poifs.filesystem, + org.apache.poi.poifs.nio, + org.apache.poi.poifs.poibrowser, + org.apache.poi.poifs.property, + org.apache.poi.poifs.storage, + org.apache.poi.sl.usermodel, + org.apache.poi.ss, + org.apache.poi.ss.examples, + org.apache.poi.ss.examples.formula, + org.apache.poi.ss.examples.html, + org.apache.poi.ss.excelant, + org.apache.poi.ss.excelant.util, + org.apache.poi.ss.extractor, + org.apache.poi.ss.format, + org.apache.poi.ss.formula, + org.apache.poi.ss.formula.atp, + org.apache.poi.ss.formula.constant, + org.apache.poi.ss.formula.eval, + org.apache.poi.ss.formula.eval.forked, + org.apache.poi.ss.formula.function, + org.apache.poi.ss.formula.functions, + org.apache.poi.ss.formula.ptg, + org.apache.poi.ss.formula.udf, + org.apache.poi.ss.usermodel, + org.apache.poi.ss.usermodel.charts, + org.apache.poi.ss.util, + org.apache.poi.ss.util.cellwalk, + org.apache.poi.util, + org.apache.poi.xslf, + org.apache.poi.xslf.extractor, + org.apache.poi.xslf.model, + org.apache.poi.xslf.model.geom, + org.apache.poi.xslf.usermodel, + org.apache.poi.xslf.usermodel.tutorial, + org.apache.poi.xslf.util, + org.apache.poi.xssf.dev, + org.apache.poi.xssf.eventusermodel, + org.apache.poi.xssf.eventusermodel.examples, + org.apache.poi.xssf.extractor, + org.apache.poi.xssf.model, + org.apache.poi.xssf.streaming, + org.apache.poi.xssf.usermodel, + org.apache.poi.xssf.usermodel.charts, + org.apache.poi.xssf.usermodel.examples, + org.apache.poi.xssf.usermodel.extensions, + org.apache.poi.xssf.usermodel.helpers, + org.apache.poi.xssf.util, + org.apache.poi.xwpf.extractor, + org.apache.poi.xwpf.model, + org.apache.poi.xwpf.usermodel, + org.apache.xmlbeans, + org.apache.xmlbeans.impl.common, + org.apache.xmlbeans.impl.config, + org.apache.xmlbeans.impl.inst2xsd, + org.apache.xmlbeans.impl.inst2xsd.util, + org.apache.xmlbeans.impl.jam, + org.apache.xmlbeans.impl.jam.annotation, + org.apache.xmlbeans.impl.jam.internal, + org.apache.xmlbeans.impl.jam.internal.classrefs, + org.apache.xmlbeans.impl.jam.internal.elements, + org.apache.xmlbeans.impl.jam.internal.javadoc, + org.apache.xmlbeans.impl.jam.internal.parser, + org.apache.xmlbeans.impl.jam.internal.reflect, + org.apache.xmlbeans.impl.jam.mutable, + org.apache.xmlbeans.impl.jam.provider, + org.apache.xmlbeans.impl.jam.visitor, + org.apache.xmlbeans.impl.jam.xml, + org.apache.xmlbeans.impl.piccolo.io, + org.apache.xmlbeans.impl.piccolo.util, + org.apache.xmlbeans.impl.piccolo.xml, + org.apache.xmlbeans.impl.regex, + org.apache.xmlbeans.impl.richParser, + org.apache.xmlbeans.impl.schema, + org.apache.xmlbeans.impl.soap, + org.apache.xmlbeans.impl.store, + org.apache.xmlbeans.impl.tool, + org.apache.xmlbeans.impl.util, + org.apache.xmlbeans.impl.validator, + org.apache.xmlbeans.impl.values, + org.apache.xmlbeans.impl.xb.ltgfmt, + org.apache.xmlbeans.impl.xb.ltgfmt.impl, + org.apache.xmlbeans.impl.xb.substwsdl, + org.apache.xmlbeans.impl.xb.substwsdl.impl, + org.apache.xmlbeans.impl.xb.xmlconfig, + org.apache.xmlbeans.impl.xb.xmlconfig.impl, + org.apache.xmlbeans.impl.xb.xmlschema, + org.apache.xmlbeans.impl.xb.xmlschema.impl, + org.apache.xmlbeans.impl.xb.xsdownload, + org.apache.xmlbeans.impl.xb.xsdownload.impl, + org.apache.xmlbeans.impl.xb.xsdschema, + org.apache.xmlbeans.impl.xb.xsdschema.impl, + org.apache.xmlbeans.impl.xsd2inst, + org.apache.xmlbeans.soap, + org.apache.xmlbeans.xml.stream, + org.apache.xmlbeans.xml.stream.events, + org.apache.xmlbeans.xml.stream.utils, + org.dom4j, + org.dom4j.bean, + org.dom4j.datatype, + org.dom4j.dom, + org.dom4j.dtd, + org.dom4j.io, + org.dom4j.jaxb, + org.dom4j.rule, + org.dom4j.rule.pattern, + org.dom4j.swing, + org.dom4j.tree, + org.dom4j.util, + org.dom4j.xpath, + org.dom4j.xpp, + org.openxmlformats.schemas.drawingml.x2006.chart, + org.openxmlformats.schemas.drawingml.x2006.chart.impl, + org.openxmlformats.schemas.drawingml.x2006.main, + org.openxmlformats.schemas.drawingml.x2006.main.impl, + org.openxmlformats.schemas.drawingml.x2006.picture, + org.openxmlformats.schemas.drawingml.x2006.picture.impl, + org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing, + org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.impl, + org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing, + org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.impl, + org.openxmlformats.schemas.officeDocument.x2006.customProperties, + org.openxmlformats.schemas.officeDocument.x2006.customProperties.impl, + org.openxmlformats.schemas.officeDocument.x2006.docPropsVTypes, + org.openxmlformats.schemas.officeDocument.x2006.docPropsVTypes.impl, + org.openxmlformats.schemas.officeDocument.x2006.extendedProperties, + org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.impl, + org.openxmlformats.schemas.officeDocument.x2006.relationships, + org.openxmlformats.schemas.officeDocument.x2006.relationships.impl, + org.openxmlformats.schemas.presentationml.x2006.main, + org.openxmlformats.schemas.presentationml.x2006.main.impl, + org.openxmlformats.schemas.spreadsheetml.x2006.main, + org.openxmlformats.schemas.spreadsheetml.x2006.main.impl, + org.openxmlformats.schemas.wordprocessingml.x2006.main, + org.openxmlformats.schemas.wordprocessingml.x2006.main.impl, + org.w3c.dom, + repackage, + schemaorg_apache_xmlbeans.system.sE130CAA0A01A7CDE5A2B4FEB8B311707, + schemaorg_apache_xmlbeans.system.sXMLCONFIG, + schemaorg_apache_xmlbeans.system.sXMLLANG, + schemaorg_apache_xmlbeans.system.sXMLSCHEMA, + schemaorg_apache_xmlbeans.system.sXMLTOOLS, + schemasMicrosoftComOfficeExcel, + schemasMicrosoftComOfficeExcel.impl, + schemasMicrosoftComOfficeOffice, + schemasMicrosoftComOfficeOffice.impl, + schemasMicrosoftComVml, + schemasMicrosoftComVml.impl +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 diff --git a/connor_cpzc_service/lib/org.apache.poi.39/NOTICE b/connor_cpzc_service/lib/org.apache.poi.39/NOTICE new file mode 100644 index 0000000..6d9855f --- /dev/null +++ b/connor_cpzc_service/lib/org.apache.poi.39/NOTICE @@ -0,0 +1,21 @@ +Apache POI +Copyright 2009 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + +This product contains the DOM4J library (http://www.dom4j.org). +Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved. + +This product contains parts that were originally based on software from BEA. +Copyright (c) 2000-2003, BEA Systems, . + +This product contains W3C XML Schema documents. Copyright 2001-2003 (c) +World Wide Web Consortium (Massachusetts Institute of Technology, European +Research Consortium for Informatics and Mathematics, Keio University) + +This product contains the Piccolo XML Parser for Java +(http://piccolo.sourceforge.net/). Copyright 2002 Yuval Oren. + +This product contains the chunks_parse_cmds.tbl file from the vsdump program. +Copyright (C) 2006-2007 Valek Filippov (frob@df.ru) diff --git a/connor_cpzc_service/lib/org.apache.poi.39/dom4j-1.6.1.jar b/connor_cpzc_service/lib/org.apache.poi.39/dom4j-1.6.1.jar new file mode 100644 index 0000000..c8c4dbb Binary files /dev/null and b/connor_cpzc_service/lib/org.apache.poi.39/dom4j-1.6.1.jar differ diff --git a/connor_cpzc_service/lib/org.apache.poi.39/poi-3.9-20121203.jar b/connor_cpzc_service/lib/org.apache.poi.39/poi-3.9-20121203.jar new file mode 100644 index 0000000..0f46288 Binary files /dev/null and b/connor_cpzc_service/lib/org.apache.poi.39/poi-3.9-20121203.jar differ diff --git a/connor_cpzc_service/lib/org.apache.poi.39/poi-examples-3.9-20121203.jar b/connor_cpzc_service/lib/org.apache.poi.39/poi-examples-3.9-20121203.jar new file mode 100644 index 0000000..a364cc2 Binary files /dev/null and b/connor_cpzc_service/lib/org.apache.poi.39/poi-examples-3.9-20121203.jar differ diff --git a/connor_cpzc_service/lib/org.apache.poi.39/poi-excelant-3.9-20121203.jar b/connor_cpzc_service/lib/org.apache.poi.39/poi-excelant-3.9-20121203.jar new file mode 100644 index 0000000..cb403fa Binary files /dev/null and b/connor_cpzc_service/lib/org.apache.poi.39/poi-excelant-3.9-20121203.jar differ diff --git a/connor_cpzc_service/lib/org.apache.poi.39/poi-ooxml-3.9-20121203.jar b/connor_cpzc_service/lib/org.apache.poi.39/poi-ooxml-3.9-20121203.jar new file mode 100644 index 0000000..8792d46 Binary files /dev/null and b/connor_cpzc_service/lib/org.apache.poi.39/poi-ooxml-3.9-20121203.jar differ diff --git a/connor_cpzc_service/lib/org.apache.poi.39/poi-ooxml-schemas-3.9-20121203.jar b/connor_cpzc_service/lib/org.apache.poi.39/poi-ooxml-schemas-3.9-20121203.jar new file mode 100644 index 0000000..eda4ef4 Binary files /dev/null and b/connor_cpzc_service/lib/org.apache.poi.39/poi-ooxml-schemas-3.9-20121203.jar differ diff --git a/connor_cpzc_service/lib/org.apache.poi.39/poi-scratchpad-3.9-20121203.jar b/connor_cpzc_service/lib/org.apache.poi.39/poi-scratchpad-3.9-20121203.jar new file mode 100644 index 0000000..1520855 Binary files /dev/null and b/connor_cpzc_service/lib/org.apache.poi.39/poi-scratchpad-3.9-20121203.jar differ diff --git a/connor_cpzc_service/lib/org.apache.poi.39/xmlbeans-2.3.0.jar b/connor_cpzc_service/lib/org.apache.poi.39/xmlbeans-2.3.0.jar new file mode 100644 index 0000000..ccd8163 Binary files /dev/null and b/connor_cpzc_service/lib/org.apache.poi.39/xmlbeans-2.3.0.jar differ diff --git a/connor_cpzc_service/lib/resolver.jar b/connor_cpzc_service/lib/resolver.jar new file mode 100644 index 0000000..e535bdc Binary files /dev/null and b/connor_cpzc_service/lib/resolver.jar differ diff --git a/connor_cpzc_service/lib/tcgatewaystubs.jar b/connor_cpzc_service/lib/tcgatewaystubs.jar new file mode 100644 index 0000000..79c78ef Binary files /dev/null and b/connor_cpzc_service/lib/tcgatewaystubs.jar differ diff --git a/connor_cpzc_service/lib/tcmemjavabinding.jar b/connor_cpzc_service/lib/tcmemjavabinding.jar new file mode 100644 index 0000000..5caaf0c Binary files /dev/null and b/connor_cpzc_service/lib/tcmemjavabinding.jar differ diff --git a/connor_cpzc_service/lib/tcserverjavabinding.jar b/connor_cpzc_service/lib/tcserverjavabinding.jar new file mode 100644 index 0000000..877b16f Binary files /dev/null and b/connor_cpzc_service/lib/tcserverjavabinding.jar differ diff --git a/connor_cpzc_service/lib/teamcenter_sso_applib.jar b/connor_cpzc_service/lib/teamcenter_sso_applib.jar new file mode 100644 index 0000000..7ae2c95 Binary files /dev/null and b/connor_cpzc_service/lib/teamcenter_sso_applib.jar differ diff --git a/connor_cpzc_service/lib/teamcenter_sso_common.jar b/connor_cpzc_service/lib/teamcenter_sso_common.jar new file mode 100644 index 0000000..99305dc Binary files /dev/null and b/connor_cpzc_service/lib/teamcenter_sso_common.jar differ diff --git a/connor_cpzc_service/lib/teamcenter_sso_webtoolkit.jar b/connor_cpzc_service/lib/teamcenter_sso_webtoolkit.jar new file mode 100644 index 0000000..278c379 Binary files /dev/null and b/connor_cpzc_service/lib/teamcenter_sso_webtoolkit.jar differ diff --git a/connor_cpzc_service/lib/xercesImpl.jar b/connor_cpzc_service/lib/xercesImpl.jar new file mode 100644 index 0000000..0aaa990 Binary files /dev/null and b/connor_cpzc_service/lib/xercesImpl.jar differ diff --git a/connor_cpzc_service/lib/xml-apis.jar b/connor_cpzc_service/lib/xml-apis.jar new file mode 100644 index 0000000..4673346 Binary files /dev/null and b/connor_cpzc_service/lib/xml-apis.jar differ diff --git a/connor_cpzc_service/mvnw b/connor_cpzc_service/mvnw new file mode 100644 index 0000000..8a8fb22 --- /dev/null +++ b/connor_cpzc_service/mvnw @@ -0,0 +1,316 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /usr/local/etc/mavenrc ] ; then + . /usr/local/etc/mavenrc + fi + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`\\unset -f command; \\command -v java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + $MAVEN_DEBUG_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" \ + "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/connor_cpzc_service/mvnw.cmd b/connor_cpzc_service/mvnw.cmd new file mode 100644 index 0000000..1d8ab01 --- /dev/null +++ b/connor_cpzc_service/mvnw.cmd @@ -0,0 +1,188 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* +if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + +FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% ^ + %JVM_CONFIG_MAVEN_PROPS% ^ + %MAVEN_OPTS% ^ + %MAVEN_DEBUG_OPTS% ^ + -classpath %WRAPPER_JAR% ^ + "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ + %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" +if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%"=="on" pause + +if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% + +cmd /C exit /B %ERROR_CODE% diff --git a/connor_cpzc_service/pom.xml b/connor_cpzc_service/pom.xml new file mode 100644 index 0000000..adf60d0 --- /dev/null +++ b/connor_cpzc_service/pom.xml @@ -0,0 +1,390 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.6.2 + + + com.connor + connor_cpzc_service + 0.0.1 + connor_cpzc_service + connor_cpzc_service + + 1.8 + + + + com.jgoodies + forms + 1.2.1 + + + com.squareup.okio + okio + 1.9.0 + + + com.squareup.okhttp3 + okhttp + 3.4.1 + + + javax.validation + validation-api + 2.0.1.Final + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter + + + org.mybatis + mybatis + 3.4.6 + + + io.minio + minio + 8.0.3 + + + org.mybatis.spring.boot + mybatis-spring-boot-starter + 2.1.4 + + + com.oracle + ojdbc8 + 12.2.0.1 + + + org.mybatis + mybatis-spring + 1.3.1 + + + no.tornado + tornadofx-controls + 1.0.3 + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.boot + spring-boot-configuration-processor + true + + + + + teamcenter + commons-io + 2.5 + + + teamcenter + commons-logging + 2.5 + + + teamcenter + fccclient + 12.3.0 + + + + teamcenter + fscclient + 12.3.0 + + + + teamcenter + httpclient + 12.3.0 + + + + teamcenter + httpcore + 12.3.0 + + + + teamcenter + httpmime + 12.3.0 + + + + teamcenter + log4j + 12.3.0 + + + + teamcenter + TcSoaAdministrationStrong + 12.3.0 + + + + teamcenter + TcSoaAiStrong + 12.3.0 + + + + teamcenter + TcSoaAllocationsStrong + 12.3.0 + + + + teamcenter + TcSoaBomStrong + 12.3.0 + + + + teamcenter + TcSoaBusinessModelerStrong + 12.3.0 + + + + teamcenter + TcSoaCadBomAlignmentStrong + 12.3.0 + + + + teamcenter + TcSoaCadStrong + 12.3.0 + + + + teamcenter + TcSoaCaeStrong + 12.3.0 + + + + teamcenter + TcSoaCalendarManagementStrong + 12.3.0 + + + + teamcenter + TcSoaChangeManagementStrong + 12.3.0 + + + + teamcenter + TcSoaClassificationStrong + 12.3.0 + + + + teamcenter + TcSoaClient + 12.3.0 + + + + teamcenter + TcSoaCommon + 12.3.0 + + + + teamcenter + TcSoaConfigurationStrong + 12.3.0 + + + + teamcenter + TcSoaCoreLoose + 12.3.0 + + + + teamcenter + TcSoaCoreStrong + 12.3.0 + + + + teamcenter + TcSoaDocumentManagementStrong + 12.3.0 + + + + teamcenter + TcSoaImportExportStrong + 12.3.0 + + + + teamcenter + TcSoaQueryStrong + 12.3.0 + + + + teamcenter + TcSoaStrongModel + 12.3.0 + + + + teamcenter + TcSoaWorkflowLoose + 12.3.0 + + + teamcenter + TcSoaWorkflowStrong + 12.3.0 + + + + teamcenter + xercesImpl + 12.3.0 + + + org.projectlombok + lombok + 1.18.20 + + + teamcenter + xml-apis + 12.3.0 + + + com.alibaba + fastjson + 1.2.66 + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + + + com.s8.services.strong.bypass + S8SoaBypassLoose + 11000.2.0 + system + ${pom.basedir}/lib/S8SoaBypassLoose_11000.2.0.jar + + + com.s8.services.strong.bypass + S8SoaBypassStrong + 11000.2.0 + system + ${pom.basedir}/lib/S8SoaBypassStrong_11000.2.0.jar + + + com.s8.services.strong.bypass + S8SoaBypassTypes + 11000.2.0 + system + ${pom.basedir}/lib/S8SoaBypassTypes_11000.2.0.jar + + + + poi + poi + 3.9-20121203 + system + D:/TC_install/ZhengTai/chint/canshuhua8089/connor_cpzc_service/lib/org.apache.poi.39/poi-3.9-20121203.jar + + + poi + poi-examples + 3.9-20121203 + system + D:/TC_install/ZhengTai/chint/canshuhua8089/connor_cpzc_service/lib/org.apache.poi.39/poi-examples-3.9-20121203.jar + + + poi + poi-excelant + 3.9-20121203 + system + D:/TC_install/ZhengTai/chint/canshuhua8089/connor_cpzc_service/lib/org.apache.poi.39/poi-excelant-3.9-20121203.jar + + + poi + poi-ooxml + 3.9-20121203 + system + D:/TC_install/ZhengTai/chint/canshuhua8089/connor_cpzc_service/lib/org.apache.poi.39/poi-ooxml-3.9-20121203.jar + + + poi + poi-ooxml-schemas + 3.9-20121203 + system + D:/TC_install/ZhengTai/chint/canshuhua8089/connor_cpzc_service/lib/org.apache.poi.39/poi-ooxml-schemas-3.9-20121203.jar + + + poi + xmlbeans + 2.3.0 + system + D:/TC_install/ZhengTai/chint/canshuhua8089/connor_cpzc_service/lib/org.apache.poi.39/xmlbeans-2.3.0.jar + + + poi + dom4j + 1.6.1 + system + D:/TC_install/ZhengTai/chint/canshuhua8089/connor_cpzc_service/lib/org.apache.poi.39/dom4j-1.6.1.jar + + + + + + + org.apache.maven.plugins + maven-resources-plugin + 3.1.0 + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + + + diff --git a/connor_cpzc_service/src/main/java/com/chint/plm/modules/controller/TestController.java b/connor_cpzc_service/src/main/java/com/chint/plm/modules/controller/TestController.java new file mode 100644 index 0000000..e518f72 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/chint/plm/modules/controller/TestController.java @@ -0,0 +1,35 @@ +package com.chint.plm.modules.controller; + +import com.chint.plm.tcclient.SessionContext; +import com.chint.plm.tcclient.helper.BypassHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + *

+ * 测试 控制器 + *

+ * + * @author Yudy + * @since 2024-03-24 + */ +public class TestController { + + private static final Logger logger = LoggerFactory.getLogger(ZtRestController.class); + + public static void main(String[] args) { + String host = "http://10.128.10.203:7001/tc"; + String username = "dcproxy"; + String password = "dcproxy"; + SessionContext session = new SessionContext(host, username, password); + BypassHelper.open(); + try { + + } catch (Exception e) { + logger.error("操作异常", e); + } finally { + BypassHelper.close(); + session.logout(); + } + } +} diff --git a/connor_cpzc_service/src/main/java/com/chint/plm/modules/controller/ZtRestController.java b/connor_cpzc_service/src/main/java/com/chint/plm/modules/controller/ZtRestController.java new file mode 100644 index 0000000..3c0fe13 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/chint/plm/modules/controller/ZtRestController.java @@ -0,0 +1,284 @@ +package com.chint.plm.modules.controller; + +import com.alibaba.fastjson.JSONObject; +import com.chint.plm.tcclient.SessionContext; +import com.chint.plm.tcclient.enums.ObjectTypeEnum; +import com.chint.plm.tcclient.helper.*; +import com.connor.connor_cpzc_service.controller.DownLoadController; +import com.connor.connor_cpzc_service.info.DesignInfoBean; +import com.connor.connor_cpzc_service.info.FileInfoBean; +import com.teamcenter.services.strong.core.DataManagementService; +import com.teamcenter.soa.client.model.ModelObject; +import com.teamcenter.soa.client.model.Property; +import com.teamcenter.soa.client.model.strong.*; +import com.teamcenter.soa.exceptions.NotLoadedException; +import org.codehaus.plexus.util.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.util.CollectionUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.*; + +/** + * ZT + * + * @author Yudy + */ +@RestController +@RequestMapping(value = "/plm") +public class ZtRestController { + + private static final Logger logger = LoggerFactory.getLogger(ZtRestController.class); + + @Value("${tc.server}") + private String host; + + @Value("${tc.user}") + private String username; + + @Value("${tc.password}") + private String password; + + @Autowired + private DownLoadController designController; + + @GetMapping("/getAttachment") + public DesignInfoBean getAttachment(String item, String wbsno, String factoryNo, String factory, String folderNames, String objectTypes, String fileTypes) { + SessionContext session = new SessionContext(host, username, password); + BypassHelper.open(); + List fileInfoBeans = new ArrayList<>(); + StringBuilder message = new StringBuilder(); + try { + DataManagementService dataManagementService = ServiceHelper.getDataManagementService(); + List fTypes = new ArrayList<>(); + if (fileTypes != null) { + fTypes = Arrays.asList(fileTypes.split(",")); + } + if (StringUtils.isNotBlank(factoryNo)) { + if (StringUtils.isNotBlank(folderNames) && StringUtils.isNotBlank(objectTypes)) { + List dirs = Arrays.asList(folderNames.split(",")); + List objTypes = Arrays.asList(objectTypes.split(",")); + fileInfoBeans = getByFactoryNo(dataManagementService, factoryNo, factory, dirs, objTypes, fTypes, message); + } else { + message.append("按出厂编号查询时,文件夹目录和对象类型不能为空"); + } + } else { + if (StringUtils.isNotBlank(item) && StringUtils.isNotBlank(wbsno)) { + fileInfoBeans = getByMaterialNoAdnWbsno(dataManagementService, item, wbsno, fTypes, message); + } else { + // 调用图纸接口 + String result = designController.getDesign(item, wbsno, factoryNo); + if (StringUtils.isNotBlank(result)) { + try { + DesignInfoBean designInfoBean = JSONObject.parseObject(result, DesignInfoBean.class); + if (designInfoBean != null) { + fileInfoBeans = designInfoBean.getFile(); + if (StringUtils.isNotBlank(designInfoBean.getDesc())) { + message.append(designInfoBean.getDesc()); + } + } + } catch (Exception e) { + message.append(result); + } + } else { + message.append("出厂编号为空时,物料编码和WBS号不能为空"); + } + } + } + } catch (Exception e) { + logger.error("操作异常", e); + } finally { + BypassHelper.close(); + session.logout(); + } + // 返回数据 + return new DesignInfoBean(fileInfoBeans, message.toString()); + } + + private List getByFactoryNo(DataManagementService dataManagementService, String factoryNo, String factory, List dirs, List objTypes, List types, StringBuilder message) throws Exception { + // 附件信息 + List fileInfoBeans = new ArrayList<>(); + // 查询出厂编号 + Map queryCondition = new HashMap<>(); + queryCondition.put("fid", factoryNo); + ModelObject[] modelObjects = QueryHelper.query("chint_query_FactoryNo", queryCondition); + if (modelObjects != null && modelObjects.length > 0) { + // 找到对象 + ModelObject modelObject = modelObjects[0]; + logger.debug("找到模型对象,uid={} ", modelObject.getUid()); + // ## 直接引用的版本对象,正好符合查找的类型 + List objVevTypes = new ArrayList<>(); + for (String objType : objTypes) { + objVevTypes.add(objType + "Revision"); + } + List directObjects = RevisionHelper.getItemRevisionObjects(dataManagementService, (WorkspaceObject) modelObject, objVevTypes); + // 模型版本对象 + List revisionObjects = new ArrayList<>(directObjects); + + // ## 先找到项目,再通过项目去查询 + // 反向查询项目零组件 <出厂编号-项目启动-项目零组件> + List projectItemObjects = getProjectItemObjects(dataManagementService, (WorkspaceObject) modelObject, factory); + for (String dir : dirs) { + // 正向查询项目零组件下的模型版本对象 例如: + // 正向查询项目零组件下的图纸模型 <项目零组件-项目执行-电气图纸-图纸模型> + // 正向查询项目零组件下的文档 <项目零组件-项目执行-电气图纸-文档> + List projectFolders = Arrays.asList(dir.split("/")); + List targetObjects = ItemHelper.getReferenceObjects(dataManagementService, projectItemObjects, projectFolders, objTypes); + revisionObjects.addAll(RevisionHelper.getItemRevisionObjects(dataManagementService, targetObjects)); + } + // 规范与附件 + List specsAttaches = RevisionHelper.getSpecsAttaches(dataManagementService, revisionObjects); + fileInfoBeans = getFileInfoBeans(dataManagementService, specsAttaches, types); + } else { + logger.debug("使用出厂编号进行查询未找到对象"); + message.append("使用出厂编号进行查询未找到对象"); + } + return fileInfoBeans; + } + + private List getByMaterialNoAdnWbsno(DataManagementService dataManagementService, String materialNo, String wbsno, List types, StringBuilder message) throws Exception { + // 附件信息 + List fileInfoBeans = new ArrayList<>(); + // 查询物料零件 + Map queryCondition = new HashMap<>(); + queryCondition.put("materialno", materialNo + "*"); + queryCondition.put("WBS No", wbsno); + ModelObject[] modelObjects = QueryHelper.query("chint_query_material", queryCondition); + if (modelObjects == null || modelObjects.length == 0) { + // 按物料号查询 + queryCondition.remove("WBS No"); + modelObjects = QueryHelper.query("chint_query_material", queryCondition); + } + if (modelObjects != null && modelObjects.length > 0) { + List specsAttaches = new ArrayList<>(); + for (ModelObject modelObject : modelObjects) { + // 零件版本 + if (modelObject instanceof Part_Revision) { + Part_Revision partRevision = (Part_Revision) modelObject; + ModelObject[] partRevisions = new ModelObject[]{partRevision}; + // 零件版本-图纸[TC_Is_Represented_By] + dataManagementService.refreshObjects(partRevisions); + dataManagementService.getProperties(partRevisions, new String[]{"TC_Is_Represented_By"}); + ModelObject[] reps = partRevision.get_TC_Is_Represented_By(); + dataManagementService.refreshObjects(reps); + if (reps != null) { + for (ModelObject rep : reps) { + if (rep instanceof ItemRevision) { + ItemRevision itemRevision = (ItemRevision) rep; + specsAttaches.addAll(RevisionHelper.getSpecsAttaches(dataManagementService, itemRevision)); + } + } + } + } + } + fileInfoBeans = getFileInfoBeans(dataManagementService, specsAttaches, types); + } else { + logger.debug("使用物料号和WBS号进行查询未找到对象"); + message.append("使用物料号和WBS号进行查询未找到对象"); + } + return fileInfoBeans; + } + + private List getFileInfoBeans(DataManagementService dataManagementService, List specsAttaches, List types) throws NotLoadedException { + List fileInfoBeans = new ArrayList<>(); + for (ModelObject fileObject : specsAttaches) { + if (fileObject instanceof Dataset) { + Dataset dataset = (Dataset) fileObject; + String type = dataset.get_object_type(); + if (types.isEmpty() || types.contains(type)) { + String name = BaseHelper.getDatasetName(dataManagementService, dataset); + fileInfoBeans.add(new FileInfoBean(dataset.getUid(), name)); + logger.debug("uid: {}, type: {}, name: {}", dataset.getUid(), type, name); + } + } + } + return fileInfoBeans; + } + + private List getProjectItemObjects(DataManagementService dataManagementService, WorkspaceObject currentObject, String factory) throws NotLoadedException { + // 反向查询项目零组件 <出厂编号-项目启动-项目零组件> + List projectItemObjects = ItemHelper.getWhereReferencedObjects(dataManagementService, currentObject, Arrays.asList("出厂编号", "项目启动"), ObjectTypeEnum.PROJECT_ITEM.value()); + // 只保留查询工厂下的项目 + Iterator iterator = projectItemObjects.iterator(); + while (iterator.hasNext()) { + WorkspaceObject object = iterator.next(); + String name = BaseHelper.getOwningGroupName(dataManagementService, (Item) object); + if (StringUtils.isNotBlank(factory)) { + if (!factory.equals(name)) { + iterator.remove(); + } + } + } + return projectItemObjects; + } + + @GetMapping("/getProjectFactoryNo") + public JSONObject getProjectFactoryNo(String factoryNo, String factory) { + SessionContext session = new SessionContext(host, username, password); + BypassHelper.open(); + StringBuilder message = new StringBuilder(); + String projectId = ""; + List factoryNoList = new ArrayList<>(); + try { + DataManagementService dataManagementService = ServiceHelper.getDataManagementService(); + // 查询出厂编号 + Map queryCondition = new HashMap<>(); + queryCondition.put("fid", factoryNo); + ModelObject[] modelObjects = QueryHelper.query("chint_query_FactoryNo", queryCondition); + if (modelObjects != null && modelObjects.length > 0) { + // 找到对象 + ModelObject modelObject = modelObjects[0]; + logger.debug("找到模型对象,uid={} ", modelObject.getUid()); + // ## 直接引用的版本对象,正好符合查找的类型 + List objVevTypes = new ArrayList<>(); + // 公共文件夹 - 出厂编号 + objVevTypes.add("ZT2_ProjectFolder"); + List directObjects = RevisionHelper.getItemRevisionObjects(dataManagementService, (WorkspaceObject) modelObject, objVevTypes); + if (!CollectionUtils.isEmpty(directObjects)) { + for (WorkspaceObject object : directObjects) { + WorkspaceObject[] contents = ItemHelper.getContentObjects(dataManagementService, object, "ZT2_ProjectFolder"); + if (contents != null) { + for (WorkspaceObject content : contents) { + dataManagementService.refreshObjects(new ModelObject[]{content}); + dataManagementService.getProperties(new ModelObject[]{content}, new String[]{"item_id"}); + Item item = (Item) content; + String itemId = item.get_item_id(); + factoryNoList.add(itemId); + } + } + } + } + // 项目 + List projectItemObjects = getProjectItemObjects(dataManagementService, (WorkspaceObject) modelObject, factory); + if (!CollectionUtils.isEmpty(projectItemObjects)) { + WorkspaceObject projectItemObject = projectItemObjects.get(0); + // 获取属性 + dataManagementService.refreshObjects(new ModelObject[]{projectItemObject}); + dataManagementService.getProperties(new ModelObject[]{projectItemObject}, new String[]{"zt2_ProjectNo"}); + Item projectItem = (Item) projectItemObject; + Property prop = projectItem.getPropertyObject("zt2_ProjectNo"); + projectId = prop.toNeutralString(); + } + } + } catch (Exception e) { + logger.error("操作异常", e); + message.append("操作异常,").append(e.getMessage()); + } finally { + BypassHelper.close(); + session.logout(); + } + JSONObject jsonObject = new JSONObject(); + jsonObject.put("projectId", projectId); + jsonObject.put("factoryNo", factoryNo); + jsonObject.put("factoryNoList", factoryNoList); + if (message.length() > 0) { + jsonObject.put("message", message.toString()); + } + return jsonObject; + } +} diff --git a/connor_cpzc_service/src/main/java/com/chint/plm/modules/pojo/DesignInfoBean.java b/connor_cpzc_service/src/main/java/com/chint/plm/modules/pojo/DesignInfoBean.java new file mode 100644 index 0000000..a404b5d --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/chint/plm/modules/pojo/DesignInfoBean.java @@ -0,0 +1,38 @@ +package com.chint.plm.modules.pojo; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.List; + +/** + * @author Admin + */ +public class DesignInfoBean { + + private List file; + + @JsonProperty("Desc") + private String desc; + + + public DesignInfoBean(List file,String desc) { + this.file = file; + this.desc = desc; + } + + public List getFile() { + return file; + } + + public void setFile(List file) { + this.file = file; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + desc = desc; + } +} diff --git a/connor_cpzc_service/src/main/java/com/chint/plm/modules/pojo/FileInfoBean.java b/connor_cpzc_service/src/main/java/com/chint/plm/modules/pojo/FileInfoBean.java new file mode 100644 index 0000000..b4a7ebe --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/chint/plm/modules/pojo/FileInfoBean.java @@ -0,0 +1,31 @@ +package com.chint.plm.modules.pojo; + +/** + * Created by K on 2019/8/13. + * @author Admin + */ +public class FileInfoBean { + private String id; + private String name; + + public FileInfoBean(String id, String name) { + this.id = id; + this.name = name; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/ClientCredentialManager.java b/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/ClientCredentialManager.java new file mode 100644 index 0000000..e4e2f9d --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/ClientCredentialManager.java @@ -0,0 +1,65 @@ +package com.chint.plm.tcclient; + +import com.teamcenter.schemas.soa._2006_03.exceptions.InvalidCredentialsException; +import com.teamcenter.schemas.soa._2006_03.exceptions.InvalidUserException; +import com.teamcenter.soa.client.CredentialManager; +import com.teamcenter.soa.exceptions.CanceledOperationException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.UUID; + +/** + *

+ * 凭据管理器 + *

+ * + * @author Yudy + * @since 2024-03-24 + */ +public class ClientCredentialManager implements CredentialManager { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + private String username = null; + private String password = null; + private String group = ""; // default group + private String role = ""; // default role + private String discriminator = "SoaAppX"; // always connect same user to same instance of server + + @Override + public int getCredentialType() { + return CredentialManager.CLIENT_CREDENTIAL_TYPE_STD; + } + + @Override + public String[] getCredentials(InvalidCredentialsException e) throws CanceledOperationException { + logger.error("无效的凭据", e); + return promptForCredentials(username, password); + } + + @Override + public String[] getCredentials(InvalidUserException e) throws CanceledOperationException { + logger.error("无效的用户", e); + return promptForCredentials(username, password); + } + + @Override + public void setUserPassword(String username, String password, String discriminator) { + this.username = username; + this.password = password; + this.discriminator = discriminator; + } + + @Override + public void setGroupRole(String group, String role) { + this.group = group; + this.role = role; + } + + public String[] promptForCredentials(String username, String password) { + this.username = username; + this.password = password; + return new String[]{username, password, group, role, UUID.randomUUID().toString()}; + } +} diff --git a/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/ClientExceptionHandler.java b/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/ClientExceptionHandler.java new file mode 100644 index 0000000..4e2c4af --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/ClientExceptionHandler.java @@ -0,0 +1,33 @@ +package com.chint.plm.tcclient; + +import com.teamcenter.schemas.soa._2006_03.exceptions.ConnectionException; +import com.teamcenter.schemas.soa._2006_03.exceptions.InternalServerException; +import com.teamcenter.schemas.soa._2006_03.exceptions.ProtocolException; +import com.teamcenter.soa.client.ExceptionHandler; +import com.teamcenter.soa.exceptions.CanceledOperationException; + +/** + *

+ * 异常处理 + *

+ * + * @author Yudy + * @since 2024-03-24 + */ +public class ClientExceptionHandler implements ExceptionHandler { + + @Override + public void handleException(InternalServerException e) { + if (e instanceof ConnectionException) { + throw new RuntimeException("soa connection failed", e); + } else if (e instanceof ProtocolException) { + throw new RuntimeException("soa connection failed", e); + } + throw new RuntimeException("内部服务器异常", e); + } + + @Override + public void handleException(CanceledOperationException e) { + throw new RuntimeException("取消操作异常", e); + } +} diff --git a/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/SessionContext.java b/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/SessionContext.java new file mode 100644 index 0000000..b412b4d --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/SessionContext.java @@ -0,0 +1,123 @@ +package com.chint.plm.tcclient; + +import com.chint.plm.tcclient.listener.ClientChangeListener; +import com.chint.plm.tcclient.listener.ClientDeleteListener; +import com.chint.plm.tcclient.listener.ClientPartialErrorListener; +import com.chint.plm.tcclient.listener.ClientRequestListener; +import com.teamcenter.clientx.AppXExceptionHandler; +import com.teamcenter.schemas.soa._2006_03.exceptions.InvalidCredentialsException; +import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException; +import com.teamcenter.services.strong.core.SessionService; +import com.teamcenter.services.strong.core._2006_03.Session.LoginResponse; +import com.teamcenter.soa.SoaConstants; +import com.teamcenter.soa.client.Connection; +import com.teamcenter.soa.client.model.strong.User; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + *

+ * 会话环境 + *

+ * + * @author Yudy + * @since 2024-03-24 + */ +public class SessionContext { + + private static final Logger logger = LoggerFactory.getLogger(SessionContext.class); + + private static Connection connection; + + private static ClientCredentialManager credentialManager; + + private static User user; + + public SessionContext(String host) { + // Create an instance of the CredentialManager, this is used + // by the SOA Framework to get the user's credentials when + // challanged by the server (sesioin timeout on the web tier). + credentialManager = new ClientCredentialManager(); + + String protocol = (host.startsWith("http")) ? SoaConstants.HTTP : SoaConstants.IIOP; + + // Create the Connection object, no contact is made with the server + // until a service request is made + connection = new Connection(host, credentialManager, SoaConstants.REST, protocol); + + // Add an ExceptionHandler to the Connection, this will handle any + // InternalServerException, communication errors, xml marshalling errors + // .etc + connection.setExceptionHandler(new AppXExceptionHandler()); + + // While the above ExceptionHandler is required, all of the following + // Listeners are optional. Client application can add as many or as few Listeners + // of each type that they want. + + // Add a Partial Error Listener, this will be notified when ever a + // a service returns partial errors. + connection.getModelManager().addPartialErrorListener(new ClientPartialErrorListener()); + + // Add a Change Listener, this will be notified when ever a + // a service returns model objects that have been updated. + connection.getModelManager().addChangeListener(new ClientChangeListener()); + + // Add a Delete Listener, this will be notified when ever a + // a service returns objects that have been deleted. + connection.getModelManager().addDeleteListener(new ClientDeleteListener()); + + // Add a Request Listener, this will be notified before and after each + // service request is sent to the server. + Connection.addRequestListener(new ClientRequestListener()); + } + + public SessionContext(String host, String username, String password) { + this(host); + User user = login(username, password); + logger.info("登录成功,{}", user.getUid()); + } + + public static Connection getConnection() { + if (connection == null) { + throw new RuntimeException("请先创建连接"); + } + return connection; + } + + public static User getUser() { + if (user == null) { + throw new RuntimeException("请先登录"); + } + return user; + } + + public User login(String username, String password) { + SessionService sessionService = SessionService.getService(connection); + String[] credentials = credentialManager.promptForCredentials(username, password); + try { + LoginResponse response = sessionService.login( + credentials[0], + credentials[1], + credentials[2], + credentials[3], + credentials[4]); + if (response != null) { + user = response.user; + return user; + } else { + return null; + } + } catch (InvalidCredentialsException e) { + throw new RuntimeException("登录失败", e); + } + } + + public void logout() { + SessionService sessionService = SessionService.getService(connection); + try { + sessionService.logout(); + } catch (ServiceException e) { + logger.error("服务异常", e); + } + } +} diff --git a/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/enums/ObjectTypeEnum.java b/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/enums/ObjectTypeEnum.java new file mode 100644 index 0000000..2577260 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/enums/ObjectTypeEnum.java @@ -0,0 +1,38 @@ +package com.chint.plm.tcclient.enums; + +/** + *

+ * 对象类型枚举 + *

+ * + * @author Yudy + * @since 2024-03-24 + */ +public enum ObjectTypeEnum { + + PROJECT_ITEM("ZT2_ProjectItem", "项目零组件"), + PROJECT_FOLDER("ZT2_ProjectFolder", "公共文件夹"), + DESIGN("ZT2_Design3D", "图纸模型"), + DESIGN_REVISION("ZT2_Design3DRevision", "图纸模型版本"), + DOCUMENT("Document", "文档"), + DOCUMENT_REVISION("DocumentRevision", "文档版本"), + FACTORY_NO("ZT2_FactoryNo", "出厂编号"), + ; + + private final String code; + + private final String name; + + ObjectTypeEnum(String code, String name) { + this.code = code; + this.name = name; + } + + public String value() { + return code; + } + + public String display() { + return name; + } +} diff --git a/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/helper/BaseHelper.java b/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/helper/BaseHelper.java new file mode 100644 index 0000000..b407867 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/helper/BaseHelper.java @@ -0,0 +1,91 @@ +package com.chint.plm.tcclient.helper; + +import com.teamcenter.services.strong.core.DataManagementService; +import com.teamcenter.soa.client.model.ModelObject; +import com.teamcenter.soa.client.model.ServiceData; +import com.teamcenter.soa.client.model.strong.Dataset; +import com.teamcenter.soa.client.model.strong.Item; +import com.teamcenter.soa.exceptions.NotLoadedException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + *

+ * 基础助手 + *

+ * + * @author Yudy + * @since 2024-03-24 + */ +public class BaseHelper { + + protected static final Logger logger = LoggerFactory.getLogger(BaseHelper.class); + + /** + * 局部错误处理 + * + * @param serviceData 服务数据 + */ + public static void throwServiceDataError(ServiceData serviceData) { + if (serviceData != null && serviceData.sizeOfPartialErrors() > 0) { + StringBuilder errInfo = new StringBuilder(); + for (int i = 0; i < serviceData.sizeOfPartialErrors(); i++) { + for (String message : serviceData.getPartialError(i).getMessages()) { + errInfo.append(message).append("\n\r"); + } + } + throw new RuntimeException(errInfo.toString()); + } + } + + /** + * 获取数据集名称 + * + * @param dataManagementService 数据管理服务 + * @param dataset 数据集 + * @return 数据集名称 + * @throws NotLoadedException 没有载入异常 + */ + public static String getDatasetName(DataManagementService dataManagementService, Dataset dataset) throws NotLoadedException { + dataManagementService.refreshObjects(new ModelObject[]{dataset}); + dataManagementService.getProperties(new ModelObject[]{dataset}, new String[]{"object_name"}); + return dataset.get_object_name(); + } + + /** + * 获取所属组名称 + * + * @param dataManagementService 数据管理服务 + * @param item Item + * @return 所属组名称 + * @throws NotLoadedException 没有载入异常 + */ + public static String getOwningGroupName(DataManagementService dataManagementService, Item item) throws NotLoadedException { + dataManagementService.getProperties(new ModelObject[]{item}, new String[]{"owning_group"}); + ModelObject owningGroup = item.get_owning_group(); + /* + // 等效于 + // Property prop = projectItem.getPropertyObject("owning_group"); + // ModelObject owningGroup = prop.getModelObjectValue(); + */ + dataManagementService.refreshObjects(new ModelObject[]{owningGroup}); + dataManagementService.getProperties(new ModelObject[]{owningGroup}, new String[]{"name"}); + return owningGroup.getPropertyObject("name").getStringValue(); + } + + /** + * 获取所属用户名称 + * + * @param dataManagementService 数据管理服务 + * @param item Item + * @return 所属用户名称 + * @throws NotLoadedException 没有载入异常 + */ + public static String getOwningUserName(DataManagementService dataManagementService, Item item) throws NotLoadedException { + dataManagementService.getProperties(new ModelObject[]{item}, new String[]{"owning_user"}); + ModelObject owningUser = item.get_owning_user(); + dataManagementService.refreshObjects(new ModelObject[]{owningUser}); + dataManagementService.getProperties(new ModelObject[]{owningUser}, new String[]{"user_name"}); + return owningUser.getPropertyObject("user_name").getStringValue(); + } +} diff --git a/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/helper/BypassHelper.java b/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/helper/BypassHelper.java new file mode 100644 index 0000000..1555e55 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/helper/BypassHelper.java @@ -0,0 +1,37 @@ +package com.chint.plm.tcclient.helper; + +import com.s8.services.strong.bypass._2016_05.S8SoaBypassService; + +/** + *

+ * 旁路助手 + *

+ * + * @author Yudy + * @since 2024-03-24 + */ +public class BypassHelper { + + /** + * 旁路开关 + * @param flag 开关 + */ + public static void bypass(boolean flag) { + S8SoaBypassService service = ServiceHelper.getS8SoaBypassService(); + service.setBypass(flag); + } + + /** + * 开旁路 + */ + public static void open() { + bypass(true); + } + + /** + * 关旁路 + */ + public static void close() { + bypass(false); + } +} diff --git a/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/helper/ItemHelper.java b/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/helper/ItemHelper.java new file mode 100644 index 0000000..05a57da --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/helper/ItemHelper.java @@ -0,0 +1,313 @@ +package com.chint.plm.tcclient.helper; + +import com.chint.plm.tcclient.enums.ObjectTypeEnum; +import com.teamcenter.services.strong.core.DataManagementService; +import com.teamcenter.services.strong.core._2007_01.DataManagement; +import com.teamcenter.soa.client.model.ModelObject; +import com.teamcenter.soa.client.model.strong.Folder; +import com.teamcenter.soa.client.model.strong.Item; +import com.teamcenter.soa.client.model.strong.WorkspaceObject; +import com.teamcenter.soa.exceptions.NotLoadedException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.List; + +/** + *

+ * Item 助手 + *

+ * + * @author Yudy + * @since 2024-03-24 + */ +public class ItemHelper extends BaseHelper { + + private static final Logger logger = LoggerFactory.getLogger(ItemHelper.class); + + /** + * 获取内容对象 + * + * @param dataManagementService 数据管理服务 + * @param currentObject 当前工作对象 + * @return 内容对象 + * @throws NotLoadedException 没有载入异常 + */ + public static WorkspaceObject[] getContentObjects(DataManagementService dataManagementService, WorkspaceObject currentObject) throws NotLoadedException { + Folder folder = (Folder) currentObject; + dataManagementService.refreshObjects(new ModelObject[]{folder}); + dataManagementService.getProperties(new ModelObject[]{folder}, new String[]{"contents"}); + return folder.get_contents(); + } + + /** + * 获取内容对象 + * + * @param dataManagementService 数据管理服务 + * @param currentObject 当前工作对象 + * @param objectType 对象类型 + * @return 内容对象 + * @throws NotLoadedException 没有载入异常 + */ + public static WorkspaceObject[] getContentObjects(DataManagementService dataManagementService, WorkspaceObject currentObject, String objectType) throws NotLoadedException { + dataManagementService.getProperties( + new ModelObject[]{currentObject}, + new String[]{"object_type", "object_string"}); + logger.debug("找到内容对象 类型:<{}>,名称:<{}>", currentObject.get_object_type(), currentObject.get_object_string()); + if (objectType.equals(currentObject.get_object_type())) { + return getContentObjects(dataManagementService, currentObject); + } else { + return new WorkspaceObject[0]; + } + } + + /** + * 获取内容对象 + * + * @param dataManagementService 数据管理服务 + * @param currentObject 当前工作对象 + * @param objectType 对象类型 + * @param objectName 对象名称 + * @return 内容对象 + * @throws NotLoadedException 没有载入异常 + */ + public static WorkspaceObject[] getContentObjects(DataManagementService dataManagementService, WorkspaceObject currentObject, String objectType, String objectName) throws NotLoadedException { + dataManagementService.getProperties( + new ModelObject[]{currentObject}, + new String[]{"object_type", "object_string"}); + logger.debug("找到内容对象 类型:<{}>,名称:<{}>", currentObject.get_object_type(), currentObject.get_object_string()); + if (objectType.equals(currentObject.get_object_type()) && objectName.equals(currentObject.get_object_string())) { + return getContentObjects(dataManagementService, currentObject); + } else { + return new WorkspaceObject[0]; + } + } + + /** + * 获取引用对象 + * + * @param dataManagementService 数据管理服务 + * @param currentObject 当前工作对象 + * @return 引用对象 + * @throws NotLoadedException 没有载入异常 + */ + public static ModelObject[] getReferenceObjects(DataManagementService dataManagementService, WorkspaceObject currentObject) throws NotLoadedException { + Item item = (Item) currentObject; + dataManagementService.getProperties(new ModelObject[]{item}, new String[]{"IMAN_reference"}); + return item.get_IMAN_reference(); + } + + /** + * 获取引用对象 + * + * @param dataManagementService 数据管理服务 + * @param currentObjects 当前工作对象 + * @param projectFolders 公共文件夹目录 + * @param targetObjectTypes 目标对象类型 + * @return 引用对象 + * @throws NotLoadedException 没有载入异常 + */ + public static List getReferenceObjects(DataManagementService dataManagementService, List currentObjects, List projectFolders, List targetObjectTypes) throws NotLoadedException { + List resultObjects = new ArrayList<>(); + if (!currentObjects.isEmpty()) { + for (WorkspaceObject currentObject : currentObjects) { + resultObjects.addAll(ItemHelper.getReferenceObjects(dataManagementService, currentObject, projectFolders, targetObjectTypes)); + } + } + return resultObjects; + } + + /** + * 获取引用对象 + * + * @param dataManagementService 数据管理服务 + * @param currentObject 当前工作对象 + * @param projectFolders 公共文件夹目录 + * @param targetObjectTypes 目标对象类型 + * @return 引用对象 + * @throws NotLoadedException 没有载入异常 + */ + public static List getReferenceObjects(DataManagementService dataManagementService, WorkspaceObject currentObject, List projectFolders, List targetObjectTypes) throws NotLoadedException { + List resultObjects = new ArrayList<>(); + // 引用对象集合 + ModelObject[] referenceObjects = ItemHelper.getReferenceObjects(dataManagementService, currentObject); + if (referenceObjects != null) { + for (ModelObject modelObject : referenceObjects) { + WorkspaceObject referenceObject = (WorkspaceObject) modelObject; + String type = referenceObject.get_object_type(); + String name = referenceObject.get_object_string(); + logger.debug("找到引用对象 类型:<{}>,名称:<{}>", type, name); + List contentObjects = getReferenceContentObjects(dataManagementService, referenceObject, projectFolders, targetObjectTypes); + resultObjects.addAll(contentObjects); + } + } + return resultObjects; + } + + /** + * 获取内容对象 + * + * @param dataManagementService 数据管理服务 + * @param referenceObject 当前工作对象 + * @param projectFolders 公共文件夹目录 + * @param targetObjectTypes 目标对象类型 + * @return 内容对象 + * @throws NotLoadedException 没有载入异常 + */ + private static List getReferenceContentObjects(DataManagementService dataManagementService, WorkspaceObject referenceObject, List projectFolders, List targetObjectTypes) throws NotLoadedException { + return getReferenceContentObjects(dataManagementService, referenceObject, projectFolders, 0, targetObjectTypes); + } + + /** + * 获取内容对象 + * + * @param dataManagementService 数据管理服务 + * @param referenceObject 当前工作对象 + * @param projectFolders 公共文件夹目录 + * @param findIndex 查找索引 + * @param targetObjectTypes 目标对象类型 + * @return 内容对象 + * @throws NotLoadedException 没有载入异常 + */ + private static List getReferenceContentObjects(DataManagementService dataManagementService, WorkspaceObject referenceObject, List projectFolders, int findIndex, List targetObjectTypes) throws NotLoadedException { + List resultObjects = new ArrayList<>(); + String type = referenceObject.get_object_type(); + String name = referenceObject.get_object_string(); + if (ObjectTypeEnum.PROJECT_FOLDER.value().equals(type)) { + // 公共文件夹 + if (projectFolders != null && projectFolders.size() > findIndex) { + String projectFolder = projectFolders.get(findIndex); + if (name.equals(projectFolder)) { + WorkspaceObject[] contentObjects = getContentObjects(dataManagementService, referenceObject); + if (contentObjects != null) { + for (WorkspaceObject contentObject : contentObjects) { + logger.debug("找到内容对象 类型:<{}>,名称:<{}>", contentObject.get_object_type(), contentObject.get_object_string()); + List subContentObjects = getReferenceContentObjects(dataManagementService, contentObject, projectFolders, findIndex + 1, targetObjectTypes); + resultObjects.addAll(subContentObjects); + } + } + } + } + } else if (targetObjectTypes.contains(type)) { + // 目标对象 + resultObjects.add(referenceObject); + } + return resultObjects; + } + + /** + * 获取何处引用信息 + * + * @param dataManagementService 数据管理服务 + * @param currentObject 当前工作对象 + * @return 引用信息 + * @throws NotLoadedException 没有载入异常 + */ + public static List getWhereReferencedInfos(DataManagementService dataManagementService, WorkspaceObject currentObject) throws NotLoadedException { + List referencedInfos = new ArrayList<>(); + // 何处引用响应 + DataManagement.WhereReferencedResponse referencedResponse = dataManagementService.whereReferenced(new WorkspaceObject[]{currentObject}, 1); + throwServiceDataError(referencedResponse.serviceData); + int outputSize = referencedResponse.output.length; + logger.debug("找到引用输出 {} 项", outputSize); + for (int i = 0; i < outputSize; i++) { + // 何处引用输出 + DataManagement.WhereReferencedOutput referencedOutput = referencedResponse.output[i]; + int infoSize = referencedOutput.info.length; + logger.debug("找到引用信息 {} 项", infoSize); + for (int j = 0; j < infoSize; j++) { + // 何处引用信息 + DataManagement.WhereReferencedInfo referencedInfo = referencedOutput.info[j]; + // 当前引用对象 + WorkspaceObject referencedObject = referencedInfo.referencer; + if (referencedObject != null) { + referencedInfos.add(referencedInfo); + } + } + } + return referencedInfos; + } + + /** + * 获取何处引用对象 + * + * @param dataManagementService 数据管理服务 + * @param currentObject 当前工作对象 + * @return 引用对象 + * @throws NotLoadedException 没有载入异常 + */ + public static List getWhereReferencedObjects(DataManagementService dataManagementService, WorkspaceObject currentObject) throws NotLoadedException { + List referencedObjects = new ArrayList<>(); + List referencedInfos = getWhereReferencedInfos(dataManagementService, currentObject); + if (!referencedInfos.isEmpty()) { + for (DataManagement.WhereReferencedInfo referencedInfo : referencedInfos) { + // 当前引用对象 + WorkspaceObject referencedObject = referencedInfo.referencer; + if (referencedObject != null) { + referencedObjects.add(referencedObject); + } + } + } + return referencedObjects; + } + + /** + * 查找何处引用对象 + * + * @param dataManagementService 数据管理服务 + * @param currentObject 当前工作对象 + * @param projectFolders 公共文件夹目录 + * @param targetObjectType 目标对象类型 + * @return 引用对象 + * @throws NotLoadedException 没有载入异常 + */ + public static List getWhereReferencedObjects(DataManagementService dataManagementService, WorkspaceObject currentObject, List projectFolders, String targetObjectType) throws NotLoadedException { + return getWhereReferencedObjects(dataManagementService, currentObject, projectFolders, 0, targetObjectType); + } + + /** + * 查找何处引用对象 + * + * @param dataManagementService 数据管理服务 + * @param currentObject 当前工作对象 + * @param projectFolders 公共文件夹目录 + * @param findIndex 查找索引 + * @param targetObjectType 目标对象类型 + * @return 引用对象 + * @throws NotLoadedException 没有载入异常 + */ + private static List getWhereReferencedObjects(DataManagementService dataManagementService, WorkspaceObject currentObject, List projectFolders, int findIndex, String targetObjectType) throws NotLoadedException { + List resultObjects = new ArrayList<>(); + List referencedInfos = getWhereReferencedInfos(dataManagementService, currentObject); + if (!referencedInfos.isEmpty()) { + for (DataManagement.WhereReferencedInfo referencedInfo : referencedInfos) { + WorkspaceObject referencedObject = referencedInfo.referencer; + if (referencedObject != null) { + // 刷新对象(设置属性) + dataManagementService.refreshObjects(new ModelObject[]{currentObject}); + // 获取属性 + dataManagementService.getProperties( + new ModelObject[]{referencedObject}, + new String[]{"object_type", "object_string"}); + String type = referencedObject.get_object_type(); + String name = referencedObject.get_object_string(); + logger.debug("找到引用对象 类型:<{}>,名称:<{}>,关系:<{}>", type, name, referencedInfo.relation); + if (ObjectTypeEnum.PROJECT_FOLDER.value().equals(type)) { + // 公共文件夹 + if (projectFolders != null && projectFolders.size() > findIndex) { + String projectFolder = projectFolders.get(findIndex); + if (name.equals(projectFolder)) { + resultObjects.addAll(getWhereReferencedObjects(dataManagementService, referencedObject, projectFolders, findIndex + 1, targetObjectType)); + } + } + } else if (targetObjectType.equals(type)) { + // 目标对象 + resultObjects.add(referencedObject); + } + } + } + } + return resultObjects; + } +} diff --git a/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/helper/QueryHelper.java b/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/helper/QueryHelper.java new file mode 100644 index 0000000..e74ce41 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/helper/QueryHelper.java @@ -0,0 +1,69 @@ +package com.chint.plm.tcclient.helper; + +import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException; +import com.teamcenter.services.strong.query.SavedQueryService; +import com.teamcenter.services.strong.query._2006_03.SavedQuery; +import com.teamcenter.soa.client.model.ModelObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.LinkedHashMap; +import java.util.Map; + +/** + *

+ * 模型对象助手 + *

+ * + * @author Yudy + * @since 2024-03-24 + */ +public class QueryHelper extends BaseHelper { + + private static final Logger logger = LoggerFactory.getLogger(QueryHelper.class); + + private static Map getSavedQueryObjectMap(SavedQueryService queryService) throws ServiceException { + Map map = new LinkedHashMap<>(); + // 获取保存的查询 + SavedQuery.GetSavedQueriesResponse savedQueries = queryService.getSavedQueries(); + SavedQuery.SavedQueryObject[] savedQueryObjects = savedQueries.queries; + if (savedQueryObjects != null && savedQueryObjects.length > 0) { + for (SavedQuery.SavedQueryObject savedQueryObject : savedQueryObjects) { + map.put(savedQueryObject.name, savedQueryObject); + } + } else { + throw new RuntimeException("没有找到任何保存的查询"); + } + return map; + } + + public static ModelObject[] query(String queryName, Map queryCondition) throws Exception { + if (queryName != null && !"".equals(queryName) && queryCondition != null && !queryCondition.isEmpty()) { + // 保存的查询服务 + SavedQueryService queryService = ServiceHelper.getSavedQueryService(); + Map queryObjectMap = getSavedQueryObjectMap(queryService); + SavedQuery.SavedQueryObject queryObject = queryObjectMap.get(queryName); + if (queryObject != null) { + logger.info("执行查询:{}", queryName); + logger.info("查询键:{}", queryCondition.keySet()); + logger.info("查询值:{}", queryCondition.values()); + // 新建查询输入 + com.teamcenter.services.strong.query._2007_06.SavedQuery.SavedQueryInput savedQueryInput = new com.teamcenter.services.strong.query._2007_06.SavedQuery.SavedQueryInput(); + savedQueryInput.query = queryObject.query; + savedQueryInput.entries = queryCondition.keySet().toArray(new String[]{});// new String[]{"Item ID"}; + savedQueryInput.values = queryCondition.values().toArray(new String[]{}); // new String[]{itemID}; + // 执行查询 + com.teamcenter.services.strong.query._2007_06.SavedQuery.ExecuteSavedQueriesResponse response = queryService.executeSavedQueries(new com.teamcenter.services.strong.query._2007_06.SavedQuery.SavedQueryInput[]{savedQueryInput}); + // 错误处理 + throwServiceDataError(response.serviceData); + // 查询结果 + com.teamcenter.services.strong.query._2007_06.SavedQuery.SavedQueryResults queryResults = response.arrayOfResults[0]; + return queryResults.objects; + } else { + throw new RuntimeException("查询名称不存在:" + queryName); + } + } else { + return null; + } + } +} diff --git a/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/helper/RevisionHelper.java b/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/helper/RevisionHelper.java new file mode 100644 index 0000000..4456af2 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/helper/RevisionHelper.java @@ -0,0 +1,176 @@ +package com.chint.plm.tcclient.helper; + +import com.teamcenter.services.strong.core.DataManagementService; +import com.teamcenter.services.strong.core._2007_01.DataManagement; +import com.teamcenter.soa.client.model.ModelObject; +import com.teamcenter.soa.client.model.strong.Item; +import com.teamcenter.soa.client.model.strong.ItemRevision; +import com.teamcenter.soa.client.model.strong.ReleaseStatus; +import com.teamcenter.soa.client.model.strong.WorkspaceObject; +import com.teamcenter.soa.exceptions.NotLoadedException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + *

+ * 版本助手 + *

+ * + * @author Yudy + * @since 2024-03-24 + */ +public class RevisionHelper extends BaseHelper { + + private static final Logger logger = LoggerFactory.getLogger(RevisionHelper.class); + + /** + * 获取模型版本对象 + * + * @param dataManagementService 数据管理服务 + * @param currentObjects 当前工作对象 + * @return 模型版本 + * @throws NotLoadedException 没有载入异常 + */ + public static List getItemRevisionObjects(DataManagementService dataManagementService, List currentObjects) throws NotLoadedException { + List resultObjects = new ArrayList<>(); + if (currentObjects != null) { + for (WorkspaceObject currentObject : currentObjects) { + resultObjects.addAll(getItemRevisionObjects(dataManagementService, currentObject)); + } + } + return resultObjects; + } + + /** + * 获取模型版本对象-取最新状态 + * + * @param dataManagementService 数据管理服务 + * @param currentObject 当前工作对象 + * @return 模型版本 + * @throws NotLoadedException 没有载入异常 + */ + public static List getItemRevisionObjects(DataManagementService dataManagementService, WorkspaceObject currentObject) throws NotLoadedException { + List resultObjects = new ArrayList<>(); + Item item = (Item) currentObject; + dataManagementService.getProperties(new ModelObject[]{item}, new String[]{"revision_list"}); + // 所有版本 + ModelObject[] modelObjects = item.get_revision_list(); + if (modelObjects != null) { + int lastRevisionNo = -1; + // 最新版本 + ItemRevision lastRevisionObject = null; + // 循环所有版本 + for (ModelObject modelObject : modelObjects) { + ItemRevision revisionObject = (ItemRevision) modelObject; + dataManagementService.getProperties( + new ModelObject[]{revisionObject}, + new String[]{"release_status_list"}); + // 发布状态 + ReleaseStatus[] releaseStatuses = revisionObject.get_release_status_list(); + if (releaseStatuses.length == 0) { + continue; + } + // 最新版本 + dataManagementService.getProperties(new ModelObject[]{revisionObject}, new String[]{"item_revision_id"}); + String uid = revisionObject.getUid(); + String name = revisionObject.get_object_string(); + String revisionId = revisionObject.get_item_revision_id(); + int currRevisionNo = 0; + try { + currRevisionNo = Integer.parseInt(revisionId.replace("V", "")); + } catch (Exception e) { + logger.error("获取最新版本异常," + uid + " - " + name, e); + // throw new RuntimeException("获取最新版本异常," + uid + " - " + name, e); + } + // 比较版本大小 + if (currRevisionNo > lastRevisionNo) { + lastRevisionNo = currRevisionNo; + lastRevisionObject = revisionObject; + } + } + if (lastRevisionObject != null) { + dataManagementService.getProperties( + new ModelObject[]{lastRevisionObject}, + new String[]{"object_type", "object_string"}); + logger.debug("找到模型版本 类型:<{}>,名称:<{}>", lastRevisionObject.get_object_type(), lastRevisionObject.get_object_string()); + resultObjects.add(lastRevisionObject); + } + } + return resultObjects; + } + + /** + * 获取模型版本对象 - 直接引用的上级 + * + * @param dataManagementService 数据管理服务 + * @param currentObject 当前工作对象 + * @param targetObjectTypes 目标对象类型 + * @return 引用对象模型版本 + * @throws NotLoadedException 没有载入异常 + */ + public static List getItemRevisionObjects(DataManagementService dataManagementService, WorkspaceObject currentObject, List targetObjectTypes) throws NotLoadedException { + List resultObjects = new ArrayList<>(); + List referencedInfos = ItemHelper.getWhereReferencedInfos(dataManagementService, currentObject); + if (!referencedInfos.isEmpty()) { + for (DataManagement.WhereReferencedInfo referencedInfo : referencedInfos) { + WorkspaceObject referencedObject = referencedInfo.referencer; + if (referencedObject != null) { + // 获取属性 + dataManagementService.getProperties( + new ModelObject[]{referencedObject}, + new String[]{"object_type", "object_string", "IMAN_specification"}); + String type = referencedObject.get_object_type(); + String name = referencedObject.get_object_string(); + logger.warn("找到引用对象 类型:<{}>,名称:<{}>,关系:<{}>", type, name, referencedInfo.relation); + if (targetObjectTypes.contains(type)) { + resultObjects.add(referencedObject); + } + } + } + } + return resultObjects; + } + + /** + * 获取版本对象下的规范与附加 + * + * @param dataManagementService 数据管理服务 + * @param itemRevisionObjects 版本对象集合 + * @return 规范与附加 + * @throws NotLoadedException 没有载入异常 + */ + public static List getSpecsAttaches(DataManagementService dataManagementService, List itemRevisionObjects) throws NotLoadedException { + List specsAttaches = new ArrayList<>(); + if (itemRevisionObjects != null && itemRevisionObjects.size() > 0) { + for (WorkspaceObject itemRevisionObject : itemRevisionObjects) { + specsAttaches.addAll(getSpecsAttaches(dataManagementService, itemRevisionObject)); + } + } + return specsAttaches; + } + + /** + * 获取版本对象下的规范与附加 + * + * @param dataManagementService 数据管理服务 + * @param itemRevisionObject 版本对象 + * @return 规范与附加 + * @throws NotLoadedException 没有载入异常 + */ + public static List getSpecsAttaches(DataManagementService dataManagementService, WorkspaceObject itemRevisionObject) throws NotLoadedException { + List specsAttaches = new ArrayList<>(); + ItemRevision revision = (ItemRevision) itemRevisionObject; + dataManagementService.getProperties(new ModelObject[]{revision}, new String[]{"IMAN_specification", "TC_Attaches"}); + // 规范[IMAN_specification] + ModelObject[] specs = revision.get_IMAN_specification(); + // 附加[TC_Attaches] + ModelObject[] attaches = revision.get_TC_Attaches(); + specsAttaches.addAll(new ArrayList<>(Arrays.asList(specs))); + specsAttaches.addAll(new ArrayList<>(Arrays.asList(attaches))); + return specsAttaches; + } +} diff --git a/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/helper/ServiceHelper.java b/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/helper/ServiceHelper.java new file mode 100644 index 0000000..6cc0965 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/helper/ServiceHelper.java @@ -0,0 +1,35 @@ +package com.chint.plm.tcclient.helper; + +import com.chint.plm.tcclient.SessionContext; +import com.s8.services.strong.bypass.S8SoaBypassServiceService; +import com.s8.services.strong.bypass._2016_05.S8SoaBypassService; +import com.teamcenter.services.strong.core.DataManagementService; +import com.teamcenter.services.strong.query.SavedQueryService; +import com.teamcenter.soa.client.Connection; + +/** + *

+ * 服务助手 + *

+ * + * @author Yudy + * @since 2024-03-24 + */ +public class ServiceHelper { + + public static Connection getConnection() { + return SessionContext.getConnection(); + } + + public static S8SoaBypassService getS8SoaBypassService() { + return S8SoaBypassServiceService.getService(getConnection()); + } + + public static DataManagementService getDataManagementService() { + return DataManagementService.getService(getConnection()); + } + + public static SavedQueryService getSavedQueryService() { + return SavedQueryService.getService(getConnection()); + } +} diff --git a/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/listener/ClientChangeListener.java b/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/listener/ClientChangeListener.java new file mode 100644 index 0000000..b05d7a0 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/listener/ClientChangeListener.java @@ -0,0 +1,39 @@ +package com.chint.plm.tcclient.listener; + +import com.teamcenter.soa.client.model.ChangeListener; +import com.teamcenter.soa.client.model.ModelObject; +import com.teamcenter.soa.exceptions.NotLoadedException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + *

+ * 改变监听器 + *

+ * + * @author Yudy + * @since 2024-03-24 + */ +public class ClientChangeListener implements ChangeListener { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Override + public void modelObjectChange(ModelObject[] modelObjects) { + if (modelObjects != null) { + for (ModelObject modelObject : modelObjects) { + String uid = modelObject.getUid(); + String type = modelObject.getTypeObject().getName(); + String name = ""; + if (modelObject.getTypeObject().isInstanceOf("WorkspaceObject")) { + try { + name = modelObject.getPropertyObject("object_string").getStringValue(); + } catch (NotLoadedException e) { + throw new RuntimeException("没有载入", e); + } + } + logger.info("模型对象改变监听:{} | {} | {}", uid, type, name); + } + } + } +} diff --git a/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/listener/ClientDeleteListener.java b/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/listener/ClientDeleteListener.java new file mode 100644 index 0000000..616482e --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/listener/ClientDeleteListener.java @@ -0,0 +1,27 @@ +package com.chint.plm.tcclient.listener; + +import com.teamcenter.soa.client.model.DeleteListener; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + *

+ * 删除监听器 + *

+ * + * @author Yudy + * @since 2024-03-24 + */ +public class ClientDeleteListener implements DeleteListener { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Override + public void modelObjectDelete(String[] uids) { + if (uids != null) { + for (String string : uids) { + logger.info("模型对象删除监听:{}", string); + } + } + } +} diff --git a/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/listener/ClientPartialErrorListener.java b/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/listener/ClientPartialErrorListener.java new file mode 100644 index 0000000..e0d912b --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/listener/ClientPartialErrorListener.java @@ -0,0 +1,43 @@ +package com.chint.plm.tcclient.listener; + +import com.teamcenter.soa.client.model.ErrorStack; +import com.teamcenter.soa.client.model.ErrorValue; +import com.teamcenter.soa.client.model.PartialErrorListener; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + *

+ * 局部错误监听器 + *

+ * + * @author Yudy + * @since 2024-03-24 + */ +public class ClientPartialErrorListener implements PartialErrorListener { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Override + public void handlePartialError(ErrorStack[] errorStacks) { + if (errorStacks != null) { + for (ErrorStack errorStack : errorStacks) { + if (errorStack.hasClientId()) { + logger.error("局部错误监听:clientId - {} ", errorStack.getClientId()); + } + if (errorStack.hasClientIndex()) { + logger.error("局部错误监听:clientIndex - {} ", errorStack.getClientIndex()); + } + if (errorStack.hasAssociatedObject()) { + logger.error("局部错误监听:associatedObjectUid - {} ", errorStack.getAssociatedObject().getUid()); + } + ErrorValue[] errorValues = errorStack.getErrorValues(); + if (errorValues != null) { + for (ErrorValue errorValue : errorValues) { + logger.error("错误信息:{} - {} - {}", errorValue.getLevel(), errorValue.getCode(), errorValue.getMessage()); + } + } + } + } + } +} diff --git a/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/listener/ClientRequestListener.java b/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/listener/ClientRequestListener.java new file mode 100644 index 0000000..87edd95 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/listener/ClientRequestListener.java @@ -0,0 +1,28 @@ +package com.chint.plm.tcclient.listener; + +import com.teamcenter.soa.client.RequestListener; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + *

+ * 请求监听器 + *

+ * + * @author Yudy + * @since 2024-03-24 + */ +public class ClientRequestListener implements RequestListener { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Override + public void serviceRequest(final Info info) { + logger.info("服务请求监听:{} - {}.{}", info.id, info.service, info.operation); + } + + @Override + public void serviceResponse(final Info info) { + logger.info("服务响应监听:{} - {}.{}", info.id, info.service, info.operation); + } +} diff --git a/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/pojo/FindObjectInfo.java b/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/pojo/FindObjectInfo.java new file mode 100644 index 0000000..c5cbec4 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/chint/plm/tcclient/pojo/FindObjectInfo.java @@ -0,0 +1,38 @@ +package com.chint.plm.tcclient.pojo; + +/** + *

+ * 查找对象信息 + *

+ * + * @author Yudy + * @since 2024-03-24 + */ +public class FindObjectInfo { + + private String objectType; + private String objectName; + + public static FindObjectInfo newInstance(String objectType, String objectName) { + FindObjectInfo objectInfo = new FindObjectInfo(); + objectInfo.setObjectType(objectType); + objectInfo.setObjectName(objectName); + return objectInfo; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public String getObjectName() { + return objectName; + } + + public void setObjectName(String objectName) { + this.objectName = objectName; + } +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/ConnorCpzcServiceApplication.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/ConnorCpzcServiceApplication.java new file mode 100644 index 0000000..7952bcc --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/ConnorCpzcServiceApplication.java @@ -0,0 +1,17 @@ +package com.connor.connor_cpzc_service; + +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = {"com.connor.connor_cpzc_service", "com.chint.plm"}) +@MapperScan("com.connor.connor_cpzc_service.mapper") +public class ConnorCpzcServiceApplication { + + public static void main(String[] args) { + ConfigurableApplicationContext run = SpringApplication.run(ConnorCpzcServiceApplication.class, args); + } +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/SaticScheduleTask.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/SaticScheduleTask.java new file mode 100644 index 0000000..9c093c4 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/SaticScheduleTask.java @@ -0,0 +1,283 @@ +package com.connor.connor_cpzc_service; + +// import com.connor.overtime.hs.mapper.EPMMapper; + +import com.connor.connor_cpzc_service.bean.MdmDs.ErrorTimeBean; +import com.connor.connor_cpzc_service.bean.SapSumBean; +import com.connor.connor_cpzc_service.controller.DefineUtil; +import com.connor.connor_cpzc_service.info.LoginInfo; +import com.connor.connor_cpzc_service.mapper.EPMMapper; +import com.connor.connor_cpzc_service.util.KUtil; +import com.teamcenter.services.strong.core.DataManagementService; +import com.teamcenter.soa.client.model.ModelObject; +import com.teamcenter.soa.client.model.ServiceData; +import com.teamcenter.soa.client.model.strong.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.Async; +import org.springframework.scheduling.annotation.EnableAsync; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.scheduling.annotation.Scheduled; + +import javax.annotation.PostConstruct; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.text.SimpleDateFormat; +import java.time.LocalDateTime; +import java.util.*; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +// @Service +// @ConfigurationProperties(prefix = "tc") +@Configuration // 1.主要用于标记配置类,兼备Component的效果。 +@EnableScheduling // 2.开启定时任务 +@EnableAsync +public class SaticScheduleTask { + // 3.添加定时任务 + @Autowired + LoginInfo loginInfo; + + @PostConstruct + @Async + @Scheduled(cron = "${update.cron}") // 30 18 17 * * ?"${update.cron}" + public void configureTasks() { + System.err.println("执行静态定时任务时间: " + LocalDateTime.now()); + // String property = run.getEnvironment().getProperty("tc.server"); + // String property1 = run.getEnvironment().getProperty("tc.password"); + // String property2 = run.getEnvironment().getProperty("tc.user"); + try { + if (KUtil.getLoginUser() != null) { + KUtil.logoutAndClearCache2(); + } + KUtil.login(loginInfo.getServer(), loginInfo.getUser(), loginInfo.getPassword()); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @PostConstruct + @Async + @Scheduled(cron = "0 0/5 * * * ?") // 30 18 17 * * ?"${update.cron}" + public void configureTasks2() { + System.err.println("执行静态定时任务时间: " + LocalDateTime.now()); + try { + String cmd = "D:\\updateMantr2.bat"; + System.out.println(cmd); + executeCmdCommand(cmd); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Autowired + private EPMMapper dataMapper; + + /** + * 定时执行传递SAPBOM + */ + @PostConstruct + @Async + @Scheduled(cron = "${updateSAP.cron}") // 30 18 17 * * ?"${update.cron}" + public void sendBomSap() { //发送BOM到SAP的定时任务 + try { + //读取数据库的信息一次10个 + System.out.println(loginInfo.getExeSize()); + List sendMessage = dataMapper.findSendMessage(); + //查询exe数量根据配置项执行bat + int num = getProcessCount(DefineUtil.EXENAME); + if (num < loginInfo.getExeSize()) { + int threadCnt = Math.min(loginInfo.getExeSize() - num, sendMessage.size()); + System.out.println("启动线程数量===>" + threadCnt); + if (threadCnt <= 0) { + return; + } + ExecutorService executor = Executors.newFixedThreadPool(threadCnt); + for (int i = 0; i < threadCnt; i++) { + SapSumBean sapSumBean = sendMessage.get(i); + executor.submit(new Runnable() { + @Override + public void run() { + try { + String cmd = DefineUtil.BATPATH + + sapSumBean.getCode() + DefineUtil.CMDSPLIT + sapSumBean.getFactory() + + DefineUtil.CMDSPLIT + sapSumBean.getProjectUid() + DefineUtil.CMDSPLIT + + sapSumBean.getKeyMsg() + DefineUtil.CMDSPLIT + sapSumBean.getUser(); //D:\参数化集成 + dataMapper.updateTaskStatus(sapSumBean.getCode().toString()); + executeCmdCommand(cmd); + KUtil.log("sendBomXB cmd ====> " + cmd); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + executor.shutdown(); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + +// /** +// * 定时执行传递SAPBOM 异常机制 +// */ +// @PostConstruct +// @Async +// @Scheduled(cron = "${updateSAP.cron}") // 30 18 17 * * ?"${update.cron}" +// public void sendErrorBomSap() { //发送BOM到SAP的定时任务 +// try { +// +//// SELECT * FROM CHINT_BOM_TO_SAP_SUM WHERE taskstauts = '组织中' and +//// PLMFINISHTIME is NULL and PLMSTARTTIME < SYSDATE - INTERVAL '30' MINUTE +//// order by CODE desc +// //读取数据库的信息一次10个 异常机制 错误数据再推一次 +// List sendMessages = dataMapper.findErrorMessage(); +// List sendMessage = new ArrayList<>(); +// for (SapSumBean sapSumBean : sendMessages) { +// String oldtaskcode = sapSumBean.getOldtaskcode(); +// //第一次异常处理 +// if (oldtaskcode == null || oldtaskcode.isEmpty()) { +// //记录原始ID和上一次任务的ID +// sapSumBean.setOldtaskcode(sapSumBean.getCode().toString()); +// sapSumBean.setLasttaskcode(sapSumBean.getCode().toString()); +// sendMessage.add(sapSumBean); +// } else { +// //已经有原始ID的情况 +// ErrorTimeBean compensation = getCompensation(sapSumBean.getFactory()); +// int integer = Integer.parseInt(compensation.getNumber()); +// //判断异常处理次数是否到配置的数量 +// int numOfError = dataMapper.getNumOfError(sapSumBean.getCode().toString()); +// if (numOfError < integer) { +// sapSumBean.setLasttaskcode(sapSumBean.getCode().toString()); +// sendMessage.add(sapSumBean); +// } +// +// } +// } +// //查询exe数量根据配置项执行bat +// int num = getProcessCount(DefineUtil.ERR_EXENAME); +// if (num < loginInfo.getErrorExeSize()) { +// int threadCnt = Math.min(loginInfo.getErrorExeSize() - num, sendMessage.size()); +// System.out.println("启动线程数量===>" + threadCnt); +// if (threadCnt <= 0) { +// return; +// } +// ExecutorService executor = Executors.newFixedThreadPool(threadCnt); +// for (int i = 0; i < threadCnt; i++) { +// SapSumBean sapSumBean = sendMessage.get(i); +// executor.submit(new Runnable() { +// @Override +// public void run() { +// try { +// Integer code = getCode(); +// System.out.println("======" + code + "======"); +// String cmd = DefineUtil.BATPATH_ERROR + +// code + DefineUtil.CMDSPLIT + sapSumBean.getFactory() + +// DefineUtil.CMDSPLIT + sapSumBean.getProjectUid() + DefineUtil.CMDSPLIT + +// sapSumBean.getKeyMsg() + DefineUtil.CMDSPLIT + sapSumBean.getUser(); //D:\参数化集成 +// dataMapper.updateTaskError(sapSumBean.getCode().toString()); +// SimpleDateFormat formatTemp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); +// Date date = formatTemp.parse(sapSumBean.getStarttime()); +// String format = formatTemp.format(date); +// sapSumBean.setStarttime(format); +// sapSumBean.setCode(code); +// System.out.println(format); +// dataMapper.insertErrorTask(sapSumBean); +// executeCmdCommand(cmd); +// KUtil.log("sendBomXB cmd ====> " + cmd); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } +// }); +// } +// executor.shutdown(); +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } + + public static void executeCmdCommand(String cmdCommand) { + StringBuilder stringBuilder = new StringBuilder(); + Process process = null; + try { + process = Runtime.getRuntime().exec(cmdCommand); + BufferedReader bufferedReader = + new BufferedReader(new InputStreamReader(process.getInputStream(), "GBK")); + String line = null; + while ((line = bufferedReader.readLine()) != null) { + KUtil.log("cmd ==>" + line); + } + //return stringBuilder.toString(); + } catch (Exception e) { + e.printStackTrace(); + return; + } + } + + /** + * 获取指定名称的exe正在执行的数量 + * + * @param exeName exe名称 + * @return + */ + public static int getProcessCount(String exeName) { + int count = 0; + try { + Process process = Runtime.getRuntime().exec("tasklist"); + BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); + String line; + Pattern pattern = Pattern.compile(exeName); + while ((line = reader.readLine()) != null) { + Matcher matcher = pattern.matcher(line); + if (matcher.find()) { + count++; + } + } + reader.close(); + } catch (IOException e) { + e.printStackTrace(); + } + return count; + } + + /** + * overtime=30min:3|M040:30min:3;M046:20min:2 + * 根据输入的组ID获取间隔和次数 + * + * @return + */ + public ErrorTimeBean getCompensation(String groupId) { + String overtime = loginInfo.getOvertime(); + String[] split = overtime.split("\\|"); + if (overtime.contains(groupId)) { + String[] split1 = split[1].split(";"); + for (String val : split1) { + if (val.contains(groupId)) { + String[] vals = val.split(":"); + return new ErrorTimeBean(vals[1], vals[2]); + } + } + return null; + } else { + String[] vals = split[0].split(":"); + return new ErrorTimeBean(vals[0], vals[1]); + } + } + + /** + * 获取SUM表的最大code + * + * @return + */ + public Integer getCode() { + int code = dataMapper.getCode(); + return code; + } +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/CoreBean.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/CoreBean.java new file mode 100644 index 0000000..f7a14b6 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/CoreBean.java @@ -0,0 +1,23 @@ +package com.connor.connor_cpzc_service.bean; + +public class CoreBean { + + private String productno; + private String wbsno; + + public String getProductno() { + return productno; + } + + public void setProductno(String productno) { + this.productno = productno; + } + + public String getWbsno() { + return wbsno; + } + + public void setWbsno(String wbsno) { + this.wbsno = wbsno; + } +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/CoreBeanReturn.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/CoreBeanReturn.java new file mode 100644 index 0000000..182002f --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/CoreBeanReturn.java @@ -0,0 +1,48 @@ +package com.connor.connor_cpzc_service.bean; + +public class CoreBeanReturn { + + private String productno; + private String wbsno; + private String weight; + private String code; + + public CoreBeanReturn(String productno, String wbsno, String weight, String code) { + this.productno = productno; + this.wbsno = wbsno; + this.weight = weight; + this.code = code; + } + + public String getProductno() { + return productno; + } + + public String getWeight() { + return weight; + } + + public void setWeight(String weight) { + this.weight = weight; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public void setProductno(String productno) { + this.productno = productno; + } + + public String getWbsno() { + return wbsno; + } + + public void setWbsno(String wbsno) { + this.wbsno = wbsno; + } +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/CshXlsxBean.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/CshXlsxBean.java new file mode 100644 index 0000000..566e1a3 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/CshXlsxBean.java @@ -0,0 +1,28 @@ +package com.connor.connor_cpzc_service.bean; + +import com.connor.connor_cpzc_service.controller.BomPropBean; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.List; + +public class CshXlsxBean { + + @JsonProperty("code") + private String code; + @JsonProperty("desc") + private String desc; + @JsonProperty("uid") + private String uidName; + + public CshXlsxBean(String code, String desc, String uidName, String fileName,String revisionId) { + this.code = code; + this.desc = desc; + this.uidName = uidName; + this.fileName = fileName; + this.revisionId = revisionId; + } + @JsonProperty("revId") + private String revisionId; + @JsonProperty("fileName") + private String fileName; +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/CswjBean.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/CswjBean.java new file mode 100644 index 0000000..f358f55 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/CswjBean.java @@ -0,0 +1,34 @@ +package com.connor.connor_cpzc_service.bean; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class CswjBean { + @JsonProperty("code") + private String code = "200"; + @JsonProperty("desc") + private String desc = "参数化文件已上传"; + @JsonProperty("item_id") + private String item_id; + @JsonProperty("object_name") + private String object_name; + @JsonProperty("Save_time") + private String Save_time; + @JsonProperty("item_revision_id") + private String item_revision_id; + @JsonProperty("create_time") + private String create_time; + @JsonProperty("Release_time") + private String Release_time; + @JsonProperty("responsible_user") + private String responsible_user; + + public CswjBean(String item_id, String object_name, String save_time, String item_revision_id, String create_time, String release_time, String responsible_user) { + this.item_id = item_id; + this.object_name = object_name; + Save_time = save_time; + this.item_revision_id = item_revision_id; + this.create_time = create_time; + Release_time = release_time; + this.responsible_user = responsible_user; + } +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/CswjErrBean.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/CswjErrBean.java new file mode 100644 index 0000000..04660a0 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/CswjErrBean.java @@ -0,0 +1,16 @@ +package com.connor.connor_cpzc_service.bean; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class CswjErrBean { + @JsonProperty("code") + private String code = "500"; + @JsonProperty("reason") + private String reason = "PLM系统中无此通用件,请联系通用件管理员"; + public CswjErrBean() { + } + public CswjErrBean(String code, String reason) { + this.code = code; + this.reason = reason; + } +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/ECNBean.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/ECNBean.java new file mode 100644 index 0000000..c68c069 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/ECNBean.java @@ -0,0 +1,36 @@ +package com.connor.connor_cpzc_service.bean; + +public class ECNBean { + + private String creationdatebefore;//创建时间早于 + private String factory;//所属组织 + private String creationdateafter;//创建时间晚于 + + public String getCreationdatebefore() { + return creationdatebefore; + } + + public void setCreationdatebefore(String creationdatebefore) { + this.creationdatebefore = creationdatebefore; + } + + public String getFactory() { + return factory; + } + + public void setFactory(String factory) { + this.factory = factory; + } + + public String getCreationdateafter() { + return creationdateafter; + } + + public void setCreationdateafter(String creationdateafter) { + this.creationdateafter = creationdateafter; + } + + public String toString(){ + return "{\"factory\":\"" + factory + "\",\"creationdatebefore\":\"" + creationdatebefore + "\",\"creationdateafter\":\"" + creationdateafter + "\"}"; + } +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/ECNBeanReturn.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/ECNBeanReturn.java new file mode 100644 index 0000000..058da5f --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/ECNBeanReturn.java @@ -0,0 +1,33 @@ +package com.connor.connor_cpzc_service.bean; + +public class ECNBeanReturn { + + private String owninguser; + private int counts; + + public ECNBeanReturn(String owninguser, int counts) { + this.owninguser = owninguser; + this.counts = counts; + } + + public String getOwninguser() { + return owninguser; + } + public void setOwninguser(String owninguser) { + this.owninguser = owninguser; + } + public int getCounts() { + return counts; + } + public void setCounts(int counts) { + this.counts = counts; + } + + public void add(){ + counts ++; + } + + public String toString(){ + return "{\"owninguser\":\"" + owninguser + "\",\"counts\":\"" + counts + "\"}"; + } +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/GetCoilBean.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/GetCoilBean.java new file mode 100644 index 0000000..3236bdb --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/GetCoilBean.java @@ -0,0 +1,17 @@ +package com.connor.connor_cpzc_service.bean; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetCoilBean { + + private String materialno; + + public String getMaterialno() { + return materialno; + } + + public void setMaterialno(String materialno) { + this.materialno = materialno; + } +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/HistoryBean.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/HistoryBean.java new file mode 100644 index 0000000..499f812 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/HistoryBean.java @@ -0,0 +1,19 @@ +package com.connor.connor_cpzc_service.bean; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.List; + +public class HistoryBean { + + @JsonProperty("code") + private String code="200"; + @JsonProperty("desc") + private String desc = "找到对应对象"; + @JsonProperty("detail") + private List items; + + public HistoryBean(List items) { + this.items = items; + } +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/HistoryErrBean.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/HistoryErrBean.java new file mode 100644 index 0000000..4da5e5a --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/HistoryErrBean.java @@ -0,0 +1,25 @@ +package com.connor.connor_cpzc_service.bean; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class HistoryErrBean { + + public HistoryErrBean(String nuff_Properties) { + this.nuff_Properties = nuff_Properties; + } + + @JsonProperty("code") + private String code = "500"; + @JsonProperty("desc") + private String desc = "未找到到对应图纸对象,请检查数据重新查询"; + @JsonProperty("nuff_Properties") + private String nuff_Properties; + + public String getNuff_Properties() { + return nuff_Properties; + } + + public void setNuff_Properties(String nuff_Properties) { + this.nuff_Properties = nuff_Properties; + } +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/ItemBean.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/ItemBean.java new file mode 100644 index 0000000..65f4cae --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/ItemBean.java @@ -0,0 +1,16 @@ +package com.connor.connor_cpzc_service.bean; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class ItemBean { + + @JsonProperty("item_id") + private String itemId; + @JsonProperty("revision") + private String object_name; + + public ItemBean(String itemId, String object_name) { + this.itemId = itemId; + this.object_name = object_name; + } +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/MdmDs/DesignBean.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/MdmDs/DesignBean.java new file mode 100644 index 0000000..ab9d762 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/MdmDs/DesignBean.java @@ -0,0 +1,26 @@ +package com.connor.connor_cpzc_service.bean.MdmDs; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class DesignBean { + @JSONField(name = "drawingno") + String drawingNo; + @JSONField(name = "drawingname") + String drawingName; + @JSONField(name = "materialcode") + String materialCode; //暂时为空 + @JSONField(name = "version") + String version; + @JSONField(name = "files") + List fileBeans; //暂时为空 + +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/MdmDs/ErrorTimeBean.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/MdmDs/ErrorTimeBean.java new file mode 100644 index 0000000..f35b592 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/MdmDs/ErrorTimeBean.java @@ -0,0 +1,13 @@ +package com.connor.connor_cpzc_service.bean.MdmDs; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class ErrorTimeBean { + private String overTime; + private String number; +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/MdmDs/FileBean.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/MdmDs/FileBean.java new file mode 100644 index 0000000..9303d6c --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/MdmDs/FileBean.java @@ -0,0 +1,20 @@ +package com.connor.connor_cpzc_service.bean.MdmDs; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class FileBean { + + @JSONField(name = "no") + String no; + @JSONField(name = "fileuid") + String fileUid; + @JSONField(name = "filename") + String fileName; + +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/MdmDs/MomRuleBean.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/MdmDs/MomRuleBean.java new file mode 100644 index 0000000..703326d --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/MdmDs/MomRuleBean.java @@ -0,0 +1,18 @@ +package com.connor.connor_cpzc_service.bean.MdmDs; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class MomRuleBean { + + String psmcode ; + String no ; + String drawingno ; + String list ; + String elsedrawingno ; + +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/MdmDs/OaReferenceBean.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/MdmDs/OaReferenceBean.java new file mode 100644 index 0000000..2019f07 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/MdmDs/OaReferenceBean.java @@ -0,0 +1,16 @@ +package com.connor.connor_cpzc_service.bean.MdmDs; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class OaReferenceBean { + + private String principal; + private String file; + private String pctime; + +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/MdmDs/SapMsg.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/MdmDs/SapMsg.java new file mode 100644 index 0000000..ed24941 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/MdmDs/SapMsg.java @@ -0,0 +1,22 @@ +package com.connor.connor_cpzc_service.bean.MdmDs; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class SapMsg { + + private String starttime; + private String wbsno; + private String projectno; + private String puid; + private String productmaterialno; + private String transfer; + private String sapresult; + private String userid; + private String user; + private String factory; +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/PartBean.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/PartBean.java new file mode 100644 index 0000000..53cf11f --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/PartBean.java @@ -0,0 +1,20 @@ +package com.connor.connor_cpzc_service.bean; + +import com.connor.connor_cpzc_service.controller.BomPropBean; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.List; + +public class PartBean { + + @JsonProperty("code") + private String code="200"; + @JsonProperty("desc") + private String desc = "找到对应部件"; + @JsonProperty("detail") + private List items; + + public PartBean(List items) { + this.items = items; + } +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/PartErrBean.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/PartErrBean.java new file mode 100644 index 0000000..065e6cb --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/PartErrBean.java @@ -0,0 +1,18 @@ +package com.connor.connor_cpzc_service.bean; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class PartErrBean { + + @JsonProperty("code") + private String code="500"; + @JsonProperty("desc") + private String desc = "查询结果为空,未找到到对应部件对象,请联系通用件管理员"; + + public PartErrBean(String itemId) { + this.itemId = itemId; + } + + @JsonProperty("item_id") + private String itemId; +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/QMSBean.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/QMSBean.java new file mode 100644 index 0000000..b78fb43 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/QMSBean.java @@ -0,0 +1,222 @@ +package com.connor.connor_cpzc_service.bean; + +import java.util.Date; + +public class QMSBean { + private Integer code; + private String factory; // 工厂 + private String qmsinspectioncode; // QMS检验项编码 + private String qmsinspectionname; // QMS检验项名称 + private String qmssuperiorinspectioncode; // QMS上级检验项编码 + private String qmssuperiorinspectionname; // QMS上级检验项名称 + private String qmspushuser; // QMS推送人员 + private Date qmspushtime; // QMS推送时间 + private String qmsremark; // QMS备注 + private String plminspectioncode; // PLM检验项编码 + private String plmvaluetype; // 取值类型 + private String plmdesignation; // 参数代号 + private String plmsequence; // 规格位数(顺序) + private String status; // 是否同步QMS(成功/失败) + private String plmchangeuser; // 修改人员 + private Date plmchangetime; // 修改时间 + private String plmremark; // PLM备注 + private Date synctime; // 同步时间 + private String syncuser; // 同步账号 + private String qmsinspectionschemename; // QMS检验方案名称 + private String qmsinspectionschemecode; // QMS检验方案编码 + private String result; // 结果 + + // 构造函数、getter 和 setter 方法 + + public QMSBean() { + } + + public QMSBean(String factory, String qmsinspectioncode, String qmsinspectionname, String qmspushuser, Date qmspushtime, String qmsremark,String qmssuperiorinspectionname, String qmssuperiorinspectioncode, String qmsinspectionschemename, String qmsinspectionschemecode) { + this.factory = factory; + this.qmsinspectioncode = qmsinspectioncode; + this.qmsinspectionname = qmsinspectionname; + this.qmssuperiorinspectioncode = qmssuperiorinspectioncode; + this.qmssuperiorinspectionname = qmssuperiorinspectionname; + this.qmspushuser = qmspushuser; + this.qmspushtime = qmspushtime; + this.qmsremark = qmsremark; + this.qmsinspectionschemename = qmsinspectionschemename; + this.qmsinspectionschemecode = qmsinspectionschemecode; + } + + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + + public String getFactory() { + return factory; + } + + public void setFactory(String factory) { + this.factory = factory; + } + + public String getQmsinspectioncode() { + return qmsinspectioncode; + } + + public void setQmsinspectioncode(String qmsinspectioncode) { + this.qmsinspectioncode = qmsinspectioncode; + } + + public String getQmsinspectionname() { + return qmsinspectionname; + } + + public void setQmsinspectionname(String qmsinspectionname) { + this.qmsinspectionname = qmsinspectionname; + } + + public String getQmssuperiorinspectioncode() { + return qmssuperiorinspectioncode; + } + + public void setQmssuperiorinspectioncode(String qmssuperiorinspectioncode) { + this.qmssuperiorinspectioncode = qmssuperiorinspectioncode; + } + + public String getQmssuperiorinspectionname() { + return qmssuperiorinspectionname; + } + + public void setQmssuperiorinspectionname(String qmssuperiorinspectionname) { + this.qmssuperiorinspectionname = qmssuperiorinspectionname; + } + + public String getQmspushuser() { + return qmspushuser; + } + + public void setQmspushuser(String qmspushuser) { + this.qmspushuser = qmspushuser; + } + + public Date getQmspushtime() { + return qmspushtime; + } + + public void setQmspushtime(Date qmspushtime) { + this.qmspushtime = qmspushtime; + } + + public String getQmsremark() { + return qmsremark; + } + + public void setQmsremark(String qmsremark) { + this.qmsremark = qmsremark; + } + + public String getPlminspectioncode() { + return plminspectioncode; + } + + public void setPlminspectioncode(String plminspectioncode) { + this.plminspectioncode = plminspectioncode; + } + + public String getPlmvaluetype() { + return plmvaluetype; + } + + public void setPlmvaluetype(String plmvaluetype) { + this.plmvaluetype = plmvaluetype; + } + + public String getPlmdesignation() { + return plmdesignation; + } + + public void setPlmdesignation(String plmdesignation) { + this.plmdesignation = plmdesignation; + } + + public String getPlmsequence() { + return plmsequence; + } + + public void setPlmsequence(String plmsequence) { + this.plmsequence = plmsequence; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getPlmchangeuser() { + return plmchangeuser; + } + + public void setPlmchangeuser(String plmchangeuser) { + this.plmchangeuser = plmchangeuser; + } + + public Date getPlmchangetime() { + return plmchangetime; + } + + public void setPlmchangetime(Date plmchangetime) { + this.plmchangetime = plmchangetime; + } + + public String getPlmremark() { + return plmremark; + } + + public void setPlmremark(String plmremark) { + this.plmremark = plmremark; + } + + public Date getSynctime() { + return synctime; + } + + public void setSynctime(Date synctime) { + this.synctime = synctime; + } + + public String getSyncuser() { + return syncuser; + } + + public void setSyncuser(String syncuser) { + this.syncuser = syncuser; + } + + public String getQmsinspectionschemename() { + return qmsinspectionschemename; + } + + public void setQmsinspectionschemename(String qmsinspectionschemename) { + this.qmsinspectionschemename = qmsinspectionschemename; + } + + public String getQmsinspectionschemecode() { + return qmsinspectionschemecode; + } + + public void setQmsinspectionschemecode(String qmsinspectionschemecode) { + this.qmsinspectionschemecode = qmsinspectionschemecode; + } + + public String getResult() { + return result; + } + + public void setResult(String result) { + this.result = result; + } +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/ReturnBean1.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/ReturnBean1.java new file mode 100644 index 0000000..8254b8e --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/ReturnBean1.java @@ -0,0 +1,58 @@ +package com.connor.connor_cpzc_service.bean; + +public class ReturnBean1 { + + private String code; + private String weight; + private String drawingno; + private String materialno; + private String name; + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getWeight() { + return weight; + } + + public void setWeight(String weight) { + this.weight = weight; + } + + public String getDrawingno() { + return drawingno; + } + + public void setDrawingno(String drawingno) { + this.drawingno = drawingno; + } + + public String getMaterialno() { + return materialno; + } + + public void setMaterialno(String materialno) { + this.materialno = materialno; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public ReturnBean1(String code, String weight, String drawingno, String materialno, String name) { + this.code = code; + this.weight = weight; + this.drawingno = drawingno; + this.materialno = materialno; + this.name = name; + } +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/SapResult.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/SapResult.java new file mode 100644 index 0000000..619a758 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/SapResult.java @@ -0,0 +1,132 @@ +package com.connor.connor_cpzc_service.bean; + +public class SapResult { + + private String factory; + private String wbsno; + private String materialno; + private String batchnumber; + private String puid; + private String status; + private String message; + private String createdate; + private String createtime; + private String returndate; + private String returntime; + + public String getFactory() { + return factory; + } + + public void setFactory(String factory) { + this.factory = factory; + } + + public String getWbsno() { + return wbsno; + } + + public void setWbsno(String wbsno) { + this.wbsno = wbsno; + } + + public String getMaterialno() { + return materialno; + } + + public void setMaterialno(String materialno) { + this.materialno = materialno; + } + + public String getBatchnumber() { + return batchnumber; + } + + public void setBatchnumber(String batchnumber) { + this.batchnumber = batchnumber; + } + + public String getPuid() { + return puid; + } + + public void setPuid(String puid) { + this.puid = puid; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public String getCreatedate() { + return createdate; + } + + public void setCreatedate(String createdate) { + this.createdate = createdate; + } + + public String getCreatetime() { + return createtime; + } + + public void setCreatetime(String createtime) { + this.createtime = createtime; + } + + public String getReturndate() { + return returndate; + } + + public void setReturndate(String returndate) { + this.returndate = returndate; + } + + public String getReturntime() { + return returntime; + } + + public void setReturntime(String returntime) { + this.returntime = returntime; + } + + @Override + public String toString() { + return "SapResult{" + + "factory='" + factory + '\'' + + ", wbsno='" + wbsno + '\'' + + ", materialno='" + materialno + '\'' + + ", batchnumber='" + batchnumber + '\'' + + ", puid='" + puid + '\'' + + ", status='" + status + '\'' + + ", message='" + message + '\'' + + ", createdate='" + createdate + '\'' + + ", createtime='" + createtime + '\'' + + ", returndate='" + returndate + '\'' + + ", returntime='" + returntime + '\'' + + '}'; + } + // "factory":"工厂", +// "wbsno":"项目wbs号,可为空", +// "materialno":"父物料编码1", +// "batchnumber":"批次号", +// "puid":"PLM中的物料item_uid", +// "status":"处理结果状态", +// "message":"具体返回的信息内容", +// "createdate":"BOM创建日期", +// "createtime":"BOM创建时间", +// "returndate":"BOM同步日期", +// "returntime":"BOM同步时间" +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/SapReturn.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/SapReturn.java new file mode 100644 index 0000000..f3312ec --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/SapReturn.java @@ -0,0 +1,23 @@ +package com.connor.connor_cpzc_service.bean; + +import java.util.List; + +public class SapReturn { + + private List result; + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } + + @Override + public String toString() { + return "SapReturn{" + + "result=" + result + + '}'; + } +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/SapSumBean.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/SapSumBean.java new file mode 100644 index 0000000..2b0f200 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/bean/SapSumBean.java @@ -0,0 +1,25 @@ +package com.connor.connor_cpzc_service.bean; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class SapSumBean { + private String keyMsg; + private Integer code; + private String factory; + private String projectUid; + private String user; + private String starttime; + private String wbsno; + private String projectno; + private String sapresult; + private String transfer; + private String oldtaskcode;//记录原始的任务ID + private String lasttaskcode;//记录上一个任务 + private String serverhost; + private String userid; +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/controller/BomPropBean.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/controller/BomPropBean.java new file mode 100644 index 0000000..944d7b1 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/controller/BomPropBean.java @@ -0,0 +1,62 @@ +package com.connor.connor_cpzc_service.controller; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.List; + +public class BomPropBean { +// 图号、名称、描述 创建时间,发布时间,版本,责任人 + @JsonProperty("item_id") + private String itemId; + @JsonProperty("Creationtime") + private String createDate; + @JsonProperty("Releasetime") + private String releaseDate; + @JsonProperty("revision") + private String revision; + @JsonProperty("user") + private String assignee; +// @JsonProperty("children") +// private List children; + + public String getItemId() { + return itemId; + } + + public void setItemId(String itemId) { + this.itemId = itemId; + } + + public String getCreateDate() { + return createDate; + } + + public void setCreateDate(String createDate) { + this.createDate = createDate; + } + + public String getReleaseDate() { + return releaseDate; + } + + public void setReleaseDate(String releaseDate) { + this.releaseDate = releaseDate; + } + + public String getRevision() { + return revision; + } + + public void setRevision(String revision) { + this.revision = revision; + } + + public String getAssignee() { + return assignee; + } + + public void setAssignee(String assignee) { + this.assignee = assignee; + } + +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/controller/DefineUtil.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/controller/DefineUtil.java new file mode 100644 index 0000000..c889dd2 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/controller/DefineUtil.java @@ -0,0 +1,18 @@ +package com.connor.connor_cpzc_service.controller; + +import java.text.SimpleDateFormat; + +public class DefineUtil { + + public static final String DRAWNO = "zt2_DrawingNo"; + public static final String ITEMID = "item_id"; + public static final String SEARCHDRAW = "参数化查询图纸"; + public static final String PATTERNCODE = "图样代号"; + public static final String EXENAME = "BOMToSapOpt.exe"; + public static final String ERR_EXENAME = "BOMToSapOptError.exe"; + //D:\参数化集成\BOMToSapOpt.bat D:\server\CshTest\BOMToSapOpt.bat D:\参数化集成\BOMToSapOpt.bat + public static final String BATPATH = "D:\\server\\参数化-8089\\BOMToSapOpt.bat "; + public static final String BATPATH_ERROR = "D:\\参数化集成\\BOMToSapOptError.bat "; + public static final String CMDSPLIT = " "; + public static final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/controller/DownLoadController.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/controller/DownLoadController.java new file mode 100644 index 0000000..d45e15b --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/controller/DownLoadController.java @@ -0,0 +1,2903 @@ +package com.connor.connor_cpzc_service.controller; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.connor.connor_cpzc_service.bean.*; +import com.connor.connor_cpzc_service.info.DesignInfoBean; +import com.connor.connor_cpzc_service.info.FileInfoBean; +import com.connor.connor_cpzc_service.info.LoginInfo; +import com.connor.connor_cpzc_service.mapper.EPMMapper; +import com.connor.connor_cpzc_service.util.JsonResult; +import com.connor.connor_cpzc_service.util.KUtil; +import com.connor.connor_cpzc_service.util.RelationUtils; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.teamcenter.clientx.AppXSession; +import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException; +import com.teamcenter.services.strong.cad._2007_01.StructureManagement; +import com.teamcenter.services.strong.classification.ClassificationService; +import com.teamcenter.services.strong.classification._2007_01.Classification; +import com.teamcenter.services.strong.core.DataManagementService; +import com.teamcenter.services.strong.core._2007_01.DataManagement; +import com.teamcenter.soa.client.FileManagementUtility; +import com.teamcenter.soa.client.GetFileResponse; +import com.teamcenter.soa.client.model.ModelObject; +import com.teamcenter.soa.client.model.ServiceData; +import com.teamcenter.soa.client.model.strong.*; +import io.minio.GetPresignedObjectUrlArgs; +import io.minio.MinioClient; +import io.minio.PutObjectArgs; +import io.minio.http.Method; +import org.apache.commons.io.FileUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.io.FileSystemResource; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletResponse; +import java.io.*; +import java.math.BigInteger; +import java.nio.charset.Charset; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.logging.SimpleFormatter; +import java.util.regex.Pattern; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; +import java.util.zip.ZipOutputStream; + +@RestController +@RequestMapping(value = "/plm") +public class DownLoadController { + // private static final Logger logger = LoggerFactory.getLogger(KUtil.class); + private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(KUtil.class); + @Autowired protected LoginInfo loginInfo; + + public static void log(String msg) { + logger.warn(msg); + } + + public static String getFMSTempFolder(String getFms_cachedir, String doc) { + return getFms_cachedir + "\\" + doc + "\\" + UUID.randomUUID(); + } + + @GetMapping("/ParameterFileReturnJGJ") + public String getTemplateJGJ(String item_id) { + AppXSession session = null; + StringBuilder message = new StringBuilder(""); + List downFile = new ArrayList<>(); + List errFile = new ArrayList<>(); + String code = "200"; + String lastId = ""; + // String url = ""; + String document = ""; + List fileNames = new ArrayList<>(); + List uids = new ArrayList<>(); + List jgjList = new ArrayList<>(); + try { + // KUtil.setByPass(true); + Map fields1 = new HashMap<>(); + // 原来查询 + fields1.put("零组件 ID", item_id + "*"); + ModelObject[] designs = KUtil.query("Item ID", fields1); + System.out.println("designs.length:" + designs.length); + for (ModelObject design : designs) { + Item designItem = (Item) design; + KUtil.refreshAndGetProperties(designItem, "item_id"); + String item_id1 = designItem.get_item_id(); + jgjList.add(item_id1); + } + if (designs.length > 0) { + Item designItem = (Item) designs[0]; + KUtil.refreshAndGetProperties(designItem, "revision_list"); + ModelObject[] revision_list1 = designItem.get_revision_list(); + ItemRevision designRev = (ItemRevision) revision_list1[revision_list1.length - 1]; + KUtil.refreshAndGetProperties(designRev, "items_tag"); + Item item1 = designRev.get_items_tag(); + List dsList = new ArrayList<>(); + KUtil.refreshAndGetProperties( + item1, "revision_list", "item_id", "owning_user", "object_name"); + lastId = item1.get_item_id(); + ModelObject[] revision_list = item1.get_revision_list(); + ItemRevision revision = (ItemRevision) revision_list[revision_list.length - 1]; + KUtil.refreshAndGetProperties(revision, "IMAN_specification"); + ModelObject[] IMAN_specifications = revision.get_IMAN_specification(); + boolean hasSw = false; + boolean hastz = false; + ArrayList arrayList = KUtil.openBOMWindow(revision); + BOMLine bomLine = (BOMLine) arrayList.get(1); + for (ModelObject IMAN_specificatio : IMAN_specifications) { + if (IMAN_specificatio instanceof Dataset) { + Dataset ds = (Dataset) IMAN_specificatio; + KUtil.refreshAndGetProperties(ds, "object_type"); + String object_type = ds.get_object_type(); + System.out.println("文件类型:" + object_type); + if (object_type.equals("ProPrt") || object_type.equals("ProAsm")) { + hasSw = true; + hastz = true; + dsList.add(ds); + if (object_type.equals("ProAsm")) { + // asm 文件BOM排除 + KUtil.refreshAndGetProperties(ds, "Pro2_bom_exclusion"); + ModelObject[] bom_exclusions = + ds.getPropertyObject("Pro2_bom_exclusion").getModelObjectArrayValue(); + if (bom_exclusions != null && bom_exclusions.length > 0) { + getBomExclusion(dsList, bom_exclusions); + } + } + } else if (object_type.equals("ProDrw")) { + hastz = true; + dsList.add(ds); + } + } + } + if (!hastz) { + getTempDataset(dsList, item_id); + } + getAllDs(bomLine, dsList); + KUtil.closeBOMWindow((BOMWindow) arrayList.get(0)); + System.out.println("遍历获取数据集"); + FileManagementUtility fmu = + new FileManagementUtility( + AppXSession.getConnection(), + null, + new String[] {loginInfo.getFmsUrl()}, + new String[] {loginInfo.getFmsUrl()}, + loginInfo.getFmstemp()); + List files = new ArrayList<>(); + // ModelObject[] zt2_cshRelations = + // designRev.getPropertyObject("ZT2_CSHRelation").getModelObjectArrayValue(); + Set set = new HashSet(dsList); + dsList.clear(); + dsList.addAll(set); + for (Dataset ds : dsList) { + KUtil.refreshAndGetProperties(ds, "ref_list", "ref_names", "object_name", "object_type"); + String object_type1 = ds.get_object_type(); + if (object_type1.equals("ProPrt") || object_type1.equals("ProAsm")) { + KUtil.refreshAndGetProperties(ds, "IPEM_master_dependency"); + ModelObject[] ipem_master_dependencies = + ds.getPropertyObject("IPEM_master_dependency").getModelObjectArrayValue(); + if (ipem_master_dependencies.length > 0) { + ItemRevision ipemTag = (ItemRevision) ipem_master_dependencies[0]; + KUtil.refreshAndGetProperties(ipemTag, "IMAN_specification"); + ModelObject[] IMAN_specifications2 = ipemTag.get_IMAN_specification(); + for (ModelObject IMAN_specificatio : IMAN_specifications2) { + if (IMAN_specificatio instanceof Dataset) { + Dataset dataset = (Dataset) IMAN_specificatio; + KUtil.refreshAndGetProperties(dataset, "object_type"); + String object_type = dataset.get_object_type(); + if (object_type.equals("ProPrt") + || object_type.equals("ProAsm") + || object_type.equals("ProDrw")) { + // dsList.add(ds); + ds = dataset; + KUtil.refreshAndGetProperties(ds, "ref_list", "ref_names", "object_name"); + break; + } + } + } + } + } + ModelObject[] ref_list = ds.get_ref_list(); + String object_name = ds.get_object_name(); + String[] ref_names = ds.get_ref_names(); + if (ref_list.length == 0 && !errFile.contains(object_name)) { + errFile.add(object_name); + if (object_name.contains(item_id)) { + code = "600"; + } else { + code = "700"; + } + } + System.out.println(ref_list.length + "ref_list"); + for (int i = 0; i < ref_list.length; i++) { + if (!(ref_list[i] instanceof ImanFile) || ref_names[i].equals("MetaData")) { + System.out.println("i==>" + i); + continue; + } + ImanFile file = (ImanFile) ref_list[i]; + KUtil.refreshAndGetProperties(file, "original_file_name", "file_size"); + String file_size = file.get_file_size(); + if (file_size == null || file_size.equals("0")) { + System.out.println("i====>" + i); + continue; + } + if (files.contains(file)) { + System.out.println("i======>" + i); + continue; + } + String original_file_name = file.getPropertyDisplayableValue("original_file_name"); + if (ref_names[i].equals("PrtFile") + || ref_names[i].equals("DrwFile") + || ref_names[i].equals("AsmFile")) { + downFile.add(original_file_name); + } + fileNames.add(original_file_name); + uids.add(file.getUid()); + files.add(file); + } + } + if (dsList.size() == 0) { + code = "600"; + } + if (code.equals("600") && (files.size() == 0 || dsList.size() == 0)) { + message.append("PLM系统中此紧固件无数据模型,请联系通用件管理员"); + } else if (code.equals("700") && files.size() == 0) { + message.append("PLM系统中紧固件的数据模型数据异常,无法传递。请联系通用件管理员"); + } else if (!hasSw) { + code = "600"; + User owning_user = (User) item1.get_owning_user(); + KUtil.refreshAndGetProperties(owning_user, "user_name"); + String user_name = owning_user.get_user_name(); + if (!hastz) { + message.append("PLM系统中此通用件无数据模型,请联系通用件管理员"); + } else { + message.append("不存在三维图纸,user_id:").append(user_name); + } + } else { + message.append("存在三维图纸,图纸已打包"); + } + } else { + message.append("PLM系统中无此紧固件,请联系通用件管理员"); + lastId = item_id; + code = "500"; + } + } catch (Exception e) { + e.printStackTrace(); + code = "900"; + message.append(e.getMessage()); + } finally { + try { + // KUtil.setByPass(false); + } catch (Exception e) { + e.printStackTrace(); + } + } + JgjBean res = + new JgjBean( + downFile, + errFile, + message.toString(), + code, + lastId, + fileNames, + uids, + document, + jgjList); + ObjectMapper objectMapper = new ObjectMapper(); + String data = ""; + try { + data = objectMapper.writeValueAsString(res); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + return data.toString(); + } + + @GetMapping("/GetCshDocument") + public String getTemplate(String item_id, String revId) { + + String uidName = ""; + String fileName = ""; + String code = "200"; + String msg = "Excel下载完成"; + String revisionId = ""; + try { + Map fields1 = new HashMap<>(); + fields1.put("零组件 ID", item_id); + // fields1.put("版本", revId); + ModelObject[] designs = KUtil.query("Latest Item Revision...", fields1); + System.out.println("designs.length:" + designs.length); + if (designs.length > 0) { + ItemRevision designRev = (ItemRevision) designs[0]; + KUtil.refreshAndGetProperties(designRev, "ZT2_CSHRelation", "item_revision_id"); + revisionId = designRev.get_item_revision_id(); + ModelObject[] zt2_cshRelations = + designRev.getPropertyObject("ZT2_CSHRelation").getModelObjectArrayValue(); + if (zt2_cshRelations.length > 0 && (zt2_cshRelations[0] instanceof ItemRevision)) { + ItemRevision cshDocument = (ItemRevision) zt2_cshRelations[0]; + KUtil.refreshAndGetProperties(cshDocument, "IMAN_specification"); + ModelObject[] cshDataset = cshDocument.get_IMAN_specification(); + if (cshDataset.length > 0) { + Dataset ds = (Dataset) cshDataset[0]; + KUtil.refreshAndGetProperties(ds, "ref_list", "object_name"); + ModelObject[] ref_list = ds.get_ref_list(); + if (ref_list.length > 0) { + ImanFile file = (ImanFile) ref_list[0]; + KUtil.refreshAndGetProperties(file, "original_file_name"); + String original_file_name = file.getPropertyDisplayableValue("original_file_name"); + fileName = original_file_name; + uidName = file.getUid(); + } + } + } else if (!revId.equals("TS")) { + code = "500"; + msg = "当前图号TC中不存在参数化文档,请检查。"; + } + } else { + code = "500"; + msg = "当前图号TC中不存在对象,请检查。"; + } + } catch (Exception e) { + e.printStackTrace(); + code = "500"; + msg = e.getMessage(); + } + String data = ""; + try { + ObjectMapper objectMapper = new ObjectMapper(); + data = + objectMapper.writeValueAsString( + new CshXlsxBean(code, msg, uidName, fileName, revisionId)); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + return data.toString(); + } + + @PostMapping(value = "/ParameterFile", name = "测试") + public String test(MultipartFile uploadFile, String design_id) { + // log.info("ProjectOpenController.test() 入参:{}", object); + String code = "200"; + String errReason = ""; + try { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); + // JSONObject object = JSON.parseObject(json); + // System.out.println(object); + File file = + new File(System.getenv("temp") + File.separator + uploadFile.getOriginalFilename()); + KUtil.log("FilePath:" + file.getAbsolutePath()); + // KUtil.log("执行saveAsItem:[start]"); + FileUtils.copyInputStreamToFile(uploadFile.getInputStream(), file); + // String save_time = object.getString("Save_time"); + // String design_id = object.getString("design_id"); + String object_name = design_id; // object.getString("object_name"); + String item_id = ""; // object.getString("item_id"); + Map fields1 = new HashMap<>(); + fields1.put("零组件 ID", design_id); + String createTime = ""; + String releaseTime = ""; + String dsUid = ""; + // 查询图号 + ModelObject[] designs = KUtil.query("Item ID", fields1); + if (designs.length == 0) { + // errReason = "PLM系统中无此通用件,请联系通用件管理员"; + KUtil.log("Error:无此通用件,请联系通用件管理员"); + ObjectMapper objectMapper = new ObjectMapper(); + String data = ""; + try { + data = objectMapper.writeValueAsString(new CswjErrBean()); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + return data.toString(); + } else { + Item design = (Item) designs[0]; + KUtil.refreshAndGetProperties(design, "revision_list", "owning_user", "owning_group"); + ModelObject[] revision_list = design.get_revision_list(); + ItemRevision designRev = (ItemRevision) revision_list[revision_list.length - 1]; + // fields1.put("零组件 ID", item_id); + // 查询文档对象 + KUtil.refreshAndGetProperties(designRev, "owning_user", "owning_group", "ZT2_CSHRelation"); + String item_revision_id = ""; + // ModelObject[] documents = KUtil.query("Item ID", fields1); + User owning_user = (User) designRev.get_owning_user(); + KUtil.refreshAndGetProperties(owning_user, "user_name"); + Group owning_group = (Group) designRev.get_owning_group(); + ModelObject[] documents = + designRev.getPropertyObject("ZT2_CSHRelation").getModelObjectArrayValue(); + if (documents.length == 0) { + // 创建文档对象 + KUtil.log("Start:创建文档对象"); + System.out.println(owning_user); + ItemRevision zt2_cshDocument = + KUtil.createNewItemSoa( + "ZT2_CSHDocument", object_name, owning_group, owning_user, designRev); + createTime = format.format(new Date()); + KUtil.refreshAndGetProperties(zt2_cshDocument, "item_revision_id", "item_id"); + item_id = zt2_cshDocument.get_item_id(); + item_revision_id = zt2_cshDocument.get_item_revision_id(); + KUtil.log("Start:文件上传"); + Dataset dataset = + KUtil.uploadFile( + "MSExcelX", + "excel", + uploadFile.getOriginalFilename(), + file.getAbsolutePath(), + zt2_cshDocument, + loginInfo.getFmsUrl(), + loginInfo.getFmstemp()); + KUtil.log("Start:发布版本"); + KUtil.createProcess( + new String[] {dataset.getUid(), zt2_cshDocument.getUid()}, + "TCM Release Process", + "TCM Release Process"); + // KUtil.createProcess(zt2_cshDocument.getUid(),"TCM Release + // Process","TCM Release Process"); + dsUid = dataset.getUid(); + releaseTime = format.format(new Date()); + } else { + // 升版文档对象上传数据集 + // Item document = (Item)documents[0]; + // + // KUtil.refreshAndGetProperties(document,"revision_list","owning_user","owning_group"); + // ModelObject[] documentRevs = document.get_revision_list(); + KUtil.log("Start:升版文档版本"); + ItemRevision documentRev = (ItemRevision) documents[0]; + ItemRevision revise = KUtil.revise(documentRev, ""); + createTime = format.format(new Date()); + KUtil.changeOwner( + revise, + owning_user, + owning_group, + DataManagementService.getService(AppXSession.getConnection())); + KUtil.refreshAndGetProperties(revise, "item_revision_id", "item_id"); + item_id = revise.get_item_id(); + item_revision_id = revise.get_item_revision_id(); + KUtil.removeRelation("ZT2_CSHRelation", designRev); + KUtil.addRelation("ZT2_CSHRelation", designRev, revise); + KUtil.removeRelation("IMAN_specification", revise); + Dataset dataset = + KUtil.uploadFile( + "MSExcelX", + "excel", + uploadFile.getOriginalFilename(), + file.getAbsolutePath(), + revise, + loginInfo.getFmsUrl(), + loginInfo.getFmstemp()); + KUtil.createProcess( + new String[] {dataset.getUid(), revise.getUid()}, + "TCM Release Process", + "TCM Release Process"); + // KUtil.createProcess(revise.getUid(),"TCM Release Process","TCM + // Release Process"); + KUtil.log("End:升版文档版本"); + releaseTime = format.format(new Date()); + dsUid = dataset.getUid(); + } + mapper.insertIntoLog( + item_id, object_name, design_id, "", createTime, dsUid, releaseTime, item_revision_id); + CswjBean cswjBean = + new CswjBean( + item_id, + object_name, + "", + item_revision_id, + createTime, + releaseTime, + owning_user.get_user_name()); + ObjectMapper objectMapper = new ObjectMapper(); + String data = ""; + try { + data = objectMapper.writeValueAsString(cswjBean); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + return data; + } + } catch (Exception e) { + e.printStackTrace(); + errReason = e.getMessage(); + } + String data = ""; + try { + ObjectMapper objectMapper = new ObjectMapper(); + data = objectMapper.writeValueAsString(new CswjErrBean("600", errReason)); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + return data.toString(); + // return "ddwda"; + } + + public void replaceZipFile(String zipFileName, String newFile) throws Exception { + FileInputStream fis = new FileInputStream(zipFileName); + File file = new File(newFile); + ZipInputStream zis = new ZipInputStream(fis, Charset.forName("GBK")); + ZipEntry entry = null; + while ((entry = zis.getNextEntry()) != null) { + System.out.println("name==>" + entry.getName()); + if (entry.getName().equals(file.getName())) {} + } + zis.close(); + fis.close(); + } + + @Autowired EPMMapper mapper; + + @PostMapping("/ReuseofHistoricalProjects1") + public String findClass(String jSONObject) { + JSONObject request = JSON.parseObject(jSONObject); + Set strings = request.keySet(); + StringBuilder builder = new StringBuilder("未查询到的属性:"); + StringBuilder sql = + new StringBuilder("select PID from PICM0 where PCID ='ICM230101'"); // ICM230101 + for (String key : strings) { + String idNo = mapper.getPunct(key); + if (idNo == null || idNo.equals("")) { + continue; + } + String psm = "psm" + String.format("%02d", Integer.valueOf(idNo)); + sql.append(" and ") + .append(psm) + .append(" like '%") + .append(request.getString(key)) + .append("%'"); + builder.append(key).append(":").append(request.getString(key)).append(";"); + } + builder.append("."); + List beans = new ArrayList<>(); + List list = mapper.selectBj(sql.toString()); + List list2 = new ArrayList<>(); + for (String val : list) { + String itemId = val.split("/")[0]; + if (!list2.contains(itemId)) { + String name = mapper.getName(itemId); + beans.add(new ItemBean(itemId, name)); + list2.add(itemId); + } + } + Object bean = null; + if (list2.size() > 0) { + bean = new HistoryBean(beans); + } else { + bean = new HistoryErrBean(builder.toString()); + } + ObjectMapper objectMapper = new ObjectMapper(); + String data = ""; + try { + data = objectMapper.writeValueAsString(bean); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + return data.toString(); + } + + public Boolean inIds(String[] ids, String itemId) { + for (String id : ids) { + if (itemId.contains(id)) { + return true; + } + } + return false; + } + + public BomPropBean getPropBean(ItemRevision childRev) { + BomPropBean bean = new BomPropBean(); + // ArrayList cBeans = new ArrayList<>(); + // bean.setChildren(cBeans); + try { + KUtil.refreshAndGetProperties( + childRev, + "item_id", + "object_name", + "creation_date", + "object_desc", + "item_revision_id", + "release_status_list", + "date_released"); + // BomPropBean bean = new BomPropBean(); + String object_name = childRev.get_object_name(); + String object_desc = childRev.get_object_desc(); + String revisionId = childRev.get_item_revision_id(); + Calendar creation_date = childRev.get_creation_date(); + User owning_user = (User) childRev.get_owning_user(); + KUtil.refreshAndGetProperties(owning_user, "user_id"); + String item_id1 = childRev.get_item_id(); + ReleaseStatus[] release_status_list = childRev.get_release_status_list(); + if (release_status_list.length == 0) { + // bean.setReleaseDate("未发布"); + } else { + Calendar date_released = childRev.get_date_released(); + String s = + String.valueOf(date_released.get(Calendar.YEAR)) + + "-" + + String.format("%02d", date_released.get(Calendar.MONTH) + 1) + + "-" + + String.format("%02d", date_released.get(Calendar.DATE)); + bean.setReleaseDate(s); + } + bean.setCreateDate( + String.valueOf(creation_date.get(Calendar.YEAR)) + + "-" + + String.format("%02d", creation_date.get(Calendar.MONTH) + 1) + + "-" + + String.format("%02d", creation_date.get(Calendar.DATE))); + bean.setRevision(revisionId); + bean.setAssignee(owning_user.get_user_id()); + bean.setItemId(item_id1); + // bean.setObjDesc(object_desc); + // bean.setObjName(object_name); + } catch (Exception e) { + e.printStackTrace(); + } + return bean; + } + + @GetMapping("/ReuseofHistoricalProjects2") + public String getBomMessage(String item_id) { + Map fields1 = new HashMap<>(); + // 原来查询 + fields1.put("零组件 ID", item_id); + List beans = new ArrayList<>(); + try { + ModelObject[] designs = KUtil.query("Item ID", fields1); + if (designs.length > 0) { + Item item1 = (Item) designs[0]; + KUtil.refreshAndGetProperties(item1, "revision_list"); + ModelObject[] revision_list = item1.get_revision_list(); + ItemRevision revision = (ItemRevision) revision_list[revision_list.length - 1]; + String[] chint_cshCheckProps = KUtil.GetPrefValues("chint_CshCheckProp"); + String[] ids = chint_cshCheckProps[0].split(";"); + ArrayList arrayList = KUtil.openBOMWindow(revision); + BOMLine bomLine = (BOMLine) arrayList.get(1); + KUtil.refreshAndGetProperties(bomLine, "bl_child_lines"); + ModelObject[] bl_child_lines = bomLine.get_bl_child_lines(); + for (ModelObject bl_child_line : bl_child_lines) { + if (bl_child_line instanceof BOMLine) { + BOMLine line = (BOMLine) bl_child_line; + KUtil.refreshAndGetProperties(line, "bl_line_object"); + ItemRevision childRev = (ItemRevision) line.get_bl_line_object(); + KUtil.refreshAndGetProperties(childRev, "item_id"); + String item_id1 = childRev.get_item_id(); + System.out.println("child==>" + item_id1); + if (inIds(ids, item_id1)) { + BomPropBean propBean = getPropBean(childRev); + beans.add(propBean); + } + } + } + KUtil.closeBOMWindow((BOMWindow) arrayList.get(0)); + } + } catch (Exception e) { + e.printStackTrace(); + } + Object bean = null; + if (beans.size() > 0) { + bean = new PartBean(beans); + } else { + bean = new PartErrBean(item_id); + } + ObjectMapper objectMapper = new ObjectMapper(); + String data = ""; + try { + data = objectMapper.writeValueAsString(bean); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + System.out.println("data.toString()==>" + data.toString()); + return data.toString(); + } + + // private void readLine(BOMLine bomLine, BomPropBean bean) { + // try { + // KUtil.refreshAndGetProperties(bomLine, "bl_child_lines"); + // ModelObject[] bl_child_lines = bomLine.get_bl_child_lines(); + // for (ModelObject bl_child_line : bl_child_lines) { + // if (bl_child_line instanceof BOMLine) { + // BOMLine line = (BOMLine) bl_child_line; + // KUtil.refreshAndGetProperties(line, "bl_line_object"); + // ItemRevision revision = (ItemRevision) line.get_bl_line_object(); + // BomPropBean cBean = getPropBean(revision); + // bean.getChildren().add(cBean); + // readLine(line, cBean); + // } + // } + // } catch (Exception e) { + // e.printStackTrace(); + // } + // } + + private void readBomExclusionds(List dsList, BOMLine bomLine) throws Exception { + + KUtil.refreshAndGetProperties(bomLine, "bl_line_object"); + ItemRevision revision = (ItemRevision) bomLine.get_bl_line_object(); + KUtil.refreshAndGetProperties(revision, "IMAN_specification"); + ModelObject[] IMAN_specifications = revision.get_IMAN_specification(); + for (ModelObject IMAN_specificatio : IMAN_specifications) { + if (IMAN_specificatio instanceof Dataset) { + Dataset ds = (Dataset) IMAN_specificatio; + KUtil.refreshAndGetProperties(ds, "object_type"); + String object_type = ds.get_object_type(); + if (object_type.equals("ProPrt") + || object_type.equals("ProAsm") + || object_type.equals("ProDrw")) { + dsList.add(ds); + if (object_type.equals("ProAsm")) { + // asm 文件BOM排除 + KUtil.refreshAndGetProperties(ds, "Pro2_bom_exclusion"); + ModelObject[] bom_exclusions = + ds.getPropertyObject("Pro2_bom_exclusion").getModelObjectArrayValue(); + if (bom_exclusions != null && bom_exclusions.length > 0) { + getBomExclusion(dsList, bom_exclusions); + } + } + } + } + } + KUtil.refreshAndGetProperties(bomLine, "bl_child_lines"); + ModelObject[] bl_child_lines = bomLine.get_bl_child_lines(); + for (ModelObject bl_child_line : bl_child_lines) { + readBomExclusionds(dsList, (BOMLine) bl_child_line); + } + } + + private void getBomExclusion(List dsList, ModelObject[] bom_exclusions) + throws Exception { + + for (ModelObject bom_exclusion : bom_exclusions) { + if (bom_exclusion instanceof ItemRevision) { + ItemRevision bomRev = (ItemRevision) bom_exclusion; + ArrayList arrayList = KUtil.openBOMWindow(bomRev); + BOMLine bomLine = (BOMLine) arrayList.get(1); + + readBomExclusionds(dsList, bomLine); + + KUtil.closeBOMWindow((BOMWindow) arrayList.get(0)); + } + } + } + + private void getAllDs(BOMLine bomLine, List dsList) { + try { + KUtil.refreshAndGetProperties(bomLine, "bl_child_lines"); + ModelObject[] bl_child_lines = bomLine.get_bl_child_lines(); + for (ModelObject bl_child_line : bl_child_lines) { + if (bl_child_line instanceof BOMLine) { + BOMLine line = (BOMLine) bl_child_line; + KUtil.refreshAndGetProperties(line, "bl_line_object"); + ItemRevision revision = (ItemRevision) line.get_bl_line_object(); + KUtil.refreshAndGetProperties(revision, "IMAN_specification"); + ModelObject[] IMAN_specifications = revision.get_IMAN_specification(); + for (ModelObject IMAN_specificatio : IMAN_specifications) { + if (IMAN_specificatio instanceof Dataset) { + Dataset ds = (Dataset) IMAN_specificatio; + KUtil.refreshAndGetProperties(ds, "object_type"); + String object_type = ds.get_object_type(); + if (object_type.equals("ProPrt") + || object_type.equals("ProAsm") + || object_type.equals("ProDrw")) { + dsList.add(ds); + if (object_type.equals("ProAsm")) { + // asm 文件BOM排除 + KUtil.refreshAndGetProperties(ds, "Pro2_bom_exclusion"); + ModelObject[] bom_exclusions = + ds.getPropertyObject("Pro2_bom_exclusion").getModelObjectArrayValue(); + if (bom_exclusions != null && bom_exclusions.length > 0) { + getBomExclusion(dsList, bom_exclusions); + } + } + } + } + } + getAllDs(line, dsList); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + private void getAllDs2(List revisions, List dsList) { + try { + // KUtil.refreshAndGetProperties(bomLine,"bl_child_lines"); + // ModelObject[] bl_child_lines = bomLine.get_bl_child_lines(); + for (ItemRevision revision : revisions) { + KUtil.refreshAndGetProperties(revision, "IMAN_specification"); + ModelObject[] IMAN_specifications = revision.get_IMAN_specification(); + System.out.println("IMAN_specifications.size" + IMAN_specifications.length); + for (ModelObject IMAN_specificatio : IMAN_specifications) { + if (IMAN_specificatio instanceof Dataset) { + Dataset ds = (Dataset) IMAN_specificatio; + KUtil.refreshAndGetProperties(ds, "object_type"); + String object_type = ds.get_object_type(); + if (object_type.equals("ProPrt") + || object_type.equals("ProAsm") + || object_type.equals("ProDrw")) { + dsList.add(ds); + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + // 获取原始文件 + public void getTempDataset(List dsList, String item) throws Exception { + Map fields = new HashMap<>(); + fields.put("图样代号", item); + ModelObject[] objects = KUtil.query("参数化查询图纸", fields); + if (objects.length > 0) { + if (objects[0] instanceof ItemRevision) { + ItemRevision designRev = (ItemRevision) objects[0]; + KUtil.refreshAndGetProperties(designRev, "items_tag"); + Item items_tag = designRev.get_items_tag(); + KUtil.refreshAndGetProperties( + items_tag, "revision_list", "item_id", "owning_user", "object_name"); + + ModelObject[] revision_list = items_tag.get_revision_list(); + ItemRevision revision = (ItemRevision) revision_list[revision_list.length - 1]; + KUtil.refreshAndGetProperties(revision, "IMAN_specification"); + ModelObject[] IMAN_specifications = revision.get_IMAN_specification(); + ArrayList arrayList = KUtil.openBOMWindow(revision); + BOMLine bomLine = (BOMLine) arrayList.get(1); + for (ModelObject IMAN_specificatio : IMAN_specifications) { + if (IMAN_specificatio instanceof Dataset) { + Dataset ds = (Dataset) IMAN_specificatio; + KUtil.refreshAndGetProperties(ds, "object_type"); + String object_type = ds.get_object_type(); + System.out.println("文件类型:" + object_type); + if (object_type.equals("ProPrt") || object_type.equals("ProAsm")) { + dsList.add(ds); + if (object_type.equals("ProAsm")) { + // asm 文件BOM排除 + KUtil.refreshAndGetProperties(ds, "Pro2_bom_exclusion"); + ModelObject[] bom_exclusions = + ds.getPropertyObject("Pro2_bom_exclusion").getModelObjectArrayValue(); + if (bom_exclusions != null && bom_exclusions.length > 0) { + getBomExclusion(dsList, bom_exclusions); + } + } + } else if (object_type.equals("ProDrw")) { + dsList.add(ds); + } + } + } + getAllDs(bomLine, dsList); + KUtil.closeBOMWindow((BOMWindow) arrayList.get(0)); + } + } + } + + public Boolean isTyj(String drawNo, String tyjId) { + + if (drawNo.equals(tyjId)) { + return true; + } + if (Pattern.matches("(\\S+)-\\d{6}$", drawNo)) { + String drawNo2 = drawNo.substring(0, drawNo.length() - 7); + if (drawNo2.equals(tyjId)) { + return true; + } + } + return false; + } + // @PostMapping("/updateMaterial") + // public JsonResult updateMantr(@RequestBody JSONObject jSONObject){ + // + // new Thread(new Runnable() { + // @Override + // public void run() { + // try{ + //// System.out.println(jSONObject.toJSONString()); + // SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd-HHmmssSSS"); + // String txtPath = "D:\\"+format2.format(new Date()) + ".txt"; + // FileOutputStream out = new FileOutputStream(txtPath); + // OutputStreamWriter outWriter = new OutputStreamWriter(out, "UTF-8"); + // BufferedWriter bufWrite = new BufferedWriter(outWriter); + // bufWrite.write(jSONObject.toJSONString()); + // bufWrite.close(); + // outWriter.close(); + // out.close(); + // String cmd = "D:\\updateMantr.bat "+txtPath; + // String s = executeCmdCommand(cmd); + // System.out.println(s); + // new File(txtPath).delete(); + // KUtil.logMsg(jSONObject.toJSONString()); + // }catch (Exception e){ + // e.printStackTrace(); + // } + // } + // }).start(); + // + // + // JsonResult jsonResult = new JsonResult("接收成功",200); + // return jsonResult; + // + // } + + String[] getTagById(String item, String spec, String userId, String itemId) throws Exception { + String code = ""; + + Map fields1 = new HashMap<>(); + // 原来查询 + fields1.put("图样代号", item + "*"); + fields1.put("型号规格", spec); + ModelObject[] designs = KUtil.query("参数化查询图纸", fields1); + System.out.println("designs.length:" + designs.length); + ItemRevision designRev = null; + for (ModelObject design : designs) { + KUtil.refreshAndGetProperties(design, "zt2_DrawingNo"); + String zt2_drawingNo = design.getPropertyDisplayableValue("zt2_DrawingNo"); + if (isTyj(zt2_drawingNo, item)) { + designRev = (ItemRevision) design; + break; + } + } + if (designRev != null) { + code = "200"; + KUtil.refreshAndGetProperties(designRev, "item_id"); + itemId = designRev.get_item_id(); + // message = "存在对应规格的通用件."; + } else { + Map fields = new HashMap<>(); + // 原来查询 + fields.put(DefineUtil.PATTERNCODE, item + "*"); + ModelObject[] objects2 = KUtil.query(DefineUtil.SEARCHDRAW, fields); + fields.put(DefineUtil.PATTERNCODE, item); + ModelObject[] objects = KUtil.query(DefineUtil.SEARCHDRAW, fields); + // 获取最大流水号 + int flowNum = 0; + for (ModelObject object : objects2) { + KUtil.refreshAndGetProperties(object, DefineUtil.ITEMID); + String objectId = object.getPropertyDisplayableValue(DefineUtil.ITEMID); + if (Pattern.matches(item + "-\\d{6}$", objectId)) { + String[] split = objectId.split("-"); + if (split.length == 1) { + continue; + } + int num = Integer.parseInt(split[split.length - 1]); + if (num >= flowNum) { + flowNum = num; + } + } + } + String newID = item + "-" + String.format("%06d", flowNum + 1); + ModelObject tempModj = null; + for (ModelObject obj : objects) { + KUtil.refreshAndGetProperties(obj, DefineUtil.DRAWNO); + String zt2_drawingNo = obj.getPropertyDisplayableValue(DefineUtil.DRAWNO); + if (isTyj(zt2_drawingNo, item)) { + tempModj = obj; + break; + } + } + if (tempModj == null) { + code = "800"; + } else { + itemId = newID; + KUtil.refreshAndGetProperties(tempModj, "object_name", "items_tag"); + Item items_tag = ((ItemRevision) tempModj).get_items_tag(); + KUtil.refreshAndGetProperties(items_tag, "revision_list"); + ModelObject[] revision_list = items_tag.get_revision_list(); + ItemRevision revision = (ItemRevision) revision_list[revision_list.length - 1]; + String object_nameN = tempModj.getPropertyDisplayableValue("object_name"); + Map userMap = new HashMap<>(); + // 原来查询 + userMap.put("用户 ID", userId); + ModelObject[] object2 = KUtil.query("Admin - Employee Information", userMap); + User user = (User) object2[0]; + KUtil.refreshAndGetProperties(user, "default_group"); + Group group = (Group) user.get_default_group(); + KUtil.log("执行saveAsItem:[start]"); + saveAsItem(revision, newID, object_nameN, group, user, spec); + // message = ("新通用件号如下."); + code = "500"; + KUtil.log("执行saveAsItem:[end:" + revision.getUid() + "]"); + } + } + String[] test = new String[] {code, itemId}; + return test; + } + + @PostMapping("/CshGetCommonPartsNoDS") + public String cshGetCommonPartsNoDS(String jSONObject) { + AppXSession session = null; + StringBuilder message = new StringBuilder(""); + JSONObject data = new JSONObject(); + try { + JSONArray dataArray = new JSONArray(); + JSONObject obj200 = new JSONObject(); + System.out.println("jSONObject" + jSONObject); + JSONObject object = JSON.parseObject(jSONObject); + String user_id = object.getString("user_id"); + JSONArray array200 = new JSONArray(); + obj200.put("code", "200"); + obj200.put("desc", "存在对应规格的通用件."); // desc":"存在对应规格的通用件", + obj200.put("user", user_id); + obj200.put("details", array200); + JSONObject obj500 = new JSONObject(); + JSONArray array500 = new JSONArray(); + obj500.put("code", "500"); + obj500.put("desc", "新通用件号如下."); // desc":"存在对应规格的通用件", + obj500.put("user", user_id); + obj500.put("details", array500); + JSONObject obj800 = new JSONObject(); + JSONArray array800 = new JSONArray(); + obj800.put("code", "800"); + obj800.put("desc", "输入的通用件图号不存在,请先上传原始通用件号."); // desc":"存在对应规格的通用件", + obj800.put("user", user_id); + obj800.put("details", array800); + JSONArray contents = object.getJSONArray("contents"); + for (int i = 0; i < contents.size(); i++) { + JSONObject jsonObject = contents.getJSONObject(i); + String item_id = jsonObject.getString("item_id"); + String zt2_specifications = jsonObject.getString("zt2_Specifications"); + String no = jsonObject.getString("no"); + String itemId = item_id; + String[] codes = getTagById(item_id, zt2_specifications, user_id, itemId); + JSONObject details = new JSONObject(); + details.put("item_id", codes[1]); + details.put("zt2_Specifications", zt2_specifications); + details.put("no", no); + if (codes[0].equals("200")) { + array200.add(details); + } else if (codes[0].equals("500")) { + array500.add(details); + } else if (codes[0].equals("800")) { + array800.add(details); + } + } + if (array200.size() > 0) { + dataArray.add(obj200); + } + if (array500.size() > 0) { + dataArray.add(obj500); + } + if (array800.size() > 0) { + dataArray.add(obj800); + } + data.put("result", dataArray); + } catch (Exception e) { + e.printStackTrace(); + message.append(e.getMessage()); + } finally { + try { + // KUtil.setByPass(false); + } catch (Exception e) { + e.printStackTrace(); + } + } + KUtil.log("EndMsg:[data:" + data.toString() + "]"); + return data.toString(); + } + + @Transactional + @RequestMapping( + value = "/getCoreweight", + method = {RequestMethod.GET, RequestMethod.POST}) + public String getCoreweight(@RequestBody CoreBean coreBean) throws Exception { + + log(">> 开始执行:getCoreweight"); + log("jSONObject = " + coreBean); + // Session session = new Session(config.getTc_url()); + // User user = session.login2(config.getTc_user(), config.getTc_pwd()); + // if (user == null) { + // throw new Exception("Teamcenter SOA登录失败"); + // } + DataManagementService dataManagementService = + DataManagementService.getService(AppXSession.getConnection()); + String productno = coreBean.getProductno(); + String wbsno = coreBean.getWbsno(); + // 根据查询搜索到线圈物料 + String code = "500"; + Map fields = new HashMap<>(); + fields.put("materialno", productno); + fields.put("WBS号", wbsno); + String weight = ""; // 0.0; + ModelObject[] chint_query_material_updates = KUtil.query("chint_query_material_test", fields); + if (chint_query_material_updates.length > 0) { + ModelObject item = chint_query_material_updates[0]; + dataManagementService.getProperties( + new ModelObject[] {item}, new String[] {"TC_Is_Represented_By"}); + ModelObject[] modelObjectValue = + item.getPropertyObject("TC_Is_Represented_By").getModelObjectArrayValue(); // 物料对象 + if (modelObjectValue.length > 0) { + ModelObject modelObject = modelObjectValue[0]; + dataManagementService.getProperties( + new ModelObject[] {modelObject}, new String[] {"item_id"}); + String item_id = modelObject.getPropertyObject("item_id").getStringValue(); + String[] split = item_id.split("-"); + String id = "1ZDB400000T-" + split[1]; + Map fields1 = new HashMap<>(); + // 原来查询 + fields1.put("零组件 ID", id); + ModelObject[] designs = KUtil.query("Item ID", fields1); + // ModelObject[] designs = TCUtil.queryItemByID(id); + if (designs.length > 0) { + Item design = (Item) designs[0]; + dataManagementService.getProperties( + new ModelObject[] {design}, new String[] {"revision_list"}); + ModelObject[] revision_list = design.get_revision_list(); + ItemRevision revision = (ItemRevision) revision_list[revision_list.length - 1]; + dataManagementService.getProperties( + new ModelObject[] {revision}, new String[] {"zt2_DesignWeight"}); + double zt2_designWeight = revision.getPropertyObject("zt2_DesignWeight").getDoubleValue(); + code = "200"; + String format = String.format("%.3f", zt2_designWeight); + System.out.println(String.valueOf(zt2_designWeight)); + weight = format.toString(); + } + } + } + + CoreBeanReturn rs = new CoreBeanReturn(productno, wbsno, weight, code); + // Result rs = new Result("",1); + ObjectMapper objectMapper = new ObjectMapper(); + String data = objectMapper.writeValueAsString(rs); + log("返回数据:" + data + "\n"); + // session.logout(); + return data; + } + + @Transactional + @RequestMapping( + value = "/GetSinglephasecoil", + method = {RequestMethod.GET, RequestMethod.POST}) + public String getSinglephasecoil(@RequestBody GetCoilBean getCoilBean) throws Exception { + // ProjectInfoBean projInfo + log(">> 开始执行:getSinglephasecoil"); + log("jSONObject = " + getCoilBean); + // if (user == null) { + // throw new Exception("Teamcenter SOA登录失败"); + // } + String materialno2 = getCoilBean.getMaterialno(); + // 根据查询搜索到线圈物料 + Map fields = new HashMap<>(); + fields.put("materialno", materialno2); + ModelObject[] chint_query_material_updates = KUtil.query("chint_query_material_update", fields); + String code = "500"; + String weight = ""; + String drawingno = ""; + String materialno = materialno2; + String name = ""; + for (ModelObject chint_query_material_update : chint_query_material_updates) { + DataManagementService dataManagementService = + DataManagementService.getService(AppXSession.getConnection()); + com.teamcenter.services.strong.core._2012_02.DataManagement.WhereUsedInputData inputData = + new com.teamcenter.services.strong.core._2012_02.DataManagement.WhereUsedInputData(); + com.teamcenter.services.strong.core._2012_02.DataManagement.WhereUsedInputData[] datas = + new com.teamcenter.services.strong.core._2012_02.DataManagement.WhereUsedInputData[1]; + inputData.useLocalParams = false; + // ModelObject chint_query_material_update = chint_query_material_updates[0]; + if (chint_query_material_update instanceof ItemRevision) { + dataManagementService.getProperties( + new ModelObject[] {chint_query_material_update}, new String[] {"object_name"}); + name = ((ItemRevision) chint_query_material_update).get_object_name(); + inputData.inputObject = (ItemRevision) chint_query_material_update; + } + datas[0] = inputData; + com.teamcenter.services.strong.core._2012_02.DataManagement.WhereUsedConfigParameters + parameters = + new com.teamcenter.services.strong.core._2012_02.DataManagement + .WhereUsedConfigParameters(); + parameters.boolMap.put("whereUsedPreciseFlag", false); + parameters.intMap.put("numLevels", new BigInteger("1")); + + com.teamcenter.services.strong.core._2012_02.DataManagement.WhereUsedResponse + whereUsedResponse = dataManagementService.whereUsed(datas, parameters); + if (whereUsedResponse.output.length > 0) { + com.teamcenter.services.strong.core._2012_02.DataManagement.WhereUsedParentInfo[] info = + whereUsedResponse.output[0].info; + for (com.teamcenter.services.strong.core._2012_02.DataManagement.WhereUsedParentInfo in : + info) { + WorkspaceObject parentObject = in.parentObject; + if (parentObject instanceof ItemRevision) { + ItemRevision parentRev = (ItemRevision) parentObject; + dataManagementService.getProperties( + new ModelObject[] {parentRev}, new String[] {"object_type"}); + if (!parentRev.get_object_type().contains("Part")) { + continue; + } + dataManagementService.getProperties( + new ModelObject[] {parentRev}, new String[] {"TC_Is_Represented_By"}); + ModelObject[] modelObjectValue = + parentRev + .getPropertyObject("TC_Is_Represented_By") + .getModelObjectArrayValue(); // 物料对象 + if (modelObjectValue != null && modelObjectValue.length > 0) { + ItemRevision designRev = (ItemRevision) modelObjectValue[0]; + dataManagementService.getProperties( + new ModelObject[] {designRev}, new String[] {"item_id", "zt2_DesignWeight"}); + drawingno = designRev.get_item_id(); + if (drawingno.contains("-")) { + String[] split = drawingno.split("-"); + String topId = "1ZDB300000P" + "-" + split[1]; + Map fields1 = new HashMap<>(); + // 原来查询 + fields1.put("零组件 ID", topId); + ModelObject[] designs = KUtil.query("Item ID", fields1); + // ModelObject[] designs = + // KUtil.queryItemByID(topId); + if (designs.length > 0) { + Item design = (Item) designs[0]; + System.out.println(design.getUid()); + ClassificationService service = + ClassificationService.getService(AppXSession.getConnection()); + Classification.FindClassificationObjectsResponse classificationObjects1 = + service.findClassificationObjects(new WorkspaceObject[] {design}); + // Classification.FindClassifiedObjectsResponse + // classifiedObjects = service.findClassifiedObjects(new ModelObject[]{design}); + Classification.GetAttributesForClassesResponse attributesForClasses = + service.getAttributesForClasses(new String[] {"ICM230101"}); + Map attributes = + attributesForClasses.attributes; + System.out.println(attributes.toString()); + Classification.ClassAttribute[] icm220101s = attributes.get("ICM230101"); + int ids = 0; + for (Classification.ClassAttribute icm220101 : icm220101s) { + System.out.println("name" + icm220101.name + "idsss" + icm220101.id); + if (icm220101.name.equals("相数")) { + ids = icm220101.id; + break; + } + } + int len = 1; + Map icos = classificationObjects1.icos; + if (icos.size() > 0) { + Classification.GetClassificationObjectsResponse classificationObjects = + service.getClassificationObjects(icos.get(design)); + Map clsObjs = + classificationObjects.clsObjs; + for (ModelObject mod : clsObjs.keySet()) { + System.out.println(mod.getUid()); + Classification.ClassificationObject classificationObject = clsObjs.get(mod); + Classification.ClassificationProperty[] properties = + classificationObject.properties; + for (Classification.ClassificationProperty property : properties) { + if (property.attributeId == ids) { + if (!property.values[0].dbValue.equals("")) { + len = Integer.valueOf(property.values[0].dbValue); + code = "200"; + } + } + } + } + } + double res = 0; + double zt2_designWeight = + designRev.getPropertyObject("zt2_DesignWeight").getDoubleValue(); + res = zt2_designWeight / len; + String format = String.format("%.3f", res); + weight = format; + } + } + } + } + } + } + if (code.equals("200")) { + break; + } + } + ReturnBean1 rs = new ReturnBean1(code, weight, drawingno, materialno, name); + // Result rs = new Result("",1); + ObjectMapper objectMapper = new ObjectMapper(); + String data = objectMapper.writeValueAsString(rs); + log("返回数据:" + data + "\n"); + return data; + } + + @GetMapping("/CshGetCommonParts") + public String getTemplate(String item_id, String zt2_Specifications, String userId) { + AppXSession session = null; + StringBuilder message = new StringBuilder(""); + List downFile = new ArrayList<>(); + List errFile = new ArrayList<>(); + String code = "200"; + String lastId = ""; + String objName = ""; + // String url = ""; + String document = ""; + List fileNames = new ArrayList<>(); + List uids = new ArrayList<>(); + try { + String item = item_id; + String spec = zt2_Specifications; + + // Creo 零件 Creo 图纸 Creo 装配 + // 查询图纸对 + // 存在 + Map fields1 = new HashMap<>(); + // 原来查询 + fields1.put("图样代号", item + "*"); + fields1.put("型号规格", spec); + ModelObject[] designs = KUtil.query("参数化查询图纸", fields1); + System.out.println("designs.length:" + designs.length); + ItemRevision designRev = null; + for (ModelObject design : designs) { + KUtil.refreshAndGetProperties(design, "zt2_DrawingNo"); + String zt2_drawingNo = design.getPropertyDisplayableValue("zt2_DrawingNo"); + if (isTyj(zt2_drawingNo, item)) { + designRev = (ItemRevision) design; + break; + } + } + if (designRev != null) { + KUtil.refreshAndGetProperties(designRev, "items_tag"); + Item items_tag = designRev.get_items_tag(); + List dsList = new ArrayList<>(); + Item item1 = items_tag; + KUtil.refreshAndGetProperties( + item1, "revision_list", "item_id", "owning_user", "object_name"); + objName = item1.get_object_name(); + lastId = item1.get_item_id(); + ModelObject[] revision_list = item1.get_revision_list(); + ItemRevision revision = (ItemRevision) revision_list[revision_list.length - 1]; + KUtil.refreshAndGetProperties(revision, "IMAN_specification"); + ModelObject[] IMAN_specifications = revision.get_IMAN_specification(); + boolean hasSw = false; + boolean hastz = false; + ArrayList arrayList = KUtil.openBOMWindow(revision); + BOMLine bomLine = (BOMLine) arrayList.get(1); + for (ModelObject IMAN_specificatio : IMAN_specifications) { + if (IMAN_specificatio instanceof Dataset) { + Dataset ds = (Dataset) IMAN_specificatio; + KUtil.refreshAndGetProperties(ds, "object_type"); + String object_type = ds.get_object_type(); + System.out.println("文件类型:" + object_type); + if (object_type.equals("ProPrt") || object_type.equals("ProAsm")) { + hasSw = true; + hastz = true; + dsList.add(ds); + if (object_type.equals("ProAsm")) { + // asm 文件BOM排除 + KUtil.refreshAndGetProperties(ds, "Pro2_bom_exclusion"); + ModelObject[] bom_exclusions = + ds.getPropertyObject("Pro2_bom_exclusion").getModelObjectArrayValue(); + if (bom_exclusions != null && bom_exclusions.length > 0) { + getBomExclusion(dsList, bom_exclusions); + } + } + } else if (object_type.equals("ProDrw")) { + hastz = true; + dsList.add(ds); + } + } + } + if (!hastz) { + getTempDataset(dsList, item_id); + } + getAllDs(bomLine, dsList); + KUtil.closeBOMWindow((BOMWindow) arrayList.get(0)); + System.out.println("遍历获取数据集"); + FileManagementUtility fmu = + new FileManagementUtility( + AppXSession.getConnection(), + null, + new String[] {loginInfo.getFmsUrl()}, + new String[] {loginInfo.getFmsUrl()}, + loginInfo.getFmstemp()); + List files = new ArrayList<>(); + Set set = new HashSet(dsList); + dsList.clear(); + dsList.addAll(set); + for (Dataset ds : dsList) { + KUtil.refreshAndGetProperties(ds, "ref_list", "ref_names", "object_name", "object_type"); + String object_type1 = ds.get_object_type(); + if (object_type1.equals("ProPrt") || object_type1.equals("ProAsm")) { + KUtil.refreshAndGetProperties(ds, "IPEM_master_dependency"); + ModelObject[] ipem_master_dependencies = + ds.getPropertyObject("IPEM_master_dependency").getModelObjectArrayValue(); + if (ipem_master_dependencies.length > 0) { + ItemRevision ipemTag = (ItemRevision) ipem_master_dependencies[0]; + KUtil.refreshAndGetProperties(ipemTag, "IMAN_specification"); + ModelObject[] IMAN_specifications2 = ipemTag.get_IMAN_specification(); + for (ModelObject IMAN_specificatio : IMAN_specifications2) { + if (IMAN_specificatio instanceof Dataset) { + Dataset dataset = (Dataset) IMAN_specificatio; + KUtil.refreshAndGetProperties(dataset, "object_type"); + String object_type = dataset.get_object_type(); + if (object_type.equals("ProPrt") + || object_type.equals("ProAsm") + || object_type.equals("ProDrw")) { + // dsList.add(ds); + ds = dataset; + KUtil.refreshAndGetProperties(ds, "ref_list", "ref_names", "object_name"); + break; + } + } + } + } + } + ModelObject[] ref_list = ds.get_ref_list(); + String object_name = ds.get_object_name(); + String[] ref_names = ds.get_ref_names(); + if (ref_list.length == 0 && !errFile.contains(object_name)) { + errFile.add(object_name); + if (object_name.contains(item_id)) { + code = "600"; + } else { + code = "700"; + } + } + System.out.println(ref_list.length + "ref_list"); + for (int i = 0; i < ref_list.length; i++) { + if (!(ref_list[i] instanceof ImanFile) || ref_names[i].equals("MetaData")) { + System.out.println("i==>" + i); + continue; + } + ImanFile file = (ImanFile) ref_list[i]; + KUtil.refreshAndGetProperties(file, "original_file_name", "file_size"); + String file_size = file.get_file_size(); + if (file_size == null || file_size.equals("0")) { + System.out.println("i====>" + i); + continue; + } + if (files.contains(file)) { + System.out.println("i======>" + i); + continue; + } + String original_file_name = file.getPropertyDisplayableValue("original_file_name"); + if (ref_names[i].equals("PrtFile") + || ref_names[i].equals("DrwFile") + || ref_names[i].equals("AsmFile")) { + downFile.add(original_file_name); + } + fileNames.add(original_file_name); + uids.add(file.getUid()); + files.add(file); + } + // .addAll(Arrays.asList(ref_list)); + } + if (dsList.size() == 0) { + code = "600"; + } + if (code.equals("600") && (files.size() == 0 || dsList.size() == 0)) { + message.append("PLM系统中此通用件无数据模型,请联系通用件管理员"); + } else if (code.equals("700") && files.size() == 0) { + message.append("PLM系统中通用件的数据模型数据异常,无法传递。请联系通用件管理员"); + } else if (!hasSw) { + code = "600"; + User owning_user = (User) item1.get_owning_user(); + KUtil.refreshAndGetProperties(owning_user, "user_name"); + String user_name = owning_user.get_user_name(); + if (!hastz) { + message.append("PLM系统中此通用件无数据模型,请联系通用件管理员"); + } else { + message.append("不存在三维图纸,user_id:").append(user_name); + } + } else { + message.append("存在三维图纸,图纸已打包"); + } + } else { + Map fields = new HashMap<>(); + // 原来查询 + fields.put("图样代号", item + "*"); + ModelObject[] objects2 = KUtil.query("参数化查询图纸", fields); + fields.put("图样代号", item); + ModelObject[] objects = KUtil.query("参数化查询图纸", fields); + String newID = item + "-" + String.format("%06d", objects2.length + 1); + lastId = newID; + code = "500"; + ModelObject tempModj = null; + for (ModelObject obj : objects) { + KUtil.refreshAndGetProperties(obj, "zt2_DrawingNo"); + String zt2_drawingNo = obj.getPropertyDisplayableValue("zt2_DrawingNo"); + if (isTyj(zt2_drawingNo, item)) { + tempModj = obj; + break; + } + } + if (tempModj == null) { + message.append("输入的通用件图号存在问题,请输入准确图号。"); + lastId = item_id; + code = "800"; + } else { + + KUtil.refreshAndGetProperties(tempModj, "object_name", "items_tag"); + Item items_tag = ((ItemRevision) tempModj).get_items_tag(); + KUtil.refreshAndGetProperties(items_tag, "revision_list"); + ModelObject[] revision_list = items_tag.get_revision_list(); + ItemRevision revision = (ItemRevision) revision_list[revision_list.length - 1]; + String object_nameN = tempModj.getPropertyDisplayableValue("object_name"); + Map userMap = new HashMap<>(); + // 原来查询 + userMap.put("用户 ID", userId); + ModelObject[] object2 = KUtil.query("Admin - Employee Information", userMap); + User user = (User) object2[0]; + KUtil.refreshAndGetProperties(user, "default_group"); + Group group = (Group) user.get_default_group(); + KUtil.log("执行saveAsItem:[start]"); + saveAsItem(revision, newID, object_nameN, group, user, zt2_Specifications); + message.append("PLM系统中无此通用件,请联系通用件管理员."); + List dsList = new ArrayList<>(); + // ItemRevision revision =(ItemRevision) tempModj; + KUtil.log("执行saveAsItem:[end:" + revision.getUid() + "]"); + // System.out.println("revision==>"+revision.getUid()); + KUtil.refreshAndGetProperties(revision, "IMAN_specification"); + ModelObject[] IMAN_specifications = revision.get_IMAN_specification(); + boolean hasSw = false; + boolean hastz = false; + ArrayList arrayList = KUtil.openBOMWindow(revision); + BOMLine bomLine = (BOMLine) arrayList.get(1); + KUtil.log("获取全部CORE文件[start]"); + for (ModelObject IMAN_specificatio : IMAN_specifications) { + if (IMAN_specificatio instanceof Dataset) { + Dataset ds = (Dataset) IMAN_specificatio; + KUtil.refreshAndGetProperties(ds, "object_type"); + String object_type = ds.get_object_type(); + KUtil.log("文件类型:" + object_type); + if (object_type.equals("ProPrt") || object_type.equals("ProAsm")) { + hasSw = true; + hastz = true; + dsList.add(ds); + if (object_type.equals("ProAsm")) { + // asm 文件BOM排除 + KUtil.refreshAndGetProperties(ds, "Pro2_bom_exclusion"); + ModelObject[] bom_exclusions = + ds.getPropertyObject("Pro2_bom_exclusion").getModelObjectArrayValue(); + if (bom_exclusions != null && bom_exclusions.length > 0) { + getBomExclusion(dsList, bom_exclusions); + } + } + } else if (object_type.equals("ProDrw")) { + hastz = true; + dsList.add(ds); + } + } + } + getAllDs(bomLine, dsList); + KUtil.closeBOMWindow((BOMWindow) arrayList.get(0)); + KUtil.log("获取全部CORE文件[end" + dsList.size() + "]"); + KUtil.log("遍历获取数据集"); + FileManagementUtility fmu = + new FileManagementUtility( + AppXSession.getConnection(), + null, + new String[] {loginInfo.getFmsUrl()}, + new String[] {loginInfo.getFmsUrl()}, + loginInfo.getFmstemp()); + List files = new ArrayList<>(); + // ModelObject[] zt2_cshRelations = + // designRev.getPropertyObject("ZT2_CSHRelation").getModelObjectArrayValue(); + for (Dataset ds : dsList) { + KUtil.refreshAndGetProperties( + ds, "ref_list", "ref_names", "object_name", "object_type"); + String object_type1 = ds.get_object_type(); + if (object_type1.equals("ProPrt") || object_type1.equals("ProAsm")) { + KUtil.refreshAndGetProperties(ds, "IPEM_master_dependency"); + ModelObject[] ipem_master_dependencies = + ds.getPropertyObject("IPEM_master_dependency").getModelObjectArrayValue(); + if (ipem_master_dependencies.length > 0) { + ItemRevision ipemTag = (ItemRevision) ipem_master_dependencies[0]; + KUtil.refreshAndGetProperties(ipemTag, "IMAN_specification"); + ModelObject[] IMAN_specifications2 = ipemTag.get_IMAN_specification(); + for (ModelObject IMAN_specificatio : IMAN_specifications2) { + if (IMAN_specificatio instanceof Dataset) { + Dataset dataset = (Dataset) IMAN_specificatio; + KUtil.refreshAndGetProperties(dataset, "object_type"); + String object_type = dataset.get_object_type(); + if (object_type.equals("ProPrt") + || object_type.equals("ProAsm") + || object_type.equals("ProDrw")) { + // dsList.add(ds); + ds = dataset; + KUtil.refreshAndGetProperties(ds, "ref_list", "ref_names", "object_name"); + break; + } + } + } + } + } + ModelObject[] ref_list = ds.get_ref_list(); + String object_name = ds.get_object_name(); + String[] ref_names = ds.get_ref_names(); + if (ref_list.length == 0 && !errFile.contains(object_name)) { + errFile.add(object_name); + if (object_name.contains(item_id)) { + code = "600"; + } else { + code = "700"; + } + } + KUtil.log("遍历获取ref_list:[ref_list.length" + ref_list.length + "]"); + // System.out.println(ref_list.length+"ref_list"); + for (int i = 0; i < ref_list.length; i++) { + if (!(ref_list[i] instanceof ImanFile) || ref_names[i].equals("MetaData")) { + // System.out.println("i==>"+i); + continue; + } + ImanFile file = (ImanFile) ref_list[i]; + KUtil.refreshAndGetProperties(file, "original_file_name", "file_size"); + String file_size = file.get_file_size(); + if (file_size == null || file_size.equals("0")) { + // System.out.println("i====>"+i); + continue; + } + if (files.contains(file)) { + // System.out.println("i======>"+i); + continue; + } + String original_file_name = file.getPropertyDisplayableValue("original_file_name"); + if (ref_names[i].equals("PrtFile") + || ref_names[i].equals("DrwFile") + || ref_names[i].equals("AsmFile")) { + downFile.add(original_file_name); + } + fileNames.add(original_file_name); + uids.add(file.getUid()); + files.add(file); + } + // .addAll(Arrays.asList(ref_list)); + } + if (dsList.size() == 0) { + code = "600"; + } + if (code.equals("600") && (files.size() == 0 || dsList.size() == 0)) { + message.append("PLM系统中此通用件无数据模型,请联系通用件管理员"); + } else if (code.equals("700") && files.size() == 0) { + message.append("PLM系统中通用件的数据模型数据异常,无法传递。请联系通用件管理员"); + } else if (!hasSw) { + code = "600"; + User owning_user = (User) revision.get_owning_user(); + KUtil.refreshAndGetProperties(owning_user, "user_name"); + String user_name = owning_user.get_user_name(); + if (!hastz) { + message.append("PLM系统中此通用件无数据模型,请联系通用件管理员"); + } else { + message.append("不存在三维图纸,user_id:").append(user_name); + } + } else { + message.append("存在三维图纸,图纸已打包"); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + code = "900"; + message.append(e.getMessage()); + } finally { + try { + // KUtil.setByPass(false); + } catch (Exception e) { + e.printStackTrace(); + } + } + ReturnBean res = + new ReturnBean( + downFile, + errFile, + message.toString(), + code, + userId, + zt2_Specifications, + lastId, + fileNames, + uids, + document, + objName); + ObjectMapper objectMapper = new ObjectMapper(); + String data = ""; + try { + data = objectMapper.writeValueAsString(res); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + KUtil.log("EndMsg:[data:" + data.toString() + "]"); + return data.toString(); + } + + public static List listBoms(BOMLine bomLine) { + // List bomLineNodes = list; + + // 预定义BOM父子对map及ItemRev map + List listBoms = new ArrayList<>(); + try { + com.teamcenter.services.strong.cad._2007_01.StructureManagement structureService = + com.teamcenter.services.strong.cad.StructureManagementService.getService( + AppXSession.getConnection()); + com.teamcenter.services.strong.cad._2007_01.StructureManagement.ExpandPSAllLevelsInfo + levelInfo = + new com.teamcenter.services.strong.cad._2007_01.StructureManagement + .ExpandPSAllLevelsInfo(); + com.teamcenter.services.strong.cad._2007_01.StructureManagement.ExpandPSAllLevelsPref + levelPref = + new com.teamcenter.services.strong.cad._2007_01.StructureManagement + .ExpandPSAllLevelsPref(); + levelInfo.parentBomLines = new BOMLine[] {bomLine}; // 输入顶层BOMLine对象 + levelInfo.excludeFilter = "None"; + levelPref.expItemRev = false; + levelPref.info = + new com.teamcenter.services.strong.cad._2007_01.StructureManagement.RelationAndTypesFilter + [0]; + // 使用以下方法展开完整的BOM行 + com.teamcenter.services.strong.cad._2007_01.StructureManagement.ExpandPSAllLevelsResponse + levelResp = structureService.expandPSAllLevels(levelInfo, levelPref); + if (levelResp.output.length > 0) { + // 将BOM构建成uid父子对关系 + for (StructureManagement.ExpandPSAllLevelsOutput data : levelResp.output) { + ItemRevision parentBomLine = (ItemRevision) data.parent.itemRevOfBOMLine; + listBoms.add(parentBomLine); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return listBoms; + } + + @GetMapping("/ParameterFileReturn") + public String getTemplate2(String item_id) { + AppXSession session = null; + StringBuilder message = new StringBuilder(""); + List downFile = new ArrayList<>(); + List errFile = new ArrayList<>(); + String code = "200"; + String lastId = ""; + // String url = ""; + String document = ""; + List fileNames = new ArrayList<>(); + List uids = new ArrayList<>(); + try { + // KUtil.setByPass(true); + Map fields1 = new HashMap<>(); + // 原来查询 + fields1.put("图样代号", item_id + "*"); + ModelObject[] designs = KUtil.query("参数化查询图纸", fields1); + + ItemRevision designRev = null; + for (ModelObject design : designs) { + // KUtil.refreshAndGetProperties(design,"zt2_DrawingNo"); + // String zt2_drawingNo = + // design.getPropertyDisplayableValue("zt2_DrawingNo"); + // if(isTyj(zt2_drawingNo,item_id)){ + designRev = (ItemRevision) design; + break; + // } + } + + System.out.println("designs.length:" + designs.length); + if (designRev != null) { + // ItemRevision designRev = (ItemRevision) designs[0]; + KUtil.refreshAndGetProperties(designRev, "items_tag", "ZT2_CSHRelation"); + Item item1 = designRev.get_items_tag(); + List dsList = new ArrayList<>(); + KUtil.refreshAndGetProperties( + item1, "revision_list", "item_id", "owning_user", "object_name"); + lastId = item1.get_item_id(); + ModelObject[] revision_list = item1.get_revision_list(); + ItemRevision revision = (ItemRevision) revision_list[revision_list.length - 1]; + KUtil.refreshAndGetProperties(revision, "IMAN_specification"); + ModelObject[] IMAN_specifications = revision.get_IMAN_specification(); + boolean hasSw = false; + boolean hastz = false; + ArrayList arrayList = KUtil.openBOMWindow(revision); + BOMLine bomLine = (BOMLine) arrayList.get(1); + for (ModelObject IMAN_specificatio : IMAN_specifications) { + if (IMAN_specificatio instanceof Dataset) { + Dataset ds = (Dataset) IMAN_specificatio; + KUtil.refreshAndGetProperties(ds, "object_type"); + String object_type = ds.get_object_type(); + System.out.println("文件类型:" + object_type); + if (object_type.equals("ProPrt") || object_type.equals("ProAsm")) { + hasSw = true; + hastz = true; + dsList.add(ds); + } else if (object_type.equals("ProDrw")) { + hastz = true; + dsList.add(ds); + } + } + } + List revisions = listBoms(bomLine); + System.out.println(revisions.size()); + getAllDs2(revisions, dsList); + KUtil.closeBOMWindow((BOMWindow) arrayList.get(0)); + System.out.println("遍历获取数据集"); + FileManagementUtility fmu = + new FileManagementUtility( + AppXSession.getConnection(), + null, + new String[] {loginInfo.getFmsUrl()}, + new String[] {loginInfo.getFmsUrl()}, + loginInfo.getFmstemp()); + List files = new ArrayList<>(); + ModelObject[] zt2_cshRelations = + designRev.getPropertyObject("ZT2_CSHRelation").getModelObjectArrayValue(); + for (Dataset ds : dsList) { + KUtil.refreshAndGetProperties(ds, "ref_list", "ref_names", "object_name"); + + ModelObject[] ref_list = ds.get_ref_list(); + String object_name = ds.get_object_name(); + String[] ref_names = ds.get_ref_names(); + if (ref_list.length == 0 && !errFile.contains(object_name)) { + errFile.add(object_name); + if (object_name.contains(item_id)) { + code = "600"; + } else { + code = "700"; + } + } + System.out.println(ref_list.length + "ref_list" + ds.getUid()); + for (int i = 0; i < ref_list.length; i++) { + if (!(ref_list[i] instanceof ImanFile) || ref_names[i].equals("MetaData")) { + System.out.println("i==>" + i); + continue; + } + ImanFile file = (ImanFile) ref_list[i]; + KUtil.refreshAndGetProperties(file, "original_file_name", "file_size"); + String file_size = file.get_file_size(); + if (file_size == null || file_size.equals("0")) { + System.out.println("i====>" + i); + continue; + } + if (files.contains(file)) { + System.out.println("i======>" + i); + continue; + } + String original_file_name = file.getPropertyDisplayableValue("original_file_name"); + if (ref_names[i].equals("PrtFile") + || ref_names[i].equals("DrwFile") + || ref_names[i].equals("AsmFile")) { + downFile.add(original_file_name); + } + fileNames.add(original_file_name); + uids.add(file.getUid()); + files.add(file); + } + // .addAll(Arrays.asList(ref_list)); + } + if (dsList.size() == 0) { + code = "600"; + } + if (code.equals("600") && files.size() == 0) { + message.append("PLM系统中此通用件无数据模型,请联系通用件管理员"); + } else if (code.equals("700")) { + message.append("PLM系统中通用件的数据模型数据异常,无法传递。请联系通用件管理员"); + } else if (!hasSw) { + code = "600"; + User owning_user = (User) item1.get_owning_user(); + KUtil.refreshAndGetProperties(owning_user, "user_name"); + String user_name = owning_user.get_user_name(); + if (!hastz) { + message.append("PLM系统中此通用件无数据模型,请联系通用件管理员"); + } else { + message.append("不存在三维图纸,user_id:").append(user_name); + } + } else { + message.append("存在三维图纸,图纸已打包"); + } + System.out.println(zt2_cshRelations.length + "zt2_cshRelations.length"); + if (zt2_cshRelations.length > 0 && (zt2_cshRelations[0] instanceof ItemRevision)) { + ItemRevision cshDocument = (ItemRevision) zt2_cshRelations[0]; + KUtil.refreshAndGetProperties(cshDocument, "IMAN_specification"); + ModelObject[] cshDataset = cshDocument.get_IMAN_specification(); + if (cshDataset.length > 0) { + Dataset ds = (Dataset) cshDataset[0]; + KUtil.refreshAndGetProperties(ds, "ref_list", "object_name"); + ModelObject[] ref_list = ds.get_ref_list(); + document = ds.get_object_name(); + if (ref_list.length > 0) { + ImanFile file = (ImanFile) ref_list[0]; + KUtil.refreshAndGetProperties(file, "original_file_name"); + String original_file_name = file.getPropertyDisplayableValue("original_file_name"); + fileNames.add(original_file_name); + uids.add(file.getUid()); + } + } + } + } else { + message.append("PLM系统中无此通用件,请联系通用件管理员"); + lastId = item_id; + code = "500"; + } + } catch (Exception e) { + code = "900"; + message.append(e.getMessage()); + e.printStackTrace(); + } finally { + try { + // KUtil.setByPass(false); + } catch (Exception e) { + e.printStackTrace(); + } + } + ReturnBean res = + new ReturnBean( + downFile, errFile, message.toString(), code, lastId, fileNames, uids, document); + ObjectMapper objectMapper = new ObjectMapper(); + String data = ""; + try { + data = objectMapper.writeValueAsString(res); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + return data.toString(); + } + + @GetMapping("/Test") + public String getTemplate22(String item_id, String item_id2) { + DataManagementService dmService = DataManagementService.getService(AppXSession.getConnection()); + try { + ModelObject modelObject = string_to_component(dmService, item_id); + ModelObject modelObject2 = string_to_component(dmService, item_id2); + saveAsItem((ItemRevision) modelObject2, "Test2023101904"); + } catch (Exception e) { + e.printStackTrace(); + } + // ServiceData sd = dmService.loadObjects(new String[]{item_id}); + // try { + // KUtil.throwServiceDataError(sd); + // } catch (Exception e) { + // e.printStackTrace(); + // } + // ModelObject[] foundObjs = new ModelObject[ sd.sizeOfPlainObjects()]; + return "11"; + } + + public static Item saveAsObjectsAndRelate( + Item items_tag, + String itemId, + String name, + Group group, + User userOwn, + String zt2_Specifications, + DataManagementService dmService, + ItemRevision rev) { + // DataManagementService service1 = + // DataManagementService.getService(AppXSession.getConnection()); + com.teamcenter.services.strong.core._2014_10.DataManagement.SaveAsIn[] saveAsIns = + new com.teamcenter.services.strong.core._2014_10.DataManagement.SaveAsIn[1]; + com.teamcenter.services.strong.core._2012_09.DataManagement.RelateInfoIn[] var2 = + new com.teamcenter.services.strong.core._2012_09.DataManagement.RelateInfoIn[1]; + saveAsIns[0] = new com.teamcenter.services.strong.core._2014_10.DataManagement.SaveAsIn(); + var2[0] = new com.teamcenter.services.strong.core._2012_09.DataManagement.RelateInfoIn(); + var2[0].relate = true; + System.out.println("items_tag===>" + items_tag.getUid()); + saveAsIns[0].targetObject = items_tag; + saveAsIns[0].inputPropValues.put("zt2_unit", new String[] {"ST"}); + saveAsIns[0].inputPropValues.put("item_id", new String[] {itemId}); + saveAsIns[0].inputPropValues.put("is_configuration_item", new String[] {"0"}); + // com.teamcenter.services.strong.core._2013_05.DataManagement. + // 获取深度复制规则 + // com.teamcenter.services.strong.core._2013_05.DataManagement.DeepCopyData + // com.teamcenter.services.strong.core._2014_10.DataManagement.DeepCopyDataInput[] + // deepCopyDataInput = new + // com.teamcenter.services.strong.core._2014_10.DataManagement.DeepCopyDataInput[1]; + // deepCopyDataInput[0] = new + // com.teamcenter.services.strong.core._2014_10.DataManagement.DeepCopyDataInput(); + // deepCopyDataInput[0].businessObject = items_tag; + // deepCopyDataInput[0].operation = "SaveAs"; + // com.teamcenter.services.strong.core._2014_10.DataManagement.GetDeepCopyDataResponse + // deepCopyResponse = + // dmService.getDeepCopyData(deepCopyDataInput); + // Map deepCopyInfoMap = + // deepCopyResponse.deepCopyInfoMap; + // ServiceData deepCopyServiceData = deepCopyResponse.serviceData; + // for(ModelObject modelObject:deepCopyInfoMap.keySet()){ + // System.out.println(modelObject.getUid()); + // System.out.println(deepCopyInfoMap.get(modelObject).length); + // for(com.teamcenter.services.strong.core._2014_10.DataManagement.DeepCopyData + // ds:deepCopyInfoMap.get(modelObject)){ + // System.out.println(ds.attachedObject.getUid()); + // } + // } + // System.out.println(111); + // TCServiceExceptionUtils.validateServiceException(deepCopyServiceData); + // 根据深度复制规则确定哪些对象需要另存 + // int plainObjNums = deepCopyServiceData.sizeOfPlainObjects(); + // List saveAsChildren = new ArrayList(); + // for (int i = 0; i < plainObjNums; i++) { + // if (!deepCopyServiceData.getPlainObject(i).equals(items_tag)) { + // saveAsChildren.add(deepCopyServiceData.getPlainObject(i)); + // } + // } + // 根据深度复制规则另存 + // com.teamcenter.services.strong.core._2014_10.DataManagement.SaveAsIn[] saveAsIns = new + // com.teamcenter.services.strong.core._2014_10.DataManagement.SaveAsIn[1]; + // saveAsIns[0] = new + // com.teamcenter.services.strong.core._2014_10.DataManagement.SaveAsIn(); + // saveAsIns[0].targetObject = baseFolder; + // saveAsIns[0].inputPropValues = new HashMap(); + // saveAsIns[0].inputPropValues.put("object_name", new String[] { newFolderName }); + try { + // System.out.println("saveAsChildren==>"+saveAsChildren.size()); + // saveAsIns[0].deepCopyDatas = new + // com.teamcenter.services.strong.core._2013_05.DataManagement.DeepCopyData[saveAsChildren.size()]; + // for (int j = 0; j < saveAsChildren.size(); j++) { + // saveAsIns[0].deepCopyDatas[j] = new + // com.teamcenter.services.strong.core._2013_05.DataManagement.DeepCopyData(); + // saveAsIns[0].deepCopyDatas[j].copyAction = "CopyAsObject"; + // saveAsIns[0].deepCopyDatas[j].copyRelations = true; + // saveAsIns[0].deepCopyDatas[j].isRequired = true; + // saveAsIns[0].deepCopyDatas[j].isTargetPrimary = true; + // saveAsIns[0].deepCopyDatas[j].propertyName = "contents"; + // saveAsIns[0].deepCopyDatas[j].propertyType = "Reference"; + // ModelObject modelObject = saveAsChildren.get(j); + // saveAsIns[0].deepCopyDatas[j].attachedObject = modelObject; + // saveAsIns[0].deepCopyDatas[j].operationInputs = new HashMap(); + // KUtil.refreshAndGetProperties(modelObject,"object_name"); + // saveAsIns[0].deepCopyDatas[j].operationInputs.put("object_name", + // new String[] { + // modelObject.getPropertyDisplayableValue("object_name") }); + // } + // dmService.getDeepCopyData() + // com.teamcenter.services.strong.core._2014_10.DataManagement.DeepCopyData[] + // deepCopyData = deepCopyInfoMap.get(items_tag); + KUtil.refreshAndGetProperties(items_tag, "IMAN_master_form", "bom_view_tags"); + ModelObject[] iman_master_form = items_tag.get_IMAN_master_form(); + ModelObject[] bom_view_tags = items_tag.get_bom_view_tags(); + com.teamcenter.services.strong.core._2013_05.DataManagement.DeepCopyData[] deepCopyDatas = + new com.teamcenter.services.strong.core._2013_05.DataManagement.DeepCopyData[3]; + deepCopyDatas[0] = + new com.teamcenter.services.strong.core._2013_05.DataManagement.DeepCopyData(); + deepCopyDatas[0].copyAction = "CopyAsObject"; + deepCopyDatas[0].copyRelations = true; + deepCopyDatas[0].isRequired = false; + deepCopyDatas[0].isTargetPrimary = true; + deepCopyDatas[0].operationInputTypeName = ""; + deepCopyDatas[0].propertyName = "IMAN_master_form"; + deepCopyDatas[0].propertyType = "Relation"; + deepCopyDatas[0].attachedObject = iman_master_form[0]; + + deepCopyDatas[1] = + new com.teamcenter.services.strong.core._2013_05.DataManagement.DeepCopyData(); + deepCopyDatas[1].copyAction = "SystemCopy"; + deepCopyDatas[1].copyRelations = true; + deepCopyDatas[1].isRequired = false; + deepCopyDatas[1].isTargetPrimary = true; + deepCopyDatas[1].operationInputTypeName = ""; + deepCopyDatas[1].propertyName = "bom_view_tags"; + deepCopyDatas[1].propertyType = "Reference"; + deepCopyDatas[1].attachedObject = bom_view_tags[0]; + + deepCopyDatas[2] = + new com.teamcenter.services.strong.core._2013_05.DataManagement.DeepCopyData(); + deepCopyDatas[2].copyAction = "CopyAsObject"; + deepCopyDatas[2].copyRelations = true; + deepCopyDatas[2].isRequired = false; + deepCopyDatas[2].isTargetPrimary = true; + deepCopyDatas[2].operationInputTypeName = ""; + deepCopyDatas[2].propertyName = "revision_list"; + deepCopyDatas[2].propertyType = "Reference"; + deepCopyDatas[2].attachedObject = rev; + // int sequence_id = rev.get_sequence_id(); + + saveAsIns[0].deepCopyDatas = deepCopyDatas; + // var1[0].deepCopyDatas + log("执行saveAsItem:[end1]"); + com.teamcenter.services.strong.core._2011_06.DataManagement.SaveAsObjectsResponse + saveAsObjectsResponse = dmService.saveAsObjectsAndRelate(saveAsIns, var2); + com.teamcenter.services.strong.core._2011_06.DataManagement.SaveAsOut[] output = + saveAsObjectsResponse.output; + + log("执行ChangeOwner:[Start]"); + + KUtil.throwServiceDataError(saveAsObjectsResponse.serviceData); + for (int i = 0; i < output.length; i++) { + ModelObject[] objects = output[i].objects; + for (ModelObject object : objects) { + KUtil.refreshAndGetProperties(object, "object_type"); + String object_type = object.getPropertyDisplayableValue("object_type"); + dmService.unloadObjects(new ModelObject[] {object}); + if (object_type.equals("ZT2_Design3D")) { + log("ObjectUid:[ObjectUid:" + object.getUid() + "]"); + Item createdObject = (Item) object; + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + public static ModelObject saveAsItem(ItemRevision rev, String num) throws Exception { + DataManagementService dMService = DataManagementService.getService(AppXSession.getConnection()); + com.teamcenter.services.strong.core._2008_06.DataManagement.SaveAsNewItemInfo info = + new com.teamcenter.services.strong.core._2008_06.DataManagement.SaveAsNewItemInfo(); + info.clientId = "saveAsItem"; + info.newItemId = num; + info.baseItemRevision = rev; + // info.deepCopyInfo = deepCopyDatas; + com.teamcenter.services.strong.core._2008_06.DataManagement.SaveAsNewItemResponse2 response = + dMService.saveAsNewItem2( + new com.teamcenter.services.strong.core._2008_06.DataManagement.SaveAsNewItemInfo[] { + info + }); + // KUtil.throwServiceDataError(response.serviceData); + Map + map = response.saveAsOutputMap; + if (map != null && map.size() > 0) { + for (Map.Entry< + String, + com.teamcenter.services.strong.core._2008_06.DataManagement.SaveAsNewItemOutput2> + entry : map.entrySet()) { + return entry.getValue().newItem; + } + } + throw new Exception("另存对象失败!"); + } + + public static Item saveAsItem( + ItemRevision rev, + String itemId, + String name, + Group group, + User userOwn, + String zt2_Specifications) { + + try { + DataManagementService dMService = + DataManagementService.getService(AppXSession.getConnection()); + com.teamcenter.services.strong.core._2008_06.DataManagement.SaveAsNewItemInfo info = + new com.teamcenter.services.strong.core._2008_06.DataManagement.SaveAsNewItemInfo(); + info.clientId = "saveAsItem"; + info.newItemId = itemId; + info.baseItemRevision = rev; + // info.deepCopyInfo = deepCopyDatas; + com.teamcenter.services.strong.core._2008_06.DataManagement.SaveAsNewItemResponse2 response = + dMService.saveAsNewItem2( + new com.teamcenter.services.strong.core._2008_06.DataManagement.SaveAsNewItemInfo[] { + info + }); + // KUtil.throwServiceDataError(response.serviceData); + Map + map = response.saveAsOutputMap; + if (map != null && map.size() > 0) { + for (Map.Entry< + String, + com.teamcenter.services.strong.core._2008_06.DataManagement.SaveAsNewItemOutput2> + entry : map.entrySet()) { + Item createdObject = entry.getValue().newItem; + log("执行saveAsItem:[end1]"); + log("执行ChangeOwner:[Start]"); + try { + KUtil.refreshAndGetProperties(createdObject, "revision_list", "bom_view_tags"); + DataManagementService dmService = + DataManagementService.getService(AppXSession.getConnection()); + ModelObject[] revisionList = createdObject.get_revision_list(); + KUtil.changeOwner(createdObject, userOwn, group, dmService); + ItemRevision revision = (ItemRevision) revisionList[0]; + KUtil.setProperty(revision, "zt2_Specifications", zt2_Specifications); + KUtil.refreshAndGetProperties(revision, "IMAN_specification"); + ModelObject[] iman_specification = revision.get_IMAN_specification(); + log("执行ChangeOwner:[End1]"); + log("执行删除关系:[Start]"); + for (ModelObject iman : iman_specification) { + com.teamcenter.services.strong.core._2006_03.DataManagement.Relationship[] rela_vec = + new com.teamcenter.services.strong.core._2006_03.DataManagement.Relationship[1]; + com.teamcenter.services.strong.core._2006_03.DataManagement.Relationship one_rela = + new com.teamcenter.services.strong.core._2006_03.DataManagement.Relationship(); + one_rela.clientId = "Connor"; + one_rela.primaryObject = revision; + one_rela.secondaryObject = iman; + one_rela.relationType = "IMAN_specification"; + one_rela.userData = null; + rela_vec[0] = one_rela; + ServiceData serviceData = dmService.deleteRelations(rela_vec); + KUtil.throwServiceDataError(serviceData); + } + KUtil.changeOwner(revision, userOwn, group, dmService); + ModelObject[] bom_view_tags = createdObject.get_bom_view_tags(); + if (bom_view_tags != null && bom_view_tags.length > 0) { + KUtil.changeOwner(bom_view_tags[0], userOwn, group, dmService); + } + log("执行删除关系:[End]"); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return createdObject; + } + } + // if(saveAsNewItem.serviceData.sizeOfCreatedObjects()>0){ + // Item createdObject = (Item) saveAsNewItem.serviceData.getCreatedObject(0); + // log("执行saveAsItem:[end1]"); + // log("执行ChangeOwner:[Start]"); + // try { + // KUtil.refreshAndGetProperties(createdObject, + // "revision_list","bom_view_tags"); + // DataManagementService dmService = DataManagementService + // .getService(AppXSession.getConnection()); + // ModelObject[] revisionList = createdObject.get_revision_list(); + // KUtil.changeOwner(createdObject,userOwn,group,dmService); + // ItemRevision revision = (ItemRevision) revisionList[0]; + // KUtil.setProperty(revision,"zt2_Specifications",zt2_Specifications); + // KUtil.refreshAndGetProperties(revision,"IMAN_specification"); + // ModelObject[] iman_specification = revision.get_IMAN_specification(); + // log("执行ChangeOwner:[End1]"); + // log("执行删除关系:[Start]"); + // for(ModelObject iman:iman_specification){ + // + // com.teamcenter.services.strong.core._2006_03.DataManagement.Relationship[] + // rela_vec = new + // com.teamcenter.services.strong.core._2006_03.DataManagement.Relationship[1]; + // + // com.teamcenter.services.strong.core._2006_03.DataManagement.Relationship + // one_rela = new + // com.teamcenter.services.strong.core._2006_03.DataManagement.Relationship(); + // one_rela.clientId = "Connor"; + // one_rela.primaryObject = revision; + // one_rela.secondaryObject = iman; + // one_rela.relationType = "IMAN_specification"; + // one_rela.userData = null; + // rela_vec[0] = one_rela; + // ServiceData serviceData = dmService.deleteRelations(rela_vec); + // KUtil.throwServiceDataError(serviceData); + // } + // KUtil.changeOwner(revision,userOwn,group,dmService); + // ModelObject[] bom_view_tags = createdObject.get_bom_view_tags(); + // if(bom_view_tags!=null && bom_view_tags.length>0) { + // KUtil.changeOwner(bom_view_tags[0],userOwn,group,dmService); + // } + // log("执行删除关系:[End]"); + // } catch (Exception e) { + // // TODO Auto-generated catch block + // e.printStackTrace(); + // } + //// System.out.println("createdObject"+createdObject); + // return createdObject; + // } + + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + public static String executeCmdCommand(String cmdCommand) { + StringBuilder stringBuilder = new StringBuilder(); + Process process = null; + try { + process = Runtime.getRuntime().exec(cmdCommand); + BufferedReader bufferedReader = + new BufferedReader(new InputStreamReader(process.getInputStream(), "GBK")); + String line = null; + while ((line = bufferedReader.readLine()) != null) { + System.out.println(line); + } + return stringBuilder.toString(); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + @PostMapping("/updateMaterial") + public JsonResult updateMantr(@RequestBody JSONObject jSONObject) { + + new Thread( + new Runnable() { + @Override + public void run() { + try { + // System.out.println(jSONObject.toJSONString()); + SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd-HHmmssSSS"); + String txtPath = "D:\\" + format2.format(new Date()) + ".txt"; + FileOutputStream out = new FileOutputStream(txtPath); + OutputStreamWriter outWriter = new OutputStreamWriter(out, "UTF-8"); + BufferedWriter bufWrite = new BufferedWriter(outWriter); + bufWrite.write(jSONObject.toJSONString()); + bufWrite.close(); + outWriter.close(); + out.close(); + String cmd = "D:\\updateMantr.bat " + txtPath; + String s = executeCmdCommand(cmd); + System.out.println(s); + new File(txtPath).delete(); + KUtil.logMsg(jSONObject.toJSONString()); + } catch (Exception e) { + e.printStackTrace(); + } + } + }) + .start(); + + JsonResult jsonResult = new JsonResult("接收成功", 200); + return jsonResult; + } + + @RequestMapping( + value = "/getFile", + method = {RequestMethod.GET, RequestMethod.POST}) + public ResponseEntity getFile(@RequestParam String id) throws Exception { + log(">> 开始执行:获取TC中物理文件"); + log("id = " + id); + // Session session = new Session(config.getTc_url()); + // User user = session.login2(config.getTc_user(), config.getTc_pwd()); + // if (user == null) { + // throw new Exception("Teamcenter SOA登录失败"); + // } + String tempFolder = getFMSTempFolder(System.getenv("temp"), id); + log("临时文件夹:" + tempFolder); + DataManagementService dataManagementService = + DataManagementService.getService(AppXSession.getConnection()); + + ModelObject obj = string_to_component(dataManagementService, id); + if (obj == null) { + throw new Exception("通过UID = " + id + "未查询到数据集"); + } + if (!(obj instanceof Dataset)) { + throw new Exception("UID = " + id + " 不是数据集对象"); + } + List dsFiles = + getDatasetFile((Dataset) obj, dataManagementService, loginInfo.getFmsUrl(), tempFolder); + log(("从数据集共找到" + dsFiles.size() + "个文件")); + if (dsFiles.size() == 0) { + throw new Exception("数据集中不存在引用文件"); + } + return export(dsFiles.get(0)); + } + + 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 ModelObject string_to_component( + DataManagementService dataManagementService, String id) throws Exception { + if (id == null || "".equals(id.trim())) { + return null; + } + System.out.println("开始获取TC对象"); + ServiceData resp = dataManagementService.loadObjects(new String[] {id}); + throwServiceDataError(resp); + if (resp.sizeOfPlainObjects() > 0) { + return resp.getPlainObject(0); + } + return null; + } + /** + * 从数据集获取文件 + * + * @param dataset + * @param dataManagementService + * @param fmsUrl + * @param tempFolder + * @return + * @throws Exception + */ + public static List getDatasetFile( + Dataset dataset, + DataManagementService dataManagementService, + String fmsUrl, + String tempFolder) + throws Exception { + List res = new ArrayList<>(); + dataManagementService.refreshObjects(new ModelObject[] {dataset}); + dataManagementService.getProperties( + new ModelObject[] {dataset}, new String[] {"object_name", "ref_list"}); + log("下载数据集文件:" + dataset.get_object_name()); + ModelObject[] refs = dataset.get_ref_list(); + if (refs == null) { + return res; + } + int len = refs.length; + log("引用个数:" + len); + if (len == 0) { + return res; + } + String cacheDir = tempFolder; // config.getFms_cachedir() + "\\" + uid; + log("cacheDir:" + cacheDir); + File dir = new File(cacheDir); + /*if(dir.exists()) + { + log("存在"); + }else + { + log("不存在"); + boolean flag = dir.mkdirs(); + if (!flag) { + throw new Exception("创建文件夹失败:" + cacheDir); + }else{ + log("创建成功"); + + } + log("flag:"+flag); + }*/ + if (!dir.isDirectory()) { + log("创建文件夹"); + boolean flag = dir.mkdirs(); + log("flag:" + flag); + if (!flag) { + throw new Exception("创建文件夹失败:" + cacheDir); + } + + log("flag:" + flag); + } + String[] fmsUrls = new String[] {fmsUrl}; + FileManagementUtility fileManagementUtility = + new FileManagementUtility(AppXSession.getConnection(), null, null, fmsUrls, cacheDir); + dataManagementService.refreshObjects(refs); + for (int i = 0; i < len; i++) { + log("开始遍历"); + if (refs[i] instanceof ImanFile) { + ImanFile imanFile = (ImanFile) refs[i]; + dataManagementService.getProperties( + new ModelObject[] {imanFile}, new String[] {"original_file_name"}); + log("找到文件:" + imanFile.get_original_file_name()); + GetFileResponse resp = fileManagementUtility.getFiles(new ModelObject[] {imanFile}); + throwServiceDataError(resp); + File[] files = resp.getFiles(); + for (int f = 0; f < files.length; f++) { + File targetFile = getFilePath(cacheDir, imanFile.get_original_file_name()); + if (files[f].renameTo(targetFile)) { + log("添加文件:" + targetFile.getAbsolutePath()); + res.add(targetFile); + } else { + throw new Exception( + "重命名文件 " + + files[f].getAbsolutePath() + + " -> " + + targetFile.getAbsolutePath() + + " 失败"); + } + } + } + } + return res; + } + /** + * 获取不重复文件名的文件 + * + * @param dir + * @param fileName + * @return + */ + private static File getFilePath(String dir, String fileName) { + int ind = fileName.lastIndexOf('.'); + String name = fileName; + String ext = ""; + if (ind > 0) { + name = fileName.substring(0, ind); + ext = fileName.substring(ind + 1); + } + String path = dir + "\\" + fileName; + File file = new File(path); + int index = 0; + while (file.exists()) { + if (!"".equals(ext)) { + path = dir + "\\" + name + "(" + (index++) + ")." + ext; + } else { + path = dir + "\\" + name + "(" + (index++) + ")"; + } + file = new File(path); + } + return file; + } + + public static void throwServiceDataError(GetFileResponse 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 ResponseEntity export(File file) { + if (file == null) { + return null; + } + String fileName = file.getName(); + log("返回文件名称:" + fileName); + try { + // fileName = URLEncoder.encode(file.getName(),"UTF-8"); + fileName = new String(fileName.getBytes("UTF-8"), "iso-8859-1"); + } catch (Exception e) { + e.printStackTrace(); + } + HttpHeaders headers = new HttpHeaders(); + headers.add("Cache-Control", "no-cache, no-store, must-revalidate"); + headers.add("Content-Disposition", "attachment; filename=" + fileName); + headers.add("Pragma", "no-cache"); + headers.add("Expires", "0"); + headers.add("Last-Modified", new Date().toString()); + headers.add("ETag", String.valueOf(System.currentTimeMillis())); + return ResponseEntity.ok() + .headers(headers) + .contentLength(file.length()) + .contentType(MediaType.parseMediaType("application/octet-stream")) + .body(new FileSystemResource(file)); + } + + private void getDesignByFactoryNo(String factoryNo, List exportFiles) { + try { + // 数据管理服务 + DataManagementService dataManagementService = + DataManagementService.getService(AppXSession.getConnection()); + if (factoryNo != null && !"".equals(factoryNo)) { + // 查询模型对象 + KUtil.log(logger, "查询模型对象,by chint_query_FactoryNo [fid=" + factoryNo + "{}]", factoryNo); + Map fields = new HashMap<>(); + fields.put("fid", factoryNo); + ModelObject[] modelObjects = KUtil.query("chint_query_FactoryNo", fields); + if (modelObjects != null && modelObjects.length > 0) { + // 模型对象 + ModelObject mo = modelObjects[0]; + KUtil.log(logger, "找到模型对象,uid={}", mo.getUid()); + // logger.warn("找到模型对象,uid={}", mo.getUid()); + Item part_revision = (Item) mo; + ModelObject[] objects = new ModelObject[] {part_revision}; + // 刷新对象(设置属性) + dataManagementService.refreshObjects(objects); + // 图纸模型版本 + List designRevisionObjects = new ArrayList<>(); + List designRevisionObjects01 = + RelationUtils.getDesignRevisionByFactoryNo(dataManagementService, part_revision); + List projectItemObjects = + RelationUtils.getItemByFactoryNo(dataManagementService, part_revision); + List designRevisionObjects02 = + RelationUtils.getDesignRevisionByItems(dataManagementService, projectItemObjects); + designRevisionObjects.addAll(designRevisionObjects01); + designRevisionObjects.addAll(designRevisionObjects02); + if (!designRevisionObjects.isEmpty()) { + for (WorkspaceObject referencedObject : designRevisionObjects) { + ItemRevision revision = (ItemRevision) referencedObject; + dataManagementService.getProperties( + new ModelObject[] {revision}, new String[] {"items_tag"}); + Item item2 = revision.get_items_tag(); + dataManagementService.getProperties( + new ModelObject[] {item2}, new String[] {"item_id"}); + KUtil.log(logger, "ZT2_Design3DRevision uid: {}", revision.getUid()); + dataManagementService.getProperties( + new ModelObject[] {revision}, + new String[] {"object_desc", "IMAN_specification", "TC_Attaches"}); + String object_desc = revision.getPropertyDisplayableValue("object_desc"); + KUtil.log(logger, "object_desc: {}", object_desc); + ModelObject[] specs = revision.get_IMAN_specification(); + ModelObject[] attaches = revision.get_TC_Attaches(); + dataManagementService.refreshObjects(specs); + dataManagementService.getProperties(specs, new String[] {"object_type"}); + dataManagementService.refreshObjects(attaches); + dataManagementService.getProperties(attaches, new String[] {"object_type"}); + for (int k = 0; k < specs.length; k++) { + if (specs[k] instanceof Dataset) { + Dataset dataset = (Dataset) specs[k]; + log("数据集类型:" + dataset.get_object_type()); + if (dataset.get_object_type().equals("PDF")) { + String fileName = KUtil.getDatasetName(dataset, dataManagementService); + if (fileName != null && !"".equals(fileName)) { + exportFiles.add(new FileInfoBean(dataset.getUid(), fileName)); + KUtil.log(logger, "uid: {}, name: {}", dataset.getUid(), fileName); + } + } + } + } + for (int k = 0; k < attaches.length; k++) { + if (attaches[k] instanceof Dataset) { + Dataset dataset = (Dataset) attaches[k]; + log("数据集类型:" + dataset.get_object_type()); + if (dataset.get_object_type().equals("PDF")) { + String fileName = KUtil.getDatasetName(dataset, dataManagementService); + if (fileName != null && !"".equals(fileName)) { + exportFiles.add(new FileInfoBean(dataset.getUid(), fileName)); + KUtil.log(logger, "uid: {}, name: {}", dataset.getUid(), fileName); + } + } + } + } + } + } + } + } + } catch (Exception e) { + logger.error("查询图纸列表异常", e); + } + } + // @GetMapping("/getDesign") + @RequestMapping( + value = "/getDesign", + method = {RequestMethod.GET, RequestMethod.POST}) + public String getDesign(String item, String wbsno, String factoryNo) throws Exception { + // Session session = new Session(config.getTc_url()); + List exportFiles = new ArrayList<>(); + String desc_String = ""; + try { + // User user = session.login2(config.getTc_user(), config.getTc_pwd()); + // KUtil.setByPass(true); + DataManagementService dataManagementService = + DataManagementService.getService(AppXSession.getConnection()); + log("item:" + item); + log("WBS No:" + wbsno); + log("WBS No:" + factoryNo); + // 按出厂编号查询 add by 20220916 + if (factoryNo != null && !"".equals(factoryNo)) { + getDesignByFactoryNo(factoryNo, exportFiles); + DesignInfoBean res = new DesignInfoBean(exportFiles, desc_String); + ObjectMapper objectMapper = new ObjectMapper(); + String data = objectMapper.writeValueAsString(res); + // KUtil.setByPass(false); + log("返回数据:" + data + "\n"); + // session.logout(); + return data; + } + if (item == null || "".equals(item)) { + return "请输入物料号"; + } + Map fields = new HashMap<>(); + // 原来查询 + fields.put("materialno", item + "*"); + ModelObject[] object; + if (wbsno == null || "".equals(wbsno)) { + object = KUtil.query("chint_query_material", fields); + // object =queryItems("chint_query_material",new String[]{"materialno"},new String[]{item}); + if (object == null || object.length == 0) { + log("仅使用物料号进行查询未找到对象"); + throw new Exception("找不到物料"); + } + } else { + fields.put("WBS号", wbsno); + object = KUtil.query("chint_query_material", fields); + if (object == null || object.length == 0) { + log("使用物料号和WBS号进行查询未找到对象"); + fields.remove("WBS号"); + object = KUtil.query("chint_query_material", fields); + if (object == null || object.length == 0) { + log("第二次仅使用物料号进行查询未找到对象"); + throw new Exception("找不到物料"); + } + } + } + Part_Revision part_revision = (Part_Revision) object[0]; + ModelObject[] objects = new ModelObject[] {part_revision}; + dataManagementService.refreshObjects(objects); + dataManagementService.getProperties(objects, new String[] {"TC_Is_Represented_By"}); + ModelObject[] reps = part_revision.get_TC_Is_Represented_By(); + dataManagementService.refreshObjects(reps); + // dataManagementService.getProperties(reps,new + // String[]{"object_type","IMAN_specification","TC_Attaches"}); + dataManagementService.getProperties(reps, new String[] {"object_type"}); + log("图纸文件夹下对象数量:" + reps.length); + Map> item_revs = new HashMap<>(); + for (int i = 0; i < reps.length; i++) { + if (reps[i] instanceof ItemRevision) { + ItemRevision revision = (ItemRevision) reps[i]; + if (revision.get_object_type().equals("ZT2_Design3DRevision")) { + dataManagementService.getProperties( + new ModelObject[] {revision}, new String[] {"items_tag"}); + Item item2 = revision.get_items_tag(); + dataManagementService.getProperties( + new ModelObject[] {item2}, new String[] {"item_id"}); + + String item_id = item2.get_item_id(); + + // log("图纸ID:"+item_id); + if (item_revs.containsKey(item2)) { + item_revs.get(item2).add(revision); + } else { + List revs = new ArrayList<>(); + revs.add(revision); + item_revs.put(item2, revs); + } + } + } + } + + List revs = new ArrayList<>(); + Iterator>> iterator = item_revs.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry> it = iterator.next(); + List it_revs = it.getValue(); + if (it_revs.size() == 1) { + revs.add(it_revs.get(0)); + continue; + } + if (it_revs.size() < 1) { + continue; + } + ModelObject max_Rev = null; + String s = ""; + ; + int index = -1; + for (ModelObject it_rev : it_revs) { + dataManagementService.refreshObjects(new ModelObject[]{it_rev}); + dataManagementService.getProperties( + new ModelObject[]{it_rev}, new String[]{"release_status_list"}); + if (((ItemRevision) it_rev).get_release_status_list().length == 0) { + continue; + } + dataManagementService.getProperties( + new ModelObject[]{it_rev}, new String[]{"item_revision_id"}); + + String item_id = ((ItemRevision) it_rev).get_item_revision_id(); + if (s.isEmpty()) { + s = item_id; + max_Rev = it_rev; + for (int k = 0; k < s.length(); k++) { + if (s.charAt(k) >= '0' && s.charAt(k) <= '9') { + index = k; + break; + } + } + } else { + String temp = item_id; + if (index != -1) { + if (temp.substring(0, index).compareTo(s.substring(0, index)) > 0) { + s = temp; + max_Rev = it_rev; + } else if (temp.substring(0, index).compareTo(s.substring(0, index)) == 0) { + String s1 = s.substring(index); + String temp1 = temp.substring(index); + int min = Math.min(s1.length(), temp1.length()); + for (int k = 0; k < min; k++) { + if (temp1.charAt(k) > s1.charAt(k)) { + s = temp; + max_Rev = it_rev; + break; + } + } + + if (temp1.length() > min) { + s = temp; + max_Rev = it_rev; + } + } + } else if (temp.compareTo(s) > 0) { + s = temp; + max_Rev = it_rev; + } + } + } + log("加入:" + s); + + if (max_Rev != null) { + revs.add(max_Rev); + } + } + + if (revs.size() == 0) { + dataManagementService.refreshObjects(objects); + dataManagementService.getProperties( + objects, new String[] {"object_desc", "IMAN_specification", "TC_Attaches"}); + desc_String = part_revision.getPropertyDisplayableValue("object_desc"); + // log("第"+(i+1)+"个,object_desc:"+desc_String); + ModelObject[] specs = part_revision.get_IMAN_specification(); + ModelObject[] attaches = part_revision.get_TC_Attaches(); + dataManagementService.refreshObjects(specs); + dataManagementService.getProperties(specs, new String[] {"object_type"}); + dataManagementService.refreshObjects(attaches); + dataManagementService.getProperties(attaches, new String[] {"object_type"}); + // log("规范关系数据集个数:"+specs.length); + // log("附加关系数据集个数:"+attaches.length); + for (ModelObject spec : specs) { + // log("j------"+j); + // log("数据集类型:"+specs[j].toString()); + if (spec instanceof Dataset) { + Dataset dataset = (Dataset) spec; + log("数据集类型:" + dataset.get_object_type()); + if (dataset.get_object_type().equals("PDF")) { + String fileName = KUtil.getDatasetName(dataset, dataManagementService); + if (fileName != null && !"".equals(fileName)) { + exportFiles.add(new FileInfoBean(dataset.getUid(), fileName)); + } + } + } + } + for (ModelObject attach : attaches) { + if (attach instanceof Dataset) { + Dataset dataset = (Dataset) attach; + log("数据集类型:" + dataset.get_object_type()); + if (dataset.get_object_type().equals("PDF")) { + String fileName = KUtil.getDatasetName(dataset, dataManagementService); + if (fileName != null && !"".equals(fileName)) { + exportFiles.add(new FileInfoBean(dataset.getUid(), fileName)); + } + } + } + } + } else { + // for(int i=0;i" + KUtil.getStackTrace(e)); + } finally { + if(fileOutputStream != null){ + try{ + fileOutputStream.close(); + }catch (Exception e) { + e.printStackTrace(); + } + } + } + return data; + } +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/controller/GetDesignController.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/controller/GetDesignController.java new file mode 100644 index 0000000..1a4c7ea --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/controller/GetDesignController.java @@ -0,0 +1,927 @@ +package com.connor.connor_cpzc_service.controller; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.chint.plm.tcclient.SessionContext; +import com.chint.plm.tcclient.helper.ItemHelper; +import com.chint.plm.tcclient.helper.ServiceHelper; +import com.connor.connor_cpzc_service.bean.ECNBean; +import com.connor.connor_cpzc_service.bean.ECNBeanReturn; +import com.connor.connor_cpzc_service.bean.MdmDs.DesignBean; +import com.connor.connor_cpzc_service.bean.MdmDs.FileBean; +import com.connor.connor_cpzc_service.bean.MdmDs.MomRuleBean; +import com.connor.connor_cpzc_service.bean.SapResult; +import com.connor.connor_cpzc_service.bean.SapReturn; +import com.connor.connor_cpzc_service.info.LoginInfo; +import com.connor.connor_cpzc_service.mapper.EPMMapper; +import com.connor.connor_cpzc_service.service.BomResultService; +import com.connor.connor_cpzc_service.util.JsonResult; +import com.connor.connor_cpzc_service.util.KUtil; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.teamcenter.clientx.AppXSession; +import com.teamcenter.services.strong.cad.StructureManagementService; +import com.teamcenter.services.strong.cad._2007_01.StructureManagement; +import com.teamcenter.services.strong.core.DataManagementService; +import com.teamcenter.services.strong.core._2007_01.DataManagement; +import com.teamcenter.services.strong.workflow.WorkflowService; +import com.teamcenter.soa.client.Connection; +import com.teamcenter.soa.client.FileManagementUtility; +import com.teamcenter.soa.client.model.ModelObject; +import com.teamcenter.soa.client.model.Property; +import com.teamcenter.soa.client.model.ServiceData; +import com.teamcenter.soa.client.model.strong.*; +import org.apache.http.HttpRequest; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.*; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.regex.Pattern; + +@RestController +@RequestMapping(value = "/plm") +public class GetDesignController { + @Autowired EPMMapper mapper; + + @Autowired BomResultService service; +// private static final org.apache.log4j.Logger logger = +// org.apache.log4j.Logger.getLogger(GetDesignController.class); + @Autowired protected LoginInfo loginInfo; + + @PostMapping("/getBOMResult") + public String getBOMResult(@RequestBody SapReturn sapReturn) { + JSONObject result = new JSONObject(); + new Thread( + new Runnable() { + @Override + public void run() { + try { + ObjectMapper objectMapper = new ObjectMapper(); + String data = objectMapper.writeValueAsString(sapReturn); + KUtil.log("START: getBOMResult01 解析SAP回传信息 ====> " + data); + List result1 = sapReturn.getResult(); + service.saveSapResult(result1); + KUtil.log("End: 解析完成"); + } catch (Exception e) { + e.printStackTrace(); + } + } + }) + .start(); + try { + result.put("code", "S"); + result.put("msg", "成功接收"); + } catch (Exception e) { + e.printStackTrace(); + } + return result.toString(); + } + // MDM获取TC图纸 + + + /** + * 根据版本打开BOM + * + * @param parentItemRev BOM顶层版本 + * @param conn + * @return 返回信息 0 BOMWindow 1 BOMLine + */ + public ArrayList openBOMWindow(ItemRevision parentItemRev, Connection conn) { + + ArrayList bomWindowandParentLine = new ArrayList<>(); + com.teamcenter.services.strong.cad._2007_01.StructureManagement.CreateBOMWindowsInfo[] createBOMWindowsInfo = new com.teamcenter.services.strong.cad._2007_01.StructureManagement.CreateBOMWindowsInfo[1]; + + + createBOMWindowsInfo[0] = new com.teamcenter.services.strong.cad._2007_01.StructureManagement.CreateBOMWindowsInfo(); + createBOMWindowsInfo[0].itemRev = parentItemRev; + com.teamcenter.services.strong.cad.StructureManagementService cadSMService = + com.teamcenter.services.strong.cad.StructureManagementService + .getService(conn); + + com.teamcenter.services.strong.cad._2007_01.StructureManagement.CreateBOMWindowsResponse createBOMWindowsResponse = + cadSMService.createBOMWindows(createBOMWindowsInfo); +// cadSMService. +// cadSMService.d + if (createBOMWindowsResponse.serviceData.sizeOfPartialErrors() > 0) { + for (int i = 0; i < createBOMWindowsResponse.serviceData + .sizeOfPartialErrors(); i++) { + + System.out.println("Partial Error in Open BOMWindow = " + createBOMWindowsResponse.serviceData + .getPartialError(i).getMessages()[0]); + } + } + + bomWindowandParentLine.add(createBOMWindowsResponse.output[0].bomWindow);//BOMWindow + BOMLine bomLine = createBOMWindowsResponse.output[0].bomLine; + bomWindowandParentLine.add(bomLine); + return bomWindowandParentLine; + } + + + + + + + + + @Value("${tc.server}") + private String host; + + @Value("${tc.user}") + private String username; + + @Value("${tc.password}") + private String password; + + + @PostMapping("/getDesignlist") + public String getDesignList(@RequestBody JSONObject designJson ) { + // logger. + // + + + KUtil.log("getDesignList MDM入参:" + designJson.toJSONString()); +// SessionContext session = new SessionContext(host, username, password); + + Connection conn = AppXSession.getConnection(); +// DataManagementService dataManagementService = ServiceHelper.getDataManagementService(); + DataManagementService dataManagementService = DataManagementService.getService(conn); + String wbsNo = designJson.getString("wbsno"); // WBS号 + String materialNo = designJson.getString("materialno"); // 生产订单的物料编码 + JSONArray processList = designJson.getJSONArray("processlist"); // 一级工序编码清单 + + String factory = designJson.getString("factory"); // 工厂 + String factoryno = designJson.getString("factoryno"); // 出厂编号 + System.out.println("factory==="+factory+"factoryno==="+factoryno); + List psmCodes = new ArrayList<>(); // 记录一级工序编码 + for (int i = 0; i < processList.size(); i++) { + psmCodes.add(processList.getJSONObject(i).getString("process")); + } + // 查询图纸,物料分为产成品和非产成品 + // 查询 chint_search_material_mom 先带WBS 再不带WBS查 + Map searchMap = new HashMap<>(); + searchMap.put("WBS号", wbsNo); + searchMap.put("materialno", materialNo); + String errMsg = ""; + try { + + ItemRevision designRev = null; + Map referencedObjectMap = new HashMap<>(); + String projectCode = ""; // 工程图号 + if(factoryno != null && !factoryno.isEmpty()){ + Map searchCCBHMap = new HashMap<>(); + searchCCBHMap.put("fid", factoryno); + ModelObject[] ccbh = KUtil.query("chint_query_FactoryNo", searchCCBHMap);//查询出场编号 + + + System.out.println("ccbh。size============="+ccbh.length); + if(ccbh.length > 0){ + List referencedInfos = ItemHelper.getWhereReferencedInfos(dataManagementService, (Item)ccbh[0]); + if (!referencedInfos.isEmpty()) { + for (DataManagement.WhereReferencedInfo referencedInfo : referencedInfos) { + WorkspaceObject referencedObject = referencedInfo.referencer; + if (referencedObject != null) { + dataManagementService.getProperties( + new ModelObject[]{referencedObject}, + new String[]{"object_type", "object_name","item_id"}); + String type = referencedObject.get_object_type(); + String name = referencedObject.get_object_name(); + System.out.println("type==="+type+"name==="+name); + if(type.equals("ZT2_Design3DRevision")){ + referencedObjectMap.put(name,referencedObject); + } + + + } + } + + System.out.println("referencedObjectMap========="+referencedObjectMap.toString()); + if(referencedObjectMap.size() > 1){ + for (Map.Entry map :referencedObjectMap.entrySet() + ) { + if(map.getKey().contains("总装") || map.getKey().contains("变压器")){ + designRev = (ItemRevision) map.getValue(); + break; + } + } + }else if(referencedObjectMap.size() == 1){ + for (Map.Entry map :referencedObjectMap.entrySet() + ) { + + designRev = (ItemRevision) map.getValue(); + break; + } + } + } + + if(designRev != null){ + // 获取属性 + //dataManagementService.getProperties(new ModelObject[]{designRev}, new String[]{"item_id"}); + // KUtil.refreshAndGetProperties(designRev, "item_id"); + String item_id = designRev.get_item_id(); + projectCode = item_id.split("-")[1]; + System.out.println("projectCode========"+projectCode); + } + + } + } + + + ItemRevision material = null; + if(projectCode == null || projectCode.isEmpty()) { + + ModelObject[] designs = KUtil.query("chint_query_material_test", searchMap); // 查询物料 + + if (designs.length == 0) { + // 再不带wbs查询 并且判断多个物料且存在不同的wbs + searchMap.clear(); + searchMap.put("materialno", materialNo); + designs = KUtil.query("chint_query_material_test", searchMap); + if (designs.length == 0) { + errMsg = "查询不到物料,请输入准确的物料编码."; + return JSONObject.toJSONString(JsonResult.error(errMsg)); +// } else if (designs.length == 1) { +// material = (ItemRevision) designs[0]; + } else { + material = (ItemRevision) designs[0]; + /*List wbsList = new ArrayList<>(); + for (ModelObject design : designs) { + KUtil.refreshAndGetProperties(design, "zt2_WBSNo"); + String ztWbsNo = design.getPropertyObject("zt2_WBSNo").getStringValue(); + if (wbsList.contains(ztWbsNo)) { + errMsg = "找到多个物料且存在不同的wbs,请输入准确的数据信息."; + } else { + wbsList.add(ztWbsNo); + } + } + if (errMsg.equals("")) { + material = (ItemRevision) designs[0]; + } else { + KUtil.log("getDesignList TC回传:找到多个物料且存在不同的wbs"); + return JSONObject.toJSONString(JsonResult.error(errMsg)); + }*/ + } + } else { + material = (ItemRevision) designs[0]; + } + + } + // 找到物料后判断是不是产成品 获取图纸找到工程图号 + if (material != null || (projectCode != null && !projectCode.isEmpty())) { + String coreCode = ""; // 线圈id + if(material != null) { + + KUtil.refreshAndGetProperties( + material, "object_name", "TC_Is_Represented_By", "object_desc","ZT2_FactoryNumber"); + String objectName = material.get_object_name(); + System.out.println(objectName); + if (objectName.contains("变压器")) { + // 获取产成品关联的图纸 + ModelObject[] designRevs = + material.getPropertyObject("TC_Is_Represented_By").getModelObjectArrayValue(); + if (designRevs.length > 0) { + designRev = (ItemRevision) designRevs[0]; + KUtil.refreshAndGetProperties(designRev, "item_id"); + String item_id = designRev.get_item_id(); + projectCode = item_id.split("-")[1]; + }else{//如果没有图纸 20240820 + Map searchMap1 = new HashMap<>(); + //获取出产编号 + String ccbh = ""; + String[] CHINT_Search_Drawing_ID = KUtil.GetPrefValues("CHINT_Search_Drawing_ID"); + System.out.println("CHINT_Search_Drawing_ID====================="+CHINT_Search_Drawing_ID.length); + //dataManagementService.getProperties(new ModelObject[]{material}, new String[]{"ZT2_FactoryNumber"}); + Property zt2_factoryNumber = material.getPropertyObject("ZT2_FactoryNumber"); + ModelObject[] modelObjectArrayValue = zt2_factoryNumber.getModelObjectArrayValue(); + System.out.println("modelObjectArrayValue================================"+modelObjectArrayValue.length); + if(modelObjectArrayValue.length > 0){ + ModelObject modelObject = modelObjectArrayValue[0]; + Item ccbhItem = (Item)modelObject; + KUtil.refreshAndGetProperties(ccbhItem, "item_id"); + ccbh = ccbhItem.get_item_id(); + + } + System.out.println("ccbh==============================="+ccbh); + if(ccbh != null && !ccbh.isEmpty()){ + searchMap1.put("fid", ccbh); + ModelObject[] designs = KUtil.query("chint_query_search_drawing", searchMap1); + System.out.println("designs============================"+designs.length); + for (int i = 0; i < designs.length; i++) { + designRev = (ItemRevision) designs[i]; + //dataManagementService.getProperties(new ModelObject[]{designRev}, new String[]{"item_id"}); + KUtil.refreshAndGetProperties(designRev, "item_id"); + String item_id = designRev.get_item_id(); + System.out.println("design_item_id==================================="+item_id); + for (int j = 0; j < CHINT_Search_Drawing_ID.length; j++) { + if(item_id.contains(CHINT_Search_Drawing_ID[j])) { + projectCode = item_id.split("-")[1]; + } + } + } + + + + + + } + + + + } + } else { + // 非产成品直接获取物料描述 + String object_desc = material.get_object_desc(); + String[] splitBak = object_desc.split(" "); + System.out.println(object_desc); + if (splitBak.length >= 2) { + String itemId = splitBak[1]; + projectCode = itemId.substring(itemId.lastIndexOf("-") + 1); +// if (objectName.contains("压线圈")) { // 5种线圈特殊处理ID +// coreCode = itemId.substring(0, itemId.indexOf("-")); +// } + } + } + } + + + + + + + + List momRuleBeans = null; + // 查询数据表规则 + if (coreCode.equals("")) { + System.out.println("psmCodes====================="+psmCodes.toString()); + System.out.println("factory====================="+factory); + momRuleBeans = mapper.selectRuleBean(psmCodes,factory); + } else { + //momRuleBeans = mapper.selectRuleBean2(psmCodes, coreCode,factory); + } + System.out.println(momRuleBeans.toString()); + // 遍历BOM获取PDF数据集信息 + Map> designBeanMap = new HashMap<>(); // 记录图纸信息 + for (MomRuleBean momRuleBean : momRuleBeans) { + String drawingNo = momRuleBean.getDrawingno(); // 图号拼接工程图号 + String type = momRuleBean.getList(); // ALL全部BOM ,0本身 , 1单层 + String elseDrawingNo = momRuleBean.getElsedrawingno(); // 排除的图号 + String designId = drawingNo + "-" + projectCode; + System.out.println(designId); + String psmCode = momRuleBean.getPsmcode(); + ModelObject[] modelObjects = KUtil.queryItemByID(designId); // 根据数据表中的1ZDB40000T拼接工程图号获取图纸 + for (ModelObject modelObject : modelObjects) { + ItemRevision revision = (ItemRevision) modelObject; + KUtil.refreshAndGetProperties( + revision, "item_id", "object_name", "item_revision_id", "ps_children"); + List dsList = getPdfByRevision(revision); + if (dsList.size() > 0) { + DesignBean bean = + new DesignBean( + revision.get_item_id(), + revision.get_object_name(), + getMaterialNo(revision), + revision.get_item_revision_id(), + dsList); + // designBeans.add(bean); + if (designBeanMap.containsKey(psmCode)) { + designBeanMap.get(psmCode).add(bean); + } else { + List designBeans = new ArrayList<>(); + designBeans.add(bean); + designBeanMap.put(psmCode, designBeans); + } + } + if (!type.equals("0")) { + + // System.out.println("revision.get_item_id()===================="+ revision.get_item_id()); + KUtil.log("revision.get_item_id()===================="+ revision.get_item_id()); + // ArrayList arrayList = KUtil.openBOMWindow(revision); // 打开BOM + + ModelObject[] psChildren = revision.get_ps_children(); + //遍历bom 获取bl_is_occ_suppressed + ArrayList list = new ArrayList<>(); + + //BOM全展开 + StructureManagementService service = StructureManagementService.getService(conn); + ArrayList arrayList; + arrayList = openBOMWindow(revision, conn); + + + BOMLine procTopLine = (BOMLine) arrayList.get(1); + // StructureManagement structureService = (StructureManagement)StructureManagementService.getService(connection); + com.teamcenter.services.strong.cad._2007_01.StructureManagement.ExpandPSAllLevelsInfo levelInfo = new com.teamcenter.services.strong.cad._2007_01.StructureManagement.ExpandPSAllLevelsInfo(); + com.teamcenter.services.strong.cad._2007_01.StructureManagement.ExpandPSAllLevelsPref levelPref = new StructureManagement.ExpandPSAllLevelsPref(); + levelInfo.parentBomLines = new BOMLine[] { procTopLine }; //输入顶层BOMLine对象 + levelInfo.excludeFilter = "None"; + levelPref.expItemRev = false; + levelPref.info = new StructureManagement.RelationAndTypesFilter[0]; + com.teamcenter.services.strong.cad._2007_01.StructureManagement.ExpandPSAllLevelsResponse levelResp = service.expandPSAllLevels(levelInfo, levelPref); + List bomlineList = new ArrayList(); + List itemRevList = new ArrayList(); + for (int i = 0; i < levelResp.serviceData.sizeOfPlainObjects(); i++) + { + ModelObject obj = levelResp.serviceData.getPlainObject(i); + BOMLine bomline = null; + ItemRevision itemrev = null; + //获取所有的BOMLine对象 + if (obj instanceof BOMLine) + { + bomline = (BOMLine)obj; + bomlineList.add(bomline); + } + else if (obj instanceof ItemRevision) + { + //获取当前BOM窗口中所有的版本对象 + itemrev = (ItemRevision)obj; + itemRevList.add(itemrev); + } + } + //属性批量预读 + + JSONArray array = new JSONArray(); + ArrayList judgeList = new ArrayList<>();//判断是否重复id + // ServiceData resp = dataManagementService.getProperties(bomlineList.toArray(new BOMLine[0]), new String[]{"bl_item_item_id","bl_is_occ_suppressed"}); + + for (int i = 0; i < bomlineList.size(); i++) { + try{ + BOMLine tempBomline = bomlineList.get(i); + // KUtil.log("uid================"+tempBomline.getUid()); + KUtil.refreshAndGetProperties( + tempBomline, "bl_item_item_id", "bl_is_occ_suppressed"); + + boolean bl_is_occ_suppressed = tempBomline.get_bl_is_occ_suppressed(); + String bl_item_item_id = tempBomline.get_bl_item_item_id(); + KUtil.log("id=================="+bl_item_item_id+"bl_is_occ_suppressed==== "+bl_is_occ_suppressed); + if(bl_is_occ_suppressed){ + list.add(bl_item_item_id); + } + + }catch (Exception e){ + //e.printStackTrace(); + // KUtil.log("ffffffffffffffffffffffffffffffffffffffffffffff"); + continue; + } + } + + +// for (int i = 0; i < resp.sizeOfPlainObjects(); i++) { +// +// BOMLine loadPropObj = (BOMLine) resp.getPlainObject(i); +// boolean bl_is_occ_suppressed = loadPropObj.get_bl_is_occ_suppressed(); +// String bl_item_item_id = loadPropObj.get_bl_item_item_id(); +// System.out.println("id=================="+bl_item_item_id+"bl_is_occ_suppressed==== "+bl_is_occ_suppressed); +// if(bl_is_occ_suppressed){ +// list.add(bl_item_item_id); +// } +// +// } + + + // KUtil.log("list=========================="+list.size()); + KUtil.log("list=========================="+list.toString()); + + + getAllDs(psChildren, elseDrawingNo, type, designBeanMap, psmCode,list); + // KUtil.closeBOMWindow((BOMWindow) arrayList.get(0)); + } + } + } + JSONArray array = new JSONArray(); + for (String key : designBeanMap.keySet()) { + List designBeans = designBeanMap.get(key); + JSONObject jsonObject = + new JSONObject().fluentPut("process", key).fluentPut("list", designBeans); + array.add(jsonObject); + } + JSONObject jsonObject = + new JSONObject() + .fluentPut("wbsno", wbsNo) + .fluentPut("materialno", materialNo) + .fluentPut("processlist", array); + KUtil.log("getDesignList TC回传:" + jsonObject.toJSONString()); + return jsonObject.toJSONString(); + } else { + errMsg = "当前物料没有关联图纸."; + return JSONObject.toJSONString(JsonResult.error(errMsg)); + } + } catch (Exception e) { + KUtil.log(e); + e.printStackTrace(); + } + return JSONObject.toJSONString(JsonResult.error(errMsg)); + } + + // 获取版本下的PDF + public List getPdfByRevision(ItemRevision revision) throws Exception { + List dsList = new ArrayList<>(); + KUtil.refreshAndGetProperties(revision, "IMAN_specification"); + ModelObject[] specifications = revision.get_IMAN_specification(); + int no = 1; + for (ModelObject specification : specifications) { + if (specification instanceof Dataset) { + Dataset ds = (Dataset) specification; + KUtil.refreshAndGetProperties(ds, "object_type", "object_name"); + String object_type = ds.get_object_type(); + if (object_type.equals("PDF")) { + String objectName = ds.get_object_name(); + String uid = ds.getUid(); + dsList.add(new FileBean(no + "", uid, objectName)); + no++; + } + } + } + return dsList; + } + + String getMaterialNo(ItemRevision revision) { + String materialNo = ""; + try { + String item_id = revision.get_item_id(); + if (item_id.startsWith("1ZD")) { + KUtil.refreshAndGetProperties(revision, "representation_for"); + ModelObject[] materials = revision.get_representation_for(); + if (materials.length > 0) { + ItemRevision material = (ItemRevision) materials[0]; + KUtil.refreshAndGetProperties(material, "zt2_MaterialNo"); + materialNo = material.getPropertyObject("zt2_MaterialNo").getStringValue(); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return materialNo; + } + + // 遍历BOM获取图纸下的pdf文件 + private void getAllDs( + ModelObject[] psChildren, + String elseDrawingNo, + String type, + Map> designBeanMap, + String psmCode, + ArrayList list + ) { + try { + String pattern = elseDrawingNo == null ? "" : elseDrawingNo.replaceAll("\\*", ".*"); + for (ModelObject psChild : psChildren) { + ItemRevision revision = (ItemRevision) psChild; + KUtil.refreshAndGetProperties(revision, "item_id", "ps_children"); + String itemId = revision.get_item_id(); + ModelObject[] psRevChildren = revision.get_ps_children(); + if (Pattern.matches(pattern, itemId.split("-")[0])) { + continue; + } + List dsList = getPdfByRevision(revision); + System.out.println("item_id========================="+itemId); + if (dsList.size() > 0 && (!list.contains(itemId))) { + DesignBean bean = + new DesignBean( + revision.get_item_id(), + revision.get_object_name(), + getMaterialNo(revision), + revision.get_item_revision_id(), + dsList); + if (designBeanMap.containsKey(psmCode)) { + designBeanMap.get(psmCode).add(bean); + } else { + List designBeans = new ArrayList<>(); + designBeans.add(bean); + designBeanMap.put(psmCode, designBeans); + } + } + if (type.equals("ALL")) { + getAllDs(psRevChildren, elseDrawingNo, type, designBeanMap, psmCode,list); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + // 变更申请单信息推送至TC + @PostMapping("/getECNResult") + public String getECNResult(@RequestBody JSONObject designJson) { + // org.springframework.boot.configurationprocessor.json.JSONObject result = new + // org.springframework.boot.configurationprocessor.json.JSONObject(); + KUtil.log("getECNResult json ====> " + designJson.toJSONString()); + JSONObject result = new JSONObject(); + FileInputStream fis = null; + FileOutputStream fos = null; + try { + // 根据提供的流程UID完成审核节点 + saveECRResult(designJson); + // 更新数据库 + JSONObject changeExecution = designJson.getJSONObject("changeexecution"); + // 技术部 + String ecnCode = designJson.getString("ecncode"); + KUtil.log("ecnCode ====> " + ecnCode); + if(!designJson.containsKey("ecncode")|| ecnCode.isEmpty()){ + return JSONObject.toJSONString(JsonResult.error("ecncode不存在请检查JSON......", 500)); + } + //TODO OA回传会签信息时将回传信息中的“计划完成时间(数据库字段:pctime)”与“备注(数据库字段:remark)”写入Excel并更新Excel + HashMap map = new HashMap<>(); +// XSSFSheet sheet = null; + /**/ + List ecns = KUtil.query("Item...", new String[] { "零组件 ID" }, new String[] { ecnCode }); + if(ecns == null || ecns.size() == 0){ + return JSONObject.toJSONString(JsonResult.error("ecncode在TC中不存在请检查JSON......", 500)); + } + ModelObject ecn = ecns.get(0); + DataManagementService dataManagementService = DataManagementService.getService(AppXSession.getConnection()); + dataManagementService.getProperties(new ModelObject[]{ ecn }, new String[]{ "IMAN_reference" }); + ModelObject[] refs = ecn.getPropertyObject("IMAN_reference").getModelObjectArrayValue(); + FileManagementUtility fmu = new FileManagementUtility(AppXSession.getConnection(), null, + new String[] { loginInfo.getFmsUrl() }, new String[] { loginInfo.getFmsUrl() }, loginInfo.getFmstemp()); + Dataset excel = null; + dataManagementService.getProperties(refs, new String[]{ "object_type" }); + for(ModelObject ref : refs){ + if(ref.getPropertyObject("object_type").getStringValue().equals("MSExcelX")){ + excel = (Dataset) ref; + break; + } + } + if(excel == null){ + return JSONObject.toJSONString(JsonResult.error("TC变更申请单未找到Excel,请检查", 500)); + } + File file = new File(KUtil.TCFileToFile(fmu, excel)); + KUtil.log("file ====> " + file.getPath()); + fis = new FileInputStream(file); + XSSFWorkbook workbook = new XSSFWorkbook(fis); + XSSFSheet sheet = workbook.getSheetAt(0); + map.put("产品图样、目录、铭牌等", new int[]{ 10, 7 }); + map.put("技术方案、DFMEA、产品质量特性重要度分级表", new int[]{ 11, 7 }); + map.put("BOM物料更改", new int[]{ 12, 7 }); + map.put("包装图样/规范", new int[]{ 13, 7 }); + map.put("发货标签更改", new int[]{ 14, 7 }); + map.put("客户承诺相关设计文件", new int[]{ 15, 7 }); + map.put("环保要求更改", new int[]{ 16, 7 }); + map.put("工艺流程图、PFMEA、工艺守则", new int[]{ 17, 7 }); + map.put("作业指导书、包装指导书", new int[]{ 18, 7 }); + map.put("客户承诺相关工艺文件", new int[]{ 19, 7 }); + map.put("模具、工装、设备更改", new int[]{ 20, 7 }); + map.put("控制计划", new int[]{ 21, 7 }); + map.put("进货/过程/成品检验文件", new int[]{ 22, 7 }); + map.put("供应商产品质量检验报告", new int[]{ 23, 7 }); + map.put("客户承诺相关质量文件", new int[]{ 24, 7 }); + map.put("断点标识(物料切换)", new int[]{ 10, 17 }); + map.put("在制品确认及处理", new int[]{ 11, 17 }); + map.put("成品确认及处理", new int[]{ 12, 17 }); + map.put("计划确认及调整", new int[]{ 13, 17 }); + map.put("采购价格变化", new int[]{ 14, 17 }); + map.put("更改信息(资料、价格)传递", new int[]{ 15, 17 }); + map.put("合格供方评价(新增时)", new int[]{ 16, 17 }); + map.put("供应商合同修改", new int[]{ 17, 17 }); + map.put("供应商处产品确认", new int[]{ 18, 17 }); + map.put("通知客户", new int[]{ 19, 17 }); + map.put("客户批准", new int[]{ 20, 17 }); + map.put("修改客户协议", new int[]{ 21, 17 }); + map.put("销售价格变化", new int[]{ 22, 17 }); + + getJsonMessage("design", changeExecution.getJSONObject("design"), ecnCode, sheet, map); + getJsonMessage("tech", changeExecution.getJSONObject("tech"), ecnCode, sheet, map); + getJsonMessage("quality", changeExecution.getJSONObject("quality"), ecnCode, sheet, map); + getJsonMessage("produce", changeExecution.getJSONObject("produce"), ecnCode, sheet, map); + getJsonMessage("purchase", changeExecution.getJSONObject("purchase"), ecnCode, sheet, map); + getJsonMessage("customnotice", changeExecution.getJSONObject("customnotice"), ecnCode, sheet, map); + getJsonMessage("finaprice", changeExecution.getJSONObject("finaprice"), ecnCode, sheet, map); + result.put("code", "200"); + result.put("msc", "接收成功"); + + fos = new FileOutputStream(file); + workbook.write(fos); + KUtil.uploadFileToTc(file, excel, "excel", fmu); + + } catch (Exception e) { + try { + result.put("code", "500"); + result.put("msc", "接收失败" + e.getMessage()); + } catch (Exception jsonException) { + jsonException.printStackTrace(); + } + e.printStackTrace(); + KUtil.log(KUtil.getStackTrace(e)); + }finally{ + if(fis != null) { + try { + fis.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + if(fos != null) { + try { + fos.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + KUtil.log("result ====> " + result); + return result.toString(); + } + + void getJsonMessage(String depart, JSONObject departJson, String ecnCode, XSSFSheet sheet, HashMap map) { + if(departJson == null){ + return; + } + String principal = departJson.getString(depart + "principal").replaceAll(":", ";"); + String coudata = departJson.getString(depart + "date"); + JSONArray files = departJson.getJSONArray(depart + "files"); + XSSFRow row; + XSSFCell cell; + for (int i = 0; i < files.size(); i++) { + JSONObject file = files.getJSONObject(i); + String fileVal = file.getString(depart + "file"); // pctime + String pctimeVal = file.getString(depart + "pctime"); + String remarkVal = file.getString(depart + "remark"); + mapper.updateRefMethod(fileVal, principal, coudata, pctimeVal, remarkVal, ecnCode); + + int[] w = map.get(fileVal); + row = sheet.getRow(w[0]); + cell = row.getCell(w[1]); + cell.setCellValue(pctimeVal); + cell = row.getCell(w[1] + 2); + cell.setCellValue(remarkVal); + } + } + // 存储变更申请单信息 + public void saveECRResult(JSONObject jsonObject) throws Exception { + // 登录 + // Session session = new Session(config.getTc_url()); + try { + DataManagementService dmService = + DataManagementService.getService(AppXSession.getConnection()); + // User user = session.login2(config.getTc_user(), config.getTc_pwd()); + // 根据UID查询流程对象 + String uuid = jsonObject.getString("uuid"); + ServiceData serverData = dmService.loadObjects(new String[] {uuid}); + if (serverData.sizeOfPlainObjects() > 0) { + assignOATask(serverData.getPlainObject(0)); + } + } catch (Exception e) { + e.printStackTrace(); + KUtil.log(KUtil.getStackTrace(e)); + } finally { + // 登出 + // session.logout(); + } + } + + public void assignOATask(ModelObject childTaskMo) throws Exception { + WorkflowService wfService = WorkflowService.getService(AppXSession.getConnection()); + DataManagementService dmService = DataManagementService.getService(AppXSession.getConnection()); + EPMTask childTask = (EPMTask) childTaskMo; + dmService.refreshObjects(new ModelObject[] {childTask}); + dmService.getProperties( + new ModelObject[] {childTask}, new String[] {"object_type", "object_name"}); + String taskType = childTask.get_object_type(); + KUtil.log("taskType ====>" + taskType); + if(taskType.compareTo("EPMPerformSignoffTask") == 0){ + dmService.getProperties( + new ModelObject[] {childTask}, + new String[] {"parent_task"}); + childTask = childTask.get_parent_task(); + dmService.refreshObjects(new ModelObject[] {childTask}); + dmService.getProperties( + new ModelObject[] {childTask}, new String[] {"object_type", "object_name"}); + } + if (childTask.get_object_type().compareTo("EPMReviewTask") == 0) { + dmService.getProperties( + new ModelObject[] {(EPMTask) childTask}, + new String[] {"fnd0TaskPathName", "child_tasks", "user_all_signoffs"}); + // 获取审核任务的子任务 + ModelObject[] childReviewTasks = childTask.get_child_tasks(); + dmService.refreshObjects(childReviewTasks); + dmService.getProperties( + childReviewTasks, + new String[] { + "signoff_profiles", "user_all_signoffs", "valid_signoffs", "signoff_attachments" + }); + // 审核人 + ModelObject signOff = null; + // 审批子任务 + EPMTask childReview = null; + for (ModelObject childReviewTask : childReviewTasks) { + // 如果是选人子任务 + if (childReviewTask instanceof EPMSelectSignoffTask) { + EPMSelectSignoffTask childSelectReview = (EPMSelectSignoffTask) childReviewTask; + dmService.refreshObjects(new ModelObject[] { childSelectReview }); + ModelObject[] signOffs = childSelectReview.get_valid_signoffs(); + dmService.refreshObjects(signOffs); + if (signOffs.length > 0) { + for (ModelObject off : signOffs) { + Signoff center = (Signoff) off; + dmService.getProperties(new ModelObject[]{center}, new String[]{"object_string"}); + System.out.println("当前的值为:" + center.get_object_string()); + if (center.get_object_string().contains("dcproxy")) { + signOff = off; + dmService.refreshObjects(new ModelObject[]{signOff}); + break; + } + } + } + } + // 如果是审批子任务 + else if (childReviewTask instanceof EPMPerformSignoffTask) { + childReview = (EPMTask) childReviewTask; + // dmService.refreshObjects(new ModelObject[]{childReview}); + } + } + dmService.refreshObjects(new ModelObject[] {signOff, childReview}); + KUtil.log("批准OA审批节点 ====>" + childReview); + System.out.println("批准OA审批节点 ====>" + childReview.getUid()); + ServiceData sData1 = + wfService.performAction( + childReview, "SOA_EPM_perform_action", "", null, "SOA_EPM_approve", signOff); +// Workflow.PerformActionInputInfo info = new Workflow.PerformActionInputInfo(); +// info.actionableObject = childReview; +// info.action = "SOA_EPM_perform_action"; +// wfService.performAction3(new Workflow.PerformActionInputInfo[] { info }); + serviceDataError(sData1); + } + } + + //TODO 云派调用TC接口查询更改通知单对象 + @RequestMapping(value = "/getECN", method = {RequestMethod.GET, RequestMethod.POST}) + public String getECN(@RequestBody ECNBean ecnBean) throws Exception { + + KUtil.log(">> 开始执行:getECN"); + KUtil.log("jSONObject = " + ecnBean); + /*Session session = new Session(config.getTc_url()); + User user = session.login2(config.getTc_user(), config.getTc_pwd()); + if (user == null) { + throw new Exception("Teamcenter SOA登录失败"); + }*/ + HashMap counts = new HashMap<>(); + try{ +// DataManagementService dataManagementService = DataManagementService.getService(Session.getConnection()); + DataManagementService dataManagementService = DataManagementService.getService(AppXSession.getConnection()); + SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat sdf2 = new SimpleDateFormat("dd-MMM-yyyy", Locale.US); +// sdf2.applyLocalizedPattern(); + String[] vals = new String[]{ sdf2.format(sdf1.parse(ecnBean.getCreationdatebefore())) + " 23:59", "*" + ecnBean.getFactory() + "*", + sdf2.format(sdf1.parse(ecnBean.getCreationdateafter())) + " 00:00" }; + KUtil.log("query = " + Arrays.toString(vals)); +// ModelObject[] results = queryItems("chint_query_change", new String[]{ "创建时间早于", "所有权组", "创建时间晚于" }, vals); +// ModelObject[] results = queryItems("chint_query_change", new String[]{ "CreatedBefore", "OwningGroup", "CreatedAfter" }, vals); +// ModelObject[] results = queryItems("chint_query_change", new String[]{ "before", "groupname", "after" }, vals); + HashMap searchMap = new HashMap<>(); + searchMap.put("before", vals[0]); + searchMap.put("groupname", vals[1]); + searchMap.put("after", vals[2]); + ModelObject[] results = KUtil.query("chint_query_material_test", searchMap); + if (results != null) { + for(ModelObject result : results){ + dataManagementService.getProperties(new ModelObject[] { result }, new String[]{ "owning_user" }); + com.teamcenter.soa.client.model.Property prop = result.getPropertyObject("owning_user"); + ModelObject owning_user = prop.getModelObjectValue(); + dataManagementService.getProperties(new ModelObject[] { owning_user }, new String[]{ "user_name" }); + String user_name = owning_user.getPropertyDisplayableValue("user_name"); + if(counts.containsKey(user_name)){ + counts.get(user_name).add(); + }else { + counts.put(user_name, new ECNBeanReturn(user_name, 1)); + } + } + }else{ + KUtil.log("chint_query_change查询未返回有效结果"); + } + }catch(Exception e){ + e.printStackTrace(); + KUtil.log("getECN 异常===>" + KUtil.getStackTrace(e)); + throw e; + } + + ArrayList returns = new ArrayList<>(counts.values()); + ObjectMapper objectMapper = new ObjectMapper(); + String data = "{\"code\": \"200\",\"msg\": \"\",\"results\":" + objectMapper.writeValueAsString(returns) + "}"; + KUtil.log("返回数据:" + data + "\n"); +// session.logout(); + return data; + } + + public static boolean serviceDataError(ServiceData data) { + if (data.sizeOfPartialErrors() > 0) { + for (int i = 0; i < data.sizeOfPartialErrors(); i++) { + String[] msgs = data.getPartialError(i).getMessages(); + for(String msg : msgs){ + System.out.println(msg); + KUtil.log(msg); + } + //System.out.println(data.getPartialError(i).getMessages()[0]); + // TDefaultLogger.CreateInstance().LogAgent.DebugFormat("错误{0}", + // data.getPartialError(i).getMessages()); + } + return false; + } + return true; + } +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/controller/JfwController.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/controller/JfwController.java new file mode 100644 index 0000000..4bbd225 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/controller/JfwController.java @@ -0,0 +1,146 @@ +//package com.connor.connor_cpzc_service.controller; +// +//import com.alibaba.fastjson.JSON; +//import com.alibaba.fastjson.JSONObject; +//import com.connor.connor_cpzc_service.info.JFWEntry; +//import com.connor.connor_cpzc_service.info.JFWMesEntry; +//import com.connor.connor_cpzc_service.info.LoginInfo; +//import com.connor.connor_cpzc_service.info.RiskEntry; +//import com.connor.connor_cpzc_service.util.KUtil; +//import com.teamcenter.services.strong.core.DataManagementService; +//import com.teamcenter.soa.client.model.ModelObject; +//import com.teamcenter.soa.client.model.ServiceData; +//import com.teamcenter.soa.client.model.strong.*; +//import org.apache.log4j.Logger; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.stereotype.Component; +//import org.springframework.web.bind.annotation.PathVariable; +//import org.springframework.web.bind.annotation.RequestMapping; +//import org.springframework.web.bind.annotation.RequestMethod; +//import org.springframework.web.bind.annotation.RestController; +// +//import java.util.ArrayList; +//import java.util.List; +// +//@Component +//@RestController +//@RequestMapping(value = "/connor/jfw") +//public class JfwController { +// private static final Logger log = Logger.getLogger(WBSController.class); +// +// @Autowired +// protected LoginInfo loginInfo; +// +// @RequestMapping(value = "/{projectId}", method = RequestMethod.POST) +// public String updateStatus(@PathVariable String projectId) { +// log.error(String.format("收到请求交付物:项目ID【%s】",projectId)); +// String json =""; +// List wbsInfos=new ArrayList<>(); +// try { +//// DataManagementService dmService = KUtil.login(loginInfo.getServer(), loginInfo.getUser(), loginInfo.getPassword()); +// KUtil.setByPass(true); +// String projectFind = "Projects..."; +// String[] proId = new String[]{"项目 ID"}; +// String[] proVal = new String[]{"*"}; +// List projects = KUtil.query(projectFind, proId, proVal); +// System.out.println("projects数量"+projects.size()); +// +// +// +// for (ModelObject pro:projects){ +// JFWEntry wbsInfo=new JFWEntry(); +// wbsInfos.add(wbsInfo); +// TC_Project project = (TC_Project)pro; +//// ItemRevision rev = (ItemRevision) revs.get(0); +// KUtil.refreshAndGetProperties(project, "project_id", "project_name","project_data","xa2_ProjectState"); +// wbsInfo.setProjectstatus(project.getPropertyObject("xa2_ProjectState").getStringValue()); +// log.error("找到项目:"+project.get_object_string()); +// wbsInfo.setProjectname(project.get_project_name()); +// wbsInfo.setProjectid(project.get_project_id()); +// ModelObject[] project_data = project.get_project_data(); +// if(project_data.length==0){ +// throw new Exception(String.format("未找到时间表\"%s\"", projectId)); +// } +// List jfwMesEntries=new ArrayList<>(); +// Schedule schedule=null; +// for(ModelObject modelObject :project_data){ +// KUtil.refreshAndGetProperties(modelObject, "object_type"); +// String object_type = modelObject.getPropertyObject("object_type").getStringValue(); +// if(object_type.equals("Schedule")){ +// schedule =(Schedule)modelObject; +// } +// } +// if(schedule==null){ +// throw new Exception(String.format("没有找到时间表\"%s\"", projectId)); +// } +// KUtil.refreshAndGetProperties(schedule, "object_type"); +// String object_type = schedule.get_object_type(); +//// if(object_type.equals("xa2.ScheduleType") || true){ +// KUtil.refreshAndGetProperties(schedule, "fnd0SummaryTask"); +// ScheduleTask fnd0SummaryTask = (ScheduleTask)schedule.get_fnd0SummaryTask(); +// KUtil.refreshAndGetProperties(fnd0SummaryTask, "fnd0TaskTypeString","child_task_taglist"); +// ArrayList child_tasks=new ArrayList<>(); +// KUtil.getChildTask(fnd0SummaryTask,child_tasks); +//// ScheduleTask[] child_task_taglist = fnd0SummaryTask.get_child_task_taglist(); +// for(int j=0;j0){ +// jfwMes.setDeliverstatus("完成"); +// }else if(dataSet.get_fnd0AllWorkflows().length>0){ +// jfwMes.setDeliverstatus("进行中"); +// }else { +// jfwMes.setDeliverstatus("未开始"); +// } +//// } +// }catch (Exception e){ +// e.printStackTrace(); +// KUtil.refreshAndGetProperties(dataSet, "fnd0AllWorkflows"); +// if(schTaskDeliverable.get_fnd0InstanceReleaseStatus().length>0){ +// jfwMes.setDeliverstatus("完成"); +// }else if(dataSet.get_fnd0AllWorkflows().length>0){ +// jfwMes.setDeliverstatus("进行中"); +// }else { +// jfwMes.setDeliverstatus("未开始"); +// } +// } +// +// jfwMesEntries.add(jfwMes); +// } +// } +// +//// } +// wbsInfo.setEntry(jfwMesEntries); +// } +// +// +// }catch (Exception e){ +// e.printStackTrace(); +// }finally { +//// KUtil.logoutAndClearCache2(); +// } +//// wbsInfo.setMessage(new Message()); +// json= JSON.toJSONString(wbsInfos); +// return json; +// } +//} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/controller/JgjBean.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/controller/JgjBean.java new file mode 100644 index 0000000..56be090 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/controller/JgjBean.java @@ -0,0 +1,46 @@ +package com.connor.connor_cpzc_service.controller; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.List; + +public class JgjBean { + @JsonProperty("downFile") + private List downFile; + @JsonProperty("errFile") + private List errFile; + @JsonProperty("desc") + private String desc; + @JsonProperty("code") + private String code; + @JsonProperty("user") + private String userId; + @JsonProperty("zt2_Specifications") + private String zt2_Specifications; + @JsonProperty("item_id") + private String itemId; + @JsonProperty("fileNames") + private List fileNames; + @JsonProperty("objName") + private String objName; + @JsonProperty("jgjIds") + List jgjList; + public JgjBean(List downFile, List errFile, String desc, String code, + String itemId, List fileNames, List uids, String document,List jgjList) { + this.downFile = downFile; + this.errFile = errFile; + this.desc = desc; + this.code = code; + this.itemId = itemId; + this.fileNames = fileNames; + this.uids = uids; + this.document = document; + this.jgjList = jgjList; + } + + @JsonProperty("uids") + private List uids; + @JsonProperty("document") + private String document; + +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/controller/RDMController.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/controller/RDMController.java new file mode 100644 index 0000000..3548f40 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/controller/RDMController.java @@ -0,0 +1,358 @@ +package com.connor.connor_cpzc_service.controller; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.connor.connor_cpzc_service.bean.MdmDs.DesignBean; +import com.connor.connor_cpzc_service.bean.MdmDs.FileBean; +import com.connor.connor_cpzc_service.bean.MdmDs.MomRuleBean; +import com.connor.connor_cpzc_service.bean.QMSBean; +import com.connor.connor_cpzc_service.bean.SapResult; +import com.connor.connor_cpzc_service.bean.SapReturn; +import com.connor.connor_cpzc_service.mapper.EPMMapper; +import com.connor.connor_cpzc_service.service.BomResultService; +import com.connor.connor_cpzc_service.service.RDMService; +import com.connor.connor_cpzc_service.util.JsonResult; +import com.connor.connor_cpzc_service.util.KUtil; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.teamcenter.clientx.AppXSession; +import com.teamcenter.services.strong.core.DataManagementService; +import com.teamcenter.services.strong.workflow.WorkflowService; +import com.teamcenter.soa.client.model.ModelObject; +import com.teamcenter.soa.client.model.ServiceData; +import com.teamcenter.soa.client.model.strong.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.regex.Pattern; + +@RestController +@RequestMapping(value = "/plm") +public class RDMController { + + + @Autowired RDMService service; + private static org.apache.log4j.Logger logger = + org.apache.log4j.Logger.getLogger(RDMController.class); + + @PostMapping("/getFileList") + public String getBOMResult(@RequestBody String json) throws Exception { + + JSONObject parse = (JSONObject) JSON.parse(json); + JSONObject errorResult = new JSONObject(); + // 遍历lists数组 + HashMap map = new HashMap(); + LinkedHashMap stringJSONObjectLinkedHashMap = new LinkedHashMap<>(); + String queryID = ""; + JSONArray lists = parse.getJSONArray("drawlist"); + for (int i = 0; i < lists.size(); i++) { + JSONObject listObject = lists.getJSONObject(i); + // 获取listObject中的属性 + String drawNo = listObject.getString("drawNo"); + String no = listObject.getString("no"); + + + //参数非空判断 + if (drawNo == null || drawNo.isEmpty()) { + errorResult.put("code", "500"); + errorResult.put("msg", "drawNo不能为空!"); + return errorResult.toString(); + } + + if (no == null || no.isEmpty()) { + errorResult.put("code", "500"); + errorResult.put("msg", "no不能为空!"); + return errorResult.toString(); + } + map.put(drawNo,no); + queryID = queryID+drawNo+";"; + + } + + + return service.GetDrawing(map,queryID,stringJSONObjectLinkedHashMap); + } + + + + @PostMapping("/GetRDMProject") + public String getRDMProject(@RequestBody String json){ + + + + return service.getRDMProject(json); + } + + + @PostMapping("/getProjectFinish") + public String getProjectFinish(@RequestBody String json){ + + + + return service.getProjectFinish(json); + } + + @PostMapping("/getInspection") + public String getInspection(@RequestBody String json){ + JSONObject errorResult = new JSONObject(); + JSONObject result = new JSONObject(); + + // 解析JSON字符串 + JSONObject jsonObject = JSON.parseObject(json); + String factory = jsonObject.getString("factory"); + + //参数非空判断 + if(factory == null || factory.isEmpty()){ + errorResult.put("code",400); + errorResult.put("msg","factory不能为空!"); + return errorResult.toString(); + } + + // 获取lists对象 + JSONArray lists = jsonObject.getJSONArray("lists"); + if(lists == null || lists.size() == 0){ + errorResult.put("code",400); + errorResult.put("msg","lists不能为空!"); + return errorResult.toString(); + } + + try { + + for (int i = 0; i < lists.size(); i++) { + JSONObject listObject = lists.getJSONObject(i); + // 获取listObject中的属性 + String qmsinspectioncode = listObject.getString("qmsinspectioncode"); + String qmsinspectionname = listObject.getString("qmsinspectionname"); + String qmspushuser = listObject.getString("qmspushuser"); + String qmspushtime = listObject.getString("qmspushtime"); + String qmsremark = listObject.getString("qmsremark"); + String qmssuperiorinspectionname = listObject.getString("qmssuperiorinspectionname"); + String qmssuperiorinspectioncode = listObject.getString("qmssuperiorinspectioncode"); + String qmsinspectionschemename = listObject.getString("qmsinspectionschemename"); + String qmsinspectionschemecode = listObject.getString("qmsinspectionschemecode"); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date qmspushtimeDate = sdf.parse(qmspushtime); + + QMSBean qmsBean = new QMSBean(factory,qmsinspectioncode,qmsinspectionname,qmspushuser,qmspushtimeDate,qmsremark,qmssuperiorinspectionname,qmssuperiorinspectioncode,qmsinspectionschemename,qmsinspectionschemecode); + + //service.getInspection(factory, qmsinspectioncode, qmsinspectionname, qmssuperiorinspection, qmspushuser, qmspushtime, qmsremark); + service.getInspection(qmsBean); + } + }catch (Exception e){ + e.printStackTrace(); + errorResult.put("code",500); + errorResult.put("msg","失败!"); + return errorResult.toString(); + } + result.put("code",200); + result.put("msg","成功接收"); + return result.toJSONString(); + + + } + + + + + @PostMapping("/getInspectionResult") + public String getInspectionResult(@RequestBody String json){ + JSONObject errorResult = new JSONObject(); + JSONObject result = new JSONObject(); + HashMap enptyMap = new HashMap<>(); + List lastBeans = new ArrayList(); + // 解析JSON字符串 + JSONObject jsonObject = JSON.parseObject(json); + String factory = jsonObject.getString("factory"); + + //参数非空判断 + if(factory == null || factory.isEmpty()){ + errorResult.put("code",400); + errorResult.put("msg","factory不能为空!"); + return errorResult.toString(); + } + + // 获取lists对象 + JSONArray lists = jsonObject.getJSONArray("lists"); + if(lists == null || lists.size() == 0){ + errorResult.put("code",400); + errorResult.put("msg","lists不能为空!"); + return errorResult.toString(); + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + try { + + + + + for (int i = 0; i < lists.size(); i++) { + JSONObject listObject = lists.getJSONObject(i); + // 获取listObject中的属性 + String qmsinspectioncode = listObject.getString("qmsinspectioncode"); +// String qmsinspectionname = listObject.getString("qmsinspectionname"); +// String qmspushuser = listObject.getString("qmspushuser"); +// String qmspushtime = listObject.getString("qmspushtime"); +// String qmsremark = listObject.getString("qmsremark"); +// String qmssuperiorinspectionname = listObject.getString("qmssuperiorinspectionname"); +// String qmssuperiorinspectioncode = listObject.getString("qmssuperiorinspectioncode"); +// String qmsinspectionschemename = listObject.getString("qmsinspectionschemename"); + String qmsinspectionschemecode = listObject.getString("qmsinspectionschemecode"); + + if(qmsinspectioncode == null || qmsinspectioncode.isEmpty()){ + errorResult.put("code",400); + errorResult.put("msg","qmsinspectioncode不能为空!"); + return errorResult.toString(); + } + + if(qmsinspectionschemecode == null || qmsinspectionschemecode.isEmpty()){ + errorResult.put("code",400); + errorResult.put("msg","qmsinspectionschemecode不能为空!"); + return errorResult.toString(); + } + + + + List qmsBeans = service.getInspectionResult(factory,qmsinspectioncode,qmsinspectionschemecode); + if(qmsBeans != null && qmsBeans.size() > 0){ + for (QMSBean qmsBean : qmsBeans) { + lastBeans.add(qmsBean); + } + }else{ + JSONObject tempJsonObject = new JSONObject(); + tempJsonObject.put("qmsinspectioncode",listObject.getString("qmsinspectioncode")); + tempJsonObject.put("qmsinspectionname",listObject.getString("qmsinspectionname")); + tempJsonObject.put("qmssuperiorinspectionname",listObject.getString("qmssuperiorinspectionname")); + tempJsonObject.put("qmssuperiorinspectioncode",listObject.getString("qmssuperiorinspectioncode")); + tempJsonObject.put("qmsinspectionschemename",listObject.getString("qmsinspectionschemename")); + tempJsonObject.put("qmsinspectionschemecode",listObject.getString("qmsinspectionschemecode")); + tempJsonObject.put("qmspushuser",listObject.getString("qmspushuser")); + tempJsonObject.put("qmspushtime",listObject.getString("qmspushtime")); + tempJsonObject.put("qmsremark",listObject.getString("qmsremark")); + tempJsonObject.put("plminspectioncode",""); + tempJsonObject.put("plmremark",""); + tempJsonObject.put("result",""); + tempJsonObject.put("synctime",""); + tempJsonObject.put("syncuser",""); + enptyMap.put(listObject.getString("qmsinspectioncode")+listObject.getString("qmsinspectionschemecode"),tempJsonObject); + } + } + }catch (Exception e){ + e.printStackTrace(); + errorResult.put("code",500); + errorResult.put("msg","失败!"); + return errorResult.toString(); + } + + result.put("code",200); + result.put("msg","成功接收"); + result.put("factory",factory); + JSONArray jsonArray = new JSONArray(); + System.out.println("lastBean============"+ lastBeans.size()); + for (QMSBean lastBean : lastBeans) { + JSONObject tempJsonObject = new JSONObject(); + tempJsonObject.put("qmsinspectioncode",lastBean.getQmsinspectioncode() == null ? "" : lastBean.getQmsinspectioncode()); + tempJsonObject.put("qmsinspectionname",lastBean.getQmsinspectionname() == null ? "" : lastBean.getQmsinspectionname()); + tempJsonObject.put("qmssuperiorinspectionname",lastBean.getQmssuperiorinspectionname() == null ? "" : lastBean.getQmssuperiorinspectionname()); + tempJsonObject.put("qmssuperiorinspectioncode",lastBean.getQmssuperiorinspectioncode() == null ? "" : lastBean.getQmssuperiorinspectioncode()); + tempJsonObject.put("qmsinspectionschemename",lastBean.getQmsinspectionschemename() == null ? "" : lastBean.getQmsinspectionschemename()); + tempJsonObject.put("qmsinspectionschemecode",lastBean.getQmsinspectionschemecode() == null ? "" : lastBean.getQmsinspectionschemecode()); + tempJsonObject.put("qmspushuser",lastBean.getQmspushuser() == null ? "" : lastBean.getQmspushuser()); + tempJsonObject.put("qmspushtime",lastBean.getQmspushtime() == null ? "" :sdf.format(lastBean.getQmspushtime())); + tempJsonObject.put("qmsremark",lastBean.getQmsremark() == null ? "" : lastBean.getQmsremark()); + tempJsonObject.put("plminspectioncode",lastBean.getPlminspectioncode() == null ? "" : lastBean.getPlminspectioncode()); + tempJsonObject.put("plmremark",lastBean.getPlmremark() == null ? "" : lastBean.getPlmremark()); + tempJsonObject.put("result",lastBean.getResult() == null ? "" : lastBean.getResult()); + tempJsonObject.put("synctime",lastBean.getSynctime() == null ? "" :sdf.format(lastBean.getSynctime())); + tempJsonObject.put("syncuser",lastBean.getSyncuser() == null ? "" : lastBean.getSyncuser()); + jsonArray.add(tempJsonObject); + } + + for (Map.Entry entryMap : enptyMap.entrySet() + ) { + JSONObject value = entryMap.getValue(); + jsonArray.add(value); + } + + + result.put("lists",jsonArray); + + + return result.toJSONString(); + + + } + + + + @PostMapping("/getProjectInspection") + public String getProjectInspection(@RequestBody String json){ + JSONObject errorResult = new JSONObject(); + + HashMap enptyMap = new HashMap<>(); + List lastBeans = new ArrayList(); + // 解析JSON字符串 + JSONObject jsonObject = JSON.parseObject(json); + String factory = jsonObject.getString("factory"); + +// //参数非空判断 +// if(factory == null || factory.isEmpty()){ +// errorResult.put("code",400); +// errorResult.put("msg","factory不能为空!"); +// return errorResult.toString(); +// } +// +// // 获取lists对象 +// JSONArray lists = jsonObject.getJSONArray("lists"); +// if(lists == null || lists.size() == 0){ +// errorResult.put("code",400); +// errorResult.put("msg","lists不能为空!"); +// return errorResult.toString(); +// } + + String wbsno = jsonObject.getString("wbsno"); + String drawingno = jsonObject.getString("drawingno"); + String factoryno = jsonObject.getString("factoryno"); + JSONArray materialnolists = jsonObject.getJSONArray("materialnolists"); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + try { + + + + + for (int i = 0; i < materialnolists.size(); i++) { + JSONObject materialnolistsObject = materialnolists.getJSONObject(i); + // 获取listObject中的属性 + String materialno = materialnolistsObject.getString("materialno"); + JSONArray inspectionlists = materialnolistsObject.getJSONArray("inspectionlists"); + for (int j = 0; j < inspectionlists.size(); j++) { + JSONObject inspectionlistsObject = inspectionlists.getJSONObject(j); + String plminspectioncode = inspectionlistsObject.getString("plminspectioncode"); + String value = service.getProjectInspection(wbsno,drawingno,factoryno,materialno,plminspectioncode); + inspectionlistsObject.put("value",value); + } + + + } + jsonObject.put("code","200"); + jsonObject.put("msg","成功"); + }catch (Exception e){ + e.printStackTrace(); + errorResult.put("code",500); + errorResult.put("msg","失败!"); + return errorResult.toString(); + } + + + return jsonObject.toJSONString(); + + + } + + +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/controller/ReBean.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/controller/ReBean.java new file mode 100644 index 0000000..fb45ef4 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/controller/ReBean.java @@ -0,0 +1,15 @@ +package com.connor.connor_cpzc_service.controller; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.List; + +public class ReBean { + public ReBean(List zztQd) { + this.zztQd = zztQd; + } + private String code; + @JsonProperty("zztQd") + private List zztQd; + +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/controller/ReturnBean.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/controller/ReturnBean.java new file mode 100644 index 0000000..b0865fa --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/controller/ReturnBean.java @@ -0,0 +1,66 @@ +package com.connor.connor_cpzc_service.controller; + +import com.connor.connor_cpzc_service.info.FileInfoBean; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.ArrayList; +import java.util.List; + +public class ReturnBean { + @JsonProperty("downFile") + private List downFile; + @JsonProperty("errFile") + private List errFile; + @JsonProperty("desc") + private String desc; + @JsonProperty("code") + private String code; + @JsonProperty("user") + private String userId; + @JsonProperty("zt2_Specifications") + private String zt2_Specifications; + @JsonProperty("item_id") + private String itemId; + @JsonProperty("fileNames") + private List fileNames; + @JsonProperty("objName") + private String objName; + public ReturnBean(List downFile, List errFile, String desc, String code, + String itemId, List fileNames, List uids, String document) { + this.downFile = downFile; + this.errFile = errFile; + this.desc = desc; + this.code = code; + this.itemId = itemId; + this.fileNames = fileNames; + this.uids = uids; + this.document = document; + } + + @JsonProperty("uids") + private List uids; + @JsonProperty("document") + private String document; + public ReturnBean(String userId, String zt2_Specifications, String itemId,List fileNames) { + this.userId = userId; + this.zt2_Specifications = zt2_Specifications; + this.itemId = itemId; + this.fileNames = fileNames; + } + + public ReturnBean(List downFile, List errFile, String desc, String code, + String userId, String zt2_Specifications, String itemId,List fileNames, + List uids,String document,String objName) { + this.downFile = downFile; + this.errFile = errFile; + this.desc = desc; + this.code = code; + this.userId = userId; + this.zt2_Specifications = zt2_Specifications; + this.itemId = itemId; + this.fileNames = fileNames; + this.uids = uids; + this.document = document; + this.objName = objName; + } +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/controller/RiskController.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/controller/RiskController.java new file mode 100644 index 0000000..fdc7f54 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/controller/RiskController.java @@ -0,0 +1,102 @@ +//package com.connor.connor_cpzc_service.controller; +// +//import com.alibaba.fastjson.JSON; +//import com.alibaba.fastjson.JSONObject; +//import com.connor.connor_cpzc_service.info.*; +//import com.connor.connor_cpzc_service.util.KUtil; +//import com.teamcenter.services.strong.core.DataManagementService; +//import com.teamcenter.soa.client.model.ModelObject; +//import com.teamcenter.soa.client.model.ServiceData; +//import com.teamcenter.soa.client.model.strong.*; +//import org.apache.log4j.Logger; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.stereotype.Component; +//import org.springframework.web.bind.annotation.PathVariable; +//import org.springframework.web.bind.annotation.RequestMapping; +//import org.springframework.web.bind.annotation.RequestMethod; +//import org.springframework.web.bind.annotation.RestController; +// +//import java.util.ArrayList; +//import java.util.List; +// +//@Component +//@RestController +//@RequestMapping(value = "/connor/risk") +//public class RiskController { +// private static final Logger log = Logger.getLogger(WBSController.class); +// +// @Autowired +// protected LoginInfo loginInfo; +// @RequestMapping(value = "/{projectId}", method = RequestMethod.POST) +// public String RiskMes(@PathVariable String projectId) { +// log.error(String.format("收到请求risk:项目ID【%s】",projectId)); +// String json=""; +// List wbsInfos=new ArrayList<>(); +// +// try { +//// DataManagementService dmService = KUtil.login(loginInfo.getServer(), loginInfo.getUser(), loginInfo.getPassword()); +// KUtil.setByPass(true); +// +// String projectFind = "Projects..."; +// String[] proId = new String[]{"项目 ID"}; +// String[] proVal = new String[]{"*"}; +// List projects = KUtil.query(projectFind, proId, proVal); +// System.out.println("projects数量"+projects.size()); +// +// for (ModelObject pro:projects){ +// RiskEntry riskEntry=new RiskEntry(); +// wbsInfos.add(riskEntry); +// TC_Project project = (TC_Project)pro; +// KUtil.refreshAndGetProperties(project, "project_id", "project_name", "project_data","TC_Program_Preferred_Items","xa2_ProjectState"); +// log.error("找到项目:" + project.get_object_string()); +// ModelObject[] items = project.get_project_data(); +// riskEntry.setProjectid(project.get_project_id()); +// riskEntry.setProjectstatus(project.getPropertyObject("xa2_ProjectState").getStringValue()); +// riskEntry.setProjectname(project.get_project_name()); +// List changeList=new ArrayList<>(); +// System.out.println("project_data"+items.length); +// if(items.length>0){ +// for(int i=0;i< items.length;i++){ +// ModelObject item =items[i]; +// KUtil.refreshAndGetProperties(item, "object_type","item_id","object_name","revision_list","owning_user"); +// System.out.println(item.getPropertyObject("object_type").getStringValue()); +// if(item.getPropertyObject("object_type").getStringValue().equals("XA2_LLearnd")){ +// RiskMesEntry riskMesEntry=new RiskMesEntry(); +// riskMesEntry.setLessonslearnedid(item.getPropertyObject("item_id").getStringValue()); +// riskMesEntry.setLessonslearnedname(item.getPropertyObject("object_name").getStringValue()); +// User owning_user =(User) item.getPropertyObject("owning_user").getModelObjectValue(); +// KUtil.refreshAndGetProperties(owning_user, "user_name"); +// riskMesEntry.setLessonslearnedowner(owning_user.get_user_name()); +// changeList.add(riskMesEntry); +// List itemsList=new ArrayList<>(); +// ModelObject[] revision_list = item.getPropertyObject("revision_list").getModelObjectArrayValue(); +// ItemRevision item_revision =(ItemRevision) revision_list[revision_list.length - 1]; +// KUtil.refreshAndGetProperties(item_revision, "current_revision_id","IMAN_master_form_rev"); +// ModelObject[] iman_master_form_rev = item_revision.get_IMAN_master_form_rev(); +// ModelObject modelObject = iman_master_form_rev[0]; +// KUtil.refreshAndGetProperties(modelObject, "xa2_DesLl","xa2_Analysisdes"); +// riskMesEntry.setFaultdescription(modelObject.getPropertyObject("xa2_DesLl").getStringValue()); +// riskMesEntry.setAnalysisdescription(modelObject.getPropertyObject("xa2_Analysisdes").getStringValue()); +// } +// } +// } +// if(changeList.size()==0){ +// RiskMesEntry changeMesEntry=new RiskMesEntry(); +// changeList.add(changeMesEntry); +// } +// riskEntry.setEntry(changeList); +// } +// +// +// }catch (Exception e){ +// e.printStackTrace(); +// log.error(e); +// return e.getMessage(); +// }finally { +//// KUtil.logoutAndClearCache2(); +// } +//// riskEntry.setMessage(new Message()); +// json= JSON.toJSONString(wbsInfos); +// return json; +// } +//} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/controller/WBSController.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/controller/WBSController.java new file mode 100644 index 0000000..437143c --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/controller/WBSController.java @@ -0,0 +1,245 @@ +//package com.connor.connor_cpzc_service.controller; +// +//import com.alibaba.fastjson.JSON; +//import com.alibaba.fastjson.JSONObject; +//import com.connor.connor_cpzc_service.info.LoginInfo; +//import com.connor.connor_cpzc_service.info.WBSInfo; +//import com.connor.connor_cpzc_service.info.WBSScheduleInfo; +//import com.connor.connor_cpzc_service.util.KUtil; +//import com.teamcenter.services.loose.core._2018_11.ProjectLevelSecurity; +//import com.teamcenter.services.strong.core.DataManagementService; +//import com.teamcenter.soa.client.model.ModelObject; +//import com.teamcenter.soa.client.model.strong.*; +//import org.apache.log4j.Logger; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.stereotype.Component; +//import org.springframework.web.bind.annotation.*; +// +//import java.util.ArrayList; +//import java.util.Calendar; +//import java.util.List; +// +//@Component +//@RestController +//@RequestMapping(value = "/connor/wbs") +//public class WBSController { +// private static final Logger log = Logger.getLogger(WBSController.class); +// +// @Autowired +// protected LoginInfo loginInfo; +// +// @RequestMapping(value = "/{projectId}", method = RequestMethod.POST) +// public String updateStatus(@PathVariable String projectId) { +// log.error(String.format("收到请求 wbs:项目ID【%s】",projectId)); +// String json =null; +// List wbsInfos=new ArrayList<>(); +// try{ +//// DataManagementService dmService = KUtil.login(loginInfo.getServer(), loginInfo.getUser(), loginInfo.getPassword()); +// KUtil.setByPass(true); +// +//// String projectFind1= "__EINT_group_members"; +//// String[] proId1 = new String[]{"User"}; +//// String[] proVal1 = new String[]{"3785"}; +//// List groupMember2 = KUtil.query(projectFind1,proId1 ,proVal1); +//// GroupMember groupMember3 =(GroupMember) groupMember2.get(0); +//// +//// if(groupMember3!=null){ +//// KUtil.refreshAndGetProperties(groupMember3,"role"); +//// Role role = groupMember3.get_role(); +//// KUtil.refreshAndGetProperties(role,"object_name"); +//// String role_name = role.getPropertyObject("object_name").getStringValue(); +//// System.out.println(role_name); +////// wbsScheduleInfo.setResourceRole(role_name); +//// } +// String projectFind = "Projects..."; +// String[] proId = new String[]{"项目 ID"}; +// String[] proVal = new String[]{"*"}; +// List projects = KUtil.query(projectFind, proId, proVal); +// System.out.println("projects数量"+projects.size()); +//// String queryName = "Admin - Group/Role Membership"; +//// String[] fields = new String[]{"组"}; +//// String[] values = new String[]{"*"}; +////// ProjectLevelSecurity +//// List name = KUtil.query(queryName, fields, values); +// for(ModelObject pro:projects){ +// WBSInfo wbsInfo=new WBSInfo(); +// wbsInfos.add(wbsInfo); +// TC_Project project = (TC_Project)pro; +// KUtil.refreshAndGetProperties(project, "project_id", "project_name","project_data","xa2_ProjectState"); +// log.error("找到项目:"+project.get_object_string()); +// +// wbsInfo.setProjectname(project.get_project_name()); +// wbsInfo.setProjectid(project.get_project_id()); +// wbsInfo.setProjectstatus(project.getPropertyObject("xa2_ProjectState").getStringValue()); +// ModelObject[] project_data = project.get_project_data(); +// if(project_data.length==0){ +// System.out.println(String.format("未找到时间表\"%s\"", projectId)); +// continue; +// } +// Schedule schedule=null; +// for(ModelObject modelObject :project_data){ +// KUtil.refreshAndGetProperties(modelObject, "object_type"); +// String object_type = modelObject.getPropertyObject("object_type").getStringValue(); +// if(object_type.equals("Schedule")){ +// schedule =(Schedule)modelObject; +// } +// } +// if(schedule==null){ +// continue; +// } +// KUtil.refreshAndGetProperties(schedule, "project_id", "item_id","object_name","fnd0SummaryTask"); +// wbsInfo.setScheduleid(schedule.get_item_id()); +// wbsInfo.setSchedulename(schedule.get_object_name()); +// ScheduleTask fnd0SummaryTask = (ScheduleTask)schedule.get_fnd0SummaryTask(); +// KUtil.refreshAndGetProperties(fnd0SummaryTask, "fnd0TaskTypeString","child_task_taglist"); +//// ScheduleTask[] child_task_taglist = fnd0SummaryTask.get_child_task_taglist(); +// ArrayList child_tasks=new ArrayList<>(); +// KUtil.getChildTask(fnd0SummaryTask,child_tasks); +// System.out.println("child_tasks"+child_tasks.size()); +// List wbsList=new ArrayList<>(); +// for(int i=1;i groupMember2 = KUtil.query(projectFind1,proId1 ,proVal1); +// if(groupMember2.size()>0){ +// GroupMember groupMember3 =(GroupMember) groupMember2.get(0); +// if(groupMember3!=null){ +// KUtil.refreshAndGetProperties(groupMember3,"role"); +// Role role = groupMember3.get_role(); +// KUtil.refreshAndGetProperties(role,"object_name"); +// String role_name = role.getPropertyObject("object_name").getStringValue(); +//// System.out.println(role_name); +// wbsScheduleInfo.setResourceRole(role_name); +// } +// } +// Calendar start_date = scheduleTask.get_start_date(); +// Calendar finish_date = scheduleTask.get_finish_date(); +// Calendar actual_start_date = scheduleTask.get_actual_start_date(); +// Calendar actual_finish_date = scheduleTask.get_actual_finish_date(); +// wbsScheduleInfo.setPlanstartdate(String.valueOf(start_date.get(Calendar.YEAR))+"-"+ +// String.format("%02d",start_date.get(Calendar.MONTH)+1)+"-"+ +// String.format("%02d",start_date.get(Calendar.DATE))+" "+ +// String.format("%02d",start_date.get(Calendar.HOUR))+":"+String.format("%02d",start_date.get(Calendar.MINUTE))); +// wbsScheduleInfo.setPlanfinishdate(String.valueOf(finish_date.get(Calendar.YEAR))+"-"+ +// String.format("%02d",finish_date.get(Calendar.MONTH)+1)+"-"+ +// String.format("%02d",finish_date.get(Calendar.DATE))+" "+ +// String.format("%02d",finish_date.get(Calendar.HOUR))+":"+String.format("%02d",finish_date.get(Calendar.MINUTE))); +// if(actual_start_date!=null){ +// wbsScheduleInfo.setActualstartdate(String.valueOf(actual_start_date.get(Calendar.YEAR))+"-"+ +// String.format("%02d",actual_start_date.get(Calendar.MONTH)+1)+"-"+ +// String.format("%02d",actual_start_date.get(Calendar.DATE))+" "+ +// String.format("%02d",actual_start_date.get(Calendar.HOUR))+":"+ +// String.format("%02d",actual_start_date.get(Calendar.MINUTE))); +// }if(actual_finish_date!=null){ +// wbsScheduleInfo.setActualfinishdate(String.valueOf(actual_finish_date.get(Calendar.YEAR))+"-"+ +// String.format("%02d",actual_finish_date.get(Calendar.MONTH)+1)+"-"+ +// String.format("%02d",actual_finish_date.get(Calendar.DATE))+" "+ +// String.format("%02d",actual_finish_date.get(Calendar.HOUR))+":"+ +// String.format("%02d",actual_finish_date.get(Calendar.MINUTE))); +// } +// wbsScheduleInfo.setTaskstate(scheduleTask.getPropertyObject("fnd0state").getDisplayableValue()); +// wbsScheduleInfo.setTasktype(scheduleTask.get_task_type()==0?"普通":"里程碑"); +// wbsScheduleInfo.setWorkestimate(scheduleTask.get_fnd0WorkEffortString()); +// wbsScheduleInfo.setWorkcomplete(scheduleTask.get_fnd0WorkCompleteString()); +// EPMTaskTemplate workflow_template = scheduleTask.get_workflow_template(); +// if(workflow_template !=null){ +// KUtil.refreshAndGetProperties(workflow_template, "object_name"); +// wbsScheduleInfo.setTaskworkflow(workflow_template.get_object_name()); +// } +// ModelObject[] fnd0AllWorkflows = scheduleTask.get_fnd0AllWorkflows(); +// if(fnd0AllWorkflows.length!=0){ +// EPMTask fnd0AllWorkflow = (EPMTask) fnd0AllWorkflows[0]; +// KUtil.refreshAndGetProperties(fnd0AllWorkflow, "object_name","fnd0StartedTasks","fnd0StartDate","fnd0EndDate"); +// EPMTask[] fnd0StartedTasks = fnd0AllWorkflow.get_fnd0StartedTasks(); +// if(fnd0StartedTasks.length!=0){ +// KUtil.refreshAndGetProperties(fnd0StartedTasks[0], "object_name"); +// wbsScheduleInfo.setWorkflownode(fnd0StartedTasks[0].get_object_name()); +// } +// Calendar fnd0StartDate = fnd0AllWorkflow.get_fnd0StartDate(); +// wbsScheduleInfo.setWorkflowstartdate(String.valueOf(fnd0StartDate.get(Calendar.YEAR))+"-"+ +// String.format("%02d",fnd0StartDate.get(Calendar.MONTH)+1)+"-"+ +// String.format("%02d",fnd0StartDate.get(Calendar.DATE))+" "+ +// String.format("%02d",fnd0StartDate.get(Calendar.HOUR))+":"+ +// String.format("%02d",fnd0StartDate.get(Calendar.MINUTE))); +// Calendar fnd0EndDate = fnd0AllWorkflow.get_fnd0EndDate(); +// if(fnd0EndDate!=null){ +// wbsScheduleInfo.setWorkflowfinishdate(String.valueOf(fnd0EndDate.get(Calendar.YEAR))+"-"+ +// String.format("%02d",fnd0EndDate.get(Calendar.MONTH)+1)+"-"+ +// String.format("%02d",fnd0EndDate.get(Calendar.DATE))+" "+ +// String.format("%02d",fnd0EndDate.get(Calendar.HOUR))+":"+ +// String.format("%02d",fnd0EndDate.get(Calendar.MINUTE))); +// } +// } +// wbsList.add(wbsScheduleInfo); +// } +// wbsInfo.setEntry(wbsList); +// } +// +//// log.error("登录信息:"+loginInfo.getServer()+" -> "+loginInfo.getUser()); +// +//// if(KUtil.isEmpty(projectId)){ +//// throw new Exception("项目ID不能为空"); +//// } +// +//// int proCnt = projects==null?0:projects.size(); +//// log.error("查询到项目数量:"+proCnt); +//// if(proCnt==0){ +//// throw new Exception(String.format("未找到项目\"%s\"", projectId)); +//// } +//// if(proCnt>1){ +//// throw new Exception(String.format("查询到多个项目\"%s\",异常数量%d", projectId, proCnt)); +//// } +// +// +// +//// ModelObject[] forms = project.get_IMAN_master_form_rev(); +//// if(KUtil.getLen(forms)==0){ +//// throw new Exception("获取版本主属性表单失败:"+rev.get_object_string()); +//// } +//// ModelObject form = forms[0]; +//// KUtil.refreshAndGetProperties(form, "object_string"); +//// String propName = queryInfo.getProperty(); +//// log.error("更新属性:"+propName +" = ["+status+"]"); +//// KUtil.setProperty(form, propName, status); +//// log.error("更新完成"); +// }catch (Exception e){ +// e.printStackTrace(); +// log.error("发生异常",e); +// return KUtil.getMessage(e); +// }finally { +//// KUtil.logoutAndClearCache2(); +// } +//// Message message=new Message(); +//// message.setMessage("传递成功"); +// json= JSON.toJSONString(wbsInfos); +// +// return json; +// } +//} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/controller/changeNoticeController.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/controller/changeNoticeController.java new file mode 100644 index 0000000..e47074f --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/controller/changeNoticeController.java @@ -0,0 +1,124 @@ +//package com.connor.connor_cpzc_service.controller; +// +//import com.alibaba.fastjson.JSON; +//import com.alibaba.fastjson.JSONObject; +//import com.connor.connor_cpzc_service.info.*; +//import com.connor.connor_cpzc_service.util.KUtil; +//import com.teamcenter.services.strong.core.DataManagementService; +//import com.teamcenter.soa.client.model.ModelObject; +//import com.teamcenter.soa.client.model.Property; +//import com.teamcenter.soa.client.model.ServiceData; +//import com.teamcenter.soa.client.model.strong.Item; +//import com.teamcenter.soa.client.model.strong.ItemRevision; +//import com.teamcenter.soa.client.model.strong.TC_Project; +//import com.teamcenter.soa.client.model.strong.User; +//import org.apache.log4j.Logger; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.stereotype.Component; +//import org.springframework.web.bind.annotation.PathVariable; +//import org.springframework.web.bind.annotation.RequestMapping; +//import org.springframework.web.bind.annotation.RequestMethod; +//import org.springframework.web.bind.annotation.RestController; +// +//import java.util.ArrayList; +//import java.util.Calendar; +//import java.util.List; +// +//@Component +//@RestController +//@RequestMapping(value = "/connor/bgtz") +//public class changeNoticeController{ +// private static final Logger log = Logger.getLogger(WBSController.class); +// +// @Autowired +// protected LoginInfo loginInfo; +// @RequestMapping(value = "/{projectId}", method = RequestMethod.POST) +// public String changeNotice(@PathVariable String projectId) { +// log.error(String.format("收到请求变更:项目ID【%s】",projectId)); +// String json =""; +// +// List wbsInfos=new ArrayList<>(); +// try { +//// DataManagementService dmService = KUtil.login(loginInfo.getServer(), loginInfo.getUser(), loginInfo.getPassword()); +// KUtil.setByPass(true); +// String projectFind = "Projects..."; +// String[] proId = new String[]{"项目 ID"}; +// String[] proVal = new String[]{"*"}; +// List projects = KUtil.query(projectFind, proId, proVal); +// System.out.println("projects数量"+projects.size()); +// +// for (ModelObject pro:projects){ +// ChangeEntry changeEntry=new ChangeEntry(); +// wbsInfos.add(changeEntry); +// TC_Project project = (TC_Project)pro; +// KUtil.refreshAndGetProperties(project, "project_id", "project_name", "project_data","TC_Program_Preferred_Items","xa2_ProjectState"); +// log.error("找到项目:" + project.get_object_string()); +// ModelObject[] items = project.get_project_data(); +// changeEntry.setProjectid(project.get_project_id()); +// changeEntry.setProjectstatus(project.getPropertyObject("xa2_ProjectState").getStringValue()); +// changeEntry.setProjectname(project.get_project_name()); +// List changeList=new ArrayList<>(); +// System.out.println("获取对的project_data"+items.length); +// if(items.length>0){ +// for(int i=0;i< items.length;i++){ +// ModelObject modelObject = items[i]; +// +// KUtil.refreshAndGetProperties(modelObject, "object_type","item_id","object_name","revision_list","creation_date"); +// System.out.println(modelObject.getPropertyObject("object_type").getStringValue()); +// if(modelObject.getPropertyObject("object_type").getStringValue().equals("ChangeNotice")){ +// ChangeMesEntry changeMesEntry=new ChangeMesEntry(); +//// changeMesEntry.setChangereason(modelObject.getPropertyObject("xa2_changereason").getStringValue()); +// changeMesEntry.setChangenoticeid(modelObject.getPropertyObject("item_id").getStringValue()); +// changeMesEntry.setChangenoticename(modelObject.getPropertyObject("object_name").getStringValue()); +// User owning_user =(User) modelObject.getPropertyObject("owning_user").getModelObjectValue(); +// KUtil.refreshAndGetProperties(owning_user, "user_name"); +// changeMesEntry.setChangenoticeowner(owning_user.get_user_name()); +// List itemsList=new ArrayList<>(); +// ModelObject[] revision_list = modelObject.getPropertyObject("revision_list").getModelObjectArrayValue(); +// ItemRevision item_revision =(ItemRevision) revision_list[revision_list.length - 1]; +// KUtil.refreshAndGetProperties(item_revision, "current_revision_id","CMHasProblemItem","xa2_changereason"); +// String xa2_changereason = item_revision.getPropertyObject("xa2_changereason").getStringValue(); +// changeMesEntry.setChangereason(xa2_changereason); +// Calendar start_date = modelObject.getPropertyObject("creation_date").getCalendarValue(); +// changeMesEntry.setChangenoticecreationdate(String.valueOf(start_date.get(Calendar.YEAR))+"-"+ +// String.format("%02d",start_date.get(Calendar.MONTH)+1)+"-"+ +// String.format("%02d",start_date.get(Calendar.DATE))+" "+ +// String.format("%02d",start_date.get(Calendar.HOUR))+":"+ +// String.format("%02d",start_date.get(Calendar.MINUTE))); +// changeList.add(changeMesEntry); +// System.out.println(item_revision.get_current_revision_id()+"reason"+xa2_changereason); +// ModelObject[] rb3_clyfbms = item_revision.getPropertyObject("CMHasProblemItem").getModelObjectArrayValue(); +// for(int t=0;t< rb3_clyfbms.length;t++){ +// ChangeItems changeItems=new ChangeItems(); +// KUtil.refreshAndGetProperties(rb3_clyfbms[t], "item_id","object_name","object_type"); +// changeItems.setChangeitemid(rb3_clyfbms[t].getPropertyObject("item_id").getStringValue()); +// changeItems.setChangeitemtype(rb3_clyfbms[t].getPropertyObject("object_type").getStringValue()); +// changeItems.setChangeitemname(rb3_clyfbms[t].getPropertyObject("object_name").getStringValue()); +// itemsList.add(changeItems); +// } +// changeMesEntry.setItem(itemsList); +// } +// } +// } +// if(changeList.size()==0){ +// System.out.println("不存在"); +// ChangeMesEntry changeMesEntry=new ChangeMesEntry(); +// changeList.add(changeMesEntry); +// } +// changeEntry.setEntry(changeList); +// } +// +// +// }catch (Exception e){ +// e.printStackTrace(); +// log.error(e); +// +// }finally { +//// KUtil.logoutAndClearCache2(); +// } +//// changeEntry.setMessage(new Message()); +// json= JSON.toJSONString(wbsInfos); +// return json; +// } +// +//} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/info/ChangeEntry.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/info/ChangeEntry.java new file mode 100644 index 0000000..212b245 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/info/ChangeEntry.java @@ -0,0 +1,50 @@ +package com.connor.connor_cpzc_service.info; + +import com.alibaba.fastjson.annotation.JSONField; + +import java.util.List; + +public class ChangeEntry { + @JSONField(name="Projectid") + private String Projectid=""; + + public String getProjectid() { + return Projectid; + } + + public void setProjectid(String projectid) { + Projectid = projectid; + } + + public String getProjectname() { + return Projectname; + } + + public void setProjectname(String projectname) { + Projectname = projectname; + } + + public List getEntry() { + return entry; + } + + public void setEntry(List entry) { + this.entry = entry; + } + + public String getProjectstatus() { + return Projectstatus; + } + + public void setProjectstatus(String projectstatus) { + Projectstatus = projectstatus; + } + + @JSONField(name="Projectstatus") + private String Projectstatus; + + @JSONField(name="Projectname") + private String Projectname=""; + private List entry; + +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/info/ChangeItems.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/info/ChangeItems.java new file mode 100644 index 0000000..353e8e4 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/info/ChangeItems.java @@ -0,0 +1,36 @@ +package com.connor.connor_cpzc_service.info; + +import com.alibaba.fastjson.annotation.JSONField; + +public class ChangeItems { + @JSONField(name = "Changeitemid") + private String Changeitemid = ""; + @JSONField(name = "Changeitemname") + private String Changeitemname = ""; + + public String getChangeitemtype() { + return Changeitemtype; + } + + public void setChangeitemtype(String changeitemtype) { + Changeitemtype = changeitemtype; + } + + @JSONField(name = "Changeitemtype") + private String Changeitemtype=""; + public String getChangeitemid() { + return Changeitemid; + } + + public void setChangeitemid(String changeitemid) { + Changeitemid = changeitemid; + } + + public String getChangeitemname() { + return Changeitemname; + } + + public void setChangeitemname(String changeitemname) { + Changeitemname = changeitemname; + } +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/info/ChangeMesEntry.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/info/ChangeMesEntry.java new file mode 100644 index 0000000..732d286 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/info/ChangeMesEntry.java @@ -0,0 +1,72 @@ +package com.connor.connor_cpzc_service.info; + +import com.alibaba.fastjson.annotation.JSONField; + +import java.util.List; + +public class ChangeMesEntry { + @JSONField(name="Changenoticeid") + private String Changenoticeid=""; + @JSONField(name="Changenoticename") + private String Changenoticename=""; + @JSONField(name="Changenoticeowner") + private String Changenoticeowner=""; + + + public String getChangenoticecreationdate() { + return Changenoticecreationdate; + } + + public void setChangenoticecreationdate(String changenoticecreationdate) { + Changenoticecreationdate = changenoticecreationdate; + } + + @JSONField(name="Changenoticecreationdate") + private String Changenoticecreationdate=""; + + public List getItem() { + return item; + } + + public void setItem(List item) { + this.item = item; + } + + public String getChangereason() { + return Changereason; + } + + public void setChangereason(String changereason) { + Changereason = changereason; + } + + @JSONField(name="Changereason") + private String Changereason=""; + private List item; + + public String getChangenoticeid() { + return Changenoticeid; + } + + public void setChangenoticeid(String changenoticeid) { + Changenoticeid = changenoticeid; + } + + public String getChangenoticename() { + return Changenoticename; + } + + public void setChangenoticename(String changenoticename) { + Changenoticename = changenoticename; + } + + public String getChangenoticeowner() { + return Changenoticeowner; + } + + public void setChangenoticeowner(String changenoticeowner) { + Changenoticeowner = changenoticeowner; + } + + +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/info/DesignInfoBean.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/info/DesignInfoBean.java new file mode 100644 index 0000000..3824945 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/info/DesignInfoBean.java @@ -0,0 +1,35 @@ +package com.connor.connor_cpzc_service.info; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.List; + +public class DesignInfoBean { + + private List file; + + @JsonProperty("Desc") + private String desc; + + + public DesignInfoBean(List file, String desc_String) { + this.file = file; + this.desc = desc_String; + } + + public List getFile() { + return file; + } + + public void setFile(List file) { + this.file = file; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + desc = desc; + } +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/info/FileInfoBean.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/info/FileInfoBean.java new file mode 100644 index 0000000..fb73be0 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/info/FileInfoBean.java @@ -0,0 +1,30 @@ +package com.connor.connor_cpzc_service.info; + +/** + * Created by K on 2019/8/13. + */ +public class FileInfoBean { + private String id; + private String name; + + public FileInfoBean(String id, String name) { + this.id = id; + this.name = name; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/info/JFWEntry.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/info/JFWEntry.java new file mode 100644 index 0000000..55766e9 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/info/JFWEntry.java @@ -0,0 +1,50 @@ +package com.connor.connor_cpzc_service.info; + +import com.alibaba.fastjson.annotation.JSONField; + +import java.util.List; + +public class JFWEntry { + @JSONField(name="Projectid") + private String Projectid=""; + @JSONField(name="Projectname") + private String Projectname=""; + + + public String getProjectstatus() { + return Projectstatus; + } + + public void setProjectstatus(String projectstatus) { + Projectstatus = projectstatus; + } + + @JSONField(name="Projectstatus") + private String Projectstatus; + private List entry; + + + public String getProjectid() { + return Projectid; + } + + public void setProjectid(String projectid) { + Projectid = projectid; + } + + public String getProjectname() { + return Projectname; + } + + public void setProjectname(String projectname) { + Projectname = projectname; + } + + public List getEntry() { + return entry; + } + + public void setEntry(List entry) { + this.entry = entry; + } +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/info/JFWMesEntry.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/info/JFWMesEntry.java new file mode 100644 index 0000000..150d63e --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/info/JFWMesEntry.java @@ -0,0 +1,50 @@ +package com.connor.connor_cpzc_service.info; + +import com.alibaba.fastjson.annotation.JSONField; + +import javax.swing.*; + +public class JFWMesEntry { + @JSONField(name="Deliverid") + private String Deliverid=""; + @JSONField(name="Delivername") + private String Delivername=""; + @JSONField(name="Deliverowner") + private String Deliverowner=""; + + public String getDeliverid() { + return Deliverid; + } + + public void setDeliverid(String deliverid) { + Deliverid = deliverid; + } + + public String getDelivername() { + return Delivername; + } + + public void setDelivername(String delivername) { + Delivername = delivername; + } + + public String getDeliverowner() { + return Deliverowner; + } + + public void setDeliverowner(String deliverowner) { + Deliverowner = deliverowner; + } + + public String getDeliverstatus() { + return Deliverstatus; + } + + public void setDeliverstatus(String deliverstatus) { + Deliverstatus = deliverstatus; + } + + @JSONField(name="Deliverstatus") + private String Deliverstatus; + +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/info/LoginInfo.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/info/LoginInfo.java new file mode 100644 index 0000000..d2e8130 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/info/LoginInfo.java @@ -0,0 +1,82 @@ +package com.connor.connor_cpzc_service.info; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +@Component +@ConfigurationProperties(prefix = "tc") +public class LoginInfo { + + private String server; + private String user; + private String password; + private String fmsUrl; + private String fmstemp; + private Integer exeSize; + private Integer errorExeSize; + private String overtime; + + public String getOvertime() { + return overtime; + } + + public void setOvertime(String overtime) { + this.overtime = overtime; + } + + public Integer getErrorExeSize() { + return errorExeSize; + } + + public void setErrorExeSize(Integer errorExeSize) { + this.errorExeSize = errorExeSize; + } + + public Integer getExeSize() { + return exeSize; + } + + public void setExeSize(Integer exeSize) { + this.exeSize = exeSize; + } + + public String getFmstemp() { + return fmstemp; + } + + public void setFmstemp(String fmstemp) { + this.fmstemp = fmstemp; + } + + public String getFmsUrl() { + return fmsUrl; + } + + public void setFmsUrl(String fmsUrl) { + this.fmsUrl = fmsUrl; + } + + public String getServer() { + return server; + } + + public void setServer(String server) { + this.server = server; + } + + public String getUser() { + return user; + } + + public void setUser(String user) { + this.user = user; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/info/RiskEntry.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/info/RiskEntry.java new file mode 100644 index 0000000..f57db3a --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/info/RiskEntry.java @@ -0,0 +1,55 @@ +package com.connor.connor_cpzc_service.info; + +import com.alibaba.fastjson.annotation.JSONField; + +import java.util.List; + +public class RiskEntry { + @JSONField(name="Projectid") + private String Projectid=""; + @JSONField(name="Projectname") + private String Projectname=""; + + public String getProjectstatus() { + return Projectstatus; + } + + public void setProjectstatus(String projectstatus) { + Projectstatus = projectstatus; + } + + @JSONField(name="Projectstatus") + private String Projectstatus; + private List entry; + public String getProjectid() { + return Projectid; + } + + public void setProjectid(String projectid) { + Projectid = projectid; + } + + public String getProjectname() { + return Projectname; + } + + public void setProjectname(String projectname) { + Projectname = projectname; + } + + public List getEntry() { + return entry; + } + + public void setEntry(List entry) { + this.entry = entry; + } + +// public Message getMessage() { +// return message; +// } +// +// public void setMessage(Message message) { +// this.message = message; +// } +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/info/RiskMesEntry.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/info/RiskMesEntry.java new file mode 100644 index 0000000..76d5254 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/info/RiskMesEntry.java @@ -0,0 +1,58 @@ +package com.connor.connor_cpzc_service.info; + +import com.alibaba.fastjson.annotation.JSONField; + +public class RiskMesEntry { + + @JSONField(name="Lessonslearnedid") + private String Lessonslearnedid=""; + @JSONField(name="Lessonslearnedname") + private String Lessonslearnedname=""; + + public String getLessonslearnedid() { + return Lessonslearnedid; + } + + public void setLessonslearnedid(String lessonslearnedid) { + Lessonslearnedid = lessonslearnedid; + } + + public String getLessonslearnedname() { + return Lessonslearnedname; + } + + public void setLessonslearnedname(String lessonslearnedname) { + Lessonslearnedname = lessonslearnedname; + } + + public String getLessonslearnedowner() { + return Lessonslearnedowner; + } + + public void setLessonslearnedowner(String lessonslearnedowner) { + Lessonslearnedowner = lessonslearnedowner; + } + + public String getFaultdescription() { + return Faultdescription; + } + + public void setFaultdescription(String faultdescription) { + Faultdescription = faultdescription; + } + + public String getAnalysisdescription() { + return Analysisdescription; + } + + public void setAnalysisdescription(String analysisdescription) { + Analysisdescription = analysisdescription; + } + + @JSONField(name="Lessonslearnedowner") + private String Lessonslearnedowner=""; + @JSONField(name="Faultdescription") + private String Faultdescription=""; + @JSONField(name="Analysisdescription") + private String Analysisdescription=""; +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/info/WBSInfo.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/info/WBSInfo.java new file mode 100644 index 0000000..b5d94fc --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/info/WBSInfo.java @@ -0,0 +1,79 @@ +package com.connor.connor_cpzc_service.info; + +import com.alibaba.fastjson.annotation.JSONField; +import org.springframework.stereotype.Component; + +import java.util.List; + +@Component +public class WBSInfo { + @JSONField(name="Projectid") + private String Projectid; + @JSONField(name="Projectname") + private String Projectname; + @JSONField(name="Scheduleid") + private String Scheduleid; + @JSONField(name="Schedulename") + private String Schedulename; + + public String getProjectstatus() { + return Projectstatus; + } + + public void setProjectstatus(String projectstatus) { + Projectstatus = projectstatus; + } + + @JSONField(name="Projectstatus") + private String Projectstatus; + private List entry; + +// public Message getMessage() { +// return message; +// } +// +// public void setMessage(Message message) { +// this.message = message; +// } +// +// private Message message; +// public String getProjectid() { +// return Projectid; +// } + + public void setProjectid(String projectid) { + this.Projectid = projectid; + } + + public String getProjectname() { + return Projectname; + } + + public void setProjectname(String projectname) { + this.Projectname = projectname; + } + + public String getScheduleid() { + return Scheduleid; + } + + public void setScheduleid(String scheduleid) { + this.Scheduleid = scheduleid; + } + + public String getSchedulename() { + return Schedulename; + } + + public void setSchedulename(String schedulename) { + this.Schedulename = schedulename; + } + + public List getEntry() { + return entry; + } + + public void setEntry(List entry) { + this.entry = entry; + } +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/info/WBSScheduleInfo.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/info/WBSScheduleInfo.java new file mode 100644 index 0000000..a183244 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/info/WBSScheduleInfo.java @@ -0,0 +1,166 @@ +package com.connor.connor_cpzc_service.info; + +import com.alibaba.fastjson.annotation.JSONField; + +public class WBSScheduleInfo { + @JSONField(name="Taskname") + private String Taskname=""; + @JSONField(name="Resource") + private String Resource=""; + @JSONField(name="ResourceGroup") + private String ResourceGroup=""; + @JSONField(name="ResourceRole") + private String ResourceRole=""; + @JSONField(name="Planstartdate") + private String Planstartdate=""; + @JSONField(name="Planfinishdate") + private String Planfinishdate=""; + @JSONField(name="actualstartdate") + private String actualstartdate=""; + @JSONField(name="actualfinishdate") + private String actualfinishdate=""; + @JSONField(name="Taskstate") + private String Taskstate=""; + @JSONField(name="Tasktype") + private String Tasktype=""; + @JSONField(name="Workestimate") + private String Workestimate=""; + @JSONField(name="Workcomplete") + private String Workcomplete=""; + @JSONField(name="Taskworkflow") + private String Taskworkflow=""; + @JSONField(name="Workflownode") + private String Workflownode=""; + @JSONField(name="Workflowstartdate") + private String Workflowstartdate=""; + @JSONField(name="Workflowfinishdate") + private String Workflowfinishdate=""; + + public String getTaskname() { + return Taskname; + } + + public void setTaskname(String taskname) { + this.Taskname = taskname; + } + + public String getResource() { + return Resource; + } + + public void setResource(String resource) { + this.Resource = resource; + } + + public String getResourceGroup() { + return ResourceGroup; + } + + public void setResourceGroup(String resourceGroup) { + this.ResourceGroup = resourceGroup; + } + + public String getResourceRole() { + return ResourceRole; + } + + public void setResourceRole(String resourceRole) { + this.ResourceRole = resourceRole; + } + + public String getPlanstartdate() { + return Planstartdate; + } + + public void setPlanstartdate(String planstartdate) { + this.Planstartdate = planstartdate; + } + + public String getPlanfinishdate() { + return Planfinishdate; + } + + public void setPlanfinishdate(String planfinishdate) { + this.Planfinishdate = planfinishdate; + } + + public String getActualstartdate() { + return actualstartdate; + } + + public void setActualstartdate(String actualstartdate) { + this.actualstartdate = actualstartdate; + } + + public String getActualfinishdate() { + return actualfinishdate; + } + + public void setActualfinishdate(String actualfinishdate) { + this.actualfinishdate = actualfinishdate; + } + + public String getTaskstate() { + return Taskstate; + } + + public void setTaskstate(String taskstate) { + this.Taskstate = taskstate; + } + + public String getTasktype() { + return Tasktype; + } + + public void setTasktype(String tasktype) { + this.Tasktype = tasktype; + } + + public String getWorkestimate() { + return Workestimate; + } + + public void setWorkestimate(String workestimate) { + this.Workestimate = workestimate; + } + + public String getWorkcomplete() { + return Workcomplete; + } + + public void setWorkcomplete(String workcomplete) { + this.Workcomplete = workcomplete; + } + + public String getTaskworkflow() { + return Taskworkflow; + } + + public void setTaskworkflow(String taskworkflow) { + this.Taskworkflow = taskworkflow; + } + + public String getWorkflownode() { + return Workflownode; + } + + public void setWorkflownode(String workflownode) { + this.Workflownode = workflownode; + } + + public String getWorkflowstartdate() { + return Workflowstartdate; + } + + public void setWorkflowstartdate(String workflowstartdate) { + this.Workflowstartdate = workflowstartdate; + } + + public String getWorkflowfinishdate() { + return Workflowfinishdate; + } + + public void setWorkflowfinishdate(String workflowfinishdate) { + this.Workflowfinishdate = workflowfinishdate; + } +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/mapper/EPMMapper.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/mapper/EPMMapper.java new file mode 100644 index 0000000..8ddbf63 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/mapper/EPMMapper.java @@ -0,0 +1,291 @@ +package com.connor.connor_cpzc_service.mapper; + +import com.connor.connor_cpzc_service.bean.MdmDs.MomRuleBean; +import com.connor.connor_cpzc_service.bean.MdmDs.SapMsg; +import com.connor.connor_cpzc_service.bean.SapResult; +import com.connor.connor_cpzc_service.bean.SapSumBean; +//import org.apache.ibatis.annotations.*; +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Results; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Result; +import org.apache.ibatis.annotations.Update; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.type.JdbcType; + +import java.util.List; + +@Mapper +public interface EPMMapper { + + /** + * 错误数据处理时新插入一条CODE + */ + @Insert("insert INTO \"CHINT_BOM_TO_SAP_SUM\" ("+ + "\"CODE\", " + + "\"FACTORY\", " + + "\"PROJECTUID\", " + + "\"USER\", " + + "\"KEYMSG\", " + + "\"STARTTIME\", " + + "\"WBSNO\", " + + "\"PROJECTNO\", " + + "\"SAPRESULT\", "+ + "\"TRANSFER\", " + + "\"OLDTASKCODE\", "+ + "\"LASTTASKCODE\", "+ + "\"SERVERHOST\", " + + "\"USERID\", "+ + "\"PLMRESULT\", "+ + "\"PLMSTARTTIME\", "+ + "\"TASKSTAUTS\""+ + ")"+ + "VALUES("+ + "#{code}, "+ + "#{factory,jdbcType=VARCHAR}, "+ + "#{projectUid,jdbcType=VARCHAR}, "+ + "#{user,jdbcType=VARCHAR}, "+ + "#{keyMsg, jdbcType = LONGVARBINARY}, "+ + "to_date(#{starttime},'yyyy-mm-ddhh24:mi:ss'), "+ + "#{wbsno,jdbcType=VARCHAR}, "+ + "#{projectno,jdbcType=VARCHAR}, "+ + "#{sapresult,jdbcType=VARCHAR} ,"+ + "#{transfer,jdbcType=VARCHAR}, "+ + "#{oldtaskcode}, "+ + "#{lasttaskcode}, "+ + "#{serverhost,jdbcType=VARCHAR}, "+ + "#{userid,jdbcType=VARCHAR}, "+ + "'未处理',SYSDATE, '组织中'"+ + ")" + ) + void insertErrorTask(SapSumBean bean); + + /** + * 查询异常的CODE数据 + * + * @return + */ + @Select("SELECT * FROM CHINT_BOM_TO_SAP_SUM WHERE taskstauts = '组织中' " + + "and PLMFINISHTIME is NULL and PLMSTARTTIME < SYSDATE - INTERVAL '30' MINUTE " + + "order by CODE desc") + @Results(id = "SapSuMapError", value = { + @Result(column = "keyMsg", property = "keyMsg", javaType = String.class, jdbcType = JdbcType.LONGVARBINARY), + @Result(column = "code", property = "code"), + @Result(column = "factory", property = "factory"), + @Result(column = "projectUid", property = "projectUid"), + @Result(column = "user", property = "user"), + @Result(column = "starttime", property = "starttime"), + @Result(column = "wbsno", property = "wbsno"), + @Result(column = "projectno", property = "projectno"), + @Result(column = "sapresult", property = "sapresult"), + @Result(column = "transfer", property = "transfer"), + @Result(column = "oldtaskcode", property = "oldtaskcode"), + @Result(column = "lasttaskcode", property = "lasttaskcode"), + @Result(column = "serverhost", property = "serverhost"), + @Result(column = "userid", property = "userid") + }) + List findErrorMessage(); + + /** + * 查询需要传递的code信息 + * + * @return + */ + @Select("select keyMsg,code,factory,projectUid,\"USER\" from CHINT_BOM_TO_SAP_SUM where taskstauts = '等待组织' and PROJECTUID is not NULL order by code") + @Results(id = "SapSuMap", value = { + @Result(column = "keyMsg", property = "keyMsg", javaType = String.class, jdbcType = JdbcType.LONGVARBINARY), + @Result(column = "code", property = "code"), + @Result(column = "factory", property = "factory"), + @Result(column = "projectUid", property = "projectUid"), + @Result(column = "USER", property = "user") + }) + List findSendMessage(); + + /** + * 发送飞书通知时获取需要的信息 + * @param code + * @return + */ + @Select("select keyMsg,code,factory,projectUid,user from CHINT_BOM_TO_SAP_SUM where code = #{code}") + @Results(id = "SapSumMap", value = { + @Result(column = "keyMsg", property = "keyMsg", javaType = String.class, jdbcType = JdbcType.LONGVARBINARY), + @Result(column = "code", property = "code"), + @Result(column = "factory", property = "factory"), + @Result(column = "projectUid", property = "projectUid"), + @Result(column = "user", property = "user") + }) + List findKeyMessage(String code); + /** + * 根据序列获取最大CODE + * @return + */ + @Select("select COUNT(*) from CHINT_BOM_TO_SAP_SUM where oldtaskcode = #{code} ") + int getNumOfError(String code); + /** + * 根据序列获取最大CODE + * @return + */ + @Select("select Tab_SendBom_Sequence.nextval as sid from dual") + int getCode(); + + /** + * 定时任务处理传递时更新状态 + * @param code + * @return + */ + @Update("update CHINT_BOM_TO_SAP_SUM set taskstauts = '组织中',plmstarttime = SYSDATE where CODE = #{code} ") + int updateTaskStatus(String code); + + /** + * 异常处理时更新状态 + * @param code + * @return + */ + @Update("update CHINT_BOM_TO_SAP_SUM set taskstauts = '异常处理' where CODE = #{code} ") + int updateTaskError(String code); + // @Select("select POBJECT_NAME from PWORKSPACEOBJECT where puid = (select PUID from PITEM + // where PITEM_ID = #{ID})") + @Select( + "select MAX(PITEM_REVISION_ID) from PITEMREVISION where RITEMS_TAGU = (select PUID from PITEM where PITEM_ID = #{ID})") + String getName(@Param("ID") String ID); + + @Select( + "select PDBINDEX from PSMLB1 where rtag_to_headeru = 'wjgRvS7Fpof3PC' and PUNCT = #{PUNCT}") + String getPunct(@Param("PUNCT") String PUNCT); // wjgRvS7Fpof3PC xoiRKNuxbJ7sDB + + @Select("${value}") + List selectBj(@Param("value") String value); + + @Insert( + "INSERT into CHINT_CSH VALUES (#{ID},#{name},#{designId},#{saveTime},#{saveDate},#{uid},#{wareTime},#{revision})") + void insertIntoLog( + @Param("ID") String ID, + @Param("name") String name, + @Param("designId") String designId, + @Param("saveTime") String saveTime, + @Param("saveDate") String saveDate, + @Param("uid") String uid, + @Param("wareTime") String wareTime, + @Param("revision") String revision); + +// @Select({ +// "" +// }) +// List selectRuleBean(@Param("psmCodes") List psmCodes); +@Select({ + "" +}) +List selectRuleBean(@Param("psmCodes") List psmCodes,@Param("factory")String factory); + + @Select({ + "" + }) + List selectRuleBean2( + @Param("psmCodes") List psmCodes, @Param("drawingno") String drawingno); + + @Select( + "select puid from CHINT_BOM_TO_SAP_DETIALS where CODE = #{batchnumber,jdbcType=VARCHAR} and status is null ") + List getStatus(String batchnumber); + + // 获取失败信息 + @Select( + "select DISTINCT(MESSAGE) from CHINT_BOM_TO_SAP_DETIALS where CODE = #{batchnumber,jdbcType=VARCHAR} and status = 'E' ") + List getErrorReason(String batchnumber); + + // 失败的产成品 + @Select( + "select DISTINCT(PRODUCTMATERIALNO) from CHINT_BOM_TO_SAP_DETIALS where code = #{batchnumber} and status = 'E' ") + List getErrCpp(String batchnumber); + + // 所有产成品 + @Select( + "select DISTINCT(PRODUCTMATERIALNO) from CHINT_BOM_TO_SAP_DETIALS where code = #{batchnumber} ") + List getAllCpp(String batchnumber); + + /** + * 获取失败BOM总数 + * + * @param batchnumber + * @return + */ + @Select( + "select COUNT(*) from CHINT_BOM_TO_SAP_DETIALS where CODE = #{batchnumber,jdbcType=VARCHAR} and status = 'E' ") + Integer getErrorBomCount(String batchnumber); + + /** + * 获取BOM总数 + * + * @param batchnumber + * @return + */ + @Select( + "select COUNT(*) from CHINT_BOM_TO_SAP_DETIALS where code = #{batchnumber} ") + Integer getBomCount(String batchnumber); + + // 更新TC属性 + @Select( + "select PUID,productmaterialno from CHINT_BOM_TO_SAP_DETIALS where code = #{batchnumber} and status = 'S' ") + List getSuccessPart(String batchnumber); + + @Select( + "select starttime,wbsno,projectno,transfer,SAPRESULT,USERID,\"USER\",factory from CHINT_BOM_TO_SAP_SUM where CODE = #{code,jdbcType=VARCHAR} ") + List getSumMessage(String code); + + @Update( + "update CHINT_BOM_TO_SAP_SUM set SAPRESULT = #{sapResult,jdbcType=VARCHAR} , " + + " PLMRESULT = '已飞书通知',SAPENDTIME = SYSDATE where CODE = #{code} ") + int updateSAPSum(String code, String sapResult); + + @Update("update CHINT_BOM_TO_SAP_SUM set PLMENDTIME = SYSDATE where CODE = #{code} ") + int updatePLMEnd(String code); + + @Update( + "update CHINT_BOM_TO_SAP_DETIALS set message = #{message,jdbcType=VARCHAR} , " + + " status = #{status,jdbcType=VARCHAR}," + + " createdate = #{createdate,jdbcType=VARCHAR}, " + + " createtime = #{createtime,jdbcType=VARCHAR}, " + + " returndate = #{returndate,jdbcType=VARCHAR}, " + + " returntime = #{returntime,jdbcType=VARCHAR}, " + + " PLMSENDFINISHTIME = sysdate, " + + " PLMSTATUS = '已处理数据' " + + " where batchnumber = #{batchnumber,jdbcType=VARCHAR} and puid = #{puid,jdbcType=VARCHAR}") + int updateSAPDetails(SapResult sapResult); + + // 更新影响分析表格属性 + @Update( + "update CHINT_ECN_NOTIFICATION set \"principal\" = #{principal},\"coudata\" = #{coudata},\"pctime\" = #{pctime},\"remark\" = #{remark}" + + " where \"ecncode\" = #{ecnCode}" + + " and \"actionstatement\" = #{file}") + int updateRefMethod(String file, String principal, String coudata, String pctime, String remark, String ecnCode); + + /** + * 获取是否需要修改状态的属性 + * + * @param code + * @param puid + * @return + */ + @Select( + "select plmalterstatus from CHINT_BOM_TO_SAP_DETIALS where CODE = #{code,jdbcType=VARCHAR} and puid = #{puid,jdbcType=VARCHAR} ") + List getAlterStatus(String code, String puid); +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/mapper/RDMMapper.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/mapper/RDMMapper.java new file mode 100644 index 0000000..22f71b0 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/mapper/RDMMapper.java @@ -0,0 +1,92 @@ +package com.connor.connor_cpzc_service.mapper; + +import com.connor.connor_cpzc_service.bean.MdmDs.MomRuleBean; +import com.connor.connor_cpzc_service.bean.MdmDs.SapMsg; +import com.connor.connor_cpzc_service.bean.QMSBean; +import com.connor.connor_cpzc_service.bean.SapResult; +import com.connor.connor_cpzc_service.bean.SapSumBean; +import org.apache.ibatis.annotations.*; +import org.apache.ibatis.type.JdbcType; + +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +//import org.apache.ibatis.annotations.*; + +@Mapper +public interface RDMMapper { + + @Select("select ordernumber,status from CHINT_RDM_PROJECT where ordernumber=#{ordernumber} FETCH FIRST 1 ROW ONLY") + List> queryRDMProject(@Param("ordernumber")String ordernumber); + + @Delete("delete from CHINT_RDM_PROJECT where ordernumber=#{ordernumber}") + int deleteRDMProject(@Param("ordernumber")String ordernumber); + + + @Insert("insert into CHINT_RDM_PROJECT(ordernumber,projectno,rdmprojectno,projectname,projectleader,factory,pushuser,pushdate,status,createdate,projectleaderid,pushuserid)" + + "values(#{ordernumber},#{projectno},#{rdmprojectno},#{projectname},#{projectleader},#{factory},#{pushuser},#{pushdate},#{status},#{createdate},#{projectleaderid},#{pushuserid})") + int insertRDMProject(@Param("ordernumber")String ordernumber,@Param("projectno")String projectno,@Param("rdmprojectno")String rdmprojectno, @Param("projectname")String projectname, @Param("projectleader")String projectleader,@Param("factory")String factory,@Param("pushuser")String pushuser,@Param("pushdate")Timestamp pushdate,@Param("status")String status,@Param("createdate") Timestamp createdate,@Param("projectleaderid")String projectleaderid,@Param("pushuserid")String pushuserid); + + @Insert("insert into CHINT_RDM_PROJECT_PDTTEAMS(ordernumber,\"USER\",USERID,ROLE,FACTORY)" + + "values(#{ordernumber},#{user},#{userid},#{role},#{factory})") + int insertRDMProjectUser(@Param("ordernumber")String ordernumber,@Param("user")String user,@Param("userid")String userid,@Param("role")String role,@Param("factory")String factory); + + @Delete("delete from CHINT_RDM_PROJECT_PDTTEAMS where ordernumber=#{ordernumber}") + int deleteRDMProjectUser(@Param("ordernumber")String ordernumber); + + + + @Select("select ordernumber from CHINT_RDM_PROJECT_ENGDING where ordernumber=#{ordernumber} FETCH FIRST 1 ROW ONLY") + String queryProjectFinish(@Param("ordernumber")String ordernumber); + + @Delete("delete from CHINT_RDM_PROJECT_ENGDING where ordernumber=#{ordernumber}") + int deleteProjectFinish(@Param("ordernumber")String ordernumber); + + + @Insert("insert into CHINT_RDM_PROJECT_ENGDING(ordernumber,projectno,rdmprojectno,projectname,projectleader,factory,pushuser,pushdate,status,createdate)" + + "values(#{ordernumber},#{projectno},#{rdmprojectno},#{projectname},#{projectleader},#{factory},#{pushuser},#{pushdate},#{status},#{createdate})") + int insertProjectFinish(@Param("ordernumber")String ordernumber,@Param("projectno")String projectno,@Param("rdmprojectno")String rdmprojectno, @Param("projectname")String projectname, @Param("projectleader")String projectleader,@Param("factory")String factory,@Param("pushuser")String pushuser,@Param("pushdate")Timestamp pushdate,@Param("status")String status,@Param("createdate") Timestamp createdate); + + + + +// @Insert("insert into CHINT_QMS_INSPECIFICATION_CODE_RULE(\"factory\",\"qmsinspectioncode\",\"qmsinspectionname\",\"qmssuperiorinspection\",\"qmspushuser\",\"qmspushtime\",\"qmsremark\") values(#{factory},#{qmsinspectioncode},#{qmsinspectionname},#{qmssuperiorinspection},#{qmspushuser},#{qmspushtime},#{qmsremark})") +// void insertInspection(String factory, String qmsinspectioncode, String qmsinspectionname, String qmssuperiorinspection, String qmspushuser, @Param("qmspushtime")java.sql.Date qmspushtime, String qmsremark); +// +// @Select("select count(*) from CHINT_QMS_INSPECIFICATION_CODE_RULE where \"factory\" = #{factory} and \"qmsinspectioncode\" = #{qmsinspectioncode}") +// Integer selectInspection(String factory, String qmsinspectioncode); +// +// @Delete("delete from CHINT_QMS_INSPECIFICATION_CODE_RULE where \"factory\" = #{factory} and \"qmsinspectioncode\" = #{qmsinspectioncode}") +// void deleteInspection(String factory, String qmsinspectioncode); + + + @Insert("insert into CHINT_QMS_INSPECIFICATION_CODE_RULE(\"factory\",\"qmsinspectioncode\",\"qmsinspectionname\",\"qmspushuser\",\"qmspushtime\",\"qmsremark\",\"qmssuperiorinspectionname\",\"qmssuperiorinspectioncode\",\"qmsinspectionschemename\",\"qmsinspectionschemecode\") values(#{factory},#{qmsinspectioncode},#{qmsinspectionname},#{qmspushuser},#{qmspushtime},#{qmsremark},#{qmssuperiorinspectionname},#{qmssuperiorinspectioncode},#{qmsinspectionschemename},#{qmsinspectionschemecode})") + void insertInspection(QMSBean qmsBean); + + @Insert("insert into CHINT_QMS_INSPECIFICATION_CODE_RULE(\"code\",\"factory\",\"qmsinspectioncode\",\"qmsinspectionname\",\"qmspushuser\",\"qmspushtime\",\"qmsremark\",\"qmssuperiorinspectionname\",\"qmssuperiorinspectioncode\",\"qmsinspectionschemename\",\"qmsinspectionschemecode\") values(#{code},#{factory},#{qmsinspectioncode},#{qmsinspectionname},#{qmspushuser},#{qmspushtime},#{qmsremark},#{qmssuperiorinspectionname},#{qmssuperiorinspectioncode},#{qmsinspectionschemename},#{qmsinspectionschemecode})") + void insertInspectionCode(QMSBean qmsBean); + + @Select("select \"code\" from CHINT_QMS_INSPECIFICATION_CODE_RULE order by \"code\" desc FETCH FIRST 1 ROW ONLY") + int selectLs(); + + + @Select("select * from CHINT_QMS_INSPECIFICATION_CODE_RULE where \"factory\" = #{factory} and \"qmsinspectioncode\" = #{qmsinspectioncode} and \"qmsinspectionschemecode\" = #{qmsinspectionschemecode} and \"qmssuperiorinspectioncode\" = #{qmssuperiorinspectioncode} FETCH FIRST 1 ROW ONLY") + List selectInspection(String factory, String qmsinspectioncode,String qmsinspectionschemecode,String qmssuperiorinspectioncode); + + @Delete("delete from CHINT_QMS_INSPECIFICATION_CODE_RULE where \"code\" = #{code}") + void deleteInspection(Integer code); + + @Select("select * from CHINT_QMS_INSPECIFICATION_CODE_RULE where \"factory\" = #{factory} and \"qmsinspectioncode\" = #{qmsinspectioncode} and \"qmsinspectionschemecode\" = #{qmsinspectionschemecode}") + List getInspectionResult(String factory, String qmsinspectioncode, String qmsinspectionschemecode); + + @Select("select * from CHINT_QMS_INSPECIFICATION_CODE_RULE where \"plminspectioncode\" = #{plminspectioncode} and \"status\" = '成功' FETCH FIRST 1 ROW ONLY") + List getProjectInspection(String plminspectioncode); + + @Select("select MATERIALNO,NETWORKNO from CHINT_PM_PRODUCT where FACTORYNO = #{FACTORYNO} FETCH FIRST 1 ROW ONLY") + List getMaterialNo(String FACTORYNO); + + @Select("select WBSNO from CHINT_PM_PROJECT where NETWORKNO = #{NETWORKNO} FETCH FIRST 1 ROW ONLY") + String getWbsno(String NETWORKNO); +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/service/BomResultService.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/service/BomResultService.java new file mode 100644 index 0000000..88f113e --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/service/BomResultService.java @@ -0,0 +1,340 @@ +package com.connor.connor_cpzc_service.service; + +import com.alibaba.fastjson.JSONObject; +import com.connor.connor_cpzc_service.bean.MdmDs.SapMsg; +import com.connor.connor_cpzc_service.bean.SapResult; +import com.connor.connor_cpzc_service.bean.SapSumBean; +import com.connor.connor_cpzc_service.mapper.EPMMapper; +import com.connor.connor_cpzc_service.util.KUtil; +import com.teamcenter.clientx.AppXSession; +import com.teamcenter.services.strong.core.DataManagementService; +import com.teamcenter.soa.client.model.ModelObject; +import com.teamcenter.soa.client.model.ServiceData; +import okhttp3.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; + +@Service +public class BomResultService { + @Autowired + private EPMMapper dataMapper; + + public static final String MSG_TITLE = "【PLM系统自动通知】【"; + public static final String MSG_CODE = " 任务号:"; + public static final String MSG_TYPE = ", 传递类型:"; + public static final String MSG_RESULT = ", 本次传递结果为:"; + public static final String MSG_ALL = "\n具体结果如下: "; + public static final String MSG_SUCC_CCP = ", 成功的产成品数量为"; + public static final String MSG_ALL_BOM = ", BOM总数为"; + public static final String MSG_ERROR_BOM = ", 失败的BOM数量为"; + public static final String MSG_ALL_CCP = "本次传递产成品数量为"; + public static final String MSG_SUCC = "全部成功"; + public static final String MSG_ERROR = "部分失败"; + public static final String SPLIT_KEY = ":"; + public static final String SPLIT_MSG = ";"; + public static final String PROP_NAME = "object_name"; + public static final String EMAIL_SJQ = "shaojq"; + public static final String EMAIL_WLL = "wangll06"; + /** + * BOM传递SAP后,易发通知生产计划人员 + **/ + public static final String CHINT_Notify = "CHINT_Notify"; + public static final String NOTIFY_SPLIT = "/"; + public static final String NOTIFY_MSG = "传递:"; + + public void saveSapResult(List results) { + try { + String batchNumber = ""; + for (SapResult result : results) { + KUtil.log("update==>" + result.toString()); + dataMapper.updateSAPDetails(result); + batchNumber = result.getBatchnumber(); + } + String code = batchNumber.split("-")[0]; + List status = dataMapper.getStatus(code); + KUtil.log("status==>" + status.size()); + if (status.size() == 0) { + // 已经全部完成,修改NUM表的状态 ,发送飞书信息 + // 查询成功的 + // List successBom = dataMapper.getSuccessBom(code); + List errorCpps = dataMapper.getErrCpp(code); + List allCpps = dataMapper.getAllCpp(code); + Integer errorBomCount = dataMapper.getErrorBomCount(code); + List errMessages = new ArrayList<>(); + List succMessages = new ArrayList<>(); + for (String errorCpp : errorCpps) { + if (errorCpp.contains(";")) { + String[] cpps = errorCpp.split(";"); + for (String cpp : cpps) { + if (!errMessages.contains(errorCpp)) { + errMessages.add(cpp); + } + } + } else if (!errMessages.contains(errorCpp)) { + errMessages.add(errorCpp); + } + } + for (String allCpp : allCpps) { + if (allCpp.contains(";")) { + String[] cpps = allCpp.split(";"); + for (String cpp : cpps) { + if (!errMessages.contains(cpp) && !succMessages.contains(cpp)) { + succMessages.add(cpp); + } + } + } else if (!errMessages.contains(allCpp) && !succMessages.contains(allCpp)) { + succMessages.add(allCpp); + } + } + // + if (errorCpps.size() == 0) { + dataMapper.updateSAPSum(code, MSG_SUCC); + } else { + dataMapper.updateSAPSum(code, MSG_ERROR); + } + List errorReason = dataMapper.getErrorReason(code); + //获取BOM总数 + Integer bomCount = dataMapper.getBomCount(code); + // 数据库中成功的数据 + List successPart = dataMapper.getSuccessPart(code); + List uidList = new ArrayList<>(); + for (SapMsg sapMsg : successPart) { + String productMaterialNo = sapMsg.getProductmaterialno(); + if (productMaterialNo.contains(";")) { + boolean flag = true; + for (String materialNo : productMaterialNo.split(";")) { + if (!succMessages.contains(materialNo)) { + flag = false; + break; + } + } + if (flag) { + String puid = sapMsg.getPuid(); + List alter = dataMapper.getAlterStatus(code, puid); + if(KUtil.equals(alter.size() > 0 ? alter.get(0) : "", "Y")) + uidList.add(puid); + } + } else if (succMessages.contains(productMaterialNo)) { + String puid = sapMsg.getPuid(); + List alter = dataMapper.getAlterStatus(code, puid); + if(KUtil.equals(alter.size() > 0 ? alter.get(0) : "", "Y")) + uidList.add(puid); + } + } + KUtil.log("uidList:" + uidList); + //设置成功属性 + if (uidList.size() > 0) { + DataManagementService dmService = DataManagementService.getService(AppXSession.getConnection()); + ServiceData sd = dmService.loadObjects(uidList.toArray(new String[]{})); + ModelObject[] foundObjs = new ModelObject[sd.sizeOfPlainObjects()]; + for (int k = 0; k < sd.sizeOfPlainObjects(); k++) { + foundObjs[k] = sd.getPlainObject(k); + } + KUtil.log("加载完成 foundObjs ====>" + foundObjs.length); + KUtil.setPropertys(foundObjs, "zt2_SapState", "3"); + } + //获取产成品用来通知信息 + StringBuilder returnMsg = new StringBuilder(""); + // 飞书通知的改一下:发起时间+发起的+wbs+项目名称+项目已经处理完毕,具体结果如下: + List sumMessage = dataMapper.getSumMessage(code); +// if (sumMessage.size() > 0) { + SapMsg sapMsg = sumMessage.get(0); + returnMsg.append(MSG_TITLE).append(sapMsg.getFactory()).append("】:") + .append(sapMsg.getStarttime()) + .append(" ").append(sapMsg.getUser()) + .append("发起的 \"") + .append(sapMsg.getWbsno()) + .append("\" \"") + .append(sapMsg.getProjectno()) + .append("\" 项目BOM已同步SAP, ") + .append(MSG_CODE).append(code).append(MSG_TYPE) + .append(sapMsg.getTransfer()).append(MSG_RESULT) + .append(sapMsg.getSapresult()).append(MSG_ALL).append(MSG_ALL_CCP) + .append(errMessages.size() + succMessages.size()).append(MSG_ALL_BOM) + .append(bomCount).append(MSG_SUCC_CCP) + .append(succMessages.size()).append(MSG_ERROR_BOM).append(errorBomCount);//具体结果如下: + +// } + returnMsg.append("\n成功数据:").append(succMessages).append("\n"); + if (errorCpps.size() > 0) { + returnMsg.append("失败数据:").append(errMessages).append("\n"); + returnMsg.append("失败原因如下:\n"); + for (String reason : errorReason) { + returnMsg.append(reason).append("\n"); + } + } + // 查询失败的 + if (returnMsg.length() >= 20000) { + returnMsg = new StringBuilder(returnMsg.substring(0, 20000)); + returnMsg.append("等"); + } + KUtil.log("sendAM8 start"); + List emails = new ArrayList<>(); + sendAM8(sapMsg.getTransfer(), code, emails); + KUtil.log("emails:" + emails); +// emails.add(EMAIL_SJQ); +// emails.add(EMAIL_WLL); + String userid = sapMsg.getUserid(); + if (userid != null && !userid.isEmpty() && !userid.equals("admin")) { + emails.add(sapMsg.getUserid()); + } + // + String[] prefs = KUtil.GetPrefValues("CHINT_SENDMESSAGE_SYSAD_USER"); + emails.addAll(Arrays.asList(prefs[1].split(","))); + JSONObject msgJson = new JSONObject(); + msgJson.put("mobiles", prefs[0].split(","));//new String[]{ "15295371103", "13135660326" }); // "15295371103" + msgJson.put("emails", emails.toArray(new String[]{})); // + msgJson.put("sms", false); + msgJson.put("content", returnMsg.toString()); + KUtil.log(msgJson.toJSONString()); + // String result = okHttpCli.doPostJson(finalUrl, msgJson.toJSONString()); + /*OkHttpClient client = new OkHttpClient(); + MediaType mediaType = MediaType.parse("application/json"); + RequestBody body = RequestBody.create(mediaType, msgJson.toJSONString()); + Request request = + new Request.Builder() + .url("http://10.128.10.170/api/feishu/Message/sendMessages") + .method("POST", body) + .addHeader("Content-Type", "application/json") + .build(); + Response response = client.newCall(request).execute();*/ + //TODO lidy20240829新接口 先获取token,再组织数据 + OkHttpClient client = new OkHttpClient(); + RequestBody body = RequestBody.create(null, new byte[0]); + Request request = new Request.Builder() + .url("https://pub.chintelec.com/api/getToken?appId=zt_plm&appSecret=RA5KfdZtj37zpVsmgKeSxWncEIT8npVf") + .post(body) + .build(); + Response response = client.newCall(request).execute(); + String res = response.body().string(); + JSONObject jsonObject = JSONObject.parseObject(res); +// System.out.println(res); + if(!jsonObject.getBoolean("success")) { + System.out.println(res); + return; + } + String token = jsonObject.getString("data"); + + client = new OkHttpClient(); + MediaType mediaType = MediaType.parse("application/json"); + body = RequestBody.create(mediaType, msgJson.toJSONString()); + request = new Request.Builder() + .url("https://pub.chintelec.com/api/open/Feishu/sendMessages") + .post(body) + .addHeader("Authorization", token) + .addHeader("Content-Type", "application/json") + .build(); + response = client.newCall(request).execute(); + KUtil.log("LOG 接口的CODE ===> " + code); + KUtil.log("LOG 飞书消息: ===> " + msgJson); + KUtil.log("LOG 飞书接口返回:===> " + response.body().string()); + dataMapper.updatePLMEnd(code); + } + + } catch (Exception e) { + e.printStackTrace(); + KUtil.log(KUtil.getStackTrace(e)); + } finally { + } + } + + // 事业部发易发通知 + public void sendAM8(String transfer, String code, List emails) throws Exception { + List keyMessages = dataMapper.findKeyMessage(code); + SapSumBean sapSumBean = keyMessages.get(0); + String factory = sapSumBean.getFactory(); + String[] split = sapSumBean.getKeyMsg().split(SPLIT_KEY); + if (split.length > 0) { + DataManagementService dmService = DataManagementService.getService(AppXSession.getConnection()); + ServiceData sd = dmService.loadObjects(split); + ModelObject[] foundObjs = new ModelObject[sd.sizeOfPlainObjects()]; + for (int k = 0; k < sd.sizeOfPlainObjects(); k++) { + foundObjs[k] = sd.getPlainObject(k); + } + KUtil.log("加载完成 foundObjs ====>" + foundObjs.length); + KUtil.refreshModsAndGetProperties(foundObjs, PROP_NAME); + String[] chintNotify = KUtil.GetPrefValues(CHINT_Notify); + StringBuilder match = new StringBuilder(); + match.append(factory).append(NOTIFY_SPLIT).append(transfer).append(NOTIFY_MSG); + String temp = match.toString(); + match.setLength(0); + StringBuilder userIDs = new StringBuilder(); + Map map_type_users = new HashMap(); + List user_else = new ArrayList(); + + String[] types; + String[] vals; + int index = 0; + for (String pref : chintNotify) { + if (pref.startsWith(temp)) { + index++; + pref = pref.replace(temp, ""); + if (!pref.contains("|")) { + user_else.add(pref); + } else { + vals = pref.split("\\|"); + for (String val : vals) { + types = val.split(";"); + for (String type : types) { + map_type_users.put(type, vals[1]); + } + } + } + } + } + if (index == 0) { + KUtil.log("未找到相应通知人员"); + return; + } + List list_types = new ArrayList<>(map_type_users.keySet()); + list_types.sort(new Comparator() { + @Override + public int compare(String o1, String o2) { + return o2.compareTo(o1); + } + }); + List isSend = new ArrayList<>(); + if (index == 1) { + if (user_else.size() > 0) { + userIDs.append(user_else.get(0)); + } else { + userIDs.append(map_type_users.get(list_types.get(0))); + } + } else { + String object_name; + String id; + String type; + boolean flag = false; + for (ModelObject foundObj : foundObjs) { + + object_name = foundObj.getPropertyDisplayableValue(PROP_NAME); + if (isSend.contains(object_name)) + continue; + isSend.add(object_name); + type = KUtil.inArray2(object_name, list_types); + if (KUtil.isEmpty(type)) { + id = user_else.size() > 0 ? user_else.get(0) : ""; + } else { + id = map_type_users.get(type); + } + if (!userIDs.toString().contains(id)) { + if (flag) { + userIDs.append(SPLIT_MSG).append(id); + } else { + userIDs.append(id); + flag = true; + } + } + } + } + String[] split1 = userIDs.toString().split(SPLIT_MSG); +// emails.addAll(Arrays.asList(split1)); + for(String s : split1){ + if(!s.equals("admin")) + emails.add(s); + } + } + } +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/service/RDMService.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/service/RDMService.java new file mode 100644 index 0000000..55042fa --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/service/RDMService.java @@ -0,0 +1,609 @@ +package com.connor.connor_cpzc_service.service; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.JSONPObject; +import com.connor.connor_cpzc_service.bean.QMSBean; +import com.connor.connor_cpzc_service.mapper.RDMMapper; +import com.connor.connor_cpzc_service.util.KUtil; +import com.teamcenter.clientx.AppXSession; +import com.teamcenter.services.strong.core.DataManagementService; +import com.teamcenter.services.strong.query.SavedQueryService; +import com.teamcenter.services.strong.query._2007_09.SavedQuery; +import com.teamcenter.soa.client.model.ModelObject; +import com.teamcenter.soa.client.model.Property; +import com.teamcenter.soa.client.model.ServiceData; +import com.teamcenter.soa.client.model.strong.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStreamReader; +import java.sql.Timestamp; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.stream.Collectors; + +@Service +public class RDMService { + + @Autowired + public RDMMapper mapper; + + public String GetDrawing(HashMap jsonMaps,String queryID,LinkedHashMap stringJSONObjectLinkedHashMap) throws Exception { + JSONObject errorResult = new JSONObject(); + JSONObject result = new JSONObject(); + try { + + + + + + JSONArray results = new JSONArray(); + DataManagementService dataManagementService = DataManagementService.getService(AppXSession.getConnection()); + System.out.println("登入成功"); + //SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + //查询 + SavedQueryService queryService = SavedQueryService.getService(AppXSession.getConnection()); + com.teamcenter.services.strong.query._2006_03.SavedQuery.GetSavedQueriesResponse savedQueries1 = queryService.getSavedQueries(); + if (savedQueries1.queries.length == 0) { + throw new Exception("系统中没有保存的查询"); + } + ImanQuery query = null; + for (com.teamcenter.services.strong.query._2006_03.SavedQuery.SavedQueryObject queryObj : savedQueries1.queries) { + if (queryObj.name.equals("chint_query_item_status")) { + query = queryObj.query; + } + } + if (query == null) { + throw new Exception("没有找到查询:chint_query_item_status"); + } + SavedQuery.QueryInput queryInput = + new com.teamcenter.services.strong.query._2007_09.SavedQuery.QueryInput(); + queryInput.query = query; + queryInput.entries = new String[]{"ID"}; + queryInput.values = new String[]{queryID}; + queryInput.maxNumToReturn = 2; + com.teamcenter.services.strong.query._2007_09.SavedQuery.SavedQueriesResponse queryResp = + queryService.executeSavedQueries( + new com.teamcenter.services.strong.query._2007_09.SavedQuery.QueryInput[]{queryInput}); + com.teamcenter.services.strong.query._2007_09.SavedQuery.QueryResults queryResults = + queryResp.arrayOfResults[0]; + int cnt = queryResults.objectUIDS.length; + + System.out.println("cnt============" + cnt); + System.out.println("参数的查询个数============" + cnt); + if (cnt > 0) { + + for (int i = 0; i < cnt; i++) { + + String userUid = queryResults.objectUIDS[i]; + ServiceData serviceData = dataManagementService.loadObjects(new String[]{userUid}); + //物料对象 + ItemRevision designRev = (ItemRevision) serviceData.getPlainObject(0); + //获取图纸下的PDF对象 + dataManagementService.getProperties(new ModelObject[]{designRev}, new String[]{"IMAN_specification", "item_revision_id", "object_name", "item_id", "zt2_WBSNo", "owning_user", "creation_date", "date_released"}); + Property dsProp = designRev.getPropertyObject("IMAN_specification"); + String item_id = designRev.get_item_id(); + String tz_object_name = designRev.get_object_name(); + String tzRevision = designRev.get_item_revision_id(); + + User owning_user = (User) designRev.get_owning_user(); + dataManagementService.getProperties(new ModelObject[]{owning_user}, new String[]{"object_string"}); + + owning_user.get_object_string(); + + String owning_user_object_string = owning_user.get_object_string(); + Calendar creation_date = designRev.get_creation_date(); + String creation_dateStr = String.valueOf(creation_date.get(Calendar.YEAR)) + + "-" + + String.format("%02d", creation_date.get(Calendar.MONTH) + 1) + + "-" + + String.format("%02d", creation_date.get(Calendar.DATE)); + Calendar date_released = designRev.get_date_released(); + String date_releasedStr = String.valueOf(date_released.get(Calendar.YEAR)) + + "-" + + String.format("%02d", date_released.get(Calendar.MONTH) + 1) + + "-" + + String.format("%02d", date_released.get(Calendar.DATE)); + ModelObject[] dsObjs = dsProp.getModelObjectArrayValue(); + JSONObject tempObject = new JSONObject(); + tempObject.put("no", jsonMaps.get(item_id)); + tempObject.put("drawNo", item_id); + tempObject.put("drawName", tz_object_name); + tempObject.put("drawVer", tzRevision); + tempObject.put("creator", owning_user_object_string); + tempObject.put("createDate", creation_dateStr); + tempObject.put("releaseDate", date_releasedStr); + dataManagementService.refreshObjects(dsObjs); + JSONArray drawlist = new JSONArray(); + dataManagementService.getProperties(dsObjs, new String[]{"object_type", "object_name"}); + ArrayList tempJsonArray = new ArrayList<>(); + for (int d = 0; d < dsObjs.length; d++) { + if (dsObjs[d] instanceof Dataset) { + Dataset ds = (Dataset) dsObjs[d]; + String object_type = ds.get_object_type(); + // if (object_type.equals("PDF") || object_type.equals("MS ExcelX") || object_type.equals("MSExcelX") || object_type.equals("JPEG") || object_type.equals("MSExcelX")) { + if (object_type.equals("PDF")){ + JSONObject tempObject1 = new JSONObject(); + String ds_object_name = ds.get_object_name(); + String uid = ds.getUid(); + tempObject1.put("drawUrlname", ds_object_name); + tempObject1.put("drawUrlDesc", uid); + drawlist.add(tempObject1); + }else{ + JSONObject tempObject1 = new JSONObject(); + String ds_object_name = ds.get_object_name(); + String uid = ds.getUid(); + tempObject1.put("drawUrlname", ds_object_name); + tempObject1.put("drawUrlDesc", uid); + tempJsonArray.add(tempObject1); + } + } + } + for (JSONObject list:tempJsonArray + ) { + drawlist.add(list); + } + + + tempObject.put("drawlist", drawlist); + stringJSONObjectLinkedHashMap.put(jsonMaps.get(item_id),tempObject); + jsonMaps.remove(item_id); + + } + + + } +// else {//未查到数据 +// +// errorResult.put("code", "500"); +// errorResult.put("msg", "TC未查询到图纸信息!"); +// return errorResult.toJSONString(); +// } + //没查到的全设置空 + for (Map.Entry entryMap : jsonMaps.entrySet() + ) { + String key = entryMap.getKey(); + String value = entryMap.getValue(); + JSONObject tempObject = new JSONObject(); + tempObject.put("no", value); + tempObject.put("drawNo", key); + tempObject.put("drawName", ""); + tempObject.put("drawVer", ""); + tempObject.put("creator", ""); + tempObject.put("createDate", ""); + tempObject.put("releaseDate", ""); + JSONArray drawlist = new JSONArray(); + JSONObject tempObject1 = new JSONObject(); + tempObject1.put("drawUrlname", ""); + tempObject1.put("drawUrlDesc", ""); + drawlist.add(tempObject1); + tempObject.put("drawlist", drawlist); + //results.add(tempObject); + stringJSONObjectLinkedHashMap.put(value,tempObject); + } + + + // 将Map转换为流,然后排序,最后收集为新的Map + Map sortedMap = stringJSONObjectLinkedHashMap.entrySet() + .stream() + .sorted(Map.Entry.comparingByKey(Comparator.comparingInt(s -> Integer.parseInt((String) s)))) + .collect(Collectors.toMap( + Map.Entry::getKey, + Map.Entry::getValue, + (e1, e2) -> e1, // 解决键冲突,这里不应该发生,因为键应该是唯一的 + LinkedHashMap::new // 使用LinkedHashMap保持排序 + )); + + + + for (Map.Entry jsonMap:sortedMap.entrySet() + ) { + results.add(jsonMap.getValue()); + } + + + + result.put("code", "200"); + result.put("results", results); + return result.toJSONString(); + }catch(Exception e){ + errorResult.put("code", "500"); + errorResult.put("msg", "执行报错,请联系管理员!"); + e.printStackTrace(); + return errorResult.toJSONString(); + } + } + + + public String getRDMProject(String json){ + JSONObject parse = (JSONObject) JSON.parse(json); + JSONObject result = new JSONObject(); + String ordernumber = parse.getString("ordernumber"); + if(ordernumber == null || ordernumber.isEmpty()){ + result.put("code","500"); + result.put("msg","接受失败:ordernumber字段为空"); + return result.toJSONString(); + } + String projectno = parse.getString("projectno"); + String rdmprojectno = parse.getString("rdmprojectno"); + String projectname = parse.getString("projectname"); + String projectleader = parse.getString("projectleader"); + String factory = parse.getString("factory"); + String pushuser = parse.getString("pushuser"); + String pushdate = parse.getString("pushdate"); + + String projectleaderid = parse.getString("projectleaderid"); + String pushuserid = parse.getString("pushuserid"); + + List> maps = mapper.queryRDMProject(ordernumber); + String resultStatus = "未创建"; + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String newDare = sdf.format(new Date()); + // 解析日期字符串 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + LocalDateTime localDateTimepushdate = LocalDateTime.parse(pushdate, formatter); + LocalDateTime localDateTimenewDare = LocalDateTime.parse(newDare, formatter); + // 转换为Timestamp + Timestamp timestamppushdate = Timestamp.valueOf(localDateTimepushdate); + Timestamp timestamppunewDare = Timestamp.valueOf(localDateTimenewDare); + if(maps.size() > 0){ + Map stringStringMap = maps.get(0); + System.out.println("stringStringMap====="+stringStringMap); + String code = stringStringMap.get("ORDERNUMBER"); + String status = stringStringMap.get("STATUS"); + System.out.println("code================================"+code); + + + if(code != null && !code.isEmpty()){ + + if(status != null && status.equals("未创建")){ + mapper.deleteRDMProject(code); + mapper.insertRDMProject(ordernumber,projectno,rdmprojectno,projectname,projectleader,factory,pushuser,timestamppushdate,"未创建",timestamppunewDare,projectleaderid,pushuserid); + }else if(status != null && status.equals("已创建")){ + mapper.deleteRDMProject(code); + mapper.insertRDMProject(ordernumber,projectno,rdmprojectno,projectname,projectleader,factory,pushuser,timestamppushdate,"已变更",timestamppunewDare,projectleaderid,pushuserid); + resultStatus = "已变更"; + }else if(status != null && status.equals("已变更")){ + mapper.deleteRDMProject(code); + mapper.insertRDMProject(ordernumber,projectno,rdmprojectno,projectname,projectleader,factory,pushuser,timestamppushdate,"已变更",timestamppunewDare,projectleaderid,pushuserid); + resultStatus = "已变更"; + }else if(status != null && status.equals("已关闭")){ + mapper.deleteRDMProject(code); + mapper.insertRDMProject(ordernumber,projectno,rdmprojectno,projectname,projectleader,factory,pushuser,timestamppushdate,"已关闭",timestamppunewDare,projectleaderid,pushuserid); + resultStatus = "已关闭"; + } + + }else{ + mapper.insertRDMProject(ordernumber,projectno,rdmprojectno,projectname,projectleader,factory,pushuser,timestamppushdate,"未创建",timestamppunewDare,projectleaderid,pushuserid); + + } + } + else{ + mapper.insertRDMProject(ordernumber,projectno,rdmprojectno,projectname,projectleader,factory,pushuser,timestamppushdate,"未创建",timestamppunewDare,projectleaderid,pushuserid); + } + + //导入user + JSONArray lists = parse.getJSONArray("pdtteams"); + if(lists.size() > 0){ + mapper.deleteRDMProjectUser(ordernumber); + for (int i = 0; i < lists.size(); i++) { + JSONObject listObject = lists.getJSONObject(i); + // 获取listObject中的属性 + String user = listObject.getString("user"); + String userid = listObject.getString("userid"); + String role = listObject.getString("role"); + String factory_user = listObject.getString("factory"); + mapper.insertRDMProjectUser(ordernumber==null?"":ordernumber,user==null?"":user,userid==null?"":userid,role==null?"":role,factory_user==null?"":factory_user); + + } + + } + + result.put("code","200"); + result.put("msg","成功接收"); + result.put("status",resultStatus); + return result.toJSONString(); + } + + + + public String getProjectFinish(String json){ + JSONObject parse = (JSONObject) JSON.parse(json); + JSONObject result = new JSONObject(); + String ordernumber = parse.getString("ordernumber"); + if(ordernumber == null || ordernumber.isEmpty()){ + result.put("code","500"); + result.put("msg","接受失败:ordernumber字段为空"); + return result.toJSONString(); + } + String projectno = parse.getString("projectno"); + String rdmprojectno = parse.getString("rdmprojectno"); + String projectname = parse.getString("projectname"); + String projectleader = parse.getString("projectleader"); + JSONArray lists = parse.getJSONArray("factorys"); + String factory = ""; + for (int i = 0; i < lists.size(); i++) { + JSONObject listObject = lists.getJSONObject(i); + // 获取listObject中的属性 + String tempFactory = listObject.getString("factory"); + if(tempFactory != null && !tempFactory.isEmpty()){ + factory +=tempFactory+";"; + } + + } + String pushuser = parse.getString("pushuser"); + String pushdate = parse.getString("pushdate"); + + String code = mapper.queryProjectFinish(ordernumber); + System.out.println("code================================"+code); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String newDare = sdf.format(new Date()); + // 解析日期字符串 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + LocalDateTime localDateTimepushdate = LocalDateTime.parse(pushdate, formatter); + LocalDateTime localDateTimenewDare = LocalDateTime.parse(newDare, formatter); + // 转换为Timestamp + Timestamp timestamppushdate = Timestamp.valueOf(localDateTimepushdate); + Timestamp timestamppunewDare = Timestamp.valueOf(localDateTimenewDare); + if(code != null && !code.isEmpty()){ + mapper.deleteProjectFinish(code); + mapper.insertProjectFinish(ordernumber,projectno,rdmprojectno,projectname,projectleader,factory,pushuser,timestamppushdate,"未创建",timestamppunewDare); + }else{ + mapper.insertProjectFinish(ordernumber,projectno,rdmprojectno,projectname,projectleader,factory,pushuser,timestamppushdate,"未创建",timestamppunewDare); + } + result.put("code","200"); + result.put("msg","成功接收"); + return result.toJSONString(); + } + +// public void getInspection(String factory,String qmsinspectioncode, String qmsinspectionname, String qmssuperiorinspection, String qmspushuser, String qmspushtime, String qmsremark) throws ParseException { +// Integer count = mapper.selectInspection(factory,qmsinspectioncode); +// //把日期的时间转化一下 +//// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); +//// LocalDateTime localDateTimepushdate = LocalDateTime.parse(qmspushtime, formatter); +//// Timestamp timestamppushdate = Timestamp.valueOf(localDateTimepushdate); +// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); +// Date date = sdf.parse(qmspushtime); +// java.sql.Date sqlDate = new java.sql.Date(date.getTime()); +// if(count > 0){ +// mapper.deleteInspection(factory,qmsinspectioncode); +// mapper.insertInspection(factory,qmsinspectioncode,qmsinspectionname,qmssuperiorinspection,qmspushuser,sqlDate,qmsremark); +// +// }else{ +// +// mapper.insertInspection(factory,qmsinspectioncode,qmsinspectionname,qmssuperiorinspection,qmspushuser,sqlDate,qmsremark); +// } +// } + + + public void getInspection(QMSBean qmsBean) throws ParseException { + List selectQmsBeans = mapper.selectInspection(qmsBean.getFactory(), qmsBean.getQmsinspectioncode(), qmsBean.getQmsinspectionschemecode(),qmsBean.getQmssuperiorinspectioncode()); + //把日期的时间转化一下 +// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); +// LocalDateTime localDateTimepushdate = LocalDateTime.parse(qmspushtime, formatter); +// Timestamp timestamppushdate = Timestamp.valueOf(localDateTimepushdate); + if(selectQmsBeans.size() > 0){ + QMSBean selectBean = selectQmsBeans.get(0); + mapper.deleteInspection(selectBean.getCode()); + qmsBean.setCode(selectBean.getCode()); + mapper.insertInspectionCode(qmsBean); + + }else{ + + //获取最大流水 + int ls = mapper.selectLs(); + System.out.println("ls==========="+ls); + qmsBean.setCode(ls+1); + mapper.insertInspectionCode(qmsBean); + } + } + + public List getInspectionResult(String factory, String qmsinspectioncode, String qmsinspectionschemecode) { + List qmsBeans = null; + return qmsBeans = mapper.getInspectionResult(factory,qmsinspectioncode,qmsinspectionschemecode); + } + + public String getProjectInspection(String wbsno,String drawingno,String factoryno,String materialno,String plminspectioncode) throws Exception { + + //查询数据库 判断是否存在 判断类型 + String value = ""; + List qmsBeans = mapper.getProjectInspection(plminspectioncode); + if(qmsBeans.size() > 0){ + QMSBean qmsBean = qmsBeans.get(0); + String plmvaluetype = qmsBean.getPlmvaluetype(); + String plmdesignation = qmsBean.getPlmdesignation(); + System.out.println("plmdesignation==="+plmdesignation+"plmvaluetype==="+plmvaluetype); + if(plmvaluetype != null && !plmvaluetype.isEmpty()){ + + if(plmvaluetype.equals("参数化")){ + + + //去数据库查 wbs和物料号 + ItemRevision designRev = null; + String networkNo = ""; + String materialNo = ""; + List list = mapper.getMaterialNo(factoryno); + // List list = mapper.getMaterialNo("123"); + if(list.size() >= 2){ + System.out.println("list==============="+list.toString()); + materialNo = list.get(0); + networkNo = list.get(1); + } + + if(drawingno == null || drawingno.isEmpty()) { + + if (materialNo != null && !materialNo.isEmpty() && networkNo != null && !networkNo.isEmpty()) { + String wbsNo = mapper.getWbsno(networkNo); + System.out.println("wbsNo==============="+wbsNo); + if (wbsNo != null && !wbsNo.isEmpty()) { + //通过wbs和物料去tc找图纸 + Map searchMap = new HashMap<>(); + searchMap.put("所关联物料ID", materialNo); + searchMap.put("WBS号", wbsNo); + ModelObject[] designs = KUtil.query("chint_query_designforMaterialWBS", searchMap); + String[] CHINT_Search_Drawing_ID = KUtil.GetPrefValues("CHINT_Search_Drawing_ID"); + System.out.println("designs.length==================="+designs.length); + for (int i = 0; i < designs.length; i++) { + designRev = (ItemRevision) designs[i]; + //dataManagementService.getProperties(new ModelObject[]{designRev}, new String[]{"item_id"}); + KUtil.refreshAndGetProperties(designRev, "item_id"); + String item_id = designRev.get_item_id(); + System.out.println("design_item_id===================================" + item_id); + for (int j = 0; j < CHINT_Search_Drawing_ID.length; j++) { + if (item_id.contains(CHINT_Search_Drawing_ID[j])) { + System.out.println("通过判断----------------"); + designRev = (ItemRevision) designs[i]; + } + } + } + } + } + + + //没找到再用出产编号到tc去查图纸 + if (designRev == null && plmdesignation != null && !plmdesignation.isEmpty()) { + Map searchMap = new HashMap<>(); + searchMap.put("ID", factoryno); + ModelObject[] designs = KUtil.query("chint_query_designforFactoryNo", searchMap); + String[] CHINT_Search_Drawing_ID = KUtil.GetPrefValues("CHINT_Search_Drawing_ID"); + System.out.println("22222222designs.length================="+designs.length); + for (int i = 0; i < designs.length; i++) { + designRev = (ItemRevision) designs[i]; + //dataManagementService.getProperties(new ModelObject[]{designRev}, new String[]{"item_id"}); + KUtil.refreshAndGetProperties(designRev, "item_id"); + String item_id = designRev.get_item_id(); + System.out.println("222222222222design_item_id===================================" + item_id); + for (int j = 0; j < CHINT_Search_Drawing_ID.length; j++) { + if (item_id.contains(CHINT_Search_Drawing_ID[j])) { + System.out.println("22222222222222通过判断"); + designRev = (ItemRevision) designs[i]; + } + } + } + + + } + + } + //找到图纸后 + if((designRev != null || (drawingno != null && !drawingno.isEmpty())) && plmdesignation != null && !plmdesignation.isEmpty()){ + + + String item_id = ""; + if(!drawingno.isEmpty()){ + item_id = drawingno; + }else{ + KUtil.refreshAndGetProperties(designRev, "item_id"); + item_id = designRev.get_item_id(); + } + String th = ""; + String[] split = item_id.split("-"); + if(split.length == 2 || split.length == 3){ + th = split[1]; + } + System.out.println("th================="+th); + if(th != null && !th.isEmpty()){ + //调用jar包 + String pathToJar = "D:\\Siemens\\Teamcenter11\\bin\\findCshSql.jar"; + try { + ProcessBuilder processBuilder = new ProcessBuilder( + "java", "-jar", pathToJar, th, plmdesignation); + + Process process = processBuilder.start(); + + // 读取输出流 + try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) { + String line; + StringBuilder result = new StringBuilder(); + while ((line = reader.readLine()) != null) { + result.append(line).append("\n"); + } + value = result.toString().trim(); + System.out.println("Result from JAR: " + value); + } + + int exitCode = process.waitFor(); + System.out.println("Process exited with code: " + exitCode); + + } catch (IOException | InterruptedException e) { + e.printStackTrace(); + } + } + } + + return value; + + + + }else if(plmvaluetype.equals("型号规格(3d模型)")){ + if(materialno != null && !materialno.isEmpty()) { + //通过查询获取物料 + Map searchMap = new HashMap<>(); + searchMap.put("materialno", materialno); + ModelObject[] materials = KUtil.query("chint_query_material", searchMap); + if (materials.length > 0) { + //获取图纸 + + ItemRevision material = (ItemRevision) materials[0]; + KUtil.refreshAndGetProperties( + material, "TC_Is_Represented_By"); + // 获取产成品关联的图纸 + ModelObject[] designRevs = + material.getPropertyObject("TC_Is_Represented_By").getModelObjectArrayValue(); + System.out.println("designRevs==================="+designRevs.length); + if (designRevs.length > 0) { + ItemRevision designRev = (ItemRevision) designRevs[0]; + KUtil.refreshAndGetProperties(designRev, "zt2_Specifications"); + String zt2_Specifications = designRev.getPropertyDisplayableValue("zt2_Specifications"); + System.out.println("zt2_Specifications============"+zt2_Specifications); + String plmsequence = qmsBean.getPlmsequence(); + if (zt2_Specifications != null && !zt2_Specifications.isEmpty() && plmsequence != null && !plmsequence.isEmpty()) { + String[] split = zt2_Specifications.split("/"); + if (split.length >= Integer.parseInt(plmsequence)) { + value = split[Integer.parseInt(plmsequence) - 1]; + System.out.println("22222222value============"+value); + } + + } + } + } + } + }else if(plmvaluetype.equals("物料描述规格(2d图纸)")) { + if (materialno != null && !materialno.isEmpty()) { + //通过查询获取物料 + Map searchMap = new HashMap<>(); + searchMap.put("materialno", materialno); + ModelObject[] materials = KUtil.query("chint_query_material", searchMap); + System.out.println("chint_query_material.lenth=========="+materials.length); + if (materials.length > 0) { + ItemRevision material = (ItemRevision) materials[0]; + KUtil.refreshAndGetProperties( + material, "zt2_Specifications"); + String zt2_specifications = material.getPropertyDisplayableValue("zt2_Specifications"); + System.out.println("zt2_specifications==========="+zt2_specifications); + String plmsequence = qmsBean.getPlmsequence(); + System.out.println("plmsequence============"+plmsequence); + if (zt2_specifications != null && !zt2_specifications.isEmpty() && plmsequence != null && !plmsequence.isEmpty()) { + String[] split = zt2_specifications.split("/"); + if (split.length >= Integer.parseInt(plmsequence)) { + value = split[Integer.parseInt(plmsequence) - 1]; + System.out.println("value3=================="+value); + } + + } + } + } + } + } + } + return value; + } +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/util/JsonResult.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/util/JsonResult.java new file mode 100644 index 0000000..acb0c8e --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/util/JsonResult.java @@ -0,0 +1,72 @@ +package com.connor.connor_cpzc_service.util; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class JsonResult implements Serializable { + private static final long serialVersionUID = -8191886883629303111L; + /** + * 接口是否完成操作 + */ + private boolean success = true; + /** + * 接口处理的消息 + */ + private String msg; + /** + * 状态码 + */ + private Integer code; + /** + * 返回的对象 + */ + private Object data; + + public JsonResult() {} + + public JsonResult(String msg) { + this.msg = msg; + } + + public JsonResult(String msg, Integer code) { + this.msg = msg; + this.code = code; + } + + public static JsonResult success() { + return new JsonResult(); + } + + public static JsonResult success(Object data) { + JsonResult jr = new JsonResult(); + jr.setData(data); + return jr; + } + + public static JsonResult success(String msg, Object data) { + JsonResult jr = new JsonResult(); + jr.setMsg(msg); + jr.setData(data); + return jr; + } + + public static JsonResult error() { + JsonResult jr = new JsonResult(); + jr.setSuccess(false); + return jr; + } + + public static JsonResult error(String msg) { + JsonResult jr = new JsonResult(msg); + jr.setSuccess(false); + return jr; + } + + public static JsonResult error(String msg, Integer code) { + JsonResult jr = new JsonResult(msg, code); + jr.setSuccess(false); + return jr; + } +} diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/util/KUtil.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/util/KUtil.java new file mode 100644 index 0000000..fbada5c --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/util/KUtil.java @@ -0,0 +1,989 @@ +package com.connor.connor_cpzc_service.util; + +import com.teamcenter.clientx.AppXSession; +import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException; +import com.teamcenter.services.loose.core._2006_03.FileManagement; +import com.teamcenter.services.strong.cad._2007_01.StructureManagement; +import com.teamcenter.services.strong.core.DataManagementService; +import com.teamcenter.services.strong.core.ReservationService; +import com.teamcenter.services.strong.core.SessionService; +import com.teamcenter.services.strong.core._2007_01.DataManagement; +import com.teamcenter.services.strong.core._2007_06.DataManagement.ExpandGRMRelationsData; +import com.teamcenter.services.strong.core._2007_06.DataManagement.ExpandGRMRelationsPref; +import com.teamcenter.services.strong.core._2007_06.DataManagement.ExpandGRMRelationsResponse; +import com.teamcenter.services.strong.core._2007_06.DataManagement.RelationAndTypesFilter2; +import com.teamcenter.services.strong.core._2010_04.DataManagement.DatasetInfo; +import com.teamcenter.services.strong.core._2007_12.Session; +import com.teamcenter.services.strong.query.SavedQueryService; +import com.teamcenter.services.strong.query._2006_03.SavedQuery.GetSavedQueriesResponse; +import com.teamcenter.services.strong.query._2006_03.SavedQuery.SavedQueryObject; +import com.teamcenter.services.strong.query._2007_06.SavedQuery.ExecuteSavedQueriesResponse; +import com.teamcenter.services.strong.query._2007_06.SavedQuery.SavedQueryInput; +import com.teamcenter.services.strong.query._2007_09.SavedQuery; +import com.teamcenter.services.strong.workflow.WorkflowService; +import com.teamcenter.services.strong.workflow._2008_06.Workflow; +import com.teamcenter.soa.client.FileManagementUtility; +import com.teamcenter.soa.client.GetFileResponse; +import com.teamcenter.soa.client.model.ErrorValue; +import com.teamcenter.soa.client.model.ModelObject; +import com.teamcenter.soa.client.model.Property; +import com.teamcenter.soa.client.model.ServiceData; +import com.teamcenter.soa.client.model.strong.*; +import com.teamcenter.soa.exceptions.NotLoadedException; +import org.apache.log4j.Logger; + +import java.io.File; +import java.util.*; + +public class KUtil { + + private static Logger logger = Logger.getLogger(KUtil.class); + private static User loginedUser; + public static DataManagementService dmService; +// private static Map loadedObjects = new HashMap<>(); + private static Map loadedQueries = new HashMap<>(); + private static SavedQueryService queryService; + private static AppXSession session; + /** + * 从对象id查询对象 + * + * @param itemID + * @return + * @throws Exception + */ + public static ModelObject[] queryItemByID(String itemID) throws Exception { + if (itemID == null || "".equals(itemID)) { + return null; + } + SavedQueryService queryService = SavedQueryService.getService(AppXSession.getConnection()); + com.teamcenter.services.strong.query._2006_03.SavedQuery.GetSavedQueriesResponse savedQueries = queryService.getSavedQueries(); + if (savedQueries.queries.length == 0) { + throw new Exception("没有从TC中找到保存的查询"); + } + com.teamcenter.services.strong.query._2006_03.SavedQuery.SavedQueryObject query = null; + for (int i = 0; i < savedQueries.queries.length; i++) { + if ("Latest Item Revision...".equals(savedQueries.queries[i].name)) { + query = savedQueries.queries[i]; + break; + } + } + if (query == null) { + throw new Exception("TC中不存在“零组件...”查询"); + } + com.teamcenter.services.strong.query._2007_06.SavedQuery.SavedQueryInput savedQueryInput = new com.teamcenter.services.strong.query._2007_06.SavedQuery.SavedQueryInput(); + savedQueryInput.query = query.query; + savedQueryInput.entries = new String[]{"零组件 ID"}; + savedQueryInput.values = new String[]{itemID}; + com.teamcenter.services.strong.query._2007_06.SavedQuery.ExecuteSavedQueriesResponse res = queryService.executeSavedQueries(new com.teamcenter.services.strong.query._2007_06.SavedQuery.SavedQueryInput[]{savedQueryInput}); + throwServiceDataError(res.serviceData); + com.teamcenter.services.strong.query._2007_06.SavedQuery.SavedQueryResults found = res.arrayOfResults[0]; + return found.objects; + } + private KUtil() { + + } + public static String inArray2(String cName, List bomNames) { + if (KUtil.isEmpty(cName) || bomNames == null || bomNames.size() == 0) { + return ""; + } + for (String string : bomNames) { + + if(string.startsWith("@")) { + if (cName.contains(string.substring(1))) { + return string; + } + }else { + if (cName.contains(string)) { + return string; + } + } +// if (cName.indexOf(string) != -1) { +// return string; +// } + } + return ""; + } + public static void addRelation(String relationType,ItemRevision revision,ModelObject child){ + com.teamcenter.services.strong.core._2006_03.DataManagement.Relationship[] + rela_vec = new com.teamcenter.services.strong.core._2006_03.DataManagement.Relationship[1]; + com.teamcenter.services.strong.core._2006_03.DataManagement.Relationship + one_rela = new com.teamcenter.services.strong.core._2006_03.DataManagement.Relationship(); + one_rela.clientId = ""; + one_rela.primaryObject = revision; + one_rela.secondaryObject = child; + one_rela.relationType = relationType; + one_rela.userData = null; + rela_vec[0] = one_rela; + dmService.createRelations(rela_vec); + } + public static void removeRelation(String relationType,ItemRevision revision) throws Exception { +// revision.getPropertyObject() + refreshAndGetProperties(revision,relationType); + ModelObject[] modelObjectArrayValue = revision.getPropertyObject(relationType).getModelObjectArrayValue(); + for(ModelObject modelObject:modelObjectArrayValue){ + com.teamcenter.services.strong.core._2006_03.DataManagement.Relationship[] + rela_vec = new com.teamcenter.services.strong.core._2006_03.DataManagement.Relationship[1]; + com.teamcenter.services.strong.core._2006_03.DataManagement.Relationship + one_rela = new com.teamcenter.services.strong.core._2006_03.DataManagement.Relationship(); + one_rela.clientId = "Connor"; + one_rela.primaryObject = revision; + one_rela.secondaryObject = modelObject; + one_rela.relationType = relationType; + one_rela.userData = null; + rela_vec[0] = one_rela; + ServiceData serviceData = dmService.deleteRelations(rela_vec); + } + } + public static ItemRevision revise( ItemRevision revision,String revID) throws Exception { + if (revision == null ) { + return null; + } + System.out.println("升版"); + DataManagementService service = DataManagementService.getService(AppXSession.getConnection()); + service.refreshObjects(new ModelObject[] { revision }); + KUtil.refreshAndGetProperties(revision,"object_name"); + com.teamcenter.services.strong.core._2008_06.DataManagement.ReviseInfo info = new com.teamcenter.services.strong.core._2008_06.DataManagement.ReviseInfo(); + info.baseItemRevision = revision; +// info.newRevId = "B"; + info.clientId = "connor"; + info.name = revision.get_object_name(); + com.teamcenter.services.strong.core._2008_06.DataManagement.ReviseResponse2 resp = service.revise2(new com.teamcenter.services.strong.core._2008_06.DataManagement.ReviseInfo[] { info }); + System.out.println("升版结束"); + try { + throwServiceDataError(resp.serviceData); + }catch (Exception e){ + System.out.println(e.getMessage()); + } + for (String key : resp.reviseOutputMap.keySet()) { + com.teamcenter.services.strong.core._2008_06.DataManagement.ReviseOutput output = resp.reviseOutputMap.get(key); + if (output.newItemRev != null) { + return output.newItemRev; + } + } + return null; + } + public static void changeOwner(ModelObject newComp,User userOwn,Group group,DataManagementService dmService) { + com.teamcenter.services.strong.core._2006_03.DataManagement.ObjectOwner objectOwner + = new com.teamcenter.services.strong.core._2006_03.DataManagement.ObjectOwner(); + objectOwner.object = newComp; + objectOwner.owner = userOwn; + objectOwner.group = group; + //更改所有者 + dmService.changeOwnership(new com.teamcenter.services.strong.core._2006_03.DataManagement.ObjectOwner[]{objectOwner}); + } + public static ItemRevision createNewItemSoa( + String itemType, String itemName,Group group,User userOwn,ItemRevision zcRev) { + Item newComp = null; + ItemRevision itemRev = null; + try { + DataManagementService datamanagementservice = DataManagementService + .getService(AppXSession.getConnection()); + com.teamcenter.services.strong.core._2006_03.DataManagement.CreateItemsResponse createitemsresponse = null; + // 设置创建对象的主要属性 + com.teamcenter.services.strong.core._2006_03.DataManagement.ItemProperties aitemproperties[] = new com.teamcenter.services.strong.core._2006_03.DataManagement.ItemProperties[1]; + aitemproperties[0] = new com.teamcenter.services.strong.core._2006_03.DataManagement.ItemProperties(); + aitemproperties[0].clientId = Integer.toString(1); +// aitemproperties[0].itemId = itemID; + aitemproperties[0].name = itemName; + aitemproperties[0].type = itemType; + + ModelObject tccomponent1 = null; + String s1 = ""; + createitemsresponse = datamanagementservice.createItems( + aitemproperties, tccomponent1, s1); + if (createitemsresponse.serviceData.sizeOfPartialErrors() == 0) { + newComp = createitemsresponse.output[0].item; + itemRev = createitemsresponse.output[0].itemRev; + changeOwner(newComp,userOwn,group,dmService); + changeOwner(itemRev,userOwn,group,dmService); + com.teamcenter.services.strong.core._2006_03.DataManagement.Relationship[] + rela_vec = new com.teamcenter.services.strong.core._2006_03.DataManagement.Relationship[1]; + com.teamcenter.services.strong.core._2006_03.DataManagement.Relationship + one_rela = new com.teamcenter.services.strong.core._2006_03.DataManagement.Relationship(); + one_rela.clientId = ""; + one_rela.primaryObject = zcRev; + one_rela.secondaryObject = itemRev; + one_rela.relationType = "ZT2_CSHRelation"; + one_rela.userData = null; + rela_vec[0] = one_rela; + dmService.createRelations(rela_vec); + }else { + System.out.println(createitemsresponse.serviceData.getPartialError(0).getMessages()[0]); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + System.out.println("创建对象[item_id= " + " / name= " + itemName + "]失败"); + } + return itemRev; + } + /// + /// 上传附件 + /// + /// 版本附件 + /// 版本 + /// + public static Dataset uploadFile(String file_type, String namedReferencedName, String fileName, String filePath, + ModelObject rev,String fmsUrl,String cacheDir) + { + try + { + com.teamcenter.soa.client.Connection connection = AppXSession.getConnection(); + setByPass(true); + com.teamcenter.services.loose.core.DataManagementService dmService = com.teamcenter.services.loose.core.DataManagementService.getService(connection); + com.teamcenter.services.loose.core._2008_06.DataManagement.DatasetProperties2 + oneDatasetProp = new com.teamcenter.services.loose.core._2008_06.DataManagement.DatasetProperties2(); + com.teamcenter.services.loose.core._2008_06.DataManagement.DatasetProperties2[] + dataset_vec = new com.teamcenter.services.loose.core._2008_06.DataManagement.DatasetProperties2[1]; + oneDatasetProp.clientId = "Connor"; + oneDatasetProp.type = file_type; + oneDatasetProp.name = fileName; + oneDatasetProp.description = ""; + oneDatasetProp.container = null; + dataset_vec[0] = oneDatasetProp; + com.teamcenter.services.loose.core._2006_03.DataManagement.CreateDatasetsResponse + dsResp = dmService.createDatasets2(dataset_vec); + Dataset createdataset = (Dataset)dsResp.output[0].dataset; + + //create relationship + com.teamcenter.services.loose.core._2006_03.DataManagement.Relationship[] + rela_vec = new com.teamcenter.services.loose.core._2006_03.DataManagement.Relationship[1]; + com.teamcenter.services.loose.core._2006_03.DataManagement.Relationship + one_rela = new com.teamcenter.services.loose.core._2006_03.DataManagement.Relationship(); + one_rela.clientId = "Connor"; + one_rela.primaryObject = rev; + one_rela.secondaryObject = createdataset; + one_rela.relationType = "IMAN_specification"; + one_rela.userData = null; + rela_vec[0] = one_rela; + com.teamcenter.services.loose.core._2006_03.DataManagement.CreateRelationsResponse + reResp = dmService.createRelations(rela_vec); + + com.teamcenter.services.loose.core._2006_03.FileManagement.DatasetFileInfo[] fileInfos = new com.teamcenter.services.loose.core._2006_03.FileManagement.DatasetFileInfo[1]; + + com.teamcenter.services.loose.core._2006_03.FileManagement.DatasetFileInfo fileInfo = new com.teamcenter.services.loose.core._2006_03.FileManagement.DatasetFileInfo(); + + fileInfo.fileName = filePath; + fileInfo.allowReplace = true; + fileInfo.isText = false; + fileInfo.namedReferencedName = namedReferencedName; + fileInfos[0] = fileInfo; + com.teamcenter.services.loose.core._2006_03.FileManagement.GetDatasetWriteTicketsInputData inputData = new com.teamcenter.services.loose.core._2006_03.FileManagement.GetDatasetWriteTicketsInputData(); + inputData.dataset = createdataset; + inputData.createNewVersion = false; + inputData.datasetFileInfos = fileInfos; + com.teamcenter.services.loose.core._2006_03.FileManagement.GetDatasetWriteTicketsInputData[] inputs = new com.teamcenter.services.loose.core._2006_03.FileManagement.GetDatasetWriteTicketsInputData[1]; + inputs[0] = inputData; + String[] url = new String[]{fmsUrl}; + com.teamcenter.soa.client.FileManagementUtility fMSFileManagement = + new com.teamcenter.soa.client.FileManagementUtility(AppXSession.getConnection(), null, null, url, cacheDir); + ServiceData response = fMSFileManagement.putFiles(inputs); + + + System.out.println("开始更改所有者"); + //获取版本的所有者和所有组 + ItemRevision revision = (ItemRevision) rev; + dmService.getProperties(new ModelObject[]{revision}, new String[]{"owning_user", "owning_group"}); + + User ownUser = (User) revision.get_owning_user(); + Group ownGroup = (Group) revision.get_owning_group(); + com.teamcenter.services.loose.core._2006_03.DataManagement.ObjectOwner objectOwner + = new com.teamcenter.services.loose.core._2006_03.DataManagement.ObjectOwner(); + objectOwner.object = createdataset; + objectOwner.owner = ownUser; + objectOwner.group = ownGroup; + //更改所有者 + dmService.changeOwnership(new com.teamcenter.services.loose.core._2006_03.DataManagement.ObjectOwner[]{objectOwner}); + System.out.println("结束更改所有者"); + dmService.refreshObjects2(new ModelObject[]{revision, createdataset}, false); + +// if(createdObject!=null){ +// addToWorkflow(createdObject,createdataset,connection); +// } + + ModelObject[] datasets = new ModelObject[1]; + datasets[0] = createdataset; + dmService.refreshObjects(datasets); + +// //发布数据集 +// if(taskBean.getToPdf()!=null && taskBean.getToPdf().equals("Y")){ +// createProcess(createdataset.getUid(),"快速归档流程","快速归档流程",connection,dmService); +// } + + + setByPass(false); + new File(filePath).delete(); + return createdataset; + } + catch (Exception ex) + { + ex.printStackTrace(); + } + return null; + } + + public static void createProcess(String[] uids, String process_name, String process_temp) { + try { + com.teamcenter.soa.client.Connection connection = AppXSession.getConnection(); + System.out.println("process_temp:" + process_temp); + System.out.println("revisionUid:" + uids.length); + //创建流程 + WorkflowService wfService = WorkflowService.getService(connection); + + Workflow.ContextData contextData = new Workflow.ContextData(); + + String observerKey = ""; + String name = process_name; + String subject = ""; + String description = ""; + + contextData.processTemplate = process_temp; // update with your own ProcessTemplate. + contextData.subscribeToEvents = false; + contextData.subscriptionEventCount = 0; + contextData.attachmentCount = uids.length; + contextData.attachments = uids; + contextData.attachmentTypes = new int[]{1,1}; + //创建流程 + com.teamcenter.services.strong.workflow._2008_06.Workflow.InstanceInfo instanceInfo = + wfService.createInstance(true, observerKey, name, subject, description, contextData); + + System.out.println("创建流程完成!"); + } catch (Exception ex) { + System.out.println(ex.getMessage()); + } + } + public static void getChildTask(ScheduleTask fnd0SummaryTask, ArrayList child_tasks){ + try { + child_tasks.add(fnd0SummaryTask); + KUtil.refreshAndGetProperties(fnd0SummaryTask, "child_task_taglist"); + ScheduleTask[] child_task_taglist = fnd0SummaryTask.get_child_task_taglist(); + fnd0SummaryTask.get_fnd0ParentTask(); + for(ScheduleTask scheduleTask:child_task_taglist){ + getChildTask(scheduleTask,child_tasks); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static void checkLogin() throws Exception { + if (loginedUser == null) { + throw new Exception("请先登录"); + } + } + + public static User getLoginUser() { + return loginedUser; + } + + public static void log(Logger logger, String format, Object... args) { + if (args == null || args.length == 0) { + logger.error(format); + } else { + logger.error(String.format(format, args)); + } + } + + public static void log(Logger logger, String msg, Exception e) { + logger.error(msg, e); + } + public static GroupMember findGroupMember(String group, String role, String userId) + { + ImanQuery query = null; + GroupMember groupMember = null; + + SavedQueryService queryService = SavedQueryService.getService(session.getConnection()); + DataManagementService dmService= DataManagementService.getService(session.getConnection()); + try + { + GetSavedQueriesResponse savedQueries = queryService.getSavedQueries(); + if (savedQueries.queries.length == 0) + { + System.out.println("There are no saved queries in the system."); + return groupMember; + } + + for (int i = 0; i < savedQueries.queries.length; i++) + { + + if (savedQueries.queries[i].name.equals("__EINT_group_members")) + { + query = savedQueries.queries[i].query; + break; + } + } + } + catch (ServiceException e) + { + System.out.println("GetSavedQueries service request failed."); + System.out.println(e.getMessage()); + return groupMember; + } + + if (query == null) + { + System.out.println("There is not an '__EINT_group_members' query."); + return groupMember; + } + +// try +// { + com.teamcenter.services.strong.query._2008_06.SavedQuery.QueryInput savedQueryInput[] = new com.teamcenter.services.strong.query._2008_06.SavedQuery.QueryInput[1]; + savedQueryInput[0] = new com.teamcenter.services.strong.query._2008_06.SavedQuery.QueryInput(); + savedQueryInput[0].query = query; + savedQueryInput[0].entries = new String[3]; + savedQueryInput[0].values = new String[3]; + savedQueryInput[0].entries[0] = "Group"; + savedQueryInput[0].values[0] = "*"; + savedQueryInput[0].entries[1] = "Role"; + savedQueryInput[0].values[1] = "*"; + savedQueryInput[0].entries[2] = "User"; + savedQueryInput[0].values[2] = userId; + savedQueryInput[0].maxNumToReturn = 25; + + SavedQuery.SavedQueriesResponse savedQueryResult = queryService.executeSavedQueries(savedQueryInput); + SavedQuery.QueryResults found = savedQueryResult.arrayOfResults[0]; + + int length = found.objectUIDS.length; + + String[] uids = new String[length]; + for( int ii = 0; ii < length; ii++) + { + uids[ii]= found.objectUIDS[ii]; + } + ServiceData sd = dmService.loadObjects(uids); + ModelObject[] foundObjs = new ModelObject[ sd.sizeOfPlainObjects()]; + for( int k =0; k< sd.sizeOfPlainObjects(); k++) + { + foundObjs[k] = sd.getPlainObject(k); + } + groupMember = (GroupMember) foundObjs[0]; +// } +// catch (Exception e) +// { +// System.out.println("ExecuteSavedQuery service request failed."); +// System.out.println(e.getMessage()); +// } + return groupMember; + } + public static void logMsg(String msg){ + logger.error("/plm/updateMaterial:"+ msg); + } + + public synchronized static DataManagementService login(String url, String user, String password) throws Exception { + logger.error("登录到TC:" + user); + String group = ""; + String role = ""; + session = new AppXSession(url); + loginedUser = null; + System.out.println("logstart"); + try { + loginedUser = session.login(user, password, group, role); + } catch (Exception e) { + e.printStackTrace(); + logger.error("登录失败", e); + } + if (loginedUser == null) { + throw new Exception("登录到Teamcenter失败"); + } + System.out.println("logend"); + dmService = DataManagementService.getService(AppXSession.getConnection()); + queryService = SavedQueryService.getService(AppXSession.getConnection()); + KUtil.setByPass(true); + return dmService; + } + + public static void getProperties(ModelObject modelObject, String... properties) throws Exception { +// loadedObjects.put(modelObject.getUid(), modelObject); + ServiceData resp = dmService.getProperties(new ModelObject[]{modelObject}, properties); + checkPartialError(resp); + } + public static void getProperties(ModelObject[] modelObjects, String... properties) throws Exception { +// loadedObjects.put(modelObject.getUid(), modelObject); + ServiceData resp = dmService.getProperties(modelObjects, properties); + checkPartialError(resp); + } + public static String[] GetPrefValues(String prefName) throws Exception { + SessionService sessionService = SessionService.getService(AppXSession.getConnection()); + com.teamcenter.services.strong.core._2007_01.Session.ScopedPreferenceNames sprefName = new com.teamcenter.services.strong.core._2007_01.Session.ScopedPreferenceNames(); + sprefName.names = new String[] { prefName }; + sprefName.scope = "site"; + com.teamcenter.services.strong.core._2010_04.Session.MultiPreferenceResponse2 resp = sessionService.getPreferences2(new com.teamcenter.services.strong.core._2007_01.Session.ScopedPreferenceNames[] { sprefName }); + com.teamcenter.services.strong.core._2010_04.Session.ReturnedPreferences2[] prefs = resp.preferences; + if (prefs.length == 0) + throw new Exception("+ prefName + "); + String[] values = (prefs[0]).values; + if (values == null || values.length == 0) + throw new Exception("+ prefName + "); + return values; + } + public static void refreshAndGetProperties(ModelObject modelObject, String... properties) throws Exception { + ServiceData resp = dmService.refreshObjects(new ModelObject[]{modelObject}); +// checkPartialError(resp); + getProperties(modelObject, properties); + } + + public static List getGRMChildren(ModelObject modelObject, String relation, String[] typeNames) throws Exception { + List res = new ArrayList<>(); + ExpandGRMRelationsPref pref = new ExpandGRMRelationsPref(); + RelationAndTypesFilter2 filter = new RelationAndTypesFilter2(); + filter.relationName = relation; + filter.objectTypeNames = typeNames; + pref.expItemRev = false; + pref.info = new RelationAndTypesFilter2[]{filter}; + ExpandGRMRelationsResponse resp = dmService.expandGRMRelationsForPrimary(new ModelObject[]{modelObject}, pref); + checkPartialError(resp.serviceData); + ExpandGRMRelationsData[] datas = resp.output[0].otherSideObjData; + int len = KUtil.getLen(datas); + for (int i = 0; i < len; i++) { + ExpandGRMRelationsData data = datas[i]; + ModelObject[] cc = data.otherSideObjects; + int childCnt = KUtil.getLen(cc); + for (int j = 0; j < childCnt; j++) { + res.add(cc[i]); + } + } + return res; + } + + public synchronized static void logoutAndClearCache2() { + if (loginedUser == null) { + return; + } + KUtil.log(logger, "注销并释放资源"); + try { +// if (loadedObjects.size() > 0) { +// dmService.unloadObjects(loadedObjects.values().toArray(new ModelObject[]{})); +// } + } catch (Exception e) { + e.printStackTrace(); + KUtil.log(logger, "卸载对象失败", e); + } + try { + setByPass(false); + } catch (Exception e) { + e.printStackTrace(); + KUtil.log(logger, "关闭旁路失败", e); + } + session.logout(); + loginedUser = null; + KUtil.log(logger, "已结束"); + } + + public static void checkPartialError(ServiceData data) throws Exception { + if (data.sizeOfPartialErrors() > 0) { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < data.sizeOfPartialErrors(); i++) { + for (String msg : data.getPartialError(i).getMessages()) { + sb.append(msg + "\r\n"); + } + } + if (sb.length() > 0) { + throw new Exception(sb.toString()); + } + } + } + + public static boolean isEmpty(String str) { + return str == null || "".equals(str.trim()); + } + + public static ImanQuery findQuery(String queryName) throws Exception { + if (KUtil.isEmpty(queryName)) { + throw new Exception("查询名称不可为空"); + } + if (loadedQueries.containsKey(queryName)) { + return loadedQueries.get(queryName); + } + GetSavedQueriesResponse resp = queryService.getSavedQueries(); + checkPartialError(resp.serviceData); + int len = resp.queries == null ? 0 : resp.queries.length; + for (int i = 0; i < len; i++) { + SavedQueryObject queryObj = resp.queries[i]; + if (queryName.equals(queryObj.name)) { + loadedQueries.put(queryName, queryObj.query); + return queryObj.query; + } + } + throw new Exception("未找到保存的查询“" + queryName + "”"); + } + + public static List query(ImanQuery query, String[] entries, String[] values) throws Exception { + List res = new ArrayList<>(); + SavedQueryInput input = new SavedQueryInput(); + input.query = query; + input.entries = entries; + input.values = values; + input.resultsType = 0; + ExecuteSavedQueriesResponse resp = queryService.executeSavedQueries(new SavedQueryInput[]{input}); + checkPartialError(resp.serviceData); + for (ModelObject e : resp.arrayOfResults[0].objects) { + res.add(e); + } + return res; + } + public static String getDatasetName(Dataset dataset, DataManagementService dataManagementService) throws Exception { + dataManagementService.refreshObjects(new ModelObject[]{dataset}); + dataManagementService.getProperties(new ModelObject[]{dataset}, new String[]{"object_name"}); + return dataset.get_object_name(); + } + public static void log(org.slf4j.Logger logger, String msg) { + logger.warn(msg); + } + + public static void log(String msg) { + log(logger, msg); + } + public static void log(Exception e) { + log(logger, e); + } + public static void log(Logger logger, Exception e) { + logger.error(" getDesignList TCError: {}", e); + } + public static ModelObject[] query(String queryName, Map fields) throws Exception { + if (queryName == null || "".equals(queryName) || fields == null || fields.size() == 0) { + return null; + } + SavedQueryService queryService = SavedQueryService.getService(AppXSession.getConnection()); + com.teamcenter.services.strong.query._2006_03.SavedQuery.GetSavedQueriesResponse savedQueries = queryService.getSavedQueries(); + if (savedQueries.queries.length == 0) { + throw new Exception("没有从TC中找到保存的查询"); + } + com.teamcenter.services.strong.query._2006_03.SavedQuery.SavedQueryObject query = null; + for (int i = 0; i < savedQueries.queries.length; i++) { + if (queryName.equals(savedQueries.queries[i].name)) { + query = savedQueries.queries[i]; + break; + } + } + if (query == null) { + log("没有找到查询:" + queryName); + throw new Exception("TC中不存在“" + queryName + "”查询"); + } + log("执行查询:[" + queryName+"]"); + log("查询字段:" + fields.keySet()); + log("查询值:" + fields.values()); + com.teamcenter.services.strong.query._2007_06.SavedQuery.SavedQueryInput savedQueryInput = new com.teamcenter.services.strong.query._2007_06.SavedQuery.SavedQueryInput(); + savedQueryInput.query = query.query; + savedQueryInput.entries = fields.keySet().toArray(new String[]{});// new String[]{"Item ID"}; + savedQueryInput.values = fields.values().toArray(new String[]{});// new String[]{itemID}; + com.teamcenter.services.strong.query._2007_06.SavedQuery.ExecuteSavedQueriesResponse res = queryService.executeSavedQueries(new com.teamcenter.services.strong.query._2007_06.SavedQuery.SavedQueryInput[]{savedQueryInput}); + throwServiceDataError(res.serviceData); + com.teamcenter.services.strong.query._2007_06.SavedQuery.SavedQueryResults found = res.arrayOfResults[0]; + return found.objects; + } + /** + * 抛出soa异常 + * + * @param serviceData SOA结果数据 + * @throws Exception 有异常则抛出 + */ + 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).append("\n"); + } + } + // System.out.println(errInfo.toString()); + throw new Exception(errInfo.toString()); + } + } + public synchronized static void closeBOMWindow(BOMWindow bomWindow) + { + try { + com.teamcenter.services.strong.cad.StructureManagementService cadSMService + = com.teamcenter.services.strong.cad.StructureManagementService + .getService(AppXSession.getConnection()); + StructureManagement.CloseBOMWindowsResponse response = null; + com.teamcenter.services.strong.cad._2008_06.StructureManagement.SaveBOMWindowsResponse res = null; + if (cadSMService != null && bomWindow != null) + { + res = cadSMService.saveBOMWindows(new BOMWindow[]{bomWindow}); + response = + cadSMService.closeBOMWindows(new BOMWindow[] { bomWindow }); + } + if (response.serviceData.sizeOfPartialErrors() > 0) + { + for (int i = 0; i < response.serviceData + .sizeOfPartialErrors(); i++) + { + System.out.println("Close BOMWindow Partial Error -- "+response.serviceData + .getPartialError(i).getMessages()[0]); + } + } + if (res.serviceData.sizeOfPartialErrors() > 0) + { + for (int i = 0; i < res.serviceData + .sizeOfPartialErrors(); i++) + { + System.out.println("save BOMWindow Partial Error -- "+res.serviceData + .getPartialError(i).getMessages()[0]); + } + } + }catch (Exception e){ + e.printStackTrace(); + } + + } + public static ArrayList openBOMWindow(ItemRevision parentItemRev) + { + + ArrayList bomWindowandParentLine = new ArrayList<>(); + StructureManagement.CreateBOMWindowsInfo[] createBOMWindowsInfo = new StructureManagement.CreateBOMWindowsInfo[1]; + + + createBOMWindowsInfo[0] = new StructureManagement.CreateBOMWindowsInfo(); + createBOMWindowsInfo[0].itemRev = (ItemRevision) parentItemRev; + com.teamcenter.services.strong.cad.StructureManagementService cadSMService = + com.teamcenter.services.strong.cad.StructureManagementService + .getService(AppXSession.getConnection()); + + StructureManagement.CreateBOMWindowsResponse createBOMWindowsResponse = + cadSMService.createBOMWindows(createBOMWindowsInfo); +// cadSMService. +// cadSMService.d + if (createBOMWindowsResponse.serviceData.sizeOfPartialErrors() > 0) + { + for (int i = 0; i < createBOMWindowsResponse.serviceData + .sizeOfPartialErrors(); i++) { + + System.out.println("Partial Error in Open BOMWindow = "+createBOMWindowsResponse.serviceData + .getPartialError(i).getMessages()[0]); + } + } + + bomWindowandParentLine.add(createBOMWindowsResponse.output[0].bomWindow);//BOMWindow + BOMLine bomLine = createBOMWindowsResponse.output[0].bomLine; + bomWindowandParentLine.add(bomLine);//TOPLine in BOMWINDOW +// bomLine.get_bl_child_lines() +// bomLine.get_fnd0bl_markup_subs_objs_add(). + return bomWindowandParentLine; + } + public static void setByPass(boolean b) throws Exception { + Session.StateNameValue[] propPairs = new Session.StateNameValue[1]; + propPairs[0] = new Session.StateNameValue(); + propPairs[0].name = new String("bypassFlag"); + propPairs[0].value = new String(Property.toBooleanString(b)); + ServiceData data = SessionService.getService(AppXSession.getConnection()).setUserSessionState(propPairs); + checkPartialError(data); + } + + public static void setProperty(ModelObject mo, String propName, String propValue) throws Exception { + Map properties = new HashMap<>(); + DataManagement.VecStruct vec = new DataManagement.VecStruct(); + vec.stringVec = new String[]{propValue}; + properties.put(propName, vec); + ServiceData sd = dmService.setProperties(new ModelObject[]{mo}, properties); + checkPartialError(sd); + } + public static void setPropertys(ModelObject[] mos, String propName, String propValue) throws Exception { + Map properties = new HashMap<>(); + DataManagement.VecStruct vec = new DataManagement.VecStruct(); + vec.stringVec = new String[]{propValue}; + properties.put(propName, vec); + ServiceData sd = dmService.setProperties(mos, properties); + checkPartialError(sd); + } + public static void refreshModsAndGetProperties(ModelObject[] modelObjects, String... properties) throws Exception { + ServiceData resp = dmService.refreshObjects(modelObjects); + getProperties(modelObjects, properties); + } + public static List query(String queryName, String[] entries, String[] values) throws Exception { + KUtil.log(logger, "执行查询 %s %s = %s", queryName, Arrays.toString(entries), Arrays.toString(values)); + SavedQueryService queryService = SavedQueryService.getService(AppXSession.getConnection()); + ImanQuery query = null; + GetSavedQueriesResponse savedQueries = queryService.getSavedQueries(); + for (int i = 0; i < savedQueries.queries.length; i++) { +// System.out.println("queries[i]==>" + savedQueries.queries[i].name); + if (!savedQueries.queries[i].name.equals(queryName)) + { + continue; + } + query = savedQueries.queries[i].query; + break; + } + if (query == null) { + System.out.println("There is not an " + queryName + " query."); + return null; + } + List res = new ArrayList<>(); + SavedQueryInput input = new SavedQueryInput(); + input.query = query; + input.entries = entries; + input.values = values; + input.resultsType = 0; + ExecuteSavedQueriesResponse resp = queryService.executeSavedQueries(new SavedQueryInput[]{input}); + checkPartialError(resp.serviceData); + KUtil.log(logger, "查询结果数 = %d", resp.arrayOfResults[0].objects.length); + Collections.addAll(res, resp.arrayOfResults[0].objects); + return res; + } + + + public static int getLen(E[] arr) { + return arr == null ? 0 : arr.length; + } + + + public static String getMessage(Exception e) { + String message = e.getLocalizedMessage(); + if (KUtil.isEmpty(message)) { + message = e.getClass().getName() + " - 无详细信息"; + } + return message; + } + + public static String getStackTrace(Exception e) { + StringBuilder rError = new StringBuilder("" + e.getMessage()); + for(StackTraceElement ste : e.getStackTrace()) { + rError.append("\n\t").append(ste.toString()); + } + return rError.toString(); + } + public static boolean equals(Object o1, Object o2){ + if(o1 == null){ + return o2 == null; + }else if(o2 == null){ + return false; + }else{ + return o1.equals(o2); + } + } + + /* + * + * + * */ + public static String TCFileToFile(FileManagementUtility fmu, Dataset dataset) throws Exception { + if(dataset == null){ + return null; + } + String filename = ""; + dmService.getProperties(new ModelObject[] { dataset }, new String[]{ "ref_list"}); + ModelObject[] objects = dataset.get_ref_list(); + dmService.getProperties(objects, new String[] { "original_file_name" }); + filename = objects[0].getPropertyDisplayableValue("original_file_name");//.getStringValue(); +// filename = new Date() + filename; + GetFileResponse getFileResponse = fmu.getFiles(objects); + File[] fileinfovec = getFileResponse.getFiles(); + // + File download = new File(fileinfovec[0].getParentFile().getPath() + "\\" + filename); + fileinfovec[0].renameTo(download); +// return fileinfovec[0].getPath(); + return download.getPath(); + } + + /** + * 创建数据集(无文件) + * @param datasetName 数据集名称 + * @param type 数据集类型 + * @return 数据集 + */ + public static Dataset createDatset(String datasetName, String type) throws Exception { + Dataset dataset = null; + //获取service +// DataManagementService dmService = DataManagementService.getService(session.getConnection()); + System.out.println("开始创建数据集ok"); + logger.info("开始创建数据集ok"); + DatasetInfo[] datasetInfos = new DatasetInfo[1]; + datasetInfos[0] = new DatasetInfo(); + datasetInfos[0].name = datasetName; + datasetInfos[0].type = type; + datasetInfos[0].description = "TCServerCreate"; + + com.teamcenter.services.strong.core._2010_04.DataManagement.CreateDatasetsResponse response = dmService.createDatasets(datasetInfos); + throwServiceDataError(response.servData); + + System.out.println("创建数据集ok"); + logger.info("创建数据集ok"); + dataset = response.datasetOutput[0].dataset; + + return dataset; + } + /** + * 文件转为数据集上传到tc + * @param file 文件 + * @param dataset 数据集 + * @param refName 数据集引用名称 + * @param fmu 文件管理服务 + * @return 是否成功 + */ + public static boolean uploadFileToTc(File file, Dataset dataset, String refName, FileManagementUtility fmu){ + try { + System.out.println("开始添加引用"); + FileManagement.DatasetFileInfo[] datasetFileInfos = new FileManagement.DatasetFileInfo[1]; + datasetFileInfos[0] = new FileManagement.DatasetFileInfo(); + datasetFileInfos[0].fileName = file.getAbsolutePath(); + datasetFileInfos[0].allowReplace = true; + datasetFileInfos[0].isText = false; + datasetFileInfos[0].namedReferencedName = refName; + System.out.println("1:"+"设置基本属性"); + FileManagement.GetDatasetWriteTicketsInputData inputData = new FileManagement.GetDatasetWriteTicketsInputData(); + inputData.dataset = dataset; + //true 为增加,false为替换 + System.out.println("2:"+"开始增加引用文件"); + inputData.createNewVersion = true; + inputData.datasetFileInfos = datasetFileInfos; + dmService.refreshObjects2(new ModelObject[] { dataset }, false); + ModelObject[] datasets = new ModelObject[]{ dataset }; + dmService.getProperties(datasets, new String[] { "checked_out", "ref_list" }); + String check_out = dataset.get_checked_out(); + System.out.println("3:"+"判断是否签出"); + logger.info("是否签出: " + check_out); + if("Y".equals(check_out)){ + ReservationService reservationService = ReservationService.getService(session.getConnection()); + reservationService.checkin(datasets); + } + System.out.println("4:"+"获取数据集的命名引用数量"); + ModelObject[] refModel = dataset.get_ref_list(); + int refLength = refModel == null ? 0 : refModel.length; + logger.info("命名引用数量" + refLength); + + System.out.println("获取文件管理器"); + FileManagement.GetDatasetWriteTicketsInputData[] inputs = new FileManagement.GetDatasetWriteTicketsInputData[1]; + inputs[0] = inputData; +// String fmsurl = savadataApplication.TC_FMSURL; +// logger.info("卷链接: "+fmsurl); +// FileManagementUtility fmu = new FileManagementUtility(session.getConnection(), +// null, new String[]{fmsurl}, new String[]{fmsurl}, fcc); + ServiceData serviceData = null; + int breakTime = 0; + System.out.println("开始上传引用文件"); + while (true){ + serviceData = fmu.putFiles(inputs); + if(serviceData != null && serviceData.sizeOfPartialErrors() > 0){ + try { + throwServiceDataError(serviceData); + } catch (Exception e) { + e.printStackTrace(); + logger.info("上传文件错误,信息:" + getStackTrace(e)); + } + }else { + dmService.refreshObjects2(new ModelObject[]{ dataset }, false); + refModel = dataset.get_ref_list(); + refLength = refModel == null ? 0 : refModel.length; + logger.info("上传后,命名引用数量" + refLength); + if(refLength > 0){ + break; + } + } + breakTime ++; + Thread.sleep(5000); + if(breakTime > 5){ + System.out.println("循环5次上传文件依旧失败,不再上传"); + logger.info("循环5次上传文件依旧失败,不再上传"); + return false; + } + } +// dmService.refreshObjects2(new ModelObject[]{ dataset }, false); + System.out.println("结束上传文件"); + logger.info("结束上传文件"); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } +} \ No newline at end of file diff --git a/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/util/RelationUtils.java b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/util/RelationUtils.java new file mode 100644 index 0000000..592d206 --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/connor/connor_cpzc_service/util/RelationUtils.java @@ -0,0 +1,346 @@ +package com.connor.connor_cpzc_service.util; + +import com.teamcenter.services.strong.core.DataManagementService; +import com.teamcenter.services.strong.core._2007_01.DataManagement; +import com.teamcenter.soa.client.model.ModelObject; +import com.teamcenter.soa.client.model.strong.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.validation.constraints.NotNull; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * 关系查找工具类 + */ +public class RelationUtils { + + private static final Logger logger = LoggerFactory.getLogger(RelationUtils.class); + + // 项目零组件 + private static final String OBJECT_TYPE_PROJECT_ITEM = "ZT2_ProjectItem"; + + // 公共文件夹 + private static final String OBJECT_TYPE_PROJECT_FOLDER = "ZT2_ProjectFolder"; + + // 图纸模型 + private static final String OBJECT_TYPE_DESIGN = "ZT2_Design3D"; + + // 图纸模型版本 + private static final String OBJECT_TYPE_DESIGN_REVISION = "ZT2_Design3DRevision"; + + /** + * 获取引用信息 + * @param dataManagementService 数据管理服务 + * @param currentObject 当前工作对象 + * @return 引用信息 + * @throws Exception 异常处理 + */ + public static List getWhereReferencedInfos(DataManagementService dataManagementService, WorkspaceObject currentObject) throws Exception { + List referencedInfos = new ArrayList<>(); + // 何处引用响应 + DataManagement.WhereReferencedResponse referencedResponse = dataManagementService.whereReferenced(new WorkspaceObject[]{currentObject}, 1); + KUtil.throwServiceDataError(referencedResponse.serviceData); + int outputSize = referencedResponse.output.length; + logger.warn("找到引用输出 {} 项", outputSize); + for (int i = 0; i < outputSize; i++) { + // 何处引用输出 + DataManagement.WhereReferencedOutput referencedOutput = referencedResponse.output[i]; + int infoSize = referencedOutput.info.length; + logger.warn("找到引用信息 {} 项", infoSize); + for (int j = 0; j < infoSize; j++) { + // 何处引用信息 + DataManagement.WhereReferencedInfo referencedInfo = referencedOutput.info[j]; + // 当前引用对象 + WorkspaceObject referencedObject = referencedInfo.referencer; + if (referencedObject != null) { + referencedInfos.add(referencedInfo); + } + } + } + return referencedInfos; + } + + /** + * 获取引用对象 + * @param dataManagementService 数据管理服务 + * @param currentObject 当前工作对象 + * @return 引用对象 + * @throws Exception 异常处理 + */ + public static List getWhereReferencedObjects(DataManagementService dataManagementService, WorkspaceObject currentObject) throws Exception { + List referencedObjects = new ArrayList<>(); + List referencedInfos = getWhereReferencedInfos(dataManagementService, currentObject); + if (!referencedInfos.isEmpty()) { + for (DataManagement.WhereReferencedInfo referencedInfo : referencedInfos) { + // 当前引用对象 + WorkspaceObject referencedObject = referencedInfo.referencer; + if (referencedObject != null) { + referencedObjects.add(referencedObject); + } + } + } + return referencedObjects; + } + + /** + * 递归调用查找引用对象 + * [反向查找:出厂编号-图纸模型版本-图纸模型] + * @param dataManagementService 数据管理服务 + * @param currentObject 当前工作对象 + * @return 引用对象 + * @throws Exception 异常处理 + */ + public static List getDesignByFactoryNo(DataManagementService dataManagementService, WorkspaceObject currentObject) throws Exception { + List resultObjects = new ArrayList<>(); + List referencedInfos = getWhereReferencedInfos(dataManagementService, currentObject); + if (!referencedInfos.isEmpty()) { + for (DataManagement.WhereReferencedInfo referencedInfo : referencedInfos) { + WorkspaceObject referencedObject = referencedInfo.referencer; + if (referencedObject != null) { + // 获取属性 + dataManagementService.getProperties( + new ModelObject[]{referencedObject}, + new String[]{"object_type", "object_string","ZT2_FactoryNumber","IMAN_specification"}); + String type = referencedObject.get_object_type(); + String name = referencedObject.get_object_string(); + logger.warn("找到引用对象 类型:<{}>,名称:<{}>,关系:<{}>", type, name, referencedInfo.relation); + if (OBJECT_TYPE_DESIGN_REVISION.equals(type)) { + // 图纸模型版本 + resultObjects.addAll(getDesignByFactoryNo(dataManagementService, referencedObject)); + } else if (OBJECT_TYPE_DESIGN.equals(type)) { + // 图纸模型 + resultObjects.add(referencedObject); + } + } + } + } + return resultObjects; + } + + /** + * 递归调用查找引用对象 + * [反向查找:出厂编号-图纸模型版本] + * @param dataManagementService 数据管理服务 + * @param currentObject 当前工作对象 + * @return 引用对象 + * @throws Exception 异常处理 + */ + public static List getDesignRevisionByFactoryNo(DataManagementService dataManagementService, WorkspaceObject currentObject) throws Exception { + List resultObjects = new ArrayList<>(); + List referencedInfos = getWhereReferencedInfos(dataManagementService, currentObject); + if (!referencedInfos.isEmpty()) { + for (DataManagement.WhereReferencedInfo referencedInfo : referencedInfos) { + WorkspaceObject referencedObject = referencedInfo.referencer; + if (referencedObject != null) { + // 获取属性 + dataManagementService.getProperties( + new ModelObject[]{referencedObject}, + new String[]{"object_type", "object_string","ZT2_FactoryNumber","IMAN_specification"}); + String type = referencedObject.get_object_type(); + String name = referencedObject.get_object_string(); + logger.warn("找到引用对象 类型:<{}>,名称:<{}>,关系:<{}>", type, name, referencedInfo.relation); + if (OBJECT_TYPE_DESIGN_REVISION.equals(type)) { + // 图纸模型版本 + resultObjects.add(referencedObject); + } + } + } + } + return resultObjects; + } + + /** + * 递归调用查找引用对象 + * [反向查找:出厂编号-出厂编号-项目启动-项目对象] + * @param dataManagementService 数据管理服务 + * @param currentObject 当前工作对象 + * @return 引用对象 + * @throws Exception 异常处理 + */ + public static List getItemByFactoryNo(DataManagementService dataManagementService, WorkspaceObject currentObject) throws Exception { + List resultObjects = new ArrayList<>(); + List referencedInfos = getWhereReferencedInfos(dataManagementService, currentObject); + if (!referencedInfos.isEmpty()) { + for (DataManagement.WhereReferencedInfo referencedInfo : referencedInfos) { + WorkspaceObject referencedObject = referencedInfo.referencer; + if (referencedObject != null) { + // 获取属性 + dataManagementService.getProperties( + new ModelObject[]{referencedObject}, + new String[]{"object_type", "object_string","ZT2_FactoryNumber","IMAN_specification"}); + String type = referencedObject.get_object_type(); + String name = referencedObject.get_object_string(); + logger.warn("找到引用对象 类型:<{}>,名称:<{}>,关系:<{}>", type, name, referencedInfo.relation); + if (OBJECT_TYPE_PROJECT_FOLDER.equals(type) && "出厂编号".equals(name)) { + // 出厂编号 + resultObjects.addAll(getItemByFactoryNo(dataManagementService, referencedObject)); + } else if (OBJECT_TYPE_PROJECT_FOLDER.equals(type) && "项目启动".equals(name)) { + // 项目启动 + resultObjects.addAll(getItemByFactoryNo(dataManagementService, referencedObject)); + } else if (OBJECT_TYPE_PROJECT_ITEM.equals(type)) { + // 项目对象 + resultObjects.add(referencedObject); + } + } + } + } + return resultObjects; + } + + /** + * 获取引用对象 + * @param dataManagementService 数据管理服务 + * @param currentObject 当前工作对象 + * @return 引用对象 + * @throws Exception 异常处理 + */ + public static ModelObject[] getReferenceObjects(@NotNull DataManagementService dataManagementService, @NotNull WorkspaceObject currentObject) throws Exception { + Item item = (Item) currentObject; + dataManagementService.getProperties(new ModelObject[]{item}, new String[]{"IMAN_reference"}); + return item.get_IMAN_reference(); + } + + /** + * 获取内容对象 + * @param dataManagementService 数据管理服务 + * @param currentObject 当前工作对象 + * @return 引用对象 + * @throws Exception 异常处理 + */ + public static WorkspaceObject[] getContentObjects(@NotNull DataManagementService dataManagementService, @NotNull WorkspaceObject currentObject) throws Exception { + Folder folder = (Folder) currentObject; + dataManagementService.getProperties(new ModelObject[]{folder}, new String[]{"contents"}); + return folder.get_contents(); + } + + /** + * 获取内容对象 + * @param dataManagementService 数据管理服务 + * @param currentObject 当前工作对象 + * @param objectType 对象类型 + * @return 内容对象 + * @throws Exception 异常处理 + */ + public static WorkspaceObject[] getContentObjects(@NotNull DataManagementService dataManagementService, @NotNull WorkspaceObject currentObject, @NotNull String objectType) throws Exception { + dataManagementService.getProperties( + new ModelObject[]{currentObject}, + new String[]{"object_type", "object_string"}); + logger.warn("找到内容对象 类型:<{}>,名称:<{}>", currentObject.get_object_type(), currentObject.get_object_string()); + if (objectType.equals(currentObject.get_object_type()) ) { + return getContentObjects(dataManagementService, currentObject); + } else { + return new WorkspaceObject[0]; + } + } + + /** + * 获取内容对象 + * @param dataManagementService 数据管理服务 + * @param currentObject 当前工作对象 + * @param objectType 对象类型 + * @param objectName 对象名称 + * @return 内容对象 + * @throws Exception 异常处理 + */ + public static WorkspaceObject[] getContentObjects(@NotNull DataManagementService dataManagementService, @NotNull WorkspaceObject currentObject, @NotNull String objectType, @NotNull String objectName) throws Exception { + dataManagementService.getProperties( + new ModelObject[]{currentObject}, + new String[]{"object_type", "object_string"}); + logger.warn("找到内容对象 类型:<{}>,名称:<{}>", currentObject.get_object_type(), currentObject.get_object_string()); + if (objectType.equals(currentObject.get_object_type()) && objectName.equals(currentObject.get_object_string())) { + return getContentObjects(dataManagementService, currentObject); + } else { + return new WorkspaceObject[0]; + } + } + + public static WorkspaceObject[] getDesignRevisionObjects(@NotNull DataManagementService dataManagementService, @NotNull WorkspaceObject currentObject) throws Exception { + List resultObjects = new ArrayList<>(); + Item item = (Item) currentObject; + dataManagementService.getProperties(new ModelObject[]{item}, new String[]{"revision_list"}); + // 所有版本 + ModelObject[] modelObjects = item.get_revision_list(); + if (modelObjects!=null) { + int lastRevisionNo = -1; + ItemRevision lastRevisionObject = null; + for (int i = 0; i < modelObjects.length; i++) { + ItemRevision revisionObject = (ItemRevision) modelObjects[i]; + dataManagementService.getProperties( + new ModelObject[]{revisionObject}, + new String[]{"release_status_list"}); + // 发布状态 + ReleaseStatus[] releaseStatuses = revisionObject.get_release_status_list(); + if (releaseStatuses.length == 0) { + continue; + } + // 最新版本 + dataManagementService.getProperties(new ModelObject[]{revisionObject}, new String[]{"item_revision_id"}); + String revisionId = revisionObject.get_item_revision_id(); + int currRevisionNo = Integer.parseInt(revisionId.replace("V", "")); + if (currRevisionNo > lastRevisionNo) { + lastRevisionNo = currRevisionNo; + lastRevisionObject = revisionObject; + } + } + if (lastRevisionObject!=null) { + dataManagementService.getProperties( + new ModelObject[]{lastRevisionObject}, + new String[]{"object_type", "object_string"}); + logger.warn("找到图纸模型版本 类型:<{}>,名称:<{}>", lastRevisionObject.get_object_type(), lastRevisionObject.get_object_string()); + resultObjects.add(lastRevisionObject); + } + return resultObjects.toArray(new WorkspaceObject[0]); + } else { + return new WorkspaceObject[0]; + } + } + + public static WorkspaceObject[] getDesignRevisionObjects(@NotNull DataManagementService dataManagementService, @NotNull WorkspaceObject currentObject, @NotNull String objectType) throws Exception { + dataManagementService.getProperties( + new ModelObject[]{currentObject}, + new String[]{"object_type", "object_string"}); + logger.warn("找到图纸模型 类型:<{}>,名称:<{}>", currentObject.get_object_type(), currentObject.get_object_string()); + if (objectType.equals(currentObject.get_object_type())) { + return getDesignRevisionObjects(dataManagementService, currentObject); + } else { + return new WorkspaceObject[0]; + } + } + + public static List getDesignRevisionByItem(@NotNull DataManagementService dataManagementService, @NotNull WorkspaceObject currentObject) throws Exception { + List resultObjects = new ArrayList<>(); + // 引用对象集合 + ModelObject[] referenceObjects = RelationUtils.getReferenceObjects(dataManagementService, currentObject); + for (ModelObject modelObject : referenceObjects) { + WorkspaceObject referenceObject = (WorkspaceObject) modelObject; + // 公共文件夹[项目执行]-内容对象集合 + WorkspaceObject[] projectExecuteCOs = RelationUtils.getContentObjects(dataManagementService, referenceObject, "ZT2_ProjectFolder", "项目执行"); + for (WorkspaceObject projectExecuteCO : projectExecuteCOs) { + // 公共文件夹[电气图纸]-内容对象集合 + WorkspaceObject[] designCOs = RelationUtils.getContentObjects(dataManagementService, projectExecuteCO, "ZT2_ProjectFolder", "电气图纸"); + for (WorkspaceObject designCO : designCOs) { + // 图纸模型版本集合 + WorkspaceObject[] designRevisionObjects = RelationUtils.getDesignRevisionObjects(dataManagementService, designCO, "ZT2_Design3D"); + if (designRevisionObjects.length > 0) { + Collections.addAll(resultObjects, designRevisionObjects); + } + } + } + } + return resultObjects; + } + + public static List getDesignRevisionByItems(@NotNull DataManagementService dataManagementService, @NotNull List currentObjects) throws Exception { + List resultObjects = new ArrayList<>(); + if (!currentObjects.isEmpty()) { + for (WorkspaceObject currentObject : currentObjects) { + resultObjects.addAll(getDesignRevisionByItem(dataManagementService, currentObject)); + } + } + return resultObjects; + } + +} diff --git a/connor_cpzc_service/src/main/java/com/teamcenter/clientx/AppXCredentialManager.java b/connor_cpzc_service/src/main/java/com/teamcenter/clientx/AppXCredentialManager.java new file mode 100644 index 0000000..9c2513e --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/teamcenter/clientx/AppXCredentialManager.java @@ -0,0 +1,143 @@ +//================================================== +// +// Copyright 2017 Siemens Product Lifecycle Management Software Inc. All Rights Reserved. +// +//================================================== + +package com.teamcenter.clientx; + +import com.teamcenter.schemas.soa._2006_03.exceptions.InvalidCredentialsException; +import com.teamcenter.schemas.soa._2006_03.exceptions.InvalidUserException; +import com.teamcenter.soa.client.CredentialManager; +import com.teamcenter.soa.exceptions.CanceledOperationException; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.LineNumberReader; + +/** + * The CredentialManager is used by the Teamcenter Services framework to get the + * user's credentials when challenged by the server. This can occur after a period + * of inactivity and the server has timed-out the user's session, at which time + * the client application will need to re-authenticate. The framework will + * call one of the getCredentials methods (depending on circumstances) and will + * send the SessionService.login service request. Upon successful completion of + * the login service request. The last service request (one that caused the challenge) + * will be resent. + * + * The framework will also call the setUserPassword setGroupRole methods when ever + * these credentials change, thus allowing this implementation of the CredentialManager + * to cache these values so prompting of the user is not required for re-authentication. + * + */ +public class AppXCredentialManager implements CredentialManager +{ + + private String name = null; + private String password = null; + private String group = ""; // default group + private String role = ""; // default role + private String discriminator = "SoaAppX"; // always connect same user + // to same instance of server + + /** + * Return the type of credentials this implementation provides, + * standard (user/password) or Single-Sign-On. In this case + * Standard credentials are returned. + * + * @see com.teamcenter.soa.client.CredentialManager#getCredentialType() + */ + public int getCredentialType() + { + return CredentialManager.CLIENT_CREDENTIAL_TYPE_STD; + } + + /** + * Prompt's the user for credentials. + * This method will only be called by the framework when a login attempt has + * failed. + * + * @see com.teamcenter.soa.client.CredentialManager#getCredentials(com.teamcenter.schemas.soa._2006_03.exceptions.InvalidCredentialsException) + */ + public String[] getCredentials(InvalidCredentialsException e) + throws CanceledOperationException + { + System.out.println(e.getMessage()); + return promptForCredentials(); + } + + /** + * Return the cached credentials. + * This method will be called when a service request is sent without a valid + * session ( session has expired on the server). + * + * @see com.teamcenter.soa.client.CredentialManager#getCredentials(com.teamcenter.schemas.soa._2006_03.exceptions.InvalidUserException) + */ + public String[] getCredentials(InvalidUserException e) + throws CanceledOperationException + { + // Have not logged in yet, should not happen but just in case + if (name == null) return promptForCredentials(); + + // Return cached credentials + String[] tokens = { name, password, group, role, discriminator }; + return tokens; + } + + /** + * Cache the group and role + * This is called after the SessionService.setSessionGroupMember service + * operation is called. + * + * @see com.teamcenter.soa.client.CredentialManager#setGroupRole(String, + * String) + */ + public void setGroupRole(String group, String role) + { + this.group = group; + this.role = role; + } + + /** + * Cache the User and Password + * This is called after the SessionService.login service operation is called. + * + * @see com.teamcenter.soa.client.CredentialManager#setUserPassword(String, + * String, String) + */ + public void setUserPassword(String user, String password, String discriminator) + { + this.name = user; + this.password = password; + this.discriminator = discriminator; + } + + + public String[] promptForCredentials() + throws CanceledOperationException + { + try + { + LineNumberReader reader = new LineNumberReader(new InputStreamReader(System.in)); + System.out.println("Please enter user credentials (return to quit):"); + System.out.print("User Name: "); + name = reader.readLine(); + + if (name.length() == 0) + throw new CanceledOperationException(""); + + System.out.print("Password: "); + password = reader.readLine(); + } + catch (IOException e) + { + String message = "Failed to get the name and password.\n" + e.getMessage(); + System.out.println(message); + throw new CanceledOperationException(message); + } + + String[] tokens = { name, password, group, role, discriminator }; + return tokens; + } + +} diff --git a/connor_cpzc_service/src/main/java/com/teamcenter/clientx/AppXExceptionHandler.java b/connor_cpzc_service/src/main/java/com/teamcenter/clientx/AppXExceptionHandler.java new file mode 100644 index 0000000..72a463c --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/teamcenter/clientx/AppXExceptionHandler.java @@ -0,0 +1,48 @@ +//================================================== +// +// Copyright 2017 Siemens Product Lifecycle Management Software Inc. All Rights Reserved. +// +//================================================== + +package com.teamcenter.clientx; + +import com.teamcenter.schemas.soa._2006_03.exceptions.InternalServerException; +import com.teamcenter.soa.client.ExceptionHandler; +import com.teamcenter.soa.exceptions.CanceledOperationException; + +/** + * Implementation of the ExceptionHandler. For ConnectionExceptions (server + * temporarily down .etc) prompts the user to retry the last request. For other + * exceptions convert to a RunTime exception. + */ +public class AppXExceptionHandler implements ExceptionHandler +{ + + /* + * (non-Javadoc) + * + * @see com.teamcenter.soa.client.ExceptionHandler#handleException(com.teamcenter.schemas.soa._2006_03.exceptions.InternalServerException) + */ + public void handleException(InternalServerException ise) + { + throw new RuntimeException(ise.getMessage()); + } + + /* + * (non-Javadoc) + * + * @see com.teamcenter.soa.client.ExceptionHandler#handleException(com.teamcenter.soa.exceptions.CanceledOperationException) + */ + public void handleException(CanceledOperationException coe) + { + System.out.println(""); + System.out.println("*****"); + System.out.println("Exception caught in com.teamcenter.clientx.AppXExceptionHandler.handleException(CanceledOperationException)."); + + // Expecting this from the login tests with bad credentials, and the + // AnyUserCredentials class not + // prompting for different credentials + throw new RuntimeException(coe); + } + +} diff --git a/connor_cpzc_service/src/main/java/com/teamcenter/clientx/AppXSession.java b/connor_cpzc_service/src/main/java/com/teamcenter/clientx/AppXSession.java new file mode 100644 index 0000000..30c679a --- /dev/null +++ b/connor_cpzc_service/src/main/java/com/teamcenter/clientx/AppXSession.java @@ -0,0 +1,184 @@ +//================================================== +// +// Copyright 2017 Siemens Product Lifecycle Management Software Inc. All Rights Reserved. +// +//================================================== + +package com.teamcenter.clientx; + + +import com.teamcenter.schemas.soa._2006_03.exceptions.InvalidCredentialsException; +import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException; +import com.teamcenter.services.strong.core.SessionService; +import com.teamcenter.services.strong.core._2006_03.Session.LoginResponse; +import com.teamcenter.soa.SoaConstants; +import com.teamcenter.soa.client.Connection; +import com.teamcenter.soa.client.model.strong.User; +import com.teamcenter.soa.exceptions.CanceledOperationException; + +import java.util.UUID; + + +public class AppXSession +{ + /** + * Single instance of the Connection object that is shared throughout + * the application. This Connection object is needed whenever a Service + * stub is instantiated. + */ + private static Connection connection; + + /** + * The credentialManager is used both by the Session class and the Teamcenter + * Services Framework to get user credentials. + * + */ + private static AppXCredentialManager credentialManager; + + /** + * Create an instance of the Session with a connection to the specified + * server. + * + * Add implementations of the ExceptionHandler, PartialErrorListener, + * ChangeListener, and DeleteListeners. + * + * @param host Address of the host to connect to, http://serverName:port/tc + */ + public AppXSession(String host) + { + // Create an instance of the CredentialManager, this is used + // by the SOA Framework to get the user's credentials when + // challenged by the server (session timeout on the web tier). + credentialManager = new AppXCredentialManager(); + + String protocol=null; + String envNameTccs = null; + if ( host.startsWith("http") ) + { + protocol = SoaConstants.HTTP; + } + else if ( host.startsWith("tccs") ) + { + protocol = SoaConstants.TCCS; + host = host.trim(); + int envNameStart = host.indexOf('/') + 2; + envNameTccs = host.substring( envNameStart, host.length() ); + host = ""; + } + else + { + protocol = SoaConstants.IIOP; + } + + + // Create the Connection object, no contact is made with the server + // until a service request is made + connection = new Connection(host, credentialManager, SoaConstants.REST, protocol); + + if( protocol == SoaConstants.TCCS ) + { + connection.setOption( Connection.TCCS_ENV_NAME, envNameTccs ); + } + + + // Add an ExceptionHandler to the Connection, this will handle any + // InternalServerException, communication errors, XML marshaling errors + // .etc + connection.setExceptionHandler(new AppXExceptionHandler()); + + // While the above ExceptionHandler is required, all of the following + // Listeners are optional. Client application can add as many or as few Listeners + // of each type that they want. + + // Add a Partial Error Listener, this will be notified when ever a + // a service returns partial errors. + // connection.getModelManager().addPartialErrorListener(new AppXPartialErrorListener()); + + // Add a Change and Delete Listener, this will be notified when ever a + // a service returns model objects that have been updated or deleted. + // connection.getModelManager().addModelEventListener(new AppXModelEventListener()); + + + // Add a Request Listener, this will be notified before and after each + // service request is sent to the server. + // Connection.addRequestListener( new AppXRequestListener() ); + + } + + public User login(String userId, String password, String group, String role) throws Exception { + SessionService sessionService = SessionService.getService(connection); + String[] credentials = new String[] { userId, password, group, role, UUID.randomUUID().toString() }; + LoginResponse out = sessionService.login(credentials[0], credentials[1], credentials[2], credentials[3], "zh_CN", credentials[4]); + return out.user; + } + + /** + * Get the single Connection object for the application + * + * @return connection + */ + public static Connection getConnection() + { + return connection; + } + + /** + * Login to the Teamcenter Server + * + */ + public User login() + { + // Get the service stub + SessionService sessionService = SessionService.getService(connection); + + try + { + // Prompt for credentials until they are right, or until user + // cancels + String[] credentials = credentialManager.promptForCredentials(); + while (true) + { + try + { + + // ***************************** + // Execute the service operation + // ***************************** + LoginResponse out = sessionService.login(credentials[0], credentials[1], + credentials[2], credentials[3],"", credentials[4]); + + return out.user; + } + catch (InvalidCredentialsException e) + { + credentials = credentialManager.getCredentials(e); + } + } + } + // User canceled the operation, don't need to tell him again + catch (CanceledOperationException e) {} + + // Exit the application + System.exit(0); + return null; + } + + /** + * Terminate the session with the Teamcenter Server + * + */ + public void logout() + { + // Get the service stub + SessionService sessionService = SessionService.getService(connection); + try + { + // ***************************** + // Execute the service operation + // ***************************** + sessionService.logout(); + } + catch (ServiceException e){} + } + +} diff --git a/connor_cpzc_service/src/main/resources/application.properties b/connor_cpzc_service/src/main/resources/application.properties new file mode 100644 index 0000000..1e0a0ee --- /dev/null +++ b/connor_cpzc_service/src/main/resources/application.properties @@ -0,0 +1,41 @@ +# TCַ +#server.port=8089 +#tc.server=http://10.128.155.206:7001/tc +## TC¼ûҪԿ·Ȩ +#tc.user=dcproxy +## TC¼ +#tc.password=dcproxy +#tc.fmsUrl=http://10.128.155.206:4544 +#tc.fmstemp=D:\\FMS_CACHE +#tc.exeSize=5 +#tc.errorExeSize=2 +#tc.overtime=30min:3|M040:30min:3;M046:20min:2 +#update.cron=0 0 6 * * ? +#updateSAP.cron=0 0/1 * * * ? +#spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver +#spring.datasource.password=infodba +#spring.datasource.url=jdbc:oracle:thin:@10.128.155.206:1521:tcqa +#spring.datasource.username=infodba +## ڴ +#spring.datasource.tomcat.max-active=1024 +## Сڴ +#spring.datasource.tomcat.min-idle=512 +## öڴ +#tomcat.tomcat.max-connections=512 +server.port=8089 +tc.server=http://10.128.11.142:7020/tc +# TC¼ûҪԿ·Ȩ +tc.user=dcproxy +# TC¼ +tc.password=dcproxy +tc.fmsUrl=http://10.128.10.203:4544 +tc.fmstemp=D:\\FMS_CACHE +tc.exeSize=5 +#tc.errorExeSize=2 +#tc.overtime=30min:3|M040:30min:3;M046:20min:2 +update.cron=0 0 6 * * ? +updateSAP.cron=0 0/1 * * * ? +spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver +spring.datasource.password=infodba +spring.datasource.url=jdbc:oracle:thin:@10.128.10.207:1521:tcprod +spring.datasource.username=infodba \ No newline at end of file diff --git a/connor_cpzc_service/src/main/resources/log4j.properties b/connor_cpzc_service/src/main/resources/log4j.properties new file mode 100644 index 0000000..067941c --- /dev/null +++ b/connor_cpzc_service/src/main/resources/log4j.properties @@ -0,0 +1,17 @@ +# LOG4J配置 +log4j.rootCategory=WARN,stdout,file +# ,file +# 控制台输出 +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %5p %c{1}:%L - %m%n + +# 文件输出 +log4j.appender.file=org.apache.log4j.DailyRollingFileAppender +log4j.appender.file.file=./logs/rest_service.log +log4j.appender.file.Threshold = WARN +log4j.appender.file.Append = true +log4j.appender.file.DatePattern='.'yyyy-MM-dd +log4j.appender.file.layout=org.apache.log4j.PatternLayout +log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %5p %c{1}:%L - %m%n + diff --git a/connor_cpzc_service/src/test/java/com/connor/connor_cpzc_service/ConnorCpzcServiceApplicationTests.java b/connor_cpzc_service/src/test/java/com/connor/connor_cpzc_service/ConnorCpzcServiceApplicationTests.java new file mode 100644 index 0000000..600c0d9 --- /dev/null +++ b/connor_cpzc_service/src/test/java/com/connor/connor_cpzc_service/ConnorCpzcServiceApplicationTests.java @@ -0,0 +1,13 @@ +package com.connor.connor_cpzc_service; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class ConnorCpzcServiceApplicationTests { + + @Test + void contextLoads() { + } + +}