Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
T
tianjin-cement
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
竹天卫
tianjin-cement
Commits
8cb23f81
Commit
8cb23f81
authored
Nov 18, 2020
by
qinhu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.报告导出新模板
2.excel转pdf
parent
90a286f8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
7885 additions
and
17 deletions
+7885
-17
pom.xml
cement-business/pom.xml
+22
-0
EntityEnclosureController.java
...cement/business/controller/EntityEnclosureController.java
+13
-1
ReportController.java
.../wise/sc/cement/business/controller/ReportController.java
+46
-13
EntityEnclosure.java
...va/cn/wise/sc/cement/business/entity/EntityEnclosure.java
+3
-0
SampleHandleEnclosure.java
...wise/sc/cement/business/entity/SampleHandleEnclosure.java
+3
-0
SampleHandleEnclosureQuery.java
...ment/business/model/query/SampleHandleEnclosureQuery.java
+2
-0
SampleHandleEnclosureVo.java
.../sc/cement/business/model/vo/SampleHandleEnclosureVo.java
+3
-0
EntrustServiceImpl.java
...e/sc/cement/business/service/impl/EntrustServiceImpl.java
+2
-1
Word2PdfUtil.java
...in/java/cn/wise/sc/cement/business/util/Word2PdfUtil.java
+41
-0
FastDFSUtils.java
...ava/cn/wise/sc/cement/business/util/dfs/FastDFSUtils.java
+29
-0
fastdfs-client.properties
cement-business/src/main/resources/fastdfs-client.properties
+1
-1
report.ftl
cement-business/src/main/resources/templates/report.ftl
+1
-1
report_new.ftl
cement-business/src/main/resources/templates/report_new.ftl
+7719
-0
检测报告模板(最新).xls
cement-business/src/main/resources/检测报告模板(最新).xls
+0
-0
No files found.
cement-business/pom.xml
View file @
8cb23f81
...
...
@@ -138,7 +138,29 @@
<version>
2.8.5
</version>
</dependency>
<dependency>
<groupId>
com.aspose
</groupId>
<!--自定义-->
<artifactId>
words
</artifactId>
<!--自定义-->
<version>
1.0
</version>
<!--自定义-->
<scope>
system
</scope>
<!--system,类似provided,需要显式提供依赖的jar以后,Maven就不会在Repository中查找它-->
<systemPath>
${basedir}/lib/words.jar
</systemPath>
<!--项目根目录下的lib文件夹下-->
</dependency>
<!-- https://mvnrepository.com/artifact/com.aspose/aspose-slides -->
<dependency>
<groupId>
com.aspose
</groupId>
<!--自定义-->
<artifactId>
sliders
</artifactId>
<!--自定义-->
<version>
1.0
</version>
<!--自定义-->
<scope>
system
</scope>
<!--system,类似provided,需要显式提供依赖的jar以后,Maven就不会在Repository中查找它-->
<systemPath>
${basedir}/lib/aspose.slides-15.9.0.jar
</systemPath>
<!--项目根目录下的lib文件夹下-->
</dependency>
<dependency>
<groupId>
com.aspose
</groupId>
<!--自定义-->
<artifactId>
cells
</artifactId>
<!--自定义-->
<version>
1.0
</version>
<!--自定义-->
<scope>
system
</scope>
<!--system,类似provided,需要显式提供依赖的jar以后,Maven就不会在Repository中查找它-->
<systemPath>
${basedir}/lib/aspose-cells-8.5.2.jar
</systemPath>
<!--项目根目录下的lib文件夹下-->
</dependency>
</dependencies>
<build>
...
...
cement-business/src/main/java/cn/wise/sc/cement/business/controller/EntityEnclosureController.java
View file @
8cb23f81
...
...
@@ -61,6 +61,12 @@ public class EntityEnclosureController {
}
else
{
return
BaseResponse
.
errorMsg
(
"登录信息失效"
);
}
if
(!
extName
.
equals
(
".pdf"
))
{
String
pdfPath
=
FastDFSUtils
.
conventAndUpload
(
file
.
getInputStream
(),
fileName
);
map
.
put
(
"pdfPath"
,
pdfPath
);
}
else
{
map
.
put
(
"pdfPath"
,
filePath
);
}
String
picUrl
=
filePath
;
map
.
put
(
"fileUrl"
,
picUrl
);
map
.
put
(
"fileName"
,
fileName
);
...
...
@@ -95,7 +101,7 @@ public class EntityEnclosureController {
map
.
put
(
"fileUrl"
,
picUrl
);
map
.
put
(
"fileName"
,
fileName
);
map
.
put
(
"extName"
,
extName
);
map
.
put
(
"pdfPath"
,
filePath
);
return
BaseResponse
.
okData
(
map
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
toString
());
...
...
@@ -127,6 +133,12 @@ public class EntityEnclosureController {
mapSub
.
put
(
"fileUrl"
,
picUrl
);
mapSub
.
put
(
"fileName"
,
fileName
);
mapSub
.
put
(
"extName"
,
extName
);
if
(!
extName
.
equals
(
".pdf"
))
{
String
pdfPath
=
FastDFSUtils
.
conventAndUpload
(
file
.
getInputStream
(),
fileName
);
mapSub
.
put
(
"pdfPath"
,
pdfPath
);
}
else
{
mapSub
.
put
(
"pdfPath"
,
filePath
);
}
filePathList
.
add
(
mapSub
);
}
}
else
{
...
...
cement-business/src/main/java/cn/wise/sc/cement/business/controller/ReportController.java
View file @
8cb23f81
package
cn
.
wise
.
sc
.
cement
.
business
.
controller
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.wise.sc.cement.business.entity.EntityEnclosure
;
import
cn.wise.sc.cement.business.model.BaseResponse
;
import
cn.wise.sc.cement.business.model.FileExt
;
...
...
@@ -38,6 +40,8 @@ import org.springframework.web.multipart.MultipartFile;
import
javax.servlet.http.HttpServletResponse
;
import
java.time.LocalDateTime
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
...
...
@@ -113,11 +117,20 @@ public class ReportController {
beanParams
.
put
(
"sampleNum"
,
rts
.
getSampleNum
());
beanParams
.
put
(
"sampleNames"
,
set2String
(
rts
.
getSampleNames
()));
beanParams
.
put
(
"teamNames"
,
set2String
(
rts
.
getTeamNames
()));
beanParams
.
put
(
"methodNames"
,
set2StringN
(
rts
.
getMethodNames
()));
beanParams
.
put
(
"equipmentNames"
,
set2StringN
(
rts
.
getEquipmentNames
()));
beanParams
.
put
(
"projectName"
,
rts
.
getProjectName
());
beanParams
.
put
(
"printDate"
,
rts
.
getPrintDate
());
beanParams
.
put
(
"year"
,
DateUtil
.
year
(
DateUtil
.
date
()));
beanParams
.
put
(
"month"
,
DateUtil
.
month
(
DateUtil
.
date
()));
beanParams
.
put
(
"day"
,
DateUtil
.
today
());
beanParams
.
put
(
"reportNo"
,
StrUtil
.
isEmpty
(
rts
.
getReportNo
())?
""
:
rts
.
getReportNo
());
beanParams
.
put
(
"firstMethodName"
,
getFirstSet
(
rts
.
getMethodNames
()));
beanParams
.
put
(
"firstEquipment"
,
getFirstSet
(
rts
.
getEquipmentNames
()));
beanParams
.
put
(
"methodNames"
,
moveFirst
(
rts
.
getMethodNames
()));
beanParams
.
put
(
"equipmentNames"
,
moveFirst
(
rts
.
getEquipmentNames
()));
//六元素导出
List
<
SixElementReport
>
list
=
iEntrustService
.
getSampleSixElementCheck
(
entrustId
);
...
...
@@ -136,25 +149,25 @@ public class ReportController {
list1
.
forEach
(
this
::
initMapStr2AlongPro
);
beanParams
.
put
(
"list3"
,
list1
);
WordUtil
.
writeWordReport
(
rts
.
getProjectName
()
+
"(报告)"
,
"report.ftl"
,
WordUtil
.
writeWordReport
(
rts
.
getProjectName
()
+
"(报告)"
,
"report
_new
.ftl"
,
beanParams
,
response
,
FileExt
.
EXCL
);
}
@PostMapping
(
"/upload"
)
@ApiOperation
(
"上传报告"
)
public
BaseResponse
<
Boolean
>
uploadReport
(
@RequestBody
SampleHandleEnclosureQuery
query
){
public
BaseResponse
<
Boolean
>
uploadReport
(
@RequestBody
SampleHandleEnclosureQuery
query
)
{
Assert
.
notNull
(
query
.
getId
(),
"委托id不能为空!"
);
Assert
.
notNull
(
query
.
getId
(),
"委托id不能为空!"
);
QueryWrapper
<
EntityEnclosure
>
qw
=
new
QueryWrapper
();
qw
.
eq
(
"entity_type"
,
5
);
qw
.
eq
(
"entity_id"
,
query
.
getId
());
qw
.
eq
(
"entity_type"
,
5
);
qw
.
eq
(
"entity_id"
,
query
.
getId
());
if
(
FileExt
.
EXCL
.
getName
().
equals
(
query
.
getExtName
())
||
FileExt
.
EXCLX
.
getName
().
equals
(
query
.
getExtName
())){
if
(
FileExt
.
EXCL
.
getName
().
equals
(
query
.
getExtName
())
||
FileExt
.
EXCLX
.
getName
().
equals
(
query
.
getExtName
()))
{
EntityEnclosure
one
=
iEntityEnclosureService
.
getOne
(
qw
);
if
(
BeanUtil
.
isEmpty
(
one
)){
if
(
BeanUtil
.
isEmpty
(
one
))
{
EntityEnclosure
entityEnclosure
=
new
EntityEnclosure
();
entityEnclosure
.
setEntityId
(
query
.
getId
());
entityEnclosure
.
setExtName
(
query
.
getExtName
());
...
...
@@ -163,9 +176,10 @@ public class ReportController {
entityEnclosure
.
setEnclosureUrl
(
query
.
getEnclosureUrl
());
entityEnclosure
.
setAlias
(
query
.
getAlias
());
entityEnclosure
.
setEntityType
(
5
);
entityEnclosure
.
setPdfUrl
(
query
.
getPdfUrl
());
iEntityEnclosureService
.
save
(
entityEnclosure
);
return
BaseResponse
.
okData
(
true
);
}
else
{
}
else
{
one
.
setAlias
(
query
.
getAlias
());
one
.
setEnclosureUrl
(
query
.
getEnclosureUrl
());
one
.
setExtName
(
query
.
getExtName
());
...
...
@@ -173,7 +187,7 @@ public class ReportController {
iEntityEnclosureService
.
updateById
(
one
);
return
BaseResponse
.
okData
(
true
);
}
}
else
{
}
else
{
return
BaseResponse
.
errorMsg
(
"文件类型只能是excel!"
);
}
...
...
@@ -214,6 +228,26 @@ public class ReportController {
sixElement
.
setSo3
(
countResultMap
.
getOrDefault
(
SixElementKey
.
SO3
.
getKey
(),
"0"
));
}
private
String
getFirstSet
(
Set
<
String
>
set
){
Iterator
<
String
>
iterator
=
set
.
iterator
();
if
(
iterator
.
hasNext
()){
return
iterator
.
next
();
}
return
""
;
}
private
static
Set
<
String
>
moveFirst
(
Set
<
String
>
set
){
Set
<
String
>
newSet
=
new
HashSet
<>(
set
.
size
());
Iterator
<
String
>
iterator
=
set
.
iterator
();
if
(
iterator
.
hasNext
())
{
String
next
=
iterator
.
next
();
newSet
.
addAll
(
set
);
newSet
.
remove
(
next
);
return
newSet
;
}
return
null
;
}
private
void
initMapStr2AlongPro
(
IndustrialReport
industrialReport
)
{
String
countResult
=
industrialReport
.
getCountResults
();
List
<
SixElementReport
.
Element
>
list
=
JSON
.
parseArray
(
countResult
,
SixElementReport
.
Element
.
class
);
...
...
@@ -254,5 +288,4 @@ public class ReportController {
}
}
cement-business/src/main/java/cn/wise/sc/cement/business/entity/EntityEnclosure.java
View file @
8cb23f81
...
...
@@ -60,6 +60,9 @@ public class EntityEnclosure implements Serializable {
@ApiModelProperty
(
"扩展名"
)
private
String
extName
;
@ApiModelProperty
(
"pdf路径"
)
private
String
pdfUrl
;
public
interface
EntityType
{
int
HEAD
=
0
;
int
EQUIPMENT_TEST
=
3
;
...
...
cement-business/src/main/java/cn/wise/sc/cement/business/entity/SampleHandleEnclosure.java
View file @
8cb23f81
...
...
@@ -59,4 +59,7 @@ public class SampleHandleEnclosure implements Serializable {
@ApiModelProperty
(
"扩展名"
)
private
String
extName
;
@ApiModelProperty
(
"pdf路径"
)
private
String
pdfUrl
;
}
cement-business/src/main/java/cn/wise/sc/cement/business/model/query/SampleHandleEnclosureQuery.java
View file @
8cb23f81
...
...
@@ -21,4 +21,6 @@ public class SampleHandleEnclosureQuery {
@ApiModelProperty
(
"路径"
)
private
String
enclosureUrl
;
@ApiModelProperty
(
"pdf路径"
)
private
String
pdfUrl
;
}
\ No newline at end of file
cement-business/src/main/java/cn/wise/sc/cement/business/model/vo/SampleHandleEnclosureVo.java
View file @
8cb23f81
...
...
@@ -58,4 +58,7 @@ public class SampleHandleEnclosureVo {
@ApiModelProperty
(
"扩展名"
)
private
String
extName
;
@ApiModelProperty
(
"pdf地址"
)
private
String
pdfUrl
;
}
cement-business/src/main/java/cn/wise/sc/cement/business/service/impl/EntrustServiceImpl.java
View file @
8cb23f81
...
...
@@ -199,7 +199,7 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
if
(
entityEnclosureList
!=
null
&&
entityEnclosureList
.
size
()>
0
){
EntityEnclosure
entityEnclosure
=
entityEnclosureList
.
get
(
0
);
entrustVo
.
setAlias
(
entityEnclosure
.
getAlias
());
entrustVo
.
setEnclosureUrl
(
entityEnclosure
.
get
Enclosure
Url
());
entrustVo
.
setEnclosureUrl
(
entityEnclosure
.
get
Pdf
Url
());
entrustVo
.
setExtName
(
entityEnclosure
.
getExtName
());
}
}
...
...
@@ -1284,6 +1284,7 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
sampleHandleEnclosure
.
setEnclosureUrl
(
query
.
getEnclosureUrl
())
.
setExtName
(
query
.
getExtName
())
.
setUpdateTime
(
LocalDateTime
.
now
())
.
setPdfUrl
(
query
.
getPdfUrl
())
.
setStatus
(
1
);
if
(
StringUtils
.
isEmpty
(
query
.
getEnclosureUrl
()))
{
sampleHandleEnclosure
.
setStatus
(
2
);
//上传失败
...
...
cement-business/src/main/java/cn/wise/sc/cement/business/util/Word2PdfUtil.java
0 → 100644
View file @
8cb23f81
package
cn
.
wise
.
sc
.
cement
.
business
.
util
;
import
cn.hutool.core.io.file.FileReader
;
import
cn.wise.sc.cement.business.util.dfs.FastDFSUtils
;
import
com.aspose.cells.SaveFormat
;
import
com.aspose.cells.Workbook
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
/**
* @author neo.shu
* @since 2020/9/10 20:38
*/
public
class
Word2PdfUtil
{
public
static
void
main
(
String
[]
args
)
{
try
{
long
time
=
System
.
currentTimeMillis
();
File
file
=
new
File
(
"D:\\JavaProject\\tianjin-cement\\cement-business\\src\\main\\resources\\检测报告模板(最新).xls"
);
Workbook
document
=
new
Workbook
(
new
FileInputStream
(
file
));
//pdf路径
File
outputFile
=
new
File
(
"temp-"
+
System
.
currentTimeMillis
()
+
".pdf"
);
//操作文档保存
document
.
save
(
outputFile
.
getAbsolutePath
(),
SaveFormat
.
PDF
);
FileReader
fileReader
=
new
FileReader
(
outputFile
.
getAbsolutePath
());
String
filePath
=
FastDFSUtils
.
uploadPic
(
fileReader
.
readBytes
(),
outputFile
.
getName
(),
file
.
length
());
long
time1
=
System
.
currentTimeMillis
();
System
.
out
.
println
((
time1
-
time
)
/
1000
);
System
.
out
.
println
(
filePath
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
cement-business/src/main/java/cn/wise/sc/cement/business/util/dfs/FastDFSUtils.java
View file @
8cb23f81
package
cn
.
wise
.
sc
.
cement
.
business
.
util
.
dfs
;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.io.file.FileReader
;
import
com.aspose.cells.SaveFormat
;
import
com.aspose.cells.Workbook
;
import
com.aspose.words.Document
;
import
org.apache.commons.io.FilenameUtils
;
import
org.csource.common.MyException
;
import
org.csource.common.NameValuePair
;
import
org.csource.fastdfs.*
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.IOException
;
import
java.io.InputStream
;
...
...
@@ -174,4 +181,26 @@ public class FastDFSUtils {
}
}
public
static
String
conventAndUpload
(
InputStream
inputStream
,
String
filename
)
{
File
outputFile
=
new
File
(
filename
+
".pdf"
);
String
filePath
=
""
;
try
{
Workbook
document
=
new
Workbook
(
inputStream
);
//pdf路径
//操作文档保存
document
.
save
(
outputFile
.
getAbsolutePath
(),
SaveFormat
.
PDF
);
FileReader
fileReader
=
new
FileReader
(
outputFile
.
getAbsolutePath
());
filePath
=
uploadPic
(
fileReader
.
readBytes
(),
outputFile
.
getName
(),
outputFile
.
length
());
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
//删除创建的输出文件
FileUtil
.
del
(
outputFile
);
return
filePath
;
}
}
}
\ No newline at end of file
cement-business/src/main/resources/fastdfs-client.properties
View file @
8cb23f81
...
...
@@ -4,7 +4,7 @@ fastdfs.charset=UTF-8
fastdfs.http.tracker_http_port
=
8888
fastdfs.http.anti_steal_token
=
no
fastdfs.http.secret_key
=
FastDFS1234567890
fastdfs.tracker_servers
=
localhost
:22122
fastdfs.tracker_servers
=
192.168.110.85
:22122
#fastdfs.tracker_servers=localhost:22122
cement-business/src/main/resources/templates/report.ftl
View file @
8cb23f81
...
...
@@ -20448,7 +20448,7 @@
</Cell>
</Row>
<
/#list>
<
#--
六元素2--end-->
<
#--六元素2--end-->
</Table>
<WorksheetOptions
xmlns=
"urn:schemas-microsoft-com:office:excel"
>
<PageSetup>
...
...
cement-business/src/main/resources/templates/report_new.ftl
0 → 100644
View file @
8cb23f81
This diff is collapsed.
Click to expand it.
cement-business/src/main/resources/检测报告模板(最新).xls
0 → 100644
View file @
8cb23f81
This diff is collapsed.
Click to expand it.
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