first commit

main
熊朝柱 2 weeks ago
commit 0bc1e4471a

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="lib/okio-1.13.0.jar"/>
<classpathentry exported="true" kind="lib" path="lib/xmlbeans-2.5.0.jar"/>
<classpathentry exported="true" kind="lib" path="lib/xmlschema-core-2.2.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/wsdl4j-1.6.2.jar"/>
<classpathentry exported="true" kind="lib" path="lib/axis2-transport-base-1.7.8.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-beanutils-1.7.0.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-codec-1.2.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-collections-3.2.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-httpclient-3.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-io-2.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-lang-2.4.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-logging-1.1.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/ezmorph-1.0.4.jar"/>
<classpathentry exported="true" kind="lib" path="lib/httpcore-4.4.6.jar"/>
<classpathentry exported="true" kind="lib" path="lib/woden-core-1.0M10.jar"/>
<classpathentry exported="true" kind="lib" path="lib/axis2-transport-http-1.7.8.jar"/>
<classpathentry exported="true" kind="lib" path="lib/axis2-transport-local-1.7.8.jar"/>
<classpathentry exported="true" kind="lib" path="lib/axis2-adb-1.7.8.jar"/>
<classpathentry exported="true" kind="lib" path="lib/neethi-3.0.3.jar"/>
<classpathentry exported="true" kind="lib" path="lib/axiom-impl-1.2.20.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-logging-1.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/axis2-kernel-1.7.8.jar"/>
<classpathentry exported="true" kind="lib" path="lib/axiom-api-1.2.20.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-net-3.5.jar"/>
<classpathentry exported="true" kind="lib" path="lib/sqljdbc4.jar"/>
<classpathentry exported="true" kind="lib" path="lib/spire.doc-3.2.3.jar"/>
<classpathentry exported="true" kind="lib" path="lib/swingx-1.6.1.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="lib/SPIDERIntegration.jar"/>
<classpathentry kind="lib" path="lib/cn.net.connor.std.gdtex_13000.1.0.jar"/>
<classpathentry kind="lib" path="lib/okhttp-2.7.4.jar"/>
<classpathentry kind="lib" path="lib/json.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

8
.idea/.gitignore vendored

@ -0,0 +1,8 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/com/connor/ldy/process/ProcessMultiplexDialog.java" charset="GBK" />
<file url="file://$PROJECT_DIR$/src/com/connor/ldy/process/ProcessMultiplexHandler.java" charset="GBK" />
</component>
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GitToolBoxBlameSettings">
<option name="version" value="2" />
</component>
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_22" default="true" project-jdk-name="openjdk-22" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/classes" />
</component>
</project>

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.connor.ldy</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8

@ -0,0 +1,51 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Ldy
Bundle-SymbolicName: com.connor.ldy;singleton:=true
Bundle-Version: 1.0.0
Bundle-Vendor: CONNOR
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime;bundle-version="3.15.100",
com.teamcenter.rac.aifrcp;bundle-version="13000.1.0",
com.teamcenter.rac.kernel;bundle-version="13000.1.0",
com.teamcenter.rac.util;bundle-version="13000.1.0",
com.teamcenter.rac.common;bundle-version="13000.1.0",
com.teamcenter.rac.ui.views;bundle-version="13000.1.0",
TcSoaCoreRac;bundle-version="13000.1.0",
TcSoaCoreLoose;bundle-version="13000.1.0",
com.teamcenter.rac.commonclient;bundle-version="13000.1.0",
org.eclipse.core.jobs;bundle-version="3.10.200",
org.apache.poi.39;bundle-version="3.9.0"
Automatic-Module-Name: com.connor.ldy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ClassPath: .,
lib/swingx-1.6.1.jar,
lib/spire.doc-3.2.3.jar,
lib/sqljdbc4.jar,
lib/commons-net-3.5.jar,
lib/axiom-api-1.2.20.jar,
lib/axis2-kernel-1.7.8.jar,
lib/commons-logging-1.1.jar,
lib/axiom-impl-1.2.20.jar,
lib/neethi-3.0.3.jar,
lib/axis2-adb-1.7.8.jar,
lib/axis2-transport-local-1.7.8.jar,
lib/axis2-transport-http-1.7.8.jar,
lib/axis2-transport-base-1.7.8.jar,
lib/commons-beanutils-1.7.0.jar,
lib/commons-codec-1.2.jar,
lib/commons-collections-3.2.jar,
lib/commons-httpclient-3.1.jar,
lib/commons-io-2.1.jar,
lib/commons-lang-2.4.jar,
lib/commons-logging-1.1.1.jar,
lib/ezmorph-1.0.4.jar,
lib/httpcore-4.4.6.jar,
lib/woden-core-1.0M10.jar,
lib/wsdl4j-1.6.2.jar,
lib/xmlbeans-2.5.0.jar,
lib/xmlschema-core-2.2.1.jar,
lib/cn.net.connor.std.gdtex_13000.1.0.jar,
lib/json.jar,
lib/okhttp-2.7.4.jar,
lib/okio-1.13.0.jar

