Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ghsby
o2oa
提交
d98b3920
o2oa
项目概览
ghsby
/
o2oa
落后 Fork 源项目 2880 个版本
Fork自
浙江兰德纵横网络技术股份有限公司 / o2oa
通知
1
Star
1
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,发现更多精彩内容 >>
提交
d98b3920
编写于
7月 01, 2020
作者:
O
o2sword
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
提取html转pdf为通用工具接口
上级
94ad763b
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
203 addition
and
28 deletion
+203
-28
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/ProcessFactory.java
...form/assemble/surface/factory/element/ProcessFactory.java
+1
-26
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionDownloadTransfer.java
...mble/surface/jaxrs/attachment/ActionDownloadTransfer.java
+39
-0
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionHtmlToPdf.java
...rm/assemble/surface/jaxrs/attachment/ActionHtmlToPdf.java
+124
-0
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionUploadWorkInfo.java
...semble/surface/jaxrs/attachment/ActionUploadWorkInfo.java
+2
-1
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/AttachmentAction.java
...m/assemble/surface/jaxrs/attachment/AttachmentAction.java
+37
-1
未找到文件。
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/factory/element/ProcessFactory.java
浏览文件 @
d98b3920
...
...
@@ -213,11 +213,10 @@ public class ProcessFactory extends ElementFactory {
public
List
<
String
>
listControlableProcess
(
EffectivePerson
effectivePerson
,
Application
application
)
throws
Exception
{
Business
business
=
this
.
business
();
List
<
String
>
ids
=
this
.
listWithApplication
(
application
);
List
<
String
>
list
=
new
ArrayList
<>();
for
(
String
str
:
ids
)
{
Process
o
=
business
.
process
()
.
pick
(
str
);
Process
o
=
this
.
pick
(
str
);
if
(
null
!=
o
)
{
if
(
effectivePerson
.
isPerson
(
o
.
getControllerList
()))
{
list
.
add
(
str
);
...
...
@@ -259,30 +258,6 @@ public class ProcessFactory extends ElementFactory {
return
null
;
}
// /* 判断用户是否有管理权限 */
// public boolean allowControl(EffectivePerson effectivePerson, Process process)
// throws Exception {
// if (effectivePerson.isManager()) {
// return true;
// }
// if (null != process) {
// if (effectivePerson.isUser(process.getControllerList())) {
// return true;
// }
// Application application =
// this.business().application().pick(process.getApplication());
// if (null != application) {
// if (effectivePerson.isUser(application.getControllerList())) {
// return true;
// }
// if (effectivePerson.isUser(application.getCreatorPerson())) {
// return true;
// }
// }
// }
// return false;
// }
public
<
T
extends
Process
>
List
<
T
>
sort
(
List
<
T
>
list
)
{
list
=
list
.
stream
()
.
sorted
(
Comparator
.
comparing
(
Process:
:
getAlias
,
Comparator
.
nullsLast
(
String:
:
compareTo
))
...
...
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionDownloadTransfer.java
0 → 100644
浏览文件 @
d98b3920
package
com.x.processplatform.assemble.surface.jaxrs.attachment
;
import
com.x.base.core.container.EntityManagerContainer
;
import
com.x.base.core.container.factory.EntityManagerContainerFactory
;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.jaxrs.WoFile
;
import
com.x.base.core.project.logger.Logger
;
import
com.x.base.core.project.logger.LoggerFactory
;
import
net.sf.ehcache.Element
;
class
ActionDownloadTransfer
extends
BaseAction
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ActionDownloadTransfer
.
class
);
ActionResult
<
Wo
>
execute
(
EffectivePerson
effectivePerson
,
String
flag
)
throws
Exception
{
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
Wo
wo
=
null
;
Element
element
=
cache
.
get
(
flag
);
if
((
null
!=
element
)
&&
(
null
!=
element
.
getObjectValue
()))
{
CacheResultObject
ro
=
(
CacheResultObject
)
element
.
getObjectValue
();
wo
=
new
Wo
(
ro
.
getBytes
(),
this
.
contentType
(
false
,
ro
.
getName
()),
this
.
contentDisposition
(
false
,
ro
.
getName
()));
}
result
.
setData
(
wo
);
return
result
;
}
}
public
static
class
Wo
extends
WoFile
{
public
Wo
(
byte
[]
bytes
,
String
contentType
,
String
contentDisposition
)
{
super
(
bytes
,
contentType
,
contentDisposition
);
}
}
}
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionHtmlToPdf.java
0 → 100644
浏览文件 @
d98b3920
package
com.x.processplatform.assemble.surface.jaxrs.attachment
;
import
com.google.gson.JsonElement
;
import
com.itextpdf.html2pdf.ConverterProperties
;
import
com.itextpdf.html2pdf.HtmlConverter
;
import
com.itextpdf.html2pdf.resolver.font.DefaultFontProvider
;
import
com.itextpdf.kernel.geom.PageSize
;
import
com.itextpdf.kernel.pdf.PdfDocument
;
import
com.itextpdf.kernel.pdf.PdfWriter
;
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.cache.ApplicationCache
;
import
com.x.base.core.project.config.Config
;
import
com.x.base.core.project.gson.GsonPropertyObject
;
import
com.x.base.core.project.http.ActionResult
;
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
net.sf.ehcache.Element
;
import
org.apache.commons.lang3.StringUtils
;
import
java.io.*
;
import
java.util.UUID
;
class
ActionHtmlToPdf
extends
BaseAction
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ActionEdit
.
class
);
ActionResult
<
Wo
>
execute
(
EffectivePerson
effectivePerson
,
JsonElement
jsonElement
)
throws
Exception
{
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
Wi
wi
=
this
.
convertToWrapIn
(
jsonElement
,
Wi
.
class
);
Wo
wo
=
new
Wo
();
String
id
=
savePdf
(
wi
,
effectivePerson
.
getDistinguishedName
());
wo
.
setId
(
id
);
result
.
setData
(
wo
);
return
result
;
}
}
public
static
class
Wo
extends
WoId
{
}
private
String
savePdf
(
Wi
wi
,
String
person
){
try
{
CacheResultObject
ro
=
new
CacheResultObject
();
ro
.
setPerson
(
person
);
String
workHtml
=
wi
.
getWorkHtml
();
if
(
StringUtils
.
isEmpty
(
workHtml
)){
workHtml
=
"无内容"
;
}
if
(
workHtml
.
toLowerCase
().
indexOf
(
"<html"
)
==
-
1
){
workHtml
=
"<html><head></head><body>"
+
workHtml
+
"</body></html>"
;
}
String
title
=
person
+
DateTools
.
now
()+
".pdf"
;
if
(
StringUtils
.
isNotEmpty
(
wi
.
getTitle
())){
title
=
wi
.
getTitle
()+
".pdf"
;
}
try
(
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
())
{
ConverterProperties
props
=
new
ConverterProperties
();
DefaultFontProvider
dfp
=
new
DefaultFontProvider
(
false
,
false
,
false
);
//dfp.addFont(Config.base()+"/commons/fonts/NotoSansCJKsc-Regular.otf");
dfp
.
addDirectory
(
Config
.
base
()+
"/commons/fonts"
);
props
.
setFontProvider
(
dfp
);
PdfWriter
writer
=
new
PdfWriter
(
out
);
PdfDocument
pdf
=
new
PdfDocument
(
writer
);
float
width
=
PageSize
.
A4
.
getWidth
();
if
(
wi
.
getPageWidth
()!=
null
&&
wi
.
getPageWidth
()>
100
){
width
=
wi
.
getPageWidth
().
floatValue
();
}
pdf
.
setDefaultPageSize
(
new
PageSize
(
width
,
PageSize
.
A4
.
getHeight
()));
HtmlConverter
.
convertToPdf
(
workHtml
,
pdf
,
props
);
ro
.
setBytes
(
out
.
toByteArray
());
ro
.
setName
(
title
+
".pdf"
);
}
String
cacheKey
=
ApplicationCache
.
concreteCacheKey
(
UUID
.
randomUUID
().
toString
());
cache
.
put
(
new
Element
(
cacheKey
,
ro
));
return
cacheKey
;
}
catch
(
Exception
e
)
{
logger
.
warn
(
"写work信息异常"
+
e
.
getMessage
());
}
return
""
;
}
public
static
class
Wi
extends
GsonPropertyObject
{
@FieldDescribe
(
"待转换html."
)
private
String
workHtml
;
@FieldDescribe
(
"转pdf页面宽度,默认A4."
)
private
Float
pageWidth
;
@FieldDescribe
(
"pdf标题"
)
private
String
title
;
public
String
getWorkHtml
()
{
return
workHtml
;
}
public
void
setWorkHtml
(
String
workHtml
)
{
this
.
workHtml
=
workHtml
;
}
public
Float
getPageWidth
()
{
return
pageWidth
;
}
public
void
setPageWidth
(
Float
pageWidth
)
{
this
.
pageWidth
=
pageWidth
;
}
public
String
getTitle
()
{
return
title
;
}
public
void
setTitle
(
String
title
)
{
this
.
title
=
title
;
}
}
}
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionUploadWorkInfo.java
浏览文件 @
d98b3920
...
...
@@ -88,7 +88,8 @@ class ActionUploadWorkInfo extends BaseAction {
try
(
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
())
{
ConverterProperties
props
=
new
ConverterProperties
();
DefaultFontProvider
dfp
=
new
DefaultFontProvider
(
false
,
false
,
false
);
dfp
.
addFont
(
Config
.
base
()+
"/commons/fonts/NotoSansCJKsc-Regular.otf"
);
//dfp.addFont(Config.base()+"/commons/fonts/NotoSansCJKsc-Regular.otf");
dfp
.
addDirectory
(
Config
.
base
()+
"/commons/fonts"
);
props
.
setFontProvider
(
dfp
);
PdfWriter
writer
=
new
PdfWriter
(
out
);
PdfDocument
pdf
=
new
PdfDocument
(
writer
);
...
...
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/AttachmentAction.java
浏览文件 @
d98b3920
...
...
@@ -840,7 +840,7 @@ public class AttachmentAction extends StandardJaxrsAction {
@JaxrsMethodDescribe
(
value
=
"管理员上传附件."
,
action
=
ActionManageUpload
.
class
)
@POST
@Path
(
"upload/work/{workId}
U
/manage"
)
@Path
(
"upload/work/{workId}/manage"
)
@Produces
(
HttpMediaType
.
APPLICATION_JSON_UTF_8
)
@Consumes
(
MediaType
.
MULTIPART_FORM_DATA
)
public
void
manageUpload
(
@Suspended
final
AsyncResponse
asyncResponse
,
@Context
HttpServletRequest
request
,
...
...
@@ -862,4 +862,40 @@ public class AttachmentAction extends StandardJaxrsAction {
}
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
@JaxrsMethodDescribe
(
value
=
"html转pdf工具类,转换后通过downloadTransfer接口下载"
,
action
=
ActionHtmlToPdf
.
class
)
@POST
@Path
(
"html/to/pdf"
)
@Produces
(
HttpMediaType
.
APPLICATION_JSON_UTF_8
)
@Consumes
(
MediaType
.
APPLICATION_JSON
)
public
void
htmlToPdf
(
@Suspended
final
AsyncResponse
asyncResponse
,
@Context
HttpServletRequest
request
,
JsonElement
jsonElement
)
{
ActionResult
<
ActionHtmlToPdf
.
Wo
>
result
=
new
ActionResult
<>();
EffectivePerson
effectivePerson
=
this
.
effectivePerson
(
request
);
try
{
result
=
new
ActionHtmlToPdf
().
execute
(
effectivePerson
,
jsonElement
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
,
effectivePerson
,
request
,
null
);
result
.
error
(
e
);
}
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
@JaxrsMethodDescribe
(
value
=
"下载转换后的附件"
,
action
=
ActionDownloadTransfer
.
class
)
@GET
@Path
(
"download/transfer/flag/{flag}"
)
@Consumes
(
MediaType
.
APPLICATION_JSON
)
public
void
downloadTransfer
(
@Suspended
final
AsyncResponse
asyncResponse
,
@Context
HttpServletRequest
request
,
@JaxrsParameterDescribe
(
"*转换后附件id"
)
@PathParam
(
"flag"
)
String
flag
){
ActionResult
<
ActionDownloadTransfer
.
Wo
>
result
=
new
ActionResult
<>();
EffectivePerson
effectivePerson
=
this
.
effectivePerson
(
request
);
try
{
result
=
new
ActionDownloadTransfer
().
execute
(
effectivePerson
,
flag
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
,
effectivePerson
,
request
,
null
);
result
.
error
(
e
);
}
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录