Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_42566577
o2oa
提交
e1d590ce
o2oa
项目概览
weixin_42566577
/
o2oa
与 Fork 源项目一致
Fork自
浙江兰德纵横网络技术股份有限公司 / o2oa
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
o2oa
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e1d590ce
编写于
3月 08, 2022
作者:
O
o2sword
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
签批4
上级
02147dca
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
250 addition
and
22 deletion
+250
-22
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionHtmlToImage.java
.../assemble/surface/jaxrs/attachment/ActionHtmlToImage.java
+1
-0
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/sign/ActionSave.java
...ocessplatform/assemble/surface/jaxrs/sign/ActionSave.java
+103
-9
o2server/x_processplatform_core_entity/src/main/java/com/x/processplatform/core/entity/content/Attachment.java
...com/x/processplatform/core/entity/content/Attachment.java
+3
-0
o2server/x_processplatform_core_entity/src/main/java/com/x/processplatform/core/entity/content/DocSignScrawl.java
.../x/processplatform/core/entity/content/DocSignScrawl.java
+143
-13
未找到文件。
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionHtmlToImage.java
浏览文件 @
e1d590ce
...
...
@@ -243,6 +243,7 @@ class ActionHtmlToImage extends BaseAction {
page
.
navigate
(
"file:///Users/chengjian/dev/temp/test.html"
);
Page
.
ScreenshotOptions
screenshotOptions
=
new
Page
.
ScreenshotOptions
();
screenshotOptions
.
setFullPage
(
true
);
screenshotOptions
.
setClip
(
0
,
0
,
800
,
2310
);
//screenshotOptions.setQuality(2);
screenshotOptions
.
setPath
(
Paths
.
get
(
"/Users/chengjian/dev/temp/screenshot-"
+
browserType
.
name
()
+
".png"
));
page
.
screenshot
(
screenshotOptions
);
...
...
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/sign/ActionSave.java
浏览文件 @
e1d590ce
package
com.x.processplatform.assemble.surface.jaxrs.sign
;
import
com.google.gson.JsonElement
;
import
com.google.gson.JsonObject
;
import
com.microsoft.playwright.*
;
import
com.x.base.core.container.EntityManagerContainer
;
import
com.x.base.core.container.factory.EntityManagerContainerFactory
;
import
com.x.base.core.project.annotation.FieldDescribe
;
import
com.x.base.core.project.config.Config
;
import
com.x.base.core.project.exception.ExceptionAccessDenied
;
import
com.x.base.core.project.exception.ExceptionEntityNotExist
;
import
com.x.base.core.project.exception.ExceptionFieldEmpty
;
...
...
@@ -13,12 +16,20 @@ import com.x.base.core.project.http.EffectivePerson;
import
com.x.base.core.project.jaxrs.WoId
;
import
com.x.base.core.project.logger.Logger
;
import
com.x.base.core.project.logger.LoggerFactory
;
import
com.x.base.core.project.tools.DateTools
;
import
com.x.base.core.project.tools.FileTools
;
import
com.x.base.core.project.tools.ListTools
;
import
com.x.processplatform.assemble.surface.Business
;
import
com.x.processplatform.core.entity.content.DocSign
;
import
com.x.processplatform.core.entity.content.DocSignScrawl
;
import
com.x.processplatform.core.entity.content.Task
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.omg.CORBA.ExceptionDefPOA
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.List
;
...
...
@@ -32,8 +43,8 @@ class ActionSave extends BaseAction {
if
(
wi
.
getStatus
()
==
null
){
throw
new
ExceptionFieldEmpty
(
DocSign
.
status_FIELDNAME
);
}
if
(
wi
.
getStatus
().
equals
(
DocSign
.
STATUS_3
)
&&
StringUtils
.
isBlank
(
wi
.
getContent
())){
throw
new
ExceptionFieldEmpty
(
"
c
ontent"
);
if
(
wi
.
getStatus
().
equals
(
DocSign
.
STATUS_3
)
&&
StringUtils
.
isBlank
(
wi
.
get
Html
Content
())){
throw
new
ExceptionFieldEmpty
(
"
htmlC
ontent"
);
}
Task
task
=
null
;
Wo
wo
=
new
Wo
();
...
...
@@ -55,6 +66,7 @@ class ActionSave extends BaseAction {
private
String
saveDocSign
(
Wi
wi
,
Task
task
)
throws
Exception
{
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
boolean
flag
=
false
;
emc
.
beginTransaction
(
DocSign
.
class
);
DocSign
docSign
=
emc
.
firstEqual
(
DocSign
.
class
,
DocSign
.
taskId_FIELDNAME
,
task
.
getId
());
if
(
docSign
==
null
)
{
flag
=
true
;
...
...
@@ -63,18 +75,84 @@ class ActionSave extends BaseAction {
}
docSign
.
getProperties
().
setInputList
(
wi
.
getInputList
());
docSign
.
getProperties
().
setScrawlList
(
wi
.
getScrawlList
());
if
(
!
wi
.
getStatus
().
equals
(
DocSign
.
STATUS_1
)){
if
(
wi
.
getStatus
().
equals
(
DocSign
.
STATUS_2
)){
docSign
.
setCommitTime
(
new
Date
());
emc
.
beginTransaction
(
DocSignScrawl
.
class
);
emc
.
deleteEqual
(
DocSignScrawl
.
class
,
DocSignScrawl
.
signId_FIELDNAME
,
docSign
.
getId
());
if
(
ListTools
.
isNotEmpty
(
wi
.
getScrawlList
())){
for
(
String
data
:
wi
.
getScrawlList
()){
JsonObject
jsonObject
=
gson
.
fromJson
(
data
,
JsonObject
.
class
);
DocSignScrawl
signScrawl
=
new
DocSignScrawl
(
docSign
,
data
,
null
);
if
(
jsonObject
.
has
(
"src"
)){
signScrawl
.
setType
(
DocSignScrawl
.
SCRAWL_TYPE_BASE64
);
}
emc
.
persist
(
signScrawl
);
}
}
}
else
if
(
wi
.
getStatus
().
equals
(
DocSign
.
STATUS_3
)){
docSign
.
setCommitTime
(
new
Date
());
}
if
(
flag
){
emc
.
persist
(
docSign
);
}
emc
.
commit
();
return
docSign
.
getId
();
}
}
private
void
html2Img
(
DocSign
docSign
,
Wi
wi
,
EntityManagerContainer
emc
)
throws
Exception
{
String
html
=
wi
.
getHtmlContent
();
if
(
html
.
toLowerCase
().
indexOf
(
"<html"
)
==
-
1
)
{
html
=
"<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"></head><body>"
+
html
+
"</body></html>"
;
}
String
name
=
StringUtils
.
split
(
docSign
.
getPerson
(),
"@"
)[
0
]
+
docSign
.
getTaskId
()
+
".png"
;
byte
[]
bytes
=
null
;
try
(
Playwright
playwright
=
Playwright
.
create
())
{
List
<
BrowserType
>
browserTypes
=
Arrays
.
asList
(
playwright
.
chromium
(),
playwright
.
firefox
(),
playwright
.
webkit
()
);
for
(
BrowserType
browserType
:
browserTypes
)
{
BrowserType
.
LaunchOptions
options
=
new
BrowserType
.
LaunchOptions
();
options
.
setHeadless
(
true
);
try
(
Browser
browser
=
browserType
.
launch
(
options
))
{
BrowserContext
context
=
browser
.
newContext
();
Page
page
=
context
.
newPage
();
page
.
setContent
(
html
);
Page
.
ScreenshotOptions
screenshotOptions
=
new
Page
.
ScreenshotOptions
();
screenshotOptions
.
setFullPage
(
true
);
if
(
wi
.
getHtmlWidth
()!=
null
&&
wi
.
getHtmlHeight
()!=
null
){
screenshotOptions
.
setClip
(
0
,
0
,
wi
.
getHtmlWidth
(),
wi
.
getHtmlHeight
());
}
File
tempDir
=
Config
.
dir_local_temp
();
FileTools
.
forceMkdir
(
tempDir
);
File
file
=
new
File
(
tempDir
,
name
);
screenshotOptions
.
setPath
(
file
.
toPath
());
page
.
screenshot
(
screenshotOptions
);
bytes
=
FileUtils
.
readFileToByteArray
(
file
);
break
;
}
catch
(
Exception
e
)
{
logger
.
warn
(
"Playwright user browser:{} error:{}"
,
browserType
.
name
(),
e
.
getMessage
());
}
}
}
if
(
bytes
==
null
){
throw
new
IllegalStateException
(
"签批转图片异常!"
);
}
return
""
;
}
public
static
class
Wi
extends
GsonPropertyObject
{
@FieldDescribe
(
"状态:1(暂存)|2(签批正文不可以修改)|3(签批正文可以修改,正文保存为图片)."
)
private
Integer
status
;
@FieldDescribe
(
"包含签批的html正文后内容,状态为3时必传."
)
private
String
content
;
private
String
htmlContent
;
@FieldDescribe
(
"html宽度,允许为空."
)
private
Double
htmlWidth
;
@FieldDescribe
(
"html宽度长度,允许为空."
)
private
Double
htmlHeight
;
@FieldDescribe
(
"输入框列表."
)
private
List
<
String
>
inputList
=
new
ArrayList
<>();
@FieldDescribe
(
"涂鸦列表."
)
...
...
@@ -88,12 +166,28 @@ class ActionSave extends BaseAction {
this
.
status
=
status
;
}
public
String
getContent
()
{
return
content
;
public
String
getHtmlContent
()
{
return
htmlContent
;
}
public
void
setHtmlContent
(
String
htmlContent
)
{
this
.
htmlContent
=
htmlContent
;
}
public
Double
getHtmlWidth
()
{
return
htmlWidth
;
}
public
void
setHtmlWidth
(
Double
htmlWidth
)
{
this
.
htmlWidth
=
htmlWidth
;
}
public
Double
getHtmlHeight
()
{
return
htmlHeight
;
}
public
void
set
Content
(
String
conten
t
)
{
this
.
content
=
conten
t
;
public
void
set
HtmlHeight
(
Double
htmlHeigh
t
)
{
this
.
htmlHeight
=
htmlHeigh
t
;
}
public
List
<
String
>
getInputList
()
{
...
...
o2server/x_processplatform_core_entity/src/main/java/com/x/processplatform/core/entity/content/Attachment.java
浏览文件 @
e1d590ce
...
...
@@ -51,10 +51,12 @@ public class Attachment extends StorageObject {
private
static
final
long
serialVersionUID
=
-
6564254194819206271L
;
private
static
final
String
TABLE
=
PersistenceProperties
.
Content
.
Attachment
.
table
;
@Override
public
String
getId
()
{
return
id
;
}
@Override
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
...
...
@@ -66,6 +68,7 @@ public class Attachment extends StorageObject {
/* 以上为 JpaObject 默认字段 */
@Override
public
void
onPersist
()
throws
Exception
{
this
.
extension
=
StringUtils
.
trimToEmpty
(
this
.
extension
);
this
.
site
=
StringUtils
.
trimToEmpty
(
this
.
site
);
...
...
o2server/x_processplatform_core_entity/src/main/java/com/x/processplatform/core/entity/content/DocSignScrawl.java
浏览文件 @
e1d590ce
package
com.x.processplatform.core.entity.content
;
import
com.x.base.core.entity.AbstractPersistenceProperties
;
import
com.x.base.core.entity.JpaObject
;
import
com.x.base.core.entity.SliceJpaObject
;
import
com.x.base.core.entity.StorageObject
;
import
com.x.base.core.entity.annotation.CheckPersist
;
import
com.x.base.core.entity.annotation.ContainerEntity
;
import
com.x.base.core.project.annotation.FieldDescribe
;
import
com.x.base.core.project.tools.DateTools
;
import
com.x.processplatform.core.entity.PersistenceProperties
;
import
org.apache.commons.io.FilenameUtils
;
import
org.apache.commons.lang3.BooleanUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.openjpa.persistence.jdbc.Index
;
import
javax.persistence.*
;
import
java.util.Date
;
/**
* 签批涂鸦
列表
* 签批涂鸦
信息
* @author sword
*/
@Entity
...
...
@@ -22,12 +28,18 @@ import java.util.Date;
+
JpaObject
.
DefaultUniqueConstraintSuffix
,
columnNames
=
{
JpaObject
.
IDCOLUMN
,
JpaObject
.
CREATETIMECOLUMN
,
JpaObject
.
UPDATETIMECOLUMN
,
JpaObject
.
SEQUENCECOLUMN
})
})
@Inheritance
(
strategy
=
InheritanceType
.
TABLE_PER_CLASS
)
public
class
DocSignScrawl
extends
S
liceJpa
Object
{
public
class
DocSignScrawl
extends
S
torage
Object
{
private
static
final
long
serialVersionUID
=
-
8648872600208475747L
;
private
static
final
String
TABLE
=
PersistenceProperties
.
Content
.
DocSignScrawl
.
table
;
public
static
String
SCRAWL_TYPE_PLACEHOLDER
=
"placeholder"
;
public
static
String
SCRAWL_TYPE_BASE64
=
"base64"
;
public
static
String
SCRAWL_TYPE_IMAGE
=
"image"
;
@Override
public
String
getId
()
{
return
id
;
...
...
@@ -51,14 +63,132 @@ public class DocSignScrawl extends SliceJpaObject {
// nothing
}
public
DocSignScrawl
(
DocSign
docSign
,
String
data
)
{
public
DocSignScrawl
(
DocSign
docSign
,
String
data
,
String
name
)
{
this
.
signId
=
docSign
.
getId
();
this
.
job
=
docSign
.
getJob
();
this
.
activity
=
docSign
.
getActivity
();
this
.
activityName
=
docSign
.
getActivityName
();
this
.
person
=
docSign
.
getPerson
();
this
.
commitTime
=
new
Date
();
this
.
data
=
data
;
this
.
type
=
SCRAWL_TYPE_PLACEHOLDER
;
if
(
StringUtils
.
isNotBlank
(
name
)){
this
.
lastUpdateTime
=
new
Date
();
this
.
name
=
name
;
this
.
extension
=
StringUtils
.
lowerCase
(
FilenameUtils
.
getExtension
(
name
));
}
}
@Override
public
String
path
()
{
String
str
=
DateTools
.
format
(
this
.
getCreateTime
(),
DateTools
.
formatCompact_yyyyMMdd
);
str
+=
PATHSEPARATOR
;
str
+=
this
.
job
;
str
+=
PATHSEPARATOR
;
str
+=
this
.
id
;
str
+=
StringUtils
.
isEmpty
(
this
.
extension
)
?
""
:
(
"."
+
this
.
extension
);
return
str
;
}
public
static
final
String
name_FIELDNAME
=
"name"
;
@FieldDescribe
(
"文件名称,带扩展名的文件名."
)
@Column
(
length
=
AbstractPersistenceProperties
.
processPlatform_name_length
,
name
=
ColumnNamePrefix
+
name_FIELDNAME
)
@Index
(
name
=
TABLE
+
IndexNameMiddle
+
name_FIELDNAME
)
@CheckPersist
(
allowEmpty
=
true
,
fileNameString
=
true
)
private
String
name
;
public
static
final
String
extension_FIELDNAME
=
"extension"
;
@FieldDescribe
(
"扩展名。"
)
@Column
(
length
=
JpaObject
.
length_16B
,
name
=
ColumnNamePrefix
+
extension_FIELDNAME
)
@CheckPersist
(
allowEmpty
=
true
,
fileNameString
=
true
)
private
String
extension
;
public
static
final
String
storage_FIELDNAME
=
"storage"
;
@FieldDescribe
(
"关联的存储名称."
)
@Column
(
length
=
JpaObject
.
length_64B
,
name
=
ColumnNamePrefix
+
storage_FIELDNAME
)
@CheckPersist
(
allowEmpty
=
true
,
simplyString
=
true
)
@Index
(
name
=
TABLE
+
IndexNameMiddle
+
storage_FIELDNAME
)
private
String
storage
;
public
static
final
String
length_FIELDNAME
=
"length"
;
@FieldDescribe
(
"文件大小."
)
@Column
(
name
=
ColumnNamePrefix
+
length_FIELDNAME
)
@Index
(
name
=
TABLE
+
IndexNameMiddle
+
length_FIELDNAME
)
@CheckPersist
(
allowEmpty
=
true
)
private
Long
length
;
public
static
final
String
lastUpdateTime_FIELDNAME
=
"lastUpdateTime"
;
@FieldDescribe
(
"最后更新时间"
)
@Column
(
name
=
ColumnNamePrefix
+
lastUpdateTime_FIELDNAME
)
@Index
(
name
=
TABLE
+
IndexNameMiddle
+
lastUpdateTime_FIELDNAME
)
@CheckPersist
(
allowEmpty
=
true
)
private
Date
lastUpdateTime
;
public
static
final
String
deepPath_FIELDNAME
=
"deepPath"
;
@FieldDescribe
(
"是否使用更深的路径."
)
@CheckPersist
(
allowEmpty
=
true
)
@Column
(
name
=
ColumnNamePrefix
+
deepPath_FIELDNAME
)
@Index
(
name
=
TABLE
+
IndexNameMiddle
+
deepPath_FIELDNAME
)
private
Boolean
deepPath
;
@Override
public
String
getStorage
()
{
return
storage
;
}
@Override
public
void
setStorage
(
String
storage
)
{
this
.
storage
=
storage
;
}
@Override
public
Long
getLength
()
{
return
length
;
}
@Override
public
void
setLength
(
Long
length
)
{
this
.
length
=
length
;
}
@Override
public
String
getName
()
{
return
name
;
}
@Override
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
@Override
public
String
getExtension
()
{
return
extension
;
}
@Override
public
void
setExtension
(
String
extension
)
{
this
.
extension
=
extension
;
}
@Override
public
Date
getLastUpdateTime
()
{
return
lastUpdateTime
;
}
@Override
public
void
setLastUpdateTime
(
Date
lastUpdateTime
)
{
this
.
lastUpdateTime
=
lastUpdateTime
;
}
@Override
public
Boolean
getDeepPath
()
{
return
BooleanUtils
.
isTrue
(
this
.
deepPath
);
}
@Override
public
void
setDeepPath
(
Boolean
deepPath
)
{
this
.
deepPath
=
deepPath
;
}
public
static
final
String
signId_FIELDNAME
=
"signId"
;
...
...
@@ -102,17 +232,17 @@ public class DocSignScrawl extends SliceJpaObject {
@CheckPersist
(
allowEmpty
=
true
)
private
Date
commitTime
;
public
static
final
String
hasScrawlPic_FIELDNAME
=
"hasScrawlPic
"
;
@FieldDescribe
(
"
是否有涂鸦图片
"
)
@Column
(
name
=
ColumnNamePrefix
+
hasScrawlPic
_FIELDNAME
)
public
static
final
String
type_FIELDNAME
=
"type
"
;
@FieldDescribe
(
"
涂鸦类型:placeholder(占位符)|base64(图片base64存储在data字段中)|image(图片存储在附件中)
"
)
@Column
(
name
=
ColumnNamePrefix
+
type
_FIELDNAME
)
@CheckPersist
(
allowEmpty
=
true
)
private
Boolean
hasScrawlPic
=
fals
e
;
private
String
typ
e
;
public
static
final
String
data_FIELDNAME
=
"data"
;
@FieldDescribe
(
"涂鸦信息."
)
@Lob
@Basic
(
fetch
=
FetchType
.
EAGER
)
@Column
(
length
=
JpaObject
.
length_
1
0M
,
name
=
ColumnNamePrefix
+
data_FIELDNAME
)
@Column
(
length
=
JpaObject
.
length_
2
0M
,
name
=
ColumnNamePrefix
+
data_FIELDNAME
)
@CheckPersist
(
allowEmpty
=
true
)
private
String
data
;
...
...
@@ -168,12 +298,12 @@ public class DocSignScrawl extends SliceJpaObject {
this
.
signId
=
signId
;
}
public
Boolean
getHasScrawlPic
()
{
return
hasScrawlPic
;
public
String
getType
()
{
return
type
;
}
public
void
set
HasScrawlPic
(
Boolean
hasScrawlPic
)
{
this
.
hasScrawlPic
=
hasScrawlPic
;
public
void
set
Type
(
String
type
)
{
this
.
type
=
type
;
}
public
String
getData
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录