@ -0,0 +1,235 @@
<job id="SubsMacros-MSWord">
<reference guid="{00020905-0000-0000-C000-000000000046}"/>
<script language="VBScript">
Option Explicit
On Error Resume Next
Dim digitDict
digitDict = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Dim fs, WshShell
Set fs = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell")
Dim docFileName, txtFileName
If WScript.Arguments.Count < 2 Then
'MsgBox "Usage: SubsMacros-MSWord <doc file> <data file>"
WScript.Quit
End If
docFileName = WScript.Arguments(0)
txtFileName = WScript.Arguments(1)
Dim wordApp
'Do
' Set wordApp = Nothing
' Set wordApp = GetObject(, "Word.Application")
' wordApp.Quit
'Loop Until wordApp Is Nothing
'Err.Clear
'On Error Resume Next
Dim docFilePath, pathLen
For pathLen = Len(docFileName) To 1 Step -1
If Mid(docFileName, pathLen, 1) = "\" Then
docFilePath = Left(docFileName, pathLen)
Exit For
End If
Next
'WshShell.Run "cmd.exe /c del /f /ah " & docFilePath & "~*.doc"
Dim txtFile, line, data
If fs.FileExists(docFileName) = False Then
'WScript.Echo "File " & docFileName & " doesn't exist!"
WScript.Quit
End If
If Not Right(docFileName, 4) = ".doc" Then
If Not Right(docFileName, 5) = ".docx" Then
'MsgBox "数据集引用文件 " & docFileName & " 扩展名不是.docm或doc, 可能出现不正确结果. 建议将扩展名改为.doc.docm"
End If
End If
If fs.FileExists(txtFileName) = False Then
'WScript.Echo "File " & txtFileName & " doesn't exist!"
WScript.Quit
End If
Set txtFile = fs.OpenTextFile(txtFileName)
line = txtFile.ReadLine()
txtFile.Close
Set data = ReadObject(line)
Dim doc
Dim docVar, varIndex
'Dim word, name, value, startPos, endPos,preword
Set wordApp = CreateObject("Word.Application")
'wordApp.Visible = True
Set doc = wordApp.Documents.Open( docFileName )
'检查所有的客户化属性,赋初值
Dim intProp, cusProp
For intProp = 1 To doc.CustomDocumentProperties.Count
If doc.CustomDocumentProperties(intProp).Value = "" Then
doc.CustomDocumentProperties(intProp).Value = " "
End If
Next
'更新属性值
Dim t, dataName, dataVal ,pic,strs,str,pim
Dim ObjSelection,wordRange
On Error Resume Next
For Each t In data '每个each以|区分,不是日期就是图片地址,都是“属性=值”的形式其中dataName是属性data(dataName)是值
On Error Resume Next
dataName = t
'如果是以图片格式结尾的数据data(dataName)大致就是取=以后的值
If Right(data(dataName), 4) =".jpg" Or Right(data(dataName), 4) =".png" Or Right(data(dataName), 5) =".jpg," Or Right(data(dataName), 5) =".png," Then
'WScript.Echo "插入图片"
'WScript.Echo data(dataName)
strs = Split(data(dataName), ",")
Set wordRange =wordApp.selection.Goto( , , ,dataName) 'selection.goto定位到某个书签
Set ObjSelection=wordApp.selection
if err.number=0 Then
For Each str In strs
On Error Resume Next
if(Right(str, 1) ="g") Then
Set pim =ObjSelection.InlineShapes.AddPicture(str) '书签插入图片
pim.Title="jkword" '?jkword是给签入的图片去个名字,下次可以根据名称删除
End If
Next
End if
err.Clear
'针对签名可能有多人的情况
Dim lenght
If doc.Bookmarks.Exists(dataName & "1")=True Then
For lenght=1 to 40
On Error Resume Next
If doc.Bookmarks.Exists(dataName & lenght)=True Then
Set wordRange =wordApp.selection.Goto( , , ,(dataName & lenght))
Set ObjSelection=wordApp.selection
if err.number=0 Then
For Each str In strs
On Error Resume Next
if(Right(str, 1) ="g") Then
Set pim =ObjSelection.InlineShapes.AddPicture(str)
pim.Title="jkword"
End If
Next
End if
End if
Next
End if
err.Clear
'如果不是以图片格式结尾,获得所有域,匹配名称,设值
Else
For Each cusProp In doc.CustomDocumentProperties
If cusProp.Name = dataName Then
'WScript.Echo "插入" & dataName
cusProp.Value = data(dataName) '插入时间
'WScript.Echo "cusProp.Value = data(dataName)"
Exit For
End If
Next
End If
Next
Dim aStory, aField
For Each aStory In doc.StoryRanges
For Each aField In aStory.Fields
aField.Update
Next
Next
Dim sh
dim l1
dim n1
dim n2
On Error Resume Next
For Each sh in doc.Shapes
startPos = -1 : endPos = -1
name=trim(sh.TextFrame.TextRange.text)
If left(name, 2) = "&[" and mid(name,len(name)-1,1) = "]" then
l1=len(name)
n1=right(name,l1-2)
n2=left(n1,l1-4)
name=n2
If data.Exists(name) Then
value = data(name)
sh.TextFrame.TextRange.Text=value
wordApp.Selection.Find.Execute wdReplaceAll
'WScript.Echo "wordApp.Selection.Find.Execute wdReplaceAll"
Else
value = "(?)"
'WScript.Echo "(?)"
'doc.Range(startPos-2, endPos+1).Text = value
End If
' WScript.Echo "Substituting " & doc.Range(startPos, endPos).Text & " to " & value
startPos = -1 : endPos = -1
End If
Next
'On Error Goto 0
'Err.Clear
doc.Save
doc.Close
wordApp.Quit
'WshShell.Run "cmd.exe /c del /f /ah " & docFilePath & "~*.doc"
'WScript.Echo "end"
If Err.Number > 0 Then
' WScript.Echo "脚本执行过程中发生了错误 '" & Err.Description & "', 很可能导致了不正确的结果, 请检查相应数据."
End If
Function ReadObject(dataline)
Dim data, nvpair, nv
Set ReadObject = CreateObject("Scripting.Dictionary")
data = Split(dataline, "|")
For Each nvpair In data
nv = Split(nvpair, "=")
If UBound(nv) >= 1 Then
If Not ReadObject.Exists(nv(0)) Then
ReadObject.Add nv(0), SubstEscSeq(nv(1))
End If
End If
Next
End Function
Function digitValue(hexStr)
digitValue = InStr(digitDict, hexStr) - 1
'WScript.Echo "Decode hex char " & hexStr & " to " & digitValue
End Function
Function SubstEscSeq(str)
Dim startPos, tokenPos, strLen
SubstEscSeq = ""
strLen = Len(str)
startPos = 1
Do While startPos < strLen
tokenPos = InStr(startPos, str, "%")
If tokenPos < 1 Then
Exit Do
End If
SubstEscSeq = SubstEscSeq + Mid(str, startPos, tokenPos - startPos)
'WScript.Echo "Hex token " & Mid(str, tokenPos, 3) & " decoded to asc value: " & digitValue(Mid(str, tokenPos+1, 1)) * 16 + digitValue(Mid(str, tokenPos+2, 1))
SubstEscSeq = SubstEscSeq + Chr(digitValue(Mid(str, tokenPos+1, 1)) * 16 + digitValue(Mid(str, tokenPos+2, 1)))
startPos = tokenPos + 3
Loop
SubstEscSeq = SubstEscSeq + Mid(str, startPos, strLen - startPos + 1)
'WScript.Echo "Decoded string from " & str & " to " & SubstEscSeq
End Function
</script>
</job>

