交接提交

master
刘建兵 11 months ago
commit 414845b6d0

25
.gitignore vendored

@ -0,0 +1,25 @@
/target/
!.mvn/wrapper/maven-wrapper.jar
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/build/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

42
1.txt

@ -0,0 +1,42 @@
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.pjb:springboot-jjwt:jar:0.0.1-SNAPSHOT
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.projectlombok:lombok:jar -> version (?) vs 1.16.22 @ line 271, column 21
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ----------------------< com.pjb:springboot-jjwt >-----------------------
[INFO] Building springboot-jjwt 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ springboot-jjwt ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 5 resources
[INFO] Copying 9 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ springboot-jjwt ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.0.1:testResources (default-testResources) @ springboot-jjwt ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\file store\JavaWorkSpace\IDEA\java_git\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ springboot-jjwt ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.21.0:test (default-test) @ springboot-jjwt ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:2.6:jar (default-jar) @ springboot-jjwt ---
[INFO] Building jar: D:\file store\JavaWorkSpace\IDEA\java_git\target\HG Standard Interface And PM Interface Services v0.1.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.0.3.RELEASE:repackage (default) @ springboot-jjwt ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.259 s
[INFO] Finished at: 2022-09-22T16:41:21+08:00
[INFO] ------------------------------------------------------------------------

@ -0,0 +1,224 @@
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 701936 bytes for Chunk::new
# Possible reasons:
# The system is out of physical RAM or swap space
# In 32 bit mode, the process size limit was hit
# Possible solutions:
# Reduce memory load on the system
# Increase physical memory or swap space
# Check if swap backing store is full
# Use 64 bit Java on a 64 bit OS
# Decrease Java heap size (-Xmx/-Xms)
# Decrease number of Java threads
# Decrease Java thread stack sizes (-Xss)
# Set larger code cache with -XX:ReservedCodeCacheSize=
# This output file may be truncated or incomplete.
#
# Out of Memory Error (allocation.cpp:390), pid=16260, tid=0x0000000000004ed4
#
# JRE version: Java(TM) SE Runtime Environment (8.0_181-b13) (build 1.8.0_181-b13)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.181-b13 mixed mode windows-amd64 compressed oops)
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
--------------- T H R E A D ---------------
Current thread (0x000000001e275000): JavaThread "C2 CompilerThread2" daemon [_thread_in_native, id=20180, stack(0x000000001eb40000,0x000000001ec40000)]
Stack: [0x000000001eb40000,0x000000001ec40000]
[error occurred during error reporting (printing stack bounds), id 0xc0000005]
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
Current CompileTask:
C2: 828 1490 ! 4 java.net.URL::<init> (543 bytes)
--------------- P R O C E S S ---------------
Java Threads: ( => current thread )
0x000000001e30b000 JavaThread "Service Thread" daemon [_thread_blocked, id=15988, stack(0x000000001ed40000,0x000000001ee40000)]
0x000000001e27d000 JavaThread "C1 CompilerThread3" daemon [_thread_blocked, id=13232, stack(0x000000001ec40000,0x000000001ed40000)]
=>0x000000001e275000 JavaThread "C2 CompilerThread2" daemon [_thread_in_native, id=20180, stack(0x000000001eb40000,0x000000001ec40000)]
0x000000001e274800 JavaThread "C2 CompilerThread1" daemon [_thread_in_native, id=13348, stack(0x000000001ea40000,0x000000001eb40000)]
0x000000001e271800 JavaThread "C2 CompilerThread0" daemon [_thread_in_native, id=8016, stack(0x000000001e940000,0x000000001ea40000)]
0x000000001e21a000 JavaThread "Attach Listener" daemon [_thread_blocked, id=6148, stack(0x000000001e840000,0x000000001e940000)]
0x000000001e219000 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=14388, stack(0x000000001e740000,0x000000001e840000)]
0x000000001e200800 JavaThread "Finalizer" daemon [_thread_blocked, id=9328, stack(0x000000001e5e0000,0x000000001e6e0000)]
0x000000001c30d800 JavaThread "Reference Handler" daemon [_thread_blocked, id=9668, stack(0x000000001e0e0000,0x000000001e1e0000)]
0x00000000028c2800 JavaThread "main" [_thread_in_vm, id=20224, stack(0x0000000002710000,0x0000000002810000)]
Other Threads:
0x000000001c307800 VMThread [stack: 0x000000001dfe0000,0x000000001e0e0000] [id=19244]
0x000000001e325800 WatcherThread [stack: 0x000000001ee40000,0x000000001ef40000] [id=18728]
VM state:not at safepoint (normal execution)
VM Mutex/Monitor currently owned by a thread: None
Heap:
PSYoungGen total 75776K, used 39444K [0x000000076bb80000, 0x0000000771000000, 0x00000007c0000000)
eden space 65024K, 44% used [0x000000076bb80000,0x000000076d8083f8,0x000000076fb00000)
from space 10752K, 95% used [0x000000076fb00000,0x00000007704fce10,0x0000000770580000)
to space 10752K, 0% used [0x0000000770580000,0x0000000770580000,0x0000000771000000)
ParOldGen total 173568K, used 16K [0x00000006c3200000, 0x00000006cdb80000, 0x000000076bb80000)
object space 173568K, 0% used [0x00000006c3200000,0x00000006c3204000,0x00000006cdb80000)
Metaspace used 14563K, capacity 14748K, committed 14976K, reserved 1062912K
class space used 1796K, capacity 1876K, committed 1920K, reserved 1048576K
Card table byte_map: [0x0000000011d80000,0x0000000012570000] byte_map_base: 0x000000000e767000
Marking Bits: (ParMarkBitMap*) 0x0000000065de2d00
Begin Bits: [0x00000000132c0000, 0x00000000171f8000)
End Bits: [0x00000000171f8000, 0x000000001b130000)
Polling page: 0x0000000002330000
CodeCache: size=245760Kb used=5620Kb max_used=5626Kb free=240139Kb
bounds [0x00000000029c0000, 0x0000000002f50000, 0x00000000119c0000]
total_blobs=1933 nmethods=1587 adapters=257
compilation: enabled
Compilation events (10 events):
Event: 0.825 Thread 0x000000001e27d000 1580 3 java.lang.reflect.Method::equals (69 bytes)
Event: 0.825 Thread 0x000000001e27d000 nmethod 1580 0x0000000002f3af10 code [0x0000000002f3b0a0, 0x0000000002f3ba28]
Event: 0.825 Thread 0x000000001e27d000 1582 3 java.lang.Class$MethodArray::removeByNameAndDescriptor (42 bytes)
Event: 0.825 Thread 0x000000001e27d000 nmethod 1582 0x0000000002f3bb50 code [0x0000000002f3bce0, 0x0000000002f3c018]
Event: 0.825 Thread 0x000000001e27d000 1583 3 java.lang.Class$MethodArray::addIfNotPresent (47 bytes)
Event: 0.825 Thread 0x000000001e27d000 nmethod 1583 0x0000000002f3c190 code [0x0000000002f3c320, 0x0000000002f3c718]
Event: 0.825 Thread 0x000000001e27d000 1581 3 java.lang.Class$MethodArray::get (7 bytes)
Event: 0.825 Thread 0x000000001e27d000 nmethod 1581 0x0000000002f3c8d0 code [0x0000000002f3ca20, 0x0000000002f3cbb0]
Event: 0.825 Thread 0x000000001e27d000 1584 3 java.lang.Math::min (46 bytes)
Event: 0.826 Thread 0x000000001e27d000 nmethod 1584 0x0000000002f3cc90 code [0x0000000002f3ce00, 0x0000000002f3d150]
GC Heap History (2 events):
Event: 0.560 GC heap before
{Heap before GC invocations=1 (full 0):
PSYoungGen total 75776K, used 65024K [0x000000076bb80000, 0x0000000771000000, 0x00000007c0000000)
eden space 65024K, 100% used [0x000000076bb80000,0x000000076fb00000,0x000000076fb00000)
from space 10752K, 0% used [0x0000000770580000,0x0000000770580000,0x0000000771000000)
to space 10752K, 0% used [0x000000076fb00000,0x000000076fb00000,0x0000000770580000)
ParOldGen total 173568K, used 0K [0x00000006c3200000, 0x00000006cdb80000, 0x000000076bb80000)
object space 173568K, 0% used [0x00000006c3200000,0x00000006c3200000,0x00000006cdb80000)
Metaspace used 11068K, capacity 11204K, committed 11520K, reserved 1058816K
class space used 1350K, capacity 1412K, committed 1536K, reserved 1048576K
Event: 0.566 GC heap after
Heap after GC invocations=1 (full 0):
PSYoungGen total 75776K, used 10227K [0x000000076bb80000, 0x0000000771000000, 0x00000007c0000000)
eden space 65024K, 0% used [0x000000076bb80000,0x000000076bb80000,0x000000076fb00000)
from space 10752K, 95% used [0x000000076fb00000,0x00000007704fce10,0x0000000770580000)
to space 10752K, 0% used [0x0000000770580000,0x0000000770580000,0x0000000771000000)
ParOldGen total 173568K, used 16K [0x00000006c3200000, 0x00000006cdb80000, 0x000000076bb80000)
object space 173568K, 0% used [0x00000006c3200000,0x00000006c3204000,0x00000006cdb80000)
Metaspace used 11068K, capacity 11204K, committed 11520K, reserved 1058816K
class space used 1350K, capacity 1412K, committed 1536K, reserved 1048576K
}
Deoptimization events (10 events):
Event: 0.738 Thread 0x00000000028c2800 Uncommon trap: reason=unstable_if action=reinterpret pc=0x0000000002cba808 method=org.codehaus.plexus.util.xml.pull.MXParser.nextImpl()I @ 1046
Event: 0.772 Thread 0x00000000028c2800 Uncommon trap: reason=unstable_if action=reinterpret pc=0x0000000002af4d00 method=java.lang.CharacterData.of(I)Ljava/lang/CharacterData; @ 4
Event: 0.782 Thread 0x00000000028c2800 Uncommon trap: reason=unstable_if action=reinterpret pc=0x0000000002c2c3ac method=java.lang.AbstractStringBuilder.append(Ljava/lang/String;)Ljava/lang/AbstractStringBuilder; @ 1
Event: 0.782 Thread 0x00000000028c2800 Uncommon trap: reason=unstable_if action=reinterpret pc=0x0000000002baf490 method=java.lang.AbstractStringBuilder.append(Ljava/lang/String;)Ljava/lang/AbstractStringBuilder; @ 1
Event: 0.787 Thread 0x00000000028c2800 Uncommon trap: reason=unstable_if action=reinterpret pc=0x0000000002ba9398 method=sun.misc.MetaIndex.mayContain(Ljava/lang/String;)Z @ 38
Event: 0.790 Thread 0x00000000028c2800 Uncommon trap: reason=bimorphic action=maybe_recompile pc=0x0000000002f093e4 method=java.util.regex.Pattern$CharProperty.match(Ljava/util/regex/Matcher;ILjava/lang/CharSequence;)Z @ 37
Event: 0.790 Thread 0x00000000028c2800 Uncommon trap: reason=bimorphic action=maybe_recompile pc=0x0000000002f093e4 method=java.util.regex.Pattern$CharProperty.match(Ljava/util/regex/Matcher;ILjava/lang/CharSequence;)Z @ 37
Event: 0.798 Thread 0x00000000028c2800 Uncommon trap: reason=unstable_if action=reinterpret pc=0x0000000002b5e440 method=java.lang.String.replace(CC)Ljava/lang/String; @ 2
Event: 0.798 Thread 0x00000000028c2800 Uncommon trap: reason=bimorphic action=maybe_recompile pc=0x0000000002f093e4 method=java.util.regex.Pattern$CharProperty.match(Ljava/util/regex/Matcher;ILjava/lang/CharSequence;)Z @ 37
Event: 0.798 Thread 0x00000000028c2800 Uncommon trap: reason=bimorphic action=maybe_recompile pc=0x0000000002f093e4 method=java.util.regex.Pattern$CharProperty.match(Ljava/util/regex/Matcher;ILjava/lang/CharSequence;)Z @ 37
Classes redefined (0 events):
No events
Internal exceptions (10 events):
Event: 0.687 Thread 0x00000000028c2800 Exception <a 'java/lang/NoClassDefFoundError'> (0x000000076cab00e8) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u181\11358\hotspot\src\share\vm\prims\jvm.cpp, line 1439]
Event: 0.687 Thread 0x00000000028c2800 Exception <a 'java/lang/NoClassDefFoundError': javax/annotation/Priority> (0x000000076cab5140) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u181\11358\hotspot\src\share\vm\classfile\systemDictionary.cpp, line 199]
Event: 0.762 Thread 0x00000000028c2800 Exception <a 'java/lang/NullPointerException'> (0x000000076d0ce458) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u181\11358\hotspot\src\share\vm\interpreter\linkResolver.cpp, line 1185]
Event: 0.762 Thread 0x00000000028c2800 Exception <a 'java/lang/NullPointerException'> (0x000000076d0ce660) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u181\11358\hotspot\src\share\vm\interpreter\linkResolver.cpp, line 1185]
Event: 0.762 Thread 0x00000000028c2800 Exception <a 'java/lang/NullPointerException'> (0x000000076d0ce868) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u181\11358\hotspot\src\share\vm\interpreter\linkResolver.cpp, line 1185]
Event: 0.762 Thread 0x00000000028c2800 Exception <a 'java/lang/NullPointerException'> (0x000000076d0d6dc0) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u181\11358\hotspot\src\share\vm\interpreter\linkResolver.cpp, line 1185]
Event: 0.762 Thread 0x00000000028c2800 Exception <a 'java/lang/NullPointerException'> (0x000000076d0d6fc8) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u181\11358\hotspot\src\share\vm\interpreter\linkResolver.cpp, line 1185]
Event: 0.762 Thread 0x00000000028c2800 Exception <a 'java/lang/NullPointerException'> (0x000000076d0d71d0) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u181\11358\hotspot\src\share\vm\interpreter\linkResolver.cpp, line 1185]
Event: 0.782 Thread 0x00000000028c2800 Implicit null exception at 0x0000000002c2bfd9 to 0x0000000002c2c395
Event: 0.782 Thread 0x00000000028c2800 Implicit null exception at 0x0000000002baf0d6 to 0x0000000002baf479
Events (10 events):
Event: 0.824 loading class org/apache/maven/model/MailingList
Event: 0.824 loading class org/apache/maven/model/MailingList done
Event: 0.824 loading class org/apache/maven/model/CiManagement
Event: 0.824 loading class org/apache/maven/model/CiManagement done
Event: 0.824 loading class org/apache/maven/model/Organization
Event: 0.824 loading class org/apache/maven/model/Organization done
Event: 0.824 loading class org/apache/maven/model/DistributionManagement
Event: 0.824 loading class org/apache/maven/model/DistributionManagement done
Event: 0.826 loading class org/codehaus/plexus/interpolation/util/StringUtils
Event: 0.826 loading class org/codehaus/plexus/interpolation/util/StringUtils done
Dynamic libraries:
0x00007ff6bafb0000 - 0x00007ff6bafe7000 C:\Java\jdk1.8.0_181\bin\java.exe
0x00007fffa59d0000 - 0x00007fffa5bc8000 C:\WINDOWS\SYSTEM32\ntdll.dll
0x00007fffa4630000 - 0x00007fffa46ef000 C:\WINDOWS\System32\KERNEL32.DLL
0x00007fffa36d0000 - 0x00007fffa39a2000 C:\WINDOWS\System32\KERNELBASE.dll
0x00007fffa5590000 - 0x00007fffa563e000 C:\WINDOWS\System32\ADVAPI32.dll
0x00007fffa4570000 - 0x00007fffa460e000 C:\WINDOWS\System32\msvcrt.dll
0x00007fffa54f0000 - 0x00007fffa558c000 C:\WINDOWS\System32\sechost.dll
0x00007fffa43e0000 - 0x00007fffa4505000 C:\WINDOWS\System32\RPCRT4.dll
0x00007fffa3a20000 - 0x00007fffa3bbd000 C:\WINDOWS\System32\USER32.dll
0x00007fffa33d0000 - 0x00007fffa33f2000 C:\WINDOWS\System32\win32u.dll
0x00007fffa4ea0000 - 0x00007fffa4ecb000 C:\WINDOWS\System32\GDI32.dll
0x00007fffa34e0000 - 0x00007fffa35ef000 C:\WINDOWS\System32\gdi32full.dll
0x00007fffa31d0000 - 0x00007fffa326d000 C:\WINDOWS\System32\msvcp_win.dll
0x00007fffa30d0000 - 0x00007fffa31d0000 C:\WINDOWS\System32\ucrtbase.dll
0x00007fff7b1b0000 - 0x00007fff7b44a000 C:\WINDOWS\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.19041.1110_none_60b5254171f9507e\COMCTL32.dll
0x00007fffa4d40000 - 0x00007fffa4d72000 C:\WINDOWS\System32\IMM32.DLL
0x0000000065e70000 - 0x0000000065f42000 C:\Java\jdk1.8.0_181\jre\bin\msvcr100.dll
0x00000000655c0000 - 0x0000000065e62000 C:\Java\jdk1.8.0_181\jre\bin\server\jvm.dll
0x00007fffa48c0000 - 0x00007fffa48c8000 C:\WINDOWS\System32\PSAPI.DLL
0x00007fff825d0000 - 0x00007fff825d9000 C:\WINDOWS\SYSTEM32\WSOCK32.dll
0x00007fff7d0f0000 - 0x00007fff7d117000 C:\WINDOWS\SYSTEM32\WINMM.dll
0x00007fff94080000 - 0x00007fff9408a000 C:\WINDOWS\SYSTEM32\VERSION.dll
0x00007fffa5640000 - 0x00007fffa56ab000 C:\WINDOWS\System32\WS2_32.dll
0x00000000655b0000 - 0x00000000655bf000 C:\Java\jdk1.8.0_181\jre\bin\verify.dll
0x0000000065580000 - 0x00000000655a9000 C:\Java\jdk1.8.0_181\jre\bin\java.dll
0x0000000065560000 - 0x0000000065576000 C:\Java\jdk1.8.0_181\jre\bin\zip.dll
0x00007fffa3bc0000 - 0x00007fffa4303000 C:\WINDOWS\System32\SHELL32.dll
0x00007fffa0c80000 - 0x00007fffa1412000 C:\WINDOWS\SYSTEM32\windows.storage.dll
0x00007fffa4930000 - 0x00007fffa4c84000 C:\WINDOWS\System32\combase.dll
0x00007fffa2b30000 - 0x00007fffa2b60000 C:\WINDOWS\SYSTEM32\Wldp.dll
0x00007fffa4c90000 - 0x00007fffa4d3d000 C:\WINDOWS\System32\SHCORE.dll
0x00007fffa4310000 - 0x00007fffa4365000 C:\WINDOWS\System32\shlwapi.dll
0x00007fffa3010000 - 0x00007fffa302f000 C:\WINDOWS\SYSTEM32\profapi.dll
0x00007fff893f0000 - 0x00007fff893fa000 D:\Installation directory\apache-maven-3.8.1\lib\jansi-native\windows64\jansi.dll
VM Arguments:
jvm_args: -Dclassworlds.conf=D:\Installation directory\apache-maven-3.8.1\bin\..\bin\m2.conf -Dmaven.home=D:\Installation directory\apache-maven-3.8.1\bin\.. -Dlibrary.jansi.path=D:\Installation directory\apache-maven-3.8.1\bin\..\lib\jansi-native -Dmaven.multiModuleProjectDirectory=D:\file store\ÏîÄ¿´úÂë\Àϰå¶þÆÚ\java_git
java_command: org.codehaus.plexus.classworlds.launcher.Launcher package -DskipTests
java_class_path (initial): D:\Installation directory\apache-maven-3.8.1\bin\..\boot\plexus-classworlds-2.6.0.jar
Launcher Type: SUN_STANDARD
Environment Variables:
JAVA_HOME=C:\Java\jdk1.8.0_181
JRE_HOME=C:\Java\jdk1.8.0_181\jre
CLASSPATH=.;C:\Java\jdk1.8.0_181\lib\dt.jar;C:\Java\jdk1.8.0_181\lib\tools.jar;
PATH=C:\Program Files\AdoptOpenJDK\jdk-8.0.282.8-hotspot\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;D:\Installation directory\VMware\bin\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\ZeroTier\One\;%FMS_HOME%\lib;C:\Program Files\dotnet\;C:\WINDOWS\system32\config\systemprofile\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;D:\Tomcat8.5\apache-tomcat-8.5.73;C:\Java\jdk1.8.0_181\bin;C:\Java\jdk1.8.0_181\jre\bin;D:\Installation directory\apache-maven-3.8.1\bin;C:\Program Files\Git\cmd;C:\Users\upaad\AppData\Local\Microsoft\WindowsApps;D:\Installation directory\VSCode\Microsoft VS Code\bin;C:\Users\upaad\.dotnet\tools;C:\Users\upaad\AppData\Local\JetBrains\Toolbox\scripts;
USERNAME=upaad
OS=Windows_NT
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 140 Stepping 1, GenuineIntel
--------------- S Y S T E M ---------------
OS: Windows 10.0 , 64 bit Build 19041 (10.0.19041.2251)
CPU:total 8 (initial active 8) (4 cores per cpu, 2 threads per core) family 6 model 140 stepping 1, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, avx, avx2, aes, clmul, erms, 3dnowpref, lzcnt, ht, tsc, tscinvbit, bmi1, bmi2, adx
Memory: 4k page, physical 16571704k(833464k free), swap 22029804k(5528k free)
vm_info: Java HotSpot(TM) 64-Bit Server VM (25.181-b13) for windows-amd64 JRE (1.8.0_181-b13), built on Jul 7 2018 04:01:33 by "java_re" with MS VC++ 10.0 (VS2010)
time: Tue Nov 22 11:01:26 2022
elapsed time: 0 seconds (0d 0h 0m 0s)

