Compare commits

..

4 Commits

Author SHA1 Message Date
李冬阳 46ed47515c 20240325代码上传
1 year ago
李冬阳 4209302407 1、抓取变更数据时也需要抓取变更的E物料
1 year ago
陈翼晖 2393d8401c 异步BOM调整
1 year ago
陈翼晖 a6c4b2b3a4 传递类型修改
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/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/xmlbeans-5.0.3.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 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="src" path="src"/>
<classpathentry kind="lib" path="poi/Spire.Xls.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

@ -30,7 +30,6 @@ Require-Bundle: org.eclipse.ui,
com.teamcenter.rac.commonclient;bundle-version="11000.2.0",
TcSoaWorkflowRac;bundle-version="11000.2.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",
TcSoaProjectManagementRac;bundle-version="11000.2.0",
TcSoaProjectManagementTypes;bundle-version="11000.2.0",
@ -49,7 +48,8 @@ Require-Bundle: org.eclipse.ui,
com.teamcenter.rac.util;bundle-version="11000.2.0",
org.eclipse.osgi.services;bundle-version="3.3.100",
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
Bundle-RequiredExecutionEnvironment: JavaSE-1.8,
JavaSE-1.7
@ -104,7 +104,6 @@ Bundle-ClassPath: .,
poi/axis2-xmlbeans-1.4.1.jar,
poi/backport-util-concurrent-3.1.jar,
poi/XmlSchema-1.4.7.jar,
poi/xmlbeans-5.0.3.jar,
poi/xml-resolver-1.2.jar,
poi/mail-1.4.jar,
poi/neethi-3.0.2.jar,
@ -115,4 +114,5 @@ Bundle-ClassPath: .,
poi/wstx-asl-3.2.9.jar,
json_lib/JavaFx-DateTimePicker-0.0.1.jar,
poi/okhttp-2.7.4.jar,
json_lib/jfxrt.jar
json_lib/jfxrt.jar,
poi/Spire.Xls.jar

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

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

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

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

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

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

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

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

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

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

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

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

