Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
T
topsun-bpm
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
鲁鑫
topsun-bpm
Commits
150f1f0c
Commit
150f1f0c
authored
Apr 28, 2024
by
刘学辉
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
打印PDF调整为公共方法
parent
4e36e722
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
42 additions
and
56 deletions
+42
-56
sapPermitDetail.js
.../src/main/webapp/biz/topsun/sap/permit/sapPermitDetail.js
+1
-1
PDFViewer.jsp
topsun-xt/src/main/webapp/pdfjs/PDFViewer.jsp
+1
-1
fxt.ftl
topsun-xt/src/main/webapp/template/fxt.ftl
+1
-1
CommonUtils.java
...n/src/main/java/com/huigou/topsun/common/CommonUtils.java
+2
-2
PDFViewerController.java
...ava/com/huigou/topsun/controller/PDFViewerController.java
+14
-28
SapPermitApplication.java
...u/topsun/sap/permit/application/SapPermitApplication.java
+1
-1
SapPermitApplicationImpl.java
...sap/permit/application/impl/SapPermitApplicationImpl.java
+21
-21
SapPermitController.java
...gou/topsun/sap/permit/controller/SapPermitController.java
+1
-1
No files found.
topsun-xt/src/main/webapp/biz/topsun/sap/permit/sapPermitDetail.js
View file @
150f1f0c
...
@@ -151,7 +151,7 @@ function reloadGrid() {
...
@@ -151,7 +151,7 @@ function reloadGrid() {
}
}
function
printPage
()
{
function
printPage
()
{
Public
.
openPostWindow
(
web_app
.
name
+
'/PDFViewer/PDFViewer.do'
,{
id
:
$
(
"#id"
).
val
(),
fileType
:
"p
ermit"
});
Public
.
openPostWindow
(
web_app
.
name
+
'/PDFViewer/PDFViewer.do'
,{
id
:
$
(
"#id"
).
val
(),
applicationType
:
"sapP
ermit"
});
}
}
function
getExtendedData
(
processAction
)
{
function
getExtendedData
(
processAction
)
{
...
...
topsun-xt/src/main/webapp/pdfjs/PDFViewer.jsp
View file @
150f1f0c
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
<script
type=
"text/javascript"
>
<script
type=
"text/javascript"
>
$
(
function
()
{
$
(
function
()
{
$
(
"#pdfViewer"
).
attr
(
"height"
,
$
(
document
).
height
());
$
(
"#pdfViewer"
).
attr
(
"height"
,
$
(
document
).
height
());
var
url
=
"${basePath}/pdfjs/web/viewer.html?file="
+
encodeURIComponent
(
"${basePath}/PDFViewer/displayPDF.ajax?id=${fileId}&
fileType=${file
Type}"
);
var
url
=
"${basePath}/pdfjs/web/viewer.html?file="
+
encodeURIComponent
(
"${basePath}/PDFViewer/displayPDF.ajax?id=${fileId}&
applicationType=${application
Type}"
);
$
(
"#pdfViewer"
).
attr
(
"src"
,
url
);
$
(
"#pdfViewer"
).
attr
(
"src"
,
url
);
})
})
</script>
</script>
...
...
topsun-xt/src/main/webapp/template/fxt.ftl
View file @
150f1f0c
...
@@ -69,7 +69,7 @@
...
@@ -69,7 +69,7 @@
<span
style=
"font-family:SimSun;"
>
${(list.belongings)!''}
</span>
<span
style=
"font-family:SimSun;"
>
${(list.belongings)!''}
</span>
</p>
</p>
</td>
</td>
<td
style=
"border-bottom-color:#000000; border-bottom-style:solid; border-bottom-width:0.75pt; border-right-color:#000000; border-right-style:solid; border-right-width:0.75pt; border-top-color:#000000; border-top-style:solid; border-top-width:0.75pt; vertical-align:top; width:
8
0pt"
>
<td
style=
"border-bottom-color:#000000; border-bottom-style:solid; border-bottom-width:0.75pt; border-right-color:#000000; border-right-style:solid; border-right-width:0.75pt; border-top-color:#000000; border-top-style:solid; border-top-width:0.75pt; vertical-align:top; width:
6
0pt"
>
<p
style=
"margin:0pt; orphans:0; widows:0"
>
<p
style=
"margin:0pt; orphans:0; widows:0"
>
<span
style=
"font-family:SimSun;"
>
${(list.quantity)!''}
</span>
<span
style=
"font-family:SimSun;"
>
${(list.quantity)!''}
</span>
</p>
</p>
...
...
topsun/src/main/java/com/huigou/topsun/common/CommonUtils.java
View file @
150f1f0c
...
@@ -56,7 +56,7 @@ public class CommonUtils {
...
@@ -56,7 +56,7 @@ public class CommonUtils {
// module宽度 UnitConv.in2mm(1.f / dpi);
// module宽度 UnitConv.in2mm(1.f / dpi);
double
moduleWidth
=
0.4
;
double
moduleWidth
=
0.4
;
bean
.
setModuleWidth
(
moduleWidth
);
bean
.
setModuleWidth
(
moduleWidth
);
bean
.
setMsgPosition
(
HumanReadablePlacement
.
HRP_
NONE
);
bean
.
setMsgPosition
(
HumanReadablePlacement
.
HRP_
BOTTOM
);
bean
.
setHeight
(
10
);
bean
.
setHeight
(
10
);
bean
.
doQuietZone
(
false
);
bean
.
doQuietZone
(
false
);
...
...
topsun/src/main/java/com/huigou/topsun/controller/PDFViewerController.java
View file @
150f1f0c
...
@@ -8,26 +8,25 @@ import com.huigou.uasp.bmp.doc.attachment.application.AttachmentApplication;
...
@@ -8,26 +8,25 @@ import com.huigou.uasp.bmp.doc.attachment.application.AttachmentApplication;
import
com.huigou.uasp.bmp.doc.attachment.domain.model.Attachment
;
import
com.huigou.uasp.bmp.doc.attachment.domain.model.Attachment
;
import
com.huigou.uasp.client.CommonController
;
import
com.huigou.uasp.client.CommonController
;
import
com.huigou.util.ApplicationContextWrapper
;
import
com.huigou.util.SDO
;
import
com.huigou.util.SDO
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.util.Assert
;
import
org.springframework.util.Assert
;
import
org.springframework.web.context.WebApplicationContext
;
import
javax.servlet.ServletOutputStream
;
import
javax.servlet.ServletOutputStream
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.*
;
import
java.io.*
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Method
;
@ControllerMapping
(
"/PDFViewer"
)
@ControllerMapping
(
"/PDFViewer"
)
@Controller
@Controller
public
class
PDFViewerController
extends
CommonController
{
public
class
PDFViewerController
extends
CommonController
{
@Autowired
private
AttachmentApplication
attachmentApplication
;
// @Autowired
// private AttachmentContentResolverComposition attachmentContentResolverComposition;
@Autowired
private
SapPermitApplication
sapPermitApplication
;
@Override
@Override
public
String
getPagePath
()
{
public
String
getPagePath
()
{
return
"/pdfjs/"
;
return
"/pdfjs/"
;
...
@@ -37,12 +36,13 @@ public class PDFViewerController extends CommonController {
...
@@ -37,12 +36,13 @@ public class PDFViewerController extends CommonController {
public
String
displayPDF
()
{
public
String
displayPDF
()
{
SDO
sdo
=
this
.
getSDO
();
SDO
sdo
=
this
.
getSDO
();
String
id
=
sdo
.
getString
(
"id"
);
String
id
=
sdo
.
getString
(
"id"
);
String
fileType
=
sdo
.
getString
(
"file
Type"
);
String
applicationType
=
sdo
.
getString
(
"application
Type"
);
try
{
try
{
ByteArrayOutputStream
byteArrayOutputStream
=
null
;
ByteArrayOutputStream
byteArrayOutputStream
=
null
;
if
(
"permit"
.
equals
(
fileType
)){
Object
object
=
ApplicationContextWrapper
.
getBean
(
applicationType
+
"Application"
);
byteArrayOutputStream
=
sapPermitApplication
.
printPermitInfo
(
this
.
getResponse
(),
id
);
Method
method
=
object
.
getClass
().
getMethod
(
"printInfo"
,
HttpServletResponse
.
class
,
String
.
class
);
}
byteArrayOutputStream
=(
ByteArrayOutputStream
)
method
.
invoke
(
object
,
this
.
getResponse
(),
id
);
InputStream
in
=
new
ByteArrayInputStream
(
byteArrayOutputStream
.
toByteArray
());
InputStream
in
=
new
ByteArrayInputStream
(
byteArrayOutputStream
.
toByteArray
());
HttpServletResponse
response
=
this
.
getResponse
();
HttpServletResponse
response
=
this
.
getResponse
();
ServletOutputStream
out
=
response
.
getOutputStream
();
ServletOutputStream
out
=
response
.
getOutputStream
();
...
@@ -53,30 +53,16 @@ public class PDFViewerController extends CommonController {
...
@@ -53,30 +53,16 @@ public class PDFViewerController extends CommonController {
return
null
;
return
null
;
}
}
public
static
void
inputStream2File
(
InputStream
is
,
File
file
)
throws
IOException
{
OutputStream
os
=
null
;
try
{
os
=
new
FileOutputStream
(
file
);
int
len
=
0
;
byte
[]
buffer
=
new
byte
[
8192
];
while
((
len
=
is
.
read
(
buffer
))
!=
-
1
)
{
os
.
write
(
buffer
,
0
,
len
);
}
}
finally
{
os
.
close
();
is
.
close
();
}
}
public
String
PDFViewer
()
{
public
String
PDFViewer
()
{
SDO
sdo
=
this
.
getSDO
();
SDO
sdo
=
this
.
getSDO
();
String
id
=
sdo
.
getString
(
"id"
);
String
id
=
sdo
.
getString
(
"id"
);
String
fileType
=
sdo
.
getString
(
"file
Type"
);
String
applicationType
=
sdo
.
getString
(
"application
Type"
);
// String fileName = "放行条";
putAttribute
(
"id"
,
id
);
putAttribute
(
"id"
,
id
);
putAttribute
(
"fileId"
,
id
);
putAttribute
(
"fileId"
,
id
);
putAttribute
(
"
fileType"
,
file
Type
);
putAttribute
(
"
applicationType"
,
application
Type
);
return
forward
(
"PDFViewer"
);
// 跳转预览pdf页面
return
forward
(
"PDFViewer"
);
// 跳转预览pdf页面
}
}
}
}
\ No newline at end of file
topsun/src/main/java/com/huigou/topsun/sap/permit/application/SapPermitApplication.java
View file @
150f1f0c
...
@@ -32,5 +32,5 @@ public interface SapPermitApplication {
...
@@ -32,5 +32,5 @@ public interface SapPermitApplication {
void
saveSapPermitVo
(
SapPermitVo
sapPermitVo
);
void
saveSapPermitVo
(
SapPermitVo
sapPermitVo
);
ByteArrayOutputStream
print
Permit
Info
(
HttpServletResponse
response
,
String
id
);
ByteArrayOutputStream
printInfo
(
HttpServletResponse
response
,
String
id
);
}
}
topsun/src/main/java/com/huigou/topsun/sap/permit/application/impl/SapPermitApplicationImpl.java
View file @
150f1f0c
package
com
.
huigou
.
topsun
.
sap
.
permit
.
application
.
impl
;
package
com
.
huigou
.
topsun
.
sap
.
permit
.
application
.
impl
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.bean.BeanUtil
;
import
com.alibaba.fastjson.JSONArray
;
import
com.huigou.cache.DictUtil
;
import
com.huigou.cache.DictUtil
;
import
com.huigou.context.Operator
;
import
com.huigou.context.Operator
;
import
com.huigou.context.OrgUnit
;
import
com.huigou.context.OrgUnit
;
...
@@ -29,24 +29,19 @@ import com.itextpdf.text.*;
...
@@ -29,24 +29,19 @@ import com.itextpdf.text.*;
import
com.itextpdf.text.html.simpleparser.HTMLWorker
;
import
com.itextpdf.text.html.simpleparser.HTMLWorker
;
import
com.itextpdf.text.pdf.*
;
import
com.itextpdf.text.pdf.*
;
import
com.itextpdf.text.pdf.draw.LineSeparator
;
import
freemarker.template.Template
;
import
freemarker.template.Template
;
import
org.activiti.engine.delegate.DelegateExecution
;
import
org.activiti.engine.delegate.DelegateExecution
;
import
org.activiti.engine.delegate.DelegateTask
;
import
org.activiti.engine.delegate.DelegateTask
;
import
org.activiti.engine.runtime.ProcessInstance
;
import
org.activiti.engine.runtime.ProcessInstance
;
import
org.apache.commons.io.IOUtils
;
import
org.krysalis.barcode4j.HumanReadablePlacement
;
import
org.krysalis.barcode4j.impl.code128.Code128Bean
;
import
org.krysalis.barcode4j.output.bitmap.BitmapCanvasProvider
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer
;
import
org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer
;
import
org.xhtmlrenderer.pdf.ITextRenderer
;
import
javax.servlet.ServletOutputStream
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.awt.image.BufferedImage
;
import
java.io.*
;
import
java.io.*
;
import
java.net.URLEncoder
;
import
java.net.URLEncoder
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
@@ -241,26 +236,33 @@ public class SapPermitApplicationImpl extends FlowBroker implements SapPermitApp
...
@@ -241,26 +236,33 @@ public class SapPermitApplicationImpl extends FlowBroker implements SapPermitApp
return
localSdo
;
return
localSdo
;
}
}
public
ByteArrayOutputStream
print
Permit
Info
(
HttpServletResponse
response
,
String
id
)
{
public
ByteArrayOutputStream
printInfo
(
HttpServletResponse
response
,
String
id
)
{
// wantGoods.setReceiveAddress(newAddress+wantGoods.getReceiveAddress());
SapPermit
permit
=
this
.
sapPermitRepository
.
findOne
(
id
);
SapPermit
permit
=
this
.
sapPermitRepository
.
findOne
(
id
);
List
<
SapPermitItem
>
itemList
=
this
.
sapPermitItemRepository
.
findBySapPermitId
(
id
);
List
<
SapPermitItem
>
itemList
=
this
.
sapPermitItemRepository
.
findBySapPermitId
(
id
);
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"head"
,
permit
);
data
.
put
(
"head"
,
permit
);
data
.
put
(
"itemList"
,
itemList
);
data
.
put
(
"itemList"
,
itemList
);
//data.put("invoiceList",wantGoods.getInvoiceUsedList());
Document
document
=
null
;
//Document document = null;
PdfCopy
copy
;
ByteArrayOutputStream
byteArrayOutputStream
=
null
;
ByteArrayOutputStream
byteArrayOutputStream
=
null
;
try
{
try
{
response
.
reset
();
response
.
reset
();
response
.
setHeader
(
"Content-Type"
,
"application/pdf-stream"
);
response
.
setHeader
(
"Content-Type"
,
"application/pdf-stream"
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment;filename="
+
URLEncoder
.
encode
(
"放行条.pdf"
,
"UTF-8"
));
response
.
setHeader
(
"Content-Disposition"
,
"attachment;filename="
+
URLEncoder
.
encode
(
"放行条.pdf"
,
"UTF-8"
));
String
randoms
=
CommonUtil
.
createGUID
().
substring
(
0
,
10
);
String
randoms
=
CommonUtil
.
createGUID
().
substring
(
0
,
10
);
File
file
=
new
File
(
"bar-"
+
randoms
+
".png"
);
/*File fileDir=new File("bar");
String
IMG_TYPE_PNG
=
"image/png"
;
if(!fileDir.exists()) {
data
.
put
(
"barCode"
,
CommonUtils
.
genBarCode128
(
permit
.
getBillCode
(),
IMG_TYPE_PNG
,
file
));
fileDir.mkdirs();
}*/
File
file
=
new
File
(
"bar-"
+
permit
.
getBillCode
()+
".png"
);
if
(!
file
.
exists
())
{
String
IMG_TYPE_PNG
=
"image/png"
;
data
.
put
(
"barCode"
,
CommonUtils
.
genBarCode128
(
permit
.
getBillCode
(),
IMG_TYPE_PNG
,
file
));
}
else
{
data
.
put
(
"barCode"
,
file
);
}
File
fileb
=
new
File
(
"baoshen.png"
);
File
fileb
=
new
File
(
"baoshen.png"
);
data
.
put
(
"baoshen"
,
fileb
);
data
.
put
(
"baoshen"
,
fileb
);
Template
template
=
freemarkerConfigurer
.
getConfiguration
().
getTemplate
(
"fxt.ftl"
);
Template
template
=
freemarkerConfigurer
.
getConfiguration
().
getTemplate
(
"fxt.ftl"
);
...
@@ -270,9 +272,7 @@ public class SapPermitApplicationImpl extends FlowBroker implements SapPermitApp
...
@@ -270,9 +272,7 @@ public class SapPermitApplicationImpl extends FlowBroker implements SapPermitApp
e
.
printStackTrace
();
e
.
printStackTrace
();
throw
new
RuntimeException
(
"PDF生成失败!"
);
throw
new
RuntimeException
(
"PDF生成失败!"
);
}
finally
{
}
finally
{
if
(
document
!=
null
)
{
document
.
close
();
}
}
}
return
byteArrayOutputStream
;
return
byteArrayOutputStream
;
}
}
...
...
topsun/src/main/java/com/huigou/topsun/sap/permit/controller/SapPermitController.java
View file @
150f1f0c
...
@@ -97,7 +97,7 @@ public class SapPermitController extends CommonController {
...
@@ -97,7 +97,7 @@ public class SapPermitController extends CommonController {
System
.
out
.
println
(
"id======="
+
id
);
System
.
out
.
println
(
"id======="
+
id
);
// HttpServletResponse response = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();
// HttpServletResponse response = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();
HttpServletResponse
response
=
this
.
getResponse
();
HttpServletResponse
response
=
this
.
getResponse
();
sapPermitApplication
.
print
Permit
Info
(
response
,
id
);
sapPermitApplication
.
printInfo
(
response
,
id
);
//SapPermit permit=this.sapPermitApplication.getPermitById(id);
//SapPermit permit=this.sapPermitApplication.getPermitById(id);
// List <SapPermitItem> itemList=sapPermitItemApplication.findBySapPermitId(id);
// List <SapPermitItem> itemList=sapPermitItemApplication.findBySapPermitId(id);
// String template="fxt.ftl";
// String template="fxt.ftl";
...
...
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