@ -0,0 +1,202 @@
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 467856 bytes for Chunk::new
# Possible reasons:
# The system is out of physical RAM or swap space
# In 32 bit mode, the process size limit was hit
# Possible solutions:
# Reduce memory load on the system
# Increase physical memory or swap space
# Check if swap backing store is full
# Use 64 bit Java on a 64 bit OS
# Decrease Java heap size (-Xmx/-Xms)
# Decrease number of Java threads
# Decrease Java thread stack sizes (-Xss)
# Set larger code cache with -XX:ReservedCodeCacheSize=
# This output file may be truncated or incomplete.
#
# Out of Memory Error (allocation.cpp:390), pid=20456, tid=0x00000000000046f8
#
# JRE version: Java(TM) SE Runtime Environment (8.0_181-b13) (build 1.8.0_181-b13)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.181-b13 mixed mode windows-amd64 compressed oops)
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
--------------- T H R E A D ---------------
Current thread (0x000000001e29d800): JavaThread "C2 CompilerThread0" daemon [_thread_in_native, id=18168, stack(0x000000001e910000,0x000000001ea10000)]
Stack: [0x000000001e910000,0x000000001ea10000]
[error occurred during error reporting (printing stack bounds), id 0xc0000005]
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
Current CompileTask:
C2: 428 750 % 4 java.io.WinNTFileSystem::normalize @ 22 (143 bytes)
--------------- P R O C E S S ---------------
Java Threads: ( => current thread )
0x000000001e33b000 JavaThread "Service Thread" daemon [_thread_blocked, id=10892, stack(0x000000001ed10000,0x000000001ee10000)]
0x000000001e2ad800 JavaThread "C1 CompilerThread3" daemon [_thread_blocked, id=16652, stack(0x000000001ec10000,0x000000001ed10000)]
0x000000001e2a6000 JavaThread "C2 CompilerThread2" daemon [_thread_in_native, id=6528, stack(0x000000001eb10000,0x000000001ec10000)]
0x000000001e2a4800 JavaThread "C2 CompilerThread1" daemon [_thread_blocked, id=6592, stack(0x000000001ea10000,0x000000001eb10000)]
=>0x000000001e29d800 JavaThread "C2 CompilerThread0" daemon [_thread_in_native, id=18168, stack(0x000000001e910000,0x000000001ea10000)]
0x000000001e24a000 JavaThread "Attach Listener" daemon [_thread_blocked, id=19680, stack(0x000000001e810000,0x000000001e910000)]
0x000000001e249000 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=3796, stack(0x000000001e710000,0x000000001e810000)]
0x000000001e230800 JavaThread "Finalizer" daemon [_thread_blocked, id=10212, stack(0x000000001e610000,0x000000001e710000)]
0x0000000002939000 JavaThread "Reference Handler" daemon [_thread_blocked, id=1684, stack(0x000000001e110000,0x000000001e210000)]
0x0000000002842800 JavaThread "main" [_thread_in_native, id=4252, stack(0x0000000002380000,0x0000000002480000)]
Other Threads:
0x000000001c327800 VMThread [stack: 0x000000001e010000,0x000000001e110000] [id=3536]
0x000000001e355800 WatcherThread [stack: 0x000000001ee10000,0x000000001ef10000] [id=18244]
VM state:not at safepoint (normal execution)
VM Mutex/Monitor currently owned by a thread: None
Heap:
PSYoungGen total 75776K, used 43015K [0x000000076bb80000, 0x0000000771000000, 0x00000007c0000000)
eden space 65024K, 66% used [0x000000076bb80000,0x000000076e581f18,0x000000076fb00000)
from space 10752K, 0% used [0x0000000770580000,0x0000000770580000,0x0000000771000000)
to space 10752K, 0% used [0x000000076fb00000,0x000000076fb00000,0x0000000770580000)
ParOldGen total 173568K, used 0K [0x00000006c3200000, 0x00000006cdb80000, 0x000000076bb80000)
object space 173568K, 0% used [0x00000006c3200000,0x00000006c3200000,0x00000006cdb80000)
Metaspace used 8824K, capacity 8968K, committed 9088K, reserved 1056768K
class space used 1065K, capacity 1114K, committed 1152K, reserved 1048576K
Card table byte_map: [0x0000000011da0000,0x0000000012590000] byte_map_base: 0x000000000e787000
Marking Bits: (ParMarkBitMap*) 0x0000000065de2d00
Begin Bits: [0x00000000132e0000, 0x0000000017218000)
End Bits: [0x0000000017218000, 0x000000001b150000)
Polling page: 0x0000000000660000
CodeCache: size=245760Kb used=3396Kb max_used=3404Kb free=242363Kb
bounds [0x00000000029e0000, 0x0000000002d40000, 0x00000000119e0000]
total_blobs=1091 nmethods=782 adapters=222
compilation: enabled
Compilation events (10 events):
Event: 0.421 Thread 0x000000001e2ad800 nmethod 768 0x0000000002d28cd0 code [0x0000000002d29080, 0x0000000002d2ae68]
Event: 0.421 Thread 0x000000001e2ad800 770 3 java.nio.Buffer::nextGetIndex (38 bytes)
Event: 0.421 Thread 0x000000001e2ad800 nmethod 770 0x0000000002d27c10 code [0x0000000002d27d80, 0x0000000002d27fa8]
Event: 0.421 Thread 0x000000001e2ad800 769 3 java.lang.Class::getAnnotation (22 bytes)
Event: 0.421 Thread 0x000000001e2ad800 nmethod 769 0x0000000002d27410 code [0x0000000002d275c0, 0x0000000002d27a68]
Event: 0.421 Thread 0x000000001e2ad800 771 1 java.lang.reflect.Proxy$Key1::hashCode (5 bytes)
Event: 0.421 Thread 0x000000001e2ad800 nmethod 771 0x0000000002d27150 code [0x0000000002d272a0, 0x0000000002d273b0]
Event: 0.422 Thread 0x000000001e2ad800 772 3 java.nio.HeapByteBuffer::getShort (18 bytes)
Event: 0.422 Thread 0x000000001e2ad800 nmethod 772 0x0000000002d2ec50 code [0x0000000002d2ee20, 0x0000000002d2f588]
Event: 0.422 Thread 0x000000001e2ad800 773 3 java.nio.Bits::getShort (18 bytes)
GC Heap History (0 events):
No events
Deoptimization events (8 events):
Event: 0.220 Thread 0x0000000002842800 Uncommon trap: reason=unstable_if action=reinterpret pc=0x0000000002b6b048 method=java.lang.String.indexOf([CII[CIII)I @ 3
Event: 0.303 Thread 0x0000000002842800 Uncommon trap: reason=unstable_if action=reinterpret pc=0x0000000002c45e44 method=java.util.HashMap.getNode(ILjava/lang/Object;)Ljava/util/HashMap$Node; @ 129
Event: 0.324 Thread 0x0000000002842800 Uncommon trap: reason=unstable_if action=reinterpret pc=0x0000000002c8cf54 method=java.nio.charset.CoderResult.isOverflow()Z @ 5
Event: 0.331 Thread 0x0000000002842800 Uncommon trap: reason=unstable_if action=reinterpret pc=0x0000000002c99b34 method=sun.nio.cs.StreamDecoder.implRead([CII)I @ 71
Event: 0.358 Thread 0x0000000002842800 Uncommon trap: reason=unstable_if action=reinterpret pc=0x0000000002ca24bc method=java.io.Reader.read()I @ 12
Event: 0.360 Thread 0x0000000002842800 Uncommon trap: reason=unstable_if action=reinterpret pc=0x0000000002cc20b0 method=sun.nio.cs.StreamDecoder.implRead([CII)I @ 197
Event: 0.388 Thread 0x0000000002842800 Uncommon trap: reason=unstable_if action=reinterpret pc=0x0000000002c4e89c method=java.util.HashMap.getNode(ILjava/lang/Object;)Ljava/util/HashMap$Node; @ 129
Event: 0.393 Thread 0x0000000002842800 Uncommon trap: reason=range_check action=make_not_entrant pc=0x0000000002d053e8 method=sun.reflect.generics.parser.SignatureParser.current()C @ 34
Classes redefined (0 events):
No events
Internal exceptions (10 events):
Event: 0.141 Thread 0x0000000002842800 Exception <a 'java/security/PrivilegedActionException'> (0x000000076c1b2638) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u181\11358\hotspot\src\share\vm\prims\jvm.cpp, line 1435]
Event: 0.141 Thread 0x0000000002842800 Exception <a 'java/security/PrivilegedActionException'> (0x000000076c1b2848) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u181\11358\hotspot\src\share\vm\prims\jvm.cpp, line 1435]
Event: 0.142 Thread 0x0000000002842800 Exception <a 'java/security/PrivilegedActionException'> (0x000000076c1b51b0) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u181\11358\hotspot\src\share\vm\prims\jvm.cpp, line 1435]
Event: 0.142 Thread 0x0000000002842800 Exception <a 'java/security/PrivilegedActionException'> (0x000000076c1b53c0) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u181\11358\hotspot\src\share\vm\prims\jvm.cpp, line 1435]
Event: 0.295 Thread 0x0000000002842800 Exception <a 'java/lang/ArrayIndexOutOfBoundsException'> (0x000000076d0cf7c8) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u181\11358\hotspot\src\share\vm\runtime\sharedRuntime.cpp, line 605]
Event: 0.297 Thread 0x0000000002842800 Exception <a 'java/lang/ArrayIndexOutOfBoundsException'> (0x000000076d0ed080) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u181\11358\hotspot\src\share\vm\runtime\sharedRuntime.cpp, line 605]
Event: 0.302 Thread 0x0000000002842800 Exception <a 'java/lang/ArrayIndexOutOfBoundsException'> (0x000000076d1316c0) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u181\11358\hotspot\src\share\vm\runtime\sharedRuntime.cpp, line 605]
Event: 0.365 Thread 0x0000000002842800 Exception <a 'java/lang/ArrayIndexOutOfBoundsException'> (0x000000076da2fad0) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u181\11358\hotspot\src\share\vm\runtime\sharedRuntime.cpp, line 605]
Event: 0.365 Thread 0x0000000002842800 Exception <a 'java/lang/ArrayIndexOutOfBoundsException'> (0x000000076da31660) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u181\11358\hotspot\src\share\vm\runtime\sharedRuntime.cpp, line 605]
Event: 0.393 Thread 0x0000000002842800 Exception <a 'java/lang/ArrayIndexOutOfBoundsException': 66> (0x000000076dd42260) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u181\11358\hotspot\src\share\vm\interpreter\interpreterRuntime.cpp, line 366]
Events (10 events):
Event: 0.420 loading class org/apache/maven/model/profile/activation/OperatingSystemProfileActivator
Event: 0.420 loading class org/apache/maven/model/profile/activation/OperatingSystemProfileActivator done
Event: 0.421 loading class org/apache/maven/model/profile/activation/PropertyProfileActivator
Event: 0.421 loading class org/apache/maven/model/profile/activation/PropertyProfileActivator done
Event: 0.421 loading class org/apache/maven/model/superpom/DefaultSuperPomProvider
Event: 0.421 loading class org/apache/maven/model/superpom/DefaultSuperPomProvider done
Event: 0.421 loading class org/apache/maven/model/superpom/SuperPomProvider
Event: 0.421 loading class org/apache/maven/model/superpom/SuperPomProvider done
Event: 0.422 loading class org/apache/maven/model/validation/DefaultModelValidator
Event: 0.422 loading class org/apache/maven/model/validation/DefaultModelValidator done
Dynamic libraries:
0x00007ff6bafb0000 - 0x00007ff6bafe7000 C:\Java\jdk1.8.0_181\bin\java.exe
0x00007fffa59d0000 - 0x00007fffa5bc8000 C:\WINDOWS\SYSTEM32\ntdll.dll
0x00007fffa4630000 - 0x00007fffa46ef000 C:\WINDOWS\System32\KERNEL32.DLL
0x00007fffa36d0000 - 0x00007fffa39a2000 C:\WINDOWS\System32\KERNELBASE.dll
0x00007fffa5590000 - 0x00007fffa563e000 C:\WINDOWS\System32\ADVAPI32.dll
0x00007fffa4570000 - 0x00007fffa460e000 C:\WINDOWS\System32\msvcrt.dll
0x00007fffa54f0000 - 0x00007fffa558c000 C:\WINDOWS\System32\sechost.dll
0x00007fffa43e0000 - 0x00007fffa4505000 C:\WINDOWS\System32\RPCRT4.dll
0x00007fffa3a20000 - 0x00007fffa3bbd000 C:\WINDOWS\System32\USER32.dll
0x00007fffa33d0000 - 0x00007fffa33f2000 C:\WINDOWS\System32\win32u.dll
0x00007fffa4ea0000 - 0x00007fffa4ecb000 C:\WINDOWS\System32\GDI32.dll
0x00007fffa34e0000 - 0x00007fffa35ef000 C:\WINDOWS\System32\gdi32full.dll
0x00007fffa31d0000 - 0x00007fffa326d000 C:\WINDOWS\System32\msvcp_win.dll
0x00007fffa30d0000 - 0x00007fffa31d0000 C:\WINDOWS\System32\ucrtbase.dll
0x00007fff7b1b0000 - 0x00007fff7b44a000 C:\WINDOWS\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.19041.1110_none_60b5254171f9507e\COMCTL32.dll
0x00007fffa4d40000 - 0x00007fffa4d72000 C:\WINDOWS\System32\IMM32.DLL
0x0000000065e70000 - 0x0000000065f42000 C:\Java\jdk1.8.0_181\jre\bin\msvcr100.dll
0x00000000655c0000 - 0x0000000065e62000 C:\Java\jdk1.8.0_181\jre\bin\server\jvm.dll
0x00007fffa48c0000 - 0x00007fffa48c8000 C:\WINDOWS\System32\PSAPI.DLL
0x00007fff825d0000 - 0x00007fff825d9000 C:\WINDOWS\SYSTEM32\WSOCK32.dll
0x00007fff7d0f0000 - 0x00007fff7d117000 C:\WINDOWS\SYSTEM32\WINMM.dll
0x00007fff94080000 - 0x00007fff9408a000 C:\WINDOWS\SYSTEM32\VERSION.dll
0x00007fffa5640000 - 0x00007fffa56ab000 C:\WINDOWS\System32\WS2_32.dll
0x00000000655b0000 - 0x00000000655bf000 C:\Java\jdk1.8.0_181\jre\bin\verify.dll
0x0000000065580000 - 0x00000000655a9000 C:\Java\jdk1.8.0_181\jre\bin\java.dll
0x0000000065560000 - 0x0000000065576000 C:\Java\jdk1.8.0_181\jre\bin\zip.dll
0x00007fffa3bc0000 - 0x00007fffa4303000 C:\WINDOWS\System32\SHELL32.dll
0x00007fffa0c80000 - 0x00007fffa1412000 C:\WINDOWS\SYSTEM32\windows.storage.dll
0x00007fffa4930000 - 0x00007fffa4c84000 C:\WINDOWS\System32\combase.dll
0x00007fffa2b30000 - 0x00007fffa2b60000 C:\WINDOWS\SYSTEM32\Wldp.dll
0x00007fffa4c90000 - 0x00007fffa4d3d000 C:\WINDOWS\System32\SHCORE.dll
0x00007fffa4310000 - 0x00007fffa4365000 C:\WINDOWS\System32\shlwapi.dll
0x00007fffa3010000 - 0x00007fffa302f000 C:\WINDOWS\SYSTEM32\profapi.dll
0x00007fff893f0000 - 0x00007fff893fa000 D:\Installation directory\apache-maven-3.8.1\lib\jansi-native\windows64\jansi.dll
VM Arguments:
jvm_args: -Dclassworlds.conf=D:\Installation directory\apache-maven-3.8.1\bin\..\bin\m2.conf -Dmaven.home=D:\Installation directory\apache-maven-3.8.1\bin\.. -Dlibrary.jansi.path=D:\Installation directory\apache-maven-3.8.1\bin\..\lib\jansi-native -Dmaven.multiModuleProjectDirectory=D:\file store\ÏîÄ¿´úÂë\Àϰå¶þÆÚ\java_git
java_command: org.codehaus.plexus.classworlds.launcher.Launcher package -DskipTests
java_class_path (initial): D:\Installation directory\apache-maven-3.8.1\bin\..\boot\plexus-classworlds-2.6.0.jar
Launcher Type: SUN_STANDARD
Environment Variables:
JAVA_HOME=C:\Java\jdk1.8.0_181
JRE_HOME=C:\Java\jdk1.8.0_181\jre
CLASSPATH=.;C:\Java\jdk1.8.0_181\lib\dt.jar;C:\Java\jdk1.8.0_181\lib\tools.jar;
PATH=C:\Program Files\AdoptOpenJDK\jdk-8.0.282.8-hotspot\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;D:\Installation directory\VMware\bin\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\ZeroTier\One\;%FMS_HOME%\lib;C:\Program Files\dotnet\;C:\WINDOWS\system32\config\systemprofile\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;D:\Tomcat8.5\apache-tomcat-8.5.73;C:\Java\jdk1.8.0_181\bin;C:\Java\jdk1.8.0_181\jre\bin;D:\Installation directory\apache-maven-3.8.1\bin;C:\Program Files\Git\cmd;C:\Users\upaad\AppData\Local\Microsoft\WindowsApps;D:\Installation directory\VSCode\Microsoft VS Code\bin;C:\Users\upaad\.dotnet\tools;C:\Users\upaad\AppData\Local\JetBrains\Toolbox\scripts;
USERNAME=upaad
OS=Windows_NT
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 140 Stepping 1, GenuineIntel
--------------- S Y S T E M ---------------
OS: Windows 10.0 , 64 bit Build 19041 (10.0.19041.2251)
CPU:total 8 (initial active 8) (4 cores per cpu, 2 threads per core) family 6 model 140 stepping 1, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, avx, avx2, aes, clmul, erms, 3dnowpref, lzcnt, ht, tsc, tscinvbit, bmi1, bmi2, adx
Memory: 4k page, physical 16571704k(872088k free), swap 22029804k(5164k free)
vm_info: Java HotSpot(TM) 64-Bit Server VM (25.181-b13) for windows-amd64 JRE (1.8.0_181-b13), built on Jul 7 2018 04:01:33 by "java_re" with MS VC++ 10.0 (VS2010)
time: Tue Nov 22 11:01:19 2022
elapsed time: 0 seconds (0d 0h 0m 0s)

225
mvnw vendored

@ -0,0 +1,225 @@
#!/bin/sh
# ----------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Maven2 Start Up Batch script
#
# Required ENV vars:
# ------------------
# JAVA_HOME - location of a JDK home dir
#
# Optional ENV vars
# -----------------
# M2_HOME - location of maven2's installed home dir
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
# e.g. to debug Maven itself, use
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
# ----------------------------------------------------------------------------
if [ -z "$MAVEN_SKIP_RC" ] ; then
if [ -f /etc/mavenrc ] ; then
. /etc/mavenrc
fi
if [ -f "$HOME/.mavenrc" ] ; then
. "$HOME/.mavenrc"
fi
fi
# OS specific support. $var _must_ be set to either true or false.
cygwin=false;
darwin=false;
mingw=false
case "`uname`" in
CYGWIN*) cygwin=true ;;
MINGW*) mingw=true;;
Darwin*) darwin=true
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
if [ -z "$JAVA_HOME" ]; then
if [ -x "/usr/libexec/java_home" ]; then
export JAVA_HOME="`/usr/libexec/java_home`"
else
export JAVA_HOME="/Library/Java/Home"
fi
fi
;;
esac
if [ -z "$JAVA_HOME" ] ; then
if [ -r /etc/gentoo-release ] ; then
JAVA_HOME=`java-config --jre-home`
fi
fi
if [ -z "$M2_HOME" ] ; then
## resolve links - $0 may be a link to maven's home
PRG="$0"
# need this for relative symlinks
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG="`dirname "$PRG"`/$link"
fi
done
saveddir=`pwd`
M2_HOME=`dirname "$PRG"`/..
# make it fully qualified
M2_HOME=`cd "$M2_HOME" && pwd`
cd "$saveddir"
# echo Using m2 at $M2_HOME
fi
# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --unix "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
fi
# For Migwn, ensure paths are in UNIX format before anything is touched
if $mingw ; then
[ -n "$M2_HOME" ] &&
M2_HOME="`(cd "$M2_HOME"; pwd)`"
[ -n "$JAVA_HOME" ] &&
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
# TODO classpath?
fi
if [ -z "$JAVA_HOME" ]; then
javaExecutable="`which javac`"
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
# readlink(1) is not available as standard on Solaris 10.
readLink=`which readlink`
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
if $darwin ; then
javaHome="`dirname \"$javaExecutable\"`"
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
else
javaExecutable="`readlink -f \"$javaExecutable\"`"
fi
javaHome="`dirname \"$javaExecutable\"`"
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
JAVA_HOME="$javaHome"
export JAVA_HOME
fi
fi
fi
if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
else
JAVACMD="`which java`"
fi
fi
if [ ! -x "$JAVACMD" ] ; then
echo "Error: JAVA_HOME is not defined correctly." >&2
echo " We cannot execute $JAVACMD" >&2
exit 1
fi
if [ -z "$JAVA_HOME" ] ; then
echo "Warning: JAVA_HOME environment variable is not set."
fi
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
# traverses directory structure from process work directory to filesystem root
# first directory with .mvn subdirectory is considered project base directory
find_maven_basedir() {
if [ -z "$1" ]
then
echo "Path not specified to find_maven_basedir"
return 1
fi
basedir="$1"
wdir="$1"
while [ "$wdir" != '/' ] ; do
if [ -d "$wdir"/.mvn ] ; then
basedir=$wdir
break
fi
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
if [ -d "${wdir}" ]; then
wdir=`cd "$wdir/.."; pwd`
fi
# end of workaround
done
echo "${basedir}"
}
# concatenates all lines of a file
concat_lines() {
if [ -f "$1" ]; then
echo "$(tr -s '\n' ' ' < "$1")"
fi
}
BASE_DIR=`find_maven_basedir "$(pwd)"`
if [ -z "$BASE_DIR" ]; then
exit 1;
fi
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
echo $MAVEN_PROJECTBASEDIR
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --path --windows "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
fi
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
exec "$JAVACMD" \
$MAVEN_OPTS \
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"

143
mvnw.cmd vendored

@ -0,0 +1,143 @@
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM http://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Maven2 Start Up Batch script
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM M2_HOME - location of maven2's installed home dir
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@REM ----------------------------------------------------------------------------
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
:skipRcPre
@setlocal
set ERROR_CODE=0
@REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
echo.
echo Error: JAVA_HOME not found in your environment. >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init
echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
@REM ==== END VALIDATION ====
:init
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR%
:findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD%
goto findBaseDir
:baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%"
goto endDetectBaseDir
:baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%"
:endDetectBaseDir
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
@setlocal EnableExtensions EnableDelayedExpansion
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
:endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end
:error
set ERROR_CODE=1
:end
@endlocal & set ERROR_CODE=%ERROR_CODE%
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
@REM check for post script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
:skipRcPost
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%" == "on" pause
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
exit /B %ERROR_CODE%

@ -0,0 +1,380 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.pjb</groupId>
<artifactId>springboot-jjwt</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>springboot-jjwt</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.mybatis.spring.boot</groupId>-->
<!-- <artifactId>mybatis-spring-boot-starter</artifactId>-->
<!-- <version>1.3.2</version>-->
<!-- </dependency>-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.0.5</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.47</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc8</artifactId>
<version>12.2.0.1</version>
</dependency>
<dependency>
<groupId>teamcenter</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>teamcenter</groupId>
<artifactId>commons-logging</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>teamcenter</groupId>
<artifactId>fccclient</artifactId>
<version>12.3.0</version>
</dependency>
<dependency>
<groupId>teamcenter</groupId>
<artifactId>fscclient</artifactId>
<version>12.3.0</version>
</dependency>
<dependency>
<groupId>teamcenter</groupId>
<artifactId>httpclient</artifactId>
<version>12.3.0</version>
</dependency>
<dependency>
<groupId>teamcenter</groupId>
<artifactId>httpcore</artifactId>
<version>12.3.0</version>
</dependency>
<dependency>
<groupId>teamcenter</groupId>
<artifactId>httpmime</artifactId>
<version>12.3.0</version>
</dependency>
<dependency>
<groupId>teamcenter</groupId>
<artifactId>log4j</artifactId>
<version>12.3.0</version>
</dependency>
<dependency>
<groupId>teamcenter</groupId>
<artifactId>TcSoaAdministrationStrong</artifactId>
<version>12.3.0</version>
</dependency>
<dependency>
<groupId>teamcenter</groupId>
<artifactId>TcSoaAiStrong</artifactId>
<version>12.3.0</version>
</dependency>
<dependency>
<groupId>teamcenter</groupId>
<artifactId>TcSoaAllocationsStrong</artifactId>
<version>12.3.0</version>
</dependency>
<dependency>
<groupId>teamcenter</groupId>
<artifactId>TcSoaBomStrong</artifactId>
<version>12.3.0</version>
</dependency>
<dependency>
<groupId>teamcenter</groupId>
<artifactId>TcSoaBusinessModelerStrong</artifactId>
<version>12.3.0</version>
</dependency>
<dependency>
<groupId>teamcenter</groupId>
<artifactId>TcSoaCadBomAlignmentStrong</artifactId>
<version>12.3.0</version>
</dependency>
<dependency>
<groupId>teamcenter</groupId>
<artifactId>TcSoaCadStrong</artifactId>
<version>12.3.0</version>
</dependency>
<dependency>
<groupId>teamcenter</groupId>
<artifactId>TcSoaCaeStrong</artifactId>
<version>12.3.0</version>
</dependency>
<dependency>
<groupId>teamcenter</groupId>
<artifactId>TcSoaCalendarManagementStrong</artifactId>
<version>12.3.0</version>
</dependency>
<dependency>
<groupId>teamcenter</groupId>
<artifactId>TcSoaChangeManagementStrong</artifactId>
<version>12.3.0</version>
</dependency>
<dependency>
<groupId>teamcenter</groupId>
<artifactId>TcSoaClassificationStrong</artifactId>
<version>12.3.0</version>
</dependency>
<dependency>
<groupId>teamcenter</groupId>
<artifactId>TcSoaClient</artifactId>
<version>12.3.0</version>
</dependency>
<dependency>
<groupId>teamcenter</groupId>
<artifactId>TcSoaCommon</artifactId>
<version>12.3.0</version>
</dependency>
<dependency>
<groupId>teamcenter</groupId>
<artifactId>TcSoaConfigurationStrong</artifactId>
<version>12.3.0</version>
</dependency>
<dependency>
<groupId>teamcenter</groupId>
<artifactId>TcSoaCoreLoose</artifactId>
<version>12.3.0</version>
</dependency>
<dependency>
<groupId>teamcenter</groupId>
<artifactId>TcSoaCoreStrong</artifactId>
<version>12.3.0</version>
</dependency>
<dependency>
<groupId>teamcenter</groupId>
<artifactId>TcSoaDocumentManagementStrong</artifactId>
<version>12.3.0</version>
</dependency>
<dependency>
<groupId>teamcenter</groupId>
<artifactId>TcSoaImportExportStrong</artifactId>
<version>12.3.0</version>
</dependency>
<dependency>
<groupId>teamcenter</groupId>
<artifactId>TcSoaQueryStrong</artifactId>
<version>12.3.0</version>
</dependency>
<dependency>
<groupId>teamcenter</groupId>
<artifactId>TcSoaStrongModel</artifactId>
<version>12.3.0</version>
</dependency>
<dependency>
<groupId>teamcenter</groupId>
<artifactId>TcSoaWorkflowStrong</artifactId>
<version>12.3.0</version>
</dependency>
<dependency>
<groupId>teamcenter</groupId>
<artifactId>xercesImpl</artifactId>
<version>12.3.0</version>
</dependency>
<dependency>
<groupId>teamcenter</groupId>
<artifactId>xml-apis</artifactId>
<version>12.3.0</version>
</dependency>
<dependency>
<groupId>teamcenter</groupId>
<artifactId>TcSoaManufacturingStrong</artifactId>
<version>13.1.0</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.22</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.7.22</version>
</dependency>
<!-- JSONObject对象依赖的jar包 -->
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.3</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>net.sf.ezmorph</groupId>
<artifactId>ezmorph</artifactId>
<version>1.0.6</version>
</dependency>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.2.3</version>
<classifier>jdk15</classifier><!-- 指定jdk版本 -->
</dependency>
<!-- Json依赖架包下载 -->
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.14.2</version>
</dependency>
<dependency>
<groupId>net.lingala.zip4j</groupId>
<artifactId>zip4j</artifactId>
<version>2.9.1</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.9</version>
</dependency>
</dependencies>
<build>
<finalName>KH Interface Services v0.1</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.pjb.springbootjjwt.SpringbootJjwtApplication</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

@ -0,0 +1,39 @@
package com.pjb.springbootjjwt;
import com.teamcenter.clientx.AppXSession;
import com.teamcenter.soa.client.model.strong.User;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
@SpringBootApplication
@MapperScan("com.pjb.springbootjjwt.mapper")
public class SpringbootJjwtApplication {
public static String TC_URL;
public static String TC_USER;
public static String TC_PWD;
public static String TC_FMSURL;
public static String TC_FCCCACH;
public static String ADDRESS;
public static String CAD_EXE;
public static String CAD_PATH;
public static String READ_CAD_EXE;
public static String CHECK_CAD_EXE;
public static void main(String[] args) {
ConfigurableApplicationContext contenxt = SpringApplication.run(SpringbootJjwtApplication.class, args);
TC_URL = contenxt.getEnvironment().getProperty("teamcenter.url");
TC_USER = contenxt.getEnvironment().getProperty("teamcenter.user");
TC_PWD = contenxt.getEnvironment().getProperty("teamcenter.pwd");
TC_FMSURL = contenxt.getEnvironment().getProperty("teamcenter.fmsurl");
TC_FCCCACH = contenxt.getEnvironment().getProperty("teamcenter.fcccache");
ADDRESS = contenxt.getEnvironment().getProperty("teamcenter.address");
CAD_EXE = contenxt.getEnvironment().getProperty("teamcenter.cadexe");
CAD_PATH = contenxt.getEnvironment().getProperty("teamcenter.cadpath");
READ_CAD_EXE = contenxt.getEnvironment().getProperty("teamcenter.readcadexe");
CHECK_CAD_EXE = contenxt.getEnvironment().getProperty("teamcenter.checkcadexe");
}
}