@ -0,0 +1,36 @@
source.. = src/
output.. = bin/
bin.includes = plugin.xml,\
META-INF/,\
.,\
icons/,\
lib/swingx-1.6.1.jar,\
lib/spire.doc-3.2.3.jar,\
lib/sqljdbc4.jar,\
lib/commons-net-3.5.jar,\
lib/axiom-api-1.2.20.jar,\
lib/axis2-kernel-1.7.8.jar,\
lib/commons-logging-1.1.jar,\
lib/axiom-impl-1.2.20.jar,\
lib/neethi-3.0.3.jar,\
lib/axis2-adb-1.7.8.jar,\
lib/axis2-transport-local-1.7.8.jar,\
lib/axis2-transport-http-1.7.8.jar,\
lib/axis2-transport-base-1.7.8.jar,\
lib/commons-beanutils-1.7.0.jar,\
lib/commons-codec-1.2.jar,\
lib/commons-collections-3.2.jar,\
lib/commons-httpclient-3.1.jar,\
lib/commons-io-2.1.jar,\
lib/commons-lang-2.4.jar,\
lib/commons-logging-1.1.1.jar,\
lib/ezmorph-1.0.4.jar,\
lib/httpcore-4.4.6.jar,\
lib/woden-core-1.0M10.jar,\
lib/wsdl4j-1.6.2.jar,\
lib/xmlbeans-2.5.0.jar,\
lib/xmlschema-core-2.2.1.jar,\
lib/cn.net.connor.std.gdtex_13000.1.0.jar,\
lib/json.jar,\
lib/okhttp-2.7.4.jar,\
lib/okio-1.13.0.jar

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 526 B

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -0,0 +1,212 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension point="org.eclipse.ui.commands">
<command name="工艺分工" id="ProcessDivisionHandler"/>
<command name="工艺另存" id="ProcessBorrowHandler"/>
<command name="工艺复用" id="ProcessMultiplexHandler"/>
<command name="金加工工艺卡片导出" id="ProcessWordExport1Handler"/>
<command name="后道工艺卡片导出" id="ProcessWordExport2Handler"/>
<command name="工装零件工艺卡片导出" id="ProcessWordExport3Handler"/>
<command name="临时金加工工艺卡片导出" id="ProcessWordExport4Handler"/>
<command name="临时后道工艺卡片导出" id="ProcessWordExport5Handler"/>
<command name="刀具工时统计" id="CutterWordTimeHandler"/>
<command name="OA在制品处理流程" id="SendECRtoOAHandler"/>
<command name="OA申购流程" id="OAPurchaseProcessHandler"/>
</extension>
<extension point="org.eclipse.ui.handlers">
<handler class="com.connor.ldy.process.ProcessDivisionHandler" commandId="ProcessDivisionHandler"/>
<handler class="com.connor.ldy.process.ProcessBorrowHandler" commandId="ProcessBorrowHandler"/>
<handler class="com.connor.ldy.process.ProcessMultiplexHandler" commandId="ProcessMultiplexHandler"/>
<handler class="com.connor.ldy.process.ProcessWordExportHandler" commandId="ProcessWordExport1Handler"/>
<handler class="com.connor.ldy.process.ProcessWordExportHandler" commandId="ProcessWordExport2Handler"/>
<handler class="com.connor.ldy.process.ProcessWordExportHandler" commandId="ProcessWordExport3Handler"/>
<handler class="com.connor.ldy.process.ProcessWordExportHandler" commandId="ProcessWordExport4Handler"/>
<handler class="com.connor.ldy.process.ProcessWordExportHandler" commandId="ProcessWordExport5Handler"/>
<handler class="com.connor.ldy.process.CutterWordTimeHandler" commandId="CutterWordTimeHandler"/>
<handler class="com.connor.ldy.oa.SendECRtoOAHandler" commandId="SendECRtoOAHandler"/>
<handler class="com.connor.ldy.oa.OAPurchaseProcessHandler" commandId="OAPurchaseProcessHandler"/>
</extension>
<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="menu:org.eclipse.ui.main.menu?after=additions">
<menu id="com.connor.ldy.menu" label="联德PLM开发菜单">
<menu id="com.connor.ldy.processmenu" label="工艺开发菜单">
<command commandId="ProcessDivisionHandler">
<visibleWhen checkEnabled="true">
<and>
<or>
<reference definitionId="com.teamcenter.rac.cme.mpp.inMainView"/>
</or>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="ProcessDivisionHandler"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId="ProcessBorrowHandler">
<visibleWhen checkEnabled="true">
<and>
<or>
<reference definitionId="com.teamcenter.rac.cme.mpp.inMainView"/>
</or>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="ProcessBorrowHandler"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId="ProcessMultiplexHandler">
<visibleWhen checkEnabled="true">
<and>
<or>
<reference definitionId="com.teamcenter.rac.cme.mpp.inMainView"/>
</or>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="ProcessMultiplexHandler"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<menu id="com.connor.ldy.processwordmenu" label="导出工艺卡片">
<command commandId="ProcessWordExport1Handler">
<visibleWhen checkEnabled="true">
<and>
<or>
<reference definitionId="com.teamcenter.rac.cme.mpp.inMainView"/>
</or>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="ProcessWordExport1Handler"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId="ProcessWordExport2Handler">
<visibleWhen checkEnabled="true">
<and>
<or>
<reference definitionId="com.teamcenter.rac.cme.mpp.inMainView"/>
</or>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="ProcessWordExport2Handler"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId="ProcessWordExport3Handler">
<visibleWhen checkEnabled="true">
<and>
<or>
<reference definitionId="com.teamcenter.rac.cme.mpp.inMainView"/>
</or>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="ProcessWordExport3Handler"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId="ProcessWordExport4Handler">
<visibleWhen checkEnabled="true">
<and>
<or>
<reference definitionId="com.teamcenter.rac.cme.mpp.inMainView"/>
</or>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="ProcessWordExport4Handler"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId="ProcessWordExport5Handler">
<visibleWhen checkEnabled="true">
<and>
<or>
<reference definitionId="com.teamcenter.rac.cme.mpp.inMainView"/>
</or>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="ProcessWordExport5Handler"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
</menu>
</menu>
<command commandId="CutterWordTimeHandler">
<visibleWhen checkEnabled="true">
<and>
<or>
<reference definitionId="com.teamcenter.rac.cme.mpp.inMainView"/>
</or>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="CutterWordTimeHandler"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<menu id="com.connor.ldy.oamenu" label="OA集成">
<command commandId="SendECRtoOAHandler">
<visibleWhen checkEnabled="true">
<and>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="SendECRtoOAHandler"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId="OAPurchaseProcessHandler">
<visibleWhen checkEnabled="true">
<and>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="OAPurchaseProcessHandler"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
</menu>
</menu>
</menuContribution>
</extension>
</plugin>

@ -0,0 +1,166 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension point="org.eclipse.ui.commands">
<command name="工艺分工" id="ProcessDivisionHandler"/>
<command name="工艺另存" id="ProcessBorrowHandler"/>
<command name="工艺复用" id="ProcessMultiplexHandler"/>
<command name="金加工工艺卡片导出" id="ProcessWordExport1Handler"/>
<command name="后道工艺卡片导出" id="ProcessWordExport2Handler"/>
<command name="工装零件工艺卡片导出" id="ProcessWordExport3Handler"/>
<command name="临时金加工工艺卡片导出" id="ProcessWordExport4Handler"/>
<command name="临时后道工艺卡片导出" id="ProcessWordExport5Handler"/>
<command name="刀具工时统计" id="CutterWordTimeHandler"/>
<command name="EC库存处理审批流程" id="SendECRtoOAHandler"/>
<command name="OA申购流程" id="OAPurchaseProcessHandler"/>
<command name="发送文档主数据到MES" id="SendDocumentToMESHandler"/>
<command name="工序修订" id="com.connor.ld.processRevision"/>
</extension>
<extension point="org.eclipse.ui.handlers">
<handler class="com.connor.ldy.process.ProcessDivisionHandler" commandId="ProcessDivisionHandler"/>
<handler class="com.connor.ldy.process.ProcessBorrowHandler" commandId="ProcessBorrowHandler"/>
<handler class="com.connor.ldy.process.ProcessMultiplexHandler" commandId="ProcessMultiplexHandler"/>
<handler class="com.connor.ldy.process.ProcessWordExportHandler" commandId="ProcessWordExport1Handler"/>
<handler class="com.connor.ldy.process.ProcessWordExportHandler" commandId="ProcessWordExport2Handler"/>
<handler class="com.connor.ldy.process.ProcessWordExportHandler" commandId="ProcessWordExport3Handler"/>
<handler class="com.connor.ldy.process.ProcessWordExportHandler" commandId="ProcessWordExport4Handler"/>
<handler class="com.connor.ldy.process.ProcessWordExportHandler" commandId="ProcessWordExport5Handler"/>
<handler class="com.connor.ldy.process.CutterWordTimeHandler" commandId="CutterWordTimeHandler"/>
<handler class="com.connor.ldy.oa.SendECRtoOAHandler" commandId="SendECRtoOAHandler"/>
<handler class="com.connor.ldy.oa.OAPurchaseProcessHandler" commandId="OAPurchaseProcessHandler"/>
<handler class="com.connor.ldy.oa.SendDocumentToMESHandler" commandId="SendDocumentToMESHandler"/>
<handler commandId="com.connor.ld.processRevision" class="com.connor.ld.processRevision.ProcessRevisionCommand"/>
</extension>
<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="menu:org.eclipse.ui.main.menu?after=additions">
<menu id="com.connor.ldy.menu" label="联德PLM开发菜单">
<menu id="com.connor.ldy.processmenu" label="工艺开发菜单">
<command commandId="com.connor.ld.processRevision" id="com.connor.ld.processRevision" mnemonic="S">
</command>
<command commandId="ProcessDivisionHandler">
<visibleWhen checkEnabled="true">
<and>
<or>
<reference definitionId="com.teamcenter.rac.cme.mpp.inMainView"/>
</or>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="ProcessDivisionHandler"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId="ProcessBorrowHandler">
<visibleWhen checkEnabled="true">
<and>
<or>
<reference definitionId="com.teamcenter.rac.cme.mpp.inMainView"/>
</or>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="ProcessBorrowHandler"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId="ProcessMultiplexHandler">
<visibleWhen checkEnabled="true">
<and>
<or>
<reference definitionId="com.teamcenter.rac.cme.mpp.inMainView"/>
</or>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="ProcessMultiplexHandler"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<menu id="com.connor.ldy.processwordmenu" label="导出工艺卡片">
<command commandId="ProcessWordExport1Handler" id="ProcessWordExport1Handler" mnemonic="S">
</command>
<command commandId="ProcessWordExport2Handler" id="ProcessWordExport2Handler" mnemonic="S">
</command>
<command commandId="ProcessWordExport3Handler" id="ProcessWordExport3Handler" mnemonic="S">
</command>
<command commandId="ProcessWordExport4Handler" id="ProcessWordExport4Handler" mnemonic="S">
</command>
<command commandId="ProcessWordExport5Handler" id="ProcessWordExport5Handler" mnemonic="S">
</command>
</menu>
</menu>
<command commandId="CutterWordTimeHandler">
<visibleWhen checkEnabled="true">
<and>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="CutterWordTimeHandler"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<menu id="com.connor.ldy.oamenu" label="OA集成">
<command commandId="SendECRtoOAHandler">
<visibleWhen checkEnabled="true">
<and>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="SendECRtoOAHandler"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId="OAPurchaseProcessHandler">
<visibleWhen checkEnabled="true">
<and>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="OAPurchaseProcessHandler"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
</menu>
<menu id="com.connor.ldy.integrationmenu" label="集成">
<command commandId="SendDocumentToMESHandler">
<visibleWhen checkEnabled="true">
<and>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="SendDocumentToMESHandler"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
</menu>
</menu>
</menuContribution>
</extension>
</plugin>

