Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
certificate-print
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
廖旭伟
certificate-print
Commits
a5f39b7b
Commit
a5f39b7b
authored
Mar 31, 2023
by
廖旭伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加合成word文件后转为PDF文件进行打印;二维码控件增加默认值;待打印文件列表返回值增加打印服务地址属性
parent
12cb4438
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
164 additions
and
37 deletions
+164
-37
certificate-manager/pom.xml
certificate-manager/pom.xml
+1
-0
certificate-manager/src/main/java/com/mortals/xhx/common/formdesign/ListItem.java
...main/java/com/mortals/xhx/common/formdesign/ListItem.java
+3
-0
certificate-manager/src/main/java/com/mortals/xhx/common/formdesign/component/DesignQrcodeComponent.java
...hx/common/formdesign/component/DesignQrcodeComponent.java
+10
-9
certificate-manager/src/main/java/com/mortals/xhx/common/utils/WordUtil.java
.../src/main/java/com/mortals/xhx/common/utils/WordUtil.java
+32
-0
certificate-manager/src/main/java/com/mortals/xhx/module/certificate/service/impl/CertificateCatalogServiceImpl.java
...rtificate/service/impl/CertificateCatalogServiceImpl.java
+42
-9
certificate-manager/src/main/java/com/mortals/xhx/module/record/model/vo/PrintWaitQueueVo.java
.../mortals/xhx/module/record/model/vo/PrintWaitQueueVo.java
+5
-0
certificate-manager/src/main/java/com/mortals/xhx/module/record/service/impl/ApplyLogServiceImpl.java
...s/xhx/module/record/service/impl/ApplyLogServiceImpl.java
+20
-9
certificate-manager/src/main/java/com/mortals/xhx/module/record/service/impl/PrintWaitQueueServiceImpl.java
...module/record/service/impl/PrintWaitQueueServiceImpl.java
+39
-5
certificate-manager/src/main/java/com/mortals/xhx/module/record/web/ApplyLogController.java
...com/mortals/xhx/module/record/web/ApplyLogController.java
+10
-5
certificate-manager/src/main/resources/bootstrap.yml
certificate-manager/src/main/resources/bootstrap.yml
+2
-0
No files found.
certificate-manager/pom.xml
View file @
a5f39b7b
...
...
@@ -48,6 +48,7 @@
</profile>
<profile>
<id>
test
</id>
<properties>
<profiles.active>
test
</profiles.active>
<profiles.server.port>
17216
</profiles.server.port>
...
...
certificate-manager/src/main/java/com/mortals/xhx/common/formdesign/ListItem.java
View file @
a5f39b7b
...
...
@@ -380,4 +380,7 @@ public class ListItem{
@JSONField
(
name
=
"limit"
)
private
Integer
limit
;
@JSONField
(
name
=
"value"
)
private
Object
value
;
}
\ No newline at end of file
certificate-manager/src/main/java/com/mortals/xhx/common/formdesign/component/DesignQrcodeComponent.java
View file @
a5f39b7b
...
...
@@ -20,30 +20,31 @@ public class DesignQrcodeComponent extends DesignComponent {
ListItem
columnsItem
=
new
ListItem
();
columnsItem
.
setId
(
cons
.
getVal
());
columnsItem
.
set_id
(
cons
.
getVal
());
columnsItem
.
setCompType
(
"input"
);
columnsItem
.
setCompName
(
cons
.
getLabel
());
columnsItem
.
setCompIcon
(
"input"
);
columnsItem
.
setCompType
(
"textarea"
);
columnsItem
.
setEle
(
"el-input"
);
columnsItem
.
setCompName
(
"多行文本"
);
columnsItem
.
setCompIcon
(
"textarea"
);
columnsItem
.
setViewType
(
"text"
);
columnsItem
.
setType
(
"textarea"
);
columnsItem
.
setConfig
(
true
);
columnsItem
.
setShowLabel
(
true
);
columnsItem
.
setLabel
(
cons
.
getLabel
());
columnsItem
.
setLabelWidth
(
120
);
columnsItem
.
setPlaceholder
(
"请输入"
+
cons
.
getLabel
());
columnsItem
.
setPlaceholder
(
"请输入"
+
cons
.
getLabel
());
columnsItem
.
setRequired
(
true
);
columnsItem
.
setMaxLength
(
50
);
columnsItem
.
setMaxLength
(
200
);
columnsItem
.
setShowWordLimit
(
true
);
columnsItem
.
setGutter
(
15
);
columnsItem
.
setSpan
(
24
);
columnsItem
.
setWidth
(
"100%"
);
columnsItem
.
setClearable
(
true
);
columnsItem
.
setDisabled
(
false
);
columnsItem
.
setReadonly
(
false
);
columnsItem
.
setRows
(
4
);
columnsItem
.
setStatus
(
"normal"
);
columnsItem
.
setPrefixIcon
(
""
);
//设置默认值
columnsItem
.
setRules
(
Lists
.
newArrayList
());
columnsItem
.
setRuleError
(
"该字段不能为空"
);
columnsItem
.
setRulesType
(
"default"
);
columnsItem
.
setAppend
(
""
);
columnsItem
.
setPrepend
(
""
);
columnsItem
.
setLayout
(
"colItem"
);
return
columnsItem
;
}
...
...
certificate-manager/src/main/java/com/mortals/xhx/common/utils/WordUtil.java
View file @
a5f39b7b
...
...
@@ -216,5 +216,37 @@ public class WordUtil {
}
public
static
String
convertWordToPDF
(
String
inputFile
,
String
pdfPath
)
{
FileOutputStream
os
=
null
;
try
{
long
old
=
System
.
currentTimeMillis
();
File
file
=
new
File
(
pdfPath
);
// 新建一个空白pdf文档
os
=
new
FileOutputStream
(
file
);
Document
doc
=
new
Document
(
inputFile
);
// Address是将要被转化的word文档
doc
.
save
(
os
,
SaveFormat
.
PDF
);
// 全面支持DOC, DOCX, OOXML, RTF HTML, OpenDocument, PDF,
// EPUB, XPS, SWF 相互转换
long
now
=
System
.
currentTimeMillis
();
System
.
out
.
println
(
"pdf转换成功,共耗时:"
+
((
now
-
old
)
/
1000.0
)
+
"秒"
);
// 转化用时
return
pdfPath
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
AppException
(
String
.
format
(
"文件转换异常!"
,
e
.
getMessage
()));
}
finally
{
if
(
os
!=
null
)
{
try
{
os
.
flush
();
os
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
}
public
static
void
main
(
String
[]
args
){
String
wordp
=
"D:\\mortals\\app\\data\\test\\1680172785313.docx"
;
String
pdfP
=
"D:\\mortals\\app\\data\\test\\1680172785313.pdf"
;
convertWordToPDF
(
wordp
,
pdfP
);
}
}
certificate-manager/src/main/java/com/mortals/xhx/module/certificate/service/impl/CertificateCatalogServiceImpl.java
View file @
a5f39b7b
...
...
@@ -48,6 +48,9 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi
@Value
(
"${upload.url:http://192.168.0.98:17216/cpm/file/commonupload?prePath=/file/uploadfile}"
)
private
String
uploadUrl
;
@Value
(
"${qrcode.url:http://rhpt.scjg.chengdu.gov.cn:8091/adap/spjy/process/generateQrCode.do?dto.applyId=}"
)
private
String
qrcode
;
@Autowired
private
CertificateClassifyService
certificateClassifyService
;
...
...
@@ -76,6 +79,33 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi
}
@Override
protected
void
updateBefore
(
CertificateCatalogEntity
entity
,
Context
context
)
throws
AppException
{
if
(
StringUtils
.
isEmpty
(
entity
.
getCatalogName
())){
throw
new
AppException
(
"目录名称不能为空"
);
}
if
(
StringUtils
.
isEmpty
(
entity
.
getCatalogCode
())){
throw
new
AppException
(
"目录编码不能为空"
);
}
if
(
entity
.
getHolderType
()==
null
){
throw
new
AppException
(
"持有者类型不能为空"
);
}
if
(
entity
.
getClassifyId
()==
null
){
throw
new
AppException
(
"目录分类不能为空"
);
}
if
(
entity
.
getIndustryId
()==
null
){
throw
new
AppException
(
"所属行业不能为空"
);
}
CertificateCatalogEntity
old
=
this
.
get
(
entity
.
getId
());
if
(!
old
.
getTemplateUrl
().
equals
(
entity
.
getTemplateUrl
()))
{
if
(
StringUtils
.
isNotEmpty
(
entity
.
getTemplateUrl
()))
{
//entity.setFormContent(parseDocxToJson(entity.getTemplateUrl()));
parseDocxToJson
(
entity
,
false
);
}
}
}
// @Override
// protected void validData(CertificateCatalogEntity entity, Context context) throws AppException {
// Map<String,Object> condition = new HashMap<>();
...
...
@@ -195,6 +225,9 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi
}
DesignComponent
designComponent
=
DesignComponent
.
createType
(
type
);
ListItem
listItem
=
designComponent
.
buildDefaultComponent
(
cons
);
if
(
type
.
equals
(
ComponentEnum
.
QRCODE
.
getValue
())){
listItem
.
setValue
(
qrcode
);
}
collect
.
add
(
listItem
);
}
}
...
...
@@ -209,15 +242,15 @@ public class CertificateCatalogServiceImpl extends AbstractCRUDServiceImpl<Certi
}
public
static
void
main
(
String
[]
args
){
String
excelFilePath
=
"D:/mortals/app/data/cpm/"
+
"excel/test1.xls"
;
List
<
String
>
excelList
=
new
ArrayList
<>();
excelList
.
add
(
"i_1_姓名"
);
excelList
.
add
(
"i_2_性别"
);
excelList
.
add
(
"i_3_年龄"
);
excelList
.
add
(
"i_4_证件编号"
);
excelList
.
add
(
"i_5_证件名称"
);
ExcelUtil
.
createCatalogTemplate
(
excelFilePath
,
excelList
);
//
String excelFilePath = "D:/mortals/app/data/cpm/" + "excel/test1.xls";
//
List<String> excelList = new ArrayList<>();
//
excelList.add("i_1_姓名");
//
excelList.add("i_2_性别");
//
excelList.add("i_3_年龄");
//
excelList.add("i_4_证件编号");
//
excelList.add("i_5_证件名称");
//
//
ExcelUtil.createCatalogTemplate(excelFilePath,excelList);
}
@Override
...
...
certificate-manager/src/main/java/com/mortals/xhx/module/record/model/vo/PrintWaitQueueVo.java
View file @
a5f39b7b
...
...
@@ -13,6 +13,11 @@ import java.util.List;
*/
@Data
public
class
PrintWaitQueueVo
extends
BaseEntityLong
{
/**
* 打印服务网络地址
*/
private
String
printerServiceUrl
;
/**
* 打印机名称
*/
...
...
certificate-manager/src/main/java/com/mortals/xhx/module/record/service/impl/ApplyLogServiceImpl.java
View file @
a5f39b7b
...
...
@@ -194,7 +194,7 @@ public class ApplyLogServiceImpl extends AbstractCRUDServiceImpl<ApplyLogDao, Ap
CertificateCatalogEntity
catalog
=
certificateCatalogService
.
get
(
applyLogEntity
.
getCatalogId
());
applyLogEntity
.
setCatalogCode
(
catalog
.
getCatalogCode
());
DocTemplateVO
docTemplate
=
new
DocTemplateVO
(
catalog
.
getTemplateUrl
(),
applyLogEntity
.
getFormContent
());
return
preview
(
docTemplate
,
context
);
return
preview
(
docTemplate
,
context
,
false
);
}
@Override
...
...
@@ -206,12 +206,14 @@ public class ApplyLogServiceImpl extends AbstractCRUDServiceImpl<ApplyLogDao, Ap
CertificateCatalogEntity
catalog
=
certificateCatalogService
.
get
(
applyLogEntity
.
getCatalogId
());
applyLogEntity
.
setCatalogCode
(
catalog
.
getCatalogCode
());
applyLogEntity
.
setCatalogName
(
catalog
.
getCatalogName
());
applyLogEntity
.
setFormTemplate
(
catalog
.
getFormContent
());
//
applyLogEntity.setFormTemplate(catalog.getFormContent());
DocTemplateVO
docTemplate
=
new
DocTemplateVO
(
catalog
.
getTemplateUrl
(),
applyLogEntity
.
getFormContent
());
String
paths
=
preview
(
docTemplate
,
context
);
String
paths
=
preview
(
docTemplate
,
context
,
true
);
String
[]
vals
=
paths
.
split
(
";"
);
applyLogEntity
.
setCertificateUrl
(
vals
[
0
]);
applyLogEntity
.
setPreviewUrl
(
vals
[
1
]);
if
(
vals
.
length
==
3
)
{
applyLogEntity
.
setCertificateUrl
(
vals
[
2
]);
applyLogEntity
.
setPreviewUrl
(
vals
[
1
]);
}
applyLogEntity
.
setCreateTime
(
new
Date
());
applyLogEntity
.
setRecordStatus
(
YesNoEnum
.
NO
.
getValue
());
if
(
context
!=
null
&&
context
.
getUser
()!=
null
)
{
...
...
@@ -250,7 +252,7 @@ public class ApplyLogServiceImpl extends AbstractCRUDServiceImpl<ApplyLogDao, Ap
printWaitQueueService
.
creatWaitQueueByApply
(
applyLogEntity
,
GenerateStatus
.
ORIGINAL
.
getValue
(),
context
);
}
private
String
preview
(
DocTemplateVO
docTemplate
,
Context
context
){
private
String
preview
(
DocTemplateVO
docTemplate
,
Context
context
,
boolean
hasPDF
){
String
rootPath
=
this
.
filePath
.
endsWith
(
"/"
)
?
this
.
filePath
:
this
.
filePath
+
"/"
;
//转换表单参数为map集合
ObjectMapper
mapper
=
new
ObjectMapper
();
...
...
@@ -353,9 +355,18 @@ public class ApplyLogServiceImpl extends AbstractCRUDServiceImpl<ApplyLogDao, Ap
}
WordUtil
.
convertWordToJPEG
(
mergedoc
,
preView
);
log
.
info
(
"preView:"
+
"/preview/"
+
fileName
);
//下载地址拼装
String
returnStr
=
mergedocPath
+
";"
+
"/preview/"
+
fileName
;
return
returnStr
;
if
(
hasPDF
)
{
String
pdfName
=
mergedocPath
.
substring
(
0
,
mergedocPath
.
indexOf
(
"."
))
+
".pdf"
;
String
pdfPath
=
rootPath
+
pdfName
;
WordUtil
.
convertWordToPDF
(
mergedoc
,
pdfPath
);
//下载地址拼装
String
returnStr
=
mergedocPath
+
";"
+
"/preview/"
+
fileName
+
";"
+
pdfName
;
return
returnStr
;
}
else
{
//下载地址拼装
String
returnStr
=
mergedocPath
+
";"
+
"/preview/"
+
fileName
;
return
returnStr
;
}
}
catch
(
Exception
e
)
{
log
.
error
(
"渲染模板失败:"
,
e
);
}
finally
{
...
...
certificate-manager/src/main/java/com/mortals/xhx/module/record/service/impl/PrintWaitQueueServiceImpl.java
View file @
a5f39b7b
...
...
@@ -9,10 +9,17 @@ import com.mortals.xhx.module.certificate.model.CertificateClassifyEntity;
import
com.mortals.xhx.module.certificate.model.CertificateClassifyQuery
;
import
com.mortals.xhx.module.certificate.service.CertificateCatalogService
;
import
com.mortals.xhx.module.certificate.service.CertificateClassifyService
;
import
com.mortals.xhx.module.print.model.PrintCatalogEntity
;
import
com.mortals.xhx.module.print.model.PrintCatalogQuery
;
import
com.mortals.xhx.module.print.model.PrintServiceEntity
;
import
com.mortals.xhx.module.print.model.PrintServiceQuery
;
import
com.mortals.xhx.module.print.service.PrintCatalogService
;
import
com.mortals.xhx.module.print.service.PrintServiceService
;
import
com.mortals.xhx.module.record.dao.PrintLogDao
;
import
com.mortals.xhx.module.record.dao.RetainLogDao
;
import
com.mortals.xhx.module.record.model.*
;
import
com.mortals.xhx.module.record.service.PrintLogService
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
...
...
@@ -57,14 +64,40 @@ public class PrintWaitQueueServiceImpl extends AbstractCRUDServiceImpl<PrintWait
private
CertificateClassifyService
certificateClassifyService
;
@Autowired
private
ParamService
paramService
;
@Autowired
private
PrintServiceService
printServiceService
;
@Autowired
private
PrintCatalogService
printCatalogService
;
@Override
protected
void
findAfter
(
PrintWaitQueueEntity
entity
,
Context
context
,
List
<
PrintWaitQueueEntity
>
list
)
throws
AppException
{
//TODO 当前版本没有设置多个打印服务,默认只存在一个打印服务
List
<
PrintServiceEntity
>
printServiceEntities
=
printServiceService
.
find
(
new
PrintServiceQuery
());
PrintServiceEntity
printServiceEntity
=
null
;
if
(
CollectionUtils
.
isNotEmpty
(
printServiceEntities
)){
printServiceEntity
=
printServiceEntities
.
get
(
0
);
}
for
(
PrintWaitQueueEntity
printWaitQueueEntity:
list
){
CertificateCatalogEntity
catalogEntity
=
certificateCatalogService
.
get
(
printWaitQueueEntity
.
getCatalogId
());
printWaitQueueEntity
.
setPaperSource
(
catalogEntity
.
getPaperSource
());
printWaitQueueEntity
.
setPrinterIp
(
catalogEntity
.
getPrinterIp
());
printWaitQueueEntity
.
setPrinterName
(
catalogEntity
.
getPrinterName
());
if
(
printServiceEntity
!=
null
){
PrintCatalogEntity
printCatalogEntity
=
printCatalogService
.
selectOne
(
new
PrintCatalogQuery
().
catalogId
(
printWaitQueueEntity
.
getCatalogId
()).
serviceId
(
printServiceEntity
.
getId
()));
if
(
printCatalogEntity
!=
null
){
printWaitQueueEntity
.
setPaperSource
(
printCatalogEntity
.
getPaperSource
());
printWaitQueueEntity
.
setPrinterIp
(
printCatalogEntity
.
getPrinterIp
());
printWaitQueueEntity
.
setPrinterName
(
printCatalogEntity
.
getPrinterName
());
}
else
{
CertificateCatalogEntity
catalogEntity
=
certificateCatalogService
.
get
(
printWaitQueueEntity
.
getCatalogId
());
printWaitQueueEntity
.
setPaperSource
(
catalogEntity
.
getPaperSource
());
printWaitQueueEntity
.
setPrinterIp
(
catalogEntity
.
getPrinterIp
());
printWaitQueueEntity
.
setPrinterName
(
catalogEntity
.
getPrinterName
());
}
printWaitQueueEntity
.
setPrinterServiceUrl
(
printServiceEntity
.
getServiceUrl
());
}
else
{
CertificateCatalogEntity
catalogEntity
=
certificateCatalogService
.
get
(
printWaitQueueEntity
.
getCatalogId
());
printWaitQueueEntity
.
setPaperSource
(
catalogEntity
.
getPaperSource
());
printWaitQueueEntity
.
setPrinterIp
(
catalogEntity
.
getPrinterIp
());
printWaitQueueEntity
.
setPrinterName
(
catalogEntity
.
getPrinterName
());
printWaitQueueEntity
.
setPrinterServiceUrl
(
"http://127.0.0.1:8037"
);
}
}
}
...
...
@@ -157,6 +190,7 @@ public class PrintWaitQueueServiceImpl extends AbstractCRUDServiceImpl<PrintWait
Date
now
=
new
Date
();
retainLogEntity
.
setCatalogId
(
waitQueueEntity
.
getCatalogId
());
retainLogEntity
.
setCatalogCode
(
waitQueueEntity
.
getCatalogCode
());
retainLogEntity
.
setCatalogName
(
waitQueueEntity
.
getCatalogName
());
retainLogEntity
.
setCertificateName
(
waitQueueEntity
.
getCertificateName
());
retainLogEntity
.
setCertificateCode
(
waitQueueEntity
.
getCertificateCode
());
retainLogEntity
.
setEnterpriseName
(
waitQueueEntity
.
getEnterpriseName
());
...
...
@@ -169,7 +203,7 @@ public class PrintWaitQueueServiceImpl extends AbstractCRUDServiceImpl<PrintWait
PrintLogEntity
printLogEntity
=
new
PrintLogEntity
();
printLogEntity
.
setCatalogId
(
waitQueueEntity
.
getCatalogId
());
printLogEntity
.
setCatalogCode
(
waitQueueEntity
.
getCatalogCode
());
printLogEntity
.
setCatalogName
(
waitQueueEntity
.
getCatalogName
());
printLogEntity
.
setCertificateName
(
waitQueueEntity
.
getCertificateName
());
printLogEntity
.
setCertificateCode
(
waitQueueEntity
.
getCertificateCode
());
printLogEntity
.
setEnterpriseName
(
waitQueueEntity
.
getEnterpriseName
());
...
...
certificate-manager/src/main/java/com/mortals/xhx/module/record/web/ApplyLogController.java
View file @
a5f39b7b
...
...
@@ -71,11 +71,16 @@ public class ApplyLogController extends BaseCRUDJsonBodyMappingController<ApplyL
try
{
String
paths
=
this
.
service
.
previewOriginal
(
applyLogEntity
,
getContext
());
String
[]
vals
=
paths
.
split
(
";"
);
ret
.
setCode
(
VALUE_RESULT_SUCCESS
);
ret
.
setMsg
(
"生成成功"
);
//model.put("mergeDoc", vals[0]);
model
.
put
(
"preview"
,
vals
[
1
]);
ret
.
setData
(
model
);
if
(
vals
.
length
>
1
)
{
ret
.
setCode
(
VALUE_RESULT_SUCCESS
);
ret
.
setMsg
(
"生成成功"
);
//model.put("mergeDoc", vals[0]);
model
.
put
(
"preview"
,
vals
[
1
]);
ret
.
setData
(
model
);
}
else
{
ret
.
setCode
(
VALUE_RESULT_FAILURE
);
ret
.
setMsg
(
"生成失败"
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
"合成表单异常"
,
e
);
ret
.
setCode
(
VALUE_RESULT_FAILURE
);
...
...
certificate-manager/src/main/resources/bootstrap.yml
View file @
a5f39b7b
...
...
@@ -61,3 +61,5 @@ token:
upload
:
path
:
@
profiles.filepath@
url
:
http://192.168.0.98:17216/cpm/file/commonupload?prePath=/file/uploadfile
qrcode
:
url
:
http://rhpt.scjg.chengdu.gov.cn:8091/adap/spjy/process/generateQrCode.do?dto.applyId=
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment