Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
T
traffic-front
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangxiaoming
traffic-front
Commits
4211c6e0
Commit
4211c6e0
authored
Apr 23, 2019
by
chase
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merge 档案管理
parent
0b7018c3
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
103 additions
and
76 deletions
+103
-76
TaxDocumentController.java
...va/pwc/taxtech/atms/controller/TaxDocumentController.java
+58
-25
TaxDocumentServiceImpl.java
...pwc/taxtech/atms/service/impl/TaxDocumentServiceImpl.java
+1
-2
pdf.worker.js
atms-web/src/main/webapp/Scripts/pdf/pdf.worker.js
+2
-0
tax-document-list.ctrl.js
...ocumentManage/tax-document-list/tax-document-list.ctrl.js
+35
-30
tax-document-list.html
...axDocumentManage/tax-document-list/tax-document-list.html
+6
-4
tax-document-list.svc.js
...DocumentManage/tax-document-list/tax-document-list.svc.js
+1
-15
No files found.
atms-api/src/main/java/pwc/taxtech/atms/controller/TaxDocumentController.java
View file @
4211c6e0
...
...
@@ -36,6 +36,7 @@ import pwc.taxtech.atms.vat.entity.FileUpload;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.text.SimpleDateFormat
;
...
...
@@ -122,44 +123,76 @@ public class TaxDocumentController {
*/
@PostMapping
(
"/previewPDF"
)
@ResponseBody
public
void
previewPDF
(
HttpServletResponse
response
,
@RequestBody
TaxDocumentDto
taxDocumentDto
)
{
// return taxDocumentService.previewPDF2(response,taxDocumentDto.getPath());
taxDocumentService
.
previewPDF
(
response
,
taxDocumentDto
.
getPath
());
/*InputStream is = null;
ByteArrayOutputStream os = null;
public
String
previewPDF
(
HttpServletResponse
response
,
@RequestBody
TaxDocumentDto
taxDocumentDto
)
{
return
taxDocumentService
.
previewPDF2
(
response
,
taxDocumentDto
.
getPath
());
}
// /**
// * 读取PDF 转换为图片
// *
// */
// @PostMapping("/previewPDF3")
// @ResponseBody
// public void previewPDF3(HttpServletResponse response ,@RequestBody TaxDocumentDto taxDocumentDto) {
// OutputStream outputStream = null;
// InputStream in = null;
// try {
// in = taxDocumentService.getInputStreamByUrl(taxDocumentDto.getPath());
// response.setHeader("Content-Disposition", "attachment;fileName=test.pdf");
// response.setContentType("multipart/form-data");
// outputStream = response.getOutputStream();
// IOUtils.write(IOUtils.toByteArray(in), outputStream);
// } catch (IOException e) {
// e.printStackTrace();
// throw new RuntimeException("PDF转换失败");
// } finally {
// try {
// in.close();
// } catch (IOException e) {
// throw new RuntimeException("PDF转换失败");
// }
// try {
// outputStream.close();
// } catch (IOException e) {
// throw new RuntimeException("PDF转换失败");
// }
// }
// }
/**
* 读取PDF 转换为图片
*
*/
@PostMapping
(
"/previewPDF2"
)
@ResponseBody
public
void
previewPDF2
(
HttpServletResponse
response
,
@RequestBody
TaxDocumentDto
taxDocumentDto
)
{
OutputStream
outputStream
=
null
;
InputStream
is
=
null
;
try
{
//根据url地址 获取文件输入流
is = getInputStreamByUrl(taxDocumentDto.getPath());
os = new ByteArrayOutputStream();
outputStream
=
response
.
getOutputStream
();
byte
[]
buff
=
new
byte
[
1024
];
int len
= 0
;
String dUrlData=""
;
int
len
;
is
=
taxDocumentService
.
getInputStreamByUrl
(
taxDocumentDto
.
getPath
())
;
while
((
len
=
is
.
read
(
buff
))
!=
-
1
)
{
o
s
.write(buff, 0, len);
o
utputStream
.
write
(
buff
,
0
,
len
);
}
//刷新此输出流并强制写出所有缓冲的输出字节,必须这行代码,否则有可能有问题
os.flush();
os.toByteArray();
dUrlData= Base64.encode(os.toByteArray());
return dUrlData;
} catch (Exception e) {
e.printStackTrace();
return null;
}finally {
outputStream
.
flush
();
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
"PDF转换失败"
);
}
finally
{
try
{
is
.
close
();
}
catch
(
IOException
e
)
{
e.printStackTrace(
);
throw
new
RuntimeException
(
"PDF转换失败"
);
}
try
{
o
s
.close();
o
utputStream
.
close
();
}
catch
(
IOException
e
)
{
e.printStackTrace(
);
throw
new
RuntimeException
(
"PDF转换失败"
);
}
}*/
}
}
}
@RequestMapping
(
"exportExcel"
)
@ResponseBody
public
void
exportExcelFile
(
HttpServletResponse
response
,
@RequestBody
TaxDocumentDto
taxDocumentDto
)
{
...
...
atms-api/src/main/java/pwc/taxtech/atms/service/impl/TaxDocumentServiceImpl.java
View file @
4211c6e0
...
...
@@ -1231,10 +1231,9 @@ public class TaxDocumentServiceImpl {
while
((
len
=
is
.
read
(
buff
))
!=
-
1
)
{
os
.
write
(
buff
,
0
,
len
);
}
os
.
flush
();
os
.
toByteArray
();
dUrlData
=
Base64
.
getEncoder
().
encodeToString
(
os
.
toByteArray
());
os
.
flush
();
}
catch
(
IOException
e
)
{
log
.
error
(
e
.
getMessage
());
throw
new
RuntimeException
(
"pdf转换错误"
);
...
...
atms-web/src/main/webapp/Scripts/pdf/pdf.worker.js
View file @
4211c6e0
...
...
@@ -25547,6 +25547,8 @@
}
function
createBuiltInCMap
(
name
,
builtInCMapParams
)
{
builtInCMapParams
=
{
url
:
'https://unpkg.com/pdfjs-dist@2.0.489/cmaps/'
,
packed
:
true
};
if
(
name
===
'Identity-H'
)
{
return
new
IdentityCMap
(
false
,
2
);
}
else
if
(
name
===
'Identity-V'
)
{
atms-web/src/main/webapp/app/taxDocumentManage/tax-document-list/tax-document-list.ctrl.js
View file @
4211c6e0
...
...
@@ -1593,13 +1593,13 @@ taxDocumentManageModule.directive('pdfPreview', function () {
restrict
:
'EA'
,
controller
:
[
'$scope'
,
'taxDocumentListService'
,
function
(
$scope
,
taxDocumentListService
)
{
window
.
PDFJS
.
workerSrc
=
'./bundles/pdf.worker.js'
;
//
var canvas = document.getElementById('the-canvas');
//
var context = canvas.getContext('2d');
//
var pdfCurPageIndex = 1;
//
var pdfSumPages = 1;
var
canvas
=
document
.
getElementById
(
'the-canvas'
);
var
context
=
canvas
.
getContext
(
'2d'
);
var
pdfCurPageIndex
=
1
;
var
pdfSumPages
=
1
;
var
container
=
document
.
getElementById
(
"pdfLayoutDialog"
);
//
var pdfPromise = null;
//
var cacheUrl = null;
var
pdfPromise
=
null
;
var
cacheUrl
=
null
;
$scope
.
openPdfPreviewPop_bak
=
function
(
url
)
{
container
.
style
.
display
=
"block"
;
if
(
cacheUrl
!==
url
)
{
...
...
@@ -1610,32 +1610,37 @@ taxDocumentManageModule.directive('pdfPreview', function () {
renderPdf
(
pdf
)
})
};
$scope
.
openPdfPreviewPop
=
function
(
url
)
{
var
params
=
{
path
:
url
};
taxDocumentListService
.
readPDF
(
params
).
then
(
function
(
data
,
status
,
headers
)
{
if
(
status
===
204
){
SweetAlert
.
warning
(
"没有数据可以下载"
);
return
;
$scope
.
openPdfPreviewPop
=
function
(
url
)
{
container
.
style
.
display
=
"block"
;
function
start
()
{
return
new
Promise
(
function
(
resolve
,
reject
){
resolve
(
'start'
);
});
}
start
().
then
(
function
(
data
)
{
console
.
log
(
'result of start: '
,
data
);
return
taxDocumentListService
.
readPDF
({
path
:
url
});
}).
then
(
function
(
dataURL
)
{
var
pdfData
=
null
;
if
(
typeof
dataURL
==
"string"
){
pdfData
=
convertDataURIToBinary
(
dataURL
);
}
container
.
style
.
display
=
"block"
;
var
blob
=
data
;
var
img
=
document
.
createElement
(
'img'
);
var
myBlob
=
new
window
.
Blob
([
blob
],
{
type
:
'image/png'
});
console
.
log
(
myBlob
);
var
qrUrl
=
window
.
URL
.
createObjectURL
(
myBlob
);
img
.
src
=
qrUrl
;
img
.
onload
=
function
()
{
window
.
URL
.
revokeObjectURL
(
qrUrl
);
$
(
"div.busy-indicator-container"
).
removeClass
(
"busy-indicator-container"
);
$
(
".TDL-content-container"
)[
0
].
style
.
display
=
"none"
;
$
(
".TDL-header"
)[
0
].
style
.
display
=
"none"
;
$
(
".navbar-custom-top"
)[
0
].
style
.
display
=
"none"
;
container
.
append
(
img
);
console
.
log
(
pdfData
);
return
window
.
PDFJS
.
getDocument
({
data
:
pdfData
});
}).
then
(
function
(
data
)
{
pdfSumPages
=
data
.
numPages
;
return
data
.
getPage
(
pdfCurPageIndex
);
}).
then
(
function
(
page
){
var
scale
=
1.5
;
var
viewport
=
page
.
getViewport
(
scale
);
canvas
.
height
=
viewport
.
height
;
canvas
.
width
=
viewport
.
width
;
var
renderContext
=
{
canvasContext
:
context
,
viewport
:
viewport
};
},
function
()
{
SweetAlert
.
error
(
$translate
.
instant
(
'PleaseContactAdministrator'
));
})
page
.
render
(
renderContext
);
});
};
function
convertDataURIToBinary
(
dataURI
)
{
//将encodeBase64解码
var
raw
=
window
.
atob
(
dataURI
);
...
...
atms-web/src/main/webapp/app/taxDocumentManage/tax-document-list/tax-document-list.html
View file @
4211c6e0
...
...
@@ -306,8 +306,6 @@
}
.TDL-pdf-layout-dialog
{
text-align
:
center
;
float
:
top
;
display
:
none
;
}
...
...
@@ -1483,10 +1481,14 @@
</div>
</div>
<div
class=
"TDL-pdf-layout-dialog"
id=
"pdfLayoutDialog"
pdf-preview
>
<div
id=
"pdfContainer"
style=
"width:0px;height:0px;overflow: hidden;
"
>
<div
class=
"TDL-pdf-layout-dialog"
id=
"pdfLayoutDialog"
pdf-preview
>
<div
class=
"wrapper TDL-pdf-preview-pop"
id=
"pdfContainer
"
>
<canvas
id=
"the-canvas"
></canvas>
</div>
<button
class=
"TDL-pdf-preview-pop-close-btn"
ng-click=
"closePdfPop()"
>
×
</button>
<button
class=
"TDL-pdf-paging-btn TDL-pdf-paging-btn-prev"
ng-click=
"prevPaging()"
title=
"上一页"
>
<
</button>
<button
class=
"TDL-pdf-paging-btn TDL-pdf-paging-btn-next"
ng-click=
"nextPaging()"
title=
"下一页"
>
>
</button>
</div>
<div
class=
"modal fade"
id=
"imgLayoutDialog"
img-preview
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"myModal"
...
...
atms-web/src/main/webapp/app/taxDocumentManage/tax-document-list/tax-document-list.svc.js
View file @
4211c6e0
...
...
@@ -134,21 +134,7 @@ taxDocumentManageModule.factory('taxDocumentListService',
return
jqFetch
.
post
(
apiInterceptor
.
webApiHostUrl
+
'/taxDoc/previewExcelToJson'
,
params
);
},
readPDF
:
function
(
params
){
$
(
'#busy-indicator-container'
).
show
();
var
defer
=
$q
.
defer
();
var
xhr
=
new
XMLHttpRequest
();
xhr
.
onload
=
function
(
result
)
{
if
(
this
.
status
==
200
)
{
var
blob
=
this
.
response
;
defer
.
resolve
(
blob
,
xhr
.
status
,
xhr
.
getAllResponseHeaders
());
}
};
xhr
.
open
(
"post"
,
apiInterceptor
.
webApiHostUrl
+
"/taxDoc/previewPDF"
,
true
);
xhr
.
setRequestHeader
(
"Authorization"
,
apiInterceptor
.
tokenType
+
' '
+
apiInterceptor
.
apiToken
());
xhr
.
setRequestHeader
(
"Content-Type"
,
'application/json;charset=UTF-8'
);
xhr
.
responseType
=
"blob"
;
xhr
.
send
(
JSON
.
stringify
(
params
));
return
defer
.
promise
;
return
jqFetch
.
post
(
apiInterceptor
.
webApiHostUrl
+
'/taxDoc/previewPDF'
,
params
);
},
getBinaryData
:
function
(
url
){
var
defer
=
$q
.
defer
();
...
...
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