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
909368ba
Commit
909368ba
authored
Nov 19, 2018
by
sherlock
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
显示公式的问题,导入手工数据源设置
parent
69c9343c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
16 deletions
+57
-16
TemplateController.java
.../java/pwc/taxtech/atms/controller/TemplateController.java
+47
-8
TemplateGroupServiceImpl.java
...c/taxtech/atms/service/impl/TemplateGroupServiceImpl.java
+10
-8
No files found.
atms-api/src/main/java/pwc/taxtech/atms/controller/TemplateController.java
View file @
909368ba
...
...
@@ -3,6 +3,12 @@ package pwc.taxtech.atms.controller;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.poi.openxml4j.exceptions.InvalidFormatException
;
import
org.apache.poi.ss.usermodel.Cell
;
import
org.apache.poi.ss.usermodel.Row
;
import
org.apache.poi.ss.usermodel.Sheet
;
import
org.apache.poi.ss.usermodel.Workbook
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.joda.time.DateTime
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -27,13 +33,7 @@ import pwc.taxtech.atms.service.impl.HttpFileService;
import
pwc.taxtech.atms.service.impl.TemplateServiceImpl
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.BufferedInputStream
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.io.*
;
import
java.net.URISyntaxException
;
import
java.util.Collections
;
import
java.util.List
;
...
...
@@ -64,6 +64,44 @@ public class TemplateController extends BaseController {
return
Collections
.
emptyList
();
}
private
InputStream
handleFomularView
(
InputStream
is
){
Workbook
workbook
=
null
;
try
{
workbook
=
new
XSSFWorkbook
(
is
);
}
catch
(
IOException
e
)
{
logger
.
error
(
"failed to read workbook!"
,
e
);
throw
new
ApplicationException
(
"failed to read workbook!"
);
}
for
(
int
i
=
0
;
i
<
workbook
.
getNumberOfSheets
();
i
++){
Sheet
sheet
=
workbook
.
getSheetAt
(
i
);
for
(
int
r
=
sheet
.
getFirstRowNum
();
r
<=
sheet
.
getLastRowNum
();
r
++){
Row
row
=
sheet
.
getRow
(
r
);
for
(
int
c
=
row
.
getFirstCellNum
();
c
<=
row
.
getLastCellNum
();
c
++)
{
Cell
cell
=
row
.
getCell
(
c
);
if
(
cell
!=
null
&&
!
cell
.
getCellStyle
().
getLocked
()){
cell
.
setCellValue
(
StringUtils
.
EMPTY
);
}
}
}
}
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
try
{
workbook
.
write
(
baos
);
byte
[]
content
=
baos
.
toByteArray
();
return
new
ByteArrayInputStream
(
content
);
}
catch
(
Exception
e
){
logger
.
error
(
"failed write workbook!"
,
e
);
throw
new
ApplicationException
(
"failed write workbook!"
);
}
finally
{
try
{
baos
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
@RequestMapping
(
value
=
"getTemplateJson"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_OCTET_STREAM_VALUE
)
public
@ResponseBody
void
getTemplateBlob
(
@RequestParam
(
name
=
"templateID"
)
Long
templateId
,
HttpServletResponse
response
)
throws
URISyntaxException
{
...
...
@@ -95,8 +133,9 @@ public class TemplateController extends BaseController {
// while ((len = inputStream.read(buffer)) > 0) {
// out.write(buffer, 0, len);
// }
out
=
response
.
getOutputStream
();
IOUtils
.
copy
(
inputStream
,
out
);
IOUtils
.
copy
(
handleFomularView
(
inputStream
)
,
out
);
out
.
flush
();
}
catch
(
FileNotFoundException
e
)
{
...
...
atms-api/src/main/java/pwc/taxtech/atms/service/impl/TemplateGroupServiceImpl.java
View file @
909368ba
...
...
@@ -266,12 +266,13 @@ public class TemplateGroupServiceImpl extends AbstractService {
cellTemplate
.
setIsReadOnly
(
cell
.
getCellStyle
().
getLocked
());
cellTemplateList
.
add
(
cellTemplate
);
//todo: 这里没有Config数据只有在上传模板以后,在界面里面可以配置公式
if
(!
cell
.
getCellStyle
().
getLocked
()
&&
hasKeyIn
(
cell
)
&&
allowManual
)
{
if
(!
cell
.
getCellStyle
().
getLocked
()
&&
hasKeyIn
(
cell
))
{
cell
.
setCellValue
(
StringUtils
.
EMPTY
);
addManualConfig
(
cellTemplate
,
template
,
cell
,
now
,
cellTemplateConfigList
);
if
(
allowManual
){
addManualConfig
(
cellTemplate
,
template
,
cell
,
now
,
cellTemplateConfigList
);
}
}
if
(!
cell
.
getCellStyle
().
getLocked
()
&&
StringUtils
.
isNotBlank
(
POIUtil
.
getCellFormulaString
(
cell
))
&&
"${KeyIn}"
.
equalsIgnoreCase
(
POIUtil
.
getCellFormulaString
(
cell
)))
{
if
(!
cell
.
getCellStyle
().
getLocked
()
&&
StringUtils
.
isNotBlank
(
POIUtil
.
getCellFormulaString
(
cell
)))
{
CellTemplateConfig
config
=
new
CellTemplateConfig
();
config
.
setId
(
distributedIdService
.
nextId
());
config
.
setCellTemplateId
(
cellTemplate
.
getId
());
...
...
@@ -402,12 +403,13 @@ public class TemplateGroupServiceImpl extends AbstractService {
cellTemplate
.
setIsReadOnly
(
cell
.
getCellStyle
().
getLocked
()
?
true
:
false
);
cellTemplateList
.
add
(
cellTemplate
);
//todo: 这里没有Config数据只有在上传模板以后,在界面里面可以配置公式
if
(!
cell
.
getCellStyle
().
getLocked
()
&&
hasKeyIn
(
cell
)
&&
allowManual
)
{
if
(!
cell
.
getCellStyle
().
getLocked
()
&&
hasKeyIn
(
cell
))
{
cell
.
setCellValue
(
StringUtils
.
EMPTY
);
addManualConfig
(
cellTemplate
,
template
,
cell
,
now
,
cellTemplateConfigList
);
if
(
allowManual
){
addManualConfig
(
cellTemplate
,
template
,
cell
,
now
,
cellTemplateConfigList
);
}
}
if
(!
cell
.
getCellStyle
().
getLocked
()
&&
StringUtils
.
isNotBlank
(
POIUtil
.
getCellFormulaString
(
cell
))
&&
"${KeyIn}"
.
equalsIgnoreCase
(
POIUtil
.
getCellFormulaString
(
cell
)))
{
if
(!
cell
.
getCellStyle
().
getLocked
()
&&
StringUtils
.
isNotBlank
(
POIUtil
.
getCellFormulaString
(
cell
)))
{
CellTemplateConfig
config
=
new
CellTemplateConfig
();
config
.
setId
(
distributedIdService
.
nextId
());
config
.
setCellTemplateId
(
cellTemplate
.
getId
());
...
...
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