Compare commits

..

1 Commits

Author SHA1 Message Date
陈翼晖 13d22cca14 没有BOM异步逻辑代码
1 year ago

@ -76,11 +76,11 @@
<classpathentry exported="true" kind="lib" path="poi/woden-impl-dom-1.0M9.jar"/> <classpathentry exported="true" kind="lib" path="poi/woden-impl-dom-1.0M9.jar"/>
<classpathentry exported="true" kind="lib" path="poi/wsdl4j-1.6.2.jar"/> <classpathentry exported="true" kind="lib" path="poi/wsdl4j-1.6.2.jar"/>
<classpathentry exported="true" kind="lib" path="poi/wstx-asl-3.2.9.jar"/> <classpathentry exported="true" kind="lib" path="poi/wstx-asl-3.2.9.jar"/>
<classpathentry exported="true" kind="lib" path="poi/xmlbeans-5.0.3.jar"/>
<classpathentry exported="true" kind="lib" path="poi/xml-resolver-1.2.jar"/> <classpathentry exported="true" kind="lib" path="poi/xml-resolver-1.2.jar"/>
<classpathentry exported="true" kind="lib" path="poi/XmlSchema-1.4.7.jar"/> <classpathentry exported="true" kind="lib" path="poi/XmlSchema-1.4.7.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="poi/Spire.Xls.jar"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

@ -30,6 +30,7 @@ Require-Bundle: org.eclipse.ui,
com.teamcenter.rac.commonclient;bundle-version="11000.2.0", com.teamcenter.rac.commonclient;bundle-version="11000.2.0",
TcSoaWorkflowRac;bundle-version="11000.2.0", TcSoaWorkflowRac;bundle-version="11000.2.0",
cn.net.connor.socket;bundle-version="1.0.0", cn.net.connor.socket;bundle-version="1.0.0",
org.apache.poi.39;bundle-version="3.9.0",
TcSoaProjectManagementLoose;bundle-version="11000.2.0", TcSoaProjectManagementLoose;bundle-version="11000.2.0",
TcSoaProjectManagementRac;bundle-version="11000.2.0", TcSoaProjectManagementRac;bundle-version="11000.2.0",
TcSoaProjectManagementTypes;bundle-version="11000.2.0", TcSoaProjectManagementTypes;bundle-version="11000.2.0",
@ -48,8 +49,7 @@ Require-Bundle: org.eclipse.ui,
com.teamcenter.rac.util;bundle-version="11000.2.0", com.teamcenter.rac.util;bundle-version="11000.2.0",
org.eclipse.osgi.services;bundle-version="3.3.100", org.eclipse.osgi.services;bundle-version="3.3.100",
TcSoaCaeRac;bundle-version="11000.2.0", TcSoaCaeRac;bundle-version="11000.2.0",
com.teamcenter.rac.project;bundle-version="11000.2.0", com.teamcenter.rac.project;bundle-version="11000.2.0"
org.apache.poi.39;bundle-version="3.9.0"
Automatic-Module-Name: com.connor.chint.yunpi Automatic-Module-Name: com.connor.chint.yunpi
Bundle-RequiredExecutionEnvironment: JavaSE-1.8, Bundle-RequiredExecutionEnvironment: JavaSE-1.8,
JavaSE-1.7 JavaSE-1.7
@ -104,6 +104,7 @@ Bundle-ClassPath: .,
poi/axis2-xmlbeans-1.4.1.jar, poi/axis2-xmlbeans-1.4.1.jar,
poi/backport-util-concurrent-3.1.jar, poi/backport-util-concurrent-3.1.jar,
poi/XmlSchema-1.4.7.jar, poi/XmlSchema-1.4.7.jar,
poi/xmlbeans-5.0.3.jar,
poi/xml-resolver-1.2.jar, poi/xml-resolver-1.2.jar,
poi/mail-1.4.jar, poi/mail-1.4.jar,
poi/neethi-3.0.2.jar, poi/neethi-3.0.2.jar,
@ -114,5 +115,4 @@ Bundle-ClassPath: .,
poi/wstx-asl-3.2.9.jar, poi/wstx-asl-3.2.9.jar,
json_lib/JavaFx-DateTimePicker-0.0.1.jar, json_lib/JavaFx-DateTimePicker-0.0.1.jar,
poi/okhttp-2.7.4.jar, poi/okhttp-2.7.4.jar,
json_lib/jfxrt.jar, json_lib/jfxrt.jar
poi/Spire.Xls.jar

@ -1,3 +1,2 @@
ERROR_NOT_CHANGE=\u8BF7\u9009\u62E9\u66F4\u6539\u901A\u77E5\u5355\u5BF9\u8C61 ERROR_NOT_CHANGE=\u8BF7\u9009\u62E9\u66F4\u6539\u901A\u77E5\u5355\u5BF9\u8C61
ERROR_NO_CHANGE=\u672A\u627E\u5230\u53D8\u66F4\u524D\u540E\u5BF9\u8C61,\u65E0\u6CD5\u63D0\u53D6\u5DEE\u5F02\u9879\uFF01 ERROR_NO_CHANGE=\u672A\u627E\u5230\u53D8\u66F4\u524D\u540E\u5BF9\u8C61,\u65E0\u6CD5\u63D0\u53D6\u5DEE\u5F02\u9879\uFF01
SUCC_CHANGE=\u63D0\u53D6\u5B8C\u6210

@ -42,6 +42,7 @@ bin.includes = plugin.xml,\
poi/woden-impl-dom-1.0M9.jar,\ poi/woden-impl-dom-1.0M9.jar,\
poi/wsdl4j-1.6.2.jar,\ poi/wsdl4j-1.6.2.jar,\
poi/wstx-asl-3.2.9.jar,\ poi/wstx-asl-3.2.9.jar,\
poi/xmlbeans-5.0.3.jar,\
poi/xml-resolver-1.2.jar,\ poi/xml-resolver-1.2.jar,\
poi/XmlSchema-1.4.7.jar,\ poi/XmlSchema-1.4.7.jar,\
lib/axis.jar,\ lib/axis.jar,\
@ -82,5 +83,4 @@ bin.includes = plugin.xml,\
json_lib/xom-1.2.5.jar,\ json_lib/xom-1.2.5.jar,\
json_lib/JavaFx-DateTimePicker-0.0.1.jar,\ json_lib/JavaFx-DateTimePicker-0.0.1.jar,\
poi/okhttp-2.7.4.jar,\ poi/okhttp-2.7.4.jar,\
json_lib/jfxrt.jar,\ json_lib/jfxrt.jar
poi/Spire.Xls.jar

@ -3,8 +3,8 @@
<plugin> <plugin>
<extension point="org.eclipse.ui.commands"> <extension point="org.eclipse.ui.commands">
<!--工具条--> <!--工具条-->
<command name="DBOM转EBOM" id="com.connor.chint.yunpi.command.DbomToECommand"/> <command name="DBOM转EBOM" id="com.connor.chint.yunpi.command.DbomToECommand"/>
<command name="EBOM转PBOM" id="com.connor.chint.yunpi.command.EbomToPCommand"/> <command name="EBOM转PBOM" id="com.connor.chint.yunpi.command.EbomToPCommand"/>
<command name="创建框架BOM" id="com.chint.plm.createKjBom.CreateKjBomCommand"/> <command name="创建框架BOM" id="com.chint.plm.createKjBom.CreateKjBomCommand"/>
<command name="框架BOM传递SAP" id="com.connor.chint.yunpi.command.BomSapKjSendCommand"/> <command name="框架BOM传递SAP" id="com.connor.chint.yunpi.command.BomSapKjSendCommand"/>
@ -18,17 +18,17 @@
<command name="典型工艺一键指派" id="com.connor.chint.yunpi.command.AssignProcess"/> <command name="典型工艺一键指派" id="com.connor.chint.yunpi.command.AssignProcess"/>
<command name="一键式工艺自动投料" id="com.connor.chint.yunpi.command.AutoFeedingComd"/> <command name="一键式工艺自动投料" id="com.connor.chint.yunpi.command.AutoFeedingComd"/>
<command name="创建/编辑更改通知单" id="com.chint.plm.createEcn.CreateEcnCommond"/> <command name="创建/编辑更改通知单" id="com.chint.plm.createEcn.CreateEcnCommond"/>
<command name="提取差异项" id="com.chint.plm.createbomdifference.ExtractDiffComd"/> <command name="提取差异项" id="com.chint.plm.createbomdifference.ExtractDiffComd"/>
<command name="生成更改差异文件" id="com.chint.plm.createbomdifference.BomCompareComd"/> <command name="生成更改差异文件" id="com.chint.plm.createbomdifference.BomCompareComd"/>
<command name="更新现有工时" id="com.chint.plm.updateWorkTime.UpdateWorkCommand"/> <command name="更新现有工时" id="com.chint.plm.updateWorkTime.UpdateWorkCommand"/>
<command name="单层BOM传递SAP" id="com.connor.chint.yunpi.command.BomDcSapCommand"/> <command name="单层BOM传递SAP" id="com.connor.chint.yunpi.command.BomDcSapCommand"/>
<command name="SAP传递结果查询" id="com.chint.plm.SearchSapResult.SearchSapResultComd"/> <command name="SAP传递结果查询" id="com.chint.plm.SearchSapResult.SearchSapResultComd"/>
<command name="校对表填写" id="com.connor.chint.yunpi.command.TestCommand"/><!-- --> <command name="校对表填写" id="com.connor.chint.yunpi.command.TestCommand"/><!-- -->
<command name="系统版本V1.11" id="com.connor.chint.sap2.projectTest.VersionCommandWh"/> <command name="系统版本V1.11" id="com.connor.chint.sap2.projectTest.VersionCommandWh"/>
<command name="工装需求管理" id="com.connor.plm.GZXQHandler"/> <command name="工装需求管理" id="com.connor.plm.GZXQHandler"/>
<command name="一键提取图纸" id="com.chint.plm.extractdraw.ExtractDrawComd"/> <command name="一键提取图纸" id="com.chint.plm.extractdraw.ExtractDrawComd"/>
<command name="成本单管理" id="com.connor.plm.CostListManagement"/> <command name="成本单管理" id="com.connor.plm.CostListManagement"/>
<command name="标准工序传递MOM" id="com.connor.plm.sendGXToMOM"/> <command name="标准工序传递MOM" id="com.connor.plm.sendGXToMOM"/>
</extension> </extension>
@ -44,33 +44,33 @@
<handler commandId="com.connor.chint.yunpi.command.BomDcSapCommand" class="com.connor.chint.yunpi.KHandler"/> <handler commandId="com.connor.chint.yunpi.command.BomDcSapCommand" class="com.connor.chint.yunpi.KHandler"/>
<handler commandId="com.connor.chint.yunpi.command.BomSapKjSendCommand" class="com.connor.chint.yunpi.KHandler"/> <handler commandId="com.connor.chint.yunpi.command.BomSapKjSendCommand" class="com.connor.chint.yunpi.KHandler"/>
<handler commandId="com.connor.chint.yunpi.command.AutoFeedingComd" class="com.connor.chint.yunpi.KHandler"/> <handler commandId="com.connor.chint.yunpi.command.AutoFeedingComd" class="com.connor.chint.yunpi.KHandler"/>
<handler commandId="com.chint.plm.createGGBom.GGBomCommand" class="com.connor.chint.yunpi.KHandler"/> <handler commandId="com.chint.plm.createGGBom.GGBomCommand" class="com.connor.chint.yunpi.KHandler"/>
<handler commandId="com.chint.plm.applyMatnr.ApplyMatnrCommand#all" class="com.connor.chint.yunpi.KHandler"/> <handler commandId="com.chint.plm.applyMatnr.ApplyMatnrCommand#all" class="com.connor.chint.yunpi.KHandler"/>
<handler commandId="com.chint.plm.applyMatnr.ApplyMatnrCommand#user" class="com.connor.chint.yunpi.KHandler"/> <handler commandId="com.chint.plm.applyMatnr.ApplyMatnrCommand#user" class="com.connor.chint.yunpi.KHandler"/>
<handler commandId="com.connor.chint.yunpi.command.EbomToPCommand" class="com.connor.chint.yunpi.KHandler"/> <handler commandId="com.connor.chint.yunpi.command.EbomToPCommand" class="com.connor.chint.yunpi.KHandler"/>
<handler commandId="com.connor.chint.yunpi.command.BomSapWhCommand" class="com.connor.chint.yunpi.KHandler"/> <handler commandId="com.connor.chint.yunpi.command.BomSapWhCommand" class="com.connor.chint.yunpi.KHandler"/>
<handler commandId="com.connor.chint.yunpi.command.BomSapWhBjCommand" class="com.connor.chint.yunpi.KHandler"/> <handler commandId="com.connor.chint.yunpi.command.BomSapWhBjCommand" class="com.connor.chint.yunpi.KHandler"/>
<handler commandId="com.chint.plm.createKjBom.CreateKjBomCommand" class="com.connor.chint.yunpi.KHandler"/> <handler commandId="com.chint.plm.createKjBom.CreateKjBomCommand" class="com.connor.chint.yunpi.KHandler"/>
<handler commandId="com.connor.chint.yunpi.command.DbomToECommand" class="com.connor.chint.yunpi.KHandler"/> <handler commandId="com.connor.chint.yunpi.command.DbomToECommand" class="com.connor.chint.yunpi.KHandler"/>
<handler commandId="com.connor.chint.yunpi.command.AssignProcess" class="com.connor.chint.yunpi.KHandler"/> <handler commandId="com.connor.chint.yunpi.command.AssignProcess" class="com.connor.chint.yunpi.KHandler"/>
<handler commandId="com.connor.plm.CostListManagement" class="com.connor.plm.CostListManagement.CostListManagementHandler"/> <handler commandId="com.connor.plm.CostListManagement" class="com.connor.plm.CostListManagement.CostListManagementHandler"/>
<handler commandId="com.connor.plm.sendGXToMOM" class="com.connor.plm.SendGXToMOM.sendGXToMOMHandler"/> <handler commandId="com.connor.plm.sendGXToMOM" class="com.connor.plm.SendGXToMOM.sendGXToMOMHandler"/>
<handler commandId="com.connor.plm.GZXQHandler" class="com.connor.plm.GZXQ.GZXQHandler"/> <handler commandId="com.connor.plm.GZXQHandler" class="com.connor.plm.GZXQ.GZXQHandler"/>
</extension> </extension>
<extension point="org.eclipse.ui.menus"> <extension point="org.eclipse.ui.menus">
<menuContribution locationURI="menu:org.eclipse.ui.main.menu?after=additions"> <menuContribution locationURI="menu:org.eclipse.ui.main.menu?after=additions">
<!--<menu label="云派" id="com.connor.chint.sap2.menu.yunpi"/>--> <!--<menu label="云派" id="com.connor.chint.sap2.menu.yunpi"/>-->
<menu label="武汉工厂" id="com.connor.chint.sap2.menu.whgc"/> <menu label="武汉工厂" id="com.connor.chint.sap2.menu.whgc"/>
</menuContribution> </menuContribution>
<menuContribution locationURI="menu:com.connor.chint.sap2.menu.whgc?after=additions"> <menuContribution locationURI="menu:com.connor.chint.sap2.menu.whgc?after=additions">
<command commandId = "com.chint.plm.createbomdifference.ExtractDiffComd" id = "com.chint.plm.createbomdifference.ExtractDiffComd"> <!--<command commandId = "com.chint.plm.createbomdifference.ExtractDiffComd" id = "com.chint.plm.createbomdifference.ExtractDiffComd">
<visibleWhen> <visibleWhen>
<and> <and>
<or> <or>
@ -90,8 +90,8 @@
</with> </with>
</and> </and>
</visibleWhen> </visibleWhen>
</command><!-- --> </command>
<command commandId = "com.chint.plm.createbomdifference.BomCompareComd" id = "com.chint.plm.createbomdifference.BomCompareComd"> <command commandId = "com.chint.plm.createbomdifference.BomCompareComd" id = "com.chint.plm.createbomdifference.BomCompareComd">
<visibleWhen> <visibleWhen>
<and> <and>
<or> <or>
@ -111,8 +111,8 @@
</with> </with>
</and> </and>
</visibleWhen> </visibleWhen>
</command> </command> -->
<command commandId = "com.connor.plm.CostListManagement" id = "com.connor.plm.CostListManagement"> <command commandId = "com.connor.plm.CostListManagement" id = "com.connor.plm.CostListManagement">
<visibleWhen> <visibleWhen>
<and> <and>
<or> <or>
@ -133,310 +133,310 @@
</and> </and>
</visibleWhen> </visibleWhen>
</command> </command>
<command commandId = "com.connor.chint.yunpi.command.TestCommand" id = "com.connor.chint.yunpi.command.TestCommand"> <command commandId = "com.connor.chint.yunpi.command.TestCommand" id = "com.connor.chint.yunpi.command.TestCommand">
<visibleWhen> <visibleWhen>
<and> <and>
<or> <or>
<reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/> <reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/>
<reference definitionId="com.teamcenter.rac.pse.inMainView"/> <reference definitionId="com.teamcenter.rac.pse.inMainView"/>
</or> </or>
<with <with
variable="rac_command_suppression"> variable="rac_command_suppression">
<not> <not>
<iterate <iterate
operator="or"> operator="or">
<equals <equals
value="com.connor.chint.yunpi.command.TestCommand"> value="com.connor.chint.yunpi.command.TestCommand">
</equals> </equals>
</iterate> </iterate>
</not> </not>
</with> </with>
</and> </and>
</visibleWhen> </visibleWhen>
</command> <!-- --> </command> <!-- -->
<command commandId = "com.chint.plm.createGGBom.GGBomCommand" id = "com.chint.plm.createGGBom.GGBomCommand"> <command commandId = "com.chint.plm.createGGBom.GGBomCommand" id = "com.chint.plm.createGGBom.GGBomCommand">
<visibleWhen> <visibleWhen>
<and> <and>
<or> <or>
<reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/> <reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/>
<reference definitionId="com.teamcenter.rac.pse.inMainView"/> <reference definitionId="com.teamcenter.rac.pse.inMainView"/>
</or> </or>
<with <with
variable="rac_command_suppression"> variable="rac_command_suppression">
<not> <not>
<iterate <iterate
operator="or"> operator="or">
<equals <equals
value="com.chint.plm.createGGBom.GGBomCommand"> value="com.chint.plm.createGGBom.GGBomCommand">
</equals> </equals>
</iterate> </iterate>
</not> </not>
</with> </with>
</and> </and>
</visibleWhen> </visibleWhen>
</command> </command>
<command commandId = "com.chint.plm.createKjBom.CreateKjBomCommand" id = "com.chint.plm.createKjBom.CreateKjBomCommand"> <command commandId = "com.chint.plm.createKjBom.CreateKjBomCommand" id = "com.chint.plm.createKjBom.CreateKjBomCommand">
<visibleWhen> <visibleWhen>
<and> <and>
<or> <or>
<reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/> <reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/>
<reference definitionId="com.teamcenter.rac.pse.inMainView"/> <reference definitionId="com.teamcenter.rac.pse.inMainView"/>
</or> </or>
<with <with
variable="rac_command_suppression"> variable="rac_command_suppression">
<not> <not>
<iterate <iterate
operator="or"> operator="or">
<equals <equals
value="com.chint.plm.createKjBom.CreateKjBomCommand"> value="com.chint.plm.createKjBom.CreateKjBomCommand">
</equals> </equals>
</iterate> </iterate>
</not> </not>
</with> </with>
</and> </and>
</visibleWhen> </visibleWhen>
</command> </command>
<command commandId = "com.chint.plm.applyMatnr.ApplyMatnrCommand#all" id = "com.chint.plm.applyMatnr.ApplyMatnrCommand#all"> <command commandId = "com.chint.plm.applyMatnr.ApplyMatnrCommand#all" id = "com.chint.plm.applyMatnr.ApplyMatnrCommand#all">
<visibleWhen> <visibleWhen>
<and> <and>
<or> <or>
<reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/> <reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/>
<reference definitionId="com.teamcenter.rac.pse.inMainView"/> <reference definitionId="com.teamcenter.rac.pse.inMainView"/>
</or> </or>
<with <with
variable="rac_command_suppression"> variable="rac_command_suppression">
<not> <not>
<iterate <iterate
operator="or"> operator="or">
<equals <equals
value="com.chint.plm.applyMatnr.ApplyMatnrCommand#all"> value="com.chint.plm.applyMatnr.ApplyMatnrCommand#all">
</equals> </equals>
</iterate> </iterate>
</not> </not>
</with> </with>
</and> </and>
</visibleWhen> </visibleWhen>
</command> </command>
<command commandId = "com.chint.plm.applyMatnr.ApplyMatnrCommand#user" id = "com.chint.plm.applyMatnr.ApplyMatnrCommand#user"> <command commandId = "com.chint.plm.applyMatnr.ApplyMatnrCommand#user" id = "com.chint.plm.applyMatnr.ApplyMatnrCommand#user">
<visibleWhen> <visibleWhen>
<and> <and>
<or> <or>
<reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/> <reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/>
<reference definitionId="com.teamcenter.rac.pse.inMainView"/> <reference definitionId="com.teamcenter.rac.pse.inMainView"/>
</or> </or>
<with <with
variable="rac_command_suppression"> variable="rac_command_suppression">
<not> <not>
<iterate <iterate
operator="or"> operator="or">
<equals <equals
value="com.chint.plm.applyMatnr.ApplyMatnrCommand#user"> value="com.chint.plm.applyMatnr.ApplyMatnrCommand#user">
</equals> </equals>
</iterate> </iterate>
</not> </not>
</with> </with>
</and> </and>
</visibleWhen> </visibleWhen>
</command> </command>
<command commandId = "com.connor.chint.yunpi.command.BomSapKjSendCommand" id = "com.connor.chint.yunpi.command.BomSapKjSendCommand"> <command commandId = "com.connor.chint.yunpi.command.BomSapKjSendCommand" id = "com.connor.chint.yunpi.command.BomSapKjSendCommand">
<visibleWhen> <visibleWhen>
<and> <and>
<or> <or>
<reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/> <reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/>
<reference definitionId="com.teamcenter.rac.pse.inMainView"/> <reference definitionId="com.teamcenter.rac.pse.inMainView"/>
</or> </or>
<with <with
variable="rac_command_suppression"> variable="rac_command_suppression">
<not> <not>
<iterate <iterate
operator="or"> operator="or">
<equals <equals
value="com.connor.chint.yunpi.command.BomSapKjSendCommand"> value="com.connor.chint.yunpi.command.BomSapKjSendCommand">
</equals> </equals>
</iterate> </iterate>
</not> </not>
</with> </with>
</and> </and>
</visibleWhen> </visibleWhen>
</command> </command>
<command commandId = "com.connor.chint.yunpi.command.DbomToECommand" id = "com.connor.chint.yunpi.command.DbomToECommand"> <command commandId = "com.connor.chint.yunpi.command.DbomToECommand" id = "com.connor.chint.yunpi.command.DbomToECommand">
<visibleWhen> <visibleWhen>
<and> <and>
<or> <or>
<reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/> <reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/>
<reference definitionId="com.teamcenter.rac.pse.inMainView"/> <reference definitionId="com.teamcenter.rac.pse.inMainView"/>
</or> </or>
<with <with
variable="rac_command_suppression"> variable="rac_command_suppression">
<not> <not>
<iterate <iterate
operator="or"> operator="or">
<equals <equals
value="com.connor.chint.yunpi.command.DbomToECommand"> value="com.connor.chint.yunpi.command.DbomToECommand">
</equals> </equals>
</iterate> </iterate>
</not> </not>
</with> </with>
</and> </and>
</visibleWhen> </visibleWhen>
</command> </command>
<command commandId = "com.connor.chint.yunpi.command.EbomToPCommand" id = "com.connor.chint.yunpi.command.EbomToPCommand"> <command commandId = "com.connor.chint.yunpi.command.EbomToPCommand" id = "com.connor.chint.yunpi.command.EbomToPCommand">
<visibleWhen> <visibleWhen>
<and> <and>
<or> <or>
<reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/> <reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/>
<reference definitionId="com.teamcenter.rac.pse.inMainView"/> <reference definitionId="com.teamcenter.rac.pse.inMainView"/>
</or> </or>
<with <with
variable="rac_command_suppression"> variable="rac_command_suppression">
<not> <not>
<iterate <iterate
operator="or"> operator="or">
<equals <equals
value="com.connor.chint.yunpi.command.EbomToPCommand"> value="com.connor.chint.yunpi.command.EbomToPCommand">
</equals> </equals>
</iterate> </iterate>
</not> </not>
</with> </with>
</and> </and>
</visibleWhen> </visibleWhen>
</command> </command>
<command commandId = "com.connor.chint.yunpi.command.AssignProcess" id = "com.connor.chint.yunpi.command.AssignProcess"> <command commandId = "com.connor.chint.yunpi.command.AssignProcess" id = "com.connor.chint.yunpi.command.AssignProcess">
<visibleWhen> <visibleWhen>
<and> <and>
<or> <or>
<reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/> <reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/>
<reference definitionId="com.teamcenter.rac.pse.inMainView"/> <reference definitionId="com.teamcenter.rac.pse.inMainView"/>
</or> </or>
<with <with
variable="rac_command_suppression"> variable="rac_command_suppression">
<not> <not>
<iterate <iterate
operator="or"> operator="or">
<equals <equals
value="com.connor.chint.yunpi.command.AssignProcess"> value="com.connor.chint.yunpi.command.AssignProcess">
</equals> </equals>
</iterate> </iterate>
</not> </not>
</with> </with>
</and> </and>
</visibleWhen> </visibleWhen>
</command> </command>
<command commandId = "com.connor.chint.yunpi.command.AutoFeedingComd" id = "com.connor.chint.yunpi.command.AutoFeedingComd"> <command commandId = "com.connor.chint.yunpi.command.AutoFeedingComd" id = "com.connor.chint.yunpi.command.AutoFeedingComd">
<visibleWhen> <visibleWhen>
<and> <and>
<or> <or>
<reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/> <reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/>
<reference definitionId="com.teamcenter.rac.pse.inMainView"/> <reference definitionId="com.teamcenter.rac.pse.inMainView"/>
</or> </or>
<with <with
variable="rac_command_suppression"> variable="rac_command_suppression">
<not> <not>
<iterate <iterate
operator="or"> operator="or">
<equals <equals
value="com.connor.chint.yunpi.command.AutoFeedingComd"> value="com.connor.chint.yunpi.command.AutoFeedingComd">
</equals> </equals>
</iterate> </iterate>
</not> </not>
</with> </with>
</and> </and>
</visibleWhen> </visibleWhen>
</command> </command>
<command commandId = "com.chint.plm.updateWorkTime.UpdateWorkCommand" id = "com.chint.plm.updateWorkTime.UpdateWorkCommand"> <command commandId = "com.chint.plm.updateWorkTime.UpdateWorkCommand" id = "com.chint.plm.updateWorkTime.UpdateWorkCommand">
<visibleWhen> <visibleWhen>
<and> <and>
<or> <or>
<reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/> <reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/>
<reference definitionId="com.teamcenter.rac.pse.inMainView"/> <reference definitionId="com.teamcenter.rac.pse.inMainView"/>
</or> </or>
<with <with
variable="rac_command_suppression"> variable="rac_command_suppression">
<not> <not>
<iterate <iterate
operator="or"> operator="or">
<equals <equals
value="com.chint.plm.updateWorkTime.UpdateWorkCommand"> value="com.chint.plm.updateWorkTime.UpdateWorkCommand">
</equals> </equals>
</iterate> </iterate>
</not> </not>
</with> </with>
</and> </and>
</visibleWhen> </visibleWhen>
</command> </command>
<command commandId = "com.connor.chint.yunpi.command.BomSapWhBjCommand" id = "com.connor.chint.yunpi.command.BomSapWhBjCommand"> <command commandId = "com.connor.chint.yunpi.command.BomSapWhBjCommand" id = "com.connor.chint.yunpi.command.BomSapWhBjCommand">
<visibleWhen> <visibleWhen>
<and> <and>
<or> <or>
<reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/> <reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/>
<reference definitionId="com.teamcenter.rac.pse.inMainView"/> <reference definitionId="com.teamcenter.rac.pse.inMainView"/>
</or> </or>
<with <with
variable="rac_command_suppression"> variable="rac_command_suppression">
<not> <not>
<iterate <iterate
operator="or"> operator="or">
<equals <equals
value="com.connor.chint.yunpi.command.BomSapWhBjCommand"> value="com.connor.chint.yunpi.command.BomSapWhBjCommand">
</equals> </equals>
</iterate> </iterate>
</not> </not>
</with> </with>
</and> </and>
</visibleWhen> </visibleWhen>
</command> </command>
<command commandId = "com.connor.chint.yunpi.command.BomSapWhCommand" id = "com.connor.chint.yunpi.command.BomSapWhCommand"> <command commandId = "com.connor.chint.yunpi.command.BomSapWhCommand" id = "com.connor.chint.yunpi.command.BomSapWhCommand">
<visibleWhen> <visibleWhen>
<and> <and>
<or> <or>
<reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/> <reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/>
<reference definitionId="com.teamcenter.rac.pse.inMainView"/> <reference definitionId="com.teamcenter.rac.pse.inMainView"/>
</or> </or>
<with <with
variable="rac_command_suppression"> variable="rac_command_suppression">
<not> <not>
<iterate <iterate
operator="or"> operator="or">
<equals <equals
value="com.connor.chint.yunpi.command.BomSapWhCommand"> value="com.connor.chint.yunpi.command.BomSapWhCommand">
</equals> </equals>
</iterate> </iterate>
</not> </not>
</with> </with>
</and> </and>
</visibleWhen> </visibleWhen>
</command> </command>
<command commandId = "com.connor.chint.yunpi.command.BomDcSapCommand" id = "com.connor.chint.yunpi.command.BomDcSapCommand"> <command commandId = "com.connor.chint.yunpi.command.BomDcSapCommand" id = "com.connor.chint.yunpi.command.BomDcSapCommand">
<visibleWhen> <visibleWhen>
<and> <and>
<or> <or>
<reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/> <reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/>
<reference definitionId="com.teamcenter.rac.pse.inMainView"/> <reference definitionId="com.teamcenter.rac.pse.inMainView"/>
</or> </or>
<with <with
variable="rac_command_suppression"> variable="rac_command_suppression">
<not> <not>
<iterate <iterate
operator="or"> operator="or">
<equals <equals
value="com.connor.chint.yunpi.command.BomDcSapCommand"> value="com.connor.chint.yunpi.command.BomDcSapCommand">
</equals> </equals>
</iterate> </iterate>
</not> </not>
</with> </with>
</and> </and>
</visibleWhen> </visibleWhen>
</command> </command>
<command commandId = "com.connor.plm.GZXQHandler" id = "com.connor.plm.GZXQHandler"> <command commandId = "com.connor.plm.GZXQHandler" id = "com.connor.plm.GZXQHandler">
<visibleWhen> <visibleWhen>
<and> <and>
<or> <or>
@ -521,27 +521,27 @@
</visibleWhen> </visibleWhen>
</command> </command>
<command commandId = "com.connor.chint.sap2.projectTest.VersionCommandWh" id = "com.connor.chint.sap2.projectTest.VersionCommandWh"> <command commandId = "com.connor.chint.sap2.projectTest.VersionCommandWh" id = "com.connor.chint.sap2.projectTest.VersionCommandWh">
<visibleWhen> <visibleWhen>
<and> <and>
<or> <or>
<reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/> <reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/>
<reference definitionId="com.teamcenter.rac.pse.inMainView"/> <reference definitionId="com.teamcenter.rac.pse.inMainView"/>
</or> </or>
<with <with
variable="rac_command_suppression"> variable="rac_command_suppression">
<not> <not>
<iterate <iterate
operator="or"> operator="or">
<equals <equals
value="com.connor.chint.sap2.projectTest.VersionCommandWh"> value="com.connor.chint.sap2.projectTest.VersionCommandWh">
</equals> </equals>
</iterate> </iterate>
</not> </not>
</with> </with>
</and> </and>
</visibleWhen> </visibleWhen>
</command> </command>
</menuContribution> </menuContribution>