@ -0,0 +1,54 @@
/** * @Title: KUtil.java
* @Package com.connor.ld.sendMesJc
* @Description: TODO()
* @author admin * @date 20231219
* @version V1.0
*/
package com.connor.ld.processRevision;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.kernel.TCUserService;
/**
* @ClassName: KUtil
* @Description: TODO
* @author hcj
* @date 20231219
*
*/
public class KUtil {
/**
*
* @Title: setByPass
* @Description:
* @param @param session
* @param @param val
* @return void
* @throws
*/
public static void setByPass(TCSession session, boolean val) {
try {
TCUserService userservice = session.getUserService();
userservice.call(val ? "CONNOR_open_bypass" : "CONNOR_close_bypass", new Object[] { "" });
System.out.println(val ? "Open Bypass" : "Close Bypass");
} catch (Exception e) {
e.printStackTrace();
}
}
public static boolean isTCM(TCComponent comp) throws TCException {
if (comp == null) {
return false;
}
// System.out.println("comp:"+comp);
TCComponent tcms[] = comp.getRelatedComponents("release_status_list");
if (tcms.length > 0) {
return true;
}
return false;
}
}

@ -0,0 +1,164 @@
/** * @Title: ProcessRevisionCommand.java
* @Package com.connor.ld.processRevision
* @Description: TODO()
* @author admin * @date 2024531
* @version V1.0
*/
package com.connor.ld.processRevision;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
/**
* @ClassName: ProcessRevisionCommand
* @Description:
* @author hcj
* @date 2024531
*
*/
public class ProcessRevisionCommand extends AbstractHandler {
private TCSession session;
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
// TODO Auto-generated method stub
AbstractAIFApplication app = AIFUtility.getCurrentApplication();
new Thread() {
@Override
public void run() {
// 获取tc当前选择的操作
InterfaceAIFComponent target = app.getTargetComponent();
TCComponentItemRevision revision = null;
if (target instanceof TCComponentItemRevision) {
revision = (TCComponentItemRevision) target;
} else if (target instanceof TCComponentBOMLine) {
try {
revision = ((TCComponentBOMLine) target).getItemRevision();
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
MessageBox.post("请选择版本对象", "提示", MessageBox.INFORMATION);
return;
}
String type = revision.getType();
System.out.println("type:" + type);
if ("LD6_MEOPRevision".equals(type)) {
// 判断是否为金加工序
try {
String property = revision.getProperty("ld6_MEprocessType");
if ("金加工工序".equals(property)) {
// 判断关联的工艺是否全部发布
String processIsRelease = processIsRelease(revision);
if (processIsRelease!=null) {
MessageBox.post("请修订以下工艺路线!"+processIsRelease, "提示", MessageBox.INFORMATION);
return;
}
}
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// 开始升版
try {
revise(revision);
MessageBox.post("修订成功", "提示", MessageBox.INFORMATION);
return;
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
MessageBox.post("修订失败:"+e.getMessage(), "提示", MessageBox.INFORMATION);
return;
}
} else {
MessageBox.post("请选择工序版本对象操作", "提示", MessageBox.INFORMATION);
return;
}
};
}.start();
return null;
}
/**
* @Title: revise
* @Description: TODO()
* @param @param revision
* @return void
* @throws TCException
* @throws
*/
protected void revise(TCComponentItemRevision revision) throws TCException {
// TODO Auto-generated method stub
//开旁路
KUtil.setByPass(session, true);
revision.saveAs(null);
//关旁路
KUtil.setByPass(session, false);
}
/**
* @Title: revise
* @Description:
* @param @param revision
* @return void
* @throws TCException
* @throws
*/
protected String processIsRelease(TCComponentItemRevision revision) throws TCException {
// TODO Auto-generated method stub
TCComponent[] whereUsed = revision.whereUsed((short) 0);
String err = "";
List<String> idList = new ArrayList<String>();
for(TCComponent component : whereUsed) {
if(component instanceof TCComponentItemRevision) {
TCComponentItemRevision rev = (TCComponentItemRevision)component;
String type = rev.getStringProperty("object_type");
if("LD6_MEProcessCrRevision".equals(type) || "LD6_LSMEProcessRevision".equals(type)) {
TCComponentItemRevision latestItemRevision = rev.getItem().getLatestItemRevision();
if(idList.size()>0 && idList.contains(latestItemRevision.getStringProperty("item_id"))) {
continue;
}
idList.add(latestItemRevision.getStringProperty("item_id"));
//判断是否发布
if(isTCM(latestItemRevision)) {
err += latestItemRevision.getStringProperty("item_id")+";";
}
}
}
}
if(!err.isEmpty()) {
return err;
}
return null;
}
public boolean isTCM(TCComponent comp) throws TCException {
if (comp == null) {
return false;
}
// System.out.println("comp:"+comp);
TCComponent tcms[] = comp.getRelatedComponents("release_status_list");
if (tcms.length > 0) {
return true;
}
return false;
}
}

@ -0,0 +1,271 @@
package com.connor.ldy.bom;
import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode;
import com.teamcenter.rac.aif.AbstractAIFCommand;
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.TCProperty;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class DbomTransitionToEbomCommand extends AbstractAIFCommand {
private InterfaceAIFComponent comp;
private TCSession session;
private TCComponentBOMLine bomLine = null;
private boolean flag=true;
private String topRelease ="";//顶层bom关系下的对象是否全部处于工作中非流程中或者已发布
public DbomTransitionToEbomCommand(InterfaceAIFComponent comp, TCSession session) {
// Auto-generated constructor stub
System.out.println("DbomTransitionToEbomCommand");
this.comp = comp;
this.session = session;
}
@Override
public void executeModal() throws Exception {
// Auto-generated method stub
// TCComponentType compType = session.getTypeComponent("ML8_Washing");
// String[] allProperties=compType.getPropertyNames();//获取类所有属性
//TCProperty[] allProperties=compType.getPropertyNames();//获取类所有属性
//System.out.println(tCComponents.length);
//获取选中的对象
if(!(comp instanceof TCComponentBOMLine))
{
MessageBox.post("请在结构管理器中选中BOMLine对象", "错误", MessageBox.ERROR);
return;
}
//System.out.println("11111111111");
bomLine = (TCComponentBOMLine) comp;
if(bomLine.getChildrenCount() <= 0)
{
MessageBox.post("不包含子件的DBOM不能生成EBOM", "错误", MessageBox.ERROR);
return;
}
//判断对象类型
TCComponentItem item = bomLine.getItem();
System.out.println(item.getType());
// if(!item.getType().equals("ML8_Design"))
// {
// MessageBox.post("请选中设计对象!", "错误", MessageBox.ERROR);
// return;
// }
//final List<List<Object>> bomPropertyList = this.getBomPropertys(session, bomLine);
final DefaultMutableTreeTableNode node = this.getBomPropertyToNode(session, bomLine);
//flag=true;//静态变量要重新置为true
// if(!topRelease.equals("")) {
// MessageBox.post(topRelease+"不属于工作中", "错误", MessageBox.ERROR);
// return;
// }
new Thread() {
@Override
public void run() {
new DbomTransitionToEbomDialog(comp, session,node,topRelease);
}
}.start();
super.executeModal();
}
/**
* BOM
* @throws TCException
*/
public DefaultMutableTreeTableNode getBomPropertyToNode(TCSession session, TCComponentBOMLine topBomLine) throws TCException {
// Auto-generated method stub
NodeBean nodeBean = new NodeBean();
//String ss = subline.getStringProperty("bl_indented_title");
//对象ID
nodeBean.setDbom("顶层");
nodeBean.setEbom("");
nodeBean.setEbomId("");
nodeBean.setNum("");
nodeBean.setLabel("");
nodeBean.setRefreshStatus("");
nodeBean.setParentString("");
DefaultMutableTreeTableNode rootNode = new DefaultMutableTreeTableNode(nodeBean);
//获取BOM
try {
//getRepresentationPropertysToNode(topBomLine, rootNode, "");
getBomPropertysToNode(topBomLine, rootNode, "");
return rootNode;
} catch (Exception e) {
// : handle exception
e.printStackTrace();
}
return null;
}
/***
*
* @param bomLine
* @param rootNode
* @param parentID
* @throws TCException
*/
public void getRepresentationPropertysToNode(TCComponentBOMLine bomLine, DefaultMutableTreeTableNode rootNode,String parentID,String quantity) throws TCException
{
TCComponentItemRevision itemRevision = bomLine.getItemRevision();
//获取表示关系下的对象
TCComponent[] tcComponents = itemRevision.getReferenceListProperty("representation_for");
if(flag && tcComponents.length<=0) {
topRelease += "顶层bom关系下无对象";
}
for (TCComponent tcComponent : tcComponents) {
TCProperty refreshStatusProperty = tcComponent.getTCProperty("release_status_list");
TCComponent[] refreshStatus = refreshStatusProperty.getReferenceValueArray();
TCProperty processProperty = tcComponent.getTCProperty("process_stage_list");
TCComponent[] processStage = processProperty.getReferenceValueArray();
NodeBean nodeBean = new NodeBean();
nodeBean.setDbom("");
nodeBean.setEbom(tcComponent.getStringProperty("object_string"));
nodeBean.setEbomId(tcComponent.getStringProperty("item_id"));
nodeBean.setEbomDesc(tcComponent.getStringProperty("ml8_StdDesc"));
nodeBean.setNum(quantity);
nodeBean.setLabel("0");
if(processStage.length > 0) {
nodeBean.setRefreshStatus("流程中");
if(flag) {
System.out.println("topRelease += \"流程中\"");
topRelease += "流程中";
}
}
if(refreshStatus.length > 0) {
StringBuffer stringBuffer = new StringBuffer();
//添加发布状态
for (int i = 0; i < refreshStatus.length; i++) {
stringBuffer.append(refreshStatus[i].toString());
if(i < refreshStatus.length - 1)
{
stringBuffer.append(",");
}
}
nodeBean.setRefreshStatus(stringBuffer.toString());
} else {
nodeBean.setRefreshStatus("");
}
//+++只判断顶层bom下的对象是否在流程中或者已发布
if(flag) {
String status = nodeBean.getRefreshStatus();
if(!status.isEmpty() && !status.contains("属性发布")) {
topRelease+=nodeBean.getEbomId();//对象ID
topRelease+="-";//对象ID
topRelease+=tcComponent.getStringProperty("current_revision_id");//对象版本
topRelease+="-";//对象ID
topRelease+=tcComponent.getStringProperty("object_name");//对象名称
topRelease+=";";
}
}
//+++
nodeBean.setParentString(itemRevision.getStringProperty("object_string"));
DefaultMutableTreeTableNode node = new DefaultMutableTreeTableNode(nodeBean);
rootNode.add(node);
if(tcComponents.length == 1) {
// if(getTopRefresh(node))
// {
// nodeBean.setLabel("0");
// }
// else
// {
// nodeBean.setLabel("1");
// }
nodeBean.setLabel("1");
}
}
}
/***
*
* @param node
* @return
private boolean getTopRefresh(DefaultMutableTreeTableNode node)
{
boolean result = false;
//判断上层是否勾选已发布的对象
DefaultMutableTreeTableNode parentNode = (DefaultMutableTreeTableNode) node.getParent();
if(parentNode != null)
{
DefaultMutableTreeTableNode rootNode = (DefaultMutableTreeTableNode) parentNode.getParent();
if(rootNode != null)
{
for (int i = 0; i < rootNode.getChildCount();) {
DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) rootNode.getChildAt(i);
NodeBean childBean = (NodeBean) childNode.getUserObject();
if(childBean.getLabel().equals("1") && childBean.getRefreshStatus().indexOf("发布") >= 0)
{
//MessageBox.post("上层["+childBean.getEbom()+"]已勾选发布的对象,下层不允许勾选!", "错误", MessageBox.ERROR);
return true;
}
else
{
return getTopRefresh(childNode);
}
}
}
}
return result;
}
*/
/**
* BOM
* @param bomLine
* @param bomPropertyList
* @param parentID
*/
public void getBomPropertysToNode(TCComponentBOMLine bomLine, DefaultMutableTreeTableNode rootNode,String parentID)
{
try {
NodeBean nodeBean = new NodeBean();
nodeBean.setDbom(bomLine.getStringProperty("bl_item_object_string"));
nodeBean.setNum(bomLine.getStringProperty("bl_quantity"));
nodeBean.setEbom("");
nodeBean.setEbomId("");
nodeBean.setLabel("");
nodeBean.setRefreshStatus("");
nodeBean.setParentString("");
DefaultMutableTreeTableNode node = new DefaultMutableTreeTableNode(nodeBean);
rootNode.add(node);
System.out.println("ID:"+bomLine.getStringProperty("bl_item_item_id"));
getRepresentationPropertysToNode(bomLine, node, bomLine.getStringProperty("bl_item_item_id"), bomLine.getStringProperty("bl_quantity"));
if(bomLine.getChildren().length > 0 && flag) {
flag = false;//只遍历顶层bom下的bom
AIFComponentContext aif[] = bomLine.getChildren();
for (int i = 0; i < aif.length; i++) {
TCComponentBOMLine subline = (TCComponentBOMLine) aif[i].getComponent();
getBomPropertysToNode(subline, node,bomLine.getStringProperty("bl_item_item_id"));
}
}
} catch (Exception e) {
// Auto-generated catch block
e.printStackTrace();
}
}
}

@ -0,0 +1,703 @@
package com.connor.ldy.bom;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Robot;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ListSelectionModel;
import javax.swing.table.DefaultTableModel;
import javax.swing.tree.TreePath;
import org.jdesktop.swingx.decorator.HighlighterFactory;
import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode;
import com.teamcenter.rac.aif.AbstractAIFDialog;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.common.Activator;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentBOMWindow;
import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCComponentUser;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
@SuppressWarnings("deprecation")
public class DbomTransitionToEbomDialog extends AbstractAIFDialog implements ActionListener, MouseListener {
/**
*
*/
private static final long serialVersionUID = 1L;
private TCSession session;
private InterfaceAIFComponent comp;
//private InterfaceAIFComponent comp;//获取选中的对象
private List<Integer> isNotEditableRow = new ArrayList<Integer>();
//private TCComponentBOMLine bomLine;
private DefaultMutableTreeTableNode node;
private String[] header = new String[] { "DBOM对象", "EBOM对象","选中", "EBOMID", "物料描述","数量","发布状态","对应父节点"};
private JPanel titlePanel;
private JLabel titleLabel;
private JTreeTable table;
private JTreeTableModel map;
private JPanel rootPanel;
private JButton okButton;
private JButton celButton;
private JButton refreshButton;
//右键菜单
// private static JPopupMenu menu;
//右键菜单项
private JMenuItem sendItem;
private String topRelease;
public DbomTransitionToEbomDialog(InterfaceAIFComponent comp,TCSession session,
DefaultMutableTreeTableNode node,String topRelease) {
// Auto-generated constructor stub
super(false);
this.session = session;
this.comp = comp;
this.node = node;
this.topRelease=topRelease;
init();
}
private void init() {
// Auto-generated method stub
this.setTitle("DBOM转EBOM");
this.setPreferredSize(new Dimension(800,600));
// 初始化标题部分控件
this.titlePanel = new JPanel();
this.titleLabel = new JLabel("DBOM转EBOM");
this.titleLabel.setFont(new Font("宋体", 1, 18));
this.titlePanel.add(titleLabel);
JPanel panel = new JPanel();
panel.add(this.titlePanel,BorderLayout.NORTH);
this.table = getJTreeTable(null, null, header, null);
this.table.addMouseListener(this);
// Adapter adapter = new Adapter(table);
this.rootPanel = new JPanel(new FlowLayout());
this.okButton = new JButton("确认");
this.celButton = new JButton("取消");
this.refreshButton = new JButton("刷新");
this.rootPanel.add(okButton);
this.rootPanel.add(celButton);
this.rootPanel.add(refreshButton);
//this.rootPanel.add(celValueButton);
//右键菜单
// menu = new JPopupMenu();
//添加行
sendItem = new JMenuItem("发送到我的Teamcenter");
// 添加鼠标监听
this.createActionEvent();
this.setLayout(new BorderLayout());
// this.add(centerPanel, BorderLayout.NORTH);
this.add(panel, BorderLayout.NORTH);
this.add(new JScrollPane(this.table), BorderLayout.CENTER);
// dialog.add(tablePanel, BorderLayout.CENTER);
this.add(rootPanel, BorderLayout.SOUTH);
//this.setAlwaysOnTop(true);
this.pack();
this.setLocationRelativeTo(null);
this.show();
}
//添加监听
public void createActionEvent() {
this.okButton.addActionListener(this);
this.celButton.addActionListener(this);
this.refreshButton.addActionListener(this);
this.sendItem.addActionListener(this);
//this.celValueButton.addActionListener(this);
}
//Jtable通用方法
public JTreeTable getJTreeTable(JTreeTable partsTable, DefaultTableModel dtm,
Object[] titleNames, Object[][] values) {
int simpleLen = 100;
int totleLen = 1500;
if (partsTable == null) {
this.map = new JTreeTableModel(this.node);
this.map.setIsNotEditableRow(this.isNotEditableRow);
//map.setColumnIdentifiers(titleNames);
partsTable = new JTreeTable(map);
partsTable.setIsNotEditableRow(this.isNotEditableRow);
partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
// partsTable.setRowHeight(1, 50);
// partsTable.setRowHeight(2, 100);
partsTable.setRowHeight(30);
partsTable.expandAll(); // 展开全部节点
// 隐藏列
// partsTable.HiddenCell(0);
partsTable.getColumnModel().getColumn(0).setPreferredWidth(188); // 设置第一列宽度
partsTable.getColumnModel().getColumn(1).setPreferredWidth(150); // 设置第二列宽度
partsTable.getColumnModel().getColumn(2).setPreferredWidth(55); // 设置第三列宽度
partsTable.setHighlighters(HighlighterFactory.createSimpleStriping());
if (simpleLen * titleNames.length >= totleLen) {
for (int i = 0; i < titleNames.length; i++) {
partsTable.getColumnModel().getColumn(i)
.setPreferredWidth(simpleLen);
}
partsTable.setAutoResizeMode(0);
} else {
partsTable.setAutoResizeMode(1);
}
}
return partsTable;
}
@Override
public void mouseClicked(MouseEvent e) {
// Auto-generated method stub
if(e.getClickCount() == 2) {
TreePath treePath = table.getPathForLocation(e.getX(),e.getY());
if (treePath != null) {
DefaultMutableTreeTableNode node = (DefaultMutableTreeTableNode) treePath.getLastPathComponent();
NodeBean nodeBean = (NodeBean) node.getUserObject();
String itemId = nodeBean.getDbom();
if(itemId == null || itemId.isEmpty()) {
itemId = nodeBean.getEbomId();
}
if(itemId != null && !itemId.isEmpty()) {
try {
//获取对象
TCComponentItemType itemType = (TCComponentItemType) this.session.getTypeComponent("Item");
TCComponentItem item = itemType.find(itemId.split("-")[0]);
Activator.getDefault().openPerspective("com.teamcenter.rac.ui.perspectives.navigatorPerspective");
Activator.getDefault().openComponents("com.teamcenter.rac.ui.perspectives.navigatorPerspective",new InterfaceAIFComponent[] { item });
} catch (Exception e2) {
// : handle exception
e2.printStackTrace();
}
}
}
} else if (e.getClickCount() > 0) {
//
// if(e.getButton() == MouseEvent.BUTTON3)
// {
// menu.show(table, e.getX(), e.getY());
// }
// 获得选中列
int selectColumn = table.getTableHeader().columnAtPoint(e.getPoint());
if(selectColumn != 2){
return;
}
TreePath treePath = table.getPathForLocation(e.getX(),e.getY());
if (treePath != null) {
DefaultMutableTreeTableNode node = (DefaultMutableTreeTableNode) treePath.getLastPathComponent();
NodeBean nodeBean = (NodeBean) node.getUserObject();
// if(getTopRefresh(node))
// {
// MessageBox.post("上层已勾选发布的对象,下层不允许勾选!", "错误", MessageBox.ERROR);
// return;
// }
if(getTopProcessRefresh(node))
{
MessageBox.post("上层已勾选流程中的对象,下层不允许勾选!", "错误", MessageBox.ERROR);
return;
}
DefaultMutableTreeTableNode parentNode = (DefaultMutableTreeTableNode) node.getParent();
if(parentNode != null)
{
DefaultMutableTreeTableNode rootNode = (DefaultMutableTreeTableNode) parentNode.getParent();
NodeBean rootNodeBean = (NodeBean) rootNode.getUserObject();
if(!rootNodeBean.getDbom().equals("顶层") && !getTop(node) && nodeBean.getLabel().equals("0"))
{
MessageBox.post("上层未勾选对象,下层不允许勾选!", "错误", MessageBox.ERROR);
return;
}
}
try {
TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent("Item");
if(nodeBean.getLabel().equals("0"))
{
//判断同一层是否已勾选
if(parentNode != null)
{
for (int i = 0; i < parentNode.getChildCount(); i++) {
DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) parentNode.getChildAt(i);
NodeBean childBean = (NodeBean) childNode.getUserObject();
if(childBean.getLabel().equals("1"))
{
MessageBox.post("同一层级只允许选中一个!", "错误", MessageBox.ERROR);
return;
}
}
}
nodeBean.setLabel("1");
isHaveBom(node, nodeBean.getEbomId(), "1", itemType);
} else if(nodeBean.getLabel().equals("1")) {
nodeBean.setLabel("0");
isHaveBom(node, nodeBean.getEbomId(), "0", itemType);
}
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_TAB);
robot.keyRelease(KeyEvent.VK_TAB);
} catch (Exception e2) {
// : handle exception
e2.printStackTrace();
}
}
}
}
/***
*
* @param node
* @return
* @throws TCException
*/
private void isHaveBom(DefaultMutableTreeTableNode node,String parentID,String status,TCComponentItemType itemType) throws TCException
{
TCComponentItem item = itemType.find(parentID);
TCComponentItemRevision itemRevision = item.getLatestItemRevision();
TCComponent[] tcComponents = itemRevision.getReferenceListProperty("view");
if(tcComponents.length > 0)
{
for (int ii = 0; ii < node.getParent().getChildCount(); ii++) {
DefaultMutableTreeTableNode tableNode = (DefaultMutableTreeTableNode)node.getParent().getChildAt(ii);
if(tableNode.getChildCount() > 0)
{
for (int i = 0; i < tcComponents.length; i++) {
TCComponent childBomLine = tcComponents[i];
List<String> haveItemID = new ArrayList<String>();
for (int j = 0; j < tableNode.getChildCount(); j++) {
String childItemId = childBomLine.getStringProperty("item_id");
NodeBean childNodeBean = (NodeBean) tableNode.getChildAt(j).getUserObject();
if(childItemId.equals(childNodeBean.getEbomId()) && !haveItemID.contains(childNodeBean.getEbomId()))
{
haveItemID.add(childNodeBean.getEbomId());
childNodeBean.setLabel(status);
isHaveBom((DefaultMutableTreeTableNode)(tableNode.getChildAt(j)), childNodeBean.getEbomId(), status, itemType);
}
}
}
}
}
}
}
/***
*
* @param node
* @return
*/
private boolean getTop(DefaultMutableTreeTableNode node)
{
boolean result = false;
//判断上层是否勾选已发布的对象
DefaultMutableTreeTableNode parentNode = (DefaultMutableTreeTableNode) node.getParent();
if(parentNode != null)
{
DefaultMutableTreeTableNode rootNode = (DefaultMutableTreeTableNode) parentNode.getParent();
if(rootNode != null)
{
for (int i = 0; i < rootNode.getChildCount(); i++) {
DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) rootNode.getChildAt(i);
NodeBean childBean = (NodeBean) childNode.getUserObject();
if(childBean.getLabel().equals("1"))
{
//MessageBox.post("上层["+childBean.getEbom()+"]已勾选发布的对象,下层不允许勾选!", "错误", MessageBox.ERROR);
return true;
}
}
}
}
return result;
}
/***
*
* @param node
* @return
private boolean getTopRefresh(DefaultMutableTreeTableNode node)
{
boolean result = false;
//判断上层是否勾选已发布的对象
DefaultMutableTreeTableNode parentNode = (DefaultMutableTreeTableNode) node.getParent();
if(parentNode != null)
{
DefaultMutableTreeTableNode rootNode = (DefaultMutableTreeTableNode) parentNode.getParent();
if(rootNode != null)
{
for (int i = 0; i < rootNode.getChildCount(); i++) {
DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) rootNode.getChildAt(i);
NodeBean childBean = (NodeBean) childNode.getUserObject();
if(childBean.getLabel().equals("1") && !childBean.getRefreshStatus().equals("属性发布") && !childBean.getRefreshStatus().isEmpty())
{
result = true;
break;
}
else
{
if(getTopRefresh(childNode))
{
result = true;
break;
}
}
}
}
}
return result;
}*/
/***
*
* @param node
* @return
*/
private boolean getTopProcessRefresh(DefaultMutableTreeTableNode node)
{
boolean result = false;
//判断上层是否勾选已发布的对象
DefaultMutableTreeTableNode parentNode = (DefaultMutableTreeTableNode) node.getParent();
if(parentNode != null)
{
DefaultMutableTreeTableNode rootNode = (DefaultMutableTreeTableNode) parentNode.getParent();
if(rootNode != null)
{
for (int i = 0; i < rootNode.getChildCount(); i++) {
DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) rootNode.getChildAt(i);
NodeBean childBean = (NodeBean) childNode.getUserObject();
if(childBean.getLabel().equals("1") && childBean.getRefreshStatus().equals("流程中"))
{
result = true;
break;
}
else
{
if(getTopProcessRefresh(childNode))
{
result = true;
break;
}
}
}
}
}
return result;
}
@Override
public void mousePressed(MouseEvent e) {
// Auto-generated method stub
}
@Override
public void mouseReleased(MouseEvent e) {
// Auto-generated method stub
}
@Override
public void mouseEntered(MouseEvent e) {
// Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent e) {
// Auto-generated method stub
}
@Override
public void actionPerformed(ActionEvent e) {
// Auto-generated method stub
Object source = e.getSource();
if (source.equals(this.okButton))
{
System.out.println("topRelease:"+topRelease);
if(!topRelease.equals("")) {
if(topRelease.indexOf("-")>=0) {//顶层bom关系下无对象
MessageBox.post(topRelease+"不属于工作中", "错误", MessageBox.ERROR);
return;
}else if(topRelease.contains("流程中")){
MessageBox.post("顶层对象在流程中", "错误", MessageBox.ERROR);
return;
}else {
MessageBox.post("顶层bom关系下无对象", "错误", MessageBox.ERROR);
return;
}
}
//获取选中的EBOM对象
try {
TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent("Item");
DefaultMutableTreeTableNode tableNode = (DefaultMutableTreeTableNode)this.node.getChildAt(0);
TCComponentUser user = session.getUser();
for (int i = 0; i < tableNode.getChildCount(); i++) {
DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) tableNode.getChildAt(i);
NodeBean childBean = (NodeBean) childNode.getUserObject();
if(childBean.getLabel().equals("1") && (childBean.getRefreshStatus().equals("属性发布") || childBean.getRefreshStatus().equals(""))) {
TCComponentItem topItem = itemType.findItems(childBean.getEbomId())[0];
System.out.println("topItem:"+topItem+"=="+topItem.getReferenceProperty("owning_user"));
if(!topItem.getReferenceProperty("owning_user").equals(user) && !childBean.getRefreshStatus().equals("属性发布")) {
MessageBox.post(DbomTransitionToEbomDialog.this, "当前用户不是"+topItem+"的所有者,不允许转换", "错误", MessageBox.ERROR);
return;
}
}
}
// MethodUtil.openByPass(session);//TODO
this.adaptiveVariants(tableNode, itemType);
// MethodUtil.closeByPass(session);
MessageBox.post("转换成功!", "成功", MessageBox.INFORMATION);
} catch (Exception e1) {
// Auto-generated catch block
e1.printStackTrace();
}
}
else if(source.equals(this.refreshButton))
{
this.dispose();
try {
DbomTransitionToEbomCommand command = new DbomTransitionToEbomCommand(comp,session);
command.executeModal();
} catch (Exception e1) {
// Auto-generated catch block
e1.printStackTrace();
}
}
else if(source.equals(this.sendItem))
{
String itemId = table.getValueAt(table.getSelectedRow(), 3) == null? "" : table.getValueAt(table.getSelectedRow(), 3).toString();
if(itemId.isEmpty())
{
String itemString = table.getValueAt(table.getSelectedRow(), 0) == null? "" : table.getValueAt(table.getSelectedRow(), 0).toString();
if(itemString.indexOf("-") > 0)
{
itemId = itemString.split("-")[0];
}
}
if(itemId != null && !itemId.isEmpty())
{
try {
//获取对象
TCComponentItemType itemType = (TCComponentItemType) this.session.getTypeComponent("Item");
TCComponentItem item = itemType.find(itemId.split("-")[0]);
Activator.getDefault().openPerspective("com.teamcenter.rac.ui.perspectives.navigatorPerspective");
Activator.getDefault().openComponents("com.teamcenter.rac.ui.perspectives.navigatorPerspective", new InterfaceAIFComponent[] { item });
} catch (Exception e2) {
// : handle exception
e2.printStackTrace();
}
}
}
else
{
this.dispose();
}
}
TCComponentBOMLine resultTopline = null;
/**
* BOM
*
* @param topItem
* @throws TCException
*/
private void adaptiveVariants(DefaultMutableTreeTableNode tableNode,TCComponentItemType itemType) throws TCException {
TCComponentItem topItem = null;
ArrayList<TCComponentItemRevision> itemList = new ArrayList<TCComponentItemRevision>();
Map<String,String> itemNumMap = new HashMap<String, String>();
for (int i = 0; i < tableNode.getChildCount(); i++) {
DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) tableNode.getChildAt(i);
NodeBean childBean = (NodeBean) childNode.getUserObject();
if(childBean.getLabel().equals("1") && (childBean.getRefreshStatus().equals("属性发布") || childBean.getRefreshStatus().equals(""))) {
topItem = itemType.find(childBean.getEbomId());
for (int j = 0; j < tableNode.getChildCount(); j++) {
DefaultMutableTreeTableNode node = (DefaultMutableTreeTableNode) tableNode.getChildAt(j);
for (int k = 0; k < node.getChildCount(); k++) {
DefaultMutableTreeTableNode childTableNode = (DefaultMutableTreeTableNode) node.getChildAt(k);
NodeBean childNodeBean = (NodeBean) childTableNode.getUserObject();
if(childNodeBean.getLabel().equals("1")) {
TCComponentItem item = itemType.find(childNodeBean.getEbomId());
itemList.add(item.getLatestItemRevision());
itemNumMap.put(item.getStringProperty("item_id"), childNodeBean.getNum());
if(childNodeBean.getRefreshStatus().equals("属性发布") || childNodeBean.getRefreshStatus().equals("")) {
adaptiveVariants((DefaultMutableTreeTableNode)(childTableNode.getParent()), itemType);
}
}
}
}
}
}
if(topItem != null) {
resultTopline = null;
this.recreateBom(topItem.getLatestItemRevision(), itemList, true);
if(resultTopline != null) {
resultTopline.lock();
//设置BOM行属性
for (int j = 0; j < resultTopline.getChildren().length; j++) {
TCComponentBOMLine bomLine = (TCComponentBOMLine) resultTopline.getChildren()[j].getComponent();
if(itemNumMap.keySet().contains((bomLine.getStringProperty("bl_item_item_id"))))
{
String quantity = itemNumMap.get(bomLine.getStringProperty("bl_item_item_id"));
if(quantity == null || quantity.isEmpty() || quantity.equals("0"))
{
String uom = "";
try {
uom = bomLine.getPropertyDisplayableValue("bl_uom");
} catch (Exception e) {
// Auto-generated catch block
e.printStackTrace();
}
System.out.println("单位:++++++++++++++++"+uom);
if(uom.equals("每个"))
{
continue;
}
quantity = "1.00";
}
System.out.println("数量:++++++++++++++++"+quantity);
if(quantity.indexOf(".") > 0)
{
Double bomNum = Double.parseDouble(quantity);
bomLine.setStringProperty("bl_quantity", bomNum.toString());
}
else
{
Integer bomNum = Integer.parseInt(quantity);
bomLine.setStringProperty("bl_quantity", bomNum.toString());
}
//bomLine.setStringProperty("bl_quantity", itemNumMap.get(bomLine.getStringProperty("bl_item_item_id")));
}
}
resultTopline.save();
resultTopline.unlock();
resultTopline.refresh();
if(resultTopline.getBOMView() != null)
{
resultTopline.getBOMView().save();
resultTopline.getBOMView().refresh();
}
}
}
}
/**
* BOM
*
* @param item
* @param itemlists
* @throws TCException
*/
public void recreateBom(TCComponentItemRevision topItemRev,
ArrayList<TCComponentItemRevision> itemRevisionlists, boolean isDelete)
throws TCException {
TCComponentBOMWindow bomWindow = null;
try {
TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session
.getTypeComponent("BOMWindow");
bomWindow = bomWindowType.create(null);
TCComponentBOMLine topline = bomWindow.setWindowTopLine(topItemRev.getItem(),
topItemRev, null, null);
resultTopline = topline;
bomWindow.lock();
topline.lock();
if (isDelete) {
if (topline.hasChildren()) {
AIFComponentContext[] childrens = topline.getChildren();
for (AIFComponentContext children : childrens) {
((TCComponentBOMLine) children.getComponent()).cut();
}
}
}
for (TCComponentItemRevision n_itemRevision : itemRevisionlists) {
if(n_itemRevision != null)
{
boolean isHave = false;
if(!isDelete)
{
for (AIFComponentContext children : topline.getChildren()) {
if(n_itemRevision.getStringProperty("item_id").compareTo(children.getComponent().getProperty("bl_child_id")) == 0)
{
isHave = true;
}
}
}
if(!isHave)
{
topline.add(n_itemRevision.getItem(), n_itemRevision, null, false, "");
}
}
}
topline.save();
topline.unlock();
topline.refresh();
if(topline.getBOMView() != null)
{
topline.getBOMView().save();
topline.getBOMView().refresh();
}
} catch (Exception e) {
// : handle exception
e.printStackTrace();
}
bomWindow.save();
bomWindow.unlock();
bomWindow.refresh();
}
}

@ -0,0 +1,32 @@
package com.connor.ldy.bom;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class DbomTransitionToEbomHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
// TODO Auto-generated method stub
AbstractAIFApplication app = AIFUtility.getCurrentApplication();
TCSession session = (TCSession) app.getSession();
try {
//MessageBox.post("ml8_FilingRequirements:", "´íÎó", MessageBox.ERROR);
DbomTransitionToEbomCommand command = new DbomTransitionToEbomCommand(app.getTargetComponent(),session);
command.executeModal();
} catch (Exception e) {
e.printStackTrace();
MessageBox.post("´íÎó£º"+e.getMessage(), "ERROR", MessageBox.ERROR);
}
return null;
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save