@ -1,5 +1,7 @@
package com.connor.chint.sap2.util;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.Iterator;
import java.util.List;
@ -13,7 +15,7 @@ import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.ClientAnchor;
import org.apache.poi.ss.usermodel.DateUtil;
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.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
@ -25,21 +27,26 @@ import org.apache.poi.xssf.usermodel.XSSFShape;
import org.apache.poi.xssf.usermodel.XSSFSheet;
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 static void main(String[] args) {
String name = "<>'sssshsw*s\\w/?<>|s:";
System.out.println("name:" + name);
for (int i = 0; i < strs.length; i++) {
System.out.println(i + "--[" + strs[i] + "]");
int index = name.indexOf(strs[i]);
System.out.println("index:" + index);
if (index != -1) {
name = name.replaceAll(strs2[i], "");
}
}
System.out.println("name:" + checkName("shsw\\wsw|sjw/|:<>?"));
}
// public static void main(String[] args) {
// String name = "<>'sssshsw*s\\w/?<>|s:";
// System.out.println("name:" + name);
// for (int i = 0; i < strs.length; i++) {
// System.out.println(i + "--[" + strs[i] + "]");
// int index = name.indexOf(strs[i]);
// System.out.println("index:" + index);
// if (index != -1) {
// name = name.replaceAll(strs2[i], "");
// }
// }
// System.out.println("name:" + checkName("shsw\\wsw|sjw/|:<>?"));
// }
private static String strs[] = { "\\", "/", "*", "?", "<", ">", "|", ":" };
private static String strs2[] = { "\\\\", "/", "\\*", "\\?", "<", ">", "\\|", ":" };
@ -351,7 +358,7 @@ public class POIUtil {
for (XSSFShape shape : shapes) {
XSSFPicture pic = (XSSFPicture) shape;
patriarchTo.createPicture((ClientAnchor) pic.getAnchor(),
workbook.addPicture(pic.getPictureData().getData(), Workbook.PICTURE_TYPE_PNG));
workbook.addPicture(pic.getPictureData().getData(), org.apache.poi.ss.usermodel.Workbook.PICTURE_TYPE_PNG));
}
}
}
@ -421,4 +428,179 @@ public class POIUtil {
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,27 +15,29 @@ import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import com.teamcenter.rac.aif.AbstractAIFDialog;
public class SAPMessageUtilFram extends JFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
boolean flag = true;
private JButton b_ok;
private JButton b_ch;
private String label_b_ok = "È·¶¨";
private String label_b_cel = "È¡Ïû";
private String text;
private String title;
// private String title;
private JTextArea jtf;
private int MaxX = 0;
private int MaxY = 0;
// private int MaxX = 0;
// private int MaxY = 0;
private boolean isNeedCel = false;
public SAPMessageUtilFram(String title, String text) {
// super(false);
this.text = text;
this.title = title;
// this.title = title;
initUI2();
this.setAlwaysOnTop(true);
this.pack();
@ -45,13 +47,16 @@ public class SAPMessageUtilFram extends JFrame {
// showDialog();
}
@SuppressWarnings("deprecation")
public void show() {
super.show();
}
private void initUI2() {
jtf = new JTextArea();
JPanel panel = new JPanel(new BorderLayout());
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");
int length = strs.length;
int maxX = 1;

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

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

@ -21,6 +21,7 @@ import com.connor.chint.sap2.util.TXTUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFOperation;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentBOMWindow;
@ -45,14 +46,14 @@ public class BomDcSapOp extends AbstractAIFOperation {
private String groupName = "";
private TCComponentItemType ccomponentitemtype;
public BomDcSapOp(AbstractAIFApplication app) {
// TODO Auto-generated constructor stub
// Auto-generated constructor stub
this.app = app;
this.session = (TCSession) app.getSession();
now = format.format(new Date());
try {
ccomponentitemtype = (TCComponentItemType)session.getTypeComponent("ZT2_Design3D");
} catch (TCException e) {
// TODO Auto-generated catch block
// Auto-generated catch block
e.printStackTrace();
}
@ -84,7 +85,7 @@ public class BomDcSapOp extends AbstractAIFOperation {
}
}
System.out.print("id===>"+id);
TCComponentItem find = ccomponentitemtype.find(id);
TCComponentItem find = ccomponentitemtype.findItems(id)[0];
TCComponentItemRevision zztRev = find.getLatestItemRevision();
TCComponent[] matnrs = zztRev.getRelatedComponents("representation_for");
for(TCComponent matnr:matnrs) {
@ -147,7 +148,7 @@ public class BomDcSapOp extends AbstractAIFOperation {
}
@Override
public void executeOperation() throws Exception {
// TODO Auto-generated method stub
// Auto-generated method stub
MyProgressBarCompent comp = null;
try {
groupName = SAPUtil.getGroupID(session);
@ -173,6 +174,22 @@ public class BomDcSapOp extends AbstractAIFOperation {
MessageBox.post("请选择图纸/物料版本", "", MessageBox.INFORMATION);
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....");
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.KUtil;
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.SAPUtil;
import com.connor.chint.sap2.util.SqlUtil;
import com.connor.chint.sap2.util.TXTUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFOperation;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.ListOfValuesInfo;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentBOMWindow;
@ -31,7 +31,6 @@ import com.teamcenter.rac.kernel.TCComponentDataset;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCComponentListOfValues;
import com.teamcenter.rac.kernel.TCComponentMEProcessRevision;
import com.teamcenter.rac.kernel.TCComponentUser;
import com.teamcenter.rac.kernel.TCException;
@ -40,202 +39,262 @@ import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.services.rac.cad._2007_01.StructureManagement.ExpandPSData;
public class BomSapWhBjOp extends AbstractAIFOperation {
private SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd-HHmmss");
private AbstractAIFApplication app;
private TCSession session;
private SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
private String now;
private String groupName = "";
private TCComponentItemType ccomponentitemtype;
public BomSapWhBjOp(AbstractAIFApplication app) {
// TODO Auto-generated constructor stub
this.app = app;
this.session = (TCSession) app.getSession();
now = format.format(new Date());
try {
ccomponentitemtype = (TCComponentItemType)session.getTypeComponent("ZT2_Design3D");
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public List<TCComponentItem> getCPPPRevision(TCComponentItemRevision rev2) throws TCException {
List<TCComponentItem> itemList = new ArrayList<>();
List<TCComponentItem> itemPList = new ArrayList<>();
String id = "1ZDB300000P-";
if(rev2.getType().equals("Part Revision")) {
String desc = rev2.getStringProperty("object_desc");
String[] split = desc.split(" ");
if(split.length>=2) {
String[] split2 = split[1].split("-");
if(split2.length==2) {
id = id + split2[1];
}else if(split2.length==3) {
id = id + split2[2];
}
}
}else if(rev2.getType().equals("ZT2_Design3DRevision")) {
String desc = rev2.getStringProperty("item_id");
String[] split2 = desc.split("-");
if(split2.length==2) {
id = id + split2[1];
}else if(split2.length==3) {
id = id + split2[2];
}
}
System.out.print("id===>"+id);
TCComponentItem find = ccomponentitemtype.find(id);
TCComponentItemRevision zztRev = find.getLatestItemRevision();
TCComponent[] matnrs = zztRev.getRelatedComponents("representation_for");
for(TCComponent matnr:matnrs) {
String[] properties = matnr.getProperties(new String[]{"zt2_ifpbom"});
TCComponentItemRevision revItem = (TCComponentItemRevision)matnr;
TCComponentItem item = revItem.getItem();
if(properties[0].equals("P") && !itemPList.contains(item)) {
itemPList.add(item);
}else if(!itemList.contains(item)){
itemList.add(item);
}
}
if(itemPList.size()>0) {
return itemPList;
}
return itemList;
}
public TCComponentItemRevision getPRevision(TCComponentItemRevision rev2) throws TCException {
String zt2_MaterialNo = rev2.getStringProperty("zt2_MaterialNo");
if(rev2.getType().equals("Part Revision")) {
String zt2_ifpbom = rev2.getProperty("zt2_ifpbom");
if(zt2_ifpbom.equals("P")) {
return rev2;
}else {
TCComponent designRev = rev2.getRelatedComponent("TC_Is_Represented_By");
if(designRev!=null) {
TCComponent[] matnrs = designRev.getRelatedComponents("representation_for");
for(TCComponent matnr:matnrs) {
String[] properties = matnr.getProperties(new String[]{"zt2_ifpbom","zt2_MaterialNo"});
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");
for(TCComponent matnr:matnrs) {
String[] properties = matnr.getProperties(new String[]{"zt2_ifpbom","zt2_MaterialNo"});
if(properties[0].equals("P")) {
return (TCComponentItemRevision)matnr;
}
}
return (TCComponentItemRevision)matnrs[0];
}
return rev2;
}
public static String getXML(){
private SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd-HHmmss");
private AbstractAIFApplication app;
private TCSession session;
private SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
private String now;
private String groupName = "";
private TCComponentItemType ccomponentitemtype;
public BomSapWhBjOp(AbstractAIFApplication app) {
// Auto-generated constructor stub
this.app = app;
this.session = (TCSession) app.getSession();
now = format.format(new Date());
try {
ccomponentitemtype = (TCComponentItemType) session.getTypeComponent("ZT2_Design3D");
} catch (Exception e) {
// Auto-generated catch block
e.printStackTrace();
}
}
public List<TCComponentItem> getCPPPRevision(TCComponentItemRevision rev2) throws TCException {
List<TCComponentItem> itemList = new ArrayList<>();
List<TCComponentItem> itemPList = new ArrayList<>();
String id = "1ZDB300000P-";
if (rev2.getType().equals("Part Revision")) {
String desc = rev2.getStringProperty("object_desc");
String[] split = desc.split(" ");
if (split.length >= 2) {
String[] split2 = split[1].split("-");
if (split2.length == 2) {
id = id + split2[1];
} else if (split2.length == 3) {
id = id + split2[2];
}
}
} else if (rev2.getType().equals("ZT2_Design3DRevision")) {
String desc = rev2.getStringProperty("item_id");
String[] split2 = desc.split("-");
if (split2.length == 2) {
id = id + split2[1];
} else if (split2.length == 3) {
id = id + split2[2];
}
}
System.out.print("id===>" + id);
TCComponentItem find = ccomponentitemtype.findItems(id)[0];
TCComponentItemRevision zztRev = find.getLatestItemRevision();
TCComponent[] matnrs = zztRev.getRelatedComponents("representation_for");
for (TCComponent matnr : matnrs) {
String[] properties = matnr.getProperties(new String[] { "zt2_ifpbom" });
TCComponentItemRevision revItem = (TCComponentItemRevision) matnr;
TCComponentItem item = revItem.getItem();
if (properties[0].equals("P") && !itemPList.contains(item)) {
itemPList.add(item);
} else if (!itemList.contains(item)) {
itemList.add(item);
}
}
if (itemPList.size() > 0) {
return itemPList;
}
return itemList;
}
public TCComponentItemRevision getPRevision(TCComponentItemRevision rev2) throws TCException {
String zt2_MaterialNo = rev2.getStringProperty("zt2_MaterialNo");
if (rev2.getType().equals("Part Revision")) {
String zt2_ifpbom = rev2.getProperty("zt2_ifpbom");
if (zt2_ifpbom.equals("P")) {
return rev2;
} else {
TCComponent designRev = rev2.getRelatedComponent("TC_Is_Represented_By");
if (designRev != null) {
TCComponent[] matnrs = designRev.getRelatedComponents("representation_for");
for (TCComponent matnr : matnrs) {
String[] properties = matnr.getProperties(new String[] { "zt2_ifpbom", "zt2_MaterialNo" });
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");
for (TCComponent matnr : matnrs) {
String[] properties = matnr.getProperties(new String[] { "zt2_ifpbom", "zt2_MaterialNo" });
if (properties[0].equals("P")) {
return (TCComponentItemRevision) matnr;
}
}
return (TCComponentItemRevision) matnrs[0];
}
return rev2;
}
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"
+ " <soapenv:Header/>\r\n"
+ " <soapenv:Body>\r\n"
+ " <urn:MT_MATERIAL_BOP_REQ>\r\n"
+ " </urn:MT_MATERIAL_BOP_REQ>\r\n"
+ " </soapenv:Body>\r\n"
+ "</soapenv:Envelope>";
+ " <soapenv:Header/>\r\n" + " <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;
}
@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;
}
InterfaceAIFComponent target = app.getTargetComponent();
if (target == null) {
MessageBox.post("请选择图纸版本", "", MessageBox.INFORMATION);
@Override
public void executeOperation() throws Exception {
// Auto-generated method stub
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;
}
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);
TCComponent[] release_status_list = degignRev.getReferenceListProperty("release_status_list");
if(release_status_list.length == 0) {
MessageBox.post(AIFUtility.getActiveDesktop(), "所选对象未发布,无法传递!", "", MessageBox.INFORMATION);
return;
}
comp = new MyProgressBarCompent("", "正在进行部件BOM传递SAP....");
TCComponentItemRevision pRevision = getPRevision(degignRev); //获取PBOM
List<TCComponentItem> cppRevision = getCPPPRevision(degignRev);
//获取产成品
System.out.println("cppRevision===>"+cppRevision.toString());
List<String> wbsList = new ArrayList<String>();
StringBuffer errMessage = new StringBuffer("");
BomUtilWh.checkMatnr(errMessage, pRevision);
TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
TCComponentBOMWindow win = bomWinType.create(null);
TCComponentBOMLine setWindowTopLine = win.setWindowTopLine(pRevision.getItem(), pRevision, null, null);
//优化项BOM全展开
System.out.println("BOM全展开");
Map<String, TCComponent> gy_meops = new HashMap<>(32);
String txtName = format2.format(new Date()) + getUserName(session);
String txtPath = TXTUtil.createTxt(txtName);
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");
Map<String, ExpandPSData[]> bomLineTree = BomToSapUtil.getBomLineTreeNodeSOA(setWindowTopLine);
List<TCComponentMEProcessRevision> needTCM_meops = new ArrayList<TCComponentMEProcessRevision>();
Map<String, TCComponentItemRevision> material_revs = new HashMap<>();
BomUtilWh.expandAllBomPartBj(bomLineTree, setWindowTopLine, pRevision,
groupName,wbsList,session,now,needTCM_meops,gy_meops,INTERGRATIONLIST,errMessage,cppRevision,txtPath,material_revs);
System.out.println("BOM全document===>"+document.asXML());
if(errMessage.length()>0) {
TXTUtil.writeTXT(txtPath, "----------------BOM异常--------------");
TXTUtil.writeTXT(txtPath, errMessage.toString());
TXTUtil.writeTXT(txtPath, "----------BOM信息-----------");
new SAPMessageUtilFram("", "BOM传递SAP异常:\n" + errMessage.toString()).show();
win.close();
}else {
new BomSendSapOp(session,document.asXML(),txtPath,gy_meops).executeOperation();
win.close();
}
if (comp != null) {
comp.setVisible(false);
release_status_list = bomRev.getReferenceListProperty("release_status_list");
if(release_status_list.length == 0) {
MessageBox.post(AIFUtility.getActiveDesktop(), "所选对象BOM视图未发布无法传递", "", MessageBox.INFORMATION);
return;
}
}
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);
}
}
public String getUserName(TCSession session) throws TCException {
TCComponentUser user = session.getUser();
session.getUserName();
return user.getTCProperty("user_name").getDisplayValue();
}
comp = new MyProgressBarCompent("", "正在进行部件BOM传递SAP....");
TCComponentItemRevision pRevision = getPRevision(degignRev); // 获取PBOM
List<TCComponentItem> cppRevision = getCPPPRevision(degignRev);
// 获取产成品
System.out.println("cppRevision===>" + cppRevision.toString());
//记录SUM表信息
String userName = session.getUser().getProperty("user_name");
String dataTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
// String zt2_WBSNo = project.getStringProperty("zt2_WBSNo");
// String object_name = project.getStringProperty("object_name");
String userId = session.getUser().getUserId();
// String code = BomUtilWh.getCode().toString();
StringBuilder productNosBuild = new StringBuilder("");
StringBuilder productUidsBuild = new StringBuilder("");
for(TCComponentItem cppItem:cppRevision) {
TCComponentItemRevision latestItemRevision = cppItem.getLatestItemRevision();
String property = latestItemRevision.getProperty(BomUtilWh.ZT2_MATERIALNO);
productNosBuild.append(property).append(";");
productUidsBuild.append(latestItemRevision.getUid()).append(";");
}
String substring = productUidsBuild.toString().substring(0, productUidsBuild.length() - 1);
String serverHostname = session.getServerHostname();
String wbsNo = cppRevision.get(0).getLatestItemRevision().getProperty(BomUtilWh.ZT2_WBSNO);
SqlUtil.write(BomUtilWh.detailsSql, new String[] { code, "M060", userName, dataTime, wbsNo,
"", "部件", substring, "", serverHostname, userId });
SqlUtil.freeAll();
List<String> wbsList = new ArrayList<String>();
StringBuffer errMessage = new StringBuffer("");
BomUtilWh.checkMatnr(errMessage, pRevision);
TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
TCComponentBOMWindow win = bomWinType.create(null);
TCComponentBOMLine setWindowTopLine = win.setWindowTopLine(pRevision.getItem(), pRevision, null, null);
// 优化项BOM全展开
System.out.println("BOM全展开");
Map<String, TCComponent> gy_meops = new HashMap<>(32);
String txtName = format2.format(new Date()) + getUserName(session);
String txtPath = TXTUtil.createTxt(txtName);
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");
Map<String, ExpandPSData[]> bomLineTree = BomToSapUtil.getBomLineTreeNodeSOA(setWindowTopLine);
List<TCComponentMEProcessRevision> needTCM_meops = new ArrayList<TCComponentMEProcessRevision>();
Map<String, TCComponentItemRevision> material_revs = new HashMap<>();
BomUtilWh.expandAllBomPartBj(bomLineTree, setWindowTopLine, pRevision, groupName, wbsList, session, now,
needTCM_meops, gy_meops, INTERGRATIONLIST, errMessage, cppRevision, txtPath, material_revs, batchNum);
System.out.println("BOM全document===>" + document.asXML());
if (errMessage.length() > 0) {
TXTUtil.writeTXT(txtPath, "----------------BOM异常--------------");
TXTUtil.writeTXT(txtPath, errMessage.toString());
TXTUtil.writeTXT(txtPath, "----------BOM信息-----------");
// BomUtilWh.logXmlMsg(INTERGRATIONLIST, code, productNosBuild.toString(), batchNum, pRevision.getProperty(BomUtilWh.ZT2_WBSNO), session);
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,19 +1,7 @@
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.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 {

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

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

@ -6,11 +6,8 @@ import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
@ -20,23 +17,27 @@ import javax.swing.table.TableColumnModel;
//import com.connor.chint.sap2.sap_zy.SAPZYDialog;
import com.connor.chint.sap2.util.CheckBoxTableHeaderRenderer;
import com.connor.chint.sap2.util.KUtil;
import com.connor.chint.sap2.util.MyProgressBarCompent;
import com.connor.chint.sap2.util.SAPUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFDialog;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class BomSendSapWhFram extends AbstractAIFDialog {
/**
*
*/
private static final long serialVersionUID = 1L;
private BomSendSapController controller;
private AbstractAIFApplication app;
// private AbstractAIFApplication app;
private TCSession session;
public BomSendSapWhFram(AbstractAIFApplication app) {
super(false);
this.controller = new BomSendSapController(this, app);
this.app = app;
// this.app = app;
this.session = (TCSession) app.getSession();
}
private JButton b_cel;
@ -73,6 +74,34 @@ public class BomSendSapWhFram extends AbstractAIFDialog {
MessageBox.post(this, "没有找到产成品信息", "", MessageBox.INFORMATION);
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();
} catch (Exception e) {
KUtil.setByPass(false);
@ -95,6 +124,16 @@ public class BomSendSapWhFram extends AbstractAIFDialog {
}
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() {
this.setTitle("产成品信息");
this.setPreferredSize(new Dimension(800, 400));
@ -125,7 +164,8 @@ public class BomSendSapWhFram extends AbstractAIFDialog {
}
});
}
private void setCompEnabled(boolean b) {
/*private void setCompEnabled(boolean b) {
b_cel.setEnabled(b);
t_part.setEnabled(b);
// o_btn.setEnabled(b);
@ -133,7 +173,8 @@ public class BomSendSapWhFram extends AbstractAIFDialog {
// s_btn.setEnabled(b);
// kt_btn.setEnabled(b);
// pushBOM_btn.setEnabled(b);
}
}*/
private JPanel getBtnPanel() {
JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 30, 5));
// o_btn = new JButton("一次方案传递");
@ -154,11 +195,16 @@ public class BomSendSapWhFram extends AbstractAIFDialog {
return panel;
}
private CheckBoxTableHeaderRenderer tableHeaderRenderer;
// private CheckBoxTableHeaderRenderer tableHeaderRenderer;
private JPanel getTablePanel() {
JPanel panel = new JPanel(new BorderLayout());
tm_part = new DefaultTableModel();
t_part = new JTable(tm_part) {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public boolean isCellEditable(int row, int column) { // 选择列(第三列)设置可编辑
if (column == 0)
@ -185,7 +231,7 @@ public class BomSendSapWhFram extends AbstractAIFDialog {
colModel.getColumn(i).setPreferredWidth(HEADERWIDTH[i]);
}
this.t_part.getTableHeader()
.setDefaultRenderer(this.tableHeaderRenderer = new CheckBoxTableHeaderRenderer(t_part, 0, false));
.setDefaultRenderer(new CheckBoxTableHeaderRenderer(t_part, 0, false));
this.t_part.getTableHeader().setBackground(Color.blue);
JScrollPane scroll = new JScrollPane(t_part);
panel.add(BorderLayout.CENTER, scroll);

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

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

Loading…
Cancel
Save