@ -0,0 +1,415 @@
//package com.pjb.springbootjjwt;
//
//import cn.hutool.core.io.FileUtil;
//import cn.hutool.poi.excel.ExcelReader;
//import cn.hutool.poi.excel.ExcelUtil;
//import cn.hutool.poi.excel.ExcelWriter;
//import com.pjb.springbootjjwt.utils.*;
//import com.teamcenter.clientx.AppXSession;
//import com.teamcenter.services.loose.core._2006_03.FileManagement;
//import com.teamcenter.soa.client.FileManagementUtility;
//import com.teamcenter.soa.client.model.ModelObject;
//import com.teamcenter.soa.client.model.ServiceData;
//import com.teamcenter.soa.client.model.strong.Dataset;
//import org.apache.poi.ss.usermodel.*;
//
//import java.io.*;
//import java.text.DecimalFormat;
//import java.util.*;
//
//public class Test {
// private static AppXSession session = new AppXSession("http://DHRC:8085/tc");
// private static DecimalFormat decimalFormat = new DecimalFormat("00");
//
// public static void main(String[] args) {
//// String docMlMinId = "JZ-0044-2214-01";
//// String docMlPrefix = docMlMinId.substring(0, docMlMinId.lastIndexOf("-") + 1);
//// String docMlMinSuffix = docMlMinId.substring(docMlMinId.lastIndexOf("-") + 1);
//// System.out.println("前缀:" + docMlPrefix + ",后缀:" + docMlMinSuffix);
//// if (true)return;
////
//// String str = "{\"projectApprovalTime\":\"2023-05-09 10:04:03\",\"projectStar\":\"5星\",\"productLevel\":\"S+\",\"skuList\":[{\"matterCode\":\"BC063102045144\",\"mainImg\":\"new-plm.oss-cn-hangzhou.aliyuncs.com/c3a7d398721e4d859d6e0230403c00bf外观手板图.jpg\",\"spuName\":\"全新品立项-辅食的产品名称\",\"needPush\":false,\"endProduct\":\"1\",\"skuBarCode\":\"6942053811018\",\"supplierCode\":\"CO00049450\",\"tryOutUsers\":\"AL\",\"skuZxbz\":\"GB21\",\"expiryUnit\":\"9999\",\"isRelease\":false,\"expiryDate\":9999,\"tryOutSeason\":\"DD\",\"isIteration\":\"2\",\"skuContrabandByAir\":\"2\",\"skuMctn\":1,\"skuHeight\":1,\"skuCtn\":1,\"mainPic\":\"new-plm.oss-cn-hangzhou.aliyuncs.com/c3a7d398721e4d859d6e0230403c00bf外观手板图.jpg\",\"proofOrigin\":\"贵州省-黔东南苗族侗族自治州\",\"spuCode\":\"BC2305354\",\"minOrderNumber\":1,\"skuRWeight\":1.0,\"tryOutSex\":\"AL\",\"skuRP\":1.0,\"skuUnit\":\"PN\",\"brandCode\":\"001\",\"productionCycle\":2,\"supplierName\":\"广东青艺智造文化有限公司\",\"skuRowHeight\":1,\"skuLength\":1,\"normsName\":\"111\",\"categoryCode\":\"310204\",\"skuColor\":\"11\",\"skuBP\":1.0,\"skuWidth\":1,\"skuBoxLength\":1,\"goodsType\":\"CP\",\"skuBoxWidth\":1,\"skuBoxHeight\":1,\"size\":\"1\",\"goodsStatus\":\"03\",\"skuRowLength\":1,\"isIncludeFreight\":\"2\",\"skuRowWidth\":1,\"skuWeight\":1.0}],\"projectManagerName\":\"刘紫倩-L5435\",\"projectManagerId\":\"L5435\",\"categoryOperateId\":\"L4718\",\"projectName\":\"20230509001--全新品-杨驰-标品--均已填1\",\"projectId\":\"BC202305223\",\"categoryOperateName\":\"吴正邦\"}";
////
////
////
//// System.out.println(str);
////
//// JSONObject obj = new JSONObject();
//// String[] dd = {"t1","t2"};
//// obj.put("mx",dd);
//// JSONArray array = obj.getJSONArray("mx");
//// for (Object a : array) {
//// String str1 = (String) a;
//// System.out.println("mx>" + str1);
//// }
//
//
// try {
//// String number = "JZ-5114-05";
//// int count = 3;
//// DecimalFormat df = new DecimalFormat("00");
//// String prefix = number.substring(0, number.lastIndexOf("-") + 1);
//// String num = number.substring(number.lastIndexOf("-") + 1, number.length());
//// int lastNum = Integer.valueOf(num) + count - 1;
//// System.out.println(prefix + "(" + num + "-" + df.format(lastNum) + ")");
//
//// File file = new File("C:\\Users\\upaad\\Desktop\\113.xlsx");
//// File outFile = new File("C:\\Users\\upaad\\Desktop\\outFile-" + file.getName());
//// File cppyFile = copyFile(file);
//// byte[] pictureData = FileUtil.readBytes("C:\\Users\\upaad\\Desktop\\公司图标.png");
//// ExcelReader reader = ExcelUtil.getReader(cppyFile);
//// ExcelWriter writer = ExcelUtils.getWriter(reader);
//// Workbook workbook = reader.getWorkbook();
//// Sheet sheet = reader.getSheet();
//// CellReference ref = ExcelUtils.findCellByName(workbook, sheet, "测试2");
////// System.out.println("row=" + ref.getRow() + "col=" + ref.getCol());
////// ExcelUtils.writePic(writer, ref.getCol(),ref.getRow(), pictureData, HSSFWorkbook.PICTURE_TYPE_JPEG);
//// int col =ref.getCol();
//// int row =ref.getRow();
////// col++;
//// row++;
//// writer.writeCellValue(col,row, "1111");
//// writer.setDestFile(outFile);
//// if (writer != null) writer.close();
//// if (reader != null) reader.close();
//// cppyFile.delete();
//
//// startCadexe("","");
//// System.out.println("运行结束111");
//
// File outFile = new File("C:\\Users\\upaad\\Desktop\\工艺流程图1.xlsx");
// ExcelReader reader = ExcelUtil.getReader(outFile);
// ExcelWriter writer = ExcelUtils.getWriter(reader);
//
//
// }catch (Exception e) {
// e.printStackTrace();
// LogUtil.info(e.getMessage());
// }
//
//// if (true) {
//// return;
//// }
//
//// int len = 5;
//// int onePage = 19;
//// int i = 0;
//// int max = onePage;
//// int count = len / onePage;
////// if(count >= 0 && len % onePage != 0) count = count + 1;
//// if ((len - onePage * i) / onePage == 0) max = len - onePage * i;
//// System.out.println(max);
////
//// if(count >= 0 && len % onePage != 0) count = count + 1;
//// if ((len - onePage * i) / onePage == 0) max = len - onePage * i;
//
//// session.login("gengj", "123", "test");
// try {
//
//// int num = 0;
//// do {
//// long size1 = 1064;
//// long size = 1064;
//// if (size == size1) System.out.println("相同");
//// else break;
//// num++;
//// } while (num < 10);
//// System.out.println("结束");
//// String bh = "JZCQ926-6023-01";
//// for (int i = 0; i < 8; i++) {
//// bh = getNewCode(bh, i);
//// LogUtil.info("新编号:" + bh);
//// }
//// setSqlLsh(bh);
//
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// private static String getNewCode(String code, int num) {
// String prefix = code.substring(0, code.lastIndexOf("-") + 1);
// int add = num == 0 ? 0 : 1;
// Integer number = Integer.valueOf(code.substring(code.lastIndexOf("-") + 1)) + add;
// String newCode = getNewCode(prefix + decimalFormat.format(number));
// return newCode;
// }
//
// private static String getNewCode(String code) {
// String newCode = code;
// boolean flag = queryDatasetByCode(code);
// if (flag) {
// String prefix = code.substring(0, code.lastIndexOf("-") + 1);
// Integer number = Integer.valueOf(code.substring(code.lastIndexOf("-") + 1));
// newCode = getNewCode(prefix + decimalFormat.format(number + 1));
// }
// return newCode;
// }
//
// private static boolean queryDatasetByCode(String code) {
// if(!code.endsWith("03")) return false;
// return true;
// }
//
// private static void setSqlLsh(String code) {
// String prefix = code.substring(0, code.lastIndexOf("-") + 1);
// Integer number = Integer.valueOf(code.substring(code.lastIndexOf("-") + 1));
// String lshstr = decimalFormat.format(number);
// String lsh = "";
// if (!CommonlyUtils.isEmpty(lsh)) {
// int ls = Integer.parseInt(lsh);
// if (number > ls) System.out.println("前缀" + prefix + ",设置最新流水号:" + lshstr);
// } else System.out.println("前缀" + prefix + ",新增流水号:" + lshstr);
// }
//
// public static File copyFile (File file1) throws IOException {
// String pathSufix = file1.getParent();
// String fileName = file1.getName();
// File file2 = new File(pathSufix + "\\" + 1 + "-" + fileName);
// FileUtil.copyFile(file1,file2);
// return file2;
// }
//
//
// public static String checkFileName(String name) {
// return name.replaceAll("/","_")
// .replaceAll("\\|","_")
// .replaceAll("\\\\","_")
// .replaceAll("\"","_")
// .replaceAll(":","_")
// .replaceAll("\\*","_")
// .replaceAll("\\?","_")
// .replaceAll("<","_")
// .replaceAll(">","_");
// }
//
// private static String handleXH(String xh) {
// String newXh = "";
// if (!CommonlyUtils.isEmpty(xh)) {
// if (xh.contains("/")) {
// newXh = xh.split("/")[0];
// } else if (xh.contains("\\")) {
// newXh = xh.split("\\\\")[0];
// } else {
// newXh = xh;
// }
// }
// return newXh;
// }
//
// private static void sortList(List<String> list) {
// Collections.sort(list, new Comparator<String>() {
//
// @Override
// public int compare(String lbjth1, String lbjth2) {
// try {
// if (lbjth1.contains("-B-") && lbjth2.contains("-L-")) return 1;
// else if (lbjth1.contains("-L-") && lbjth2.contains("-B-")) return -1;
// else if (lbjth1.contains("-W-") && lbjth2.contains("-B-")) return 1;
// else if (lbjth1.contains("-B-") && lbjth2.contains("-W-")) return -1;
// else if (lbjth1.contains("-W-") && lbjth2.contains("-L-")) return 1;
// else if (lbjth1.contains("-L-") && lbjth2.contains("-W-")) return -1;
// if (lbjth1.compareTo(lbjth2) >= 0) {
// return 1;
// } else {
// return -1;
// }
// } catch (NumberFormatException e2) {
// return -1;
// }
// }
// });
// }
//
// private static void waitUpdat(File file) throws InterruptedException {
// long lastModifiedDate = file.lastModified();
// while (true) {
// if (lastModifiedDate != file.lastModified()) {
// System.out.println("文件最后修改时间:" + file.lastModified() + ",已修改!");
// break;
// }
// System.out.println("文件最后修改时间:" + lastModifiedDate + ",未修改!");
// Thread.sleep(1000);
// }
// }
//
// private static String readTxtValue(File txtFile) {
// cn.hutool.core.io.file.FileReader reader = new cn.hutool.core.io.file.FileReader(txtFile);
// List<String> list = reader.readLines();
// for (String str : list) {
//// System.out.println(str);
// }
// if (CommonlyUtils.isEmptyList(list)) return "";
// else return list.get(0);
//
// }
//
// private static void createFIle() throws IOException {
// String cmdStr = "CALL";
// FileWriter writer = null;
// String now = CommonlyUtils.getNowDate();
// String filePath2 = "D:\\fcccache\\outFile" + now + ".bat";
// File data = new File(filePath2);
// data.createNewFile();
// writer = new FileWriter(filePath2);
// writer.write(cmdStr);
// writer.close();
// }
//
//
//
// private static void testfile() throws Exception {
// ModelObject object = TCUtils.getItemByPuid(session,"QXMAAYrsLZJleA");
// File file = new File("C:\\Users\\upaad\\Desktop\\大和石英PLM验收遗留问题沟通_202211(1).xlsx");
// updateDatasetSingleFile(session,(Dataset) object,file,
// "excel");
// }
//
// private static void startCadexe(String filePath,String configPath) throws IOException {
//// LogUtil.info(CreateOperationCardServiceImpl.class,"签名文件地址>>" + filePath + ",配置信息地址>>" + configPath);
//// String cmdStr = "C:\\Users\\upaad\\Desktop\\Desktop\\acad_process.exe" + " " + filePath + " " + configPath;
//// Process process = Runtime.getRuntime().exec("cmd /c " + cmdStr);
//// BufferedReader input = new BufferedReader(new InputStreamReader(process.getErrorStream(), "UTF-8"));
//// String line = null;
//// while ((line = input.readLine()) != null) {
//// System.out.println(line);
//// }
//// String newCmd="start /d D:\\Siemens\\Teamcenter12\\portal\\plugins/wait acad2pdf.exe dwgfile=C:\\Users\\upaad\\AppData\\Local\\Temp\\2022112210594704006847.dwg.dwg signtype=text pdfout=true model=pdf txtFile=C:\\Users\\upaad\\AppData\\Local\\Temp\\2022112210594704006847.txt.txt";
//// Process process = Runtime.getRuntime().exec("cmd /c " + newCmd);
//// BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream(), "GBK"));
//// String line = null;
//// while ((line = input.readLine()) != null) {
//// System.out.println(line);
//// }
//// BufferedReader input2 = new BufferedReader(new InputStreamReader(pr.getErrorStream(), "GBK"));
//// String line2 = null;
//// while ((line2 = input2.readLine()) != null) {
//// System.out.println(line2);
//// }
//
// String cmdStr = "call " + "\"C:\\Users\\upaad\\Desktop\\test.jar\"";
// LogUtil.info(CreateDocServiceImpl.class, "命令>>" + cmdStr);
// FileWriter writer = null;
// String now = CommonlyUtils.getNowDate2();
// String filePath1 = "C:\\Users\\upaad\\Desktop\\test-20231103142626184.bat";
//// String filePath1 = "C:\\Users\\upaad\\Desktop\\test-" + now + ".bat";
//// File data = new File(filePath1);
//// data.createNewFile();
//// writer = new FileWriter(filePath1);
//// writer.write(cmdStr);
//// writer.close();
// try {
//// Process process = Runtime.getRuntime().exec(filePath1);
//// process.waitFor();
// long l = 29000;
// new Thread(new Runnable() {
// @Override
// public void run() {
// int num = 0;
// while (num < 29) {
// System.out.println("当前" + num + "等待1秒");
// num++;
// try {
// Thread.sleep(1000);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// }
// }
// }).start();
// ProcessUtils.executeProcess(filePath1, l);
// } catch (Exception e) {
// e.printStackTrace();
// }
//
// }
//
// public static Boolean updateDatasetSingleFile(AppXSession session, Dataset dataset, File file,
// String reference) throws Exception {
// if (CommonlyUtils.isEmpty(dataset)) return null;
// TCUtils.setModelObjectValue(session, dataset, "ref_list");
// ModelObject[] objects = dataset.get_ref_list();
// TCUtils.setModelObjectValue(session, objects[0], "original_file_name");
// String filename = objects[0].getPropertyObject("original_file_name").getStringValue();
// file = new File(TCUtils.changeFileName(file,filename));
// FileManagementUtility fMSFileManagement = new FileManagementUtility(session.getConnection(),
// null,
// new String[]{"http://DHRC:4544"},
// new String[]{"http://DHRC:4544"},
// "D:/fcccache");
// FileManagement.DatasetFileInfo fileInfo = new FileManagement.DatasetFileInfo();
// fileInfo.fileName = file.getAbsolutePath();
// fileInfo.namedReferencedName = reference;
// fileInfo.isText = false;
// fileInfo.allowReplace = true;
// FileManagement.GetDatasetWriteTicketsInputData input = new FileManagement.GetDatasetWriteTicketsInputData();
// input.dataset = dataset;
// input.createNewVersion = false;
// input.datasetFileInfos = new FileManagement.DatasetFileInfo[]{fileInfo};
// ServiceData serviceData = fMSFileManagement.putFiles(new FileManagement.GetDatasetWriteTicketsInputData[]{input});
//
// TCUtils.checkPartialErrors(serviceData);
// return true;
// }
//
// private static void testExcel() {
// File file = new File("C:\\Users\\upaad\\Desktop\\ccx.xlsx");
// String now = CommonlyUtils.getNowDate();
// File outFile = new File( "C:\\Users\\upaad\\Desktop\\outFile" + now + ".xlsx");
// ExcelReader reader = ExcelUtil.getReader(file);
// ExcelWriter writer = reader.getWriter();
// try{
// Workbook workbook = reader.getWorkbook();
// String loc = getCellLocation(workbook,"value1");
// writer.writeCellValue(loc,"按照单元格名称设置属性");
// writer.setDestFile(outFile);
// } finally {
// if (writer != null) writer.close();
// if (reader != null) reader.close();
//// file.delete();
// }
// }
//
//
// private static String getCellLocation(Workbook workbook, String cellName){
// Name name = workbook.getName(cellName);
// String formula = name.getRefersToFormula();
// String[] values = formula.split("!")[1].split("\\$");
// String loc = "";
// for (String value : values) {
// loc = loc + value;
// }
// return loc;
// }
//
// private static List<ConfigInfo> loadBjxmConfig() throws IOException {
// String json = CommonlyUtils.loadJson("C:/123/BjxmCreate.json");
// return CommonlyUtils.jsonToObj(json);
// }
//
// private static void test() throws Exception {
//// ModelObject object = TCUtils.getItemByPuid(session,"gZGAAY6HLZJleA");
//// File file = new File("C:\\Users\\upaad\\Desktop\\大和石英新材料CRM接口开发计划v2.xlsx");
//// System.out.println(file.getAbsolutePath());
//// TCUtils.createNewDatasetAndUploadSingleFile(session,object,"QZ2khtzgx",file,
//// "数据集创建测试","MSExcelX","MSExcel","excel");
//
//
// List<CYProcess> list = new ArrayList<>();
// CYProcess cyProcess = new CYProcess();
// cyProcess.setLbjth("JZ21-1115-001");
// cyProcess.setLbjName("1");
// CYProcess cyProcess2 = new CYProcess();
// cyProcess2.setLbjth("JZ21-1115-001");
// cyProcess2.setLbjName("2");
// CYProcess cyProcess3 = new CYProcess();
// cyProcess3.setLbjth("JZ21-1115-001");
// cyProcess3.setLbjName("3");
// list.add(cyProcess);
// list.add(cyProcess2);
// list.add(cyProcess3);
// CommonlyUtils.sortList(list,"lbjth");
// list.forEach(item-> System.out.println(item.getLbjName()));
//
// }
//}

@ -0,0 +1,38 @@
package com.pjb.springbootjjwt.annotation;
import cn.hutool.core.date.DatePattern;
import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* @description:
* @param: * @param null
* @return:
* @author: Jiay
* @date: 2022-5-25 13:26
*/
@Documented
@Constraint(validatedBy = com.pjb.springbootjjwt.annotation.DateTimeValueValidator .class)
@Target({ElementType.FIELD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
public @interface DateTimeValue {
String message() default "日期时间格式不正确,正确格式应为" + DatePattern.NORM_DATETIME_PATTERN;
String pattern() default DatePattern.NORM_DATETIME_PATTERN;
Class[] groups() default {};
Class<? extends Payload>[] payload() default {};
@Target({ElementType.FIELD, ElementType.PARAMETER})
@Retention(RUNTIME)
@Documented
@interface List {
com.pjb.springbootjjwt.annotation.DateTimeValue[] value();
}
}

@ -0,0 +1,44 @@
package com.pjb.springbootjjwt.annotation;
import cn.hutool.core.util.StrUtil;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
/**
* @description:
* @param: * @param null
* @return:
* @author: Jiay
* @date: 2022-5-25 13:04
*/
public class DateTimeValueValidator implements ConstraintValidator<DateTimeValue, String> {
private String pattern;
@Override
public void initialize(DateTimeValue dateTimeValue) {
this.pattern = dateTimeValue.pattern();
}
@Override
public boolean isValid(String dateTimeValue, ConstraintValidatorContext context) {
//为空则放过,因为在此校验之前会加入@NotNull或@NotBlank校验
if (StrUtil.isBlank(dateTimeValue)) {
return true;
}
//长度不对直接返回
if (dateTimeValue.length() != pattern.length()) {
return false;
}
try {
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(pattern);
LocalDateTime.parse(dateTimeValue, dateTimeFormatter);
return true;
} catch (Exception e) {
return false;
}
}
}

@ -0,0 +1,13 @@
package com.pjb.springbootjjwt.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface PassToken {
boolean required() default true;
}

@ -0,0 +1,13 @@
package com.pjb.springbootjjwt.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface UserLoginToken {
boolean required() default true;
}

@ -0,0 +1,44 @@
/*============================================================================================================
File description:
Filename: KH_SendJCBZ_To_MES.cxx
Module :
KHom006-MES
MESTCTC
============================================================================================================
DATE Name Description of Change
2024-04-12 liujb Creation
$HISTORY$
2024-04-12 liujb Modify
============================================================================================================*/
package com.pjb.springbootjjwt.api;
import com.pjb.springbootjjwt.entity.ProductDrawingInput;
import com.pjb.springbootjjwt.entity.Result;
import com.pjb.springbootjjwt.entity.input.CompletenessInput;
import com.pjb.springbootjjwt.service.MesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class MesController {
@Autowired
MesService service;
@PostMapping("/GetProductDrawing")
@ResponseBody
public Object getProductDrawing(@RequestBody ProductDrawingInput productDrawingInput){
Result result = service.getProductDrawingInfo(productDrawingInput);
return result;
}
@PostMapping("/Completeness")
@ResponseBody
public Object getCompleteness(@RequestBody CompletenessInput completenessInput){
Result result = service.getCompletenessInfo(completenessInput);
return result;
}
}

@ -0,0 +1,22 @@
package com.pjb.springbootjjwt.api;
import com.pjb.springbootjjwt.entity.ImportWFDatasetInput;
import com.pjb.springbootjjwt.entity.ResultOa;
import com.pjb.springbootjjwt.service.OaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class OaController {
@Autowired
OaService service;
@PostMapping("/ImportWFDataset")
@ResponseBody
public Object importWFDataset(@RequestBody ImportWFDatasetInput importWFDatasetInput){
ResultOa result = service.importWFDataset(importWFDatasetInput);
return result;
}
}

@ -0,0 +1,23 @@
package com.pjb.springbootjjwt.config;
import com.pjb.springbootjjwt.interceptor.AuthenticationInterceptor;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(authenticationInterceptor())
.addPathPatterns("/**"); // 拦截所有请求,通过判断是否有 @LoginRequired 注解 决定是否需要登录
}
@Bean
public AuthenticationInterceptor authenticationInterceptor() {
return new AuthenticationInterceptor();
}
}

@ -0,0 +1,23 @@
package com.pjb.springbootjjwt.config;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
@Configuration
public class JsonConfig {
@Bean
public MappingJackson2HttpMessageConverter mappingJacksonHttpMessageConverter() {
final MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
ObjectMapper mapper = converter.getObjectMapper();
// 为mapper注册一个带有SerializerModifier的Factory此modifier主要做的事情为当序列化类型为arraylist、set时当值为空时序列化成[]
mapper.setSerializerFactory(mapper.getSerializerFactory().withSerializerModifier(new MyBeanSerializerModifier()));
return converter;
}
}

@ -0,0 +1,38 @@
package com.pjb.springbootjjwt.config;
import com.fasterxml.jackson.databind.BeanDescription;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializationConfig;
import com.fasterxml.jackson.databind.ser.BeanPropertyWriter;
import com.fasterxml.jackson.databind.ser.BeanSerializerModifier;
import java.util.List;
import java.util.Set;
public class MyBeanSerializerModifier extends BeanSerializerModifier {
// 字符串等类型
private JsonSerializer _nullJsonSerializer = new MyNullJsonSerializer();
@Override
public List<BeanPropertyWriter> changeProperties(SerializationConfig config, BeanDescription beanDesc,
List beanProperties) {
//循环所有的beanPropertyWriter
for (int i = 0; i < beanProperties.size(); i++) {
BeanPropertyWriter writer = (BeanPropertyWriter) beanProperties.get(i);
//判断字段的类型如果是arraylistset则注册nullSerializer
if (isArrayType(writer)) {;
} else {
writer.assignNullSerializer(this._nullJsonSerializer);
}
}
return beanProperties;
}
//判断是什么类型
protected boolean isArrayType(BeanPropertyWriter writer) {
Class clazz = writer.getPropertyType();
return clazz.isArray() || clazz.equals(List.class) || clazz.equals(Set.class);
}
}

@ -0,0 +1,17 @@
package com.pjb.springbootjjwt.config;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import java.io.IOException;
public class MyNullJsonSerializer extends JsonSerializer {
@Override
public void serialize(Object o, JsonGenerator jsonGenerator, SerializerProvider serializerProvider)
throws IOException, JsonProcessingException {
jsonGenerator.writeString("");
}
}

@ -0,0 +1,10 @@
package com.pjb.springbootjjwt.config;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration //说明这是一个配置类
@EnableSwagger2// 该注解开启Swagger2的自动配置
public class SwaggerConfig {
}

@ -0,0 +1,20 @@
package com.pjb.springbootjjwt.constant;
public interface ConfigeType {
public static final String BJXM_ITEM = "BJXM_ITEM";
public static final String BJXM_REV = "BJXM_REV";
public static final String BJXM_REV_MASTER = "BJXM_REV_MASTER";
public static final String XJXXD_ITEM = "XJXXD_ITEM";
public static final String XJXXD_REV = "XJXXD_REV";
public static final String XJXXD_REV_MASTER = "XJXXD_REV_MASTER";
public static final String BJBGD_ITEM = "BJBGD_ITEM";
public static final String BJBGD_REV = "BJBGD_REV";
public static final String BJBGD_REV_MASTER = "BJBGD_REV_MASTER";
public static final String NPI = "NPI";
public static final String ARRAYS = "ARRAYS";
public static final String STRING = "STRING";
}

@ -0,0 +1,13 @@
package com.pjb.springbootjjwt.constant;
public interface Type {
public static final String TOOL_CAD = "LB2_CAD";
public static final String TOOL_EXCEL = "MSExcel";
public static final String FILETYPE_CAD = "LB2_CAD";
public static final String FILETYPE_EXCEL = "MSExcelX";
public static final String REFERENCE_CAD = "LB2_dwg";
public static final String REFERENCE_EXCEL = "excel";
}

@ -0,0 +1,9 @@
package com.pjb.springbootjjwt.entity;
import lombok.Data;
@Data
public class ClassProperties {
int ID; //分类属性ID
String value; //分类属性值
}

@ -0,0 +1,24 @@
package com.pjb.springbootjjwt.entity;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
@Data
public class CompletenessInfo {
@JsonProperty
@JSONField(name="PartID")
String PartID;
@JsonProperty
@JSONField(name="PartRevID")
String PartRevID;
@JsonProperty
@JSONField(name="DrawingID")
String DrawingID;
@JsonProperty
@JSONField(name="DrawingRev")
String DrawingRev;
@JsonProperty
@JSONField(name="GXno")
String GXno;
}

@ -0,0 +1,16 @@
package com.pjb.springbootjjwt.entity;
import lombok.Data;
import java.util.List;
@Data
public class ConfigInfo {
String key;
String tcname;
String type;
String defaultValue;
String propType;
String value;
List<String> objs;
}

@ -0,0 +1,21 @@
package com.pjb.springbootjjwt.entity;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
@Data
public class ImportWFDatasetInput {
@JsonProperty
@JSONField(name="WFuid")
String WFuid;
@JsonProperty
@JSONField(name="docid")
String docid;
@JsonProperty
@JSONField(name="docrevid")
String docrevid;
@JsonProperty
@JSONField(name="url")
String url;
}

@ -0,0 +1,30 @@
package com.pjb.springbootjjwt.entity;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
@Data
public class ProductDrawingInfo {
@JsonProperty
@JSONField(name="PartID")
String PartID;
@JsonProperty
@JSONField(name="PartRevID")
String PartRevID;
@JsonProperty
@JSONField(name="DrawingID")
String DrawingID;
@JsonProperty
@JSONField(name="DrawingRev")
String DrawingRev;
@JsonProperty
@JSONField(name="File")
String File;
@JsonProperty
@JSONField(name="File2")
String File2;
@JsonProperty
@JSONField(name="File3")
String File3;
}

@ -0,0 +1,18 @@
package com.pjb.springbootjjwt.entity;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
@Data
public class ProductDrawingInput {
@JsonProperty
@JSONField(name="PartID")
String PartID;
@JsonProperty
@JSONField(name="GXNo")
String GXNo;
@JsonProperty
@JSONField(name="DrawingRev")
String DrawingRev;
}

@ -0,0 +1,12 @@
package com.pjb.springbootjjwt.entity;
import lombok.Data;
@Data
public class Result {
// String msg;
// int success;
String code;
String message;
Object data;
}

@ -0,0 +1,13 @@
package com.pjb.springbootjjwt.entity;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
@Data
public class ResultOa {
String Status;
@JsonProperty
@JSONField(name="message")
String message;
}

@ -0,0 +1,15 @@
package com.pjb.springbootjjwt.entity;
import com.teamcenter.soa.client.model.ModelObject;
import com.teamcenter.soa.client.model.strong.ItemRevision;
import lombok.Data;
import java.util.List;
@Data
public class SearchResult {
String msg;
ModelObject[] objs;
ModelObject obj;
List<ItemRevision> revlist;
}

@ -0,0 +1,15 @@
package com.pjb.springbootjjwt.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class User {
String app_secret;
String username;
String password;
}

@ -0,0 +1,13 @@
package com.pjb.springbootjjwt.entity;
import com.teamcenter.soa.client.model.ModelObject;
import lombok.Data;
import java.util.List;
@Data
public class WorkflowInfo {
String workflowName;
String workflowTempName;
List<ModelObject> workflowTargets;
}

@ -0,0 +1,8 @@
package com.pjb.springbootjjwt.entity.input;
import lombok.Data;
@Data
public class CheckDocInput {
String last_mod_date01;
}

@ -0,0 +1,14 @@
package com.pjb.springbootjjwt.entity.input;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.util.List;
@Data
public class CompletenessInput {
@JsonProperty
@JSONField(name="PartID")
List<String> PartID;
}

@ -0,0 +1,14 @@
package com.pjb.springbootjjwt.exception;
import com.pjb.springbootjjwt.utils.LogUtil;
public class SoaException extends Exception{
private String message;
public SoaException(String message){
super(message);
this.message = message;
LogUtil.error(SoaException.class,this);
}
}

@ -0,0 +1,13 @@
package com.pjb.springbootjjwt.exception;
import com.pjb.springbootjjwt.utils.LogUtil;
public class SuccessException extends Exception{
private String message;
public SuccessException(String message){
super(message);
this.message = message;
LogUtil.error(SoaException.class,this);
}
}

@ -0,0 +1,81 @@
package com.pjb.springbootjjwt.interceptor;
import com.auth0.jwt.JWT;
import com.auth0.jwt.JWTVerifier;
import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.exceptions.JWTDecodeException;
import com.auth0.jwt.exceptions.JWTVerificationException;
import com.pjb.springbootjjwt.annotation.PassToken;
import com.pjb.springbootjjwt.annotation.UserLoginToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Method;
public class AuthenticationInterceptor implements HandlerInterceptor {
// @Autowired
// UserService userService;
@Override
public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object object) throws Exception {
String token = httpServletRequest.getHeader("access_token");// 从 http 请求头中取出 token
// 如果不是映射到方法直接通过
if(!(object instanceof HandlerMethod)){
return true;
}
HandlerMethod handlerMethod=(HandlerMethod)object;
Method method=handlerMethod.getMethod();
//检查是否有passtoken注释有则跳过认证
if (method.isAnnotationPresent(PassToken.class)) {
PassToken passToken = method.getAnnotation(PassToken.class);
if (passToken.required()) {
return true;
}
}
//检查有没有需要用户权限的注解
if (method.isAnnotationPresent(UserLoginToken.class)) {
UserLoginToken userLoginToken = method.getAnnotation(UserLoginToken.class);
if (userLoginToken.required()) {
// 执行认证
if (token == null) {
throw new RuntimeException("无token请重新登录");
}
// 获取 token 中的 user id
String userId;
try {
userId = JWT.decode(token).getAudience().get(0);
} catch (JWTDecodeException j) {
throw new RuntimeException("token验证失败");
}
// User user = userService.findUserById(userId);
// if (user == null) {
// throw new RuntimeException("用户不存在,请重新登录");
// }
// // 验证 token
// JWTVerifier jwtVerifier = JWT.require(Algorithm.HMAC256(user.getPassword())).build();
// try {
// jwtVerifier.verify(token);
// } catch (JWTVerificationException e) {
// throw new RuntimeException("token验证失败");
// }
return true;
}
}
return true;
}
@Override
public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception {
}
@Override
public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {
}
}