@ -26,10 +26,6 @@ import javafx.scene.control.ComboBox;
import javafx.scene.control.TextField; import javafx.scene.control.TextField;
import javafx.stage.Stage; import javafx.stage.Stage;
/**
* @author cyh
* ID
*/
public class AssignIdController { public class AssignIdController {
private String groupID; private String groupID;
private TCSession session; private TCSession session;

@ -6,47 +6,52 @@ import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import org.apache.commons.httpclient.util.URIUtil; import org.apache.commons.httpclient.util.URIUtil;
import org.apache.poi.xssf.usermodel.XSSFCell; import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow; import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.util.CellRangeAddress;
import org.casic.javafx.control.DateTimePicker;
import org.dom4j.Document; import org.dom4j.Document;
import org.dom4j.DocumentHelper; import org.dom4j.DocumentHelper;
import org.dom4j.Element; import org.dom4j.Element;
import com.chint.plm.SearchSapResult.SumTableBean;
import com.chint.plm.fxUtil.KFXPanel; import com.chint.plm.fxUtil.KFXPanel;
import com.chint.plm.fxUtil.KFXPanelController; import com.chint.plm.fxUtil.KFXPanelController;
import com.connor.chint.JDBPackage.JDBFrame;
import com.connor.chint.sap2.util.BomToSapUtil;
import com.connor.chint.sap2.util.KUtil; import com.connor.chint.sap2.util.KUtil;
import com.connor.chint.sap2.util.POIUtil; import com.connor.chint.sap2.util.POIUtil;
import com.connor.chint.sap2.util.SAPUtil; import com.connor.chint.sap2.util.SAPUtil;
import com.connor.chint.sap2.util.SqlUtil; import com.connor.chint.sap2.util.SqlUtil;
import com.spire.xls.CheckState;
import com.spire.xls.Workbook;
import com.spire.xls.Worksheet;
import com.spire.xls.core.ICheckBox;
import com.spire.xls.core.ICheckBoxes;
import com.spire.xls.core.IShape;
import com.spire.xls.core.IShapes;
import com.squareup.okhttp.MediaType; import com.squareup.okhttp.MediaType;
import com.squareup.okhttp.OkHttpClient; import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request; import com.squareup.okhttp.Request;
import com.squareup.okhttp.RequestBody; import com.squareup.okhttp.RequestBody;
import com.squareup.okhttp.Response; import com.squareup.okhttp.Response;
import com.teamcenter.rac.aif.AbstractAIFApplication; import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.aifrcp.AIFUtility; import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponent; import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentDataset; import com.teamcenter.rac.kernel.TCComponentDataset;
import com.teamcenter.rac.kernel.TCComponentItem; import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemType; import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCComponentTcFile;
import com.teamcenter.rac.kernel.TCException; import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCProperty; import com.teamcenter.rac.kernel.TCProperty;
import com.teamcenter.rac.kernel.TCSession; import com.teamcenter.rac.kernel.TCSession;
@ -56,6 +61,7 @@ import edu.emory.mathcs.backport.java.util.Arrays;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
@ -78,12 +84,6 @@ import javafx.scene.layout.GridPane;
import javafx.scene.layout.StackPane; import javafx.scene.layout.StackPane;
import javafx.stage.Stage; import javafx.stage.Stage;
/**
* @author cyh
*
* ECN
*
*/
public class CreateEcnController extends KFXPanelController { public class CreateEcnController extends KFXPanelController {
@FXML @FXML
private TextField ecnId; private TextField ecnId;
@ -116,7 +116,7 @@ public class CreateEcnController extends KFXPanelController {
private List<String> wips = new ArrayList<String>(); private List<String> wips = new ArrayList<String>();
private List<String> products = new ArrayList<String>(); private List<String> products = new ArrayList<String>();
private List<EcnBean> ecnBeans = new ArrayList<EcnBean>(); private List<EcnBean> ecnBeans = new ArrayList<EcnBean>();
private AbstractAIFApplication app; protected AbstractAIFApplication app;
private TCSession session; private TCSession session;
private TCComponent target; private TCComponent target;
@FXML @FXML
@ -142,17 +142,11 @@ public class CreateEcnController extends KFXPanelController {
private CreateEcnController controller; private CreateEcnController controller;
private CreateEcnFrame frame; private CreateEcnFrame frame;
private String[] database; private String[] database;
protected final String UPDATE_OA = "update CHINT_ECR_FROM_OA set STATUS = '已引用' where APPLYNO = ? "; public final String UPDATE_OA = "update CHINT_ECR_FROM_OA set STATUS = '已引用' where APPLYNO = ? ";
protected final String SELECT_OA_APPLYNO = "select * from CHINT_ECR_FROM_OA where APPLYNO = ? "; public final String SELECT_OA_APPLYNO = "select * from CHINT_ECR_FROM_OA where APPLYNO = ? ";
private final int PAGE_ITEM_CNT = 6;//每页对象数量
private final int FIRST_PAGE = 28;//第二页起始行
private final int PAGE_ROW_CNT = 16;//每页行数
private final int ITEM_ROW_CNT = 1;//每个对象行数
private final int TITLE_ROW_CNT = 7;//表头行数
@Override @Override
public void initData(KFXPanel paramKFXPanel) throws Exception { public void initData(KFXPanel paramKFXPanel) throws Exception {
// Auto-generated method stub // TODO Auto-generated method stub
this.app = AIFUtility.getCurrentApplication(); this.app = AIFUtility.getCurrentApplication();
this.session = (TCSession) app.getSession(); this.session = (TCSession) app.getSession();
target = (TCComponent) app.getTargetComponent(); target = (TCComponent) app.getTargetComponent();
@ -192,7 +186,7 @@ public class CreateEcnController extends KFXPanelController {
* @function * @function
*/ */
@FXML @FXML
private void createClick(ActionEvent event) throws Exception { void createClick(ActionEvent event) throws Exception {
if (ecnId.getText().isEmpty()) { if (ecnId.getText().isEmpty()) {
MessageBox.post("请先指派变更单ID", "提示", 2); MessageBox.post("请先指派变更单ID", "提示", 2);
return; return;
@ -211,13 +205,11 @@ public class CreateEcnController extends KFXPanelController {
if (item.getRelatedComponents("IMAN_reference").length > 0) { if (item.getRelatedComponents("IMAN_reference").length > 0) {
TCComponent[] comps = item.getRelatedComponents("IMAN_reference"); TCComponent[] comps = item.getRelatedComponents("IMAN_reference");
for (int i = 0, len = comps.length; i < len; i++) { for (int i = 0, len = comps.length; i < len; i++) {
if (comps[i].isTypeOf("MSExcelX")) {// instanceof TCComponentDataset if (comps[i] instanceof TCComponentDataset) {
dataset = (TCComponentDataset) comps[i]; dataset = (TCComponentDataset) comps[i];
break; break;
} }
} }
}
if(dataset != null) {
// dataset=(TCComponentDataset) item.getRelatedComponents("IMAN_reference")[0]; // dataset=(TCComponentDataset) item.getRelatedComponents("IMAN_reference")[0];
TCComponentDataset datasetM = getDataset(type, 0); TCComponentDataset datasetM = getDataset(type, 0);
file = Util.getExcel(datasetM); file = Util.getExcel(datasetM);
@ -272,7 +264,7 @@ public class CreateEcnController extends KFXPanelController {
createOrReplace(dataset, file, changeName); createOrReplace(dataset, file, changeName);
item.setRelated("IMAN_reference", new TCComponent[] { dataset }); item.setRelated("IMAN_reference", new TCComponent[] { dataset });
// item.unlock(); item.unlock();
MessageBox.post("创建完成", "", MessageBox.INFORMATION); MessageBox.post("创建完成", "", MessageBox.INFORMATION);
} }
@ -347,203 +339,94 @@ public class CreateEcnController extends KFXPanelController {
} }
/** /**
* @param dataset * @param
* @param file * @param
* @param changeName excel * @param excel
*/ */
private void createOrReplace(TCComponentDataset dataset, File file, String changeName) { protected void createOrReplace(TCComponentDataset dataset, File file, String changeName) {
//TODO 20240227大幅修改excel // 20200407新增删除多余的
FileInputStream fis = null;
FileOutputStream fos = null;
try { try {
fis = new FileInputStream(file); FileInputStream fis = new FileInputStream(file);
XSSFWorkbook workbook = new XSSFWorkbook(fis); HSSFWorkbook workBook = new HSSFWorkbook(fis);
XSSFSheet sheet = workbook.getSheetAt(0); HSSFSheet sheet = workBook.getSheetAt(0);
XSSFRow row; sheet.getRow(1).getCell(6).setCellValue(changeName);
XSSFCell cell; sheet.getRow(1).getCell(13).setCellValue(ecnId.getText());
// setTitle(sheet, 1); // int page = 0;
//表头 List<CellRangeAddress> mergeRegions = null;
row = POIUtil.getRow(sheet, 0);
cell = POIUtil.getCell(row, 0); for (int i = 0; i < pages; i++) {
cell.setCellValue(factoryText.getText());//单位 int pace = 0;
cell = POIUtil.getCell(row, 5); if (sheet.getRow(2 + i * 23) == null) {
cell.setCellValue((rb_formalChange.isSelected() ? "正式" : "临时") + cell.getStringCellValue());//正式更改 临时更改 if (mergeRegions == null) {
cell = POIUtil.getCell(row, 17); mergeRegions = Util.getMergeRegions(sheet, 2, 24);
cell.setCellValue(ecnId.getText());//通知单编号 }
row = POIUtil.getRow(sheet, 1); Util.addExcelPage(i, mergeRegions, sheet, workBook);
cell = POIUtil.getCell(row, 17); int index = 0;
cell.setCellValue(relateEcnText.getText());//关联申请单编号 for (int k = i * 5; k < (i + 1) * 5; k++) {
row = POIUtil.getRow(sheet, 3); sheet.getRow(5 + 3 * index + i * 23).getCell(1).setCellValue("");
cell = POIUtil.getCell(row, 18); sheet.getRow(5 + 3 * index + i * 23).getCell(6).setCellValue("");
cell.setCellValue("共 " + pages + " 页");//页数 sheet.getRow(5 + 3 * index + i * 23).getCell(9).setCellValue("");
row = POIUtil.getRow(sheet, 4); sheet.getRow(5 + 3 * index + i * 23).getCell(12).setCellValue("");
cell = POIUtil.getCell(row, 0); sheet.getRow(5 + 3 * index + i * 23).getCell(14).setCellValue("");
cell.setCellValue(productModel);//产品型号 index++;
cell = POIUtil.getCell(row, 3); }
cell.setCellValue(prodNameComb.getSelectionModel().getSelectedItem());//产品名称 }
cell = POIUtil.getCell(row, 6); sheet.getRow(2 + i * 23).getCell(15).setCellValue("共 " + pages + " 页");
cell.setCellValue(markText.getText());//文件名称 sheet.getRow(3 + i * 23).getCell(1).setCellValue(changeType);
cell = POIUtil.getCell(row, 10); // sheet.getRow(3 + i * 23).getCell(9).setCellValue(jobNames);//工作号 去掉了
cell.setCellValue(contractNo);//合同代号 sheet.getRow(3 + i * 23).getCell(11).setCellValue(contractNo);
cell = POIUtil.getCell(row, 12); sheet.getRow(3 + i * 23).getCell(14).setCellValue(changeTime);
cell.setCellValue(contractName);//合同名称 sheet.getRow(23 + i * 23).getCell(2).setCellValue(contractName);
cell = POIUtil.getCell(row, 16);
cell.setCellValue(changeTime);//更改实施日期 String[] unitCount = changeUnit1.split(";");
cell = POIUtil.getCell(row, 18); for (int j = 0; j < unitCount.length; j++) {
cell.setCellValue("第 1 页");//页号 sheet.getRow(5 + j + i * 23).getCell(15).setCellValue(unitCount[j]);
row = POIUtil.getRow(sheet, 5); }
cell = POIUtil.getCell(row, 3); HSSFCell cell;
cell.setCellValue(changeUnit1);//发放部门
//复制表头与页
if(pages > 1) {
// for(int i = 0; i < 6; i++)
// POIUtil.copyRow(workbook, POIUtil.getRow(sheet, i), POIUtil.getRow(sheet, i + 35), true);
POIUtil.copyRows(sheet, 0, TITLE_ROW_CNT - 1, FIRST_PAGE, 19, 1);
row = POIUtil.getRow(sheet, FIRST_PAGE + 4);
cell = POIUtil.getCell(row, 18);
cell.setCellValue("第 2 页");//页号
}else {
POIUtil.deleteRows(sheet, FIRST_PAGE, FIRST_PAGE + PAGE_ROW_CNT - 1);
}
if(pages > 2) {
POIUtil.copyRows(sheet, FIRST_PAGE, FIRST_PAGE + PAGE_ROW_CNT - 1, FIRST_PAGE + PAGE_ROW_CNT, 19, pages - 2);
for(int i = 2; i < pages; i++) {
int cnt = (i - 1) * PAGE_ROW_CNT;
row = POIUtil.getRow(sheet, FIRST_PAGE + 4 + cnt);
cell = POIUtil.getCell(row, 18);
cell.setCellValue("第 " + (i + 1) + " 页");//页号
}
}
//内容表格 for (int k = i * 5; k < (i + 1) * 5; k++) {
ObservableList<EcnBean> items = tableView.getItems(); if (k > changeDrawingNo.length - 1) {
for (int i = 0; i < items.size(); i++) { break;
if(i < 2) { }
row = POIUtil.getRow(sheet, i + TITLE_ROW_CNT); sheet.getRow(5 + 3 * pace + i * 23).getCell(1).setCellValue(changeDrawingNo[k]);
}else { sheet.getRow(5 + 3 * pace + i * 23).getCell(3).setCellValue(sign[k]);
int r = (i - 1) % PAGE_ITEM_CNT, page = (i - 1) / PAGE_ITEM_CNT; // sheet.getRow(5 + 3 * pace + i * 23).getCell(4).setCellValue(placesNo[k]);
if(r == 0) { sheet.getRow(5 + 3 * pace + i * 23).getCell(5).setCellValue(partition[k]);
r = PAGE_ITEM_CNT; sheet.getRow(5 + 3 * pace + i * 23).getCell(6).setCellValue(changeBefore1[k]);
page --; sheet.getRow(5 + 3 * pace + i * 23).getCell(9).setCellValue(changeAfter1[k]);
} sheet.getRow(5 + 3 * pace + i * 23).getCell(12).setCellValue(changeReason[k]);
row = POIUtil.getRow(sheet, FIRST_PAGE + TITLE_ROW_CNT + (r - 1) * ITEM_ROW_CNT + page * PAGE_ROW_CNT); sheet.getRow(5 + 3 * pace + i * 23).getCell(14).setCellValue(processType1[k]);
}
// EcnBean ecnBean = items.get(i); pace++;
cell = POIUtil.getCell(row, 0); }
cell.setCellValue(i + 1);//序号
cell = POIUtil.getCell(row, 1);
cell.setCellValue(changeDrawingNo[i]);//图样代号(文件编号)
cell = POIUtil.getCell(row, 3);
cell.setCellValue(sign[i]);//标记
cell = POIUtil.getCell(row, 4);
cell.setCellValue(partition[i]);//处数
cell = POIUtil.getCell(row, 5);
cell.setCellValue(changeBefore1[i]);//更改前
cell = POIUtil.getCell(row, 8);
cell.setCellValue(szVersionBefs[i]);//更改前版本
cell = POIUtil.getCell(row, 9);
cell.setCellValue(changeAfter1[i]);//更改后
cell = POIUtil.getCell(row, 12);
cell.setCellValue(szVersionAfts[i]);//更改后版本
cell = POIUtil.getCell(row, 13);
cell.setCellValue(productSzs[i]);//特性等级
cell = POIUtil.getCell(row, 14);
cell.setCellValue(changeReason[i]);//更改原因
cell = POIUtil.getCell(row, 17);
cell.setCellValue(processType1[i]);//产品处理意见
}
//影响分析表格 }
ObservableList<RefTableBean> refs = refTable.getItems(); if (pages == 0) {
for (int i = 0; i < refs.size(); i++) { sheet.getRow(2).getCell(15).setCellValue("共 1 页");
RefTableBean refTableBean = refs.get(i); sheet.getRow(3).getCell(1).setCellValue(productModel);
row = POIUtil.getRow(sheet, i % 15 + TITLE_ROW_CNT + 3); // sheet.getRow(3).getCell(9).setCellValue(jobNames);
sheet.getRow(3).getCell(11).setCellValue(contractNo);
int j = i / 15; sheet.getRow(3).getCell(14).setCellValue(changeTime);
j = (j == 0) ? 4 : 14; sheet.getRow(23).getCell(2).setCellValue(contractName);
cell = POIUtil.getCell(row, j + (refTableBean.getShYes().isSelected() ? 0 : 1)); String[] unitCount = changeUnit1.split(";");
cell.setCellValue("√");//是 否 for (int j = 0; j < unitCount.length; j++) {
j += 2; sheet.getRow(5 + j).getCell(15).setCellValue(unitCount[j]);
cell = POIUtil.getCell(row, j++); }
cell.setCellValue(refTableBean.getUserVal());//责任人
cell = POIUtil.getCell(row, j++);
cell.setCellValue(refTableBean.getCompDate().getText());//计划完成时间
cell = POIUtil.getCell(row, j++);
cell.setCellValue(refTableBean.getMark().getText());//备注
} }
File file2 = null; File file2 = null;
String timeNow = Util.GetNowDate(); String timeNow = Util.GetNowDate();
String filePath = System.getProperty("java.io.tmpdir") + timeNow + ".xlsx"; String filePath = System.getProperty("java.io.tmpdir") + timeNow + ".xls";
file2 = new File(filePath); file2 = new File(filePath);
fos = new FileOutputStream(file2); FileOutputStream fos = new FileOutputStream(file2);
workbook.write(fos); workBook.write(fos);
fos.close();
fis.close(); Util.deMerge(filePath, filePath, pages);
Util.delete(filePath, filePath, pages);
Workbook spireBook = new Workbook();
spireBook.loadFromFile(filePath);
Worksheet spireSheet = spireBook.getWorksheets().get(0);
ICheckBoxes boxes = spireSheet.getCheckBoxes();
// System.out.println("boxes:" + boxes.getCount());
ICheckBox box1 = boxes.get(0);
CheckState check1 = rb_product.isSelected() ? CheckState.Checked : CheckState.Unchecked;
box1.setCheckState(check1);
ICheckBox box2 = boxes.get(1);
CheckState check2 = rb_Process.isSelected() ? CheckState.Checked : CheckState.Unchecked;
box2.setCheckState(check2);
if(boxes.getCount() > 2) {
ICheckBox box3 = boxes.get(2);
box3.setCheckState(check1);
ICheckBox box4 = boxes.get(3);
box4.setCheckState(check2);
}
if(pages > 2) {
String t1 = box1.getText();
String t2 = box2.getText();
for(int i = 2; i < pages; i++) {
int r = FIRST_PAGE + (i - 1) * PAGE_ROW_CNT + 3;
ICheckBox checkbox1 = boxes.addCheckBox(r, 4, 18, 80);
checkbox1.setCheckState(check1);
checkbox1.setText(t1);
ICheckBox checkbox2 = boxes.addCheckBox(r, 6, 18, 80);
checkbox2.setCheckState(check2);
checkbox2.setText(t2);
}
}else if(pages < 2) {
IShapes shapes = spireSheet.getShapes();
IShape box = shapes.get(2);
System.out.println("boxes:" + box.getName());
box.setVisible(false);
box.remove();
box = shapes.get(3);
System.out.println("boxes:" + box.getHtmlString());
box.setVisible(false);
box.remove();
}
spireBook.save();
// Util.deMerge(filePath, filePath, pages);
// Util.delete(filePath, filePath, pages);
dataset.setFiles(new String[] { filePath }, new String[] { "excel" }); dataset.setFiles(new String[] { filePath }, new String[] { "excel" });
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally {
if(fis != null) {
try {
fis.close();
} catch (Exception e) {
e.printStackTrace();
}
}
if(fos != null) {
try {
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
}
} }
} }
private String contractNo; // 合同代号 private String contractNo; // 合同代号
@ -559,7 +442,7 @@ public class CreateEcnController extends KFXPanelController {
* @throws Exception * @throws Exception
* @function * @function
*/ */
private void setItemProperty(TCComponentItem item, String changeName) throws Exception { protected void setItemProperty(TCComponentItem item, String changeName) throws Exception {
contractNo = contractText.getText(); // 合同代号 contractNo = contractText.getText(); // 合同代号
contractName = htNameText.getText();// 合同名称 contractName = htNameText.getText();// 合同名称
@ -585,7 +468,7 @@ public class CreateEcnController extends KFXPanelController {
CheckBox radioButton = partBtns.get(j); CheckBox radioButton = partBtns.get(j);
if (radioButton.isSelected()) { if (radioButton.isSelected()) {
if (unit.length() > 0) { if (unit.length() > 0) {
unit.append(" ").append(radioButton.getText()); unit.append(";").append(radioButton.getText());
} else { } else {
unit.append(radioButton.getText()); unit.append(radioButton.getText());
} }
@ -596,7 +479,7 @@ public class CreateEcnController extends KFXPanelController {
ObservableList<EcnBean> items = tableView.getItems(); ObservableList<EcnBean> items = tableView.getItems();
int rowCount = items.size(); int rowCount = items.size();
System.out.println("rowCount:" + rowCount); System.out.println(rowCount);
changeDrawingNo = new String[rowCount]; changeDrawingNo = new String[rowCount];
sign = new String[rowCount]; sign = new String[rowCount];
// placesNo = new String[rowCount]; // placesNo = new String[rowCount];
@ -611,18 +494,14 @@ public class CreateEcnController extends KFXPanelController {
productSzs = new String[rowCount]; productSzs = new String[rowCount];
processSzs = new String[rowCount]; processSzs = new String[rowCount];
if(rowCount < 3) { int modulus = changeDrawingNo.length % 5;
pages = 1; int dlivery = changeDrawingNo.length / 5;
}else { if (modulus == 0) {
int modulus = (rowCount - 2) % 6; pages = dlivery;
int dlivery = (rowCount - 2) / 6 + 1; } else {
if (modulus == 0) { pages = dlivery + 1;
pages = dlivery; System.out.println("页数pages:" + pages);
} else {
pages = dlivery + 1;
}
} }
System.out.println("页数pages:" + pages);//TODO
for (int i = 0; i < rowCount; i++) { for (int i = 0; i < rowCount; i++) {
EcnBean ecnBean = items.get(i); EcnBean ecnBean = items.get(i);
changeDrawingNo[i] = ecnBean.getDrawNo().getText(); changeDrawingNo[i] = ecnBean.getDrawNo().getText();
@ -639,23 +518,6 @@ public class CreateEcnController extends KFXPanelController {
szVersionAfts[i] = ecnBean.getAfterVersion().getText(); szVersionAfts[i] = ecnBean.getAfterVersion().getText();
productSzs[i] = ecnBean.getProductSz().getSelectionModel().getSelectedItem(); productSzs[i] = ecnBean.getProductSz().getSelectionModel().getSelectedItem();
processSzs[i] = rb_product.isSelected() ? "Y" : "N"; processSzs[i] = rb_product.isSelected() ? "Y" : "N";
if(changeDrawingNo[i] == null)
changeDrawingNo[i] = "";
if(sign[i] == null)
sign[i] = "";
if(partition[i] == null)
partition[i] = "";
if(changeBefore1[i] == null)
changeBefore1[i] = "";
if(changeAfter1[i] == null)
changeAfter1[i] = "";
if(szVersionBefs[i] == null)
szVersionBefs[i] = "";
if(szVersionAfts[i] == null)
szVersionAfts[i] = "";
if(productSzs[i] == null)
productSzs[i] = "";
} }
item.getTCProperty("zt2_ChangeDrawingNo").setStringValueArray(changeDrawingNo); item.getTCProperty("zt2_ChangeDrawingNo").setStringValueArray(changeDrawingNo);
item.getTCProperty("zt2_Sign").setStringValueArray(sign); item.getTCProperty("zt2_Sign").setStringValueArray(sign);
@ -812,8 +674,6 @@ public class CreateEcnController extends KFXPanelController {
String result = read.getString("result"); String result = read.getString("result");
if (result.equals("否")) { if (result.equals("否")) {
refTableBean.setShNo(true); refTableBean.setShNo(true);
}else {
refTableBean.setShYes(true);
} }
i = i + 1; i = i + 1;
} }
@ -906,9 +766,8 @@ public class CreateEcnController extends KFXPanelController {
* *
* @function bean * @function bean
*/ */
@SuppressWarnings("unchecked") private void createDetailTable() {
private void createDetailTable() { // TODO Auto-generated method stub
// Auto-generated method stub
TableColumn<EcnBean, TextArea> tc_beforChange = new TableColumn<EcnBean, TextArea>("更改前"); TableColumn<EcnBean, TextArea> tc_beforChange = new TableColumn<EcnBean, TextArea>("更改前");
TableColumn<EcnBean, TextArea> tc_afterChange = new TableColumn<EcnBean, TextArea>("更改后"); TableColumn<EcnBean, TextArea> tc_afterChange = new TableColumn<EcnBean, TextArea>("更改后");
@ -969,9 +828,8 @@ public class CreateEcnController extends KFXPanelController {
* *
* @function * @function
*/ */
@SuppressWarnings("unchecked") private void createRefTable() {
private void createRefTable() { // TODO Auto-generated method stub
// Auto-generated method stub
// 影响分析表格 // 影响分析表格
TableColumn<RefTableBean, String> deapart = new TableColumn<RefTableBean, String>("部门"); TableColumn<RefTableBean, String> deapart = new TableColumn<RefTableBean, String>("部门");
@ -1074,7 +932,7 @@ public class CreateEcnController extends KFXPanelController {
* @function * @function
*/ */
private void addAssignAction(List<RefTableBean> refTableBeans) { private void addAssignAction(List<RefTableBean> refTableBeans) {
// Auto-generated method stub // TODO Auto-generated method stub
Button userBtn = refTableBeans.get(0).getUserBtn(); Button userBtn = refTableBeans.get(0).getUserBtn();
assignBtnAction(userBtn, 0, 7, refTableBeans); assignBtnAction(userBtn, 0, 7, refTableBeans);
assignBtnAction(refTableBeans.get(7).getUserBtn(), 7, 11, refTableBeans); assignBtnAction(refTableBeans.get(7).getUserBtn(), 7, 11, refTableBeans);
@ -1094,7 +952,7 @@ public class CreateEcnController extends KFXPanelController {
* @function * @function
*/ */
private void assignBtnAction(Button userBtn, int start, int end, List<RefTableBean> refTableBeans) { private void assignBtnAction(Button userBtn, int start, int end, List<RefTableBean> refTableBeans) {
// Auto-generated method stub // TODO Auto-generated method stub
userBtn.setOnAction(e -> { userBtn.setOnAction(e -> {
try { try {
String userVal = refTableBeans.get(start).getUserVal(); String userVal = refTableBeans.get(start).getUserVal();
@ -1112,7 +970,7 @@ public class CreateEcnController extends KFXPanelController {
}); });
} catch (Exception e1) { } catch (Exception e1) {
// Auto-generated catch block // TODO Auto-generated catch block
e1.printStackTrace(); e1.printStackTrace();
} }
}); });
@ -1124,22 +982,14 @@ public class CreateEcnController extends KFXPanelController {
* @throws Exception * @throws Exception
* @function OA9ID * @function OA9ID
*/ */
private Map<String, String> getUserItemOA(String name) throws Exception {//TODO 调用OA接口 Map<String, String> getUserItemOA(String name) throws Exception {
OkHttpClient client = new OkHttpClient(); OkHttpClient client = new OkHttpClient();
Map<String, String> emailMap = new HashMap<>(); Map<String, String> emailMap = new HashMap<>();
String url = session.getPreferenceService().getStringValues("CHINT_OAUserID_RUL")[0];
System.out.println("url==>" + url);
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType, "Email=&Name=" + name + "&UserUUID="); RequestBody body = RequestBody.create(mediaType, "Email=&Name=" + name);
Request request = new Request.Builder() Request request = new Request.Builder()
// .url("http://10.207.0.245:8012/Portal/Webservices/EH/EH_Q_BPM_Two_Service.asmx/GetUserItems") .url("http://10.207.0.245:8012/Portal/Webservices/EH/EH_Q_BPM_Two_Service.asmx/GetUserItems")
.url(url) .method("POST", body).addHeader("Content-Type", "application/x-www-form-urlencoded").build();
.method("POST", body)
.addHeader("item", "2100004876")
.addHeader("wbs", "")
.addHeader("factoryNo", "")
.addHeader("Content-Type", "application/x-www-form-urlencoded").build();
Response response = client.newCall(request).execute(); Response response = client.newCall(request).execute();
String string = response.body().string(); String string = response.body().string();
System.out.println("xml==>" + string); System.out.println("xml==>" + string);
@ -1148,8 +998,7 @@ public class CreateEcnController extends KFXPanelController {
String type = rootElement.elementText("TYPE"); String type = rootElement.elementText("TYPE");
String message = rootElement.elementText("MESSAGE"); String message = rootElement.elementText("MESSAGE");
if (type.equals("S")) { if (type.equals("S")) {
@SuppressWarnings("unchecked") List<Element> elements = rootElement.elements("items");
List<Element> elements = rootElement.elements("items");
for (Element element : elements) { for (Element element : elements) {
Element userItemCs = element.element("EH_HR_UserItems_CS"); Element userItemCs = element.element("EH_HR_UserItems_CS");
@ -1176,21 +1025,20 @@ public class CreateEcnController extends KFXPanelController {
* @param frame * @param frame
* @function * @function
*/ */
@SuppressWarnings("unchecked") private void addWindListener(CreateEcnFrame frame) {
private void addWindListener(CreateEcnFrame frame) { // TODO Auto-generated method stub
// Auto-generated method stub
frame.addComponentListener(new ComponentListener() { frame.addComponentListener(new ComponentListener() {
@Override @Override
public void componentShown(ComponentEvent e) { public void componentShown(ComponentEvent e) {
// Auto-generated method stub // TODO Auto-generated method stub
} }
@Override @Override
public void componentResized(ComponentEvent e) { public void componentResized(ComponentEvent e) {
// Auto-generated method stub // TODO Auto-generated method stub
// System.out.println("=============="); // System.out.println("==============");
double width = e.getComponent().getSize().getWidth(); double width = e.getComponent().getSize().getWidth();
// // double width = primaryStage.getWidth(); // // double width = primaryStage.getWidth();
@ -1203,13 +1051,13 @@ public class CreateEcnController extends KFXPanelController {
@Override @Override
public void componentMoved(ComponentEvent e) { public void componentMoved(ComponentEvent e) {
// Auto-generated method stub // TODO Auto-generated method stub
} }
@Override @Override
public void componentHidden(ComponentEvent e) { public void componentHidden(ComponentEvent e) {
// Auto-generated method stub // TODO Auto-generated method stub
} }
}); });
@ -1223,7 +1071,7 @@ public class CreateEcnController extends KFXPanelController {
String part = read.getString(1); String part = read.getString(1);
String reason = read.getString(2); String reason = read.getString(2);
String manage = read.getString(3); String manage = read.getString(3);
// String dataset = read.getString(4); String dataset = read.getString(4);
String factory = read.getString(5); String factory = read.getString(5);
String grade = read.getString(6); String grade = read.getString(6);
factoryText.setText(factory); factoryText.setText(factory);
@ -1301,7 +1149,7 @@ public class CreateEcnController extends KFXPanelController {
rb_tempChange.isSelected(), assignBtn); rb_tempChange.isSelected(), assignBtn);
dialog.start(new Stage()); dialog.start(new Stage());
} catch (Exception e) { } catch (Exception e) {
// Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -1319,7 +1167,7 @@ public class CreateEcnController extends KFXPanelController {
try { try {
dialog.start(new Stage()); dialog.start(new Stage());
} catch (IOException e) { } catch (IOException e) {
// Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }

@ -82,8 +82,8 @@ public class RefTableBean {
return shYes; return shYes;
} }
public void setShYes(boolean shYes) { public void setShYes(CheckBox shYes) {
this.shYes.setSelected(shYes); this.shYes = shYes;
} }
public CheckBox getShNo() { public CheckBox getShNo() {

@ -33,11 +33,6 @@ import javafx.scene.layout.GridPane;
import javafx.scene.layout.StackPane; import javafx.scene.layout.StackPane;
import javafx.stage.Stage; import javafx.stage.Stage;
/**
* @author cyh
*
*
*/
public class RelateEcnController { public class RelateEcnController {
@FXML @FXML

@ -28,6 +28,7 @@ import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.kernel.TCComponent; import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentDataset; import com.teamcenter.rac.kernel.TCComponentDataset;
import com.teamcenter.rac.kernel.TCComponentTcFile; import com.teamcenter.rac.kernel.TCComponentTcFile;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCPreferenceService; import com.teamcenter.rac.kernel.TCPreferenceService;
import com.teamcenter.rac.kernel.TCSession; import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox; import com.teamcenter.rac.util.MessageBox;
@ -41,7 +42,6 @@ public class Util {
public static final String ITEM_REVIISON_ID = "item_revision_id"; public static final String ITEM_REVIISON_ID = "item_revision_id";
public static final String REVISION_RULE_ANY = "Any Status; Working"; public static final String REVISION_RULE_ANY = "Any Status; Working";
public static final String BL_QTY = "bl_quantity"; public static final String BL_QTY = "bl_quantity";
public Connection connect(Connection conn, TCSession session) { public Connection connect(Connection conn, TCSession session) {
String[] database = session.getPreferenceService().getStringValues("database_tc"); String[] database = session.getPreferenceService().getStringValues("database_tc");
String JdbcDriverClass = "oracle.jdbc.driver.OracleDriver"; String JdbcDriverClass = "oracle.jdbc.driver.OracleDriver";
@ -53,12 +53,12 @@ public class Util {
strPassword = database[4]; strPassword = database[4];
try { try {
Class.forName(JdbcDriverClass); Class.forName(JdbcDriverClass);
} catch (Exception e1) { } catch (ClassNotFoundException e1) {
e1.printStackTrace(); e1.printStackTrace();
} }
try { try {
conn = DriverManager.getConnection(strUrl, strUserName, strPassword); conn = DriverManager.getConnection(strUrl, strUserName, strPassword);
} catch (Exception e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
} }
return conn; return conn;
@ -105,8 +105,8 @@ public class Util {
} else { } else {
return tcFile[0].getFmsFile(); return tcFile[0].getFmsFile();
} }
} catch (Exception e) { } catch (TCException e) {
// Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
return null; return null;
@ -120,7 +120,7 @@ public class Util {
* @function * @function
*/ */
public static void setCellValue(XSSFCell cell2, int index, XSSFRow row0, String cellValue) { public static void setCellValue(XSSFCell cell2, int index, XSSFRow row0, String cellValue) {
// Auto-generated method stub // TODO Auto-generated method stub
if (cell2 == null) { if (cell2 == null) {
cell2 = row0.createCell(index); cell2 = row0.createCell(index);
@ -137,7 +137,7 @@ public class Util {
* @function * @function
*/ */
public static XSSFRow getRow(XSSFSheet sheetAt, int rowNum) { public static XSSFRow getRow(XSSFSheet sheetAt, int rowNum) {
// Auto-generated method stub // TODO Auto-generated method stub
XSSFRow row = sheetAt.getRow(rowNum); XSSFRow row = sheetAt.getRow(rowNum);
if (row == null) { if (row == null) {
@ -244,7 +244,7 @@ public class Util {
AIFComponentContext[] a3 = ((TCComponent) a2[0].getComponent()).whereReferenced();// 项目零组件 AIFComponentContext[] a3 = ((TCComponent) a2[0].getComponent()).whereReferenced();// 项目零组件
target = (TCComponent) a3[0].getComponent(); target = (TCComponent) a3[0].getComponent();
} }
} catch (Exception e1) { } catch (TCException e1) {
e1.printStackTrace(); e1.printStackTrace();
} }
try { try {
@ -265,7 +265,7 @@ public class Util {
} }
} }
} }
} catch (Exception e) { } catch (TCException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -303,7 +303,7 @@ public class Util {
AIFComponentContext[] a3 = ((TCComponent) a2[0].getComponent()).whereReferenced();// 项目零组件 AIFComponentContext[] a3 = ((TCComponent) a2[0].getComponent()).whereReferenced();// 项目零组件
target = (TCComponent) a3[0].getComponent(); target = (TCComponent) a3[0].getComponent();
} }
} catch (Exception e1) { } catch (TCException e1) {
e1.printStackTrace(); e1.printStackTrace();
} }
try { try {
@ -324,7 +324,7 @@ public class Util {
} }
} }
} }
} catch (Exception e) { } catch (TCException e) {
e.printStackTrace(); e.printStackTrace();
} }

@ -42,7 +42,6 @@ public class CreateBOMDifference_DYController {
TCComponentItem item = null; TCComponentItem item = null;
TCComponentItemRevision rev = null; TCComponentItemRevision rev = null;
BOMDifferenceBean bean; BOMDifferenceBean bean;
boolean child = !groupID.equals("M060");
/** /**
* - * -
*/ */
@ -206,9 +205,9 @@ public class CreateBOMDifference_DYController {
// BOMDifferenceBean parentBean; // BOMDifferenceBean parentBean;
bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
TCComponentBOMWindow win = bomWinType.create(null); TCComponentBOMWindow win = bomWinType.create(null);
// win.lock(); win.lock();
TCComponentBOMWindow win2 = bomWinType.create(null); TCComponentBOMWindow win2 = bomWinType.create(null);
// win2.lock(); win2.lock();
TCComponentItemRevision parentRev; TCComponentItemRevision parentRev;
try { try {
for (int i = 0, len = list_ccps.size(); i < len; i++) { for (int i = 0, len = list_ccps.size(); i < len; i++) {
@ -269,7 +268,7 @@ public class CreateBOMDifference_DYController {
childBean.setObject_desc_Parent(object_desc); childBean.setObject_desc_Parent(object_desc);
childBean.setParentPartRev(newRev); childBean.setParentPartRev(newRev);
bomCompare_M030(childBean, session, 1, 1, beans, list_items, child); bomCompare_M030(childBean, session, 1, 1, beans, list_items);
} }
} }
@ -298,7 +297,7 @@ public class CreateBOMDifference_DYController {
bean.setObject_desc_Parent(object_desc); bean.setObject_desc_Parent(object_desc);
bean.setParentPartRev(newRev); bean.setParentPartRev(newRev);
bomCompare_M030(bean, session, 1, 1, beans, list_items, child); bomCompare_M030(bean, session, 1, 1, beans, list_items);
} }
} }
} catch (Exception e) { } catch (Exception e) {
@ -326,8 +325,8 @@ public class CreateBOMDifference_DYController {
return false; return false;
} }
private static void bomCompare_M030(BOMDifferenceBean parentBean, TCSession session, double parent_quantity_old, public static void bomCompare_M030(BOMDifferenceBean parentBean, TCSession session, double parent_quantity_old,
double parent_quantity_new, List<BOMCompareBean> beans, List<TCComponentItem> item_compares, boolean child) double parent_quantity_new, List<BOMCompareBean> beans, List<TCComponentItem> item_compares)
throws TCException, SQLException { throws TCException, SQLException {
if (item_compares.indexOf(parentBean.getItem()) != -1) { if (item_compares.indexOf(parentBean.getItem()) != -1) {
System.out.println("已添加过" + parentBean.getItem()); System.out.println("已添加过" + parentBean.getItem());
@ -449,8 +448,7 @@ public class CreateBOMDifference_DYController {
object_desc_Old, num_Old, "", "", ""); object_desc_Old, num_Old, "", "", "");
beans.add(compareBean); beans.add(compareBean);
// 物料删除遍历 // 物料删除遍历
if(child) bomCompare_M030(bean, session, 1, 1, beans, item_compares);
bomCompare_M030(bean, session, 1, 1, beans, item_compares, child);
} }
if (newPartRev != null && oldPartRev == null) { if (newPartRev != null && oldPartRev == null) {
// 物料新增 若变更项不为虚拟项则记录 // 物料新增 若变更项不为虚拟项则记录
@ -464,8 +462,7 @@ public class CreateBOMDifference_DYController {
zt2_MaterialNo_New, object_desc_New, num_New); zt2_MaterialNo_New, object_desc_New, num_New);
beans.add(compareBean); beans.add(compareBean);
// 物料新增遍历 // 物料新增遍历
if(child) bomCompare_M030(bean, session, 1, 1, beans, item_compares);
bomCompare_M030(bean, session, 1, 1, beans, item_compares, child);
} }
if (newPartRev != null && oldPartRev != null) { if (newPartRev != null && oldPartRev != null) {
@ -482,8 +479,7 @@ public class CreateBOMDifference_DYController {
zt2_MaterialNo_Old, object_desc_Old, num_Old, zt2_MaterialNo_New, object_desc_New, num_New); zt2_MaterialNo_Old, object_desc_Old, num_Old, zt2_MaterialNo_New, object_desc_New, num_New);
beans.add(compareBean); beans.add(compareBean);
// 物料新增遍历 // 物料新增遍历
if(child) bomCompare_M030(bean, session, 1, 1, beans, item_compares);
bomCompare_M030(bean, session, 1, 1, beans, item_compares, child);
} else { } else {
if (bean.getOldQuantity() > bean.getNewQuantity()) { if (bean.getOldQuantity() > bean.getNewQuantity()) {
System.out.println("物料数量变更-删除-" + bean.getItem()); System.out.println("物料数量变更-删除-" + bean.getItem());
@ -505,8 +501,7 @@ public class CreateBOMDifference_DYController {
num_New); num_New);
beans.add(compareBean); beans.add(compareBean);
} }
if(child) bomCompare_M030(bean, session, 1, 1, beans, item_compares);
bomCompare_M030(bean, session, 1, 1, beans, item_compares, child);
} }
} }

@ -7,15 +7,17 @@
*/ */
package com.chint.plm.createbomdifference; package com.chint.plm.createbomdifference;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle; import java.util.ResourceBundle;
import com.chint.plm.createEcn.Util; import com.chint.plm.createEcn.Util;
import com.connor.chint.sap2.util.BomToSapUtil; import com.connor.chint.sap2.util.BomToSapUtil;
import com.connor.chint.yunpi.KCommand; import com.connor.chint.yunpi.KCommand;
import com.teamcenter.rac.aif.AbstractAIFApplication; import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.AbstractAIFSession;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponent; import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine; import com.teamcenter.rac.kernel.TCComponentBOMLine;
@ -24,6 +26,8 @@ import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
import com.teamcenter.rac.kernel.TCComponentItem; import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision; import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentRevisionRule; import com.teamcenter.rac.kernel.TCComponentRevisionRule;
import com.teamcenter.rac.kernel.TCComponentRevisionRuleType;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession; import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox; import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSData; import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSData;
@ -45,10 +49,10 @@ public class ExtractDiffComd extends KCommand {
private TCSession session; private TCSession session;
/** /**
*
* @param app * @param app
* @param commandId * @param commandId
* @param actionInfo * @param actionInfo
* @function
*/ */
public ExtractDiffComd(AbstractAIFApplication app, String commandId, String actionInfo) { public ExtractDiffComd(AbstractAIFApplication app, String commandId, String actionInfo) {
super(app, commandId, actionInfo); super(app, commandId, actionInfo);
@ -70,9 +74,9 @@ public class ExtractDiffComd extends KCommand {
return; return;
} }
readChangeDesign(oldComponents, newComponents, tar); readChangeDesign(oldComponents, newComponents, tar);
MessageBox.post(resource.getString("SUCC_CHANGE"), "", 2);
} catch (Exception e) { } catch (TCException e) {
// Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -83,12 +87,13 @@ public class ExtractDiffComd extends KCommand {
* @param oldComponents * @param oldComponents
* @param newComponents * @param newComponents
* @param tar * @param tar
* @throws Exception * @throws TCException
* @function
*/ */
private void readChangeDesign(TCComponent[] oldComponents, TCComponent[] newComponents, TCComponent tar) private void readChangeDesign(TCComponent[] oldComponents, TCComponent[] newComponents, TCComponent tar)
throws Exception { throws TCException {
// Auto-generated method stub // TODO Auto-generated method stub
HashMap<TCComponentItem, ChangeDesignBean> itemChangeMap = new HashMap<>(); Map<TCComponentItem, ChangeDesignBean> itemChangeMap = new HashMap<>();
for (TCComponent oldComponent : oldComponents) { for (TCComponent oldComponent : oldComponents) {
if (oldComponent.getType().equals(ZT_DESIGN3D)) { if (oldComponent.getType().equals(ZT_DESIGN3D)) {
TCComponentItemRevision rev = (TCComponentItemRevision) oldComponent; TCComponentItemRevision rev = (TCComponentItemRevision) oldComponent;
@ -144,65 +149,33 @@ public class ExtractDiffComd extends KCommand {
for (TCComponentItem keyItem : itemChangeMap.keySet()) { for (TCComponentItem keyItem : itemChangeMap.keySet()) {
ChangeDesignBean changeDesignBean = itemChangeMap.get(keyItem); ChangeDesignBean changeDesignBean = itemChangeMap.get(keyItem);
TCComponentItemRevision oldDesgin = changeDesignBean.getOldDesgin(); TCComponentItemRevision oldDesgin = changeDesignBean.getOldDesgin();
HashMap<String, PBomBean> materialMap = getMaterialByDesign(oldDesgin); Map<String, PBomBean> materialOld = getMaterialByDesign(oldDesgin);
System.out.println("material===>" + materialMap.toString()); TCComponentItemRevision newDesgin = changeDesignBean.getNewDesgin();
// TCComponentItemRevision newDesgin = changeDesignBean.getNewDesgin(); Map<String, PBomBean> materialNew = getMaterialByDesign(newDesgin);
// Map<String, PBomBean> materialNew = getMaterialByDesign(newDesgin); System.out.println("materialOld===>" + materialOld.toString());
System.out.println("materialNew===>" + materialNew.toString());
// System.out.println("materialNew===>" + materialNew.toString());
ArrayList<String> list = new ArrayList<>();
// 比较变更前后物料BOM // 比较变更前后物料BOM
for (String materialNo : materialMap.keySet()) { for (String materialNo : materialOld.keySet()) {
// if (!materialNew.containsKey(materialNo)) if (!materialNew.containsKey(materialNo))
// continue; continue;
String mno = materialNo.substring(2); PBomBean pBomBeanOld = materialOld.get(materialNo);
if(list.contains(mno)) PBomBean pBomBeanNew = materialNew.get(materialNo);
continue;
list.add(mno);
PBomBean pBomBeanOld, pBomBeanNew;
if(materialNo.startsWith("o@")) {
pBomBeanOld = materialMap.get(materialNo);
pBomBeanNew = materialMap.get("n@" + mno);
}else {
pBomBeanOld = materialMap.get("o@" + mno);
pBomBeanNew = materialMap.get(materialNo);
}
// 有P物料获取P没有遍历EBOM // 有P物料获取P没有遍历EBOM
/*
TCComponent oldMaterial = pBomBeanOld.getpMaterial() == null ? pBomBeanOld.geteMaterial() TCComponent oldMaterial = pBomBeanOld.getpMaterial() == null ? pBomBeanOld.geteMaterial()
: pBomBeanOld.getpMaterial(); : pBomBeanOld.getpMaterial();
TCComponent newMaterial = pBomBeanNew.getpMaterial() == null ? pBomBeanNew.geteMaterial() TCComponent newMaterial = pBomBeanNew.getpMaterial() == null ? pBomBeanNew.geteMaterial()
: pBomBeanNew.getpMaterial(); : pBomBeanNew.getpMaterial();
*/ // 全展开之后比较单层物料编码的数量
//TODO 20240201修改为遍历PBOM和EBOM // 旧的bom修改版本规则
TCComponent oldMaterial = pBomBeanOld.getpMaterial(); TCComponentBOMLine oldBomLine = sendToStructureManager((TCComponentItemRevision) oldMaterial,
if(oldMaterial != null) { Util.REVISION_RULE_ANY);
TCComponent newMaterial = pBomBeanNew.getpMaterial(); TCComponentBOMLine newBomLine = sendToStructureManager((TCComponentItemRevision) newMaterial, null);
// 全展开之后比较单层物料编码的数量 // BOM全展开
// 旧的bom修改版本规则 Map<String, ExpandPSData[]> oldBomMap = BomToSapUtil.getBomLineTreeNodeSOA(oldBomLine);
TCComponentBOMLine oldBomLine = sendToStructureManager((TCComponentItemRevision) oldMaterial, Util.REVISION_RULE_ANY); Map<String, ExpandPSData[]> newBomMap = BomToSapUtil.getBomLineTreeNodeSOA(newBomLine);
TCComponentBOMLine newBomLine = sendToStructureManager((TCComponentItemRevision) newMaterial, null); addChangeBom(oldBomMap, oldBomLine, newBomMap, newBomLine, tar);
// BOM全展开 System.out.println("oldBomMap===>" + oldBomMap.toString());
HashMap<String, ExpandPSData[]> oldBomMap = BomToSapUtil.getBomLineTreeNodeSOA(oldBomLine); System.out.println("newBomMap===>" + newBomMap.toString());
HashMap<String, ExpandPSData[]> newBomMap = BomToSapUtil.getBomLineTreeNodeSOA(newBomLine);
addChangeBom(oldBomMap, oldBomLine, newBomMap, newBomLine, tar);
System.out.println("oldBomMap===>" + oldBomMap.toString());
System.out.println("newBomMap===>" + newBomMap.toString());
}
oldMaterial = pBomBeanOld.geteMaterial();
if(oldMaterial != null) {
TCComponent newMaterial = pBomBeanNew.geteMaterial();
// 全展开之后比较单层物料编码的数量
// 旧的bom修改版本规则
TCComponentBOMLine oldBomLine = sendToStructureManager((TCComponentItemRevision) oldMaterial, Util.REVISION_RULE_ANY);
TCComponentBOMLine newBomLine = sendToStructureManager((TCComponentItemRevision) newMaterial, null);
// BOM全展开
HashMap<String, ExpandPSData[]> oldBomMap = BomToSapUtil.getBomLineTreeNodeSOA(oldBomLine);
HashMap<String, ExpandPSData[]> newBomMap = BomToSapUtil.getBomLineTreeNodeSOA(newBomLine);
addChangeBom(oldBomMap, oldBomLine, newBomMap, newBomLine, tar);
System.out.println("oldBomMap===>" + oldBomMap.toString());
System.out.println("newBomMap===>" + newBomMap.toString());
}
} }
} }
System.out.println("itemChangeMap===>" + itemChangeMap.toString()); System.out.println("itemChangeMap===>" + itemChangeMap.toString());
@ -216,22 +189,23 @@ public class ExtractDiffComd extends KCommand {
* @param newBomMap * @param newBomMap
* @param newBomLine BOM * @param newBomLine BOM
* @param changeTag * @param changeTag
* @throws Exception * @throws TCException
* @function
*/ */
private void addChangeBom(HashMap<String, ExpandPSData[]> oldBomMap, TCComponentBOMLine oldBomLine, private void addChangeBom(Map<String, ExpandPSData[]> oldBomMap, TCComponentBOMLine oldBomLine,
HashMap<String, ExpandPSData[]> newBomMap, TCComponentBOMLine newBomLine, TCComponent changeTag) Map<String, ExpandPSData[]> newBomMap, TCComponentBOMLine newBomLine, TCComponent changeTag)
throws Exception { throws TCException {
// Auto-generated method stub // TODO Auto-generated method stub
String oldUid = oldBomLine.getUid(); String oldUid = oldBomLine.getUid();
ExpandPSData[] expandPSDatasOld = oldBomMap.get(oldUid); ExpandPSData[] expandPSDatasOld = oldBomMap.get(oldUid);
ExpandPSData[] expandPSDatasNew = newBomMap.get(newBomLine.getUid()); ExpandPSData[] expandPSDatasNew = newBomMap.get(newBomLine.getUid());
if (expandPSDatasNew.length == 0 && expandPSDatasOld.length == 0) { if (expandPSDatasNew.length == 0 && expandPSDatasOld.length == 0) {
return; return;
} }
HashMap<String, Double> oldMaterialMap = new HashMap<>(); Map<String, Double> oldMaterialMap = new HashMap<>();
HashMap<String, Double> newMaterialMap = new HashMap<>(); Map<String, Double> newMaterialMap = new HashMap<>();
// 记录变更前的物料编码和对应的BOM // 记录变更前的物料编码和对应的BOM
HashMap<String, TCComponentBOMLine> oldBomLineMap = new HashMap<>(); Map<String, TCComponentBOMLine> oldBomLineMap = new HashMap<>();
for (ExpandPSData expandPSData : expandPSDatasOld) { for (ExpandPSData expandPSData : expandPSDatasOld) {
TCComponentBOMLine bomLine = expandPSData.bomLine; TCComponentBOMLine bomLine = expandPSData.bomLine;
TCComponentItemRevision itemRevOfBOMLine = expandPSData.itemRevOfBOMLine; TCComponentItemRevision itemRevOfBOMLine = expandPSData.itemRevOfBOMLine;
@ -277,8 +251,6 @@ public class ExtractDiffComd extends KCommand {
changeTag.add(ZT_CHANGE_BEF, oldBomLine.getItemRevision()); changeTag.add(ZT_CHANGE_BEF, oldBomLine.getItemRevision());
changeTag.add(ZT_CHANGE_AFT, newBomLine.getItemRevision()); changeTag.add(ZT_CHANGE_AFT, newBomLine.getItemRevision());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
} }
} else { } else {
for (String materNo : oldMaterialMap.keySet()) { for (String materNo : oldMaterialMap.keySet()) {
@ -291,7 +263,6 @@ public class ExtractDiffComd extends KCommand {
changeTag.add(ZT_CHANGE_BEF, oldBomLine.getItemRevision()); changeTag.add(ZT_CHANGE_BEF, oldBomLine.getItemRevision());
changeTag.add(ZT_CHANGE_AFT, newBomLine.getItemRevision()); changeTag.add(ZT_CHANGE_AFT, newBomLine.getItemRevision());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
} }
} }
} }
@ -301,9 +272,9 @@ public class ExtractDiffComd extends KCommand {
/** /**
* *
* *
* @param tcComponentItemRev * @param tcComponentItem
* @param revisionRuleName * @param revisionRuleName
* @return BOM * @return
*/ */
public TCComponentBOMLine sendToStructureManager(TCComponentItemRevision tcComponentItemRev, public TCComponentBOMLine sendToStructureManager(TCComponentItemRevision tcComponentItemRev,
String revisionRuleName) { String revisionRuleName) {
@ -320,7 +291,7 @@ public class ExtractDiffComd extends KCommand {
} }
return bomWindow.setWindowTopLine(null, tcComponentItemRev, null, null); return bomWindow.setWindowTopLine(null, tcComponentItemRev, null, null);
} catch (Exception e) { } catch (TCException e) {
e.printStackTrace(); e.printStackTrace();
return null; return null;
} }
@ -330,71 +301,40 @@ public class ExtractDiffComd extends KCommand {
* , PP * , PP
* *
* @param designRev * @param designRev
* @return * @throws TCException
* @throws Exception * @function
*/ */
private HashMap<String, PBomBean> getMaterialByDesign(TCComponentItemRevision designRev) throws Exception { private Map<String, PBomBean> getMaterialByDesign(TCComponentItemRevision designRev) throws TCException {
// Auto-generated method stub // TODO Auto-generated method stub
HashMap<String, PBomBean> pbomMap = new HashMap<>(); Map<String, PBomBean> pbomMap = new HashMap<>();
// 图纸下物料 // 图纸下物料
TCComponent[] represents = designRev.getReferenceListProperty(REPRESENTATION_FOR); TCComponent[] represents = designRev.getReferenceListProperty(REPRESENTATION_FOR);
for (TCComponent represent : represents) { for (TCComponent represent : represents) {
//TODO 20240226修改为通过BOMView是否发布来判断变更前后 String[] matnrProps = represent
TCComponent[] bom = represent.getReferenceListProperty("structure_revisions"); .getProperties(new String[] { Util.ZT_MATERIAL_NO, Util.ZT_PROP_PBOM, Util.ITEM_REVIISON_ID });
System.out.println("structure_revisions===>" + represent + " = " + bom.length); String materialNo = matnrProps[0];// material.getProperty(Util.ZT_MATERIAL_NO);
TCComponent[] revs = represent.getReferenceProperty("items_tag").getReferenceListProperty("revision_list"); if (pbomMap.containsKey(materialNo)) {
if(bom.length > 0 && bom[0].getDateProperty("date_released") == null && revs.length > 1) { PBomBean pBomBean = pbomMap.get(materialNo);
int size = revs.length; // 是否PBOM
//取最新版本作为变更后版本用n@表示 if (matnrProps[1].equals(Util.ZT_VAL_PBOM) && matnrProps[2].compareTo(pBomBean.getpRevision()) > 0) {
TCComponent rev = revs[size - 1]; pBomBean.setpMaterial(represent);
String[] matnrProps = rev.getProperties(new String[] { Util.ZT_MATERIAL_NO, Util.ZT_PROP_PBOM, Util.ITEM_REVIISON_ID }); pBomBean.setpRevision(matnrProps[2]);
String materialNo = matnrProps[0];// material.getProperty(Util.ZT_MATERIAL_NO); } else if (!matnrProps[1].equals(Util.ZT_VAL_PBOM)
if(pbomMap.containsKey("n@" + materialNo)) { && matnrProps[2].compareTo(pBomBean.geteRevision()) > 0) {
PBomBean pBomBean = pbomMap.get("n@" + materialNo); pBomBean.seteMaterial(represent);
if(matnrProps[1].equals(Util.ZT_VAL_PBOM)) { pBomBean.seteRevision(matnrProps[2]);
pBomBean.setpMaterial(rev);
pBomBean.setpRevision(matnrProps[2]);
}else {
pBomBean.seteMaterial(rev);
pBomBean.seteRevision(matnrProps[2]);
}
}else {
PBomBean pBomBean = new PBomBean();
if (matnrProps[1].equals(Util.ZT_VAL_PBOM)) {
pBomBean.setpMaterial(rev);
pBomBean.setpRevision(matnrProps[2]);
} else {
pBomBean.seteMaterial(rev);
pBomBean.seteRevision(matnrProps[2]);
}
pbomMap.put("n@" + materialNo, pBomBean);
} }
} else {
//取第二新版本作为变更前版本用o@表示 PBomBean pBomBean = new PBomBean();
rev = revs[size - 2]; if (matnrProps[1].equals(Util.ZT_VAL_PBOM)) {
matnrProps = rev.getProperties(new String[] { Util.ZT_MATERIAL_NO, Util.ZT_PROP_PBOM, Util.ITEM_REVIISON_ID }); pBomBean.setpMaterial(represent);
materialNo = matnrProps[0];// material.getProperty(Util.ZT_MATERIAL_NO); pBomBean.setpRevision(matnrProps[2]);
if(pbomMap.containsKey("o@" + materialNo)) { } else {
PBomBean pBomBean = pbomMap.get("o@" + materialNo); pBomBean.seteMaterial(represent);
if(matnrProps[1].equals(Util.ZT_VAL_PBOM)) { pBomBean.seteRevision(matnrProps[2]);
pBomBean.setpMaterial(rev);
pBomBean.setpRevision(matnrProps[2]);
}else {
pBomBean.seteMaterial(rev);
pBomBean.seteRevision(matnrProps[2]);
}
}else {
PBomBean pBomBean = new PBomBean();
if (matnrProps[1].equals(Util.ZT_VAL_PBOM)) {
pBomBean.setpMaterial(rev);
pBomBean.setpRevision(matnrProps[2]);
} else {
pBomBean.seteMaterial(rev);
pBomBean.seteRevision(matnrProps[2]);
}
pbomMap.put("o@" + materialNo, pBomBean);
} }
} pbomMap.put(materialNo, pBomBean);
}
} }
return pbomMap; return pbomMap;
} }

@ -1,3 +1,2 @@
ERROR_NOT_CHANGE=\u8BF7\u9009\u62E9\u66F4\u6539\u901A\u77E5\u5355\u5BF9\u8C61 ERROR_NOT_CHANGE=\u8BF7\u9009\u62E9\u66F4\u6539\u901A\u77E5\u5355\u5BF9\u8C61
ERROR_NO_CHANGE=\u672A\u627E\u5230\u53D8\u66F4\u524D\u540E\u5BF9\u8C61,\u65E0\u6CD5\u63D0\u53D6\u5DEE\u5F02\u9879\uFF01 ERROR_NO_CHANGE=\u672A\u627E\u5230\u53D8\u66F4\u524D\u540E\u5BF9\u8C61,\u65E0\u6CD5\u63D0\u53D6\u5DEE\u5F02\u9879\uFF01
SUCC_CHANGE=\u63D0\u53D6\u5B8C\u6210

@ -1,8 +1,14 @@
package com.chint.plm.updateWorkTime; package com.chint.plm.updateWorkTime;
import java.sql.ResultSet;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import javax.swing.JOptionPane;
import com.chint.plm.applyMatnr.ApplyMatnrOp;
import com.chint.plm.applyMatnr.ApplyMatnrOp2;
import com.connor.chint.sap2.util.MyProgressBarCompent; import com.connor.chint.sap2.util.MyProgressBarCompent;
import com.connor.chint.sap2.util.SAPMessageUtilFram; import com.connor.chint.sap2.util.SAPMessageUtilFram;
import com.connor.chint.sap2.util.SAPUtil; import com.connor.chint.sap2.util.SAPUtil;
@ -18,11 +24,10 @@ import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.kernel.TCUserService; import com.teamcenter.rac.kernel.TCUserService;
import com.teamcenter.rac.util.MessageBox; import com.teamcenter.rac.util.MessageBox;
@SuppressWarnings("deprecation")
public class UpdateWorkCommand extends KCommand { public class UpdateWorkCommand extends KCommand {
// private boolean top = true; private boolean top = true;
// private TCComponentBOMLine line; private TCComponentBOMLine line;
public TCComponentItemRevision getPRevision(TCComponentItemRevision rev2) throws TCException { public TCComponentItemRevision getPRevision(TCComponentItemRevision rev2) throws TCException {
String zt2_MaterialNo = rev2.getStringProperty("zt2_MaterialNo"); String zt2_MaterialNo = rev2.getStringProperty("zt2_MaterialNo");
@ -55,33 +60,41 @@ public class UpdateWorkCommand extends KCommand {
return rev2; return rev2;
} }
private TCComponentItemRevision getTopZzItem(TCComponentItemRevision rev) throws Exception { private TCComponentItemRevision getTopZzItem(TCComponentItemRevision rev) {
TCComponent[] whereUsed = rev.whereUsed(TCComponent.WHERE_USED_ALL); // TODO Auto-generated method stub
if(whereUsed.length == 0) { // item = null;
// String property = rev.getProperty("item_id"); try {
return rev; TCComponent[] whereUsed = rev.whereUsed((short)0);
}else { if(whereUsed.length==0) {
List<TCComponentItemRevision> revPs = new ArrayList<TCComponentItemRevision>(); // String property = rev.getProperty("item_id");
for(int i = 0; i < whereUsed.length; i++) { return rev;
TCComponentItemRevision revP = (TCComponentItemRevision)whereUsed[i]; }else {
if(revP.getType().contains("Part")) { List<TCComponentItemRevision> revPs = new ArrayList<TCComponentItemRevision>();
revPs.add(revP); for(int i=0;i<whereUsed.length;i++) {
TCComponentItemRevision revP = (TCComponentItemRevision)whereUsed[i];
if(revP.getType().contains("Part")) {
revPs.add(revP);
}
} }
}
for(TCComponentItemRevision revP : revPs) { for(TCComponentItemRevision revP:revPs) {
if(revPs.size() > 1) {//whereUsed.length if(whereUsed.length>1) {
// TCComponentItemRevision revP = (TCComponentItemRevision)whereUsed[i]; // TCComponentItemRevision revP = (TCComponentItemRevision)whereUsed[i];
String property = revP.getProperty("zt2_ifpbom"); String property = revP.getProperty("zt2_ifpbom");
if(property == null || !property.equals("P")) { if(property==null||!property.equals("P")) {
continue; continue;
}
}
TCComponentItemRevision item = getTopZzItem(revP);
if(item!=null) {
return item;
} }
} }
TCComponentItemRevision item = getTopZzItem(revP);
if(item != null) {
return item;
}
} }
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} }
return null; return null;
} }
@ -130,9 +143,9 @@ public class UpdateWorkCommand extends KCommand {
try { try {
// TCComponentItemRevision pRevision = getPRevision(rev); // TCComponentItemRevision pRevision = getPRevision(rev);
TCComponentItemRevision topZzItem = getTopZzItem(rev); TCComponentItemRevision topZzItem = getTopZzItem(rev);
String property = topZzItem==null ? "" : topZzItem.getProperty("zt2_ifpbom"); String property = topZzItem.getProperty("zt2_ifpbom");
if(!property.equals("P")) {// && topZzItem.getStringProperty("object_desc").contains("1ZDB300000P") if(!property.equals("P") && topZzItem.getStringProperty("object_desc").contains("1ZDB300000P")) {
MessageBox.post("δ½øÐÐEתP²Ù×÷", "", MessageBox.ERROR); MessageBox.post("ÇëÑ¡ÔñPBOM¶ÔÏó", "", MessageBox.ERROR);
return; return;
} }
// TCComponentItemRevision desginRev = (TCComponentItemRevision) topZzItem.getRelatedComponent("TC_Is_Represented_By"); // TCComponentItemRevision desginRev = (TCComponentItemRevision) topZzItem.getRelatedComponent("TC_Is_Represented_By");
@ -204,7 +217,7 @@ public class UpdateWorkCommand extends KCommand {
MessageBox.post("更新工序工时完成。","提示",MessageBox.INFORMATION); MessageBox.post("更新工序工时完成。","提示",MessageBox.INFORMATION);
} }
} catch (Exception e1) { } catch (Exception e1) {
// Auto-generated catch block // TODO Auto-generated catch block
e1.printStackTrace(); e1.printStackTrace();
}finally { }finally {
SqlUtil.freeAll(); SqlUtil.freeAll();

@ -1,11 +1,17 @@
package com.connor.chint.sap2.util; package com.connor.chint.sap2.util;
import java.awt.Desktop; import java.awt.Desktop;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI; import java.net.URI;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine; import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentItemRevision; import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.ui.common.RACUIUtil; import com.teamcenter.rac.ui.common.RACUIUtil;
@ -18,14 +24,14 @@ import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSData
public class BomToSapUtil { public class BomToSapUtil {
// BOM全展开, Map返回的内容是 BOM行的UID和对应的子行 // BOM全展开, Map返回的内容是 BOM行的UID和对应的子行
public static HashMap<String, ExpandPSData[]> getBomLineTreeNodeSOA(TCComponentBOMLine bomLine) { public static Map<String, ExpandPSData[]> getBomLineTreeNodeSOA(TCComponentBOMLine bomLine) {
// List<String> bomLineNodes = list; // List<String> bomLineNodes = list;
// 预定义BOM父子对map及ItemRev map // 预定义BOM父子对map及ItemRev map
HashMap<String, ExpandPSData[]> bomLineMap = new HashMap<>(); Map<String, ExpandPSData[]> bomLineMap = new HashMap();
try { try {
// TCComponentItemRevision object = bomLine.getItemRevision(); TCComponentItemRevision object = bomLine.getItemRevision();
// String object_type = object.getType(); String object_type = object.getType();
// if (!sparePartRevision.equals(object_type)) { // if (!sparePartRevision.equals(object_type)) {
// 调用SOA方法批量展开BOM // 调用SOA方法批量展开BOM
com.teamcenter.services.rac.cad._2007_01.StructureManagement structureService = com.teamcenter.services.rac.cad.StructureManagementService com.teamcenter.services.rac.cad._2007_01.StructureManagement structureService = com.teamcenter.services.rac.cad.StructureManagementService
@ -59,7 +65,7 @@ public class BomToSapUtil {
// 预定义BOM父子对map及ItemRev map // 预定义BOM父子对map及ItemRev map
List<TCComponentBOMLine> listBoms = new ArrayList<>(); List<TCComponentBOMLine> listBoms = new ArrayList<>();
try { try {
// TCComponentItemRevision object = bomLine.getItemRevision(); TCComponentItemRevision object = bomLine.getItemRevision();
// String object_type = object.getType(); // String object_type = object.getType();
com.teamcenter.services.rac.cad._2007_01.StructureManagement structureService = com.teamcenter.services.rac.cad.StructureManagementService com.teamcenter.services.rac.cad._2007_01.StructureManagement structureService = com.teamcenter.services.rac.cad.StructureManagementService
.getService(RACUIUtil.getTCSession()); .getService(RACUIUtil.getTCSession());
@ -95,10 +101,10 @@ public class BomToSapUtil {
// 预定义BOM父子对map及ItemRev map // 预定义BOM父子对map及ItemRev map
List<TCComponentItemRevision> bomLineMap = new ArrayList<TCComponentItemRevision>(); List<TCComponentItemRevision> bomLineMap = new ArrayList<TCComponentItemRevision>();
// Map<String, TCComponentItemRevision> bomLineItemRevMap = new HashMap(); Map<String, TCComponentItemRevision> bomLineItemRevMap = new HashMap();
try { try {
// TCComponentItemRevision object = bomLine.getItemRevision(); TCComponentItemRevision object = bomLine.getItemRevision();
// String object_type = object.getType(); String object_type = object.getType();
// if (!sparePartRevision.equals(object_type)) { // if (!sparePartRevision.equals(object_type)) {
// 调用SOA方法批量展开BOM // 调用SOA方法批量展开BOM
com.teamcenter.services.rac.cad._2007_01.StructureManagement structureService = com.teamcenter.services.rac.cad.StructureManagementService com.teamcenter.services.rac.cad._2007_01.StructureManagement structureService = com.teamcenter.services.rac.cad.StructureManagementService
@ -181,7 +187,7 @@ public class BomToSapUtil {
// fos.close(); // fos.close();
// System.out.println("下载完成"); // System.out.println("下载完成");
// } catch (IOException e) { // } catch (IOException e) {
// // Auto-generated catch block // // TODO Auto-generated catch block
// e.printStackTrace(); // e.printStackTrace();
// } // }
// return file.getPath(); // return file.getPath();

@ -1,14 +1,15 @@
package com.connor.chint.sap2.util; package com.connor.chint.sap2.util;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
//import org.apache.commons.lang.builder.StandardToStringStyle;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element; import org.dom4j.Element;
//import com.connor.chint.sap2.sap_zy.FlowBean; //import com.connor.chint.sap2.sap_zy.FlowBean;
@ -39,26 +40,8 @@ public class BomUtilWh {
public static final String WH_FACOTRY = "M060"; public static final String WH_FACOTRY = "M060";
public static final String PARENTTCID = "PARENTTCID"; public static final String PARENTTCID = "PARENTTCID";
public static final String PARENTWLBM = "PARENTWLBM"; public static final String PARENTWLBM = "PARENTWLBM";
public static final String ZT2_WBSNO = "zt2_WBSNo";
public static final String ZT2_MATERIALNO = "zt2_MaterialNo";
public static final String SPLIT_MSG = "/"; public static final String SPLIT_MSG = "/";
public static final String UID = "UID"; public static final String UID = "UID";
public static final String detailsSql = "insert into CHINT_BOM_TO_SAP_SUM (code,factory,\"USER\",starttime,wbsno,projectno,taskstauts"
+ ",plmresult,transfer,keymsg,sapresult,PROJECTUID,SERVERHOST,USERID) values "
+ "(?,?,?,to_date(?,'yyyy-mm-ddhh24:mi:ss')" + ",?,?,'组织完成','未处理',?,?,'未返回',?,?,?)";
// 获取传递BOM中最大的序列
public static Integer getCode() throws SQLException {
String sql = "select Tab_SendBom_Sequence.nextval as sid from dual";
ResultSet rs = SqlUtil.read(sql);
// Object objs[] = new Object[1];
int code = 0;
if (rs.next()) {
code = rs.getInt(1);
System.out.println("code:" + code);
}
SqlUtil.free();
return code;
}
/** /**
* BOMDETAILS * BOMDETAILS
@ -68,25 +51,23 @@ public class BomUtilWh {
* @param productNos * @param productNos
* @function * @function
*/ */
public static void logXmlMsg(Element interGrationList, String code, String productNos, String batchNo, public static void logXmlMsg(Document interGrationList, String code, String productNos, String batchNo,
String wbsNo, TCSession session) { String wbsNo, TCSession session) {
String strs[] = session.getPreferenceService().getStringValues(DATABASE_TC); String strs[] = session.getPreferenceService().getStringValues(DATABASE_TC);
SqlUtil.getTCDataConnection(strs); SqlUtil.getTCDataConnection(strs);
try { try {
Element rootElement = interGrationList.getRootElement();
// 物料信息 // 物料信息
Element element = interGrationList.element(WLLIST); Element element = rootElement.element(WLLIST);
@SuppressWarnings("unchecked") List<Element> elements = element.elements(WLCONTENTS);
List<Element> elements = element.elements(WLCONTENTS);
for (Element content : elements) { for (Element content : elements) {
// 记录TCid UID 物料编码 // 记录TCid UID 物料编码
Element bomContents = content.element("BOMCONTENTS"); String tcId = content.elementText(PARENTTCID);
String tcId = bomContents.elementText(PARENTTCID);
String[] split = tcId.split(SPLIT_MSG); String[] split = tcId.split(SPLIT_MSG);
String parentMantrNo = bomContents.elementText(PARENTWLBM); String parentMantrNo = content.elementText(PARENTWLBM);
String uid = bomContents.elementText(UID); String uid = content.elementText(UID);
String[] args = new String[] { code, batchNo, WH_FACOTRY, productNos, split[0], uid, parentMantrNo, wbsNo }; SqlUtil.write(logSql,
int i = SqlUtil.write(logSql, args); new String[] { code, batchNo, WH_FACOTRY, productNos, split[0], uid, parentMantrNo, wbsNo });
System.out.println("logSql:" + i);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -95,12 +76,7 @@ public class BomUtilWh {
} }
} }
private static ArrayList<String> lists2 = new ArrayList<String>(){/** private static ArrayList<String> lists2=new ArrayList<String>(){{add("PDF");add("MS WordX");add("MS ExcelX");add("MS Excel");add("MS Word");}};
*
*/
private static final long serialVersionUID = 1L;
{add("PDF");add("MS WordX");add("MS ExcelX");add("MS Excel");add("MS Word");}};
// public static String getXML(String parameters){ // public static String getXML(String parameters){
// String soapXML = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" " // String soapXML = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" "
// + "xmlns:web=\"http://webservice.core.intf.mes.xinhua.com/\"> " // + "xmlns:web=\"http://webservice.core.intf.mes.xinhua.com/\"> "
@ -127,7 +103,7 @@ public class BomUtilWh {
// System.out.println(document.toString()); // System.out.println(document.toString());
//// rootElement.si //// rootElement.si
// } catch (DocumentException e) { // } catch (DocumentException e) {
// // Auto-generated catch block // // TODO Auto-generated catch block
// e.printStackTrace(); // e.printStackTrace();
// } // }
// } // }
@ -161,7 +137,7 @@ public class BomUtilWh {
// } // }
// } // }
// } catch (TCException e) { // } catch (TCException e) {
// // Auto-generated catch block // // TODO Auto-generated catch block
// e.printStackTrace(); // e.printStackTrace();
// } // }
ls.add(dsList); ls.add(dsList);
@ -354,17 +330,17 @@ public class BomUtilWh {
// DT_PROCESSROUTE_S4_REQLISTITEMSITEM item = new DT_PROCESSROUTE_S4_REQLISTITEMSITEM(); // DT_PROCESSROUTE_S4_REQLISTITEMSITEM item = new DT_PROCESSROUTE_S4_REQLISTITEMSITEM();
String plnal = "1"; String plnal = "1";
String plnfl = String.format("%06d", index); String plnfl = String.format("%06d", index);
// String datuv = now; String datuv = now;
String vornr1 = ""; String vornr1 = "";
String vornr2 = ""; String vornr2 = "";
// boolean bx = false; boolean bx = false;
String flagt = ""; String flagt = "";
String bezfl = "";// 参考顺序 String bezfl = "";// 参考顺序
// item.setLTXA1("");//顺序描述 // item.setLTXA1("");//顺序描述
if (!bean.isMain) {// 并行 if (!bean.isMain) {// 并行
// item.setBEZFL("000000");//参考顺序 // item.setBEZFL("000000");//参考顺序
bezfl = (bean.BEZFL); bezfl = (bean.BEZFL);
// bx = true; bx = true;
flagt = ("1");// 顺序类别 flagt = ("1");// 顺序类别
// System.out.println("前驱:"+bean.flow_split); // System.out.println("前驱:"+bean.flow_split);
if (bean.flow_split != null) { if (bean.flow_split != null) {
@ -513,7 +489,7 @@ public class BomUtilWh {
// dsList2.add((TCComponentDataset)dataset); // dsList2.add((TCComponentDataset)dataset);
Element FILECONTENTS = OPGYSZFILELIST.addElement("FILECONTENTS"); Element FILECONTENTS = OPGYSZFILELIST.addElement("FILECONTENTS");
String fileId = processRuleRevision.getProperty("item_id"); String fileId = processRuleRevision.getProperty("item_id");
// String name = processRuleRevision.getProperty("object_name"); String name = processRuleRevision.getProperty("object_name");
String fileRevId = processRuleRevision.getProperty("item_revision_id"); String fileRevId = processRuleRevision.getProperty("item_revision_id");
String fileName = dataset.getProperty("object_name"); String fileName = dataset.getProperty("object_name");
String fileType = "文件"; String fileType = "文件";
@ -647,7 +623,7 @@ public class BomUtilWh {
// DT_PROCESSROUTE_S4_REQLISTITEMSITEM item = new DT_PROCESSROUTE_S4_REQLISTITEMSITEM(); // DT_PROCESSROUTE_S4_REQLISTITEMSITEM item = new DT_PROCESSROUTE_S4_REQLISTITEMSITEM();
String plnal = "1"; String plnal = "1";
String plnfl = String.format("%06d", index); String plnfl = String.format("%06d", index);
// String datuv = now; String datuv = now;
String vornr1 = ""; String vornr1 = "";
String vornr2 = ""; String vornr2 = "";
boolean bx = false; boolean bx = false;
@ -806,7 +782,7 @@ public class BomUtilWh {
// dsList2.add((TCComponentDataset)dataset); // dsList2.add((TCComponentDataset)dataset);
Element FILECONTENTS = OPGYSZFILELIST.addElement("FILECONTENTS"); Element FILECONTENTS = OPGYSZFILELIST.addElement("FILECONTENTS");
String fileId = processRuleRevision.getProperty("item_id"); String fileId = processRuleRevision.getProperty("item_id");
// String name = processRuleRevision.getProperty("object_name"); String name = processRuleRevision.getProperty("object_name");
String fileRevId = processRuleRevision.getProperty("item_revision_id"); String fileRevId = processRuleRevision.getProperty("item_revision_id");
String fileName = dataset.getProperty("object_name"); String fileName = dataset.getProperty("object_name");
String fileType = "文件"; String fileType = "文件";
@ -889,17 +865,17 @@ public class BomUtilWh {
// DT_PROCESSROUTE_S4_REQLISTITEMSITEM item = new DT_PROCESSROUTE_S4_REQLISTITEMSITEM(); // DT_PROCESSROUTE_S4_REQLISTITEMSITEM item = new DT_PROCESSROUTE_S4_REQLISTITEMSITEM();
String plnal = "1"; String plnal = "1";
String plnfl = String.format("%06d", index); String plnfl = String.format("%06d", index);
// String datuv = now; String datuv = now;
String vornr1 = ""; String vornr1 = "";
String vornr2 = ""; String vornr2 = "";
// boolean bx = false; boolean bx = false;
String flagt = ""; String flagt = "";
String bezfl = "";// 参考顺序 String bezfl = "";// 参考顺序
// item.setLTXA1("");//顺序描述 // item.setLTXA1("");//顺序描述
if (!bean.isMain) {// 并行 if (!bean.isMain) {// 并行
// item.setBEZFL("000000");//参考顺序 // item.setBEZFL("000000");//参考顺序
bezfl = (bean.BEZFL); bezfl = (bean.BEZFL);
// bx = true; bx = true;
flagt = ("1");// 顺序类别 flagt = ("1");// 顺序类别
// System.out.println("前驱:"+bean.flow_split); // System.out.println("前驱:"+bean.flow_split);
if (bean.flow_split != null) { if (bean.flow_split != null) {
@ -922,9 +898,9 @@ public class BomUtilWh {
KJJDHEAD.addElement("BEZFL").setText(bezfl); KJJDHEAD.addElement("BEZFL").setText(bezfl);
KJJDHEAD.addElement("VORNR1").setText(vornr1); KJJDHEAD.addElement("VORNR1").setText(vornr1);
KJJDHEAD.addElement("VORNR2").setText(vornr2); KJJDHEAD.addElement("VORNR2").setText(vornr2);
// int cnt = bean.flowList.size(); int cnt = bean.flowList.size();
// List<DT_PROCESSROUTE_S4_REQLISTITEMSITEMSUBITEMSSUBITEM> subItems = new ArrayList<>(); // List<DT_PROCESSROUTE_S4_REQLISTITEMSITEMSUBITEMSSUBITEM> subItems = new ArrayList<>();
// boolean inBx = bean.flow_split == null; boolean inBx = bean.flow_split == null;
TCComponentItemRevision gxRev = gxLine.getItemRevision(); TCComponentItemRevision gxRev = gxLine.getItemRevision();
String[] properties2 = gxLine.getProperties(new String[] { "zt2_ControlCode", String[] properties2 = gxLine.getProperties(new String[] { "zt2_ControlCode",
@ -997,7 +973,7 @@ public class BomUtilWh {
// DT_PROCESSROUTE_S4_REQLISTITEMSITEM item = new DT_PROCESSROUTE_S4_REQLISTITEMSITEM(); // DT_PROCESSROUTE_S4_REQLISTITEMSITEM item = new DT_PROCESSROUTE_S4_REQLISTITEMSITEM();
String plnal = "1"; String plnal = "1";
String plnfl = String.format("%06d", index); String plnfl = String.format("%06d", index);
// String datuv = now; String datuv = now;
String vornr1 = ""; String vornr1 = "";
String vornr2 = ""; String vornr2 = "";
boolean bx = false; boolean bx = false;
@ -1161,8 +1137,8 @@ public class BomUtilWh {
MATERIALNO.setText(zt2_MaterialNo); MATERIALNO.setText(zt2_MaterialNo);
PLANT.setText(groupId); PLANT.setText(groupId);
wbsList.add(wbsNo); wbsList.add(wbsNo);
} catch (Exception e) { } catch (TCException e) {
// Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
@ -1188,8 +1164,8 @@ public class BomUtilWh {
MATERIALNO.setText(zt2_MaterialNo); MATERIALNO.setText(zt2_MaterialNo);
PLANT.setText(groupId); PLANT.setText(groupId);
wbsList.add(wbsNo); wbsList.add(wbsNo);
} catch (Exception e) { } catch (TCException e) {
// Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
@ -1200,7 +1176,7 @@ public class BomUtilWh {
TCComponentItemRevision pRev, String groupName, List<String> wbsList, TCSession session, String now, TCComponentItemRevision pRev, String groupName, List<String> wbsList, TCSession session, String now,
List<TCComponentMEProcessRevision> needTCM_meops, Map<String, TCComponent> gy_meops, List<TCComponentMEProcessRevision> needTCM_meops, Map<String, TCComponent> gy_meops,
Element INTERGRATIONLIST, StringBuffer errMessage, List<TCComponentItem> cppRevision, String txtPath, Element INTERGRATIONLIST, StringBuffer errMessage, List<TCComponentItem> cppRevision, String txtPath,
Map<String, TCComponentItemRevision> material_revs, String batchNum) { Map<String, TCComponentItemRevision> material_revs) {
try { try {
String uid = pBomLine.getUid(); String uid = pBomLine.getUid();
@ -1298,8 +1274,6 @@ public class BomUtilWh {
BOMCONTENTS.addElement("QUANTITY").setText(properties[3]); BOMCONTENTS.addElement("QUANTITY").setText(properties[3]);
BOMCONTENTS.addElement("QUIT") BOMCONTENTS.addElement("QUIT")
.setText(pRev.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase()); .setText(pRev.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase());
BOMCONTENTS.addElement("UID").setText(pRev.getUid());
BOMCONTENTS.addElement("BATCHNUMBER").setText(batchNum);
Element SONLIST = BOMCONTENTS.addElement("SONLIST"); Element SONLIST = BOMCONTENTS.addElement("SONLIST");
// 获取工艺信息 BOPLIST BOPCONTENTS ()二级工序下的辅料放到子件 // 获取工艺信息 BOPLIST BOPCONTENTS ()二级工序下的辅料放到子件
String maxSeq = "10"; String maxSeq = "10";
@ -1336,7 +1310,11 @@ public class BomUtilWh {
material_revs.put(properties2[2], rev2); material_revs.put(properties2[2], rev2);
} }
expandAllBomPart(expands, line2, rev2, groupName, wbsList, session, now, needTCM_meops, gy_meops, expandAllBomPart(expands, line2, rev2, groupName, wbsList, session, now, needTCM_meops, gy_meops,
INTERGRATIONLIST, errMessage, txtPath, material_revs, batchNum); INTERGRATIONLIST, errMessage, txtPath, material_revs);
// if (!KUtil.isEmpty(zt2_materialNo)) {
// material_revs.put(zt2_materialNo, part2Rev);
// }
} }
AIFComponentContext[] meops = pRev.whereReferencedByTypeRelation(new String[] { "MEProcessRevision" }, AIFComponentContext[] meops = pRev.whereReferencedByTypeRelation(new String[] { "MEProcessRevision" },
new String[] { "IMAN_METarget" }); new String[] { "IMAN_METarget" });
@ -1349,7 +1327,7 @@ public class BomUtilWh {
} }
} catch (Exception e) { } catch (Exception e) {
// : handle exception // TODO: handle exception
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -1502,7 +1480,7 @@ public class BomUtilWh {
} }
} catch (Exception e) { } catch (Exception e) {
// : handle exception // TODO: handle exception
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -1552,7 +1530,7 @@ public class BomUtilWh {
TCComponentItemRevision pRev, String groupName, List<String> wbsList, TCSession session, String now, TCComponentItemRevision pRev, String groupName, List<String> wbsList, TCSession session, String now,
List<TCComponentMEProcessRevision> needTCM_meops, Map<String, TCComponent> gy_meops, List<TCComponentMEProcessRevision> needTCM_meops, Map<String, TCComponent> gy_meops,
Element INTERGRATIONLIST, StringBuffer errMessage, String txtPath, Element INTERGRATIONLIST, StringBuffer errMessage, String txtPath,
Map<String, TCComponentItemRevision> material_revs, String batchNum) { Map<String, TCComponentItemRevision> material_revs) {
try { try {
String uid = pBomLine.getUid(); String uid = pBomLine.getUid();
@ -1643,10 +1621,6 @@ public class BomUtilWh {
BOMCONTENTS.addElement("QUANTITY").setText(properties[3]); BOMCONTENTS.addElement("QUANTITY").setText(properties[3]);
BOMCONTENTS.addElement("QUIT") BOMCONTENTS.addElement("QUIT")
.setText(pRev.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase()); .setText(pRev.getItem().getTCProperty("zt2_unit").getStringValue().toUpperCase());
//新增字段UID和批次号
BOMCONTENTS.addElement("UID").setText(pRev.getUid());
BOMCONTENTS.addElement("BATCHNUMBER").setText(batchNum);
Element SONLIST = BOMCONTENTS.addElement("SONLIST"); Element SONLIST = BOMCONTENTS.addElement("SONLIST");
// 获取工艺信息 BOPLIST BOPCONTENTS ()二级工序下的辅料放到子件 // 获取工艺信息 BOPLIST BOPCONTENTS ()二级工序下的辅料放到子件
String maxSeq = "10"; String maxSeq = "10";
@ -1685,14 +1659,13 @@ public class BomUtilWh {
if (i == expandPSDatas.length - 1) { if (i == expandPSDatas.length - 1) {
maxSeq = line2.getProperty("bl_sequence_no"); maxSeq = line2.getProperty("bl_sequence_no");
} }
//异步接口不检查 if (rev2.getProperty("zt2_SapState").equals("ÒÑ´«"))
// if (rev2.getProperty("zt2_SapState").equals("已传")) continue;
// continue;
if (!KUtil.isEmpty(properties2[2])) { if (!KUtil.isEmpty(properties2[2])) {
material_revs.put(properties2[2], rev2); material_revs.put(properties2[2], rev2);
} }
expandAllBomPart(expands, line2, rev2, groupName, wbsList, session, now, needTCM_meops, gy_meops, expandAllBomPart(expands, line2, rev2, groupName, wbsList, session, now, needTCM_meops, gy_meops,
INTERGRATIONLIST, errMessage, txtPath, material_revs, batchNum); INTERGRATIONLIST, errMessage, txtPath, material_revs);
} }
AIFComponentContext[] meops = pRev.whereReferencedByTypeRelation(new String[] { "MEProcessRevision" }, AIFComponentContext[] meops = pRev.whereReferencedByTypeRelation(new String[] { "MEProcessRevision" },
@ -1706,7 +1679,7 @@ public class BomUtilWh {
} }
} catch (Exception e) { } catch (Exception e) {
// : handle exception // TODO: handle exception
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -1767,7 +1740,7 @@ public class BomUtilWh {
// //
} }
} catch (Exception e) { } catch (Exception e) {
// : handle exception // TODO: handle exception
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -1811,7 +1784,7 @@ public class BomUtilWh {
Element BOMCONTENTS = WLCONTENTS.addElement("BOMCONTENTS"); // BOM信息 Element BOMCONTENTS = WLCONTENTS.addElement("BOMCONTENTS"); // BOM信息
Element WLFILELIST = WLCONTENTS.addElement("WLFILELIST"); // 文件信息 Element WLFILELIST = WLCONTENTS.addElement("WLFILELIST"); // 文件信息
WLCONTENTS.addElement("BOPLIST"); // 工艺信息 Element BOPLIST = WLCONTENTS.addElement("BOPLIST"); // ¹¤ÒÕÐÅÏ¢
for (TCComponentDataset ds : list1) { for (TCComponentDataset ds : list1) {
Element FILECONTENTS = WLFILELIST.addElement("FILECONTENTS"); Element FILECONTENTS = WLFILELIST.addElement("FILECONTENTS");
@ -1933,7 +1906,7 @@ public class BomUtilWh {
} }
} catch (Exception e) { } catch (Exception e) {
// : handle exception // TODO: handle exception
e.printStackTrace(); e.printStackTrace();
} }
} }

@ -1,7 +1,5 @@
package com.connor.chint.sap2.util; package com.connor.chint.sap2.util;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -15,7 +13,7 @@ import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.ClientAnchor; import org.apache.poi.ss.usermodel.ClientAnchor;
import org.apache.poi.ss.usermodel.DateUtil; import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Sheet;
//import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFCell; import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFCellStyle; import org.apache.poi.xssf.usermodel.XSSFCellStyle;
@ -27,26 +25,21 @@ import org.apache.poi.xssf.usermodel.XSSFShape;
import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import com.spire.xls.Workbook;
import com.spire.xls.Worksheet;
import com.spire.xls.core.ICheckBox;
import com.spire.xls.core.ICheckBoxes;
public class POIUtil { public class POIUtil {
// public static void main(String[] args) { public static void main(String[] args) {
// String name = "<>'sssshsw*s\\w/?<>|s:"; String name = "<>'sssshsw*s\\w/?<>|s:";
// System.out.println("name:" + name); System.out.println("name:" + name);
// for (int i = 0; i < strs.length; i++) { for (int i = 0; i < strs.length; i++) {
// System.out.println(i + "--[" + strs[i] + "]"); System.out.println(i + "--[" + strs[i] + "]");
// int index = name.indexOf(strs[i]); int index = name.indexOf(strs[i]);
// System.out.println("index:" + index); System.out.println("index:" + index);
// if (index != -1) { if (index != -1) {
// name = name.replaceAll(strs2[i], ""); name = name.replaceAll(strs2[i], "");
// } }
// } }
// System.out.println("name:" + checkName("shsw\\wsw|sjw/|:<>?")); System.out.println("name:" + checkName("shsw\\wsw|sjw/|:<>?"));
// } }
private static String strs[] = { "\\", "/", "*", "?", "<", ">", "|", ":" }; private static String strs[] = { "\\", "/", "*", "?", "<", ">", "|", ":" };
private static String strs2[] = { "\\\\", "/", "\\*", "\\?", "<", ">", "\\|", ":" }; private static String strs2[] = { "\\\\", "/", "\\*", "\\?", "<", ">", "\\|", ":" };
@ -358,7 +351,7 @@ public class POIUtil {
for (XSSFShape shape : shapes) { for (XSSFShape shape : shapes) {
XSSFPicture pic = (XSSFPicture) shape; XSSFPicture pic = (XSSFPicture) shape;
patriarchTo.createPicture((ClientAnchor) pic.getAnchor(), patriarchTo.createPicture((ClientAnchor) pic.getAnchor(),
workbook.addPicture(pic.getPictureData().getData(), org.apache.poi.ss.usermodel.Workbook.PICTURE_TYPE_PNG)); workbook.addPicture(pic.getPictureData().getData(), Workbook.PICTURE_TYPE_PNG));
} }
} }
} }
@ -428,179 +421,4 @@ public class POIUtil {
cell.setCellStyle(style); cell.setCellStyle(style);
} }
} }
/**
* Excel
* @param sheet sheet
* @param i
* @return Excel
*/
public static XSSFRow getRow(XSSFSheet sheet, int i) {
XSSFRow row = sheet.getRow(i);
if (row == null) {
row = sheet.createRow(i);
}
return row;
}
/**
* Excel
* @param row
* @param col
* @return Excel
*/
public static XSSFCell getCell(XSSFRow row, int col) {
XSSFCell cell = row.getCell(col);
if(cell==null)
cell = row.createCell(col);
return cell;
}
/**
* Excel
* @param sheet sheet
* @param startRow
* @param endRow
* @param margin
* @param endCol
* @param copyCount
*/
public static void copyRows(XSSFSheet sheet, int startRow, int endRow, int margin, int endCol, int copyCount) {
int regionCnt = sheet.getNumMergedRegions();
CellRangeAddress region;
for (int i = startRow; i <= endRow; i++) {
XSSFRow sourceRow = null;
XSSFRow targetRow = null;
XSSFCell sourceCell = null;
XSSFCell targetCell = null;
short m;
sourceRow = getRow(sheet, i);
for (int j = 0; j < copyCount; j++) {
int space = (endRow - startRow + 1) * j + margin;
targetRow = getRow(sheet, i - startRow + space);
targetRow.setHeight(sourceRow.getHeight());
for (m = sourceRow.getFirstCellNum(); m <= endCol; m++) {
if(m < 0)
continue;
sourceCell = getCell(sourceRow, m);
targetCell = getCell(targetRow, m);
if (sourceCell != null) {
targetCell.setCellStyle(sourceCell.getCellStyle());
int cType = sourceCell.getCellType();
switch (cType) {
case XSSFCell.CELL_TYPE_STRING:
targetCell.setCellType(cType);
targetCell.setCellValue(sourceCell.getRichStringCellValue());
break;
case XSSFCell.CELL_TYPE_NUMERIC:
targetCell.setCellType(cType);
targetCell.setCellValue(sourceCell.getNumericCellValue());
break;
case XSSFCell.CELL_TYPE_FORMULA:
targetCell.setCellFormula(sourceCell.getCellFormula());
break;
case XSSFCell.CELL_TYPE_BOOLEAN:
targetCell.setCellType(cType);
targetCell.setCellValue(sourceCell.getBooleanCellValue());
break;
case XSSFCell.CELL_TYPE_ERROR:
targetCell.setCellType(cType);
targetCell.setCellValue(sourceCell.getErrorCellValue());
break;
default:
targetCell.setCellType(cType);
targetCell.setCellValue(sourceCell.getRichStringCellValue());
break;
}
}
}
}
}
for (int j = 0; j < copyCount; j++) {
int space = margin + (endRow - startRow + 1) * j - startRow;
for (int n = 0; n < regionCnt; n++) {
region = sheet.getMergedRegion(n);
if ((region.getFirstRow() >= startRow) && (region.getLastRow() <= endRow) && (region.getLastColumn() <= endCol)) {
CellRangeAddress newRegion = new CellRangeAddress(region.getFirstRow() + space, region.getLastRow() + space, region.getFirstColumn(), region.getLastColumn());
sheet.addMergedRegion(newRegion);
}
}
}
}
/**
* Excel
* @param sheet sheet
* @param startRow
* @param endRow
*/
public static void deleteRows(XSSFSheet sheet, int startRow, int endRow) {
int regionCnt = sheet.getNumMergedRegions();
CellRangeAddress region;
for (int i = regionCnt - 1; i >= 0; i--) {
region = sheet.getMergedRegion(i);
if (region.getFirstRow() >= startRow && region.getLastRow() <= endRow) {
sheet.removeMergedRegion(i);
}
}
for (int i = startRow; i <= endRow; i++) {
sheet.removeRow(POIUtil.getRow(sheet, i));
}
}
/**
* Excel
*/
public static void main(String[] args) {
System.out.println("BoxReport main");
FileInputStream input = null;
FileOutputStream fos = null;
try {
// File file = new File("Z:\\TC_install\\ZhengTai\\正式更改通知单模板 - 副本.xlsx");
// input = new FileInputStream(file);
// XSSFWorkbook workbook = new XSSFWorkbook(input);
// XSSFSheet sheet = workbook.getSheetAt(0);
// int PAGE_ITEM_CNT = 6;//每页对象数量
// int FIRST_PAGE = 28;//第二页起始行
// int PAGE_ROW_CNT = 16;//每页行数
// int ITEM_ROW_CNT = 1;//每个对象行数
// int TITLE_ROW_CNT = 6;//表头行数
// POIUtil.copyRows(sheet, 0, TITLE_ROW_CNT - 1, FIRST_PAGE, 19, 1);
// POIUtil.copyRows(sheet, FIRST_PAGE, FIRST_PAGE + PAGE_ROW_CNT - 1, FIRST_PAGE + PAGE_ROW_CNT, 19, 2);
Workbook workbook = new Workbook();
workbook.loadFromFile("Z:\\TC_install\\ZhengTai\\正式更改通知单模板 - 副本.xlsx");
Worksheet sheet = workbook.getWorksheets().get(0);
ICheckBoxes boxes = sheet.getCheckBoxes();
System.out.println("boxes:" + boxes.getCount());
ICheckBox box1 = boxes.get(0);
ICheckBox checkbox1 = boxes.addCheckBox(47, 4, 18, 80);
checkbox1.setCheckState(box1.getCheckState());
checkbox1.setText(box1.getText());
ICheckBox box2 = boxes.get(1);
ICheckBox checkbox2 = boxes.addCheckBox(47, 6, 18, 90);
checkbox2.setCheckState(box2.getCheckState());
checkbox2.setText(box2.getText());
// fos = new FileOutputStream(file);
workbook.save();//.write(fos);
System.out.println("end");
} catch (Exception e1) {
e1.printStackTrace();
}finally {
try {
if(fos != null)
fos.close();
} catch (Exception e1) {
e1.printStackTrace();
}
try {
if(input != null)
input.close();
} catch (Exception e1) {
e1.printStackTrace();
}
}
}
} }

@ -15,29 +15,27 @@ import javax.swing.JPanel;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import javax.swing.JTextArea; import javax.swing.JTextArea;
import com.teamcenter.rac.aif.AbstractAIFDialog;
public class SAPMessageUtilFram extends JFrame { public class SAPMessageUtilFram extends JFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
boolean flag = true; boolean flag = true;
private JButton b_ok; private JButton b_ok;
private JButton b_ch; private JButton b_ch;
private String label_b_ok = "È·¶¨"; private String label_b_ok = "È·¶¨";
private String label_b_cel = "È¡Ïû"; private String label_b_cel = "È¡Ïû";
private String text; private String text;
// private String title; private String title;
private JTextArea jtf; private JTextArea jtf;
// private int MaxX = 0; private int MaxX = 0;
// private int MaxY = 0; private int MaxY = 0;
private boolean isNeedCel = false; private boolean isNeedCel = false;
public SAPMessageUtilFram(String title, String text) { public SAPMessageUtilFram(String title, String text) {
// super(false); // super(false);
this.text = text; this.text = text;
// this.title = title; this.title = title;
initUI2(); initUI2();
this.setAlwaysOnTop(true); this.setAlwaysOnTop(true);
this.pack(); this.pack();
@ -47,16 +45,13 @@ public class SAPMessageUtilFram extends JFrame {
// showDialog(); // showDialog();
} }
@SuppressWarnings("deprecation")
public void show() {
super.show();
}
private void initUI2() { private void initUI2() {
jtf = new JTextArea(); jtf = new JTextArea();
JPanel panel = new JPanel(new BorderLayout()); JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); panel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
int dialog_X = 1, dialog_Y = 1;//, js_X = 1, js_Y = 1 int dialog_X = 1, dialog_Y = 1, js_X = 1, js_Y = 1;
String strs[] = text.split("\\n"); String strs[] = text.split("\\n");
int length = strs.length; int length = strs.length;
int maxX = 1; int maxX = 1;

@ -6,7 +6,6 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import java.util.Arrays;
import com.teamcenter.rac.util.Registry; import com.teamcenter.rac.util.Registry;
@ -715,9 +714,7 @@ public class SqlUtil {
public final static int update(String sql, Object[] argments) { public final static int update(String sql, Object[] argments) {
int i = -1; int i = -1;
try { try {
PreparedStatement ps = SqlUtil.getPs(argments, sql); i = SqlUtil.getPs(argments, sql).executeUpdate();
System.out.println("update:" + sql + "==" + Arrays.toString(argments));
i = ps.executeUpdate();
SqlUtil.connection.commit(); SqlUtil.connection.commit();
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();

@ -1,5 +1,6 @@
package com.connor.chint.yunpi.command; package com.connor.chint.yunpi.command;
import java.sql.Connection;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -7,30 +8,32 @@ import java.util.Map;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
//import com.connor.chint.sap2.KCommand;
import com.connor.chint.sap2.util.ChintPreferenceUtil;
import com.connor.chint.sap2.util.KUtil;
import com.connor.chint.sap2.util.MyProgressBarCompent; import com.connor.chint.sap2.util.MyProgressBarCompent;
import com.connor.chint.sap2.util.SAPMessageUtil;
import com.connor.chint.sap2.util.SAPMessageUtilFram; import com.connor.chint.sap2.util.SAPMessageUtilFram;
import com.connor.chint.sap2.util.SAPUtil; import com.connor.chint.sap2.util.SAPUtil;
import com.connor.chint.sap2.util.SqlUtil; import com.connor.chint.sap2.util.SqlUtil;
import com.connor.chint.yunpi.KCommand; import com.connor.chint.yunpi.KCommand;
import com.teamcenter.rac.aif.AbstractAIFApplication; import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponent; import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine; import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentItem; import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision; import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCPreferenceService; import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession; import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.kernel.TCUserService; import com.teamcenter.rac.kernel.TCUserService;
import com.teamcenter.rac.util.MessageBox; import com.teamcenter.rac.util.MessageBox;
@SuppressWarnings("deprecation")
public class AssignProcess extends KCommand { public class AssignProcess extends KCommand {
// private boolean top = true; private boolean top = true;
private TCComponentItemRevision rev; private TCComponentItemRevision rev;
public TCComponentItemRevision getPRevision(TCComponentItemRevision rev2) throws Exception { public TCComponentItemRevision getPRevision(TCComponentItemRevision rev2) throws TCException {
String zt2_MaterialNo = rev2.getStringProperty("zt2_MaterialNo"); String zt2_MaterialNo = rev2.getStringProperty("zt2_MaterialNo");
if(rev2.getType().equals("Part Revision")) { if(rev2.getType().equals("Part Revision")) {
@ -63,7 +66,7 @@ public class AssignProcess extends KCommand {
} }
private TCComponentItemRevision getTopZzItem(TCComponentItemRevision rev) { private TCComponentItemRevision getTopZzItem(TCComponentItemRevision rev) {
// Auto-generated method stub // TODO Auto-generated method stub
// item = null; // item = null;
try { try {
TCComponent[] whereUsed = rev.whereUsed((short)0); TCComponent[] whereUsed = rev.whereUsed((short)0);
@ -92,9 +95,10 @@ public class AssignProcess extends KCommand {
return item; return item;
} }
} }
} }
} catch (Exception e) { } catch (TCException e) {
// Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
return null; return null;
@ -121,59 +125,26 @@ public class AssignProcess extends KCommand {
new Thread() { new Thread() {
@Override @Override
public void run() { public void run() {
if(!rev.getType().equals("Part Revision")) { if(!rev.getType().equals("Part Revision")) {
MessageBox.post("请选择PBOM对象", "", MessageBox.ERROR); MessageBox.post("请选择PBOM对象", "", MessageBox.ERROR);
return; return;
} }
MyProgressBarCompent comp = null; MyProgressBarCompent comp = null;
try { try {
TCPreferenceService service = session.getPreferenceService();
// TCComponentItemRevision pRevision = getPRevision(rev); // TCComponentItemRevision pRevision = getPRevision(rev);
TCComponentItemRevision topZzItem = getTopZzItem(rev); TCComponentItemRevision topZzItem = getTopZzItem(rev);
String name = rev.getProperty("object_name");
String property = topZzItem.getProperty("zt2_ifpbom"); String property = topZzItem.getProperty("zt2_ifpbom");
if(!property.equals("P") && topZzItem.getStringProperty("object_desc").contains("1ZDB300000P")) { if(!property.equals("P") && topZzItem.getStringProperty("object_desc").contains("1ZDB300000P")) {
MessageBox.post("请选择PBOM对象", "", MessageBox.ERROR); MessageBox.post("请选择PBOM对象", "", MessageBox.ERROR);
return; return;
} }
boolean isback = false;
String[] rules = service.getStringValues("CHINT_PROCESS_RULE");
for(String rule : rules) {
String[] split = rule.split(":");
if(!split[0].equals(groupID))
continue;
String[] backs = split[1].split(";");
for(String back : backs) {
System.out.println(name + "==" + back + ">>" + name.contains(back));
if(name.contains(back)) {
isback = true;
break;
}
}
if(isback)
break;
}
TCComponentItemRevision desginRev = (TCComponentItemRevision) topZzItem.getRelatedComponent("TC_Is_Represented_By"); TCComponentItemRevision desginRev = (TCComponentItemRevision) topZzItem.getRelatedComponent("TC_Is_Represented_By");
System.out.println("topZzItem=="+topZzItem.toString()+">>"+isback); System.out.println("topZzItem==>"+topZzItem.toString());
if(isback) { if(desginRev==null) {
AIFComponentContext[] folders = topZzItem.getItem() MessageBox.post("存在顶层P物料没有关联图纸,请检查.","提示",2);
.whereReferencedByTypeRelation(new String[] { "ZT2_ProjectFolder" }, null);//new String[] { "contents" }
if(folders.length == 0) {
MessageBox.post("未找到产成品文件夹,请检查.", "提示", MessageBox.WARNING);
return;
}
AIFComponentContext[] ccps = folders[0].getComponent().getChildren();
System.out.println(folders[0].getComponent() + "==>" + ccps.length);
for(AIFComponentContext aifcc : ccps) {
TCComponentItem item = (TCComponentItem) aifcc.getComponent();
desginRev = (TCComponentItemRevision) item.getLatestItemRevision().getRelatedComponent("TC_Is_Represented_By");
System.out.println(item + "==>" + desginRev);
if(desginRev != null)
break;
}
}
if(desginRev == null) {
MessageBox.post("存在顶层P物料没有关联图纸,请检查.", "提示", MessageBox.WARNING);
return; return;
} }
Map<String, String> classificationAttributes = desginRev.getItem().getClassificationAttributes(); Map<String, String> classificationAttributes = desginRev.getItem().getClassificationAttributes();
@ -183,7 +154,7 @@ public class AssignProcess extends KCommand {
if(key.equals("产品型号")) { if(key.equals("产品型号")) {
String cphx = classificationAttributes.get(key); String cphx = classificationAttributes.get(key);
String sql = "SELECT \"ProductZu\" FROM \"CHINT_WORKHOUR_WhProductXH\" where \"ProductXH\" = '"+cphx+"'"; String sql = "SELECT \"ProductZu\" FROM \"CHINT_WORKHOUR_WhProductXH\" where \"ProductXH\" = '"+cphx+"'";
String[] prefs = service.getStringValues("database_tc"); String[] prefs = session.getPreferenceService().getStringValues("database_tc");
SqlUtil.getTCDataConnection(prefs); SqlUtil.getTCDataConnection(prefs);
ResultSet read2 = SqlUtil.read(sql); ResultSet read2 = SqlUtil.read(sql);
if(!read2.next()) { if(!read2.next()) {
@ -239,7 +210,7 @@ public class AssignProcess extends KCommand {
MessageBox.post("一键指派工艺路线完成。","提示",MessageBox.INFORMATION); MessageBox.post("一键指派工艺路线完成。","提示",MessageBox.INFORMATION);
} }
} catch (Exception e1) { } catch (Exception e1) {
// Auto-generated catch block // TODO Auto-generated catch block
e1.printStackTrace(); e1.printStackTrace();
}finally { }finally {
SqlUtil.freeAll(); SqlUtil.freeAll();

@ -21,7 +21,6 @@ import com.connor.chint.sap2.util.TXTUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication; import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFOperation; import com.teamcenter.rac.aif.AbstractAIFOperation;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponent; import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine; import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentBOMWindow; import com.teamcenter.rac.kernel.TCComponentBOMWindow;
@ -46,14 +45,14 @@ public class BomDcSapOp extends AbstractAIFOperation {
private String groupName = ""; private String groupName = "";
private TCComponentItemType ccomponentitemtype; private TCComponentItemType ccomponentitemtype;
public BomDcSapOp(AbstractAIFApplication app) { public BomDcSapOp(AbstractAIFApplication app) {
// Auto-generated constructor stub // TODO Auto-generated constructor stub
this.app = app; this.app = app;
this.session = (TCSession) app.getSession(); this.session = (TCSession) app.getSession();
now = format.format(new Date()); now = format.format(new Date());
try { try {
ccomponentitemtype = (TCComponentItemType)session.getTypeComponent("ZT2_Design3D"); ccomponentitemtype = (TCComponentItemType)session.getTypeComponent("ZT2_Design3D");
} catch (TCException e) { } catch (TCException e) {
// Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
@ -85,7 +84,7 @@ public class BomDcSapOp extends AbstractAIFOperation {
} }
} }
System.out.print("id===>"+id); System.out.print("id===>"+id);
TCComponentItem find = ccomponentitemtype.findItems(id)[0]; TCComponentItem find = ccomponentitemtype.find(id);
TCComponentItemRevision zztRev = find.getLatestItemRevision(); TCComponentItemRevision zztRev = find.getLatestItemRevision();
TCComponent[] matnrs = zztRev.getRelatedComponents("representation_for"); TCComponent[] matnrs = zztRev.getRelatedComponents("representation_for");
for(TCComponent matnr:matnrs) { for(TCComponent matnr:matnrs) {
@ -148,7 +147,7 @@ public class BomDcSapOp extends AbstractAIFOperation {
} }
@Override @Override
public void executeOperation() throws Exception { public void executeOperation() throws Exception {
// Auto-generated method stub // TODO Auto-generated method stub
MyProgressBarCompent comp = null; MyProgressBarCompent comp = null;
try { try {
groupName = SAPUtil.getGroupID(session); groupName = SAPUtil.getGroupID(session);
@ -174,22 +173,6 @@ public class BomDcSapOp extends AbstractAIFOperation {
MessageBox.post("请选择图纸/物料版本", "", MessageBox.INFORMATION); MessageBox.post("请选择图纸/物料版本", "", MessageBox.INFORMATION);
return; return;
} }
TCComponent bomRev = degignRev.getRelatedComponent("structure_revisions");
if(bomRev == null) {
MessageBox.post(AIFUtility.getActiveDesktop(), "所选对象没有BOM视图无法传递", "", MessageBox.INFORMATION);
return;
}
TCComponent[] release_status_list = degignRev.getReferenceListProperty("release_status_list");
if(release_status_list.length == 0) {
MessageBox.post(AIFUtility.getActiveDesktop(), "所选对象未发布,无法传递!", "", MessageBox.INFORMATION);
return;
}else {
release_status_list = bomRev.getReferenceListProperty("release_status_list");
if(release_status_list.length == 0) {
MessageBox.post(AIFUtility.getActiveDesktop(), "所选对象BOM视图未发布无法传递", "", MessageBox.INFORMATION);
return;
}
}
comp = new MyProgressBarCompent("", "正在进行单层BOM传递SAP...."); comp = new MyProgressBarCompent("", "正在进行单层BOM传递SAP....");
TCComponentItemRevision pRevision = getPRevision(degignRev); //获取PBOM TCComponentItemRevision pRevision = getPRevision(degignRev); //获取PBOM

@ -15,14 +15,14 @@ import com.connor.chint.sap2.util.BomToSapUtil;
import com.connor.chint.sap2.util.BomUtilWh; import com.connor.chint.sap2.util.BomUtilWh;
import com.connor.chint.sap2.util.KUtil; import com.connor.chint.sap2.util.KUtil;
import com.connor.chint.sap2.util.MyProgressBarCompent; import com.connor.chint.sap2.util.MyProgressBarCompent;
import com.connor.chint.sap2.util.SAPMessageUtil;
import com.connor.chint.sap2.util.SAPMessageUtilFram; import com.connor.chint.sap2.util.SAPMessageUtilFram;
import com.connor.chint.sap2.util.SAPUtil; import com.connor.chint.sap2.util.SAPUtil;
import com.connor.chint.sap2.util.SqlUtil;
import com.connor.chint.sap2.util.TXTUtil; import com.connor.chint.sap2.util.TXTUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication; import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFOperation; import com.teamcenter.rac.aif.AbstractAIFOperation;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.aifrcp.AIFUtility; import com.teamcenter.rac.kernel.ListOfValuesInfo;
import com.teamcenter.rac.kernel.TCComponent; import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine; import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentBOMWindow; import com.teamcenter.rac.kernel.TCComponentBOMWindow;
@ -31,6 +31,7 @@ import com.teamcenter.rac.kernel.TCComponentDataset;
import com.teamcenter.rac.kernel.TCComponentItem; import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision; import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType; import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCComponentListOfValues;
import com.teamcenter.rac.kernel.TCComponentMEProcessRevision; import com.teamcenter.rac.kernel.TCComponentMEProcessRevision;
import com.teamcenter.rac.kernel.TCComponentUser; import com.teamcenter.rac.kernel.TCComponentUser;
import com.teamcenter.rac.kernel.TCException; import com.teamcenter.rac.kernel.TCException;
@ -39,262 +40,202 @@ import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSData; import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSData;
public class BomSapWhBjOp extends AbstractAIFOperation { public class BomSapWhBjOp extends AbstractAIFOperation {
private SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd-HHmmss"); private SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd-HHmmss");
private AbstractAIFApplication app; private AbstractAIFApplication app;
private TCSession session; private TCSession session;
private SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); private SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
private String now; private String now;
private String groupName = ""; private String groupName = "";
private TCComponentItemType ccomponentitemtype; private TCComponentItemType ccomponentitemtype;
public BomSapWhBjOp(AbstractAIFApplication app) {
public BomSapWhBjOp(AbstractAIFApplication app) { // TODO Auto-generated constructor stub
// Auto-generated constructor stub this.app = app;
this.app = app; this.session = (TCSession) app.getSession();
this.session = (TCSession) app.getSession(); now = format.format(new Date());
now = format.format(new Date()); try {
try { ccomponentitemtype = (TCComponentItemType)session.getTypeComponent("ZT2_Design3D");
ccomponentitemtype = (TCComponentItemType) session.getTypeComponent("ZT2_Design3D"); } catch (TCException e) {
} catch (Exception e) { // TODO Auto-generated catch block
// Auto-generated catch block e.printStackTrace();
e.printStackTrace(); }
}
}
}
public List<TCComponentItem> getCPPPRevision(TCComponentItemRevision rev2) throws TCException {
public List<TCComponentItem> getCPPPRevision(TCComponentItemRevision rev2) throws TCException {
List<TCComponentItem> itemList = new ArrayList<>();
List<TCComponentItem> itemList = new ArrayList<>(); List<TCComponentItem> itemPList = new ArrayList<>();
List<TCComponentItem> itemPList = new ArrayList<>(); String id = "1ZDB300000P-";
String id = "1ZDB300000P-"; if(rev2.getType().equals("Part Revision")) {
if (rev2.getType().equals("Part Revision")) { String desc = rev2.getStringProperty("object_desc");
String desc = rev2.getStringProperty("object_desc"); String[] split = desc.split(" ");
String[] split = desc.split(" "); if(split.length>=2) {
if (split.length >= 2) { String[] split2 = split[1].split("-");
String[] split2 = split[1].split("-"); if(split2.length==2) {
if (split2.length == 2) { id = id + split2[1];
id = id + split2[1]; }else if(split2.length==3) {
} else if (split2.length == 3) { id = id + split2[2];
id = id + split2[2]; }
} }
} }else if(rev2.getType().equals("ZT2_Design3DRevision")) {
} else if (rev2.getType().equals("ZT2_Design3DRevision")) { String desc = rev2.getStringProperty("item_id");
String desc = rev2.getStringProperty("item_id"); String[] split2 = desc.split("-");
String[] split2 = desc.split("-"); if(split2.length==2) {
if (split2.length == 2) { id = id + split2[1];
id = id + split2[1]; }else if(split2.length==3) {
} else if (split2.length == 3) { id = id + split2[2];
id = id + split2[2]; }
} }
} System.out.print("id===>"+id);
System.out.print("id===>" + id); TCComponentItem find = ccomponentitemtype.find(id);
TCComponentItem find = ccomponentitemtype.findItems(id)[0]; TCComponentItemRevision zztRev = find.getLatestItemRevision();
TCComponentItemRevision zztRev = find.getLatestItemRevision(); TCComponent[] matnrs = zztRev.getRelatedComponents("representation_for");
TCComponent[] matnrs = zztRev.getRelatedComponents("representation_for"); for(TCComponent matnr:matnrs) {
for (TCComponent matnr : matnrs) { String[] properties = matnr.getProperties(new String[]{"zt2_ifpbom"});
String[] properties = matnr.getProperties(new String[] { "zt2_ifpbom" }); TCComponentItemRevision revItem = (TCComponentItemRevision)matnr;
TCComponentItemRevision revItem = (TCComponentItemRevision) matnr; TCComponentItem item = revItem.getItem();
TCComponentItem item = revItem.getItem(); if(properties[0].equals("P") && !itemPList.contains(item)) {
if (properties[0].equals("P") && !itemPList.contains(item)) { itemPList.add(item);
itemPList.add(item); }else if(!itemList.contains(item)){
} else if (!itemList.contains(item)) { itemList.add(item);
itemList.add(item); }
} }
} if(itemPList.size()>0) {
if (itemPList.size() > 0) { return itemPList;
return itemPList; }
} return itemList;
return itemList;
}
} public TCComponentItemRevision getPRevision(TCComponentItemRevision rev2) throws TCException {
public TCComponentItemRevision getPRevision(TCComponentItemRevision rev2) throws TCException { String zt2_MaterialNo = rev2.getStringProperty("zt2_MaterialNo");
if(rev2.getType().equals("Part Revision")) {
String zt2_MaterialNo = rev2.getStringProperty("zt2_MaterialNo"); String zt2_ifpbom = rev2.getProperty("zt2_ifpbom");
if (rev2.getType().equals("Part Revision")) { if(zt2_ifpbom.equals("P")) {
String zt2_ifpbom = rev2.getProperty("zt2_ifpbom"); return rev2;
if (zt2_ifpbom.equals("P")) { }else {
return rev2; TCComponent designRev = rev2.getRelatedComponent("TC_Is_Represented_By");
} else { if(designRev!=null) {
TCComponent designRev = rev2.getRelatedComponent("TC_Is_Represented_By"); TCComponent[] matnrs = designRev.getRelatedComponents("representation_for");
if (designRev != null) { for(TCComponent matnr:matnrs) {
TCComponent[] matnrs = designRev.getRelatedComponents("representation_for"); String[] properties = matnr.getProperties(new String[]{"zt2_ifpbom","zt2_MaterialNo"});
for (TCComponent matnr : matnrs) { if(properties[1].equals(zt2_MaterialNo) && properties[0].equals("P")) {
String[] properties = matnr.getProperties(new String[] { "zt2_ifpbom", "zt2_MaterialNo" }); return (TCComponentItemRevision)matnr;
if (properties[1].equals(zt2_MaterialNo) && properties[0].equals("P")) { }
return (TCComponentItemRevision) matnr; }
} }
} }
} }else if(rev2.getType().equals("ZT2_Design3DRevision")) {
} TCComponent[] matnrs = rev2.getRelatedComponents("representation_for");
} else if (rev2.getType().equals("ZT2_Design3DRevision")) { for(TCComponent matnr:matnrs) {
TCComponent[] matnrs = rev2.getRelatedComponents("representation_for"); String[] properties = matnr.getProperties(new String[]{"zt2_ifpbom","zt2_MaterialNo"});
for (TCComponent matnr : matnrs) { if(properties[0].equals("P")) {
String[] properties = matnr.getProperties(new String[] { "zt2_ifpbom", "zt2_MaterialNo" }); return (TCComponentItemRevision)matnr;
if (properties[0].equals("P")) { }
return (TCComponentItemRevision) matnr; }
} return (TCComponentItemRevision)matnrs[0];
} }
return (TCComponentItemRevision) matnrs[0]; return rev2;
}
return rev2;
}
public static String getXML() { }
public static String getXML(){
String soapXML = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:chintelectric.com:xi:plm\">\r\n" String soapXML = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:chintelectric.com:xi:plm\">\r\n"
+ " <soapenv:Header/>\r\n" + " <soapenv:Body>\r\n" + " <urn:MT_MATERIAL_BOP_REQ>\r\n" + " <soapenv:Header/>\r\n"
+ " </urn:MT_MATERIAL_BOP_REQ>\r\n" + " </soapenv:Body>\r\n" + "</soapenv:Envelope>"; + " <soapenv:Body>\r\n"
+ " <urn:MT_MATERIAL_BOP_REQ>\r\n"
+ " </urn:MT_MATERIAL_BOP_REQ>\r\n"
+ " </soapenv:Body>\r\n"
+ "</soapenv:Envelope>";
return soapXML; return soapXML;
} }
@Override
public void executeOperation() throws Exception {
// TODO Auto-generated method stub
MyProgressBarCompent comp = null;
try {
groupName = SAPUtil.getGroupID(session);
if (KUtil.isEmpty(groupName) || groupName.equalsIgnoreCase("dba")) {
MessageBox.post("当前登录组[" + groupName + "]不可使用该功能", "", MessageBox.INFORMATION);
return;
}
@Override InterfaceAIFComponent target = app.getTargetComponent();
public void executeOperation() throws Exception { if (target == null) {
// Auto-generated method stub MessageBox.post("请选择图纸版本", "", MessageBox.INFORMATION);
MyProgressBarCompent comp = null;
try {
String strs[] = session.getPreferenceService().getStringValues("database_tc");
if (SqlUtil.getTCDataConnection(strs) == null) {
MessageBox.post("数据库连接失败,请检查首选项<database_tc>", "", 2);
return;
}
String code = BomUtilWh.getCode().toString();
String batchNum = code + "-00001";
groupName = SAPUtil.getGroupID(session);
if (KUtil.isEmpty(groupName) || groupName.equalsIgnoreCase("dba")) {
MessageBox.post("当前登录组[" + groupName + "]不可使用该功能", "", MessageBox.INFORMATION);
return;
}
InterfaceAIFComponent target = app.getTargetComponent();
if (target == null) {
MessageBox.post("请选择图纸版本", "", MessageBox.INFORMATION);
return;
}
TCComponentItemRevision degignRev = null;
// String bmeng = "1";
if (target.getType().equals("ZT2_Design3DRevision")) {
degignRev = (TCComponentItemRevision) target;
} else if (target.getType().equals("Part Revision")) {
degignRev = (TCComponentItemRevision) target;
// bmeng = SAPUtil.getSAPBMENG(degignRev);
} else {
MessageBox.post("请选择图纸/物料版本", "", MessageBox.INFORMATION);
return;
}
TCComponent bomRev = degignRev.getRelatedComponent("structure_revisions");
if(bomRev == null) {
MessageBox.post(AIFUtility.getActiveDesktop(), "所选对象没有BOM视图无法传递", "", MessageBox.INFORMATION);
return; return;
} }
TCComponent[] release_status_list = degignRev.getReferenceListProperty("release_status_list"); TCComponentItemRevision degignRev = null;
if(release_status_list.length == 0) { // String bmeng = "1";
MessageBox.post(AIFUtility.getActiveDesktop(), "所选对象未发布,无法传递!", "", MessageBox.INFORMATION); if (target.getType().equals("ZT2_Design3DRevision")) {
degignRev = (TCComponentItemRevision) target;
} else if (target.getType().equals("Part Revision")) {
degignRev = (TCComponentItemRevision) target;
// bmeng = SAPUtil.getSAPBMENG(degignRev);
} else {
MessageBox.post("请选择图纸/物料版本", "", MessageBox.INFORMATION);
return; return;
}else {
release_status_list = bomRev.getReferenceListProperty("release_status_list");
if(release_status_list.length == 0) {
MessageBox.post(AIFUtility.getActiveDesktop(), "所选对象BOM视图未发布无法传递", "", MessageBox.INFORMATION);
return;
}
} }
comp = new MyProgressBarCompent("", "正在进行部件BOM传递SAP...."); comp = new MyProgressBarCompent("", "正在进行部件BOM传递SAP....");
TCComponentItemRevision pRevision = getPRevision(degignRev); // 获取PBOM TCComponentItemRevision pRevision = getPRevision(degignRev); //获取PBOM
List<TCComponentItem> cppRevision = getCPPPRevision(degignRev); List<TCComponentItem> cppRevision = getCPPPRevision(degignRev);
// 获取产成品 //获取产成品
System.out.println("cppRevision===>" + cppRevision.toString()); System.out.println("cppRevision===>"+cppRevision.toString());
List<String> wbsList = new ArrayList<String>();
//记录SUM表信息
String userName = session.getUser().getProperty("user_name"); StringBuffer errMessage = new StringBuffer("");
String dataTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
// String zt2_WBSNo = project.getStringProperty("zt2_WBSNo"); BomUtilWh.checkMatnr(errMessage, pRevision);
// String object_name = project.getStringProperty("object_name");
String userId = session.getUser().getUserId(); TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
// String code = BomUtilWh.getCode().toString(); TCComponentBOMWindow win = bomWinType.create(null);
StringBuilder productNosBuild = new StringBuilder(""); TCComponentBOMLine setWindowTopLine = win.setWindowTopLine(pRevision.getItem(), pRevision, null, null);
StringBuilder productUidsBuild = new StringBuilder(""); //优化项BOM全展开
for(TCComponentItem cppItem:cppRevision) { System.out.println("BOM全展开");
TCComponentItemRevision latestItemRevision = cppItem.getLatestItemRevision(); Map<String, TCComponent> gy_meops = new HashMap<>(32);
String property = latestItemRevision.getProperty(BomUtilWh.ZT2_MATERIALNO);
productNosBuild.append(property).append(";"); String txtName = format2.format(new Date()) + getUserName(session);
productUidsBuild.append(latestItemRevision.getUid()).append(";"); String txtPath = TXTUtil.createTxt(txtName);
}
String substring = productUidsBuild.toString().substring(0, productUidsBuild.length() - 1); Document document = DocumentHelper.parseText(getXML());
String serverHostname = session.getServerHostname(); Element rootElement = document.getRootElement();
String wbsNo = cppRevision.get(0).getLatestItemRevision().getProperty(BomUtilWh.ZT2_WBSNO); Element body = rootElement.element("Body");
SqlUtil.write(BomUtilWh.detailsSql, new String[] { code, "M060", userName, dataTime, wbsNo, Element element = body.element("MT_MATERIAL_BOP_REQ");
"", "部件", substring, "", serverHostname, userId }); Element INTERGRATIONLIST = element.addElement("INTERGRATIONLIST");
Map<String, ExpandPSData[]> bomLineTree = BomToSapUtil.getBomLineTreeNodeSOA(setWindowTopLine);
SqlUtil.freeAll(); List<TCComponentMEProcessRevision> needTCM_meops = new ArrayList<TCComponentMEProcessRevision>();
List<String> wbsList = new ArrayList<String>(); Map<String, TCComponentItemRevision> material_revs = new HashMap<>();
BomUtilWh.expandAllBomPartBj(bomLineTree, setWindowTopLine, pRevision,
StringBuffer errMessage = new StringBuffer(""); groupName,wbsList,session,now,needTCM_meops,gy_meops,INTERGRATIONLIST,errMessage,cppRevision,txtPath,material_revs);
System.out.println("BOM全document===>"+document.asXML());
BomUtilWh.checkMatnr(errMessage, pRevision); if(errMessage.length()>0) {
TXTUtil.writeTXT(txtPath, "----------------BOM异常--------------");
TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); TXTUtil.writeTXT(txtPath, errMessage.toString());
TCComponentBOMWindow win = bomWinType.create(null); TXTUtil.writeTXT(txtPath, "----------BOM信息-----------");
TCComponentBOMLine setWindowTopLine = win.setWindowTopLine(pRevision.getItem(), pRevision, null, null); new SAPMessageUtilFram("", "BOM传递SAP异常:\n" + errMessage.toString()).show();
// 优化项BOM全展开 win.close();
System.out.println("BOM全展开"); }else {
Map<String, TCComponent> gy_meops = new HashMap<>(32); new BomSendSapOp(session,document.asXML(),txtPath,gy_meops).executeOperation();
win.close();
String txtName = format2.format(new Date()) + getUserName(session); }
String txtPath = TXTUtil.createTxt(txtName); if (comp != null) {
comp.setVisible(false);
Document document = DocumentHelper.parseText(getXML()); }
Element rootElement = document.getRootElement(); TCComponentDataset dataset = TXTUtil.createDataset(txtPath, txtName, session);
Element body = rootElement.element("Body"); System.out.println("日志所挂对象:" + pRevision);
Element element = body.element("MT_MATERIAL_BOP_REQ"); KUtil.setByPass(true);
Element INTERGRATIONLIST = element.addElement("INTERGRATIONLIST"); TXTUtil.addTxttoTarget(pRevision, dataset);
Map<String, ExpandPSData[]> bomLineTree = BomToSapUtil.getBomLineTreeNodeSOA(setWindowTopLine); MessageBox.post("BOM数据推送完成..","提示",2);
List<TCComponentMEProcessRevision> needTCM_meops = new ArrayList<TCComponentMEProcessRevision>(); } catch (Exception e) {
Map<String, TCComponentItemRevision> material_revs = new HashMap<>(); e.printStackTrace();
BomUtilWh.expandAllBomPartBj(bomLineTree, setWindowTopLine, pRevision, groupName, wbsList, session, now, } finally {
needTCM_meops, gy_meops, INTERGRATIONLIST, errMessage, cppRevision, txtPath, material_revs, batchNum); KUtil.setByPass(false);
System.out.println("BOM全document===>" + document.asXML()); }
if (errMessage.length() > 0) { }
TXTUtil.writeTXT(txtPath, "----------------BOM异常--------------"); public String getUserName(TCSession session) throws TCException {
TXTUtil.writeTXT(txtPath, errMessage.toString()); TCComponentUser user = session.getUser();
TXTUtil.writeTXT(txtPath, "----------BOM信息-----------"); session.getUserName();
// BomUtilWh.logXmlMsg(INTERGRATIONLIST, code, productNosBuild.toString(), batchNum, pRevision.getProperty(BomUtilWh.ZT2_WBSNO), session); return user.getTCProperty("user_name").getDisplayValue();
new SAPMessageUtilFram("", "BOM传递SAP异常:\n" + errMessage.toString()).show(); }
win.close();
} else {
//记录产成品的物料编码
// StringBuilder productNosBuild = new StringBuilder("");
// for(TCComponentItem cppItem:cppRevision) {
// String property = cppItem.getLatestItemRevision().getProperty(BomUtilWh.ZT2_MATERIALNO);
// productNosBuild.append(property).append(";");
// }
BomUtilWh.logXmlMsg(INTERGRATIONLIST, code, productNosBuild.toString(), batchNum, wbsNo, session);
new BomSendSapOp(session, document.asXML(), txtPath, gy_meops).executeOperation();
win.close();
}
if (comp != null) {
comp.setVisible(false);
}
TCComponentDataset dataset = TXTUtil.createDataset(txtPath, txtName, session);
System.out.println("日志所挂对象:" + pRevision);
KUtil.setByPass(true);
TXTUtil.addTxttoTarget(pRevision, dataset);
MessageBox.post("BOM数据推送完成..", "提示", 2);
} catch (Exception e) {
e.printStackTrace();
} finally {
KUtil.setByPass(false);
SqlUtil.freeAll();
}
}
public String getUserName(TCSession session) throws TCException {
TCComponentUser user = session.getUser();
session.getUserName();
return user.getTCProperty("user_name").getDisplayValue();
}
} }

@ -1,7 +1,19 @@
package com.connor.chint.yunpi.command; package com.connor.chint.yunpi.command;
import java.util.ArrayList;
import java.util.List;
import com.chint.plm.createKjBom.CBean;
import com.chint.plm.createKjBom.KjBean;
import com.chint.plm.createKjBom.KjBomDialog;
//import com.connor.chint.sap2.KCommand;
import com.connor.chint.sap2.util.ChintPreferenceUtil;
import com.connor.chint.sap2.util.SAPUtil;
import com.connor.chint.yunpi.KCommand; import com.connor.chint.yunpi.KCommand;
import com.teamcenter.rac.aif.AbstractAIFApplication; import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCSession;
public class BomSapWhCommand extends KCommand { public class BomSapWhCommand extends KCommand {

@ -18,6 +18,7 @@ import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils; import org.apache.http.util.EntityUtils;
import org.dom4j.Document; import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper; import org.dom4j.DocumentHelper;
import org.dom4j.Element; import org.dom4j.Element;
@ -30,7 +31,7 @@ import com.connor.chint.sap2.util.BomUtilWh;
import com.connor.chint.sap2.util.KUtil; import com.connor.chint.sap2.util.KUtil;
import com.connor.chint.sap2.util.MyProgressBarCompent; import com.connor.chint.sap2.util.MyProgressBarCompent;
import com.connor.chint.sap2.util.SAPMessageUtil; import com.connor.chint.sap2.util.SAPMessageUtil;
import com.connor.chint.sap2.util.SqlUtil; import com.connor.chint.sap2.util.SAPUtil;
import com.connor.chint.sap2.util.TXTUtil; import com.connor.chint.sap2.util.TXTUtil;
import com.squareup.okhttp.Credentials; import com.squareup.okhttp.Credentials;
import com.squareup.okhttp.MediaType; import com.squareup.okhttp.MediaType;
@ -39,6 +40,7 @@ import com.squareup.okhttp.Request;
import com.squareup.okhttp.RequestBody; import com.squareup.okhttp.RequestBody;
import com.squareup.okhttp.Response; import com.squareup.okhttp.Response;
import com.teamcenter.rac.aif.AbstractAIFApplication; import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.ListOfValuesInfo; import com.teamcenter.rac.kernel.ListOfValuesInfo;
import com.teamcenter.rac.kernel.TCComponent; import com.teamcenter.rac.kernel.TCComponent;
@ -46,7 +48,10 @@ import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentBOMWindow; import com.teamcenter.rac.kernel.TCComponentBOMWindow;
import com.teamcenter.rac.kernel.TCComponentBOMWindowType; import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
import com.teamcenter.rac.kernel.TCComponentDataset; import com.teamcenter.rac.kernel.TCComponentDataset;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision; import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCComponentListOfValues; import com.teamcenter.rac.kernel.TCComponentListOfValues;
import com.teamcenter.rac.kernel.TCComponentMEProcessRevision; import com.teamcenter.rac.kernel.TCComponentMEProcessRevision;
import com.teamcenter.rac.kernel.TCComponentReleaseStatusType; import com.teamcenter.rac.kernel.TCComponentReleaseStatusType;
@ -58,413 +63,374 @@ import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSData
public class BomSendSapController { public class BomSendSapController {
public static final String TYPE_REV_PART = "Part Revision"; public static final String TYPE_REV_PART = "Part Revision";
public TCComponent project; // 项目信息 public TCComponent project; //项目信息
public String groupName; public String groupName;
public String zt2_ProjectNo; public String zt2_ProjectNo;
public String wbs; public String wbs;
public AbstractAIFApplication app; public AbstractAIFApplication app;
private TCSession session; private TCSession session;
public List<PartBean> partList = new ArrayList<>(); public List<PartBean> partList = new ArrayList<>();
public BomSendSapWhFram dialog; public BomSendSapWhFram dialog;
private SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd-HHmmss"); private SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd-HHmmss");
public BomSendSapController(BomSendSapWhFram sapzyDialog, AbstractAIFApplication app) {
public BomSendSapController(BomSendSapWhFram sapzyDialog, AbstractAIFApplication app) { this.app = app;
this.app = app; this.session = (TCSession) app.getSession();
this.session = (TCSession) app.getSession(); }
}
// 检查选定项目下是否存在产成品
// 检查选定项目下是否存在产成品 public boolean checkTargets() throws Exception {
public boolean checkTargets() throws Exception { InterfaceAIFComponent target = app.getTargetComponent();
InterfaceAIFComponent target = app.getTargetComponent(); if (target == null || !(target instanceof TCComponent)) {
if (target == null || !(target instanceof TCComponent)) { return false;
return false; }
} project = (TCComponent) target;
project = (TCComponent) target;
zt2_ProjectNo = project.getProperty("zt2_ProjectNo");
zt2_ProjectNo = project.getProperty("zt2_ProjectNo"); wbs = project.getProperty("zt2_WBSNo");
wbs = project.getProperty("zt2_WBSNo"); System.out.println("检查对象:" + target);
System.out.println("检查对象:" + target); List<TCComponentItemRevision> partRevList = KUtil.getCCPFromProject(project);
List<TCComponentItemRevision> partRevList = KUtil.getCCPFromProject(project);
for(TCComponentItemRevision rev:partRevList) {
for (TCComponentItemRevision rev : partRevList) { String cType = rev.getType();
String cType = rev.getType();
// System.out.println(">> 找到子对象:" + cName + "|" + cType); // System.out.println(">> 找到子对象:" + cName + "|" + cType);
if (TYPE_REV_PART.equals(cType)) { if (TYPE_REV_PART.equals(cType)) {
PartBean bean = new PartBean(rev, partList.size() + 1, ""); PartBean bean = new PartBean(rev, partList.size() + 1,"");
SAPPushBOMBean.readUser(bean, rev, groupName, session); SAPPushBOMBean.readUser(bean, rev, groupName, session);
bean.setPSPID(project.getProperty("zt2_ProjectNo")); bean.setPSPID(project.getProperty("zt2_ProjectNo"));
partList.add(bean); partList.add(bean);
} }
} }
if (partList.size() == 0) { if (partList.size() == 0) {
return false; return false;
} }
return true; return true;
} }
public String sapState = ""; public String sapState = "";
private TCComponent released_Red; private TCComponent released_Red;
private TCComponent released_Yellow; private TCComponent released_Yellow;
private TCComponent released_Green; private TCComponent released_Green;
@SuppressWarnings("deprecation")
public void getSapState() throws TCException { public void getSapState() throws TCException {
TCComponentListOfValues unitLov = KUtil.getLov(session, "zt2_SapState"); TCComponentListOfValues unitLov = KUtil.getLov(session, "zt2_SapState");
if (unitLov != null) { if (unitLov != null) {
ListOfValuesInfo listOfValues = unitLov.getListOfValues(); ListOfValuesInfo listOfValues = unitLov.getListOfValues();
String[] realval = listOfValues.getStringListOfValues(); String[] realval = listOfValues.getStringListOfValues();
for (int i = 0; i < realval.length; i++) { for (int i = 0; i < realval.length; i++) {
String disval = listOfValues.getDisplayableValue(realval[i]); String disval = listOfValues.getDisplayableValue(realval[i]);
System.out.println("显示值:" + disval + ";真实值:" + realval[i]); System.out.println("显示值:" + disval + ";真实值:" + realval[i]);
if (disval.equals("已传")) { if (disval.equals("已传")) {
sapState = realval[i]; sapState = realval[i];
} }
} }
} }
TCComponentReleaseStatusType releaseType = (TCComponentReleaseStatusType) session TCComponentReleaseStatusType releaseType = (TCComponentReleaseStatusType) session
.getTypeComponent("ReleaseStatus"); .getTypeComponent("ReleaseStatus");
released_Green = releaseType.create("ZT2_Green"); released_Green = releaseType.create("ZT2_Green");
released_Green.save(); released_Green.save();
released_Green.unlock(); released_Green.unlock();
released_Red = releaseType.create("ZT2_Red"); released_Red = releaseType.create("ZT2_Red");
released_Red.save(); released_Red.save();
released_Red.unlock(); released_Red.unlock();
released_Yellow = releaseType.create("ZT2_Yellow"); released_Yellow = releaseType.create("ZT2_Yellow");
released_Yellow.save(); released_Yellow.save();
released_Yellow.unlock(); released_Yellow.unlock();
} }
private SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
private SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
public static String getXML(){
public static String getXML() {
String soapXML = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:chintelectric.com:xi:plm\">\r\n" String soapXML = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:chintelectric.com:xi:plm\">\r\n"
+ " <soapenv:Header/>\r\n" + " <soapenv:Body>\r\n" + " <urn:MT_MATERIAL_BOP_REQ>\r\n" + " <soapenv:Header/>\r\n"
+ " </urn:MT_MATERIAL_BOP_REQ>\r\n" + " </soapenv:Body>\r\n" + "</soapenv:Envelope>"; + " <soapenv:Body>\r\n"
+ " <urn:MT_MATERIAL_BOP_REQ>\r\n"
+ " </urn:MT_MATERIAL_BOP_REQ>\r\n"
+ " </soapenv:Body>\r\n"
+ "</soapenv:Envelope>";
return soapXML; return soapXML;
} }
public TCComponentItemRevision getPRevision(TCComponentItemRevision rev2) throws TCException {
public TCComponentItemRevision getPRevision(TCComponentItemRevision rev2) throws TCException {
String zt2_MaterialNo = rev2.getStringProperty("zt2_MaterialNo");
String zt2_MaterialNo = rev2.getStringProperty("zt2_MaterialNo"); if(rev2.getType().equals("Part Revision")) {
if (rev2.getType().equals("Part Revision")) { String zt2_ifpbom = rev2.getProperty("zt2_ifpbom");
String zt2_ifpbom = rev2.getProperty("zt2_ifpbom"); if(zt2_ifpbom.equals("P")) {
if (zt2_ifpbom.equals("P")) { return rev2;
return rev2; }else {
} else { TCComponent designRev = rev2.getRelatedComponent("TC_Is_Represented_By");
TCComponent designRev = rev2.getRelatedComponent("TC_Is_Represented_By"); if(designRev!=null) {
if (designRev != null) { TCComponent[] matnrs = designRev.getRelatedComponents("representation_for");
TCComponent[] matnrs = designRev.getRelatedComponents("representation_for"); for(TCComponent matnr:matnrs) {
for (TCComponent matnr : matnrs) { String[] properties = matnr.getProperties(new String[]{"zt2_ifpbom","zt2_MaterialNo"});
String[] properties = matnr.getProperties(new String[] { "zt2_ifpbom", "zt2_MaterialNo" }); if(properties[1].equals(zt2_MaterialNo) && properties[0].equals("P")) {
if (properties[1].equals(zt2_MaterialNo) && properties[0].equals("P")) { return (TCComponentItemRevision)matnr;
return (TCComponentItemRevision) matnr; }
} }
} }
} }
} }
} return rev2;
return rev2;
}
} public String getUserName(TCSession session) throws TCException {
TCComponentUser user = session.getUser();
public String getUserName(TCSession session) throws TCException { session.getUserName();
TCComponentUser user = session.getUser(); return user.getTCProperty("user_name").getDisplayValue();
session.getUserName(); }
return user.getTCProperty("user_name").getDisplayValue(); public void sendSap() {
} try {
List<PartBean> selectedParts = getSelectedParts();
public void sendSap() { String now = format.format(new Date());
try { MyProgressBarCompent comp = null;
// try {
String strs[] = session.getPreferenceService().getStringValues("database_tc"); String txtName = format2.format(new Date()) + getUserName(session);
if (SqlUtil.getTCDataConnection(strs) == null) { String txtPath = TXTUtil.createTxt(txtName);
MessageBox.post("数据库连接失败,请检查首选项<database_tc>", "", 2); comp = new MyProgressBarCompent("", "正在进行项目BOM传递......");
return; StringBuffer errMessageAll = new StringBuffer("");
} StringBuffer sendMessageAll = new StringBuffer("");
List<PartBean> selectedParts = getSelectedParts();
// 记录SUM表信息 //2024 1 22新增逻辑往CHINT_BOM_TO_SAP_SUM
String userName = session.getUser().getProperty("user_name"); project.getProperty("zt2_WBSNo");
String dataTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); //产成品BOM组织时除了产成品不同其他相同 BOM结构是一样的
String zt2_WBSNo = project.getStringProperty("zt2_WBSNo"); for(PartBean bean : selectedParts) {
String object_name = project.getStringProperty("object_name");
String userId = session.getUser().getUserId(); Document document = DocumentHelper.parseText(getXML());
String code = BomUtilWh.getCode().toString(); Element rootElement = document.getRootElement();
StringBuilder productUidsBuild = new StringBuilder(""); Element body = rootElement.element("Body");
for (PartBean cppItem : selectedParts) { Element element = body.element("MT_MATERIAL_BOP_REQ");
productUidsBuild.append(cppItem.part.getUid()).append(";"); Element INTERGRATIONLIST = element.addElement("INTERGRATIONLIST");
}
String substring = productUidsBuild.toString().substring(0, productUidsBuild.length() - 1); TCComponentItemRevision rev2 = getPRevision(bean.part);
String serverHostname = session.getServerHostname();
SqlUtil.write(BomUtilWh.detailsSql, new String[] { code, "M060", userName, dataTime, zt2_WBSNo, object_name, StringBuffer errMessage = new StringBuffer("");
"产成品", substring, project.getUid(), serverHostname, userId });
SqlUtil.freeAll();
// 存在多个产成品时 下面的PBOM是一样的只需要记录一次日志新的
// boolean flag = true;
String batchNum = code + "-00001";
String now = format.format(new Date());
MyProgressBarCompent comp = null;
String txtName = format2.format(new Date()) + getUserName(session);
String txtPath = TXTUtil.createTxt(txtName);
comp = new MyProgressBarCompent("", "正在进行项目BOM传递......");
StringBuffer errMessageAll = new StringBuffer("");
StringBuffer sendMessageAll = new StringBuffer("");
// 2024 1 22新增逻辑往CHINT_BOM_TO_SAP_SUM
// project.getProperty("zt2_WBSNo");
// 产成品BOM组织时除了产成品不同其他相同 BOM结构是一样的
// 记录产成品的物料编码
StringBuilder productNosBuild = new StringBuilder("");
Element interLogElem = null;
for (PartBean bean : selectedParts) {
Document document = DocumentHelper.parseText(getXML());
Element rootElement = document.getRootElement();
Element body = rootElement.element("Body");
Element element = body.element("MT_MATERIAL_BOP_REQ");
Element INTERGRATIONLIST = element.addElement("INTERGRATIONLIST");
TCComponentItemRevision rev2 = getPRevision(bean.part);
StringBuffer errMessage = new StringBuffer("");
// BomUtilWh.checkMatnr(errMessage, rev2); // BomUtilWh.checkMatnr(errMessage, rev2);
TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
TCComponentBOMWindow win = bomWinType.create(null); TCComponentBOMWindow win = bomWinType.create(null);
TCComponentBOMLine setWindowTopLine = win.setWindowTopLine(rev2.getItem(), rev2, null, null); TCComponentBOMLine setWindowTopLine = win.setWindowTopLine(rev2.getItem(), rev2, null, null);
// 优化项BOM全展开 //优化项BOM全展开
System.out.println("BOM全展开"); System.out.println("BOM全展开");
Map<String, TCComponent> gy_meops = new HashMap<>(32); Map<String, TCComponent> gy_meops = new HashMap<>(32);
List<TCComponentMEProcessRevision> needTCM_meops = new ArrayList<TCComponentMEProcessRevision>(); List<TCComponentMEProcessRevision> needTCM_meops = new ArrayList<TCComponentMEProcessRevision>();
// 三种情况有PBOM传PDBOM没PBOM传EBOM没EBOM传图纸BOM //三种情况有PBOM传PDBOM没PBOM传EBOM没EBOM传图纸BOM
Map<String, ExpandPSData[]> bomLineTree = BomToSapUtil.getBomLineTreeNodeSOA(setWindowTopLine); Map<String, ExpandPSData[]> bomLineTree = BomToSapUtil.getBomLineTreeNodeSOA(setWindowTopLine);
List<String> wbsList = new ArrayList<String>(); List<String> wbsList = new ArrayList<String>();
// 记录物料图纸关系的集合 // 记录物料图纸关系的集合
Map<String, TCComponentItemRevision> material_revs = new HashMap<>(); Map<String, TCComponentItemRevision> material_revs = new HashMap<>();
// 2024 1 24 新加字段 UID 和 BATCHNUMBER BomUtilWh.expandAllBomPart(bomLineTree, setWindowTopLine, rev2,
BomUtilWh.expandAllBomPart(bomLineTree, setWindowTopLine, rev2, groupName, wbsList, session, now, groupName,wbsList,session,now,needTCM_meops,gy_meops,INTERGRATIONLIST,errMessage,txtPath,material_revs);
needTCM_meops, gy_meops, INTERGRATIONLIST, errMessage, txtPath, material_revs, batchNum); System.out.println("BOM全document===>"+document.asXML());
System.out.println("BOM全document===>" + document.asXML()); if(errMessage.length()>0) {
if (errMessage.length() > 0) { TXTUtil.writeTXT(txtPath, "----------------BOM异常--------------");
TXTUtil.writeTXT(txtPath, "----------------BOM异常--------------"); TXTUtil.writeTXT(txtPath, errMessage.toString());
TXTUtil.writeTXT(txtPath, errMessage.toString()); TXTUtil.writeTXT(txtPath, "----------BOM信息-----------");
TXTUtil.writeTXT(txtPath, "----------BOM信息-----------"); errMessageAll.append(errMessage);
errMessageAll.append(errMessage);
// new SAPMessageUtil("", "BOM传递SAP异常:\n" + errMessage.toString()); // new SAPMessageUtil("", "BOM传递SAP异常:\n" + errMessage.toString());
win.close(); win.close();
} else { }else {
// new BomSendSapOp(session,document.asXML(),txtPath,gy_meops).executeOperation(); // new BomSendSapOp(session,document.asXML(),txtPath,gy_meops).executeOperation();
// 记录XML信息到CHINT_BOM_TO_SAP_DETIALS //记录XML信息到CHINT_BOM_TO_SAP_DETIALS
interLogElem = INTERGRATIONLIST;
String property = bean.part.getProperty(BomUtilWh.ZT2_MATERIALNO); sendMessageAll.append(SendToSap(txtPath,document.asXML()));
productNosBuild.append(property).append(";"); win.close();
sendMessageAll.append(SendToSap(txtPath, document.asXML())); }
win.close(); TCComponentDataset dataset = TXTUtil.createDataset(txtPath, txtName, session);
} System.out.println("日志所挂对象:" + rev2);
TCComponentDataset dataset = TXTUtil.createDataset(txtPath, txtName, session); KUtil.setByPass(true);
System.out.println("日志所挂对象:" + rev2); TXTUtil.addTxttoTarget(rev2, dataset);
KUtil.setByPass(true); KUtil.setByPass(false);
TXTUtil.addTxttoTarget(rev2, dataset); }
KUtil.setByPass(false); if(comp!=null) {
} comp.setVisible(false);
System.out.println("productNosBuild MSG====>" + productNosBuild); }
if (interLogElem != null) { if(errMessageAll.length()>0) {
// flag = false; new SAPMessageUtil("", "BOM传递SAP异常:\n" + errMessageAll.toString());
BomUtilWh.logXmlMsg(interLogElem, code, productNosBuild.toString(), batchNum, wbs, session); }else if(sendMessageAll.length()>0) {
} new SAPMessageUtil("", "BOM推送异常:\n" + sendMessageAll.toString());
if (comp != null) { }else {
comp.setVisible(false); MessageBox.post("BOM数据推送完成..","提示",2);
} }
if (errMessageAll.length() > 0) { } catch (Exception e) {
new SAPMessageUtil("", "BOM传递SAP异常:\n" + errMessageAll.toString()); // TODO Auto-generated catch block
} else if (sendMessageAll.length() > 0) { e.printStackTrace();
new SAPMessageUtil("", "BOM推送异常:\n" + sendMessageAll.toString()); }
} else {
MessageBox.post("BOM数据推送完成..", "提示", 2); }
}
} catch (Exception e) { public List<PartBean> getSelectedParts() throws Exception {
// Auto-generated catch block List<PartBean> selectedParts = new ArrayList<>();
e.printStackTrace(); int rowCnt = dialog.t_part.getRowCount();
} finally { for (int i = 0; i < rowCnt; i++) {
SqlUtil.freeAll(); System.out.println(dialog.t_part.getValueAt(i, 0));
} if ("true".equals(dialog.t_part.getValueAt(i, 0).toString())) {
PartBean bean = (PartBean) dialog.t_part.getValueAt(i, 5);
} System.out.println("准备传递对象:" + bean);
if (bean != null) {
public List<PartBean> getSelectedParts() throws Exception { /*
List<PartBean> selectedParts = new ArrayList<>(); * if(bean.factoryNo==null) { throw new Exception("对象<"+bean.part+">没有找到出厂编号");
int rowCnt = dialog.t_part.getRowCount(); * }
for (int i = 0; i < rowCnt; i++) { */
System.out.println(dialog.t_part.getValueAt(i, 0)); selectedParts.add(bean);
if ("true".equals(dialog.t_part.getValueAt(i, 0).toString())) { }
PartBean bean = (PartBean) dialog.t_part.getValueAt(i, 5); }
System.out.println("准备传递对象:" + bean); }
if (bean != null) { return selectedParts;
/* }
* if(bean.factoryNo==null) { throw new Exception("对象<"+bean.part+">没有找到出厂编号");
* } public StringBuffer SendToSap(String txtPath,String wsdlString) throws IOException {
*/
selectedParts.add(bean);
}
}
}
return selectedParts;
}
public StringBuffer SendToSap(String txtPath, String wsdlString) throws IOException {
// new BomSendSapOp(session,document.asXML(),txtPath,gy_meops).executeOperation(); // new BomSendSapOp(session,document.asXML(),txtPath,gy_meops).executeOperation();
TXTUtil.writeTXT(txtPath, "----------------BOM传递数据--------------"); TXTUtil.writeTXT(txtPath, "----------------BOM传递数据--------------");
TXTUtil.writeTXT(txtPath, wsdlString); TXTUtil.writeTXT(txtPath, wsdlString);
TXTUtil.writeTXT(txtPath, "----------BOM传递数据-----------"); TXTUtil.writeTXT(txtPath, "----------BOM传递数据-----------");
// 推送SAP //推送SAP
String[] stringValues = session.getPreferenceService().getStringValues("CHINT_WhBomUrl_YB"); String[] stringValues = session.getPreferenceService().getStringValues("CHINT_WhBomUrl");
String sapUrl = ""; String sapUrl = "";
String momUrl = ""; String momUrl = "";
for (String stringValue : stringValues) { for(String stringValue:stringValues) {
if (stringValue.startsWith("SAP:1=")) { if(stringValue.startsWith("SAP:1=")) {
sapUrl = stringValue.replaceAll("SAP:1=", ""); sapUrl = stringValue.replaceAll("SAP:1=", "");
} else if (stringValue.startsWith("MOM:1=")) { }else if(stringValue.startsWith("MOM:1=")) {
momUrl = stringValue.replaceAll("MOM:1=", ""); momUrl = stringValue.replaceAll("MOM:1=", "");
} }
} }
StringBuffer sendSap = sendSap(sapUrl, wsdlString, txtPath); StringBuffer sendSap = sendSap(sapUrl,wsdlString,txtPath);
StringBuffer sendMom = sendMom(momUrl, wsdlString, txtPath); StringBuffer sendMom = sendMom(momUrl,wsdlString,txtPath);
StringBuffer errBuffer = new StringBuffer(""); StringBuffer errBuffer = new StringBuffer("");
if (sendSap.length() > 0) { if(sendSap.length()>0) {
errBuffer.append("推送SAP异常:").append("\n"); errBuffer.append("推送SAP异常:").append("\n");
errBuffer.append(sendSap); errBuffer.append(sendSap);
// new SAPMessageUtil("", "s:\n" + errBuffer.toString()); //new SAPMessageUtil("", "s:\n" + errBuffer.toString());
} }
if (sendMom.length() > 0) { if(sendMom.length()>0) {
errBuffer.append("推送MOM异常:").append("\n"); errBuffer.append("推送MOM异常:").append("\n");
errBuffer.append(sendMom); errBuffer.append(sendMom);
} }
// if(errBuffer.length()>0) { // if(errBuffer.length()>0) {
// new SAPMessageUtil("", "推送结果异常:\n" + errBuffer.toString()); // new SAPMessageUtil("", "推送结果异常:\n" + errBuffer.toString());
// } // }
return errBuffer; return errBuffer;
} }
public StringBuffer sendSap(String url,String wsdlString,String txtPath) throws IOException {
public StringBuffer sendSap(String url, String wsdlString, String txtPath) throws IOException {
StringBuffer errBuffer = new StringBuffer("");
StringBuffer errBuffer = new StringBuffer(""); if(!url.contains("http")) {
if (!url.contains("http")) { return errBuffer;
return errBuffer; }
} OkHttpClient client = new OkHttpClient();
OkHttpClient client = new OkHttpClient(); client.setConnectTimeout(100, TimeUnit.SECONDS);
client.setConnectTimeout(100, TimeUnit.SECONDS); client.setReadTimeout(100, TimeUnit.SECONDS);
client.setReadTimeout(100, TimeUnit.SECONDS);
// Authenticator authenticator = client.setAuthenticator(new Au); // Authenticator authenticator = client.setAuthenticator(new Au);
String credential = "";// Credentials.basic("shpodev", "sap@2019"); String credential = "";//Credentials.basic("shpodev", "sap@2019");
if (url.contains("192.168.0.184") || url.contains("gfpot01")) { if(url.contains("192.168.0.184")) {
credential = Credentials.basic("po_rfc", "1qaz!QAZ"); credential = Credentials.basic("shpodev", "sap@2019");
} else { }else {
credential = Credentials.basic("shplm", "sap@2019"); credential = Credentials.basic("shplm", "sap@2019");
} }
MediaType mediaType = MediaType.parse("application/xml"); MediaType mediaType = MediaType.parse("application/xml");
RequestBody body = RequestBody.create(mediaType, wsdlString); RequestBody body = RequestBody.create(mediaType,wsdlString);
// http://192.168.0.184:50100/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_CHINT_ELECTRIC&receiverParty=&receiverService=&interface=SIO_MATERIAL_BOP_PLM_SYN&interfaceNamespace=urn:chintelectric.com:xi:plm //http://192.168.0.184:50100/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_CHINT_ELECTRIC&receiverParty=&receiverService=&interface=SIO_MATERIAL_BOP_PLM_SYN&interfaceNamespace=urn:chintelectric.com:xi:plm
Request request = new Request.Builder().url(url).method("POST", body).header("Authorization", credential) Request request = new Request.Builder()
.addHeader("Content-Type", "application/xml").build(); .url(url)
Response response = client.newCall(request).execute(); .method("POST", body)
// Document document = null; .header("Authorization", credential)
.addHeader("Content-Type", "application/xml")
try { .build();
String string = response.body().string(); Response response = client.newCall(request).execute();
Document document = null;
try {
String string = response.body().string();
// System.out.println("response.body().string()==>"+string); // System.out.println("response.body().string()==>"+string);
TXTUtil.writeTXT(txtPath, "----------------BOM传递SAP结果--------------"); TXTUtil.writeTXT(txtPath, "----------------BOM传递SAP结果--------------");
TXTUtil.writeTXT(txtPath, string); TXTUtil.writeTXT(txtPath, string);
TXTUtil.writeTXT(txtPath, "----------BOM传递SAP结果-----------"); TXTUtil.writeTXT(txtPath, "----------BOM传递SAP结果-----------");
// document = DocumentHelper.parseText(string); document = DocumentHelper.parseText(string);
// Element rootElement = document.getRootElement(); Element rootElement = document.getRootElement();
// Element bodys = rootElement.element("Body"); Element bodys = rootElement.element("Body");
// Element elements = bodys.element("MT_MATERIAL_BOP_RSP"); Element elements = bodys.element("MT_MATERIAL_BOP_RSP");
//// String attributeValue = elements.get(0).attributeValue("CODE"); // String attributeValue = elements.get(0).attributeValue("CODE");
// List<Element> ztable = elements.elements("ZTABLE_RETURN"); List<Element> ztable = elements.elements("ZTABLE_RETURN");
// for (Element zret : ztable) { for(Element zret:ztable) {
// String status = zret.elementText("TYPE"); String status = zret.elementText("TYPE");
// if (status.equals("E")) { if(status.equals("E")) {
// String attributeValue = zret.elementText("MESSAGE"); String attributeValue = zret.elementText("MESSAGE");
// String MATNR = zret.elementText("MATNR"); String MATNR = zret.elementText("MATNR");
// if (MATNR != null) { if(MATNR!=null) {
// attributeValue = attributeValue + ",在" + MATNR + "BOM中"; attributeValue = attributeValue+",在"+MATNR+"BOM中";
// } }
//// String gbk = new String(attributeValue.getBytes("GBK"), "UTF-8"); // String gbk = new String(attributeValue.getBytes("GBK"), "UTF-8");
// System.out.println(attributeValue); System.out.println(attributeValue);
// errBuffer.append(attributeValue).append("\n"); errBuffer.append(attributeValue).append("\n");
// } }
// } }
} catch (Exception e) { } catch (DocumentException e) {
// Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
return errBuffer; return errBuffer;
// if(errBuffer.length()>0) { // if(errBuffer.length()>0) {
// new SAPMessageUtil("", "BOM物料异常:\n" + errBuffer.toString()); // new SAPMessageUtil("", "BOM物料异常:\n" + errBuffer.toString());
// } // }
} }
public String sendJsonHttpPost(String url, String xmlContent,String txtPath) {
public String sendJsonHttpPost(String url, String xmlContent, String txtPath) { CloseableHttpClient httpclient = HttpClients.createDefault();
String responseInfo = null;
try {
HttpPost httpPost = new HttpPost(url);
// 设置请求头部
httpPost.setHeader("Content-Type", "application/xml");
CloseableHttpClient httpclient = HttpClients.createDefault(); // 设置请求体
String responseInfo = null; StringEntity entityReq = new StringEntity(xmlContent, StandardCharsets.UTF_8);
try {
HttpPost httpPost = new HttpPost(url);
// 设置请求头部
httpPost.setHeader("Content-Type", "application/xml");
// 设置请求体 if(url.contains("10.128.11.12")) {
StringEntity entityReq = new StringEntity(xmlContent, StandardCharsets.UTF_8); httpPost.addHeader("Authorization", "Basic MTQyODI0Mjg2NDU2ODMwNzcxNDpkREF3TWpveE1EQXg=");
if (url.contains("10.128.11.12")) {
httpPost.addHeader("Authorization", "Basic MTQyODI0Mjg2NDU2ODMwNzcxNDpkREF3TWpveE1EQXg=");
// http://10.128.11.12:7788/gateway/chint/bop-sync // http://10.128.11.12:7788/gateway/chint/bop-sync
} else { }else {
httpPost.addHeader("Authorization", "Basic MTcxNDkwNTkyNTc2MjUzNTQyNjpkREF3TWpveE1EQXg="); httpPost.addHeader("Authorization", "Basic MTcxNDkwNTkyNTc2MjUzNTQyNjpkREF3TWpveE1EQXg=");
} }
// //
httpPost.setEntity(entityReq); httpPost.setEntity(entityReq);
CloseableHttpResponse response = httpclient.execute(httpPost); CloseableHttpResponse response = httpclient.execute(httpPost);
HttpEntity entity = response.getEntity(); HttpEntity entity = response.getEntity();
int status = response.getStatusLine().getStatusCode(); int status = response.getStatusLine().getStatusCode();
String string = EntityUtils.toString(entity); String string = EntityUtils.toString(entity);
System.out.println("MOM status:" + status + "responseInfo:" + string); System.out.println("MOM status:" + status + "responseInfo:" + string);
TXTUtil.writeTXT(txtPath, "----------------BOM传递MOM结果--------------"); TXTUtil.writeTXT(txtPath, "----------------BOM传递MOM结果--------------");
TXTUtil.writeTXT(txtPath, "MOM status:" + status); TXTUtil.writeTXT(txtPath, "MOM status:" + status);
TXTUtil.writeTXT(txtPath, "responseInfo:" + string); TXTUtil.writeTXT(txtPath, "responseInfo:" + string);
TXTUtil.writeTXT(txtPath, "----------BOM传递MOM结果-----------"); TXTUtil.writeTXT(txtPath, "----------BOM传递MOM结果-----------");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
try { try {
httpclient.close(); httpclient.close();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
return responseInfo; return responseInfo;
} }
public StringBuffer sendMom(String url,String wsdlString,String txtPath) throws IOException {
public StringBuffer sendMom(String url, String wsdlString, String txtPath) throws IOException {
StringBuffer errBuffer = new StringBuffer(""); StringBuffer errBuffer = new StringBuffer("");
if (!url.contains("http")) { if(!url.contains("http")) {
return errBuffer; return errBuffer;
} }
sendJsonHttpPost(url, wsdlString, txtPath); // "http://10.128.11.12:7788/gateway/chint/bop-sync" String string = sendJsonHttpPost(url,wsdlString,txtPath); //"http://10.128.11.12:7788/gateway/chint/bop-sync"
return errBuffer; return errBuffer;
} }
} }

@ -77,8 +77,8 @@ public class BomSendSapOp extends AbstractAIFOperation {
client.setReadTimeout(100, TimeUnit.SECONDS); client.setReadTimeout(100, TimeUnit.SECONDS);
// Authenticator authenticator = client.setAuthenticator(new Au); // Authenticator authenticator = client.setAuthenticator(new Au);
String credential = "";//Credentials.basic("shpodev", "sap@2019"); String credential = "";//Credentials.basic("shpodev", "sap@2019");
if(url.contains("192.168.0.184") || url.contains("gfpot01")) { if(url.contains("192.168.0.184")) {
credential = Credentials.basic("po_rfc", "1qaz!QAZ"); credential = Credentials.basic("shpodev", "sap@2019");
}else { }else {
credential = Credentials.basic("shplm", "sap@2019"); credential = Credentials.basic("shplm", "sap@2019");
} }
@ -100,25 +100,25 @@ public class BomSendSapOp extends AbstractAIFOperation {
TXTUtil.writeTXT(txtPath, "----------------BOM传递SAP结果--------------"); TXTUtil.writeTXT(txtPath, "----------------BOM传递SAP结果--------------");
TXTUtil.writeTXT(txtPath, string); TXTUtil.writeTXT(txtPath, string);
TXTUtil.writeTXT(txtPath, "----------BOM传递SAP结果-----------"); TXTUtil.writeTXT(txtPath, "----------BOM传递SAP结果-----------");
// document = DocumentHelper.parseText(string); document = DocumentHelper.parseText(string);
// Element rootElement = document.getRootElement(); Element rootElement = document.getRootElement();
// Element bodys = rootElement.element("Body"); Element bodys = rootElement.element("Body");
// Element elements = bodys.element("MT_MATERIAL_BOP_RSP"); Element elements = bodys.element("MT_MATERIAL_BOP_RSP");
//// String attributeValue = elements.get(0).attributeValue("CODE"); // String attributeValue = elements.get(0).attributeValue("CODE");
// List<Element> ztable = elements.elements("ZTABLE_RETURN"); List<Element> ztable = elements.elements("ZTABLE_RETURN");
// for(Element zret:ztable) { for(Element zret:ztable) {
// String status = zret.elementText("TYPE"); String status = zret.elementText("TYPE");
// if(status.equals("E")) { if(status.equals("E")) {
// String attributeValue = zret.elementText("MESSAGE"); String attributeValue = zret.elementText("MESSAGE");
// String MATNR = zret.elementText("MATNR"); String MATNR = zret.elementText("MATNR");
// if(MATNR!=null) { if(MATNR!=null) {
// attributeValue = attributeValue+",ÔÚ"+MATNR+"BOMÖÐ"; attributeValue = attributeValue+",ÔÚ"+MATNR+"BOMÖÐ";
// } }
// System.out.println(attributeValue); System.out.println(attributeValue);
// errBuffer.append(attributeValue).append("\n"); errBuffer.append(attributeValue).append("\n");
// } }
// } }
} catch (Exception e) { } catch (DocumentException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
@ -191,7 +191,7 @@ public class BomSendSapOp extends AbstractAIFOperation {
TXTUtil.writeTXT(txtPath, "----------BOM传递数据-----------"); TXTUtil.writeTXT(txtPath, "----------BOM传递数据-----------");
//推送SAP //推送SAP
String[] stringValues = session.getPreferenceService().getStringValues("CHINT_WhBomUrl_YB"); String[] stringValues = session.getPreferenceService().getStringValues("CHINT_WhBomUrl");
String sapUrl = ""; String sapUrl = "";
String momUrl = ""; String momUrl = "";
for(String stringValue:stringValues) { for(String stringValue:stringValues) {

@ -6,8 +6,11 @@ import java.awt.Dimension;
import java.awt.FlowLayout; import java.awt.FlowLayout;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.util.List;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import javax.swing.JTable; import javax.swing.JTable;
@ -17,27 +20,23 @@ import javax.swing.table.TableColumnModel;
//import com.connor.chint.sap2.sap_zy.SAPZYDialog; //import com.connor.chint.sap2.sap_zy.SAPZYDialog;
import com.connor.chint.sap2.util.CheckBoxTableHeaderRenderer; import com.connor.chint.sap2.util.CheckBoxTableHeaderRenderer;
import com.connor.chint.sap2.util.KUtil; import com.connor.chint.sap2.util.KUtil;
import com.connor.chint.sap2.util.MyProgressBarCompent;
import com.connor.chint.sap2.util.SAPUtil; import com.connor.chint.sap2.util.SAPUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication; import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFDialog; import com.teamcenter.rac.aif.AbstractAIFDialog;
import com.teamcenter.rac.kernel.TCComponent; import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCSession; import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox; import com.teamcenter.rac.util.MessageBox;
public class BomSendSapWhFram extends AbstractAIFDialog { public class BomSendSapWhFram extends AbstractAIFDialog {
/**
*
*/
private static final long serialVersionUID = 1L;
private BomSendSapController controller; private BomSendSapController controller;
// private AbstractAIFApplication app; private AbstractAIFApplication app;
private TCSession session; private TCSession session;
public BomSendSapWhFram(AbstractAIFApplication app) { public BomSendSapWhFram(AbstractAIFApplication app) {
super(false); super(false);
this.controller = new BomSendSapController(this, app); this.controller = new BomSendSapController(this, app);
// this.app = app; this.app = app;
this.session = (TCSession) app.getSession(); this.session = (TCSession) app.getSession();
} }
private JButton b_cel; private JButton b_cel;
@ -74,34 +73,6 @@ public class BomSendSapWhFram extends AbstractAIFDialog {
MessageBox.post(this, "没有找到产成品信息", "", MessageBox.INFORMATION); MessageBox.post(this, "没有找到产成品信息", "", MessageBox.INFORMATION);
return; return;
} }
//判断选择的部件存在未发布的需要提示出来值传递发布的BOM若当前选择的BOM未发布则提示出来并且不处理
// TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
// TCComponentBOMWindow win = bomWinType.create(null);
StringBuilder msg = new StringBuilder("");
for(PartBean bean : controller.partList) {
TCComponentItemRevision rev = bean.part;
// win.setWindowTopLine(rev.getItem(), rev, null, null);
// TCComponentBOMLine topLine = win.getTopBOMLine();
// checkStatus(topLine, msg);
TCComponent bomRev = rev.getRelatedComponent("structure_revisions");
TCComponent[] release_status_list = rev.getReferenceListProperty("release_status_list");
if(bomRev == null) {
msg.append("").append(rev);
}else if(release_status_list.length == 0) {
msg.append("").append(rev);
}else {
release_status_list = bomRev.getReferenceListProperty("release_status_list");
if(release_status_list.length == 0) {
msg.append("").append(rev);
}
}
}
if (msg.length() > 0) {
MessageBox.post(this, "以下产成品未发布或未找到BOM视图\n" + msg.substring(1), "", MessageBox.INFORMATION);
return;
}
// win.refresh();
// win.close();
controller.getSapState(); controller.getSapState();
} catch (Exception e) { } catch (Exception e) {
KUtil.setByPass(false); KUtil.setByPass(false);
@ -124,16 +95,6 @@ public class BomSendSapWhFram extends AbstractAIFDialog {
} }
showDialog(); showDialog();
} }
// private void checkStatus(TCComponentBOMLine parent, StringBuilder msg) throws Exception {
//
// for(AIFComponentContext c : parent.getChildren()) {
// TCComponentBOMLine bom = (TCComponentBOMLine) c.getComponent();
// TCComponentItemRevision rev = bom.getItemRevision();
//
// }
// }
private void initUI() { private void initUI() {
this.setTitle("产成品信息"); this.setTitle("产成品信息");
this.setPreferredSize(new Dimension(800, 400)); this.setPreferredSize(new Dimension(800, 400));
@ -164,8 +125,7 @@ public class BomSendSapWhFram extends AbstractAIFDialog {
} }
}); });
} }
private void setCompEnabled(boolean b) {
/*private void setCompEnabled(boolean b) {
b_cel.setEnabled(b); b_cel.setEnabled(b);
t_part.setEnabled(b); t_part.setEnabled(b);
// o_btn.setEnabled(b); // o_btn.setEnabled(b);
@ -173,8 +133,7 @@ public class BomSendSapWhFram extends AbstractAIFDialog {
// s_btn.setEnabled(b); // s_btn.setEnabled(b);
// kt_btn.setEnabled(b); // kt_btn.setEnabled(b);
// pushBOM_btn.setEnabled(b); // pushBOM_btn.setEnabled(b);
}*/ }
private JPanel getBtnPanel() { private JPanel getBtnPanel() {
JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 30, 5)); JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 30, 5));
// o_btn = new JButton("一次方案传递"); // o_btn = new JButton("一次方案传递");
@ -195,16 +154,11 @@ public class BomSendSapWhFram extends AbstractAIFDialog {
return panel; return panel;
} }
// private CheckBoxTableHeaderRenderer tableHeaderRenderer; private CheckBoxTableHeaderRenderer tableHeaderRenderer;
private JPanel getTablePanel() { private JPanel getTablePanel() {
JPanel panel = new JPanel(new BorderLayout()); JPanel panel = new JPanel(new BorderLayout());
tm_part = new DefaultTableModel(); tm_part = new DefaultTableModel();
t_part = new JTable(tm_part) { t_part = new JTable(tm_part) {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override @Override
public boolean isCellEditable(int row, int column) { // 选择列(第三列)设置可编辑 public boolean isCellEditable(int row, int column) { // 选择列(第三列)设置可编辑
if (column == 0) if (column == 0)
@ -231,7 +185,7 @@ public class BomSendSapWhFram extends AbstractAIFDialog {
colModel.getColumn(i).setPreferredWidth(HEADERWIDTH[i]); colModel.getColumn(i).setPreferredWidth(HEADERWIDTH[i]);
} }
this.t_part.getTableHeader() this.t_part.getTableHeader()
.setDefaultRenderer(new CheckBoxTableHeaderRenderer(t_part, 0, false)); .setDefaultRenderer(this.tableHeaderRenderer = new CheckBoxTableHeaderRenderer(t_part, 0, false));
this.t_part.getTableHeader().setBackground(Color.blue); this.t_part.getTableHeader().setBackground(Color.blue);
JScrollPane scroll = new JScrollPane(t_part); JScrollPane scroll = new JScrollPane(t_part);
panel.add(BorderLayout.CENTER, scroll); panel.add(BorderLayout.CENTER, scroll);

@ -1,25 +1,38 @@
package com.connor.chint.yunpi.command; package com.connor.chint.yunpi.command;
import java.util.Map;
import javax.swing.JOptionPane;
import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode;
import com.connor.chint.sap2.util.BomToSapUtil;
import com.connor.chint.sap2.util.ChintPreferenceUtil; import com.connor.chint.sap2.util.ChintPreferenceUtil;
import com.connor.chint.sap2.util.KUtil;
import com.connor.chint.sap2.util.MyProgressBarCompent; import com.connor.chint.sap2.util.MyProgressBarCompent;
import com.connor.chint.sap2.util.SAPMessageUtil;
import com.connor.chint.sap2.util.SAPMessageUtilFram; import com.connor.chint.sap2.util.SAPMessageUtilFram;
import com.connor.chint.sap2.util.SAPUtil; import com.connor.chint.sap2.util.SAPUtil;
import com.connor.chint.yunpi.KCommand; import com.connor.chint.yunpi.KCommand;
import com.teamcenter.rac.aif.AbstractAIFApplication; import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine; import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentBOMWindow;
import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
import com.teamcenter.rac.kernel.TCComponentItem; import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision; import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType; import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession; import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.kernel.TCTypeService;
import com.teamcenter.rac.kernel.TCUserService; import com.teamcenter.rac.kernel.TCUserService;
import com.teamcenter.rac.util.MessageBox; import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSData;
@SuppressWarnings("deprecation")
public class DbomToECommand extends KCommand { public class DbomToECommand extends KCommand {
// private boolean top = true; private boolean top = true;
private TCComponentItemRevision rev; private TCComponentItemRevision rev;
public DbomToECommand(AbstractAIFApplication app, String commandId, String actionInfo) { public DbomToECommand(AbstractAIFApplication app, String commandId, String actionInfo) {
super(app, commandId, actionInfo); super(app, commandId, actionInfo);
@ -34,7 +47,8 @@ public class DbomToECommand extends KCommand {
if(targetComponent instanceof TCComponentBOMLine) { if(targetComponent instanceof TCComponentBOMLine) {
rev = ((TCComponentBOMLine)targetComponent).getItemRevision(); rev = ((TCComponentBOMLine)targetComponent).getItemRevision();
}else if(targetComponent instanceof TCComponentItemRevision) { }else if(targetComponent instanceof TCComponentItemRevision) {
rev = (TCComponentItemRevision) targetComponent; TCComponentItemRevision rev = (TCComponentItemRevision) targetComponent;
this.rev = rev;
}else { }else {
MessageBox.post("请选择BOM行或者版本对象", "", MessageBox.ERROR); MessageBox.post("请选择BOM行或者版本对象", "", MessageBox.ERROR);
return; return;
@ -76,7 +90,6 @@ public class DbomToECommand extends KCommand {
} }
} }
// SAPUtil. // SAPUtil.
/* 20240314 DBOMEBOM
if(KUtil.isTCM(rev)) { if(KUtil.isTCM(rev)) {
Object[] options = {"否","是"}; Object[] options = {"否","是"};
int response = JOptionPane.showOptionDialog(null, "图纸已经发布是否要继续更新EBOM.", "选择",JOptionPane.YES_OPTION, int response = JOptionPane.showOptionDialog(null, "图纸已经发布是否要继续更新EBOM.", "选择",JOptionPane.YES_OPTION,
@ -85,7 +98,7 @@ public class DbomToECommand extends KCommand {
{ {
return; return;
} }
}*/ }
new Thread() { new Thread() {
@Override @Override
public void run() { public void run() {
@ -99,13 +112,11 @@ public class DbomToECommand extends KCommand {
System.out.println("111"); System.out.println("111");
new SAPMessageUtilFram("", "DBOM转EBOM存在异常物料,请检查:\n" + call.toString()).show(); new SAPMessageUtilFram("", "DBOM转EBOM存在异常物料,请检查:\n" + call.toString()).show();
}else { }else {
rev.refresh(); MessageBox.post("DBOMת»»EBOMÍê³É","Ìáʾ",2);
MessageBox.post("DBOM转换EBOM完成", "提示", MessageBox.INFORMATION);
} }
} catch (Exception e1) { } catch (TCException e1) {
// Auto-generated catch block // TODO Auto-generated catch block
e1.printStackTrace(); e1.printStackTrace();
MessageBox.post("错误:" + e1.toString(), "ERROR", MessageBox.ERROR);
} }
if(comp!=null) { if(comp!=null) {
comp.setVisible(false); comp.setVisible(false);
@ -113,16 +124,14 @@ public class DbomToECommand extends KCommand {
} }
}.start(); }.start();
} catch (Exception e1) { } catch (TCException e1) {
// Auto-generated catch block // TODO Auto-generated catch block
e1.printStackTrace(); e1.printStackTrace();
MessageBox.post("错误:" + e1.toString(), "ERROR", MessageBox.ERROR);
} }
} }
}.start(); }.start();
}catch(Exception e) { }catch(Exception e) {
e.printStackTrace(); e.printStackTrace();
MessageBox.post("错误:" + e.toString(), "ERROR", MessageBox.ERROR);
} }
} }
} }

@ -1,6 +1,7 @@
package com.connor.chint.yunpi.command; package com.connor.chint.yunpi.command;
import com.connor.chint.sap2.util.MyProgressBarCompent; import com.connor.chint.sap2.util.MyProgressBarCompent;
import com.connor.chint.sap2.util.SAPMessageUtil;
import com.connor.chint.sap2.util.SAPMessageUtilFram; import com.connor.chint.sap2.util.SAPMessageUtilFram;
import com.connor.chint.sap2.util.SAPUtil; import com.connor.chint.sap2.util.SAPUtil;
import com.connor.chint.yunpi.KCommand; import com.connor.chint.yunpi.KCommand;
@ -9,14 +10,14 @@ import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponent; import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine; import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentItemRevision; import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession; import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.kernel.TCUserService; import com.teamcenter.rac.kernel.TCUserService;
import com.teamcenter.rac.util.MessageBox; import com.teamcenter.rac.util.MessageBox;
@SuppressWarnings("deprecation")
public class EbomToPCommand extends KCommand { public class EbomToPCommand extends KCommand {
// private boolean top = true; private boolean top = true;
private TCComponentItemRevision rev; private TCComponentItemRevision rev;
public EbomToPCommand(AbstractAIFApplication app, String commandId, String actionInfo) { public EbomToPCommand(AbstractAIFApplication app, String commandId, String actionInfo) {
super(app, commandId, actionInfo); super(app, commandId, actionInfo);
@ -61,11 +62,8 @@ public class EbomToPCommand extends KCommand {
} }
} }
if(!flag) { if(!flag) {
TCComponent[] flows = bomRevs.getReferenceListProperty("fnd0AllWorkflows"); MessageBox.post("请检查物料版本下的BOMView状态是否已发布,只能转换已发布的EBOM.", "", MessageBox.ERROR);
if(flows == null || flows.length == 0) { return;
MessageBox.post("请检查物料版本下的BOMView状态是否已发布,只能转换已发布的EBOM.", "", MessageBox.ERROR);
return;
}
} }
TCUserService userService = (TCUserService) session.getUserService(); TCUserService userService = (TCUserService) session.getUserService();
@ -78,8 +76,8 @@ public class EbomToPCommand extends KCommand {
}else { }else {
MessageBox.post("EBOMתPBOMÍê³É","Ìáʾ",2); MessageBox.post("EBOMתPBOMÍê³É","Ìáʾ",2);
} }
} catch (Exception e) { } catch (TCException e) {
// Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
if(comp!=null) { if(comp!=null) {

Loading…
Cancel
Save