From e4512322951da44bb7dfda136e5242f803435d4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=9F=E4=BD=B3?= Date: Wed, 16 Mar 2022 18:10:32 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=91=E6=9C=9F=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hs_err_pid15044.log | 192 -------- hs_err_pid18240.log | 192 -------- pom.xml | 41 +- .../ts_obj/Util/CustomTableRenderPolicy.java | 64 +++ .../com/example/ts_obj/Util/SectionUtil.java | 39 ++ .../example/ts_obj/Util/VerifyCodeUtils.java | 2 +- .../example/ts_obj/Util/XWPFHelperTable.java | 278 ++++++++++++ .../ts_obj/controller/DataapiController.java | 2 +- .../ts_obj/controller/TypesetController.java | 421 +++++++++++------- .../ts_obj/controller/UserController.java | 28 +- .../example/ts_obj/service/UserService.java | 8 +- 11 files changed, 682 insertions(+), 585 deletions(-) delete mode 100644 hs_err_pid15044.log delete mode 100644 hs_err_pid18240.log create mode 100644 src/main/java/com/example/ts_obj/Util/CustomTableRenderPolicy.java create mode 100644 src/main/java/com/example/ts_obj/Util/SectionUtil.java create mode 100644 src/main/java/com/example/ts_obj/Util/XWPFHelperTable.java diff --git a/hs_err_pid15044.log b/hs_err_pid15044.log deleted file mode 100644 index 4952f93..0000000 --- a/hs_err_pid15044.log +++ /dev/null @@ -1,192 +0,0 @@ -# -# There is insufficient memory for the Java Runtime Environment to continue. -# Native memory allocation (mmap) failed to map 268435456 bytes for Failed to commit area from 0x0000000701000000 to 0x0000000711000000 of length 268435456. -# Possible reasons: -# The system is out of physical RAM or swap space -# The process is running with CompressedOops enabled, and the Java Heap may be blocking the growth of the native heap -# Possible solutions: -# Reduce memory load on the system -# Increase physical memory or swap space -# Check if swap backing store is full -# 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 (./src/hotspot/os/windows/os_windows.cpp:3311), pid=15044, tid=16008 -# -# JRE version: (11.0.12+7) (build ) -# Java VM: OpenJDK 64-Bit Server VM (11.0.12+7-LTS, mixed mode, sharing, tiered, compressed oops, g1 gc, windows-amd64) -# No core dump will be written. Minidumps are not enabled by default on client versions of Windows -# - ---------------- S U M M A R Y ------------ - -Command Line: C:\Users\ADMINI~1\AppData\Local\Temp\surefire10008181636460670627\surefirebooter13783129684859538853.jar C:\Users\Administrator\AppData\Local\Temp\surefire10008181636460670627 2021-12-15T16-43-37_878-jvmRun1 surefire5134485466816359046tmp surefire_014976020681817024045tmp - -Host: Intel(R) Core(TM) i5-10400F CPU @ 2.90GHz, 12 cores, 15G, Windows 10 , 64 bit Build 19041 (10.0.19041.292) -Time: Wed Dec 15 16:43:38 2021 中国标准时间 elapsed time: 0.011488 seconds (0d 0h 0m 0s) - ---------------- T H R E A D --------------- - -Current thread (0x000001ba3a5ae000): JavaThread "Unknown thread" [_thread_in_vm, id=16008, stack(0x00000024a5100000,0x00000024a5200000)] - -Stack: [0x00000024a5100000,0x00000024a5200000] -Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) -V [jvm.dll+0x601d7a] -V [jvm.dll+0x78b45e] -V [jvm.dll+0x78cb2f] -V [jvm.dll+0x78d1f3] -V [jvm.dll+0x24bc58] -V [jvm.dll+0x5fef1a] -V [jvm.dll+0x5f39d5] -V [jvm.dll+0x3038fc] -V [jvm.dll+0x303782] -V [jvm.dll+0x3084a6] -V [jvm.dll+0x34d5ff] -V [jvm.dll+0x34d030] -V [jvm.dll+0x2e0a08] -V [jvm.dll+0x2e1b66] -V [jvm.dll+0x7667e7] -V [jvm.dll+0x767f6f] -V [jvm.dll+0x35a389] -V [jvm.dll+0x749870] -V [jvm.dll+0x3c1fbf] -V [jvm.dll+0x3c4491] -C [jli.dll+0x5207] -C [ucrtbase.dll+0x21542] -C [KERNEL32.DLL+0x16fd4] -C [ntdll.dll+0x4cec1] - - ---------------- P R O C E S S --------------- - -Threads class SMR info: -_java_thread_list=0x000001ba3830e9d0, length=0, elements={ -} - -Java Threads: ( => current thread ) - -Other Threads: - 0x000001ba3a5c3000 GCTaskThread "GC Thread#0" [stack: 0x00000024a5200000,0x00000024a5300000] [id=1844] - 0x000001ba3a61f000 ConcurrentGCThread "G1 Main Marker" [stack: 0x00000024a5300000,0x00000024a5400000] [id=2152] - 0x000001ba3a622000 ConcurrentGCThread "G1 Conc#0" [stack: 0x00000024a5400000,0x00000024a5500000] [id=14136] - -[error occurred during error reporting (printing all threads), id 0xc0000005, EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ffc404b00d7] - -VM state:not at safepoint (not fully initialized) - -VM Mutex/Monitor currently owned by a thread: ([mutex/lock_event]) -[0x000001ba3a5ab090] Heap_lock - owner thread: 0x000001ba3a5ae000 - -Heap address: 0x0000000701000000, size: 4080 MB, Compressed Oops mode: Non-zero based: 0x0000000701000000 -Narrow klass base: 0x0000000000000000, Narrow klass shift: 0 - -GC Heap History (0 events): -No events - -Deoptimization events (0 events): -No events - -Classes redefined (0 events): -No events - -Internal exceptions (0 events): -No events - -Events (1 events): -Event: 0.008 Loaded shared library C:\Users\Administrator\.jdks\corretto-11.0.12\bin\zip.dll - - -Dynamic libraries: -0x00007ff61b6f0000 - 0x00007ff61b6fd000 C:\Users\Administrator\.jdks\corretto-11.0.12\bin\java.exe -0x00007ffc6ebb0000 - 0x00007ffc6eda5000 C:\windows\SYSTEM32\ntdll.dll -0x00007ffc6cc20000 - 0x00007ffc6ccdd000 C:\windows\System32\KERNEL32.DLL -0x00007ffc6c950000 - 0x00007ffc6cc17000 C:\windows\System32\KERNELBASE.dll -0x00007ffc6c850000 - 0x00007ffc6c950000 C:\windows\System32\ucrtbase.dll -0x00007ffc67600000 - 0x00007ffc67617000 C:\Users\Administrator\.jdks\corretto-11.0.12\bin\jli.dll -0x00007ffc67930000 - 0x00007ffc67949000 C:\Users\Administrator\.jdks\corretto-11.0.12\bin\VCRUNTIME140.dll -0x00007ffc6cdf0000 - 0x00007ffc6cf90000 C:\windows\System32\USER32.dll -0x00007ffc6c820000 - 0x00007ffc6c842000 C:\windows\System32\win32u.dll -0x00007ffc6d0a0000 - 0x00007ffc6d0ca000 C:\windows\System32\GDI32.dll -0x00007ffc6c450000 - 0x00007ffc6c55a000 C:\windows\System32\gdi32full.dll -0x00007ffc6c380000 - 0x00007ffc6c41d000 C:\windows\System32\msvcp_win.dll -0x00007ffc57960000 - 0x00007ffc57bfa000 C:\windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.19041.1_none_b555e41d4684ddec\COMCTL32.dll -0x00007ffc6ea30000 - 0x00007ffc6eace000 C:\windows\System32\msvcrt.dll -0x00007ffc6cf90000 - 0x00007ffc6cfc0000 C:\windows\System32\IMM32.DLL -0x00007ffc40d20000 - 0x00007ffc40dbb000 C:\Users\Administrator\.jdks\corretto-11.0.12\bin\msvcp140.dll -0x00007ffc401c0000 - 0x00007ffc40d1a000 C:\Users\Administrator\.jdks\corretto-11.0.12\bin\server\jvm.dll -0x00007ffc6e6c0000 - 0x00007ffc6e76a000 C:\windows\System32\ADVAPI32.dll -0x00007ffc6ead0000 - 0x00007ffc6eb6b000 C:\windows\System32\sechost.dll -0x00007ffc6d7e0000 - 0x00007ffc6d903000 C:\windows\System32\RPCRT4.dll -0x00007ffc6cfc0000 - 0x00007ffc6cfc8000 C:\windows\System32\PSAPI.DLL -0x00007ffc3b350000 - 0x00007ffc3b359000 C:\windows\SYSTEM32\WSOCK32.dll -0x00007ffc6d970000 - 0x00007ffc6d9db000 C:\windows\System32\WS2_32.dll -0x00007ffc6bea0000 - 0x00007ffc6beaa000 C:\windows\SYSTEM32\VERSION.dll -0x00007ffc5f230000 - 0x00007ffc5f257000 C:\windows\SYSTEM32\WINMM.dll -0x00007ffc6a230000 - 0x00007ffc6a243000 C:\windows\SYSTEM32\kernel.appcore.dll -0x00007ffc5ad50000 - 0x00007ffc5ad60000 C:\Users\Administrator\.jdks\corretto-11.0.12\bin\verify.dll -0x00007ffc58520000 - 0x00007ffc58704000 C:\windows\SYSTEM32\DBGHELP.DLL -0x00007ffc582d0000 - 0x00007ffc582fc000 C:\windows\SYSTEM32\dbgcore.DLL -0x00007ffc6c300000 - 0x00007ffc6c37f000 C:\windows\System32\bcryptPrimitives.dll -0x00007ffc4e2b0000 - 0x00007ffc4e2d8000 C:\Users\Administrator\.jdks\corretto-11.0.12\bin\java.dll -0x00007ffc5a390000 - 0x00007ffc5a39a000 C:\Users\Administrator\.jdks\corretto-11.0.12\bin\jimage.dll -0x00007ffc462d0000 - 0x00007ffc462e7000 C:\Users\Administrator\.jdks\corretto-11.0.12\bin\zip.dll - -dbghelp: loaded successfully - version: 4.0.5 - missing functions: none -symbol engine: initialized successfully - sym options: 0x614 - pdb path: .;C:\Users\Administrator\.jdks\corretto-11.0.12\bin;C:\windows\SYSTEM32;C:\windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.19041.1_none_b555e41d4684ddec;C:\Users\Administrator\.jdks\corretto-11.0.12\bin\server - -VM Arguments: -java_command: C:\Users\ADMINI~1\AppData\Local\Temp\surefire10008181636460670627\surefirebooter13783129684859538853.jar C:\Users\Administrator\AppData\Local\Temp\surefire10008181636460670627 2021-12-15T16-43-37_878-jvmRun1 surefire5134485466816359046tmp surefire_014976020681817024045tmp -java_class_path (initial): C:\Users\ADMINI~1\AppData\Local\Temp\surefire10008181636460670627\surefirebooter13783129684859538853.jar -Launcher Type: SUN_STANDARD - -[Global flags] - intx CICompilerCount = 4 {product} {ergonomic} - uint ConcGCThreads = 3 {product} {ergonomic} - uint G1ConcRefinementThreads = 10 {product} {ergonomic} - size_t G1HeapRegionSize = 1048576 {product} {ergonomic} - uintx GCDrainStackTargetSize = 64 {product} {ergonomic} - size_t InitialHeapSize = 268435456 {product} {ergonomic} - size_t MarkStackSize = 4194304 {product} {ergonomic} - size_t MaxHeapSize = 4278190080 {product} {ergonomic} - size_t MinHeapDeltaBytes = 1048576 {product} {ergonomic} - uintx NonNMethodCodeHeapSize = 5836300 {pd product} {ergonomic} - uintx NonProfiledCodeHeapSize = 122910970 {pd product} {ergonomic} - uintx ProfiledCodeHeapSize = 122910970 {pd product} {ergonomic} - uintx ReservedCodeCacheSize = 251658240 {pd product} {ergonomic} - bool SegmentedCodeCache = true {product} {ergonomic} - bool UseCompressedClassPointers = true {lp64_product} {ergonomic} - bool UseCompressedOops = true {lp64_product} {ergonomic} - bool UseG1GC = true {product} {ergonomic} - bool UseLargePagesIndividualAllocation = false {pd product} {ergonomic} - -Logging: -Log output configuration: - #0: stdout all=warning uptime,level,tags - #1: stderr all=off uptime,level,tags - -Environment Variables: -PATH=E:\vm\bin\;C:\Program Files\Common Files\Oracle\Java\javapath;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 (x86)\HP\Common\HPDestPlgIn\;C:\Program Files\Git\cmd;C:\Program Files\TortoiseGit\bin;D:\putty\;C:\Program Files\nodejs\;D:\phpstudy_pro\Extensions\php\php7.3.4nts;C:\ProgramData\ComposerSetup\bin;C:\Program Files\python;C:\Program Files\python\Scripts;;D:\BtSoft\panel\script;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;C:\Program Files (x86)\HP\Common\HPDestPlgIn\;D:\Microsoft VS Code\bin;C:\Users\Administrator\AppData\Roaming\npm;C:\Users\Administrator\AppData\Roaming\Composer\vendor\bin;E:\IntelliJ IDEA 2021.1.2\bin; -USERNAME=Administrator -OS=Windows_NT -PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 165 Stepping 3, GenuineIntel - - - ---------------- S Y S T E M --------------- - -OS: Windows 10 , 64 bit Build 19041 (10.0.19041.292) -OS uptime: 0 days 7:46 hours - -CPU:total 12 (initial active 12) (6 cores per cpu, 2 threads per core) family 6 model 165 stepping 3 microcode 0xcc, 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, fma - -Memory: 4k page, system-wide physical 16315M (2805M free) -TotalPageFile size 23890M (AvailPageFile size 127M) -current process WorkingSet (physical memory assigned to process): 10M, peak: 10M -current process commit charge ("private bytes"): 64M, peak: 320M - -vm_info: OpenJDK 64-Bit Server VM (11.0.12+7-LTS) for windows-amd64 JRE (11.0.12+7-LTS), built on Jul 13 2021 17:58:36 by "Administrator" with unknown MS VC++:1916 - -END. diff --git a/hs_err_pid18240.log b/hs_err_pid18240.log deleted file mode 100644 index 974928d..0000000 --- a/hs_err_pid18240.log +++ /dev/null @@ -1,192 +0,0 @@ -# -# There is insufficient memory for the Java Runtime Environment to continue. -# Native memory allocation (mmap) failed to map 268435456 bytes for Failed to commit area from 0x0000000701000000 to 0x0000000711000000 of length 268435456. -# Possible reasons: -# The system is out of physical RAM or swap space -# The process is running with CompressedOops enabled, and the Java Heap may be blocking the growth of the native heap -# Possible solutions: -# Reduce memory load on the system -# Increase physical memory or swap space -# Check if swap backing store is full -# 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 (./src/hotspot/os/windows/os_windows.cpp:3311), pid=18240, tid=17724 -# -# JRE version: (11.0.12+7) (build ) -# Java VM: OpenJDK 64-Bit Server VM (11.0.12+7-LTS, mixed mode, sharing, tiered, compressed oops, g1 gc, windows-amd64) -# No core dump will be written. Minidumps are not enabled by default on client versions of Windows -# - ---------------- S U M M A R Y ------------ - -Command Line: C:\Users\ADMINI~1\AppData\Local\Temp\surefire7037757628362963651\surefirebooter1583124104524680295.jar C:\Users\Administrator\AppData\Local\Temp\surefire7037757628362963651 2021-12-15T16-42-38_168-jvmRun1 surefire2885657478469464408tmp surefire_012374327702175078940tmp - -Host: Intel(R) Core(TM) i5-10400F CPU @ 2.90GHz, 12 cores, 15G, Windows 10 , 64 bit Build 19041 (10.0.19041.292) -Time: Wed Dec 15 16:42:38 2021 中国标准时间 elapsed time: 0.022441 seconds (0d 0h 0m 0s) - ---------------- T H R E A D --------------- - -Current thread (0x00000217c0229800): JavaThread "Unknown thread" [_thread_in_vm, id=17724, stack(0x000000a127600000,0x000000a127700000)] - -Stack: [0x000000a127600000,0x000000a127700000] -Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) -V [jvm.dll+0x601d7a] -V [jvm.dll+0x78b45e] -V [jvm.dll+0x78cb2f] -V [jvm.dll+0x78d1f3] -V [jvm.dll+0x24bc58] -V [jvm.dll+0x5fef1a] -V [jvm.dll+0x5f39d5] -V [jvm.dll+0x3038fc] -V [jvm.dll+0x303782] -V [jvm.dll+0x3084a6] -V [jvm.dll+0x34d5ff] -V [jvm.dll+0x34d030] -V [jvm.dll+0x2e0a08] -V [jvm.dll+0x2e1b66] -V [jvm.dll+0x7667e7] -V [jvm.dll+0x767f6f] -V [jvm.dll+0x35a389] -V [jvm.dll+0x749870] -V [jvm.dll+0x3c1fbf] -V [jvm.dll+0x3c4491] -C [jli.dll+0x5207] -C [ucrtbase.dll+0x21542] -C [KERNEL32.DLL+0x16fd4] -C [ntdll.dll+0x4cec1] - - ---------------- P R O C E S S --------------- - -Threads class SMR info: -_java_thread_list=0x00000217be0f2580, length=0, elements={ -} - -Java Threads: ( => current thread ) - -Other Threads: - 0x00000217c0241800 GCTaskThread "GC Thread#0" [stack: 0x000000a127700000,0x000000a127800000] [id=4564] - 0x00000217c029f000 ConcurrentGCThread "G1 Main Marker" [stack: 0x000000a127800000,0x000000a127900000] [id=17452] - 0x00000217c02a2000 ConcurrentGCThread "G1 Conc#0" [stack: 0x000000a127900000,0x000000a127a00000] [id=15480] - -[error occurred during error reporting (printing all threads), id 0xc0000005, EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ffc404b00d7] - -VM state:not at safepoint (not fully initialized) - -VM Mutex/Monitor currently owned by a thread: ([mutex/lock_event]) -[0x00000217c0226840] Heap_lock - owner thread: 0x00000217c0229800 - -Heap address: 0x0000000701000000, size: 4080 MB, Compressed Oops mode: Non-zero based: 0x0000000701000000 -Narrow klass base: 0x0000000000000000, Narrow klass shift: 0 - -GC Heap History (0 events): -No events - -Deoptimization events (0 events): -No events - -Classes redefined (0 events): -No events - -Internal exceptions (0 events): -No events - -Events (1 events): -Event: 0.008 Loaded shared library C:\Users\Administrator\.jdks\corretto-11.0.12\bin\zip.dll - - -Dynamic libraries: -0x00007ff61b6f0000 - 0x00007ff61b6fd000 C:\Users\Administrator\.jdks\corretto-11.0.12\bin\java.exe -0x00007ffc6ebb0000 - 0x00007ffc6eda5000 C:\windows\SYSTEM32\ntdll.dll -0x00007ffc6cc20000 - 0x00007ffc6ccdd000 C:\windows\System32\KERNEL32.DLL -0x00007ffc6c950000 - 0x00007ffc6cc17000 C:\windows\System32\KERNELBASE.dll -0x00007ffc6c850000 - 0x00007ffc6c950000 C:\windows\System32\ucrtbase.dll -0x00007ffc67600000 - 0x00007ffc67617000 C:\Users\Administrator\.jdks\corretto-11.0.12\bin\jli.dll -0x00007ffc67930000 - 0x00007ffc67949000 C:\Users\Administrator\.jdks\corretto-11.0.12\bin\VCRUNTIME140.dll -0x00007ffc6cdf0000 - 0x00007ffc6cf90000 C:\windows\System32\USER32.dll -0x00007ffc6c820000 - 0x00007ffc6c842000 C:\windows\System32\win32u.dll -0x00007ffc6d0a0000 - 0x00007ffc6d0ca000 C:\windows\System32\GDI32.dll -0x00007ffc6c450000 - 0x00007ffc6c55a000 C:\windows\System32\gdi32full.dll -0x00007ffc6c380000 - 0x00007ffc6c41d000 C:\windows\System32\msvcp_win.dll -0x00007ffc57960000 - 0x00007ffc57bfa000 C:\windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.19041.1_none_b555e41d4684ddec\COMCTL32.dll -0x00007ffc6ea30000 - 0x00007ffc6eace000 C:\windows\System32\msvcrt.dll -0x00007ffc6cf90000 - 0x00007ffc6cfc0000 C:\windows\System32\IMM32.DLL -0x00007ffc40d20000 - 0x00007ffc40dbb000 C:\Users\Administrator\.jdks\corretto-11.0.12\bin\msvcp140.dll -0x00007ffc401c0000 - 0x00007ffc40d1a000 C:\Users\Administrator\.jdks\corretto-11.0.12\bin\server\jvm.dll -0x00007ffc6e6c0000 - 0x00007ffc6e76a000 C:\windows\System32\ADVAPI32.dll -0x00007ffc6ead0000 - 0x00007ffc6eb6b000 C:\windows\System32\sechost.dll -0x00007ffc6d7e0000 - 0x00007ffc6d903000 C:\windows\System32\RPCRT4.dll -0x00007ffc6cfc0000 - 0x00007ffc6cfc8000 C:\windows\System32\PSAPI.DLL -0x00007ffc5f230000 - 0x00007ffc5f257000 C:\windows\SYSTEM32\WINMM.dll -0x00007ffc3b350000 - 0x00007ffc3b359000 C:\windows\SYSTEM32\WSOCK32.dll -0x00007ffc6d970000 - 0x00007ffc6d9db000 C:\windows\System32\WS2_32.dll -0x00007ffc6bea0000 - 0x00007ffc6beaa000 C:\windows\SYSTEM32\VERSION.dll -0x00007ffc6a230000 - 0x00007ffc6a243000 C:\windows\SYSTEM32\kernel.appcore.dll -0x00007ffc5ad50000 - 0x00007ffc5ad60000 C:\Users\Administrator\.jdks\corretto-11.0.12\bin\verify.dll -0x00007ffc58520000 - 0x00007ffc58704000 C:\windows\SYSTEM32\DBGHELP.DLL -0x00007ffc582d0000 - 0x00007ffc582fc000 C:\windows\SYSTEM32\dbgcore.DLL -0x00007ffc6c300000 - 0x00007ffc6c37f000 C:\windows\System32\bcryptPrimitives.dll -0x00007ffc4e2b0000 - 0x00007ffc4e2d8000 C:\Users\Administrator\.jdks\corretto-11.0.12\bin\java.dll -0x00007ffc5a390000 - 0x00007ffc5a39a000 C:\Users\Administrator\.jdks\corretto-11.0.12\bin\jimage.dll -0x00007ffc462d0000 - 0x00007ffc462e7000 C:\Users\Administrator\.jdks\corretto-11.0.12\bin\zip.dll - -dbghelp: loaded successfully - version: 4.0.5 - missing functions: none -symbol engine: initialized successfully - sym options: 0x614 - pdb path: .;C:\Users\Administrator\.jdks\corretto-11.0.12\bin;C:\windows\SYSTEM32;C:\windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.19041.1_none_b555e41d4684ddec;C:\Users\Administrator\.jdks\corretto-11.0.12\bin\server - -VM Arguments: -java_command: C:\Users\ADMINI~1\AppData\Local\Temp\surefire7037757628362963651\surefirebooter1583124104524680295.jar C:\Users\Administrator\AppData\Local\Temp\surefire7037757628362963651 2021-12-15T16-42-38_168-jvmRun1 surefire2885657478469464408tmp surefire_012374327702175078940tmp -java_class_path (initial): C:\Users\ADMINI~1\AppData\Local\Temp\surefire7037757628362963651\surefirebooter1583124104524680295.jar -Launcher Type: SUN_STANDARD - -[Global flags] - intx CICompilerCount = 4 {product} {ergonomic} - uint ConcGCThreads = 3 {product} {ergonomic} - uint G1ConcRefinementThreads = 10 {product} {ergonomic} - size_t G1HeapRegionSize = 1048576 {product} {ergonomic} - uintx GCDrainStackTargetSize = 64 {product} {ergonomic} - size_t InitialHeapSize = 268435456 {product} {ergonomic} - size_t MarkStackSize = 4194304 {product} {ergonomic} - size_t MaxHeapSize = 4278190080 {product} {ergonomic} - size_t MinHeapDeltaBytes = 1048576 {product} {ergonomic} - uintx NonNMethodCodeHeapSize = 5836300 {pd product} {ergonomic} - uintx NonProfiledCodeHeapSize = 122910970 {pd product} {ergonomic} - uintx ProfiledCodeHeapSize = 122910970 {pd product} {ergonomic} - uintx ReservedCodeCacheSize = 251658240 {pd product} {ergonomic} - bool SegmentedCodeCache = true {product} {ergonomic} - bool UseCompressedClassPointers = true {lp64_product} {ergonomic} - bool UseCompressedOops = true {lp64_product} {ergonomic} - bool UseG1GC = true {product} {ergonomic} - bool UseLargePagesIndividualAllocation = false {pd product} {ergonomic} - -Logging: -Log output configuration: - #0: stdout all=warning uptime,level,tags - #1: stderr all=off uptime,level,tags - -Environment Variables: -PATH=E:\vm\bin\;C:\Program Files\Common Files\Oracle\Java\javapath;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 (x86)\HP\Common\HPDestPlgIn\;C:\Program Files\Git\cmd;C:\Program Files\TortoiseGit\bin;D:\putty\;C:\Program Files\nodejs\;D:\phpstudy_pro\Extensions\php\php7.3.4nts;C:\ProgramData\ComposerSetup\bin;C:\Program Files\python;C:\Program Files\python\Scripts;;D:\BtSoft\panel\script;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;C:\Program Files (x86)\HP\Common\HPDestPlgIn\;D:\Microsoft VS Code\bin;C:\Users\Administrator\AppData\Roaming\npm;C:\Users\Administrator\AppData\Roaming\Composer\vendor\bin;E:\IntelliJ IDEA 2021.1.2\bin; -USERNAME=Administrator -OS=Windows_NT -PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 165 Stepping 3, GenuineIntel - - - ---------------- S Y S T E M --------------- - -OS: Windows 10 , 64 bit Build 19041 (10.0.19041.292) -OS uptime: 0 days 7:45 hours - -CPU:total 12 (initial active 12) (6 cores per cpu, 2 threads per core) family 6 model 165 stepping 3 microcode 0xcc, 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, fma - -Memory: 4k page, system-wide physical 16315M (2809M free) -TotalPageFile size 23890M (AvailPageFile size 136M) -current process WorkingSet (physical memory assigned to process): 10M, peak: 10M -current process commit charge ("private bytes"): 64M, peak: 320M - -vm_info: OpenJDK 64-Bit Server VM (11.0.12+7-LTS) for windows-amd64 JRE (11.0.12+7-LTS), built on Jul 13 2021 17:58:36 by "Administrator" with unknown MS VC++:1916 - -END. diff --git a/pom.xml b/pom.xml index f1b2fb2..4ccd4f5 100644 --- a/pom.xml +++ b/pom.xml @@ -16,6 +16,14 @@ 11 + + + + + com.e-iceblue + https://repo.e-iceblue.cn/repository/maven-public/ + + org.springframework.boot @@ -66,17 +74,17 @@ 4.1.2 - - - - - - - - - - - + + + + + + + + + + + com.alibaba fastjson @@ -104,6 +112,17 @@ hutool-all 5.7.18 + + org.projectlombok + lombok + true + + + + e-iceblue + spire.doc.free + 3.9.0 + diff --git a/src/main/java/com/example/ts_obj/Util/CustomTableRenderPolicy.java b/src/main/java/com/example/ts_obj/Util/CustomTableRenderPolicy.java new file mode 100644 index 0000000..5e553ad --- /dev/null +++ b/src/main/java/com/example/ts_obj/Util/CustomTableRenderPolicy.java @@ -0,0 +1,64 @@ +package com.example.ts_obj.Util; + + +import com.deepoove.poi.data.*; +import com.deepoove.poi.data.style.*; +import com.deepoove.poi.policy.AbstractRenderPolicy; +import com.deepoove.poi.policy.TableRenderPolicy; +import com.deepoove.poi.render.RenderContext; +import com.deepoove.poi.util.TableTools; +import com.deepoove.poi.util.UnitUtils; +import com.deepoove.poi.xwpf.BodyContainer; +import com.deepoove.poi.xwpf.BodyContainerFactory; +import org.apache.poi.xwpf.usermodel.XWPFRun; +import org.apache.poi.xwpf.usermodel.XWPFTable; +import org.apache.poi.xwpf.usermodel.XWPFTableRow; +import java.util.*; + +public class CustomTableRenderPolicy extends AbstractRenderPolicy>> { + + @Override + protected void afterRender(RenderContext>> context) { + // 娓呯┖鏍囩 + clearPlaceholder(context, true); + } + + @Override + public void doRender(RenderContext>> context) throws Exception { + XWPFRun run = context.getRun(); + BodyContainer bodyContainer = BodyContainerFactory.getBodyContainer(run); + + List> list = context.getThing(); + HashMap info = (HashMap) list.get(0); + // 瀹氫箟琛屽垪 + int row = list.size(), col = info.size(); + // 鎻掑叆琛ㄦ牸 + XWPFTable table = bodyContainer.insertNewTable(run, row, col); + + for (int i = 0; i < list.size(); i++) { + Iterator> it = list.get(i).entrySet().iterator(); + + List cells = new ArrayList<>(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + cells.add(entry.getValue().toString()); + } + String[] s = new String[cells.size()]; + cells.toArray(s); + //鍒涘缓涓琛屾暟鎹 + RowRenderData data = Rows.create(s); + XWPFTableRow tableRow = table.getRow(i); + //琛ㄦ牸杈规 + table.setInsideHBorder(XWPFTable.XWPFBorderType.NONE, 1, 0, ""); + table.setInsideVBorder(XWPFTable.XWPFBorderType.NONE, 1, 0, ""); + table.setLeftBorder(XWPFTable.XWPFBorderType.NONE, 1, 0, ""); + table.setRightBorder(XWPFTable.XWPFBorderType.NONE, 1, 0, ""); + // 娓叉煋涓琛 + TableRenderPolicy.Helper.renderRow(tableRow, data); + } + // 琛ㄦ牸瀹藉害 + TableTools.setWidth(table, UnitUtils.cm2Twips(14.63f) + "", null); + // 杈规鍜屾牱寮 +// TableTools.borderTable(table, BorderStyle.builder().withType(XWPFTable.XWPFBorderType.NIL).build()); + } +} diff --git a/src/main/java/com/example/ts_obj/Util/SectionUtil.java b/src/main/java/com/example/ts_obj/Util/SectionUtil.java new file mode 100644 index 0000000..a313384 --- /dev/null +++ b/src/main/java/com/example/ts_obj/Util/SectionUtil.java @@ -0,0 +1,39 @@ +package com.example.ts_obj.Util; + +import com.spire.doc.Document; +import com.spire.doc.FileFormat; +import com.spire.doc.Section; +import com.spire.doc.documents.BreakType; +import com.spire.doc.documents.Paragraph; + +/** + * 鍒嗚妭绗﹀伐鍏风被 + */ +public class SectionUtil { + + public static void main(String[] args) { + + + } + + /** + * @param sections 鑺 + * @param paragraphs 娈佃惤 + * @param breakType 鍒嗚妭绗︾被鍨 + */ + private void setSectionsBreak(Integer sections, Integer paragraphs, BreakType breakType) { + //鍔犺浇Word鏂囨。 + Document document = new Document(); + document.loadFromFile("Input.docx"); + + //鑾峰彇绗竴涓妭 0 + Section section = document.getSections().get(sections); + //鎻掑叆鍒嗛〉绗﹀埌绗洓涓钀 3 + Paragraph paragraph = section.getParagraphs().get(paragraphs); + //鍒嗚妭绗 BreakType.Line_Break + paragraph.appendBreak(breakType); + + //淇濆瓨缁撴灉鏂囨。 + document.saveToFile("AddPageBreak.docx", FileFormat.Docx_2013); + } +} diff --git a/src/main/java/com/example/ts_obj/Util/VerifyCodeUtils.java b/src/main/java/com/example/ts_obj/Util/VerifyCodeUtils.java index cecc559..a8c40ba 100644 --- a/src/main/java/com/example/ts_obj/Util/VerifyCodeUtils.java +++ b/src/main/java/com/example/ts_obj/Util/VerifyCodeUtils.java @@ -114,7 +114,7 @@ public class VerifyCodeUtils{ * @param code * @throws IOException */ - public static void outputImage(int w, int h, OutputStream os, String code) throws IOException{ + public static void outputImage(int w, int h, OutputStream os, String code) throws IOException { int verifySize = code.length(); BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); Random rand = new Random(); diff --git a/src/main/java/com/example/ts_obj/Util/XWPFHelperTable.java b/src/main/java/com/example/ts_obj/Util/XWPFHelperTable.java new file mode 100644 index 0000000..b1b0381 --- /dev/null +++ b/src/main/java/com/example/ts_obj/Util/XWPFHelperTable.java @@ -0,0 +1,278 @@ +package com.example.ts_obj.Util; + +/** + * + * @date 2021/12/27 + */ + +import cn.hutool.core.io.FileUtil; +import com.deepoove.poi.XWPFTemplate; +import com.google.common.collect.Maps; +import com.spire.doc.FileFormat; +import com.spire.doc.Section; +import com.spire.doc.documents.BreakType; +import com.spire.doc.documents.Paragraph; +import org.apache.poi.xwpf.usermodel.*; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.*; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.math.BigInteger; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * @Description 鎿嶄綔word鐨勫熀鏈伐鍏风被 + * 2021骞12鏈27鏃 涓婂崍11:12:18 + * + */ +public class XWPFHelperTable { + private static String BASE_DIR_TEMPLATE="d:/upload/data_template.docx"; + + public static void main(String[] args) { + HashMap map = Maps.newHashMap(); + SimpleDateFormat sdf = new SimpleDateFormat("dd MMMM yyyy", Locale.ENGLISH); + map.put("date", sdf.format(new Date())); + List> list = new ArrayList(); + for (int i = 0; i < 4; i++) { + HashMap params = Maps.newHashMap(); + params.put("type", "娴嬭瘯"+ i); + params.put("no", i); + params.put("title", "娴嬭瘯title" + i); + params.put("author", "浣滆" + i); + list.add(params); + } + map.put("list", list); + + XWPFTemplate template = XWPFTemplate.compile(BASE_DIR_TEMPLATE).render(map); + try { + Date date = new Date(); + String dirpath = BASE_DIR_TEMPLATE + new SimpleDateFormat("yyyyMMdd").format(date); + FileUtil.mkdir(new File(dirpath)); + String goFileName = System.currentTimeMillis() + ".docx"; + template.writeAndClose(new FileOutputStream(dirpath + "/" + goFileName)); + } catch (IOException e) { + e.printStackTrace(); + } + } + + /** + * 鍒犻櫎鎸囧畾浣嶇疆鐨勮〃鏍硷紝琚垹闄よ〃鏍煎悗鐨勭储寮曚綅缃 + * @param document + * @param pos + * + */ + public void deleteTableByIndex(XWPFDocument document, int pos) { + Iterator bodyElement = document.getBodyElementsIterator(); + int eIndex = 0, tableIndex = -1; + while(bodyElement.hasNext()) { + IBodyElement element = bodyElement.next(); + BodyElementType elementType = element.getElementType(); + if(elementType == BodyElementType.TABLE) { + tableIndex++; + if(tableIndex == pos) { + break; + } + } + eIndex++; + } + document.removeBodyElement(eIndex); + } + /** + * 鑾峰緱鎸囧畾浣嶇疆鐨勮〃鏍 + * @param document + * @param index + * @return + * + */ + public XWPFTable getTableByIndex(XWPFDocument document, int index) { + List tableList = document.getTables(); + if(tableList == null || index < 0 || index > tableList.size()) { + return null; + } + return tableList.get(index); + } + /** + * 寰楀埌琛ㄦ牸鐨勫唴瀹癸紙绗竴娆¤法琛屽崟鍏冩牸瑙嗕负涓涓紝绗簩娆¤烦杩囪法琛屽悎骞剁殑鍗曞厓鏍硷級 + * @param table + * @return + * + */ + public List> getTableRConten(XWPFTable table) { + List> tableContextList = new ArrayList>(); + for(int rowIndex = 0, rowLen = table.getNumberOfRows(); rowIndex < rowLen; rowIndex++) { + XWPFTableRow row = table.getRow(rowIndex); + List cellContentList = new ArrayList(); + for(int colIndex = 0, colLen = row.getTableCells().size(); colIndex < colLen; colIndex++ ) { + XWPFTableCell cell = row.getCell(colIndex); + CTTc ctTc = cell.getCTTc(); + if(ctTc.isSetTcPr()) { + CTTcPr tcPr = ctTc.getTcPr(); + if(tcPr.isSetHMerge()) { + CTHMerge hMerge = tcPr.getHMerge(); + if(STMerge.RESTART.equals(hMerge.getVal())) { + cellContentList.add(getTableCellContent(cell)); + } + } else if(tcPr.isSetVMerge()) { + CTVMerge vMerge = tcPr.getVMerge(); + if(STMerge.RESTART.equals(vMerge.getVal())) { + cellContentList.add(getTableCellContent(cell)); + } + } else { + cellContentList.add(getTableCellContent(cell)); + } + } + } + tableContextList.add(cellContentList); + } + return tableContextList; + } + + /** + * 鑾峰緱涓涓〃鏍肩殑鍗曞厓鏍肩殑鍐呭 + * @param cell + * @return + * + */ + public String getTableCellContent(XWPFTableCell cell) { + StringBuffer sb = new StringBuffer(); + List cellParagList = cell.getParagraphs(); + if(cellParagList != null && cellParagList.size() > 0) { + for(XWPFParagraph xwpfPr: cellParagList) { + List runs = xwpfPr.getRuns(); + if(runs != null && runs.size() > 0) { + for(XWPFRun xwpfRun : runs) { + sb.append(xwpfRun.getText(0)); + } + } + } + } + return sb.toString(); + } + /** + * 寰楀埌琛ㄦ牸鍐呭锛屽悎骞跺悗鐨勫崟鍏冩牸瑙嗕负涓涓崟鍏冩牸 + * @param table + * @return + * + */ + public List> getTableContent(XWPFTable table) { + List> tableContentList = new ArrayList>(); + for (int rowIndex = 0, rowLen = table.getNumberOfRows(); rowIndex < rowLen; rowIndex++) { + XWPFTableRow row = table.getRow(rowIndex); + List cellContentList = new ArrayList(); + for (int colIndex = 0, colLen = row.getTableCells().size(); colIndex < colLen; colIndex++) { + XWPFTableCell cell = row.getCell(colIndex); + cellContentList.add(getTableCellContent(cell)); + } + tableContentList.add(cellContentList); + } + return tableContentList; + } + + /** + * 璺ㄥ垪鍚堝苟 + * @param table + * @param row 鎵鍚堝苟鐨勮 + * @param fromCell 璧峰鍒 + * @param toCell 缁堟鍒 + * @Description + * + */ + public void mergeCellsHorizontal(XWPFTable table, int row, int fromCell, int toCell) { + for(int cellIndex = fromCell; cellIndex <= toCell; cellIndex++ ) { + XWPFTableCell cell = table.getRow(row).getCell(cellIndex); + if(cellIndex == fromCell) { + cell.getCTTc().addNewTcPr().addNewHMerge().setVal(STMerge.RESTART); + } else { + cell.getCTTc().addNewTcPr().addNewHMerge().setVal(STMerge.CONTINUE); + } + } + } + /** + * 璺ㄨ鍚堝苟 + * @param table + * @param col 鍚堝苟鐨勫垪 + * @param fromRow 璧峰琛 + * @param toRow 缁堟琛 + * @Description + * + */ + public void mergeCellsVertically(XWPFTable table, int col, int fromRow, int toRow) { + for(int rowIndex = fromRow; rowIndex <= toRow; rowIndex++) { + XWPFTableCell cell = table.getRow(rowIndex).getCell(col); + //绗竴涓悎骞跺崟鍏冩牸鐢ㄩ噸鍚悎骞跺艰缃 + if(rowIndex == fromRow) { + cell.getCTTc().addNewTcPr().addNewVMerge().setVal(STMerge.RESTART); + } else { + //鍚堝苟绗竴涓崟鍏冩牸鐨勫崟鍏冭璁剧疆涓衡滅户缁 + cell.getCTTc().addNewTcPr().addNewVMerge().setVal(STMerge.CONTINUE); + } + } + } + + /** + * @Description: 鍒涘缓琛ㄦ牸,鍒涘缓鍚庤〃鏍艰嚦灏戞湁1琛1鍒,璁剧疆鍒楀 + */ + public XWPFTable createTable(XWPFDocument xdoc, int rowSize, int cellSize, + boolean isSetColWidth, int[] colWidths) { + XWPFTable table = xdoc.createTable(rowSize, cellSize); + if (isSetColWidth) { + CTTbl ttbl = table.getCTTbl(); + CTTblGrid tblGrid = ttbl.addNewTblGrid(); + for (int j = 0, len = Math.min(cellSize, colWidths.length); j < len; j++) { + CTTblGridCol gridCol = tblGrid.addNewGridCol(); + gridCol.setW(new BigInteger(String.valueOf(colWidths[j]))); + } + } + return table; + } + + /** + * @Description: 璁剧疆琛ㄦ牸鎬诲搴︿笌姘村钩瀵归綈鏂瑰紡 + */ + public void setTableWidthAndHAlign(XWPFTable table, String width, + STJc.Enum enumValue) { + CTTblPr tblPr = getTableCTTblPr(table); + // 琛ㄦ牸瀹藉害 + CTTblWidth tblWidth = tblPr.isSetTblW() ? tblPr.getTblW() : tblPr.addNewTblW(); + if (enumValue != null) { + CTJc cTJc = tblPr.addNewJc(); + cTJc.setVal(enumValue); + } + // 璁剧疆瀹藉害 + tblWidth.setW(new BigInteger(width)); + tblWidth.setType(STTblWidth.DXA); + } + + /** + * @Description: 寰楀埌Table鐨凜TTblPr,涓嶅瓨鍦ㄥ垯鏂板缓 + */ + public CTTblPr getTableCTTblPr(XWPFTable table) { + CTTbl ttbl = table.getCTTbl(); + // 琛ㄦ牸灞炴 + CTTblPr tblPr = ttbl.getTblPr() == null ? ttbl.addNewTblPr() : ttbl.getTblPr(); + return tblPr; + } + + /** + * 璁剧疆琛ㄦ牸琛岄珮 + * @param infoTable + * @param heigth 楂樺害 + * @param vertical 琛ㄦ牸鍐呭鐨勬樉绀烘柟寮忥細灞呬腑銆侀潬鍙... + * + */ + public void setTableHeight(XWPFTable infoTable, int heigth, STVerticalJc.Enum vertical) { + List rows = infoTable.getRows(); + for(XWPFTableRow row : rows) { + CTTrPr trPr = row.getCtRow().addNewTrPr(); + CTHeight ht = trPr.addNewTrHeight(); + ht.setVal(BigInteger.valueOf(heigth)); + List cells = row.getTableCells(); + for(XWPFTableCell tableCell : cells ) { + CTTcPr cttcpr = tableCell.getCTTc().addNewTcPr(); + cttcpr.addNewVAlign().setVal(vertical); + } + } + } +} diff --git a/src/main/java/com/example/ts_obj/controller/DataapiController.java b/src/main/java/com/example/ts_obj/controller/DataapiController.java index cbfbc00..004a7cc 100644 --- a/src/main/java/com/example/ts_obj/controller/DataapiController.java +++ b/src/main/java/com/example/ts_obj/controller/DataapiController.java @@ -53,6 +53,6 @@ public class DataapiController { } catch (IOException e) { e.printStackTrace(); } - return new ReturnValue(ReturnCodeAndMsgEnum.Success); + return new ReturnValue(ReturnCodeAndMsgEnum.Success, result); } } diff --git a/src/main/java/com/example/ts_obj/controller/TypesetController.java b/src/main/java/com/example/ts_obj/controller/TypesetController.java index 615bc60..a0c3e79 100644 --- a/src/main/java/com/example/ts_obj/controller/TypesetController.java +++ b/src/main/java/com/example/ts_obj/controller/TypesetController.java @@ -3,12 +3,12 @@ package com.example.ts_obj.controller; import com.alibaba.fastjson.JSON; import com.deepoove.poi.XWPFTemplate; import com.deepoove.poi.config.Configure; -import com.deepoove.poi.config.ConfigureBuilder; import com.deepoove.poi.data.*; +import com.deepoove.poi.data.style.BorderStyle; import com.deepoove.poi.data.style.Style; -import com.deepoove.poi.policy.NumberingRenderPolicy; +import com.deepoove.poi.data.style.TableStyle; import com.deepoove.poi.policy.ParagraphRenderPolicy; -import com.deepoove.poi.policy.TableRenderPolicy; +import com.example.ts_obj.Util.CustomTableRenderPolicy; import com.example.ts_obj.Util.Util; import com.example.ts_obj.bean.ReturnCodeAndMsgEnum; import com.example.ts_obj.bean.ReturnValue; @@ -18,10 +18,12 @@ import com.example.ts_obj.entity.TypesetInfoReference; import com.example.ts_obj.entity.User; import com.example.ts_obj.service.TypesetService; import com.example.ts_obj.service.UserService; +import com.google.common.collect.Maps; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.poi.openxml4j.util.ZipSecureFile; import org.apache.poi.xwpf.usermodel.*; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -40,8 +42,8 @@ public class TypesetController { private final static Logger logger = LoggerFactory.getLogger(UserController.class); -// private String BASE_DIR="d:/upload/"; - private String BASE_DIR="/home/wwwroot/ts.tmrjournals.com/upload/"; + private String BASE_DIR="d:/upload/"; +// private String BASE_DIR = "/home/wwwroot/ts.tmrjournals.com/upload/"; @Autowired private TypesetService typesetservice; @@ -50,14 +52,14 @@ public class TypesetController { @ApiOperation(value = "娣诲姞鎺掔増瀹炰緥") @PostMapping("/addtypeset") - public ReturnValue addTypeset(String title,Long userid,String journal,String jabbr,String stage,String website, - String received_date,String accepted_date,String doi, - String little_author,String info_type){ + public ReturnValue addTypeset(String title, Long userid, String journal, String jabbr, String stage, String website, + String received_date, String accepted_date, String doi, + String little_author, String info_type) { //娣诲姞涓昏鏁版嵁妯″瀷 Typeset ts = new Typeset(); ts.setArticleFile(""); ts.setTitle(title); - ts.setCtime(System.currentTimeMillis()/1000); + ts.setCtime(System.currentTimeMillis() / 1000); ts.setUserId(userid); typesetservice.addTypeset(ts); //娣诲姞info鏁版嵁 @@ -78,46 +80,46 @@ public class TypesetController { // // Integer res = 1; - Integer res = typesetservice.addTypesetInfo(ti); - if(res>0){ + Integer res = typesetservice.addTypesetInfo(ti); + if (res > 0) { return new ReturnValue(ReturnCodeAndMsgEnum.Success); - }else{ + } else { return new ReturnValue(ReturnCodeAndMsgEnum.SYSTEM_ERROR); } } @ApiOperation(value = "淇敼瀹炰緥淇℃伅") @PostMapping("/editTitle") - public ReturnValue editTypesetTitle(Long typesetId,String title,String journal,String jabbr,String stage,String website, - String received_date,String accepted_date,String doi, - String little_author,String info_type){ - typesetservice.editTypesetTitle(typesetId,title,journal,jabbr,stage,website,received_date,accepted_date,doi,little_author,info_type); + public ReturnValue editTypesetTitle(Long typesetId, String title, String journal, String jabbr, String stage, String website, + String received_date, String accepted_date, String doi, + String little_author, String info_type) { + typesetservice.editTypesetTitle(typesetId, title, journal, jabbr, stage, website, received_date, accepted_date, doi, little_author, info_type); return new ReturnValue(ReturnCodeAndMsgEnum.Success); } @ApiOperation(value = "鑾峰彇鎺掔増瀹炰緥璇︽儏") @PostMapping("/gettypesetdetail") - public ReturnValue getTypesetDetail(Long typesetId){ + public ReturnValue getTypesetDetail(Long typesetId) { Map ts = typesetservice.getTypesetDetail(typesetId); - return new ReturnValue(ReturnCodeAndMsgEnum.Success,ts); + return new ReturnValue(ReturnCodeAndMsgEnum.Success, ts); } @ApiOperation(value = "淇敼鎺掔増") @PostMapping("/editTypesetRefer") - public ReturnValue editTypesetRefer(Long typesetInfoReferenceId,String title){ - typesetservice.editTypesetReference(typesetInfoReferenceId,title); + public ReturnValue editTypesetRefer(Long typesetInfoReferenceId, String title) { + typesetservice.editTypesetReference(typesetInfoReferenceId, title); return new ReturnValue(ReturnCodeAndMsgEnum.Success); } @ApiOperation(value = "缂栬緫鎺掔増info淇℃伅") @PostMapping("/edittypesetinfo") - public ReturnValue editTypeset(Long typesetId,String abstractText,String mainText,String info_type, - String info_title,String author,String authorAddress,String authorContribution, - String doi,String keywords,Byte info_state,String traditon,String topic, - String authorCorresponding,String authorCorrespondingEmail,String little_author, - String acknowledgment,String received_date,String accepted_date,String online_date,String abbreviation - ){ + public ReturnValue editTypeset(Long typesetId, String abstractText, String mainText, String info_type, + String info_title, String author, String authorAddress, String authorContribution, + String doi, String keywords, Byte info_state, String traditon, String topic, + String authorCorresponding, String authorCorrespondingEmail, String little_author, + String acknowledgment, String received_date, String accepted_date, String online_date, String abbreviation + ) { TypesetInfo ti = new TypesetInfo(); ti.setTypesetId(typesetId); ti.setAbstractText(abstractText.trim()); @@ -141,29 +143,29 @@ public class TypesetController { ti.setOnline_date(online_date.trim()); ti.setAbbreviation(abbreviation.trim()); Integer res = typesetservice.editTypesetInfo(ti); - if(res>0){ + if (res > 0) { return new ReturnValue(ReturnCodeAndMsgEnum.Success); - }else{ + } else { return new ReturnValue(ReturnCodeAndMsgEnum.SYSTEM_ERROR); } } @ApiOperation(value = "鑾峰彇鎺掔増瀹炰緥鍒楄〃") @PostMapping("/gettypesetlist") - public ReturnValue getTypesetList(Long userid,Long currentPage,Long pageSize){ - Long startIndex = (currentPage-1)*pageSize; - List ts = typesetservice.getTypesetListByUserId(userid,startIndex,pageSize); + public ReturnValue getTypesetList(Long userid, Long currentPage, Long pageSize) { + Long startIndex = (currentPage - 1) * pageSize; + List ts = typesetservice.getTypesetListByUserId(userid, startIndex, pageSize); Long count = typesetservice.getTypesetListCountByUserId(userid); Map re = new HashMap(); - re.put("list",ts); - re.put("count",count); - return new ReturnValue(ReturnCodeAndMsgEnum.Success,re); + re.put("list", ts); + re.put("count", count); + return new ReturnValue(ReturnCodeAndMsgEnum.Success, re); } @ApiOperation(value = "娣诲姞鎺掔増鐨勫紩鐢ㄦ枃鐚") @PostMapping("/addRederence") - public ReturnValue addTypesetReference(@RequestBody List tir){ - for (TypesetInfoReference t:tir) { + public ReturnValue addTypesetReference(@RequestBody List tir) { + for (TypesetInfoReference t : tir) { typesetservice.addTypesetInfoReference(t); } return new ReturnValue(ReturnCodeAndMsgEnum.Success); @@ -171,7 +173,7 @@ public class TypesetController { @ApiOperation(value = "鍒犻櫎鍙傝冩枃鐚産yid") @PostMapping("/delTypesetReferById") - public ReturnValue delTypesetReferById(Long typeset_info_reference_id){ + public ReturnValue delTypesetReferById(Long typeset_info_reference_id) { typesetservice.delById(typeset_info_reference_id); return new ReturnValue(ReturnCodeAndMsgEnum.Success); } @@ -182,12 +184,77 @@ public class TypesetController { // String filename = "300641ce-cb9b-4a41-b5d9-de7028e46b171639634304222.docx"; - ArrayList al = new ArrayList(); + ArrayList al = new ArrayList(); try { - File file = new File(this.BASE_DIR+filename); + File file = new File(this.BASE_DIR + filename); FileInputStream fis = new FileInputStream(file); XWPFDocument xdoc = new XWPFDocument(fis); List list = xdoc.getParagraphs(); + List tables = xdoc.getTables(); + for (XWPFTable table : tables) { + //琛ㄦ牸灞炴 + CTTblPr pr = table.getCTTbl().getTblPr(); + //鑾峰彇琛ㄦ牸瀵瑰簲鐨勮 + List rows = table.getRows(); + for (XWPFTableRow row : rows) { + //鑾峰彇琛屽搴旂殑鍗曞厓鏍 + List cells = row.getTableCells(); + for (XWPFTableCell cell : cells) { + System.out.println(cell.getText()); + } + } + } + +// List tables = xdoc.getTables(); +// for (XWPFTable table : tables) { +// List rowList = table.getRows(); +// CTTblBorders borders = table.getCTTbl().getTblPr().addNewTblBorders(); +// CTBorder hBorder = borders.addNewInsideH(); +// hBorder.setVal(STBorder.Enum.forString("nil")); +// hBorder.setSz(new BigInteger("1")); +// +// CTBorder vBorder = borders.addNewInsideV(); +// vBorder.setVal(STBorder.Enum.forString("nil")); +// vBorder.setSz(new BigInteger("1")); +// +// CTBorder lBorder = borders.addNewLeft(); +// lBorder.setVal(STBorder.Enum.forString("nil")); +// lBorder.setSz(new BigInteger("1")); +// +// CTBorder rBorder = borders.addNewRight(); +// rBorder.setVal(STBorder.Enum.forString("nil")); +// rBorder.setSz(new BigInteger("1")); +// +// CTBorder tBorder = borders.addNewTop(); +// tBorder.setVal(STBorder.Enum.forString("thick")); +// tBorder.setSz(new BigInteger("10")); +// +// CTBorder bBorder = borders.addNewBottom(); +// bBorder.setVal(STBorder.Enum.forString("thick")); +// bBorder.setSz(new BigInteger("10")); +// +// CTTbl ttbl = table.getCTTbl(); +// CTTblPr tblPr = ttbl.getTblPr() == null ? ttbl.addNewTblPr() : ttbl.getTblPr(); +// CTTblWidth tblWidth = tblPr.isSetTblW() ? tblPr.getTblW() : tblPr.addNewTblW(); +// CTJc cTJc = tblPr.addNewJc(); +// cTJc.setVal(STJc.Enum.forString("center")); +// tblWidth.setW(new BigInteger("8000")); +// tblWidth.setType(STTblWidth.DXA); + + //璁剧疆琛ㄥご鏍峰紡涓庢爣棰 +// List tableCells = rowList.get(0).getTableCells(); +// Iterator fieldIterator = Arrays.stream(TableDetail.class.getDeclaredFields()).iterator(); +// for (XWPFTableCell tableCell : tableCells) { +// Field field = fieldIterator.next(); +// TableField annotation = field.getAnnotation(TableField.class); +// String value = annotation.value(); +// CTTcBorders ctTcBorders = tableCell.getCTTc().addNewTcPr().addNewTcBorders(); +// CTBorder ctBorder = ctTcBorders.addNewBottom(); +// ctBorder.setVal(STBorder.Enum.forString("single")); +// ctBorder.setSz(new BigInteger("1")); +// setCellText(tableCell, value, "FFFFFF", 1600); +// } +// } // Boolean bold = false; for (XWPFParagraph para : list) { // ArrayList cac_al = new ArrayList();//鍔犵矖 @@ -198,23 +265,23 @@ public class TypesetController { // bold = true; // } List runs = para.getRuns(); - for (XWPFRun r:runs){ + for (XWPFRun r : runs) { // if(!bold){ // break; // } String cach = ""; - if(r.getText(0)==null){ + if (r.getText(0) == null) { continue; } - if(r.isItalic()&&r.isBold()){ - cach = ""+r.getText(0)+""; - }else if(r.isItalic()){ - cach = ""+r.getText(0)+""; - }else if(r.isBold()){ - cach = ""+r.getText(0)+""; - }else{ + if (r.isItalic() && r.isBold()) { + cach = "" + r.getText(0) + ""; + } else if (r.isItalic()) { + cach = "" + r.getText(0) + ""; + } else if (r.isBold()) { + cach = "" + r.getText(0) + ""; + } else { cach = r.getText(0); } @@ -242,25 +309,25 @@ public class TypesetController { } catch (Exception e) { e.getStackTrace(); } - return new ReturnValue(ReturnCodeAndMsgEnum.Success,al); + return new ReturnValue(ReturnCodeAndMsgEnum.Success, al); } @PostMapping("/mytest") - public ReturnValue mytest(Long typesetId){ + public ReturnValue mytest(Long typesetId) { try { Map m = typesetservice.getTypesetDetail(typesetId); Typeset t = (Typeset) m.get("info"); TypesetInfo ti = t.getU_typeset_info(); String main = ti.getMainText(); - List l = JSON.parseArray(main,String.class); - for (String s:l){ + List l = JSON.parseArray(main, String.class); + for (String s : l) { System.out.println(s); } // System.out.println(main); // List l = (List) JSON.parseObject(main); // System.out.println(l); - }catch (Exception e){ + } catch (Exception e) { logger.error(e.getMessage()); } return new ReturnValue(ReturnCodeAndMsgEnum.Success); @@ -268,7 +335,7 @@ public class TypesetController { @ApiOperation(value = "娓呯┖寮曠敤鏂囩尞") @PostMapping("/emptyForRefer") - public ReturnValue emptyForRefer(Long typesetId){ + public ReturnValue emptyForRefer(Long typesetId) { typesetservice.emptyForRefer(typesetId); return new ReturnValue(ReturnCodeAndMsgEnum.Success); } @@ -278,66 +345,80 @@ public class TypesetController { public ReturnValue getDocx(Long typesetId) throws IOException { Map m = typesetservice.getTypesetDetail(typesetId); Map frag = new HashMap(); - Typeset t = (Typeset)m.get("info"); + Typeset t = (Typeset) m.get("info"); TypesetInfo ti = t.getU_typeset_info(); - List refList = (List)m.get("refers"); + List refList = (List) m.get("refers"); ZipSecureFile.setMinInflateRatio(-1.0d); - User user = userservice.getUser(t.getUserId()); - HashMap map = new HashMap(); - map.put("type",ti.getInfo_type().toUpperCase()); - map.put("journaltitle",ti.getJournal()); - map.put("stage",ti.getStage()); - map.put("doi",ti.getDoi()); - map.put("topic",ti.getTopic()); - map.put("articletitle",ti.getInfo_title().replace("","").replace("","").replace("","").replace("","")); - map.put("author",ti.getAuthor().replace("","").replace("","").replace("","").replace("","")); - map.put("authoraddress",ti.getAuthorAddress().replace("","").replace("","").replace("","").replace("","")); - map.put("corresponding",ti.getAuthorCorresponding().replace("","").replace("","").replace("","").replace("","")); - map.put("coremail",ti.getAuthorCorrespondingEmail().replace("","").replace("","").replace("","").replace("","")); - map.put("website",ti.getWebsite()); - if(ti.getAuthorContribution().equals("")){ - map.put("contributions",false); - }else{ - HashMap map1 = new HashMap(); - map1.put("author_contribution",ti.getAuthorContribution()); - map.put("contributions",map1); + User user = userservice.getUser(t.getUserId()); + HashMap map = new HashMap<>(); + map.put("type", ti.getInfo_type().toUpperCase()); + map.put("journaltitle", ti.getJournal()); + map.put("stage", ti.getStage()); + map.put("doi", ti.getDoi()); + map.put("topic", ti.getTopic()); + map.put("articletitle", ti.getInfo_title().replace("", "").replace("", "").replace("", "").replace("", "")); + map.put("author", ti.getAuthor().replace("", "").replace("", "").replace("", "").replace("", "")); + map.put("authoraddress", ti.getAuthorAddress().replace("", "").replace("", "").replace("", "").replace("", "")); + map.put("corresponding", ti.getAuthorCorresponding().replace("", "").replace("", "").replace("", "").replace("", "")); + map.put("coremail", ti.getAuthorCorrespondingEmail().replace("", "").replace("", "").replace("", "").replace("", "")); + map.put("website", ti.getWebsite()); + if (ti.getAuthorContribution().equals("")) { + map.put("contributions", false); + } else { + HashMap map1 = new HashMap<>(); + map1.put("author_contribution", ti.getAuthorContribution()); + map.put("contributions", map1); } - if(ti.getAcknowledgment().equals("")){ - map.put("acknowledgment",false); - }else{ + if (ti.getAcknowledgment().equals("")) { + map.put("acknowledgment", false); + } else { HashMap map2 = new HashMap(); - map2.put("acknowledgment_content",ti.getAcknowledgment()); - map.put("acknowledgment",map2); + map2.put("acknowledgment_content", ti.getAcknowledgment()); + map.put("acknowledgment", map2); } - map.put("abbreviation",ti.getAbbreviation()); - map.put("citation",(ti.getLittle_author()+". "+ti.getInfo_title()+". "+ti.getJabbr()+". "+ti.getStage()+". doi: "+ti.getDoi()+".").replace("","").replace("","").replace("","").replace("","")); - map.put("exeditor",user.getAccount()); - SimpleDateFormat sdf = new SimpleDateFormat("dd MMMM yyyy",Locale.ENGLISH); - if(ti.getReceived_date().toString().equals("")){ - map.put("received_date",ti.getReceived_date()); - }else{ - map.put("received_date",sdf.format(new Date(Long.valueOf(ti.getReceived_date())))); + map.put("abbreviation", ti.getAbbreviation()); + map.put("citation", (ti.getLittle_author() + ". " + ti.getInfo_title() + ". " + ti.getJabbr() + ". " + ti.getStage() + ". doi: " + ti.getDoi() + ".").replace("", "").replace("", "").replace("", "").replace("", "")); + map.put("exeditor", user.getAccount()); + SimpleDateFormat sdf = new SimpleDateFormat("dd MMMM yyyy", Locale.ENGLISH); + if (ti.getReceived_date().toString().equals("")) { + map.put("received_date", ti.getReceived_date()); + } else { + map.put("received_date", sdf.format(new Date(Long.valueOf(ti.getReceived_date())))); } // map.put("received_date",sdf.format(new Date(Long.valueOf(ti.getReceived_date())))); - if(ti.getAccepted_date().toString().equals("")){ - map.put("accept_date",ti.getAccepted_date()); - }else{ - map.put("accept_date",sdf.format(new Date(Long.valueOf(ti.getAccepted_date())))); + if (ti.getAccepted_date().toString().equals("")) { + map.put("accept_date", ti.getAccepted_date()); + } else { + map.put("accept_date", sdf.format(new Date(Long.valueOf(ti.getAccepted_date())))); } // map.put("accept_date",sdf.format(new Date(Long.valueOf(ti.getAccepted_date())))); - if(ti.getOnline_date().toString().equals("")){ - map.put("online_date",ti.getOnline_date()); - }else{ - map.put("online_date",sdf.format(new Date(Long.valueOf(ti.getOnline_date())))); + if (ti.getOnline_date().toString().equals("")) { + map.put("online_date", ti.getOnline_date()); + } else { + map.put("online_date", sdf.format(new Date(Long.valueOf(ti.getOnline_date())))); } - map.put("ye",ti.getStage().substring(0,4)); + map.put("ye", ti.getStage().substring(0, 4)); // map.put("abstract",ti.getAbstractText().replace("","").replace("","")); - map.put("abstract",this.crowStr(ti.getAbstractText())); - map.put("keywords",ti.getKeywords().replace("","").replace("","")); - map.put("img", this.BASE_DIR+"p1.png"); + map.put("abstract", this.crowStr(ti.getAbstractText())); + map.put("keywords", ti.getKeywords().replace("", "").replace("", "")); + map.put("img", this.BASE_DIR + "p1.png"); + List list = new ArrayList<>(); + LinkedHashMap params = new LinkedHashMap<>(); + params.put("name", "濮撳悕"); + params.put("age", "骞撮緞"); + params.put("sex", "鎬у埆"); + list.add(params); + for (int i = 0; i < 4; i++) { + HashMap hashMap = new LinkedHashMap<>(); + hashMap.put("name","灏忔潕"+ i); + hashMap.put("age", 23 + i); + hashMap.put("sex", "鐢"); + list.add(hashMap); + } + map.put("table", list); Configure config = Configure.builder().bind("content", new ParagraphRenderPolicy()). - bind("abstract",new ParagraphRenderPolicy()). + bind("abstract", new ParagraphRenderPolicy()).bind("table", new CustomTableRenderPolicy()). build(); // ParagraphRenderData pds = new ParagraphRenderData(); // Style sss1 = new Style(); @@ -350,12 +431,12 @@ public class TypesetController { // map.put("keywords",pds); //part2 String main = ti.getMainText(); - List l = JSON.parseArray(main,String.class); + List l = JSON.parseArray(main, String.class); ArrayList mainArr = new ArrayList(); - for (String s:l){ + for (String s : l) { Map cache = new HashMap(); ParagraphRenderData capd = this.crowStr(s); - cache.put("content",capd); + cache.put("content", capd); // if(s.indexOf("")>=0){ // s = s.replace("","").replace("",""); // Style sty = new Style(); @@ -367,7 +448,7 @@ public class TypesetController { mainArr.add(cache); } - map.put("main",mainArr); + map.put("main", mainArr); //part3 // ArrayList refArr = new ArrayList(); @@ -387,9 +468,9 @@ public class TypesetController { //娴嬭瘯 List refsl = new ArrayList(); - for(TypesetInfoReference tif: refList){ - String tttt = tif.getRefer_title().replace("","").replace("","").replace("","").replace("","").trim().toUpperCase(); - if(tttt.equals("REFERENCE")||tttt.equals("REFERENCES")){ + for (TypesetInfoReference tif : refList) { + String tttt = tif.getRefer_title().replace("", "").replace("", "").replace("", "").replace("", "").trim().toUpperCase(); + if (tttt.equals("REFERENCE") || tttt.equals("REFERENCES")) { continue; } ParagraphRenderData chc_pd = new ParagraphRenderData(); @@ -397,131 +478,131 @@ public class TypesetController { Style chch = new Style(); chch.setFontFamily("Charis SIL"); chch.setFontSize(7.5); - String tgh_title = tif.getRefer_title().replace("","").replace("","").replace("","").replace("",""); - chc_pd.addText(new TextRenderData(tgh_title,chch)); + String tgh_title = tif.getRefer_title().replace("", "").replace("", "").replace("", "").replace("", ""); + chc_pd.addText(new TextRenderData(tgh_title, chch)); refsl.add(chc_pd); } - map.put("refs",new NumberingRenderData(NumberingFormat.DECIMAL,refsl)); + map.put("refs", new NumberingRenderData(NumberingFormat.DECIMAL, refsl)); String myTemplate = ""; //纭畾浣跨敤鐨勬ā鏉 - if(ti.getInfo_type().toUpperCase().equals("COMMENT")||ti.getInfo_type().toUpperCase().equals("NEWS")){ + if (ti.getInfo_type().toUpperCase().equals("COMMENT") || ti.getInfo_type().toUpperCase().equals("NEWS")) { myTemplate = "template2.docx"; - }else{ + } else { myTemplate = "template1.docx"; } - XWPFTemplate template = XWPFTemplate.compile(this.BASE_DIR+myTemplate,config).render(map); + XWPFTemplate template = XWPFTemplate.compile(this.BASE_DIR + myTemplate, config).render(map); try { Date date = new Date(); - String dirpath=this.BASE_DIR+new SimpleDateFormat("yyyyMMdd").format(date); + String dirpath = this.BASE_DIR + new SimpleDateFormat("yyyyMMdd").format(date); //濡傛灉涓嶅瓨鍦,鍒涘缓鏂囦欢澶 File f = new File(dirpath); - if(!f.exists()){ + if (!f.exists()) { f.mkdirs(); } - String goFileName = System.currentTimeMillis()+".docx"; - frag.put("file",new SimpleDateFormat("yyyyMMdd").format(date)+"/"+goFileName); - template.writeAndClose(new FileOutputStream(dirpath+"/"+goFileName)); + String goFileName = System.currentTimeMillis() + ".docx"; + frag.put("file", new SimpleDateFormat("yyyyMMdd").format(date) + "/" + goFileName); + template.writeAndClose(new FileOutputStream(dirpath + "/" + goFileName)); } catch (IOException e) { e.printStackTrace(); } - return new ReturnValue(ReturnCodeAndMsgEnum.Success,frag); + return new ReturnValue(ReturnCodeAndMsgEnum.Success, frag); } - private ParagraphRenderData crowStr(String s){ + private ParagraphRenderData crowStr(String s) { ParagraphRenderData p = new ParagraphRenderData(); - if(s.indexOf("")>=0){ - s = s.replace("","").replace("",""); + if (s.indexOf("") >= 0) { + s = s.replace("", "").replace("", ""); } Integer bs = s.indexOf(""); Integer is = s.indexOf(""); - if(bs>=0&&is>=0){//涓よ呴兘鏈 - while (s.indexOf("")>=0||s.indexOf("")>=0){ + if (bs >= 0 && is >= 0) {//涓よ呴兘鏈 + while (s.indexOf("") >= 0 || s.indexOf("") >= 0) { String cache_act = ""; - if(s.indexOf("")>=0&&s.indexOf("")>=0){ - if(s.indexOf("")>s.indexOf("")){ + if (s.indexOf("") >= 0 && s.indexOf("") >= 0) { + if (s.indexOf("") > s.indexOf("")) { cache_act = "i"; - }else{ + } else { cache_act = "b"; } - }else if(s.indexOf("")>=0){ + } else if (s.indexOf("") >= 0) { cache_act = "b"; - }else{ - cache_act = "i"; + } else { + cache_act = "i"; } - if(cache_act=="b"){ + if (cache_act == "b") { Integer cas = s.indexOf(""); Integer cae = s.indexOf(""); - if(cas>0){ - p.addText(s.substring(0,cas)); + if (cas > 0) { + p.addText(s.substring(0, cas)); } - String now = s.substring(cas,cae+4); + String now = s.substring(cas, cae + 4); Style ca_sty = new Style(); - if(now.indexOf("")>0){ - now = now.replace("","").replace("",""); + if (now.indexOf("") > 0) { + now = now.replace("", "").replace("", ""); ca_sty.setItalic(true); } ca_sty.setBold(true); - p.addText(new TextRenderData(now.replace("","").replace("",""),ca_sty)); - s=s.substring(cae+4); - }else { + p.addText(new TextRenderData(now.replace("", "").replace("", ""), ca_sty)); + s = s.substring(cae + 4); + } else { Integer cas = s.indexOf(""); Integer cae = s.indexOf(""); - if(cas>0){ - p.addText(s.substring(0,cas)); + if (cas > 0) { + p.addText(s.substring(0, cas)); } - String now = s.substring(cas,cae+4); + String now = s.substring(cas, cae + 4); Style ca_sty = new Style(); ca_sty.setItalic(true); - p.addText(new TextRenderData(now.replace("","").replace("",""),ca_sty)); - s=s.substring(cae+4); + p.addText(new TextRenderData(now.replace("", "").replace("", ""), ca_sty)); + s = s.substring(cae + 4); } } - if(s!=""){ + if (s != "") { p.addText(s); } - }else if(bs>=0){//鍙湁鍔犵矖 - while (s.indexOf("")>=0){ + } else if (bs >= 0) {//鍙湁鍔犵矖 + while (s.indexOf("") >= 0) { Integer cas = s.indexOf(""); Integer cae = s.indexOf(""); - if(cas>0){ - p.addText(s.substring(0,cas)); + if (cas > 0) { + p.addText(s.substring(0, cas)); } - String now = s.substring(cas,cae+4); + String now = s.substring(cas, cae + 4); Style ca_sty = new Style(); - if(now.indexOf("")>0){ - now = now.replace("","").replace("",""); + if (now.indexOf("") > 0) { + now = now.replace("", "").replace("", ""); ca_sty.setItalic(true); } ca_sty.setBold(true); - p.addText(new TextRenderData(now.replace("","").replace("",""),ca_sty)); - s=s.substring(cae+4); + p.addText(new TextRenderData(now.replace("", "").replace("", ""), ca_sty)); + s = s.substring(cae + 4); } - if(s!=""){ + if (s != "") { p.addText(s); } - }else if(is>=0){//鍙湁鏂滀綋 - while (s.indexOf("")>=0){ + } else if (is >= 0) {//鍙湁鏂滀綋 + while (s.indexOf("") >= 0) { Integer cas = s.indexOf(""); Integer cae = s.indexOf(""); - if(cas>0){ - p.addText(s.substring(0,cas)); + if (cas > 0) { + p.addText(s.substring(0, cas)); } - String now = s.substring(cas,cae+4); + String now = s.substring(cas, cae + 4); Style ca_sty = new Style(); ca_sty.setItalic(true); - p.addText(new TextRenderData(now.replace("","").replace("",""),ca_sty)); - s=s.substring(cae+4); + p.addText(new TextRenderData(now.replace("", "").replace("", ""), ca_sty)); + s = s.substring(cae + 4); } - if(s!=""){ + if (s != "") { p.addText(s); } - }else{//涓よ呴兘娌℃湁 + } else {//涓よ呴兘娌℃湁 p.addText(s); } return p; @@ -529,8 +610,8 @@ public class TypesetController { @ApiOperation(value = "瀛樺偍涓婁紶杩囩殑鏂囦欢鍚") @PostMapping("/savefilename") - public ReturnValue saveFileName(Long typesetId,String filename){ - Integer res = typesetservice.saveFileName(typesetId,filename); + public ReturnValue saveFileName(Long typesetId, String filename) { + Integer res = typesetservice.saveFileName(typesetId, filename); return new ReturnValue(ReturnCodeAndMsgEnum.Success); } @@ -568,7 +649,7 @@ public class TypesetController { outputStream = new FileOutputStream(targetFile); //鏈鍚庝娇鐢ㄨ祫婧愯闂櫒FileCopyUtils鐨刢opy鏂规硶鎷疯礉鏂囦欢 FileCopyUtils.copy(inputStream, outputStream); - m.put("filename",fileName); + m.put("filename", fileName); } catch (IOException e) { e.printStackTrace(); } finally { @@ -588,6 +669,8 @@ public class TypesetController { } } } - return new ReturnValue(ReturnCodeAndMsgEnum.Success,m); + return new ReturnValue(ReturnCodeAndMsgEnum.Success, m); } + + } diff --git a/src/main/java/com/example/ts_obj/controller/UserController.java b/src/main/java/com/example/ts_obj/controller/UserController.java index 092380e..b001553 100644 --- a/src/main/java/com/example/ts_obj/controller/UserController.java +++ b/src/main/java/com/example/ts_obj/controller/UserController.java @@ -40,19 +40,19 @@ public class UserController { @ApiOperation("娴嬭瘯") @PostMapping("/test") - public String mytest(String str){ + public String mytest(String str) { System.out.println(str); return str; } @GetMapping("/test1") - public String test(){ + public String test() { return "hello"; } @ApiOperation(value = "澧炲姞鐢ㄦ埛") @PostMapping("/insert") - public ReturnValue addUser(String account,String password,String email){ + public ReturnValue addUser(String account, String password, String email) { User user = new User(); Byte insider = 0; Byte state = 0; @@ -62,10 +62,10 @@ public class UserController { user.setIsInsider(insider); user.setState(state); Long uid = userservice.insertUser(user); - if(uid>0){ + if (uid > 0) { logger.info("add user success"); return new ReturnValue(ReturnCodeAndMsgEnum.Success); - }else{ + } else { logger.error("add user error"); return new ReturnValue(ReturnCodeAndMsgEnum.SYSTEM_ERROR); } @@ -73,27 +73,26 @@ public class UserController { @ApiOperation(value = "鑾峰彇鐢ㄦ埛淇℃伅") @PostMapping("/getuser") - public ReturnValue getUser(Long userid){ + public ReturnValue getUser(Long userid) { User u = userservice.getUser(userid); - return new ReturnValue(ReturnCodeAndMsgEnum.Success,u); + return new ReturnValue(ReturnCodeAndMsgEnum.Success, u); } - @ApiOperation(value="楠岃瘉鐧诲綍锛岀敤鎴峰悕銆佸瘑鐮") + @ApiOperation(value = "楠岃瘉鐧诲綍锛岀敤鎴峰悕銆佸瘑鐮") @PostMapping("/login") - public ReturnValue checkUser(String account,String password){ + public ReturnValue checkUser(String account, String password) { // if (!capchar.equals(session.getAttribute("verCode"))) { // // } - User user = userservice.checkUser(account.trim(),DigestUtils.md5Hex(password.trim())); - if(user == null){ + User user = userservice.checkUser(account.trim(), DigestUtils.md5Hex(password.trim())); + if (user == null) { return new ReturnValue(ReturnCodeAndMsgEnum.No_Data); - }else{ - return new ReturnValue(ReturnCodeAndMsgEnum.Success,user); + } else { + return new ReturnValue(ReturnCodeAndMsgEnum.Success, user); } } - // @RequestMapping(value = "yzm") // public void yzm(HttpServletRequest request, HttpServletResponse response) throws IOException { // response.setHeader("Pragma", "No-cache"); @@ -114,7 +113,6 @@ public class UserController { // OutputStream out = response.getOutputStream(); // VerifyCodeUtils.outputImage(w, h, out, verifyCode); // } - } diff --git a/src/main/java/com/example/ts_obj/service/UserService.java b/src/main/java/com/example/ts_obj/service/UserService.java index 10a22f3..c4c14b5 100644 --- a/src/main/java/com/example/ts_obj/service/UserService.java +++ b/src/main/java/com/example/ts_obj/service/UserService.java @@ -12,16 +12,16 @@ public class UserService { private UserMapper usermapper; - public Long insertUser(User user){ + public Long insertUser(User user) { usermapper.insert(user); return user.getUserId(); } - public User checkUser(String account,String password){ - return usermapper.selectForCheck(account,password); + public User checkUser(String account, String password) { + return usermapper.selectForCheck(account, password); } - public User getUser(Long userid){ + public User getUser(Long userid) { return usermapper.selectByPrimaryKey(userid); }