@ -0,0 +1,99 @@
package com.pjb.springbootjjwt.interceptor;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.pjb.springbootjjwt.entity.Result;
import com.pjb.springbootjjwt.exception.SoaException;
import com.pjb.springbootjjwt.exception.SuccessException;
import com.pjb.springbootjjwt.utils.ResultUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.BindingResult;
import org.springframework.validation.ObjectError;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
@Slf4j
@ControllerAdvice
public class GloablExceptionHandler {
@ResponseBody
@ExceptionHandler(Exception.class)
public Object handleException(Exception e) {
String msg = e.getMessage();
if (msg == null || msg.equals("")) {
msg = "服务器出错";
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("message", msg);
return ResultUtils.errorResult(msg);
// return jsonObject;
}
@ResponseBody
@ExceptionHandler(SoaException.class)
public Result handleSoaException(Exception e) {
String msg = e.getMessage();
if (msg == null || msg.equals("")) {
msg = "服务器出错";
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("message", msg);
return ResultUtils.successResult(msg);
}
@ResponseBody
@ExceptionHandler(SuccessException.class)
public Result handleSucException(Exception e) {
String msg = e.getMessage();
if (msg == null || msg.equals("")) {
msg = "服务器出错";
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("message", msg);
return ResultUtils.errorResult(msg);
}
/**
* @description: validation Exception
* @param: [exception]
* @return: com.pjb.springbootjjwt.entity.Result
* @author: Jiay
* @date: 2022-5-25 11:23
*/
@ExceptionHandler({ MethodArgumentNotValidException.class })
@ResponseBody
public Result handleBodyValidException(MethodArgumentNotValidException exception) {
String argNotValidMessage = getArgNotValidMessage(exception.getBindingResult());
log.error("MethodArgumentNotValidException " + argNotValidMessage);
return ResultUtils.errorResult(argNotValidMessage);
}
/**
* @description: ,
* @param: [bindingResult]
* @return: java.lang.String
* @author: Jiay
* @date: 2022-5-25 11:22
*/
private String getArgNotValidMessage(BindingResult bindingResult) {
if (bindingResult == null) {
return "";
}
StringBuilder stringBuilder = new StringBuilder();
//多个错误用逗号分隔
List<ObjectError> allErrorInfos = bindingResult.getAllErrors();
for (ObjectError error : allErrorInfos) {
stringBuilder.append(",").append(error.getDefaultMessage());
}
//最终把首部的逗号去掉
return StrUtil.removePrefix(stringBuilder.toString(), ",");
}
}

@ -0,0 +1,22 @@
package com.pjb.springbootjjwt.mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import javax.xml.crypto.Data;
import java.util.Date;
@Repository
public interface MesMapper {
int insertKH_LOG(@Param("no") String no,
@Param("desc") String desc,
@Param("provider") String provider,
@Param("caller") String caller,
@Param("itemid") String itemid,
@Param("revid") String revid,
@Param("result") String result,
@Param("in") String in,
@Param("out") String out,
@Param("time") String time);
}

@ -0,0 +1,13 @@
package com.pjb.springbootjjwt.service;
import com.pjb.springbootjjwt.entity.ProductDrawingInfo;
import com.pjb.springbootjjwt.entity.ProductDrawingInput;
import com.pjb.springbootjjwt.entity.Result;
import com.pjb.springbootjjwt.entity.input.CompletenessInput;
import java.util.List;
public interface MesService {
Result getProductDrawingInfo(ProductDrawingInput productDrawingInput);
Result getCompletenessInfo(CompletenessInput completenessInput);
}

@ -0,0 +1,8 @@
package com.pjb.springbootjjwt.service;
import com.pjb.springbootjjwt.entity.ImportWFDatasetInput;
import com.pjb.springbootjjwt.entity.ResultOa;
public interface OaService {
ResultOa importWFDataset (ImportWFDatasetInput importWFDatasetInput);
}

@ -0,0 +1,539 @@
/*============================================================================================================
File description:
Filename: ProductDrawingServiceImpl.java
Module :
KHom006-MES
MESTCTC
============================================================================================================
DATE Name Description of Change
2024-04-12 liujb Creation
$HISTORY$
2024-04-12 liujb Modify
============================================================================================================*/
package com.pjb.springbootjjwt.service.impl;
import com.alibaba.fastjson.JSON;
import com.pjb.springbootjjwt.entity.CompletenessInfo;
import com.pjb.springbootjjwt.entity.ProductDrawingInfo;
import com.pjb.springbootjjwt.entity.ProductDrawingInput;
import com.pjb.springbootjjwt.entity.Result;
import com.pjb.springbootjjwt.entity.input.CompletenessInput;
import com.pjb.springbootjjwt.mapper.MesMapper;
import com.pjb.springbootjjwt.service.MesService;
import com.pjb.springbootjjwt.utils.LogUtil;
import com.pjb.springbootjjwt.utils.ResultUtils;
import com.pjb.springbootjjwt.utils.TCUtils;
import com.teamcenter.clientx.AppXSession;
import com.teamcenter.clientx.Query;
import com.teamcenter.soa.client.model.ModelObject;
import com.teamcenter.soa.client.model.Property;
import com.teamcenter.soa.client.model.strong.Item;
import com.teamcenter.soa.client.model.strong.ItemRevision;
import com.teamcenter.soa.client.model.strong.MEProcessRevision;
import com.teamcenter.soa.exceptions.NotLoadedException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.*;
@Service
public class MesServiceImpl implements MesService {
@Autowired
MesMapper productDrawingMapper;
private final static String KH_FILTER_STATUS = "KH_Filter_Status"; //过滤状态首选项
/**
* KHom005-MES
* MESTCTC
*/
@Override
public Result getProductDrawingInfo(ProductDrawingInput productDrawingInput) {
Result result = new Result();
String log_result[] = {""};
AppXSession session = null;
try {
TCUtils.login();
session = TCUtils.getSession();
TCUtils.setByPass(session, true);
String partID = productDrawingInput.getPartID();
String gxNO = productDrawingInput.getGXNo();
String drawingRev = productDrawingInput.getDrawingRev();
if(!partID.isEmpty()){
if( !gxNO.isEmpty()) {
if(!drawingRev.isEmpty()){
result = getGyDrawing(session,partID,gxNO,result,log_result,drawingRev);
}else{
result = getGyDrawing(session,partID,gxNO,result,log_result,null);
}
}else{
System.out.println("Has gxNO");
if(!drawingRev.isEmpty()){
result = getProductDrawing(session,partID,result,log_result,drawingRev);
}else{
result = getProductDrawing(session,partID,result,log_result,null);
}
}
}
}catch (Exception e) {
e.printStackTrace();
LogUtil.error(MesServiceImpl.class, e);
return ResultUtils.errorResult(e);
} finally {
try {
TCUtils.setByPass(session, false);
} catch (Exception e) {
e.printStackTrace();
LogUtil.error(MesServiceImpl.class, e);
}
System.out.println("log_result[0]:"+log_result[0]);
productDrawingMapper.insertKH_LOG("MES002","产品图纸接口","PLM","MES","","",log_result[0],JSON.toJSONString(productDrawingInput),JSON.toJSONString(result),new SimpleDateFormat("yyyy/MM/dd hh:mm:ss").format(new Date()));
TCUtils.logoutUser(session);
}
return result;
}
/**
*
* @param session
* @param partID
* @param result
* @param log_result
* @return
*/
private Result getGyDrawing(AppXSession session, String partID,String gxNO, Result result, String[] log_result, String drawingRevId) throws Exception {
String[] Key = {"零组件 ID"};
// String[] Key = {"Item ID"};
String[] Values = {partID};
// ModelObject[] modelObjects = Query.queryItems("零组件...", Key, Values);
ModelObject[] modelObjects = Query.queryItems("Item...", Key, Values);
if(modelObjects == null || modelObjects.length == 0){
//存在第一次查询为空的情况
modelObjects = Query.queryItems("Item...", Key, Values);
if(modelObjects == null || modelObjects.length == 0){
result = ResultUtils.errorResult("物料不存在");
log_result[0] = "失败";
return result;
}
}
//过滤发布状态
String[] preferences = TCUtils.getPreferenceValue(session, KH_FILTER_STATUS);
ItemRevision partItemRev = null;
// if(drawingRev!=null){
// partItemRev = TCUtils.getRevisionReleasedByRevID(session, modelObjects[0],drawingRev);
// }else{
partItemRev = TCUtils.getRevisionReleased_Filter(session, modelObjects[0],preferences);
// }
if(partItemRev == null){
result = ResultUtils.errorResult("此物料最新版本未发布,无法提供图纸信息");
log_result[0] = "失败";
return result;
}else{
ProductDrawingInfo info = new ProductDrawingInfo();
TCUtils.setModelObjectValue(session, new ModelObject[]{partItemRev}, new String[]{"item_id", "item_revision_id" ,"TC_Is_Represented_By"});
String partItemRevID = partItemRev.getPropertyDisplayableValue("item_revision_id");
String partItemID = partItemRev.getPropertyDisplayableValue("item_id");
info.setPartID(partItemID);
info.setPartRevID(partItemRevID);
//获取工艺
List<ModelObject> meProcessRevisions = TCUtils.getWhereReference(session, partItemRev, "IMAN_METarget", "MEProcessRevision", 1);
System.out.println("meProcessRevisions.size():"+meProcessRevisions.size());
if(meProcessRevisions != null && meProcessRevisions.size() != 0 ){
MEProcessRevision meProcessRevision = (MEProcessRevision) meProcessRevisions.get(0);
Item items_tag = meProcessRevision.get_items_tag();
ItemRevision meProcessRevisionReleased = TCUtils.getRevisionReleased(session, items_tag);
// ModelObject[] bomLineByWork = TCUtils.getBomLineByWork(session, meProcessRevisionReleased);
ModelObject[] bomLines = TCUtils.getBomLine(session, meProcessRevisionReleased);
System.out.println("bomLines.size():"+bomLines.length);
if(bomLines != null &&bomLines.length != 0){
boolean existGxNO = false;
for(int i =0; i < bomLines.length ; i++){
TCUtils.setModelObjectValue(session,bomLines[i],"mfg0realRevision");
Property mfg0realRevision = bomLines[i].getPropertyObject("mfg0realRevision");
ModelObject modelObjectValue = mfg0realRevision.getModelObjectValue();
TCUtils.setModelObjectValue(session,modelObjectValue,"IMAN_reference");
ModelObject[] iman_references = modelObjectValue.getPropertyObject("IMAN_reference").getModelObjectArrayValue();
System.out.println("iman_references.size():"+iman_references.length);
if(iman_references != null && iman_references.length != 0){
ItemRevision revisionReleased_filter = TCUtils.getRevisionReleased_Filter(session, iman_references[0], preferences);
Item drawingItem = ((ItemRevision) revisionReleased_filter).get_items_tag();
ItemRevision drawningItemRev = null;
if(drawingRevId != null){
drawningItemRev = TCUtils.getRevisionReleasedByRevID(session, drawingItem,drawingRevId);
}
else{
drawningItemRev = (ItemRevision) revisionReleased_filter;
}
if(drawningItemRev == null){
result = ResultUtils.errorResult("此物料最新版本未发布,无法提供图纸信息");
log_result[0] = "失败";
return result;
}
TCUtils.setModelObjectValue(session,drawningItemRev,new String[]{"item_id","item_revision_id","IMAN_specification"});
String gxtz_item_id = drawningItemRev.getPropertyDisplayableValue("item_id");
String gxtz_item_revision_id = drawningItemRev.getPropertyDisplayableValue("item_revision_id");
String gxseq = bomLines[i].getPropertyDisplayableValue("bl_sequence_no");
System.out.println("gxtz_item_id:"+gxtz_item_id);
System.out.println("gxtz_item_revision_id:"+gxtz_item_revision_id);
System.out.println("gxseq:"+gxseq);
if(gxNO.contains(gxseq)){
existGxNO = true;
List<String> filePathList = TCUtils.getFileByFMS(session, drawningItemRev, "IMAN_specification",gxtz_item_id , gxtz_item_revision_id);
String filePathString = "";
for(String filePath : filePathList){
if(filePathString.length() != 0){
filePathString += "|";
}
filePathString += filePath;
}
info.setDrawingID(gxtz_item_id);
info.setDrawingRev(gxtz_item_revision_id);
info.setFile(filePathString);
info.setFile2("");
info.setFile3("");
result.setData(JSON.toJSON(info));
result = ResultUtils.successResult(info);
log_result[0]= "成功";
}
}
}
if(!existGxNO){
result = ResultUtils.errorResult("此物料无工序图纸");
log_result[0] = "失败";
}
}
}
}
return result;
}
/**
*
* @param session
* @param partID
* @param result
* @param log_result
* @return
* @throws Exception
*/
private Result getProductDrawing(AppXSession session,String partID,Result result,String log_result[],String drawingRevId) throws Exception {
String[] Key = {"零组件 ID"};
// String[] Key = {"Item ID"};
String[] Values = {partID};
// ModelObject[] modelObjects = Query.queryItems("零组件...", Key, Values);
ModelObject[] modelObjects = Query.queryItems("Item...", Key, Values);
if(modelObjects == null || modelObjects.length == 0){
//存在第一次查询为空的情况
modelObjects = Query.queryItems("Item...", Key, Values);
if(modelObjects == null || modelObjects.length == 0){
result = ResultUtils.errorResult("物料不存在");
log_result[0] = "失败";
return result;
}
}
ItemRevision partItemRev = null;
// if(drawingRev != null){
// partItemRev = TCUtils.getRevisionReleasedByRevID(session, modelObjects[0],drawingRev);
// }
// else{
//过滤发布状态
String[] preferences = TCUtils.getPreferenceValue(session, KH_FILTER_STATUS);
partItemRev = TCUtils.getRevisionReleased_Filter(session, modelObjects[0],preferences);
// }
if(partItemRev == null){
result = ResultUtils.errorResult("此物料最新版本未发布,无法提供图纸信息");
log_result[0] = "失败";
return result;
}else{
ProductDrawingInfo info = new ProductDrawingInfo();
TCUtils.setModelObjectValue(session, new ModelObject[]{partItemRev}, new String[]{"item_id", "item_revision_id" ,"TC_Is_Represented_By"});
String partItemRevID = partItemRev.getPropertyDisplayableValue("item_revision_id");
String partItemID = partItemRev.getPropertyDisplayableValue("item_id");
info.setPartID(partItemID);
info.setPartRevID(partItemRevID);
Property tc_is_represented_by = partItemRev.getPropertyObject("TC_Is_Represented_By");
ModelObject[] drawningItemRevs = tc_is_represented_by.getModelObjectArrayValue();
if(drawningItemRevs != null && drawningItemRevs.length != 0 ){
Item drawingItem = ((ItemRevision) drawningItemRevs[0]).get_items_tag();
ItemRevision revisionReleased_filter = TCUtils.getRevisionReleased_Filter(session, drawingItem, preferences);
TCUtils.setModelObjectValue(session, new ModelObject[]{drawningItemRevs[0]}, new String[]{"item_id", "item_revision_id" ,"IMAN_specification","EC_affected_item_rel"});
ItemRevision drawningItemRev = null;
if(drawingRevId != null){
drawningItemRev = TCUtils.getRevisionReleasedByRevID(session, drawingItem,drawingRevId);
}
else{
drawningItemRev = (ItemRevision) revisionReleased_filter;
}
if(drawningItemRev == null){
result = ResultUtils.errorResult("此物料最新版本未发布,无法提供图纸信息");
log_result[0] = "失败";
return result;
}
String drawingItemID = drawningItemRev.getPropertyDisplayableValue("item_id");
String drawingItemRevID = drawningItemRev.getPropertyDisplayableValue("item_revision_id");
List<String> filePathList = TCUtils.getFileByFMS(session, drawningItemRev, "IMAN_specification",drawingItemID , drawingItemRevID);
String filePathString = "";
for(String filePath : filePathList){
if(filePathString.length() != 0){
filePathString += "|";
}
filePathString += filePath;
}
//获取客户图纸 file2
String file2PathString = "";
List<String> file2PathList = TCUtils.getFolderFileByFMS(session, drawningItemRev, "KH3_CustomerDraw");//KH3_CustomerDraw EC_affected_item_rel
for(String file2Path : file2PathList){
if(file2PathString.length() != 0){
file2PathString += "|";
}
file2PathString += file2Path;
}
// ModelObject[] customerDrawnings = drawningItemRevs[0].getPropertyObject("EC_affected_item_rel").getModelObjectArrayValue();
// if(customerDrawnings != null && customerDrawnings.length != 0){
// TCUtils.setModelObjectValue(session, customerDrawnings, new String[]{"object_type"});
// for(ModelObject customerDrawning : customerDrawnings){
// if(customerDrawning.getPropertyDisplayableValue("object_type").endsWith("PDF")){
// System.out.println("true");
// }else{
//
// System.out.println("false");
// }
// }
// }
//获取外发图 flie3
String file3PathString = "";
// String twDrawingItemId = drawingItemID.replace("TC","TW");
ModelObject[] twDrawings = Query.queryItems("外发图纸对象查询V1.0", new String[]{"设计图ID"}, new String[]{drawingItemID});
if(twDrawings != null && twDrawings.length != 0){
for(ModelObject twDrawing : twDrawings) {
ItemRevision twDrawingRev = TCUtils.getRevisionReleased(session, twDrawing);
if(twDrawingRev != null){
TCUtils.setModelObjectValue(session, new ModelObject[]{twDrawingRev}, new String[]{"item_id", "item_revision_id" ,"IMAN_specification"});
String twDrawingItemID = twDrawingRev.getPropertyDisplayableValue("item_id");
String twDrawingItemRevID = twDrawingRev.getPropertyDisplayableValue("item_revision_id");
List<String> file3PathList = TCUtils.getFileByFMS(session, twDrawingRev, "IMAN_specification",twDrawingItemID , twDrawingItemRevID);
for(String file3Path : file3PathList){
if(file3PathString.length() != 0){
file3PathString += "|";
}
file3PathString += file3Path;
}
}
}
}
info.setDrawingID(drawingItemID);
info.setDrawingRev(drawingItemRevID);
info.setFile(filePathString);
info.setFile2(file2PathString);
info.setFile3(file3PathString);
result.setData(JSON.toJSON(info));
}
result = ResultUtils.successResult(info);
log_result[0]= "成功";
}
return result;
}
/**
* KHom006-MES
* MESTCTC
*/
@Override
public Result getCompletenessInfo(CompletenessInput completenessInput) {
Result result = new Result();
String log_result = "";
AppXSession session = null;
try {
TCUtils.login();
session = TCUtils.getSession();
TCUtils.setByPass(session, true);
List<ModelObject> allMoList = new ArrayList<>();
List<String> partIds = completenessInput.getPartID();
for(String partId :partIds ){
String[] Key = {"零组件 ID"};
// String[] Key = {"Item ID"};
String[] Values = {partId};
// ModelObject[] modelObjects = Query.queryItems("零组件...", Key, Values);
ModelObject[] modelObjects = Query.queryItems("Item...", Key, Values);
List<ModelObject> moList= Arrays.asList(modelObjects);
allMoList.addAll(moList);
}
if(allMoList == null || allMoList.size() == 0){
result = ResultUtils.errorResult("物料不存在");
log_result = "失败";
return result;
}
//正常物料
List<ModelObject> normalMoList = new ArrayList<>();
//异常物料
List<ModelObject> unnormalMoList = new ArrayList<>();
//过滤发布状态
// String[] preferences = {"TC 基线"};
String[] preferences = TCUtils.getPreferenceValue(session, KH_FILTER_STATUS);
for(ModelObject mo : allMoList){
ItemRevision partItemRev = TCUtils.getRevisionReleased_Filter(session, mo, preferences);
TCUtils.setModelObjectValue(session, new ModelObject[]{partItemRev}, new String[]{"item_id", "item_revision_id" ,"TC_Is_Represented_By"});
if(partItemRev == null){
unnormalMoList.add(mo);
// return result;
}else{
normalMoList.add(partItemRev);
}
}
List<CompletenessInfo> infoList = new ArrayList<CompletenessInfo>();
if(unnormalMoList.size() != 0 ){
StringBuilder msgBuilder = new StringBuilder();// result = ResultUtils.errorResult("<"+partItemID+">此物料最新版本未发布,无法提供图纸信息");
for(ModelObject unnormalMo : unnormalMoList){
if(msgBuilder.length() != 0 ){
msgBuilder.append(",");
}
TCUtils.setModelObjectValue(session, new ModelObject[]{unnormalMo}, new String[]{"item_id"});
String partItemID = unnormalMo.getPropertyDisplayableValue("item_id");
msgBuilder.append("<");
msgBuilder.append(partItemID);
msgBuilder.append(">");
}
msgBuilder.append("物料最新版本未发布,无法提供图纸信息");
log_result = "失败";
result = ResultUtils.errorResult(msgBuilder.toString());
return result;
}else{
for(ModelObject partItemRev : normalMoList){
CompletenessInfo productDrawinginfo = new CompletenessInfo();
String partItemRevID = partItemRev.getPropertyDisplayableValue("item_revision_id");
String partItemID = partItemRev.getPropertyDisplayableValue("item_id");
productDrawinginfo.setPartID(partItemID);
productDrawinginfo.setPartRevID(partItemRevID);
Property tc_is_represented_by = partItemRev.getPropertyObject("TC_Is_Represented_By");
ModelObject[] drawningItemRevs = tc_is_represented_by.getModelObjectArrayValue();
//制造目标下的图纸
if(drawningItemRevs != null && drawningItemRevs.length != 0 ){
TCUtils.setModelObjectValue(session, new ModelObject[]{drawningItemRevs[0]}, new String[]{"item_id", "item_revision_id" ,"IMAN_specification"});
String drawingItemID = drawningItemRevs[0].getPropertyDisplayableValue("item_id");
String drawingItemRevID = drawningItemRevs[0].getPropertyDisplayableValue("item_revision_id");
productDrawinginfo.setDrawingID(drawingItemID);
productDrawinginfo.setDrawingRev(drawingItemRevID);
infoList.add(productDrawinginfo);
}
//获取工艺
List<ModelObject> meProcessRevisions = TCUtils.getWhereReference(session, partItemRev, "IMAN_METarget", "MEProcessRevision", 1);
if(meProcessRevisions != null && meProcessRevisions.size() != 0 ){
MEProcessRevision meProcessRevision = (MEProcessRevision) meProcessRevisions.get(0);
Item items_tag = meProcessRevision.get_items_tag();
ItemRevision meProcessRevisionReleased = TCUtils.getRevisionReleased(session, items_tag);
// ModelObject[] bomLineByWork = TCUtils.getBomLineByWork(session, meProcessRevisionReleased);
ModelObject[] bomLines = TCUtils.getBomLine(session, meProcessRevisionReleased);
if(bomLines != null &&bomLines.length != 0){
for(int i =0; i < bomLines.length ; i++){
TCUtils.setModelObjectValue(session,bomLines[i],"mfg0realRevision");
Property mfg0realRevision = bomLines[i].getPropertyObject("mfg0realRevision");
ModelObject modelObjectValue = mfg0realRevision.getModelObjectValue();
TCUtils.setModelObjectValue(session,modelObjectValue,"IMAN_reference");
ModelObject[] iman_references = modelObjectValue.getPropertyObject("IMAN_reference").getModelObjectArrayValue();
if(iman_references != null && iman_references.length != 0){
ItemRevision revisionReleased_filter = TCUtils.getRevisionReleased_Filter(session, iman_references[0], preferences);
if(revisionReleased_filter == null){
break;
}
CompletenessInfo gxDrawinginfo = new CompletenessInfo();
gxDrawinginfo.setPartID(partItemID);
gxDrawinginfo.setPartRevID(partItemRevID);
TCUtils.setModelObjectValue(session,revisionReleased_filter,new String[]{"item_id","item_revision_id"});
String gxtz_item_id = revisionReleased_filter.getPropertyDisplayableValue("item_id");
String gxtz_item_revision_id = revisionReleased_filter.getPropertyDisplayableValue("item_revision_id");
String gxno = bomLines[i].getPropertyDisplayableValue("bl_sequence_no");
gxDrawinginfo.setDrawingID(gxtz_item_id);
gxDrawinginfo.setDrawingRev(gxtz_item_revision_id);
gxDrawinginfo.setGXno(gxno);
infoList.add(gxDrawinginfo);
System.out.println();
}
}
}
}
}
if(infoList.size() != 0){
result = ResultUtils.successResult(infoList);
log_result = "成功";
}else{
result = ResultUtils.errorResult("此物料产品图纸和工序图纸都不存在");
log_result = "失败";
}
}
}catch (Exception e) {
e.printStackTrace();
LogUtil.error(MesServiceImpl.class, e);
return ResultUtils.errorResult(e);
} finally {
try {
TCUtils.setByPass(session, false);
} catch (Exception e) {
e.printStackTrace();
LogUtil.error(MesServiceImpl.class, e);
}
productDrawingMapper.insertKH_LOG("MES004","产品图纸信息接口","PLM","MES","","",log_result,JSON.toJSONString(completenessInput),JSON.toJSONString(result),new SimpleDateFormat("yyyy/MM/dd hh:mm:ss").format(new Date()));
TCUtils.logoutUser(session);
}
return result;
}
public ProductDrawingInfo getProductDrawingInfoByPartID() {
return null;
}
}

@ -0,0 +1,223 @@
package com.pjb.springbootjjwt.service.impl;
import com.alibaba.fastjson.JSON;
import com.pjb.springbootjjwt.SpringbootJjwtApplication;
import com.pjb.springbootjjwt.entity.ImportWFDatasetInput;
import com.pjb.springbootjjwt.entity.ResultOa;
import com.pjb.springbootjjwt.mapper.MesMapper;
import com.pjb.springbootjjwt.service.OaService;
import com.pjb.springbootjjwt.utils.HttpUtils;
import com.pjb.springbootjjwt.utils.LogUtil;
import com.pjb.springbootjjwt.utils.ResultUtils;
import com.pjb.springbootjjwt.utils.TCUtils;
import com.teamcenter.clientx.AppXSession;
import com.teamcenter.services.strong.workflow.WorkflowService;
import com.teamcenter.services.strong.workflow._2014_06.Workflow;
import com.teamcenter.soa.client.model.ModelObject;
import com.teamcenter.soa.client.model.ServiceData;
import com.teamcenter.soa.client.model.strong.Dataset;
import com.teamcenter.soa.client.model.strong.EPMTask;
import com.teamcenter.soa.client.model.strong.ItemRevision;
import com.teamcenter.soa.client.model.strong.POM_system_class;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Service;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Service
public class OaServiceImpl implements OaService {
@Autowired
MesMapper productDrawingMapper;
@Override
public ResultOa importWFDataset(ImportWFDatasetInput importWFDatasetInput) {
ResultOa result = new ResultOa();
String log_result = "";
//入参验证
result = validation(importWFDatasetInput);
if(result.getStatus() == "F"){
return result;
}
AppXSession session = null;
try {
TCUtils.login();
session = TCUtils.getSession();
TCUtils.setByPass(session, true);
ModelObject epmMo= TCUtils.getItemByUID(session,importWFDatasetInput.getWFuid() );//"QPrZ0aRDY8MSRC"
//是否为流程任务
if(!(epmMo instanceof EPMTask)){
log_result = "失败";
result = ResultUtils.errorResultOa("无效TC流程UID");
return result;
}
TCUtils.setModelObjectValue(session,epmMo,"root_target_attachments");
ModelObject[] root_target_attachments = ((EPMTask) epmMo).get_root_target_attachments();
//目标版本
ItemRevision targetRev = null;
for(ModelObject root_target_attachment : root_target_attachments){
if(root_target_attachment instanceof ItemRevision){
TCUtils.setModelObjectValue(session,root_target_attachment,new String[]{"item_id","item_revision_id"});
String item_id = ((ItemRevision) root_target_attachment).get_item_id();
String item_revision_id = ((ItemRevision) root_target_attachment).get_item_revision_id();
if(importWFDatasetInput.getDocid().equals(item_id) && importWFDatasetInput.getDocrevid().equals(item_revision_id)){
targetRev = (ItemRevision) root_target_attachment;
}
}
}
if(targetRev == null){
log_result = "失败";
result = ResultUtils.errorResultOa("无效目标版本!");
return result;
}
//获取URL文件
List<File> files = new ArrayList<File>();
String urls[] = importWFDatasetInput.getUrl().split("\\|");
if(urls != null && urls.length != 0) {
for (String url : urls) {
// File file = HttpUtils.downloadFile(url, "D:\\DKFile\\DownLoad");
File file = HttpUtils.downloadFile(url, SpringbootJjwtApplication.TC_FCCCACH);
if (file != null) {
files.add(file);
} else {
log_result = "失败";
result = ResultUtils.errorResultOa("文件下载异常!");
return result;
}
}
}
//创建数据集附加到版本下
for(File file : files){
String fileType = null;
String[] split = file.getName().split("\\.");
if("xlsx".equals(split[1])){
fileType = "MSExcelX";
}
if("xls".equals(split[1])){
fileType = "MSExcel";
}
if(fileType != null){
//目标版本下是否包含附加数据集
ModelObject old_tc_attache = null;
TCUtils.setModelObjectValue(session,targetRev,"TC_Attaches");
ModelObject[] tc_attaches = targetRev.get_TC_Attaches();
if(tc_attaches != null && tc_attaches.length != 0){
for(ModelObject tc_attache : tc_attaches){
if(tc_attache instanceof Dataset){
TCUtils.setModelObjectValue(session,tc_attache,"object_name");
String tc_attache_name = ((Dataset)tc_attache).get_object_name();
if(file.getName().equals(tc_attache_name)){
old_tc_attache = tc_attache;
}
}
}
}
//存在移除关系
if(old_tc_attache != null){
TCUtils.removeRelation(targetRev,old_tc_attache,"TC_Attaches");
}
Dataset dataset = TCUtils.createNewDatasetAndUploadSingleFile(session, targetRev, "TC_Attaches", file, file.getName(), fileType, "MSExcel", "excel");
if(dataset == null){
log_result = "失败";
result = ResultUtils.errorResultOa("数据集创建异常!");
return result;
}else {
//获取版本所有者
POM_system_class owning_user = targetRev.get_owning_user();
//更改所有权
TCUtils.changeOwnershipModelObject(session, owning_user, dataset);
}
}
else{
log_result = "失败";
result = ResultUtils.errorResultOa("不支持的文件类型:"+file.getName());
return result;
}
}
//提升流程 fnd0StartedTasks
EPMTask[] fnd0StartedTasks = ((EPMTask) epmMo).get_fnd0StartedTasks();
if(fnd0StartedTasks != null && fnd0StartedTasks.length != 0){
EPMTask fnd0StartedTask = fnd0StartedTasks[0];
WorkflowService wfService = WorkflowService.getService(session.getConnection());
Workflow.PerformActionInputInfo[] performActionInputInfos = new Workflow.PerformActionInputInfo[1];
Workflow.PerformActionInputInfo performActionInputInfo = new Workflow.PerformActionInputInfo();
performActionInputInfo.action = "SOA_EPM_promote_action";
performActionInputInfo.actionableObject = fnd0StartedTask;
performActionInputInfos[0] = performActionInputInfo;
ServiceData serviceData = wfService.performAction3(performActionInputInfos);
if(serviceData.sizeOfPlainObjects() != 1){
log_result = "失败";
result = ResultUtils.errorResultOa("流程提升失败!");
}else
{
log_result = "成功";
result = ResultUtils.successResultOa("成功!");
}
}else{
log_result = "失败";
result = ResultUtils.errorResultOa("流程提升失败!");
}
}catch (Exception e) {
e.printStackTrace();
LogUtil.error(MesServiceImpl.class, e);
log_result = "失败";
return ResultUtils.errorResultOa(e);
} finally {
try {
TCUtils.setByPass(session, false);
} catch (Exception e) {
e.printStackTrace();
LogUtil.error(MesServiceImpl.class, e);
}
productDrawingMapper.insertKH_LOG("OA002","OA-PLM流程接口","PLM","OA","","",log_result, JSON.toJSONString(importWFDatasetInput),JSON.toJSONString(result),new SimpleDateFormat("yyyy/MM/dd hh:mm:ss").format(new Date()));
TCUtils.logoutUser(session);
return result;
}
}
private ResultOa validation(ImportWFDatasetInput importWFDatasetInput) {
ResultOa result = new ResultOa();
StringBuilder errs = new StringBuilder();
if(importWFDatasetInput == null){
result = ResultUtils.errorResultOa("无效Body");
return result;
}
if(importWFDatasetInput.getWFuid() == null || importWFDatasetInput.getWFuid().trim().isEmpty()){
errs.append("无效TC流程UID");
}
if(importWFDatasetInput.getDocid() == null || importWFDatasetInput.getDocid().trim().isEmpty()){
if(errs.length() != 0){
errs.append(";");
}
errs.append("无效文档ID");
}
if(importWFDatasetInput.getDocrevid() == null || importWFDatasetInput.getDocrevid().trim().isEmpty()){
if(errs.length() != 0){
errs.append(";");
}
errs.append("无效文档版本号");
}
if(importWFDatasetInput.getUrl() == null || importWFDatasetInput.getUrl().trim().isEmpty()){
if(errs.length() != 0){
errs.append(";");
}
errs.append("无效文件链接");
}
if(errs.length() != 0){
result = ResultUtils.errorResultOa(errs.toString());
}
return result;
}
}

@ -0,0 +1,46 @@
//public class DemoTest {
// /***
// * 自定义设置单元格样式**
// * @param writer hutool-Excel写入器*
// * @param x x_坐标*
// * @param y y_坐标*
// * @param index 背景色***/
// private static void setCellStyle(ExcelWriter writer, int x, int y, short index) {
// CellStyle cellStyle = writer.createCellStyle(x, y);
// // 填充背景色
// cellStyle.setFillForegroundColor(index);
// cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);// 解决填充背景色没有边框问题
// cellStyle.setBorderBottom(BorderStyle.THIN);
// cellStyle.setBorderTop(BorderStyle.THIN);
// cellStyle.setBorderRight(BorderStyle.THIN);
// cellStyle.setBorderLeft(BorderStyle.THIN);}
// public static void main(String[] args) {
// // 构造测试数据
// SapTaxResultTest sapTaxResultTest1 = new SapTaxResultTest("12321432", "发票1", "562.45", "3412354", "1");
// SapTaxResultTest sapTaxResultTest2 = new SapTaxResultTest("12321432", "发票2", "562.45", "3412354", "2");
// SapTaxResultTest sapTaxResultTest3 = new SapTaxResultTest("12321432", "发票3", "562.45", "3412354", "1");
// SapTaxResultTest sapTaxResultTest4 = new SapTaxResultTest("12321432", "发票4", "562.45", "3412354", "1");
// SapTaxResultTest sapTaxResultTest5 = new SapTaxResultTest("12321432", "发票5", "562.45", "3412354", "2");
// List<SapTaxResultTest> list = CollUtil.newArrayList(sapTaxResultTest1, sapTaxResultTest2, sapTaxResultTest3, sapTaxResultTest4, sapTaxResultTest5);
// BigExcelWriter writer = ExcelUtil.getBigWriter("C:/Users/Administrator/Desktop/bzbm/test" + RandomUtil.randomNumbers(2) + ".xlsx", "test表");
// // 是否写入表头
// writer.write(list, true);// 获取表格有多少列
// int rowSize = writer.getColumnCount();// 遍历数据行,设置单元格样式
// for (int i = 1; i <= list.size(); i++) {
// Row row = writer.getOrCreateRow(i);// 假设 resultFlag 列的索引为
// String resultFlag = row.getCell(4).getStringCellValue();
// if ("1".equals(resultFlag)) {// 设置行背景颜色
// for (int j = 0; j < rowSize; j++) {
// setCellStyle(writer, j, i, IndexedColors.RED.getIndex());
// }
// }
// } else if ("2".equals(resultFlag))
// {// 设置行背景颜色
// for (int j = 0; j < rowSize; j++) {
// setCellStyle(writer, j, i, IndexedColors.YELLOW.getIndex());
// }
// }}// 关闭 writer 以释放内存
// writer.close();}
//}
// }
// }

@ -0,0 +1,253 @@
package com.pjb.springbootjjwt.utils;
import com.alibaba.fastjson.JSONObject;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import com.pjb.springbootjjwt.entity.ConfigInfo;
import com.teamcenter.soa.client.model.ModelObject;
import java.io.*;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
public class CommonlyUtils {
public static SimpleDateFormat sdf = new SimpleDateFormat ( "yyyy-MM-dd HH:mm:ss" );
public static SimpleDateFormat sdf2 = new SimpleDateFormat ( "yyyy-MM-dd HH:mm" );
public static SimpleDateFormat fileNameSDF = new SimpleDateFormat ( "yyyyMMddHHmmss" );
public static SimpleDateFormat fileNameSDF2 = new SimpleDateFormat ( "yyyyMMddHHmmssSSS" );
public static SimpleDateFormat sdf_en = new SimpleDateFormat("d-MMM-yyyy HH:mm", Locale.ENGLISH);
static {
sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
fileNameSDF.setTimeZone(TimeZone.getTimeZone("GMT+8"));
}
public static String getNowDate(){
return fileNameSDF.format(new Date());
}
public static String getNowDate2(){
return fileNameSDF2.format(new Date());
}
public static boolean isEmpty(String str){
if (str != null && str.length() > 0){
return false;
}
return true;
}
public static boolean isEmptyArray(Object[] str){
if (str != null && str.length > 0){
return false;
}
return true;
}
public static boolean isEmpty(ModelObject[] objs) {
if (objs != null && objs.length > 0) {
return false;
}
return true;
}
public static boolean isEmpty(ModelObject obj){
if (obj != null){
return false;
}
return true;
}
public static <T> boolean isEmpty(T t){
if (t != null){
return false;
}
return true;
}
public static <T> boolean isEmptyMap(Map<T,T> objMap){
if (objMap != null && objMap.size() > 0){
return false;
}
return true;
}
public static <T> boolean isEmptyList(List<T> objectList){
if (objectList != null && objectList.size() > 0){
return false;
}
return true;
}
public static Long strToDateLong(String str) throws ParseException {
if (str.isEmpty()) {
return null;
}
Date date = CommonlyUtils.sdf.parse(str);
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
Long timestamp = calendar.getTimeInMillis();
return timestamp;
}
//中文日期格式转英文日期格式TC查询构建器日期需要用英文的
public static String toEnTime(String str) throws ParseException {
if (isEmpty(str)){
return null;
}
return sdf_en.format(sdf.parse(str));
}
//获取list的长度
public static int getLen(List list) {
if (list == null || list.size() == 0)
return 0;
else
return list.size();
}
public static int getLen(Object[] objs) {
if (objs == null || objs.length == 0)
return 0;
else
return objs.length;
}
//两数相乘
public static String MultiplyNumbers(String arg0, String arg1) {
BigDecimal decimal0 = new BigDecimal(arg0);
BigDecimal decimal1 = new BigDecimal(arg1);
return decimal0.multiply(decimal1).toString();
}
public static String MultiplyNumbers(int arg0, String arg1) {
BigDecimal decimal0 = new BigDecimal(arg0);
BigDecimal decimal1 = new BigDecimal(arg1);
return decimal0.multiply(decimal1).toString();
}
public static String loadJson(String path) throws IOException {
InputStream inputStream = new FileInputStream(new File(path));
Reader reader = new InputStreamReader(inputStream, "gbk");
int ch = 0;
StringBuffer sb = new StringBuffer();
while ((ch = reader.read()) != -1) {
sb.append((char) ch);
}
reader.close();
return sb.toString();
}
public static List<ConfigInfo> jsonToObj(String str) {
Gson gson = new Gson();
Type type =new TypeToken<List<ConfigInfo>>() {}.getType();
return gson.fromJson(str,type);
}
public static <T> String getEntityValue(T t, String str) {
String value = null;
if (CommonlyUtils.isEmpty(str)) return null;
String name = str.substring(0, 1).toUpperCase() + str.substring(1);
try {
Method m = t.getClass().getMethod("get" + name);
value = (String) m.invoke(t);
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return value;
}
public static void recordJson(Object obj,String str) {
String json = JSONObject.toJSONString(obj);
LogUtil.info(CommonlyUtils.class,str + json);
}
/**
* map
*
* @param map
* @return
*/
public static Object getFirstOrNullByMap(Map<Object, Object> map) {
Object obj = null;
for (Map.Entry<Object, Object> entry : map.entrySet()) {
obj = entry.getValue();
if (obj != null) break;
}
return obj;
}
/**
*
* @param list
* @param str
* @param <T>
*/
public static <T> void sortList(List<T> list, String str) throws Exception {
if (CommonlyUtils.isEmpty(str)) throw new Exception("字段名称为空!");
Collections.sort(list, new Comparator<T>() {
@Override
public int compare(T t1, T t2) {
try {
String v1 = CommonlyUtils.getEntityValue(t1,str);
String v2 = CommonlyUtils.getEntityValue(t2,str);
if (v1.compareTo(v2) >= 0) {
return 1;
} else {
return -1;
}
} catch (NumberFormatException e2) {
return -1;
}
}
});
}
//记录json数据
// public static void recordJson(HttpServletRequest request) {
// Gson gson = new Gson();
// StringBuffer sbJson = new StringBuffer();
// String type = request.getContentType();
// Map<String,Object> receiveMap = new HashMap<String,Object>();
// if("application/x-www-form-urlencoded".equals(type)){
// Enumeration<String> enu = request.getParameterNames();
// while (enu.hasMoreElements()) {
// String key = String.valueOf(enu.nextElement());
// String value = request.getParameter(key);
// receiveMap.put(key, value);
// sbJson.append("key>" + ",value>" + value);
// }
// }else{ //else是text/plain、application/json这两种情况
// BufferedReader reader = null;
// StringBuilder sb = new StringBuilder();
// try{
// reader = new BufferedReader(new InputStreamReader(request.getInputStream(), "utf-8"));
// String line = null;
// while ((line = reader.readLine()) != null){
// sb.append(line);
// }
// } catch (IOException e){
// e.printStackTrace();
// } finally {
// try{
// if (null != reader){
// reader.close();
// }
// } catch (IOException e){
// e.printStackTrace();
// }
// }
// receiveMap = gson.fromJson(sb.toString(), new TypeToken<Map<String, String>>(){}.getType());//把JSON字符串转为对象
// }
// LogUtil.info(CommonlyUtils.class,sbJson.toString());
// }
}

@ -0,0 +1,79 @@
package com.pjb.springbootjjwt.utils;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelWriter;
import cn.hutool.poi.excel.StyleSet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.AreaReference;
import org.apache.poi.ss.util.CellReference;
import java.io.Writer;
public class ExcelUtils {
public static String getCellLocation(Workbook workbook, String cellName){
Name name = workbook.getName(cellName);
if (name == null) return "";
String formula = name.getRefersToFormula();
// LogUtil.info(ExcelUtils.class,"formula" + formula);
// if (CommonlyUtils.isEmpty(formula)) return "";
String[] values = formula.split("!")[1].split("\\$");
String loc = "";
for (String value : values) {
loc = loc + value;
}
return loc;
}
public static ExcelWriter getWriter(ExcelReader reader) throws Exception{
if (reader == null) throw new Exception("文件不存在!");
ExcelWriter writer = reader.getWriter();
writer.disableDefaultStyle();
return writer;
}
public static CellReference findCellByName(Workbook workbook, Sheet sheet, String name) {
int namedCellIdx = workbook.getNameIndex(name);
Name aNamedCell = workbook.getNameAt(namedCellIdx);
AreaReference aref =null;
try {
aref=new AreaReference(aNamedCell.getRefersToFormula(),null);
} catch (Exception e) {
e.printStackTrace();
}
CellReference[] crefs = aref.getAllReferencedCells();
if(crefs == null || crefs.length == 0) return null;
return crefs[0];
}
/**
* @param writer
* @param x x
* @param y y
* @param pictureData
* @param picType
*/
public static void writePic(ExcelWriter writer, int x, int y, byte[] pictureData, int picType) {
Sheet sheet = writer.getSheet();
// Drawing drawingPatriarch = sheet.createDrawingPatriarch();
// //设置图片单元格位置
// ClientAnchor anchor = drawingPatriarch.createAnchor(0, 0, 0, 0, x, y, x + 1, y + 1);
// //随单元格改变位置和大小
// anchor.setAnchorType(ClientAnchor.AnchorType.MOVE_AND_RESIZE);
// //添加图片
// int pictureIndex = sheet.getWorkbook().addPicture(pictureData, picType);
// drawingPatriarch.createPicture(anchor, pictureIndex);
Workbook workbook = writer.getWorkbook();
int pictureIdx = workbook.addPicture(pictureData, picType);
CreationHelper helper = workbook.getCreationHelper();
Drawing drawing = sheet.createDrawingPatriarch();
ClientAnchor anchor = helper.createClientAnchor();
anchor.setCol1(x);
anchor.setRow1(y);
Picture pict = drawing.createPicture(anchor, pictureIdx);
pict.resize(0.8);
}
}

@ -0,0 +1,90 @@
package com.pjb.springbootjjwt.utils;
import java.io.*;
import java.io.File;
import java.net.*;
public class HttpUtils {
/**
* URL
*
* @param urlPath
*
* @param downloadDir
*
* @return
*/
@SuppressWarnings("finally")
public static File downloadFile(String urlPath, String downloadDir) throws Exception {
File file = null;
//中午转unicode
String fileFullName = urlPath.substring(urlPath.lastIndexOf("/") + 1 ,urlPath.length());
String parentPath = urlPath.substring(0 ,urlPath.lastIndexOf("/") + 1);
// 统一资源
URL url = new URL(parentPath + URLEncoder.encode(fileFullName, "UTF-8"));
// 连接类的父类,抽象类
URLConnection urlConnection = url.openConnection();
// http的连接类
HttpURLConnection httpURLConnection = (HttpURLConnection) urlConnection;
//设置超时
httpURLConnection.setConnectTimeout(1000*5);
//设置请求方式默认是GET
httpURLConnection.setRequestMethod("GET");
// 设置字符编码
httpURLConnection.setRequestProperty("Charset", "UTF-8");
// 打开到此 URL引用的资源的通信链接如果尚未建立这样的连接
httpURLConnection.connect();
// 文件大小
int fileLength = httpURLConnection.getContentLength();
// 控制台打印文件大小
System.out.println("您要下载的文件大小为:" + fileLength / (1024 * 1024) + "MB");
// 建立链接从请求中获取数据
URLConnection con = url.openConnection();
BufferedInputStream bin = new BufferedInputStream(httpURLConnection.getInputStream());
// 指定存放位置(有需求可以自定义)
String fileName = fileFullName.substring(14,fileFullName.length());
String path = downloadDir + File.separatorChar + fileName;
file = new File(path);
// 校验文件夹目录是否存在,不存在就创建一个目录
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
OutputStream out = new FileOutputStream(file);
int size = 0;
int len = 0;
byte[] buf = new byte[2048];
while ((size = bin.read(buf)) != -1) {
len += size;
out.write(buf, 0, size);
// 控制台打印文件下载的百分比情况
System.out.println("下载了-------> " + len * 100 / fileLength + "%\n");
}
// 关闭资源
bin.close();
out.close();
System.out.println("文件下载成功!");
return file;
// try {
// } catch (Exception e) {
// System.out.println("文件下载失败!");
// } finally {
// }
}
// /**
// * 测试
// *
// * @param args
// */
// public static void main(String[] args) {
// // 指定资源地址,下载文件测试
// downloadFile("http://count.liqucn.com/d.php?id=22709&urlos=android&from_type=web", "B:/myFiles/");
//
// }
}

@ -0,0 +1,33 @@
package com.pjb.springbootjjwt.utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class LogUtil {
public static void error(Class objClass,String msg) {
Logger logger = LoggerFactory.getLogger(objClass);
logger.error(msg);
}
public static void error(Class objClass, Throwable throwable) {
Logger logger = LoggerFactory.getLogger(objClass);
logger.error("发送错误",throwable);
}
public static void info(Class objClass, String msg) {
Logger logger = LoggerFactory.getLogger(objClass);
logger.info(msg);
}
public static void info(String msg) {
Logger logger = LoggerFactory.getLogger(LogUtil.class);
logger.info(msg);
}
public static void warn(Class objClass, String msg) {
Logger logger = LoggerFactory.getLogger(objClass);
logger.warn(msg);
}
}

@ -0,0 +1,31 @@
package com.pjb.springbootjjwt.utils;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
public class MyThread implements Runnable {
private InputStream in;
public MyThread(InputStream in){
this.in = in;
}
@Override
public void run() {
try{
BufferedReader br = new BufferedReader(new InputStreamReader(in, "GBK"));
String line = null;
while((line = br.readLine())!=null){
LogUtil.info(" inputStream: " + line);
}
}catch (IOException e){
e.printStackTrace();
}finally {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}

@ -0,0 +1,128 @@
package com.pjb.springbootjjwt.utils;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeoutException;
public class ProcessUtils {
/**
* .TimeoutException
* @param command
* @param timeout
* @return
* @throws IOException
* @throws InterruptedException
* @throws TimeoutException
*/
public static int executeCommand(final String command, final long timeout) throws IOException, InterruptedException, TimeoutException {
Process process = Runtime.getRuntime().exec(command);
Worker2 worker = new Worker2(process);
worker.start();
try {
worker.join(timeout);
if (worker.exit != null){
return worker.exit;
} else{
throw new TimeoutException();
}
} catch (InterruptedException ex) {
worker.interrupt();
Thread.currentThread().interrupt();
throw ex;
} finally {
process.destroy();
}
}
private static class Worker2 extends Thread {
private final Process process;
private Integer exit;
private Worker2(Process process) {
this.process = process;
}
public void run() {
try {
exit = process.waitFor();
} catch (InterruptedException ignore) {
return;
}
}
}
/**
* @param timeout
* @param command
* .TimeoutException
*/
public static int executeProcess(final String command, final long timeout)
throws IOException, InterruptedException, TimeoutException {
Process process = Runtime.getRuntime().exec(command);
Worker worker = new Worker(process);
worker.start();
try {
worker.join(timeout);
if (worker.exit != null){
return worker.exit;
} else{
throw new TimeoutException("CAD文件设置属性超时");
}
} catch (InterruptedException ex) {
worker.interrupt();
Thread.currentThread().interrupt();
throw ex;
}
finally {
process.destroy();
}
}
private static class Worker extends Thread {
private final Process process;
private Integer exit;
private Worker(Process process) {
this.process = process;
}
@Override
public void run() {
InputStream errorStream = null;
InputStream inputStream = null;
try {
errorStream = process.getErrorStream();
inputStream = process.getInputStream();
readStreamInfo(errorStream, inputStream);
exit = process.waitFor();
process.destroy();
if (exit == 0) {
LogUtil.info("子进程正常完成");
} else {
LogUtil.info("子进程异常结束");
}
} catch (InterruptedException ignore) {
return;
}
}
}
/**
* RunTime.exec
* @param inputStreams
*/
public static void readStreamInfo(InputStream... inputStreams){
ExecutorService executorService = Executors.newFixedThreadPool(inputStreams.length);
for (InputStream in : inputStreams) {
executorService.execute(new MyThread(in));
}
executorService.shutdown();
}
}

@ -0,0 +1,60 @@
package com.pjb.springbootjjwt.utils;
import com.alibaba.fastjson.JSON;
import com.pjb.springbootjjwt.entity.Result;
import com.pjb.springbootjjwt.entity.ResultOa;
import java.util.List;
public class ResultUtils {
//返回错误信息
public static Result errorResult(String msg){
Result result = new Result();
result.setCode("E");
result.setMessage(msg);
return result;
}
//返回错误信息OA
public static ResultOa errorResultOa(String msg){
ResultOa result = new ResultOa();
result.setStatus("F");
result.setMessage(msg);
return result;
}
//返回代码错误信息
public static Result errorResult(Throwable throwable){
Result result = new Result();
result.setCode("E");
result.setMessage(throwable.getMessage());
return result;
}
//返回代码错误信息OA
public static ResultOa errorResultOa(Throwable throwable){
ResultOa result = new ResultOa();
result.setStatus("F");
result.setMessage(throwable.toString());
return result;
}
//返回成功信息
public static Result successResult(String msg){
Result result = new Result();
result.setMessage(msg);
return result;
}
//返回成功信息OA
public static ResultOa successResultOa(String msg){
ResultOa result = new ResultOa();
result.setStatus("S");
result.setMessage(msg);
return result;
}
//返回成功信息
public static Result successResult(Object obj){
Result result = new Result();
result.setCode("S");
result.setMessage("请求成功");
result.setData(JSON.toJSON(obj));
return result;
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,222 @@
package com.pjb.springbootjjwt.utils;
/* Written by Patrick Hoonhout */
import com.teamcenter.clientx.AppXSession;
import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException;
import com.teamcenter.services.strong.core.DataManagementService;
import com.teamcenter.services.strong.core.SessionService;
import com.teamcenter.services.strong.workflow.WorkflowService;
import com.teamcenter.services.strong.workflow._2008_06.Workflow.AssignmentLists;
import com.teamcenter.services.strong.workflow._2008_06.Workflow.AttachmentInfo;
import com.teamcenter.services.strong.workflow._2008_06.Workflow.ContextData;
import com.teamcenter.services.strong.workflow._2008_06.Workflow.CreateSignoffInfo;
import com.teamcenter.services.strong.workflow._2008_06.Workflow.CreateSignoffs;
import com.teamcenter.services.strong.workflow._2008_06.Workflow.InstanceInfo;
import com.teamcenter.services.strong.workflow._2008_06.Workflow.Tasks;
import com.teamcenter.services.strong.workflow._2008_06.Workflow.Templates;
import com.teamcenter.soa.client.model.ModelObject;
import com.teamcenter.soa.client.model.ServiceData;
import com.teamcenter.soa.client.model.strong.EPMAssignmentList;
import com.teamcenter.soa.client.model.strong.EPMJob;
import com.teamcenter.soa.client.model.strong.EPMPerformSignoffTask;
import com.teamcenter.soa.client.model.strong.EPMResourceList;
import com.teamcenter.soa.client.model.strong.EPMReviewTask;
import com.teamcenter.soa.client.model.strong.EPMSelectSignoffTask;
import com.teamcenter.soa.client.model.strong.EPMSignoffProfile;
import com.teamcenter.soa.client.model.strong.EPMTask;
import com.teamcenter.soa.client.model.strong.EPMTaskTemplate;
import com.teamcenter.soa.client.model.strong.GroupMember;
import com.teamcenter.soa.client.model.strong.ItemRevision;
import com.teamcenter.soa.client.model.strong.Signoff;
import com.teamcenter.soa.client.model.strong.User;
import com.teamcenter.soa.client.model.strong.WorkspaceObject;
import com.teamcenter.soa.common.ObjectPropertyPolicy;
import com.teamcenter.soa.common.PolicyProperty;
import com.teamcenter.soa.common.PolicyType;
import com.teamcenter.soa.exceptions.NotLoadedException;
public class WorkFlowUtil {
// private ItemRevision itemRev;
// private static GroupMember grpMember;
// private EPMJob job = null;
// private User user;
// private String ItemRevUID = "wNA9ziMB4IElDC";
// private String GroupMemberUID = "A9F5GoDs4IElDC";
// SoaEPMAction
public static final String EPM_assign_action = "SOA_EPM_assign_action";
public static final String EPM_start_action = "SOA_EPM_start_action";
public static final String EPM_complete_action = "SOA_EPM_complete_action";
public static final String EPM_skip_action = "SOA_EPM_skip_action";
public static final String EPM_suspend_action = "SOA_EPM_suspend_action";
public static final String EPM_resume_action = "SOA_EPM_resume_action";
public static final String EPM_undo_action = "SOA_EPM_undo_action";
public static final String EPM_abort_action = "SOA_EPM_abort_action";
public static final String EPM_perform_action = "SOA_EPM_perform_action";
public static final String EPM_add_attachment_action = "SOA_EPM_add_attachment_action";
public static final String EPM_remove_attachment_action = "SOA_EPM_remove_attachment_action";
public static final String EPM_approve_action = "SOA_EPM_approve_action";
public static final String EPM_reject_action = "SOA_EPM_reject_action";
public static final String EPM_promote_action = "SOA_EPM_promote_action";
public static final String EPM_demote_action = "SOA_EPM_demote_action";
public static final String EPM_refuse_action = "SOA_EPM_refuse_action";
public static final String EPM_assign_approver_action = "SOA_EPM_assign_approver_action";
public static final String EPM_notify_action = "SOA_EPM_notify_action";
public static final String EPM_no_action = "SOA_EPM_no_action";
public static final String EPM_fail_action = "SOA_EPM_fail_action";
// SoaEPMSupportingValues
public static final String EPM_no_decision = "SOA_EPM_no_decision";
public static final String EPM_approve = "SOA_EPM_approve";
public static final String EPM_reject = "SOA_EPM_reject";
public static final String EPM_unset = "SOA_EPM_unset";
public static final String EPM_completed = "SOA_EPM_completed";
public static final String EPM_unable_to_complete = "SOA_EPM_unable_to_complete";
public static final String EPM_true = "SOA_EPM_true";
public static final String EPM_false = "SOA_EPM_false";
public static final String EPM_no_error = "SOA_EPM_no_error";
// SignoffAction
public static final String EPM_ACTION_UNDEFINED = "SOA_EPM_ACTION_UNDEFINED";
public static final String EPM_Review = "SOA_EPM_Review";
public static final String EPM_Acknowledge = "SOA_EPM_Acknowledge";
public static final String EPM_Notify = "SOA_EPM_Notify";
// OriginType
public static final String EPM_Origin_Undefined = "SOA_EPM_ORIGIN_UNDEFINED";
public static final String EPM_Signeoff_Origin_Profile = "SOA_EPM_SIGNOFF_ORIGIN_PROFILE";
public static final String EPM_Signoff_Origin_AddressList = "SOA_EPM_SIGNOFF_ORIGIN_ADDRESSLIST";
public WorkFlowUtil() {
// setObjectPolicy();
}
// This action uses OOTB Workflow "Required Signoff"
//修改流程节点用户并且执行流程(仅限审核节点选择用户节点未完成的情况下)
public static boolean performAction(AppXSession session, ItemRevision itemRev, String nodeName, String workflowName,
GroupMember grpMember) throws Exception {
TCUtils.setModelObjectValue(session, itemRev,new String[]{"process_stage_list"});
ModelObject[] stageList = itemRev.get_process_stage_list();
if (CommonlyUtils.isEmpty(stageList)) throw new Exception("版本上的流程为空!!!");
TCUtils.setModelObjectValue(session,stageList, new String[] {"child_tasks","object_name" });
ModelObject[] tasks = null;
for (ModelObject obj : stageList) {
String name = obj.getPropertyObject("object_name").getStringValue();
if (workflowName.equals(name)) {
tasks = ((EPMTask)obj).get_child_tasks();
}
}
if (tasks == null) throw new Exception("未找到进行中的流程!!!");
WorkflowService workflowService = WorkflowService.getService(session.getConnection());
for(ModelObject obj : tasks) {
TCUtils.setModelObjectValue(session,obj,new String[]{"object_name","child_tasks"});
String name = obj.getPropertyObject("object_name").getStringValue();
if (!name.equals(nodeName)) continue;
if(obj instanceof EPMReviewTask) {
EPMTask task = (EPMTask)obj;
Signoff signOff = null;
ModelObject[] childTasks = task.get_child_tasks();
TCUtils.setModelObjectValue(session,childTasks,new String[]{"signoff_profiles"});
for(ModelObject child : childTasks) {
if(child instanceof EPMSelectSignoffTask) {
EPMTask childTask = (EPMTask)child;
signOff = createProfileSignOff(workflowService,childTask,grpMember);
if(signOff == null)
throw new Exception("设置流程节点签发人员失败");
if(ServiceDataError(workflowService.performAction(childTask, EPM_complete_action,
"SOA complete.", null, EPM_completed, null))) // advance the EPMSelectSignoffTask
throw new Exception("执行选人节点任务出现错误");
else
return true;
}
// else if(child instanceof EPMPerformSignoffTask) {
// TCUtils.dataManagementService.refreshObjects(new ModelObject[]{itemRev,stageList[0],obj,child});
// LogUtil.info("4");
// EPMTask childTask = (EPMTask)child;
// if(signOff != null) {
// LogUtil.info("8");
// TCUtils.dataManagementService.refreshObjects(new ModelObject[]{itemRev,stageList[0],obj,child});
// if(ServiceDataError(TCUtils.workflowService.performAction(childTask, EPM_perform_action,
// "SOA approved.", null, EPM_approve, signOff)))
// return false;
// LogUtil.info("9");
// TCUtils.dataManagementService.refreshObjects(new ModelObject[]{itemRev,stageList[0],obj,child});
// if(!ServiceDataError(TCUtils.workflowService.performAction(childTask, EPM_complete_action,
// "SOA complete.", null, EPM_completed, null))) // advance the EPMPerformSignoffTask
// return true;
// }
// }
}
}
}
return false;
}
protected static Signoff createProfileSignOff(WorkflowService workflowService,EPMTask task,GroupMember grpMember)
throws Exception {
// ModelObject[] signoffProfiles = task.get_signoff_profiles();
// if(signoffProfiles != null && signoffProfiles.length > 0) {
CreateSignoffInfo profileInfo = new CreateSignoffInfo();
CreateSignoffs signoff = new CreateSignoffs();
profileInfo.signoffAction = EPM_Review;
// profileInfo.origin = signoffProfiles[0];
profileInfo.origin = null;
profileInfo.originType = EPM_Origin_Undefined;
// profileInfo.originType = EPM_Signeoff_Origin_Profile;
profileInfo.signoffMember = grpMember;
signoff.signoffInfo = new CreateSignoffInfo[]{
profileInfo };
signoff.task = task;
ServiceData sData = workflowService.addSignoffs(new CreateSignoffs[]{ signoff });
if(!ServiceDataError(sData))
{
if(sData.sizeOfCreatedObjects() > 0)
{
ModelObject obj = sData.getCreatedObject(0);
if(obj instanceof Signoff)
return (Signoff)obj;
}
}
// }
return null;
}
protected static boolean ServiceDataError(final ServiceData data) {
if(data.sizeOfPartialErrors() > 0)
{
for(int i = 0; i < data.sizeOfPartialErrors(); i++)
{
for(String msg : data.getPartialError(i).getMessages())
System.out.println(msg);
}
return true;
}
return false;
}
protected void setObjectPolicy() {
SessionService session = SessionService.getService(AppXSession.getConnection());
ObjectPropertyPolicy policy = new ObjectPropertyPolicy();
PolicyType itemRevType = new PolicyType("ItemRevision");
PolicyProperty property = new PolicyProperty("process_stage_list");
property.setModifier(PolicyProperty.WITH_PROPERTIES, true);
itemRevType.addProperty(property);
policy.addType(itemRevType);
PolicyType assignmentListType = new PolicyType("EPMAssignmentList");
property = new PolicyProperty("resoruces");
property.setModifier(PolicyProperty.WITH_PROPERTIES, true);
assignmentListType.addProperty(property);
policy.addType(assignmentListType);
policy.addType("EPMTask", new String[]{ "object_type", "object_name", "task_type",
"task_template", "parent_process" });
policy.addType("EPMJob", new String[]{ "root_task" });
policy.addType("EPMTaskTemplate", new String[]{ "object_type", "object_name"});
policy.addType("EPMAssignmentList", new String[]{ "resoruces"});
policy.addType("EPMResourceList", new String[]{ "profiles" });
// policy.addType("WorkspaceObject", new String[]{"object_name"});
session.setObjectPropertyPolicy(policy);
}
}

@ -0,0 +1,145 @@
//==================================================
//
// Copyright 2012 Siemens Product Lifecycle Management Software Inc. All Rights Reserved.
//
//==================================================
package com.teamcenter.clientx;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import com.teamcenter.schemas.soa._2006_03.exceptions.InvalidCredentialsException;
import com.teamcenter.schemas.soa._2006_03.exceptions.InvalidUserException;
import com.teamcenter.soa.client.CredentialManager;
import com.teamcenter.soa.exceptions.CanceledOperationException;
/**
* The CredentialManager is used by the Teamcenter Services framework to get the
* user's credentials when challenged by the server. This can occur after a period
* of inactivity and the server has timed-out the user's session, at which time
* the client application will need to re-authenticate. The framework will
* call one of the getCredentials methods (depending on circumstances) and will
* send the SessionService.login service request. Upon successful completion of
* the login service request. The last service request (one that caused the challenge)
* will be resent.
*
* The framework will also call the setUserPassword setGroupRole methods when ever
* these credentials change, thus allowing this implementation of the CredentialManager
* to cache these values so prompting of the user is not required for re-authentication.
*
*/
public class AppXCredentialManager implements CredentialManager
{
private String name = null;
private String password = null;
private String group = ""; // default group
private String role = ""; // default role
private String discriminator = "SoaAppX"; // always connect same user
// to same instance of server
/**
* Return the type of credentials this implementation provides,
* standard (user/password) or Single-Sign-On. In this case
* Standard credentials are returned.
*
* @see CredentialManager#getCredentialType()
*/
public int getCredentialType()
{
return CredentialManager.CLIENT_CREDENTIAL_TYPE_STD;
}
/**
* Prompt's the user for credentials.
* This method will only be called by the framework when a login attempt has
* failed.
*
* @see CredentialManager#getCredentials(InvalidCredentialsException)
*/
public String[] getCredentials(InvalidCredentialsException e)
throws CanceledOperationException
{
System.out.println(e.getMessage());
return promptForCredentials();
}
/**
* Return the cached credentials.
* This method will be called when a service request is sent without a valid
* session ( session has expired on the server).
*
* @see CredentialManager#getCredentials(InvalidUserException)
*/
public String[] getCredentials(InvalidUserException e)
throws CanceledOperationException
{
// Have not logged in yet, should not happen but just in case
if (name == null) return promptForCredentials();
// Return cached credentials
String[] tokens = { name, password, group, role, discriminator };
return tokens;
}
/**
* Cache the group and role
* This is called after the SessionService.setSessionGroupMember service
* operation is called.
*
* @see CredentialManager#setGroupRole(String,
* String)
*/
public void setGroupRole(String group, String role)
{
this.group = group;
this.role = role;
}
/**
* Cache the User and Password
* This is called after the SessionService.login service operation is called.
*
* @see CredentialManager#setUserPassword(String,
* String, String)
*/
public void setUserPassword(String user, String password, String discriminator)
{
this.name = user;
this.password = password;
this.discriminator = discriminator;
}
public String[] promptForCredentials()
throws CanceledOperationException
{
try
{
LineNumberReader reader = new LineNumberReader(new InputStreamReader(System.in));
System.out.println("Please enter user credentials (return to quit):");
System.out.print("User Name: ");
// name = reader.readLine();
name = "admin";
if (name.length() == 0)
throw new CanceledOperationException("");
System.out.print("Password: ");
// password = reader.readLine();
password = "123";
}
catch (Exception e)
{
String message = "Failed to get the name and password.\n" + e.getMessage();
System.out.println(message);
throw new CanceledOperationException(message);
}
String[] tokens = { name, password, group, role, discriminator };
return tokens;
}
}

@ -0,0 +1,102 @@
//==================================================
//
// Copyright 2012 Siemens Product Lifecycle Management Software Inc. All Rights Reserved.
//
//==================================================
package com.teamcenter.clientx;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import com.teamcenter.schemas.soa._2006_03.exceptions.ConnectionException;
import com.teamcenter.schemas.soa._2006_03.exceptions.InternalServerException;
import com.teamcenter.schemas.soa._2006_03.exceptions.ProtocolException;
import com.teamcenter.soa.client.ExceptionHandler;
import com.teamcenter.soa.exceptions.CanceledOperationException;
/**
* Implementation of the ExceptionHandler. For ConnectionExceptions (server
* temporarily down .etc) prompts the user to retry the last request. For other
* exceptions convert to a RunTime exception.
*/
public class AppXExceptionHandler implements ExceptionHandler
{
/*
* (non-Javadoc)
*
* @see com.teamcenter.soa.client.ExceptionHandler#handleException(com.teamcenter.schemas.soa._2006_03.exceptions.InternalServerException)
*/
public void handleException(InternalServerException ise)
{
System.out.println("");
System.out.println("*****");
System.out
.println("Exception caught in com.teamcenter.clientx.AppXExceptionHandler.handleException(InternalServerException).");
LineNumberReader reader = new LineNumberReader(new InputStreamReader(System.in));
if (ise instanceof ConnectionException)
{
// ConnectionException are typically due to a network error (server
// down .etc) and can be recovered from (the last request can be sent again,
// after the problem is corrected).
System.out.print("\nThe server returned an connection error.\n" + ise.getMessage()
+ "\nDo you wish to retry the last service request?[y/n]");
}
else
if (ise instanceof ProtocolException)
{
// ProtocolException are typically due to programming errors
// (content of HTTP
// request is incorrect). These are generally can not be
// recovered from.
System.out.print("\nThe server returned an protocol error.\n" + ise.getMessage()
+ "\nThis is most likely the result of a programming error."
+ "\nDo you wish to retry the last service request?[y/n]");
}
else
{
System.out.println("\nThe server returned an internal server error.\n"
+ ise.getMessage()
+ "\nThis is most likely the result of a programming error."
+ "\nA RuntimeException will be thrown.");
throw new RuntimeException(ise.getMessage());
}
try
{
String retry = reader.readLine();
// If yes, return to the calling SOA client framework, where the
// last service request will be resent.
if (retry.equalsIgnoreCase("y") || retry.equalsIgnoreCase("yes")) return;
throw new RuntimeException("The user has opted not to retry the last request");
}
catch (IOException e)
{
System.err.println("Failed to read user response.\nA RuntimeException will be thrown.");
throw new RuntimeException(e.getMessage());
}
}
/*
* (non-Javadoc)
*
* @see com.teamcenter.soa.client.ExceptionHandler#handleException(com.teamcenter.soa.exceptions.CanceledOperationException)
*/
public void handleException(CanceledOperationException coe)
{
System.out.println("");
System.out.println("*****");
System.out.println("Exception caught in com.teamcenter.clientx.AppXExceptionHandler.handleException(CanceledOperationException).");
// Expecting this from the login tests with bad credentials, and the
// AnyUserCredentials class not
// prompting for different credentials
throw new RuntimeException(coe);
}
}

@ -0,0 +1,64 @@
//==================================================
//
// Copyright 2012 Siemens Product Lifecycle Management Software Inc. All Rights Reserved.
//
//==================================================
package com.teamcenter.clientx;
import com.teamcenter.soa.client.model.ModelEventListener;
import com.teamcenter.soa.client.model.ModelObject;
import com.teamcenter.soa.exceptions.NotLoadedException;
/**
* Implementation of the ChangeListener. Print out all objects that have been updated.
*
*/
public class AppXModelEventListener extends ModelEventListener
{
@Override
public void localObjectChange(ModelObject[] objects)
{
if (objects.length == 0) return;
System.out.println("");
System.out.println("Modified Objects handled in com.teamcenter.clientx.AppXUpdateObjectListener.modelObjectChange");
System.out.println("The following objects have been updated in the client data model:");
for (int i = 0; i < objects.length; i++)
{
String uid = objects[i].getUid();
String type = objects[i].getTypeObject().getName();
String name = "";
if (objects[i].getTypeObject().isInstanceOf("WorkspaceObject"))
{
ModelObject wo = objects[i];
try
{
name = wo.getPropertyObject("object_string").getStringValue();
}
catch (NotLoadedException e) {} // just ignore
}
System.out.println(" " + uid + " " + type + " " + name);
}
}
@Override
public void localObjectDelete(String[] uids)
{
if (uids.length == 0)
return;
System.out.println("");
System.out.println("Deleted Objects handled in com.teamcenter.clientx.AppXDeletedObjectListener.modelObjectDelete");
System.out.println("The following objects have been deleted from the server and removed from the client data model:");
for (int i = 0; i < uids.length; i++)
{
System.out.println(" " + uids[i]);
}
}
}

@ -0,0 +1,61 @@
//==================================================
//
// Copyright 2012 Siemens Product Lifecycle Management Software Inc. All Rights Reserved.
//
//==================================================
package com.teamcenter.clientx;
import com.teamcenter.soa.client.model.ErrorStack;
import com.teamcenter.soa.client.model.ErrorValue;
import com.teamcenter.soa.client.model.PartialErrorListener;
/**
* Implementation of the PartialErrorListener. Print out any partial errors
* returned.
*
*/
public class AppXPartialErrorListener implements PartialErrorListener
{
@Override
public void handlePartialError(ErrorStack[] stacks)
{
if (stacks.length == 0) return;
System.out.println("");
System.out.println("*****");
System.out.println("Partial Errors caught in com.teamcenter.clientx.AppXPartialErrorListener.");
for (int i = 0; i < stacks.length; i++)
{
ErrorValue[] errors = stacks[i].getErrorValues();
System.out.print("Partial Error for ");
// The different service implementation may optionally associate
// an ModelObject, client ID, or nothing, with each partial error
if (stacks[i].hasAssociatedObject())
{
System.out.println( "object " + stacks[i].getAssociatedObject().getUid() );
}
else if (stacks[i].hasClientId())
{
System.out.println( "client id " + stacks[i].getClientId() );
}
else if (stacks[i].hasClientIndex())
System.out.println( "client index " + stacks[i].getClientIndex() );
// Each Partial Error will have one or more contributing error messages
for (int j = 0; j < errors.length; j++)
{
System.out.println(" Code: " + errors[j].getCode() + "\tSeverity: "
+ errors[j].getLevel() + "\t" + errors[j].getMessage());
}
}
}
}

@ -0,0 +1,36 @@
//==================================================
//
// Copyright 2012 Siemens Product Lifecycle Management Software Inc. All Rights Reserved.
//
//==================================================
package com.teamcenter.clientx;
import com.teamcenter.soa.client.RequestListener;
/**
* This implementation of the RequestListener, logs each service request
* to the console.
*
*/
public class AppXRequestListener implements RequestListener
{
/**
* Called before each request is sent to the server.
*/
public void serviceRequest ( final Info info )
{
// will log the service name when done
}
/**
* Called after each response from the server.
* Log the service operation to the console.
*/
public void serviceResponse( final Info info )
{
System.out.println( info.id +": "+info.service+"."+info.operation);
}
}

@ -0,0 +1,297 @@
//==================================================
//
// Copyright 2012 Siemens Product Lifecycle Management Software Inc. All Rights Reserved.
//
//==================================================
package com.teamcenter.clientx;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.List;
import java.util.Locale;
import java.util.Vector;
import com.teamcenter.schemas.soa._2006_03.exceptions.InvalidCredentialsException;
import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException;
import com.teamcenter.services.strong.core.DataManagementService;
import com.teamcenter.services.strong.core.SessionService;
import com.teamcenter.services.strong.core._2006_03.Session.LoginResponse;
import com.teamcenter.soa.SoaConstants;
import com.teamcenter.soa.client.Connection;
import com.teamcenter.soa.client.model.ModelObject;
import com.teamcenter.soa.client.model.strong.User;
import com.teamcenter.soa.client.model.strong.WorkspaceObject;
import com.teamcenter.soa.exceptions.CanceledOperationException;
import com.teamcenter.soa.exceptions.NotLoadedException;
public class AppXSession
{
/**
* Single instance of the Connection object that is shared throughout
* the application. This Connection object is needed whenever a Service
* stub is instantiated.
*/
private static Connection connection;
/**
* The credentialManager is used both by the Session class and the Teamcenter
* Services Framework to get user credentials.
*
*/
private static AppXCredentialManager credentialManager;
/**
* Create an instance of the Session with a connection to the specified
* server.
*
* Add implementations of the ExceptionHandler, PartialErrorListener,
* ChangeListener, and DeleteListeners.
*
* @param host Address of the host to connect to, http://serverName:port/tc
*/
public AppXSession(String host)
{
// Create an instance of the CredentialManager, this is used
// by the SOA Framework to get the user's credentials when
// challenged by the server (session timeout on the web tier).
credentialManager = new AppXCredentialManager();
String protocol=null;
String envNameTccs = null;
if ( host.startsWith("http") )
{
protocol = SoaConstants.HTTP;
}
else if ( host.startsWith("tccs") )
{
protocol = SoaConstants.TCCS;
host = host.trim();
int envNameStart = host.indexOf('/') + 2;
envNameTccs = host.substring( envNameStart, host.length() );
host = "";
}
else
{
protocol = SoaConstants.IIOP;
}
// Create the Connection object, no contact is made with the server
// until a service request is made
connection = new Connection(host, credentialManager, SoaConstants.REST, protocol);
if( protocol == SoaConstants.TCCS )
{
connection.setOption( Connection.TCCS_ENV_NAME, envNameTccs );
}
// Add an ExceptionHandler to the Connection, this will handle any
// InternalServerException, communication errors, XML marshaling errors
// .etc
connection.setExceptionHandler(new AppXExceptionHandler());
// While the above ExceptionHandler is required, all of the following
// Listeners are optional. Client application can add as many or as few Listeners
// of each type that they want.
// Add a Partial Error Listener, this will be notified when ever a
// a service returns partial errors.
connection.getModelManager().addPartialErrorListener(new AppXPartialErrorListener());
// Add a Change and Delete Listener, this will be notified when ever a
// a service returns model objects that have been updated or deleted.
connection.getModelManager().addModelEventListener(new AppXModelEventListener());
// Add a Request Listener, this will be notified before and after each
// service request is sent to the server.
Connection.addRequestListener( new AppXRequestListener() );
}
/**
* Get the single Connection object for the application
*
* @return connection
*/
public static Connection getConnection()
{
return connection;
}
public User login(String userName,String pwd,String sessionDiscriminator)
{
// Get the service stub
SessionService sessionService = SessionService.getService(connection);
try
{
// *****************************
// Execute the service operation
// *****************************
LoginResponse out = sessionService.login(userName, pwd,
"", "","ZH_CN", sessionDiscriminator);
return out.user;
}
catch (InvalidCredentialsException e)
{
e.printStackTrace();
}
return null;
}
/**
* Login to the Teamcenter Server
*
*/
public User login()
{
// Get the service stub
SessionService sessionService = SessionService.getService(connection);
try
{
// Prompt for credentials until they are right, or until user
// cancels
String[] credentials = credentialManager.promptForCredentials();
while (true)
{
try
{
// *****************************
// Execute the service operation
// *****************************
LoginResponse out = sessionService.login(credentials[0], credentials[1],
credentials[2], credentials[3],"", credentials[4]);
return out.user;
}
catch (InvalidCredentialsException e)
{
credentials = credentialManager.getCredentials(e);
}
}
}
// User canceled the operation, don't need to tell him again
catch (CanceledOperationException e) {}
// Exit the application
System.exit(0);
return null;
}
/**
* Terminate the session with the Teamcenter Server
*
*/
public void logout()
{
// Get the service stub
SessionService sessionService = SessionService.getService(connection);
try
{
// *****************************
// Execute the service operation
// *****************************
sessionService.logout();
}
catch (ServiceException e){}
}
/**
* Print some basic information for a list of objects
*
* @param objects
*/
public static void printObjects(ModelObject[] objects)
{
if(objects == null)
return;
SimpleDateFormat format = new SimpleDateFormat("M/d/yyyy h:mm a", new Locale("en", "US")); // Simple no time zone
// Ensure that the referenced User objects that we will use below are loaded
getUsers( objects );
System.out.println("Name\t\tOwner\t\tLast Modified");
System.out.println("====\t\t=====\t\t=============");
for (int i = 0; i < objects.length; i++)
{
if(!(objects[i] instanceof WorkspaceObject ))
continue;
WorkspaceObject wo = (WorkspaceObject)objects[i];
try
{
String name = wo.get_object_string();
User owner = (User) wo.get_owning_user();
Calendar lastModified =wo.get_last_mod_date();
System.out.println(name + "\t" + owner.get_user_name() + "\t"
+ format.format(lastModified.getTime()));
}
catch (NotLoadedException e)
{
// Print out a message, and skip to the next item in the folder
// Could do a DataManagementService.getProperties call at this point
System.out.println(e.getMessage());
System.out.println("The Object Property Policy ($TC_DATA/soa/policies/Default.xml) is not configured with this property.");
}
}
}
private static void getUsers( ModelObject[] objects )
{
if(objects == null)
return;
DataManagementService dmService = DataManagementService.getService(AppXSession.getConnection());
List<User> unKnownUsers = new Vector<User>();
for (int i = 0; i < objects.length; i++)
{
if(!(objects[i] instanceof WorkspaceObject ))
continue;
WorkspaceObject wo = (WorkspaceObject)objects[i];
User owner = null;
try
{
owner = (User) wo.get_owning_user();
owner.get_user_name();
}
catch (NotLoadedException e)
{
if(owner != null)
unKnownUsers.add(owner);
}
}
User[] users = (User[])unKnownUsers.toArray(new User[unKnownUsers.size()]);
String[] attributes = { "user_name" };
// *****************************
// Execute the service operation
// *****************************
dmService.getProperties(users, attributes);
}
}

@ -0,0 +1,297 @@
//==================================================
//
// Copyright 2012 Siemens Product Lifecycle Management Software Inc. All Rights Reserved.
//
//==================================================
package com.teamcenter.clientx;
import com.teamcenter.schemas.soa._2006_03.exceptions.InvalidCredentialsException;
import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException;
import com.teamcenter.services.strong.core.DataManagementService;
import com.teamcenter.services.strong.core.SessionService;
import com.teamcenter.services.strong.core._2006_03.Session.LoginResponse;
import com.teamcenter.soa.SoaConstants;
import com.teamcenter.soa.client.Connection;
import com.teamcenter.soa.client.model.ModelObject;
import com.teamcenter.soa.client.model.strong.User;
import com.teamcenter.soa.client.model.strong.WorkspaceObject;
import com.teamcenter.soa.exceptions.CanceledOperationException;
import com.teamcenter.soa.exceptions.NotLoadedException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.List;
import java.util.Locale;
import java.util.Vector;
public class AppXSessionTekla
{
/**
* Single instance of the Connection object that is shared throughout
* the application. This Connection object is needed whenever a Service
* stub is instantiated.
*/
private static Connection connection;
/**
* The credentialManager is used both by the Session class and the Teamcenter
* Services Framework to get user credentials.
*
*/
private static AppXCredentialManager credentialManager;
/**
* Create an instance of the Session with a connection to the specified
* server.
*
* Add implementations of the ExceptionHandler, PartialErrorListener,
* ChangeListener, and DeleteListeners.
*
* @param host Address of the host to connect to, http://serverName:port/tc
*/
public AppXSessionTekla(String host)
{
// Create an instance of the CredentialManager, this is used
// by the SOA Framework to get the user's credentials when
// challenged by the server (session timeout on the web tier).
credentialManager = new AppXCredentialManager();
String protocol=null;
String envNameTccs = null;
if ( host.startsWith("http") )
{
protocol = SoaConstants.HTTP;
}
else if ( host.startsWith("tccs") )
{
protocol = SoaConstants.TCCS;
host = host.trim();
int envNameStart = host.indexOf('/') + 2;
envNameTccs = host.substring( envNameStart, host.length() );
host = "";
}
else
{
protocol = SoaConstants.IIOP;
}
// Create the Connection object, no contact is made with the server
// until a service request is made
connection = new Connection(host, credentialManager, SoaConstants.REST, protocol);
if( protocol == SoaConstants.TCCS )
{
connection.setOption( Connection.TCCS_ENV_NAME, envNameTccs );
}
// Add an ExceptionHandler to the Connection, this will handle any
// InternalServerException, communication errors, XML marshaling errors
// .etc
connection.setExceptionHandler(new AppXExceptionHandler());
// While the above ExceptionHandler is required, all of the following
// Listeners are optional. Client application can add as many or as few Listeners
// of each type that they want.
// Add a Partial Error Listener, this will be notified when ever a
// a service returns partial errors.
connection.getModelManager().addPartialErrorListener(new AppXPartialErrorListener());
// Add a Change and Delete Listener, this will be notified when ever a
// a service returns model objects that have been updated or deleted.
connection.getModelManager().addModelEventListener(new AppXModelEventListener());
// Add a Request Listener, this will be notified before and after each
// service request is sent to the server.
Connection.addRequestListener( new AppXRequestListener() );
}
/**
* Get the single Connection object for the application
*
* @return connection
*/
public static Connection getConnection()
{
return connection;
}
public User login(String userName,String pwd) throws Exception
{
// Get the service stub
SessionService sessionService = SessionService.getService(connection);
try
{
// *****************************
// Execute the service operation
// *****************************
LoginResponse out = sessionService.login(userName, pwd,
"", "","", "Tekla");
return out.user;
}
catch (InvalidCredentialsException e)
{
e.printStackTrace();
throw e;
}
//return null;
}
/**
* Login to the Teamcenter Server
*
*/
public User login()
{
// Get the service stub
SessionService sessionService = SessionService.getService(connection);
try
{
// Prompt for credentials until they are right, or until user
// cancels
String[] credentials = credentialManager.promptForCredentials();
while (true)
{
try
{
// *****************************
// Execute the service operation
// *****************************
LoginResponse out = sessionService.login(credentials[0], credentials[1],
credentials[2], credentials[3],"", credentials[4]);
return out.user;
}
catch (InvalidCredentialsException e)
{
credentials = credentialManager.getCredentials(e);
}
}
}
// User canceled the operation, don't need to tell him again
catch (CanceledOperationException e) {}
// Exit the application
System.exit(0);
return null;
}
/**
* Terminate the session with the Teamcenter Server
*
*/
public void logout()
{
// Get the service stub
SessionService sessionService = SessionService.getService(connection);
try
{
// *****************************
// Execute the service operation
// *****************************
sessionService.logout();
}
catch (ServiceException e){}
}
/**
* Print some basic information for a list of objects
*
* @param objects
*/
public static void printObjects(ModelObject[] objects)
{
if(objects == null)
return;
SimpleDateFormat format = new SimpleDateFormat("M/d/yyyy h:mm a", new Locale("en", "US")); // Simple no time zone
// Ensure that the referenced User objects that we will use below are loaded
getUsers( objects );
System.out.println("Name\t\tOwner\t\tLast Modified");
System.out.println("====\t\t=====\t\t=============");
for (int i = 0; i < objects.length; i++)
{
if(!(objects[i] instanceof WorkspaceObject ))
continue;
WorkspaceObject wo = (WorkspaceObject)objects[i];
try
{
String name = wo.get_object_string();
User owner = (User) wo.get_owning_user();
Calendar lastModified =wo.get_last_mod_date();
System.out.println(name + "\t" + owner.get_user_name() + "\t"
+ format.format(lastModified.getTime()));
}
catch (NotLoadedException e)
{
// Print out a message, and skip to the next item in the folder
// Could do a DataManagementService.getProperties call at this point
System.out.println(e.getMessage());
System.out.println("The Object Property Policy ($TC_DATA/soa/policies/Default.xml) is not configured with this property.");
}
}
}
private static void getUsers( ModelObject[] objects )
{
if(objects == null)
return;
DataManagementService dmService = DataManagementService.getService(AppXSessionTekla.getConnection());
List<User> unKnownUsers = new Vector<User>();
for (int i = 0; i < objects.length; i++)
{
if(!(objects[i] instanceof WorkspaceObject ))
continue;
WorkspaceObject wo = (WorkspaceObject)objects[i];
User owner = null;
try
{
owner = (User) wo.get_owning_user();
owner.get_user_name();
}
catch (NotLoadedException e)
{
if(owner != null)
unKnownUsers.add(owner);
}
}
User[] users = (User[])unKnownUsers.toArray(new User[unKnownUsers.size()]);
String[] attributes = { "user_name" };
// *****************************
// Execute the service operation
// *****************************
dmService.getProperties(users, attributes);
}
}

@ -0,0 +1,19 @@
package com.teamcenter.clientx;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
public class CommonlyUtils {
public static SimpleDateFormat sdf = new SimpleDateFormat ( "yyyy-MM-dd HH:mm:ss" );
public static SimpleDateFormat fileNameSDF = new SimpleDateFormat ( "yyyyMMddHHmmss" );
static {
sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
fileNameSDF.setTimeZone(TimeZone.getTimeZone("GMT+8"));
}
public static String getNowDate(){
return fileNameSDF.format(new Date());
}
}

@ -0,0 +1,62 @@
//==================================================
//
// Copyright 2017 Siemens Product Lifecycle Management Software Inc. All Rights Reserved.
//
//==================================================
package com.teamcenter.clientx;
import com.teamcenter.clientx.AppXSession;
import com.teamcenter.soa.client.model.strong.User;
/**
* This sample client application demonstrates some of the basic features of the
* FileManagement service.
*
*/
public class FMS
{
/**
* @param args -help or -h will print out a Usage statement
*/
public static void main(String[] args)
{
if (args.length > 0)
{
if (args[0].equals("-help") || args[0].equals("-h"))
{
System.out.println("usage: java [-Dhost=http://server:port/tc] com.teamcenter.filemanagement.FMS");
System.exit(0);
}
}
// Get optional host information
String serverHost = "http://10.10.172.37:7001/tc";
String host = System.getProperty("host");
if (host != null && host.length() > 0)
{
serverHost = host;
}
AppXSession session = new AppXSession(serverHost);
FileManagement fm = new FileManagement();
// Establish a session with the Teamcenter Server
User user = session.login();
// Upload some files
fm.uploadFiles(user);
session.logout();
}
}

@ -0,0 +1,235 @@
//==================================================
//
// Copyright 2017 Siemens Product Lifecycle Management Software Inc. All Rights Reserved.
//
//==================================================
package com.teamcenter.clientx;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import com.teamcenter.clientx.AppXSession;
import com.teamcenter.services.loose.core._2006_03.FileManagement.DatasetFileInfo;
import com.teamcenter.services.loose.core._2006_03.FileManagement.GetDatasetWriteTicketsInputData;
import com.teamcenter.services.strong.core.DataManagementService;
import com.teamcenter.services.strong.core._2006_03.DataManagement.CreateDatasetsResponse;
import com.teamcenter.services.strong.core._2008_06.DataManagement.DatasetProperties2;
import com.teamcenter.soa.client.FileManagementUtility;
import com.teamcenter.soa.client.model.ModelObject;
import com.teamcenter.soa.client.model.ServiceData;
import com.teamcenter.soa.client.model.strong.Folder;
import com.teamcenter.soa.client.model.strong.User;
import com.teamcenter.soa.exceptions.NotLoadedException;
/**
* Use the FileManagementService to transfer files
*
*/
public class FileManagement
{
/** The number of datasets to upload in the multiple file example. */
static final int NUMBER_OF_DATASETS = 120;
/** The number of files per dataset to upload in the multiple file example. */
static final int NUMBER_OF_FILES_PER_DATASET = 3;
/** Upload some files using the FileManagement utilities. */
public void uploadFiles(User user)
{
FileManagementUtility fMSFileManagement = new FileManagementUtility(AppXSession.getConnection());
DataManagementService dmService = DataManagementService.getService(AppXSession.getConnection());
try
{
Folder home =user.get_home_folder();
uploadSingleFile(fMSFileManagement, dmService,home);
// uploadMultipleFiles(fMSFileManagement, dmService);
} catch (NotLoadedException e) {
e.printStackTrace();
} finally
{
// Close FMS connection when done
fMSFileManagement.term();
}
}
/** Uploads a single file using the FileManagement utilities. */
public void uploadSingleFile(final FileManagementUtility fMSFileManagement, final DataManagementService dmService, Folder home)
{
GetDatasetWriteTicketsInputData[] inputs = { getGetDatasetWriteTicketsInputData(dmService,home) };
ServiceData response = fMSFileManagement.putFiles(inputs);
if (response.sizeOfPartialErrors() > 0)
System.out.println("FileManagementService upload returned partial errors: " + response.sizeOfPartialErrors());
// Delete all objects created
ModelObject [] datasets = { inputs[0].dataset };
dmService.deleteObjects(datasets);
}
/** Uploads multiple files using the FileManagement utilities. */
public void uploadMultipleFiles(final FileManagementUtility fMSFileManagement, final DataManagementService dmService)
{
GetDatasetWriteTicketsInputData[] inputs = getMultipleGetDatasetWriteTicketsInputData(dmService);
ServiceData response = fMSFileManagement.putFiles(inputs);
if (response.sizeOfPartialErrors() > 0)
System.out.println("FileManagementService multiple upload returned partial errors: " + response.sizeOfPartialErrors());
// Delete all objects created
ModelObject[] datasets = new ModelObject[inputs.length];
for (int i = 0; i < inputs.length; ++i)
{
datasets[i] = inputs[i].dataset;
}
dmService.deleteObjects(datasets);
}
/** @return A single GetDatasetWriteTicketsInputData for uploading ReadMe.txt. */
private GetDatasetWriteTicketsInputData getGetDatasetWriteTicketsInputData(final DataManagementService dmService, Folder home)
{
// Create a Dataset
DatasetProperties2 props = new DatasetProperties2();
props.clientId = "datasetWriteTixTestClientId";
props.type = "Text";
props.name = "Sample-FMS-Upload";
props.description = "Testing put File";
props.container = home;
DatasetProperties2[] currProps = { props };
CreateDatasetsResponse resp = dmService.createDatasets2(currProps);
// Assume this file is in current dir
File file1 = new File("C:\\Users\\85490\\Desktop\\11.txt");
// Create a file to associate with dataset
DatasetFileInfo fileInfo = new DatasetFileInfo();
fileInfo.clientId = "file_1";
fileInfo.fileName = file1.getAbsolutePath();
fileInfo.namedReferencedName = "Text";
fileInfo.isText = true;
fileInfo.allowReplace = false;
DatasetFileInfo[] fileInfos = { fileInfo };
GetDatasetWriteTicketsInputData inputData = new GetDatasetWriteTicketsInputData();
inputData.dataset = resp.output[0].dataset;
inputData.createNewVersion = false;
inputData.datasetFileInfos = fileInfos;
return inputData;
}
/**
* @return An array of NUMBER_OF_DATASETS GetDatasetWriteTicketsInputData objects
* for uploading NUMBER_OF_FILES_PER_DATASET copies of ReadMe.txt to each Dataset.
*/
private GetDatasetWriteTicketsInputData[] getMultipleGetDatasetWriteTicketsInputData(final DataManagementService dmService)
{
GetDatasetWriteTicketsInputData[] inputs = new GetDatasetWriteTicketsInputData[NUMBER_OF_DATASETS];
DatasetProperties2[] currProps = new DatasetProperties2[inputs.length];
// Create a bunch of Datasets
for (int i = 0; i < inputs.length; ++i)
{
DatasetProperties2 props = new DatasetProperties2();
props.clientId = "datasetWriteTixTestClientId " + i;
props.type = "Text";
props.name = "Sample-FMS-Upload-" + i;
props.description = "Testing Multiple put File";
currProps[i] = props;
}
CreateDatasetsResponse resp = dmService.createDatasets2(currProps);
// Create files to associate with each Dataset
for (int i = 0; i < inputs.length; ++i)
{
DatasetFileInfo fileInfos[] = new DatasetFileInfo[NUMBER_OF_FILES_PER_DATASET];
for (int j = 0; j < fileInfos.length; ++j)
{
DatasetFileInfo fileInfo = new DatasetFileInfo();
// We apparently cannot upload two files with the same name to
// the same Dataset because this creates a relation name
// conflict.
// File file1 = new File("ReadMe.txt");
// Create or use this file is in current dir
File file1 = new File("ReadMeCopy" + j + ".txt");
assureFileCreated(file1);
fileInfo.clientId = "Dataset " + i + " File " + j;
fileInfo.fileName = file1.getAbsolutePath();
fileInfo.namedReferencedName = "Text";
fileInfo.isText = true;
fileInfo.allowReplace = false;
fileInfos[j] = fileInfo;
}
GetDatasetWriteTicketsInputData inputData = new GetDatasetWriteTicketsInputData();
inputData.dataset = resp.output[i].dataset;
inputData.createNewVersion = false;
inputData.datasetFileInfos = fileInfos;
inputs[i] = inputData;
}
return inputs;
}
/**
* Assures that the file exists on the file system.
* If not, this method copies "ReadMe.txt" to create the file.
* @param file1 (File) The file to be created if it does not already exist.
*/
private void assureFileCreated(final File file1)
{
if (file1.exists())
{
return;
}
FileInputStream fis = null;
FileOutputStream fos = null;
try
{
try
{
byte[] buffer = new byte[16384];
// Assume this file is in current dir
fis = new FileInputStream(new File("ReadMe.txt"));
// Assume that we can copy it in the current dir
fos = new FileOutputStream(file1);
while (true)
{
int bytesRead = fis.read(buffer);
if (bytesRead <= 0)
{
// EOF
break;
}
fos.write(buffer, 0, bytesRead);
}
}
finally
{
if (fos != null)
{
fos.close();
}
if (fis != null)
{
fis.close();
}
}
}
catch (IOException ioe)
{
System.out.println("Could not copy 'ReadMe.txt' to '" + file1.getName()
+ "' - " + ioe.getClass().getSimpleName() + ": " + ioe.getMessage());
}
}
}

@ -0,0 +1,75 @@
//==================================================
//
// Copyright 2017 Siemens Product Lifecycle Management Software Inc. All Rights Reserved.
//
//==================================================
package com.teamcenter.clientx;
import com.teamcenter.clientx.AppXSession;
import com.teamcenter.services.strong.core.DataManagementService;
import com.teamcenter.soa.client.model.ModelObject;
import com.teamcenter.soa.client.model.strong.Folder;
import com.teamcenter.soa.client.model.strong.User;
import com.teamcenter.soa.client.model.strong.WorkspaceObject;
import com.teamcenter.soa.exceptions.NotLoadedException;
public class HomeFolder
{
/**
* List the contents of the Home folder.
*
*/
public void listHomeFolder(User user)
{
Folder home = null;
WorkspaceObject[] contents = null;
// Get the service stub
DataManagementService dmService = DataManagementService.getService(AppXSession.getConnection());
try
{
// User was a primary object returned from the login command
// the Object Property Policy should be configured to include the
// 'home_folder' property. However the actuall 'home_folder' object
// was a secondary object returned from the login request and
// therefore does not have any properties associated with it. We will need to
// get those properties explicitly with a 'getProperties' service request.
home = user.get_home_folder();
}
catch (NotLoadedException e)
{
System.out.println(e.getMessage());
System.out.println("The Object Property Policy ($TC_DATA/soa/policies/Default.xml) is not configured with this property.");
return;
}
try
{
ModelObject[] objects = { home };
String[] attributes = { "contents" };
// *****************************
// Execute the service operation
// *****************************
dmService.getProperties(objects, attributes);
// The above getProperties call returns a ServiceData object, but it
// just has pointers to the same object we passed into the method, so the
// input object have been updated with new property values
contents = home.get_contents();
}
// This should never be thrown, since we just explicitly asked for this
// property
catch (NotLoadedException e){}
System.out.println("");
System.out.println("Home Folder:");
AppXSession.printObjects( contents );
}
}

@ -0,0 +1,263 @@
//==================================================
//
// Copyright 2017 Siemens Product Lifecycle Management Software Inc. All Rights Reserved.
//
//==================================================
package com.teamcenter.clientx;
import com.teamcenter.clientx.AppXSession;
import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException;
//Include the Saved Query Service Interface
import com.teamcenter.services.strong.query.SavedQueryService;
// Input and output structures for the service operations
// Note: the different namespace from the service interface
import com.teamcenter.services.strong.query._2006_03.SavedQuery.GetSavedQueriesResponse;
import com.teamcenter.services.strong.query._2007_09.SavedQuery.SavedQueriesResponse;
import com.teamcenter.services.strong.query._2008_06.SavedQuery.QueryInput;
import com.teamcenter.services.strong.query._2007_09.SavedQuery.QueryResults;
import com.teamcenter.services.strong.core.DataManagementService;
import com.teamcenter.soa.client.model.ModelObject;
import com.teamcenter.soa.client.model.PropertyDescription;
import com.teamcenter.soa.client.model.ServiceData;
import com.teamcenter.soa.client.model.Type;
import com.teamcenter.soa.client.model.strong.Group;
import com.teamcenter.soa.client.model.strong.ImanQuery;
import com.teamcenter.soa.client.model.strong.WorkspaceObject;
import java.util.Arrays;
public class Query
{
/**
* Perform a simple query of the database
*
*/
public static ModelObject[] queryItems(String queryName ,String[] entries, String[] values)
{
ImanQuery query = null;
// Get the service stub.
SavedQueryService queryService = SavedQueryService.getService(AppXSession.getConnection());
DataManagementService dmService= DataManagementService.getService(AppXSession.getConnection());
try
{
// *****************************
// Execute the service operation
// *****************************
GetSavedQueriesResponse savedQueries = queryService.getSavedQueries();
if (savedQueries.queries.length == 0)
{
System.out.println("There are no saved queries in the system.");
return null;
}
// Find one called 'Item Name'
for (int i = 0; i < savedQueries.queries.length; i++)
{
if (savedQueries.queries[i].name.equals(queryName))//("__WEB_group"))
{
query = savedQueries.queries[i].query;
break;
}
}
}
catch (ServiceException e)
{
System.out.println("GetSavedQueries service request failed.");
System.out.println(e.getMessage());
return null;
}
if (query == null)
{
System.out.println("There is not an 'Item Name' query.");
return null;
}
ModelObject[] foundObjs = new ModelObject[0];
try
{
//String[] ss = query.get_query_clauses();
//Search for all Items, returning a maximum of 25 objects
QueryInput savedQueryInput[] = new QueryInput[1];
savedQueryInput[0] = new QueryInput();
savedQueryInput[0].query = query;
//savedQueryInput[0].maxNumToReturn = 25;
//savedQueryInput[0].limitList = new ModelObject[0];
savedQueryInput[0].entries = entries;
savedQueryInput[0].values = values;
//*****************************
//Execute the service operation
//*****************************
SavedQueriesResponse savedQueryResult = queryService.executeSavedQueries(savedQueryInput);
QueryResults found = savedQueryResult.arrayOfResults[0];
//System.out.println("");
//System.out.println("Found Items:");
// Page through the results 10 at a time
// String[] uids = new String[found.objectUIDS.length];
// for(int i=0; i< found.objectUIDS.length; i++)
// {
//int pageSize = (i+10<found.objectUIDS.length)? 10:found.objectUIDS.length-i;
// for(int j=0; j<pageSize; j++)
// {
// uids[i]= found.objectUIDS[i];
// }
ServiceData sd = dmService.loadObjects( found.objectUIDS );
foundObjs = new ModelObject[ sd.sizeOfPlainObjects()];
for( int k =0; k< sd.sizeOfPlainObjects(); k++)
{
foundObjs[k] = sd.getPlainObject(k);
// Group wo = (Group) foundObjs[k];
// System.out.println("get_name:"+wo.get_name());
}
// Group wo = (Group) foundObjs[0];
// String s = wo.get_name();
// Object[] obj = Arrays.stream(foundObjs).toArray();
//AppXSession.printObjects( foundObjs );
// }
}
catch (Exception e)
{
System.out.println("ExecuteSavedQuery service request failed.");
System.out.println(e.getMessage());
return null;
}
return foundObjs;
}
/**
* Perform a simple query of the database
*
*/
public static ModelObject[] queryItemsForTekla(String queryName ,String[] entries, String[] values)
{
ImanQuery query = null;
// Get the service stub.
SavedQueryService queryService = SavedQueryService.getService(AppXSessionTekla.getConnection());
DataManagementService dmService= DataManagementService.getService(AppXSessionTekla.getConnection());
try
{
// *****************************
// Execute the service operation
// *****************************
GetSavedQueriesResponse savedQueries = queryService.getSavedQueries();
if (savedQueries.queries.length == 0)
{
System.out.println("There are no saved queries in the system.");
return null;
}
// Find one called 'Item Name'
for (int i = 0; i < savedQueries.queries.length; i++)
{
if (savedQueries.queries[i].name.equals(queryName))//("__WEB_group"))
{
query = savedQueries.queries[i].query;
break;
}
}
}
catch (ServiceException e)
{
System.out.println("GetSavedQueries service request failed.");
System.out.println(e.getMessage());
return null;
}
if (query == null)
{
System.out.println("There is not an 'Item Name' query.");
return null;
}
ModelObject[] foundObjs = new ModelObject[0];
try
{
//String[] ss = query.get_query_clauses();
//Search for all Items, returning a maximum of 25 objects
QueryInput savedQueryInput[] = new QueryInput[1];
savedQueryInput[0] = new QueryInput();
savedQueryInput[0].query = query;
//savedQueryInput[0].maxNumToReturn = 25;
//savedQueryInput[0].limitList = new ModelObject[0];
savedQueryInput[0].entries = entries;
savedQueryInput[0].values = values;
//*****************************
//Execute the service operation
//*****************************
SavedQueriesResponse savedQueryResult = queryService.executeSavedQueries(savedQueryInput);
QueryResults found = savedQueryResult.arrayOfResults[0];
//System.out.println("");
//System.out.println("Found Items:");
// Page through the results 10 at a time
// String[] uids = new String[found.objectUIDS.length];
// for(int i=0; i< found.objectUIDS.length; i++)
// {
//int pageSize = (i+10<found.objectUIDS.length)? 10:found.objectUIDS.length-i;
// for(int j=0; j<pageSize; j++)
// {
// uids[i]= found.objectUIDS[i];
// }
ServiceData sd = dmService.loadObjects( found.objectUIDS );
foundObjs = new ModelObject[ sd.sizeOfPlainObjects()];
for( int k =0; k< sd.sizeOfPlainObjects(); k++)
{
foundObjs[k] = sd.getPlainObject(k);
// Group wo = (Group) foundObjs[k];
// System.out.println("get_name:"+wo.get_name());
}
// Group wo = (Group) foundObjs[0];
// String s = wo.get_name();
// Object[] obj = Arrays.stream(foundObjs).toArray();
//AppXSession.printObjects( foundObjs );
// }
}
catch (Exception e)
{
System.out.println("ExecuteSavedQuery service request failed.");
System.out.println(e.getMessage());
return null;
}
return foundObjs;
}
}

@ -0,0 +1,228 @@
package com.teamcenter.clientx;
import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException;
import com.teamcenter.services.strong.core.DataManagementService;
import com.teamcenter.services.strong.core._2006_03.DataManagement;
import com.teamcenter.services.strong.query.SavedQueryService;
import com.teamcenter.services.strong.query._2006_03.SavedQuery;
import com.teamcenter.soa.client.model.ModelObject;
import com.teamcenter.soa.client.model.ServiceData;
import com.teamcenter.soa.client.model.strong.Group;
import com.teamcenter.soa.client.model.strong.ImanQuery;
import com.teamcenter.soa.client.model.strong.User;
public class Utils {
//Find user using User ID ->String user represent User ID
public static ModelObject findUser(String user)
{
ImanQuery query = null;
//SavedQueryService class is in package com.teamcenter.services.strong.query
SavedQueryService queryService = SavedQueryService.getService(AppXSession.getConnection());
try
{
SavedQuery.GetSavedQueriesResponse savedQueries = queryService.getSavedQueries();
if (savedQueries.queries.length == 0)
{
return null;
}
for (int i = 0; i < savedQueries.queries.length; i++)
{
//__WEB_find_user -> Query in Query builder to find the user
if (savedQueries.queries[i].name.equals("__WEB_find_user"))
{
query = savedQueries.queries[i].query;
break;
}
}
}
catch (ServiceException e)
{
System.out.println(e.getMessage());
return null;
}
if (query == null)
{
System.out.println("There is not an 'Item Name' query.");
return null;
}
try
{
com.teamcenter.services.strong.query._2007_06.SavedQuery.SavedQueryInput savedQueryInput[] = new com.teamcenter.services.strong.query._2007_06.SavedQuery.SavedQueryInput[1];
savedQueryInput[0] = new com.teamcenter.services.strong.query._2007_06.SavedQuery.SavedQueryInput();
savedQueryInput[0].query = query;
savedQueryInput[0].maxNumToReturn = 25;
savedQueryInput[0].limitListCount = 0;
savedQueryInput[0].limitList = new ModelObject[0];
savedQueryInput[0].entries = new String[]{"User ID" };//Attribute in Query to search by
savedQueryInput[0].values = new String[1];
savedQueryInput[0].values[0] = user;//Value for the search attribute
savedQueryInput[0].maxNumToInflate = 25;
//Execute Query to find the User
com.teamcenter.services.strong.query._2007_06.SavedQuery.ExecuteSavedQueriesResponse savedQueryResult = queryService.executeSavedQueries(savedQueryInput);
com.teamcenter.services.strong.query._2007_06.SavedQuery.SavedQueryResults found = savedQueryResult.arrayOfResults[0];
// System.out.println("Found Users:");
ModelObject[] modelObjs = found.objects;
return modelObjs[0]; //User object
}
catch (Exception e)
{
System.out.println(e.getMessage());
return null;
}
}
public static ModelObject findGroup(String groupName)
{
ImanQuery query = null;
SavedQueryService queryService = SavedQueryService.getService(AppXSession.getConnection());
try
{
SavedQuery.GetSavedQueriesResponse savedQueries = queryService.getSavedQueries();
if (savedQueries.queries.length == 0)
{
return null;
}
for (int i = 0; i < savedQueries.queries.length; i++)
{
//__WEB_group -> Query in Query builder to find the group
if (savedQueries.queries[i].name.equals("__WEB_group"))
{
query = savedQueries.queries[i].query;
break;
}
}
}
catch (ServiceException e)
{
System.out.println(e.getMessage());
return null;
}
if (query == null)
{
System.out.println("__WEB_group query not found");
return null;
}
try
{
com.teamcenter.services.strong.query._2007_06.SavedQuery.SavedQueryInput savedQueryInput[] = new com.teamcenter.services.strong.query._2007_06.SavedQuery.SavedQueryInput[1];
savedQueryInput[0] = new com.teamcenter.services.strong.query._2007_06.SavedQuery.SavedQueryInput();
savedQueryInput[0].query = query;
savedQueryInput[0].maxNumToReturn = 25;
savedQueryInput[0].limitListCount = 0;
savedQueryInput[0].limitList = new ModelObject[0];
savedQueryInput[0].entries = new String[]{"Name" };//Attribute in Query to search by
savedQueryInput[0].values = new String[1];
savedQueryInput[0].values[0] = groupName;//Value for the search attribute
savedQueryInput[0].maxNumToInflate = 25;
//Execute Query to find the Group
com.teamcenter.services.strong.query._2007_06.SavedQuery.ExecuteSavedQueriesResponse savedQueryResult = queryService.executeSavedQueries(savedQueryInput);
com.teamcenter.services.strong.query._2007_06.SavedQuery.SavedQueryResults found = savedQueryResult.arrayOfResults[0];
// System.out.println("Found Users:");
ModelObject[] modelObjs = found.objects;
return modelObjs[0];//Group object
}
catch (Exception e)
{
System.out.println(e.getMessage());
return null;
}
}
public static void changeOwnershipModelObject(ModelObject user, String groupName, ModelObject[] modls) throws Exception
{
DataManagementService ser1 = DataManagementService.getService( AppXSession.getConnection() );
//ModelObject user = findUser( userName ) ;
if( user != null )
{
System.out.println("................................owning user found..................................");
} else {
//The configured EPI-Owning-user is not found in Teamcenter.
System.out.println("................ EPI-owning user not found ................");
throw new Exception("Change ownership service: 003.Change ownership service - The configured EPI-owning user is not found in Teamcenter.");
}
ModelObject userGroup = null;
if(groupName!=""){
userGroup = findGroup( groupName ) ;
}else{
ser1.getProperties(new ModelObject[]{user},new String[]{"default_group"});
userGroup = user.getPropertyObject("default_group").getModelObjectValue();
}
if( userGroup != null )
{
System.out.println("................................owning group found..................................");
}else{
System.out.println("................ EPI-owning group not found ................");
throw new Exception("Change ownership service: 004.Change ownership service - The configured EPI-owning group is not found in Teamcenter.");
}
DataManagement.ObjectOwner[] ownerData = new DataManagement.ObjectOwner[modls.length];
for(int i = 0 ; i <modls.length ;i++) {
DataManagement.ObjectOwner ownrObj = new DataManagement.ObjectOwner();
ownrObj.object = modls[i];
ownrObj.group = (Group) userGroup;
ownrObj.owner = (User) user;
ownerData[i] = ownrObj;
}
ServiceData returnData = ser1.changeOwnership( ownerData );
System.out.println( "****************************** Ownership changed successfully ******************************" );
if(returnData.sizeOfPartialErrors() > 0){
throw new Exception("Change ownership service: 005.Change ownership service - "+returnData.getPartialError(0).getMessages()[0]);
}
}
}

@ -0,0 +1,28 @@
{
"properties": [
{
"name": "teamcenter.url",
"type": "java.lang.String",
"description": "Description for teamcenter.url."
},
{
"name": "teamcenter.user",
"type": "java.lang.String",
"description": "Description for teamcenter.user."
},
{
"name": "teamcenter.pwd",
"type": "java.lang.String",
"description": "Description for teamcenter.pwd."
},
{
"name": "teamcenter.fmsurl",
"type": "java.lang.String",
"description": "Description for teamcenter.fmsurl."
},
{
"name": "teamcenter.fcccash",
"type": "java.lang.String",
"description": "Description for teamcenter.fcccash."
}
] }

@ -0,0 +1,41 @@
server:
port: 9295
spring:
datasource:
driver-class-name: oracle.jdbc.OracleDriver
url: jdbc:oracle:thin:@172.18.11.38:1521:TC13
username: TCPUBLIC
password: TCPUBLIC
config:
activate:
on-profile: dev #开发环境
mybatis:
configuration:
map-underscore-to-camel-case: false
mapper-locations: classpath:com/pjb/springbootjjwt/mapper/*.xml
# mybatis 日志
mybatis-plus:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
debug: true
teamcenter:
url: http://172.18.11.38:7001/tc
user: admin
pwd: admin123
fmsurl: http://172.18.11.38:4544
fcccache: D:\fcccache
address: D:\fcccache\
cadexe: acad_process.exe
cadpath: D:\config
readcadexe: acad_read.exe
logging:
pattern:
file: '%clr(%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{50} - %msg%n)'
level:
root: info
com.pjb.springbootjjwt: debug
org:
springframework:
boot:
autoconfigure: info # 日志不打印条件评估报告
file: D:\LBLOG\LB_interface.log

@ -0,0 +1,52 @@
server:
port: 9295
# tomcat:
# uri-encoding: UTF-8
# #最小线程数
# min-spare-threads: 500
# #最大线程数
# max-threads: 2500
# #最大链接数
# max-connections: 6500
# #最大等待队列长度
# accept-count: 1000
# #请求头最大长度kb
# max-http-header-size: 1048576
# #请请求体最大长度kb
# #max-http-post-size: 2097152
# #链接建立超时时间
# connection-timeout: 120000
spring:
datasource:
driver-class-name: oracle.jdbc.OracleDriver
url: jdbc:oracle:thin:@192.168.90.117:1521:tc
username: tc11
password: infodba
config:
activate:
on-profile: prod #生产环境
mybatis:
configuration:
map-underscore-to-camel-case: false
mapper-locations: classpath:com/pjb/springbootjjwt/mapper/*.xml
teamcenter:
#测试机配置
url: http://192.168.90.118:7001/tc
user: infodba
pwd: infodba
fmsurl: http://192.168.90.116:4544
#对内路径
fcccache: D:\fcccache
address: http://192.168.90.116:19090
logging:
pattern:
file: '%clr(%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{50} - %msg%n)'
#file: '${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan}[row-num:%line] %clr(:){faint}: %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}'
level:
root: info
com.pjb.springbootjjwt: info
org:
springframework:
boot:
autoconfigure: ERROR # 日志不打印条件评估报告
file: D:\LBLOG\LB_interface.log

@ -0,0 +1,38 @@
server:
port: 9295
spring:
datasource:
driver-class-name: oracle.jdbc.OracleDriver
url: jdbc:oracle:thin:@192.168.10.161:1521:TC
username: infodba
password: infodba
config:
activate:
on-profile: xnj #开发环境
mybatis:
config-location: classpath:mybatis.xml
mapper-locations: classpath:com/pjb/springbootjjwt/mapper/*.xml
# mybatis 日志
mybatis-plus:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
debug: true
teamcenter:
url: http://192.168.10.161:8085/tc
user: gengj
pwd: 123
fmsurl: http://192.168.10.161:4544
fcccash: C://123
address: C://123/
QZBjxmConfig: C:/123/QZBjxmCreate.json
logging:
pattern:
file: '%clr(%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{50} - %msg%n)'
file: C://CRMLOG/crm.log
level:
root: info
com.pjb.springbootjjwt: debug
org:
springframework:
boot:
autoconfigure: ERROR # 日志不打印条件评估报告

@ -0,0 +1,3 @@
spring:
profiles:
active: prod #对应选择那一个环境

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.pjb.springbootjjwt.mapper.MesMapper">
<insert id="insertKH_LOG">
INSERT into KH_LOG
("NO","DESC_","PROVIDER","CALLER","ITEMID","REVID","RESULT","IN_","OUT","TIME")
values
(#{no},#{desc},#{provider},#{caller},#{itemid},#{revid},#{result},#{in},#{out},#{time})
</insert>
</mapper>

@ -0,0 +1,210 @@
import com.teamcenter.clientx.AppXSession;
import com.teamcenter.clientx.Query;
import com.teamcenter.services.strong.administration.IRMService;
import com.teamcenter.services.strong.administration._2006_03.IRM;
import com.teamcenter.services.strong.cad.StructureManagementService;
import com.teamcenter.services.strong.cad._2007_01.StructureManagement;
import com.teamcenter.services.strong.core.DataManagementService;
import com.teamcenter.services.strong.core.ReservationService;
import com.teamcenter.services.strong.core._2006_03.DataManagement;
import com.teamcenter.soa.client.model.ModelObject;
import com.teamcenter.soa.client.model.strong.*;
import java.io.Console;
import java.util.HashMap;
public class TestGetRevisionList {
public static void main(String[] args) {
if (args.length > 0)
{
if (args[0].equals("-help") || args[0].equals("-h"))
{
System.out.println("usage: java [-Dhost=http://server:port/tc] com.teamcenter.clientX.AppX");
System.exit(0);
}
}
// Get optional host information
String serverHost = "http://10.10.172.37:7001/tc";
String host = System.getProperty("host");
if (host != null && host.length() > 0)
{
serverHost = host;
}
AppXSession session = new AppXSession(serverHost);
try
{
User user = session.login();
// getRevionAndBomView();
// createFolderAndEdit(user);
// checkOutAndCheckIn();
getprivileges(user);
}catch (Exception ex)
{
System.out.println( ex.getMessage());
return ;
}
session.logout();
}
private static void getprivileges(User user) {
try
{
DataManagementService dataManagementService = DataManagementService.getService(AppXSession.getConnection());
StructureManagementService smService = StructureManagementService.getService( AppXSession.getConnection());
//获取192685产品
String[] Entries = {"Item ID"};
String[] Values = {"20.01.007.00000010"};
ModelObject[] modelObjects = Query.queryItems("Item ID",Entries, Values);
dataManagementService.getProperties(modelObjects,new String[]{"item_id","object_name","item_revision","last_release_status","revision_list"});
for(ModelObject modelObject : modelObjects) {
Item item = (Item) modelObject;
//获取最新发布的版本
ItemRevision itemRevision = (ItemRevision) item.get_last_release_status();
//若不存在 获取最新的版本
if (itemRevision == null) {
ModelObject[] itemAllRevisions = item.get_revision_list();
itemRevision = (ItemRevision) itemAllRevisions[itemAllRevisions.length - 1];
}
//查询签出状态
// itemRevision.get_checked_out();
// ReservationService reservationService = ReservationService.getService(AppXSession.getConnection());
// //签出
// reservationService.checkout(new ModelObject[]{itemRevision},"","");
// //签入
// reservationService.checkin(new ModelObject[]{itemRevision});
String[] privilegeNames = new String[] { "READ", "WRITE", "DELETE"};
IRMService irmService = IRMService.getService(AppXSession.getConnection());
IRM.CheckAccessorPrivilegesResponse resp = irmService.checkAccessorsPrivileges(user,new ModelObject[]{itemRevision}, privilegeNames);
System.out.println("");
}
}catch (Exception ex)
{
System.out.println( ex.getMessage());
return ;
}
}
private static void checkOutAndCheckIn() {
try
{
DataManagementService dataManagementService = DataManagementService.getService(AppXSession.getConnection());
StructureManagementService smService = StructureManagementService.getService( AppXSession.getConnection());
//获取192685产品
String[] Entries = {"Item ID"};
String[] Values = {"20.01.007.00000010"};
ModelObject[] modelObjects = Query.queryItems("Item ID",Entries, Values);
dataManagementService.getProperties(modelObjects,new String[]{"item_id","object_name","item_revision","last_release_status","revision_list"});
for(ModelObject modelObject : modelObjects) {
Item item = (Item) modelObject;
//获取最新发布的版本
ItemRevision itemRevision = (ItemRevision) item.get_last_release_status();
//若不存在 获取最新的版本
if (itemRevision == null) {
ModelObject[] itemAllRevisions = item.get_revision_list();
itemRevision = (ItemRevision) itemAllRevisions[itemAllRevisions.length - 1];
}
// 查询签出状态
itemRevision.get_checked_out();
ReservationService reservationService = ReservationService.getService(AppXSession.getConnection());
//签出
reservationService.checkout(new ModelObject[]{itemRevision},"","");
//签入
reservationService.checkin(new ModelObject[]{itemRevision});
}
}catch (Exception ex)
{
System.out.println( ex.getMessage());
return ;
}
}
private static void createFolderAndEdit(User user) {
try{
//在Home创建文件夹
Folder home = user.get_home_folder();
DataManagementService dataManagementService = DataManagementService.getService(AppXSession.getConnection());
DataManagement.CreateFolderInput createFolderInput = new DataManagement.CreateFolderInput();
createFolderInput.name = "测试文件夹";
DataManagement.CreateFoldersResponse createFoldersResponse = dataManagementService.createFolders(new DataManagement.CreateFolderInput[]{createFolderInput},home,"");
if(createFoldersResponse.serviceData.sizeOfCreatedObjects() == 0){
System.out.println("创建失败");
return;
}
//编辑文件夹属性
Folder theNewFolder = createFoldersResponse.output[0].folder;
com.teamcenter.services.strong.core._2007_01.DataManagement.VecStruct vecStruct = new com.teamcenter.services.strong.core._2007_01.DataManagement.VecStruct();
vecStruct.stringVec = new String[]{"测试文件夹(修改后)"};
HashMap<String, com.teamcenter.services.strong.core._2007_01.DataManagement.VecStruct> propertyMap = new HashMap<String, com.teamcenter.services.strong.core._2007_01.DataManagement.VecStruct>();
//修改的属性和值
propertyMap.put("object_name",vecStruct);
dataManagementService.setProperties(new ModelObject[]{theNewFolder} , propertyMap );
}catch (Exception ex)
{
System.out.println( ex.getMessage());
return ;
}
}
private static void getRevionAndBomView() {
try
{
DataManagementService dataManagementService = DataManagementService.getService(AppXSession.getConnection());
StructureManagementService smService = StructureManagementService.getService( AppXSession.getConnection());
//获取192685产品
String[] Entries = {"Item ID"};
String[] Values = {"20.01.007.00000010"};
ModelObject[] modelObjects = Query.queryItems("Item ID",Entries, Values);
dataManagementService.getProperties(modelObjects,new String[]{"item_id","object_name","item_revision","last_release_status","revision_list"});
for(ModelObject modelObject : modelObjects){
Item item = (Item) modelObject;
//获取最新发布的版本
ItemRevision itemRevision = (ItemRevision) item.get_last_release_status();
//若不存在 获取最新的版本
if(itemRevision == null){
ModelObject[] itemAllRevisions = item.get_revision_list();
itemRevision = (ItemRevision) itemAllRevisions[itemAllRevisions.length-1];
}
//获取BOM
StructureManagement.CreateBOMWindowsInfo[] createBOMWindowsInfo = new StructureManagement.CreateBOMWindowsInfo[1];
createBOMWindowsInfo[0] = new StructureManagement.CreateBOMWindowsInfo();
createBOMWindowsInfo[0].itemRev = itemRevision;
StructureManagement.CreateBOMWindowsResponse createBOMWindowsResponse = smService.createBOMWindows(createBOMWindowsInfo);
BOMLine topBomLine = (BOMLine) createBOMWindowsResponse.output[0].bomLine;
dataManagementService.getProperties(new BOMLine[]{topBomLine},new String[]{"bl_child_lines"});
ModelObject[] childrenBomLines = topBomLine.get_bl_child_lines();
}
}catch (Exception ex)
{
System.out.println( ex.getMessage());
return ;
}
}
public static StructureManagement.CreateBOMWindowsResponse createBomWindow(ItemRevision itemRev)
{
StructureManagement.CreateBOMWindowsInfo[] createBOMWindowsInfo = new StructureManagement.CreateBOMWindowsInfo[1];
createBOMWindowsInfo[0] = new StructureManagement.CreateBOMWindowsInfo();
createBOMWindowsInfo[0].itemRev = itemRev;StructureManagementService smService = StructureManagementService.getService( AppXSession.getConnection() );;
StructureManagement.CreateBOMWindowsResponse createBOMWindowsResponse = smService.createBOMWindows(createBOMWindowsInfo);
return createBOMWindowsResponse;
}
}

@ -0,0 +1,428 @@
package com.pjb.springbootjjwt;
import cn.hutool.poi.excel.ExcelReader;
import com.alibaba.fastjson.JSONObject;
import com.teamcenter.clientx.AppXSession;
import com.teamcenter.clientx.Query;
import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException;
import com.teamcenter.services.strong.cad.StructureManagementService;
import com.teamcenter.services.strong.cad._2007_01.StructureManagement;
import com.teamcenter.services.strong.classification.ClassificationService;
import com.teamcenter.services.strong.classification._2007_01.Classification;
import com.teamcenter.services.strong.core.DataManagementService;
import com.teamcenter.services.strong.core.FileManagementService;
import com.teamcenter.services.strong.core.SessionService;
import com.teamcenter.services.strong.core._2007_06.DataManagement;
import com.teamcenter.services.strong.core._2007_12.Session;
import com.teamcenter.soa.client.model.ModelObject;
import com.teamcenter.soa.client.model.ServiceData;
import com.teamcenter.soa.client.model.strong.*;
import com.teamcenter.soa.exceptions.NotLoadedException;
import org.apache.poi.ss.usermodel.Workbook;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.io.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
@RunWith(SpringRunner.class)
@SpringBootTest
public class SpringbootJjwtApplicationTests {
private static AppXSession tcSession;
private static User tcUser;
private static SessionService sessionService;
private static DataManagementService dataManagementService;
private static StructureManagementService smService;
private static StructureManagement.CreateBOMWindowsInfo[] createBOMWindowsInfo;
private static FileManagementService fmService;
private static ClassificationService classificationService;
static {
if(tcSession == null){
tcSession = new AppXSession("http://connor:7001/tc");
}
try{
if(tcUser == null) {
tcUser = tcSession.login("admin","1","test");
}
}catch (Exception ex){
ex.printStackTrace();
}
if (dataManagementService == null) {
dataManagementService = DataManagementService.getService(tcSession.getConnection());
}
if (smService == null){
smService = StructureManagementService.getService(tcSession.getConnection());
}
if (createBOMWindowsInfo == null) {
createBOMWindowsInfo = new StructureManagement.CreateBOMWindowsInfo[1];
}
if (fmService == null){
fmService = FileManagementService.getService(tcSession.getConnection());
}
if (classificationService == null){
classificationService = ClassificationService.getService(tcSession.getConnection());
}
if (sessionService == null) {
sessionService = SessionService.getService(tcSession.getConnection());
}
}
@Test
public void contextLoads() {
try {
ModelObject obj = getPUID("g_vJbkdKpRsZiB");
ItemRevision rev = (ItemRevision) obj;
dataManagementService.getProperties(new ModelObject[]{rev},new String[]{"release_status_list"});
ModelObject[] status = new ModelObject[0];
status = rev.get_release_status_list();
if (status != null && status.length > 0) {
ReleaseStatus statuses = (ReleaseStatus) status[0];
dataManagementService.getProperties(new ModelObject[]{statuses},new String[]{"object_type","name",
"object_name","object_type"});
System.out.println("name=" + statuses.get_name());
System.out.println("object_name=" + statuses.get_object_name());
System.out.println("object_type=" + statuses.get_object_type());
}
} catch (NotLoadedException e) {
e.printStackTrace();
}
}
private ModelObject getPUID(String str){
return dataManagementService.loadObjects(new String[]{str}).getPlainObject(0);
}
private ModelObject getItem() {
String[] key = {"Item ID"};
String[] value = {"000438"};
String searchName = "Item ID";
ModelObject[] modelObjects = Query.queryItems(searchName,key,value);
return modelObjects[0];
}
@Test
public void test01(){
//测试Item的get_item_revision方法取到是哪个版本
String [] prodpros = {"object_name","revision_list"};
String[] revprops = {"item_revision_id","IMAN_classification"};
String[] prop = {"cid"};
String[] key = {"Item ID"};
String[] value = {"000438"};
String searchName = "Item ID";
ModelObject[] modelObjects = Query.queryItems(searchName,key,value);
Item prod = (Item) modelObjects[0];
ItemRevision rev = null;
dataManagementService.getProperties(new ModelObject[]{prod},prodpros);
try {
ModelObject[] mod = prod.get_revision_list();
if (mod != null && mod.length > 0) {
rev = (ItemRevision)mod[mod.length - 1];
}
dataManagementService.getProperties(new ModelObject[]{rev},revprops);
ModelObject[] obj = rev.get_IMAN_classification();
dataManagementService.getProperties(obj,new String[] {"object_name"});
Icm0 icm0 = (Icm0)obj[0];
try {
//根据Icm0获取对象
// Classification.FindClassifiedObjectsResponse response1 = classificationService.findClassifiedObjects(new ModelObject[]{icm0});
//根据Icm0获取到分类中的对象
Classification.GetClassificationObjectsResponse response = classificationService.getClassificationObjects(new ModelObject[]{icm0});
String classId = response.clsObjs.get(icm0).classId;
//根据classid获取属性
Classification.GetAttributesForClassesResponse response1 = classificationService.getAttributesForClasses(new String[] {classId});
Map<String, Classification.ClassAttribute[]> attributes = response1.attributes;
for (Map.Entry<String, Classification.ClassAttribute[]> attribute : attributes.entrySet()) {
System.out.println("key=>" + attribute.getKey());
Classification.ClassAttribute[] cas = attribute.getValue();
for (Classification.ClassAttribute ca : cas) {
System.out.println("id=>" + ca.id);
System.out.println("name=>" + ca.name);
System.out.println("options=>" + ca.options);
}
}
// System.out.println("response.clsObjs.classId==>" + response.clsObjs.get(icm0).classId);
// ModelObject object =response.clsObjs.get(icm0).clsObjTag;
// System.out.println("response.clsObjs.getUid==>" + object.getUid());
// Classification.ClassificationObject o = (Classification.ClassificationObject)object;
// System.out.println("response.clsObjs.instanceId==>" + response.clsObjs.get(icm0).instanceId);
// System.out.println("response.clsObjs.unitBase==>" + response.clsObjs.get(icm0).unitBase);
// System.out.println("response.clsObjs.wsoId.getUid==>" + response.clsObjs.get(icm0).wsoId.getUid());
// Classification.ClassificationProperty[] properties = response.clsObjs.get(icm0).properties;
// for (Classification.ClassificationProperty property : properties){
// System.out.println("属性ID==>" + property.attributeId);
// //根据classid获取属性
// System.out.println("属性Value长度==>" + property.values.length);
// if (property.values.length > 0) {
// System.out.println("属性displayValue==>" + property.values[0].displayValue);
// //这个是值
// System.out.println("属性dbValue==>" + property.values[0].dbValue);
// }
// }
} catch (ServiceException e) {
e.printStackTrace();
}
} catch (NotLoadedException e) {
e.printStackTrace();
}
// WorkspaceObject[] obj = new WorkspaceObject[]{prod};
// DataManagement.WhereReferencedResponse response = dataManagementService.whereReferenced(obj,3);
// System.out.println("长度1===》" + response.output.length);
// DataManagement.WhereReferencedInfo[] info = response.output[0].info;
// System.out.println("长度2===》" + info.length);
// System.out.println("relation===》" + info[0].relation);
// System.out.println("referencer===》" + info[0].referencer.getUid());
// System.out.println("level===》" + info[0].level);
}
@Test
public void test02(){
String type = "HG8_DL02Form";
JSONObject jsonObject = new JSONObject();
FileInputStream fileInputStream = null;
InputStream in = null;
try {
fileInputStream = new FileInputStream("D://123//大类清单配置.xlsx");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
ExcelReader reader = new ExcelReader(fileInputStream,type);
String type1 = reader.getSheet().getSheetName();
System.out.println("sheet页数" + reader.getSheetCount() + ",类型:" + type1);
List<Object> props = reader.readColumn(0,1);
for (Object str : props) {
jsonObject.put(str.toString(),str);
}
System.out.println(jsonObject.toString());
}
@Test
public void test03() throws NotLoadedException {
String[] prop = {"bl_rev_object_type","bl_item_object_type"};
String[] key = {"MateCode"};
String[] value = {"9468127"};
String searchName = "产品信息查询";
ModelObject[] modelObjects = Query.queryItems(searchName,key,value);
ItemRevision rev = (ItemRevision) modelObjects[0];
createBOMWindowsInfo[0] = new StructureManagement.CreateBOMWindowsInfo();
createBOMWindowsInfo[0].itemRev = rev;
StructureManagement.CreateBOMWindowsResponse createBOMWindowsResponse = smService.createBOMWindows(createBOMWindowsInfo);
BOMLine topBomLine = (BOMLine) createBOMWindowsResponse.output[0].bomLine;
dataManagementService.getProperties(new BOMLine[]{topBomLine},new String[]{"bl_child_lines"});
ModelObject[] childrenBomLines = topBomLine.get_bl_child_lines();
dataManagementService.getProperties(childrenBomLines,prop);
if (childrenBomLines != null && childrenBomLines.length > 0) {
String revtype =((BOMLine)childrenBomLines[0]).get_bl_rev_object_type();
String itemtype =((BOMLine)childrenBomLines[0]).get_bl_item_object_type();
System.out.println("版本类型==》" + revtype);
System.out.println("对象类型==》" + itemtype);
}
}
@Test
public void test04(){
}
@Test
public void test05(){
// String[] key = {"date"};
String[] key = {"Released After"};
// String[] key = {"发布时间晚于"};
// String[] value = {"2022-5-11 00:00"};
String[] value = {"13-May-2022 13:45"};
// String searchName = "产品时间查询";
// String searchName = "Test";
String searchName = "QueryCateBomByTime";
// String searchName = "General...";
ModelObject[] modelObjects = Query.queryItems(searchName,key,value);
System.out.println("长度:" + modelObjects.length);
}
@Test
public void test06() throws ParseException {
String sdfStr = "d-MMM-yyyy HH:mm";
String str = "2022-05-11 12:30:00";
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat sdf_en = new SimpleDateFormat(sdfStr, Locale.ENGLISH);
String date = sdf_en.format(format.parse(str));
System.out.println("date=" + date);
}
@Test
public void test07() throws NotLoadedException {
ModelObject obj = getPUID("QMkJs$aMpRsZiB");
com.teamcenter.services.strong.core._2007_06.DataManagement.WhereReferencedByRelationNameInfo[] var1 = new com.teamcenter.services.strong.core._2007_06.DataManagement.WhereReferencedByRelationNameInfo[1];
com.teamcenter.services.strong.core._2007_06.DataManagement.RelationAndTypesFilter[] filter = new com.teamcenter.services.strong.core._2007_06.DataManagement.RelationAndTypesFilter[1];
System.out.println(filter[0]==null);
System.out.println(var1[0]==null);
filter[0] = new DataManagement.RelationAndTypesFilter();
filter[0].relationTypeName = "HG8_MatchBOM2";
filter[0].otherSideObjectTypes = new String[] {"HG8_ProductRevision"};
var1[0] = new DataManagement.WhereReferencedByRelationNameInfo();
var1[0].object = obj;
var1[0].filter = filter;
com.teamcenter.services.strong.core._2007_06.DataManagement.WhereReferencedByRelationNameResponse response = dataManagementService.whereReferencedByRelationName(var1,1);
com.teamcenter.services.strong.core._2007_06.DataManagement.WhereReferencedByRelationNameOutputInfo[] info = response.output[0].info;
for (int i = 0; i < info.length; i++) {
ModelObject rev = info[i].referencer;
dataManagementService.getProperties(new ModelObject[]{rev},new String[]{"object_type","object_name"});
System.out.println("PUID=" + rev.getUid());
System.out.println("object_type=" + rev.getPropertyObject("object_type").getStringValue());
System.out.println("object_name=" + rev.getPropertyObject("object_type").getStringValue());
System.out.println("relationTypeName=" + info[i].relationTypeName);
System.out.println("level=" + info[i].level);
}
}
@Test
public void test09() {
ModelObject obj =getPUID("hikJVVDvpRsZiB");
Map<String,String> map = new HashMap<>();
map.put("hg8_DrawNo","AAAAAAAAAAAAAA");
try {
setProperty(obj,map,null);
} catch (Exception e) {
e.printStackTrace();
}
}
public static void setByPass(boolean b) throws Exception {
com.teamcenter.services.strong.core._2007_12.Session.StateNameValue[] propPairs = new com.teamcenter.services.strong.core._2007_12.Session.StateNameValue[1];
propPairs[0] = new Session.StateNameValue();
propPairs[0].name = "bypassFlag";
propPairs[0].value = com.teamcenter.soa.client.model.Property.toBooleanString(b);
ServiceData data = sessionService.getService(AppXSession.getConnection()).setUserSessionState(propPairs);
if(displayErrors(data).length() > 0){
throw new Exception(b?"开启旁路失败!":"关闭旁路失败!");
}
}
public static void setProperty(ModelObject object,Map<String,String> valueMap) throws Exception{
Map<String, com.teamcenter.services.strong.core._2007_01.DataManagement.VecStruct> vecStructMap = new HashMap<>();
for (Map.Entry<String,String> map : valueMap.entrySet()) {
com.teamcenter.services.strong.core._2007_01.DataManagement.VecStruct vecStruct = new com.teamcenter.services.strong.core._2007_01.DataManagement.VecStruct();
vecStruct.stringVec = new String[]{ map.getValue() };
vecStructMap.put(map.getKey(),vecStruct);
}
setByPass(true);
ServiceData serviceData = dataManagementService.setProperties(new ModelObject[]{object},vecStructMap);
setByPass(false);
if(displayErrors(serviceData).length() > 0){
throw new Exception("设置属性发生错误!!!");
}
}
//显示报错
public static String displayErrors(ServiceData serviceData)
{
StringBuffer buf = new StringBuffer();
for (int x = 0; x < serviceData.sizeOfPartialErrors(); ++x)
{
String[] messages = serviceData.getPartialError(x).getMessages();
for (int y = 0; y < messages.length; ++y)
{
buf.append( messages[y] );
buf.append( "\n" );
}
}
String errorMessage = buf.toString();
return errorMessage;
}
public static void setProperty(ModelObject object,Map<String,String> valueMap,String str) throws Exception{
int size = valueMap.size();
int num = 0;
com.teamcenter.services.strong.core._2010_09.DataManagement.PropInfo[] propInfos = new com.teamcenter.services.strong.core._2010_09.DataManagement.PropInfo[size];
for (Map.Entry<String,String> map : valueMap.entrySet()) {
com.teamcenter.services.strong.core._2010_09.DataManagement.NameValueStruct1[] vecNameVal = new com.teamcenter.services.strong.core._2010_09.DataManagement.NameValueStruct1[1];
vecNameVal[0] = new com.teamcenter.services.strong.core._2010_09.DataManagement.NameValueStruct1();
propInfos[num] = new com.teamcenter.services.strong.core._2010_09.DataManagement.PropInfo();
vecNameVal[0].name = map.getKey();
vecNameVal[0].values = new String[]{map.getValue()};
propInfos[num].object = object;
propInfos[num].vecNameVal = vecNameVal;
}
setByPass(true);
com.teamcenter.services.strong.core._2010_09.DataManagement.SetPropertyResponse response = dataManagementService.setProperties(propInfos,new String[]{str});
setByPass(false);
if(displayErrors(response.data).length() > 0){
throw new Exception("设置属性2发生错误");
}
}
@Test
public void TT() {
tdd<String> t = new tdd<>();
t.setT("22");
System.out.println("t=" + t.getT());
}
@Test
public void main() {
int[] nums = {2,7,11,15};
int target = 9;
twoSum(nums,target);
}
private int getValue(String s,int max){
List<Character> clist = new ArrayList<>();
char[] cs = s.toCharArray();
int size = 0;
String s1 = "";
for (char c : cs) {
if (clist.contains(c)) {
size = clist.size();
max = size > max ? size : max;
if (s.length() > 1){
s1 = s.substring(1);
max = getValue(s.substring(1),max);
}
return max;
}
clist.add(c);
}
return 0;
}
public int[] twoSum(int[] nums, int target) {
for (int i = 0, len = nums.length; i < len; i++) {
for (int j = 0; j < len; j++) {
if (i != j && (nums[i] + nums[j]) == target){
return new int[]{i,j};
}
}
}
return null;
}
}
class tdd<T> {
private T t;
public T getT() {
return t;
}
public void setT(T t) {
this.t = t;
}
public void opt() {
}
}
Loading…
Cancel
Save