Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
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
项目统一框架
amos-boot-biz
Commits
a51480c7
Commit
a51480c7
authored
Dec 26, 2023
by
xixinzhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(jg): 告知书许可证编号修改取值。样式改为多个,部分代码优化
parent
0863bd3d
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
187 additions
and
268 deletions
+187
-268
JgInstallationNoticeMapper.xml
.../src/main/resources/mapper/JgInstallationNoticeMapper.xml
+2
-1
JgMaintainNoticeMapper.xml
...-api/src/main/resources/mapper/JgMaintainNoticeMapper.xml
+2
-1
JgReformNoticeMapper.xml
...jg-api/src/main/resources/mapper/JgReformNoticeMapper.xml
+2
-1
JgTransferNoticeMapper.xml
...-api/src/main/resources/mapper/JgTransferNoticeMapper.xml
+3
-1
JgInstallationNoticeServiceImpl.java
.../jg/biz/service/impl/JgInstallationNoticeServiceImpl.java
+25
-66
JgMaintainNoticeServiceImpl.java
...dule/jg/biz/service/impl/JgMaintainNoticeServiceImpl.java
+28
-64
JgReformNoticeServiceImpl.java
...module/jg/biz/service/impl/JgReformNoticeServiceImpl.java
+25
-68
JgTransferNoticeServiceImpl.java
...dule/jg/biz/service/impl/JgTransferNoticeServiceImpl.java
+24
-66
WordTemplateUtils.java
...join/amos/boot/module/jg/biz/utils/WordTemplateUtils.java
+76
-0
installation-notification-report.docx
...resources/templates/installation-notification-report.docx
+0
-0
installation-notification-report.ftl
.../resources/templates/installation-notification-report.ftl
+0
-0
No files found.
amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-api/src/main/resources/mapper/JgInstallationNoticeMapper.xml
View file @
a51480c7
...
...
@@ -106,7 +106,8 @@
fi.ins_use_maintain_explain AS insUseMaintainExplain,
ei.legal_person AS safetyManager,
ei.legal_phone AS safetyManagerPhone,
ei.address AS address
ei.address AS address,
ei.use_code AS useCode
FROM
tzs_jg_installation_notice isn
LEFT JOIN tzs_jg_installation_notice_eq re ON re.equip_transfer_id = isn.sequence_nbr
...
...
amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-api/src/main/resources/mapper/JgMaintainNoticeMapper.xml
View file @
a51480c7
...
...
@@ -104,7 +104,8 @@
ei.legal_phone AS safetyManagerPhone,
ui.CITY_NAME AS useUnitCityName,
ui.COUNTY_NAME AS useUnitCountyName,
ei.ADDRESS AS useUnitAddress
ei.ADDRESS AS useUnitAddress,
ei.use_code AS useCode
FROM tzs_jg_maintain_notice isn
LEFT JOIN tzs_jg_maintain_notice_eq re ON re.equip_transfer_id = isn.sequence_nbr
LEFT JOIN idx_biz_jg_register_info ri ON ri.record = re.equ_id
...
...
amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-api/src/main/resources/mapper/JgReformNoticeMapper.xml
View file @
a51480c7
...
...
@@ -125,7 +125,8 @@
fi.ins_use_maintain_explain AS insUseMaintainExplain,
ei.legal_person AS safetyManager,
ei.legal_phone AS safetyManagerPhone,
ei.ADDRESS AS useUnitAddress
ei.ADDRESS AS useUnitAddress,
ei.use_code AS useCode
FROM
tzs_jg_reform_notice isn
LEFT JOIN tzs_jg_reform_notice_eq re ON re.equip_transfer_id = isn.sequence_nbr
...
...
amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-api/src/main/resources/mapper/JgTransferNoticeMapper.xml
View file @
a51480c7
...
...
@@ -129,7 +129,8 @@
ui.PROVINCE_NAME AS useUnitProvinceName,
ui.CITY_NAME AS useUnitCityName,
ui.COUNTY_NAME AS useUnitCountyName,
ui.ADDRESS AS useUnitAddress
ui.ADDRESS AS useUnitAddress,
ei.use_code AS useCode
FROM
tzs_jg_transfer_notice tjtn
LEFT JOIN tzs_jg_transfer_notice_eq re ON re.equip_transfer_id = tjtn.sequence_nbr
...
...
@@ -138,6 +139,7 @@
LEFT JOIN idx_biz_jg_factory_info fi ON fi.record = re.equ_id
LEFT JOIN idx_biz_jg_inspection_detection_info idi ON idi.record = re.equ_id
LEFT JOIN idx_biz_jg_use_info ui ON ui.record = re.equ_id
LEFT JOIN tz_base_enterprise_info ei ON ei.use_code = tjtn.use_unit_credit_code
WHERE
tjtn.sequence_nbr = #{sequenceNbr}
LIMIT 1
...
...
amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-biz/src/main/java/com/yeejoin/amos/boot/module/jg/biz/service/impl/JgInstallationNoticeServiceImpl.java
View file @
a51480c7
...
...
@@ -30,6 +30,7 @@ import com.yeejoin.amos.boot.module.jg.biz.utils.WordTemplateUtils;
import
com.yeejoin.amos.boot.module.ymt.api.enums.ApplicationFormTypeEnum
;
import
com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum
;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.*
;
import
com.yeejoin.amos.boot.module.ymt.api.service.ITzBaseUnitLicenceService
;
import
com.yeejoin.amos.component.feign.model.FeignClientResult
;
import
com.yeejoin.amos.feign.systemctl.Systemctl
;
import
com.yeejoin.amos.feign.workflow.Workflow
;
...
...
@@ -124,21 +125,8 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
@Autowired
private
RedisUtils
redisUtils
;
public
static
byte
[]
file2byte
(
File
file
)
{
try
{
FileInputStream
in
=
new
FileInputStream
(
file
);
//当文件没有结束时,每次读取一个字节显示
byte
[]
data
=
new
byte
[
in
.
available
()];
in
.
read
(
data
);
in
.
close
();
return
data
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
null
;
}
}
@Autowired
private
TzBaseUnitLicenceMapper
baseUnitLicenceMapper
;
/**
* 根据sequenceNbr查询
...
...
@@ -334,6 +322,23 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
}
Map
<
String
,
Object
>
installation
=
informationList
.
get
(
0
);
String
useCode
=
String
.
valueOf
(
installation
.
get
(
"useCode"
));
LambdaQueryWrapper
<
TzBaseUnitLicence
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
eq
(
TzBaseUnitLicence:
:
getUnitCode
,
useCode
);
List
<
TzBaseUnitLicence
>
list
=
baseUnitLicenceMapper
.
selectList
(
wrapper
);
ArrayList
<
String
>
installLicenseNoList
=
new
ArrayList
<>();
ArrayList
<
String
>
installLicenseExpirationDateList
=
new
ArrayList
<>();
if
(!
CollectionUtils
.
isEmpty
(
list
))
{
list
.
forEach
(
tzBaseUnitLicence
->
{
// 因模板许可证编号配置最多支持三个,再多样式混乱,目前返回三个
if
(
installLicenseNoList
.
size
()
<
3
)
{
installLicenseNoList
.
add
(
tzBaseUnitLicence
.
getCertNo
());
installLicenseExpirationDateList
.
add
(
DateUtils
.
convertDateToString
(
tzBaseUnitLicence
.
getExpiryDate
(),
DateUtils
.
DATE_PATTERN
));
}
});
}
Function
<
String
,
String
>
getValue
=
key
->
installation
.
getOrDefault
(
key
,
""
).
toString
();
// 组装模板变量
...
...
@@ -359,27 +364,15 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
placeholders
.
put
(
"useUnitLeaderName"
,
getValue
.
apply
(
"safetyManager"
));
placeholders
.
put
(
"useUnitLeaderPhone"
,
getValue
.
apply
(
"safetyManagerPhone"
));
placeholders
.
put
(
"useUnitLeaderAddress"
,
getValue
.
apply
(
"address"
));
placeholders
.
put
(
"installLicenseNoList"
,
installLicenseNoList
);
placeholders
.
put
(
"installLicenseExpirationDateList"
,
installLicenseExpirationDateList
);
// 生成二维码
String
qrCode
=
ImageUtils
.
generateQRCode
(
getValue
.
apply
(
"applyNo"
),
300
,
300
);
placeholders
.
put
(
"qrCode"
,
qrCode
);
// word转pdf
File
pdfFile
;
try
{
pdfFile
=
this
.
wordToPdf
(
"installation-notification-report.ftl"
,
placeholders
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
// 上传pdf至文件服务器
String
url
=
this
.
uploadFile
(
pdfFile
);
// 删除临时文件
try
{
Files
.
deleteIfExists
(
pdfFile
.
toPath
());
}
catch
(
IOException
e
)
{
log
.
error
(
"删除临时文件失败:{}"
,
e
);
}
String
url
=
WordTemplateUtils
.
templateToPdf
(
"installation-notification-report.ftl"
,
placeholders
);
// 更新到数据库
jgInstallationNotice
.
setNoticeReportUrl
(
url
);
...
...
@@ -388,40 +381,6 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
return
url
;
}
/**
* word 转 pdf
*
* @param wordPath word文件路径
*/
private
File
wordToPdf
(
String
wordPath
,
Map
<
String
,
Object
>
placeholders
)
throws
Exception
{
Assert
.
hasText
(
wordPath
,
"word文件路径不能为空"
);
String
tempFileName
=
"安装告知单_"
+
System
.
currentTimeMillis
()
+
"_temp.pdf"
;
WordTemplateUtils
instance
=
WordTemplateUtils
.
getInstance
();
return
instance
.
fillAndConvertDocFile
(
wordPath
,
tempFileName
,
placeholders
,
SaveFormat
.
PDF
);
}
/**
* 上传文件至文件服务器
*
* @param file 文件
*/
private
String
uploadFile
(
File
file
)
{
Assert
.
notNull
(
file
,
"文件不能为空"
);
MultipartFile
multipartFile
=
new
ByteArrayMultipartFile
(
"file"
,
"file.pdf"
,
"application/pdf"
,
file2byte
(
file
));
FeignClientResult
<
Map
<
String
,
String
>>
result
=
Systemctl
.
fileStorageClient
.
updateCommonFile
(
multipartFile
);
String
urlString
=
""
;
if
(
result
!=
null
)
{
for
(
String
s
:
result
.
getResult
().
keySet
())
{
urlString
=
s
;
}
}
return
urlString
;
}
@Override
@SuppressWarnings
({
"Duplicates"
,
"rawtypes"
})
@Transactional
(
rollbackFor
=
Exception
.
class
)
...
...
amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-biz/src/main/java/com/yeejoin/amos/boot/module/jg/biz/service/impl/JgMaintainNoticeServiceImpl.java
View file @
a51480c7
...
...
@@ -23,12 +23,10 @@ import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient;
import
com.yeejoin.amos.boot.module.jg.biz.utils.ImageUtils
;
import
com.yeejoin.amos.boot.module.jg.biz.utils.WordTemplateUtils
;
import
com.yeejoin.amos.boot.module.ymt.api.entity.RegistrationInfo
;
import
com.yeejoin.amos.boot.module.ymt.api.entity.TzBaseUnitLicence
;
import
com.yeejoin.amos.boot.module.ymt.api.enums.ApplicationFormTypeEnum
;
import
com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum
;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryMapper
;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.OtherInfoMapper
;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.RegistrationInfoMapper
;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.SupervisoryCodeInfoMapper
;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.*
;
import
com.yeejoin.amos.component.feign.model.FeignClientResult
;
import
com.yeejoin.amos.feign.systemctl.Systemctl
;
import
com.yeejoin.amos.feign.workflow.Workflow
;
...
...
@@ -96,19 +94,9 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto
@Autowired
RedisUtils
redisUtils
;
public
static
byte
[]
file2byte
(
File
file
)
{
try
{
FileInputStream
in
=
new
FileInputStream
(
file
);
//当文件没有结束时,每次读取一个字节显示
byte
[]
data
=
new
byte
[
in
.
available
()];
in
.
read
(
data
);
in
.
close
();
return
data
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
null
;
}
}
@Autowired
private
TzBaseUnitLicenceMapper
baseUnitLicenceMapper
;
/**
* 根据sequenceNbr查询
...
...
@@ -293,6 +281,24 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto
throw
new
IllegalArgumentException
(
"维修告知单不存在"
);
}
Map
<
String
,
Object
>
installation
=
informationList
.
get
(
0
);
String
useCode
=
String
.
valueOf
(
installation
.
get
(
"useCode"
));
LambdaQueryWrapper
<
TzBaseUnitLicence
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
eq
(
TzBaseUnitLicence:
:
getUnitCode
,
useCode
);
List
<
TzBaseUnitLicence
>
list
=
baseUnitLicenceMapper
.
selectList
(
wrapper
);
ArrayList
<
String
>
installLicenseNoList
=
new
ArrayList
<>();
ArrayList
<
String
>
installLicenseExpirationDateList
=
new
ArrayList
<>();
if
(!
CollectionUtils
.
isEmpty
(
list
))
{
list
.
forEach
(
tzBaseUnitLicence
->
{
// 因模板许可证编号配置最多支持三个,再多样式混乱,目前返回三个
if
(
installLicenseNoList
.
size
()
<
3
)
{
installLicenseNoList
.
add
(
tzBaseUnitLicence
.
getCertNo
());
installLicenseExpirationDateList
.
add
(
DateUtils
.
convertDateToString
(
tzBaseUnitLicence
.
getExpiryDate
(),
DateUtils
.
DATE_PATTERN
));
}
});
}
Function
<
String
,
String
>
getValue
=
key
->
installation
.
getOrDefault
(
key
,
""
).
toString
();
// 组装模板变量
Map
<
String
,
Object
>
placeholders
=
new
HashMap
<>();
...
...
@@ -320,59 +326,17 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto
// 生成二维码
String
qrCode
=
ImageUtils
.
generateQRCode
(
getValue
.
apply
(
"applyNo"
),
300
,
300
);
placeholders
.
put
(
"qrCode"
,
qrCode
);
// word转pdf
File
pdfFile
;
try
{
pdfFile
=
this
.
wordToPdf
(
"installation-notification-report.ftl"
,
placeholders
);
}
catch
(
Exception
e
)
{
log
.
error
(
"word转pdf失败:{}"
,
e
);
throw
new
RuntimeException
(
e
);
}
// 上传pdf至文件服务器
String
url
=
this
.
uploadFile
(
pdfFile
);
// 删除临时文件
try
{
Files
.
deleteIfExists
(
pdfFile
.
toPath
());
}
catch
(
IOException
e
)
{
log
.
error
(
"删除临时文件失败:{}"
,
e
);
throw
new
RuntimeException
(
e
);
}
placeholders
.
put
(
"installLicenseNoList"
,
installLicenseNoList
);
placeholders
.
put
(
"installLicenseExpirationDateList"
,
installLicenseExpirationDateList
);
String
url
=
WordTemplateUtils
.
templateToPdf
(
"installation-notification-report.ftl"
,
placeholders
);
// 更新到数据库
JgMaintainNotice
.
setNoticeReportUrl
(
url
);
this
.
updateById
(
JgMaintainNotice
);
return
url
;
}
/**
* word 转 pdf
*
* @param wordPath word文件路径
*/
private
File
wordToPdf
(
String
wordPath
,
Map
<
String
,
Object
>
placeholders
)
throws
Exception
{
Assert
.
hasText
(
wordPath
,
"word文件路径不能为空"
);
String
tempFileName
=
"维修告知单_"
+
System
.
currentTimeMillis
()
+
"_temp.pdf"
;
WordTemplateUtils
instance
=
WordTemplateUtils
.
getInstance
();
return
instance
.
fillAndConvertDocFile
(
wordPath
,
tempFileName
,
placeholders
,
SaveFormat
.
PDF
);
}
/**
* 上传文件至文件服务器
*
* @param file 文件
*/
private
String
uploadFile
(
File
file
)
{
Assert
.
notNull
(
file
,
"文件不能为空"
);
MultipartFile
multipartFile
=
new
ByteArrayMultipartFile
(
"file"
,
"file.pdf"
,
"application/pdf"
,
file2byte
(
file
));
FeignClientResult
<
Map
<
String
,
String
>>
result
=
Systemctl
.
fileStorageClient
.
updateCommonFile
(
multipartFile
);
String
urlString
=
""
;
if
(
result
!=
null
)
{
for
(
String
s
:
result
.
getResult
().
keySet
())
{
urlString
=
s
;
}
}
return
urlString
;
}
@Override
@SuppressWarnings
({
"Duplicates"
,
"rawtypes"
})
@Transactional
(
rollbackFor
=
Exception
.
class
)
...
...
amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-biz/src/main/java/com/yeejoin/amos/boot/module/jg/biz/service/impl/JgReformNoticeServiceImpl.java
View file @
a51480c7
...
...
@@ -21,12 +21,10 @@ import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient;
import
com.yeejoin.amos.boot.module.jg.biz.utils.ImageUtils
;
import
com.yeejoin.amos.boot.module.jg.biz.utils.WordTemplateUtils
;
import
com.yeejoin.amos.boot.module.ymt.api.entity.RegistrationInfo
;
import
com.yeejoin.amos.boot.module.ymt.api.entity.TzBaseUnitLicence
;
import
com.yeejoin.amos.boot.module.ymt.api.enums.ApplicationFormTypeEnum
;
import
com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum
;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryMapper
;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.OtherInfoMapper
;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.RegistrationInfoMapper
;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.SupervisoryCodeInfoMapper
;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.*
;
import
com.yeejoin.amos.component.feign.model.FeignClientResult
;
import
com.yeejoin.amos.feign.systemctl.Systemctl
;
import
com.yeejoin.amos.feign.workflow.Workflow
;
...
...
@@ -96,22 +94,10 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
TzsServiceFeignClient
tzsServiceFeignClient
;
@Autowired
SupervisoryCodeInfoMapper
supervisoryCodeInfoMapper
;
@Autowired
private
RedisUtils
redisUtils
;
public
static
byte
[]
file2byte
(
File
file
)
{
try
{
FileInputStream
in
=
new
FileInputStream
(
file
);
// 当文件没有结束时,每次读取一个字节显示
byte
[]
data
=
new
byte
[
in
.
available
()];
in
.
read
(
data
);
in
.
close
();
return
data
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
null
;
}
}
@Autowired
private
TzBaseUnitLicenceMapper
baseUnitLicenceMapper
;
/**
* 根据sequenceNbr查询
...
...
@@ -302,6 +288,23 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
}
Map
<
String
,
Object
>
installation
=
informationList
.
get
(
0
);
String
useCode
=
String
.
valueOf
(
installation
.
get
(
"useCode"
));
LambdaQueryWrapper
<
TzBaseUnitLicence
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
eq
(
TzBaseUnitLicence:
:
getUnitCode
,
useCode
);
List
<
TzBaseUnitLicence
>
list
=
baseUnitLicenceMapper
.
selectList
(
wrapper
);
ArrayList
<
String
>
installLicenseNoList
=
new
ArrayList
<>();
ArrayList
<
String
>
installLicenseExpirationDateList
=
new
ArrayList
<>();
if
(!
CollectionUtils
.
isEmpty
(
list
))
{
list
.
forEach
(
tzBaseUnitLicence
->
{
// 因模板许可证编号配置最多支持三个,再多样式混乱,目前返回三个
if
(
installLicenseNoList
.
size
()
<
3
)
{
installLicenseNoList
.
add
(
tzBaseUnitLicence
.
getCertNo
());
installLicenseExpirationDateList
.
add
(
DateUtils
.
convertDateToString
(
tzBaseUnitLicence
.
getExpiryDate
(),
DateUtils
.
DATE_PATTERN
));
}
});
}
Function
<
String
,
String
>
getValue
=
key
->
installation
.
getOrDefault
(
key
,
""
).
toString
();
// 组装模板变量
...
...
@@ -331,23 +334,10 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
String
qrCode
=
ImageUtils
.
generateQRCode
(
getValue
.
apply
(
"applyNo"
),
300
,
300
);
placeholders
.
put
(
"qrCode"
,
qrCode
);
// word转pdf
File
pdfFile
;
try
{
pdfFile
=
this
.
wordToPdf
(
"installation-notification-report.ftl"
,
placeholders
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
placeholders
.
put
(
"installLicenseNoList"
,
installLicenseNoList
);
placeholders
.
put
(
"installLicenseExpirationDateList"
,
installLicenseExpirationDateList
);
// 上传pdf至文件服务器
String
url
=
this
.
uploadFile
(
pdfFile
);
// 删除临时文件
try
{
Files
.
deleteIfExists
(
pdfFile
.
toPath
());
}
catch
(
IOException
e
)
{
log
.
error
(
"删除临时文件失败:{}"
,
e
);
}
String
url
=
WordTemplateUtils
.
templateToPdf
(
"installation-notification-report.ftl"
,
placeholders
);
// 更新到数据库
JgReformNotice
.
setNoticeReportUrl
(
url
);
...
...
@@ -356,39 +346,6 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
return
url
;
}
/**
* word 转 pdf
*
* @param wordPath word文件路径
*/
private
File
wordToPdf
(
String
wordPath
,
Map
<
String
,
Object
>
placeholders
)
throws
Exception
{
Assert
.
hasText
(
wordPath
,
"word文件路径不能为空"
);
String
tempFileName
=
"改造告知单_"
+
System
.
currentTimeMillis
()
+
"_temp.pdf"
;
WordTemplateUtils
instance
=
WordTemplateUtils
.
getInstance
();
return
instance
.
fillAndConvertDocFile
(
wordPath
,
tempFileName
,
placeholders
,
SaveFormat
.
PDF
);
}
/**
* 上传文件至文件服务器
*
* @param file 文件
*/
private
String
uploadFile
(
File
file
)
{
Assert
.
notNull
(
file
,
"文件不能为空"
);
MultipartFile
multipartFile
=
new
ByteArrayMultipartFile
(
"file"
,
"file.pdf"
,
"application/pdf"
,
file2byte
(
file
));
FeignClientResult
<
Map
<
String
,
String
>>
result
=
Systemctl
.
fileStorageClient
.
updateCommonFile
(
multipartFile
);
String
urlString
=
""
;
if
(
result
!=
null
)
{
for
(
String
s
:
result
.
getResult
().
keySet
())
{
urlString
=
s
;
}
}
return
urlString
;
}
@Override
@SuppressWarnings
({
"Duplicates"
,
"rawtypes"
})
...
...
amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-biz/src/main/java/com/yeejoin/amos/boot/module/jg/biz/service/impl/JgTransferNoticeServiceImpl.java
View file @
a51480c7
...
...
@@ -22,12 +22,10 @@ import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient;
import
com.yeejoin.amos.boot.module.jg.biz.utils.ImageUtils
;
import
com.yeejoin.amos.boot.module.jg.biz.utils.WordTemplateUtils
;
import
com.yeejoin.amos.boot.module.ymt.api.entity.RegistrationInfo
;
import
com.yeejoin.amos.boot.module.ymt.api.entity.TzBaseUnitLicence
;
import
com.yeejoin.amos.boot.module.ymt.api.enums.ApplicationFormTypeEnum
;
import
com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum
;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryMapper
;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.OtherInfoMapper
;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.RegistrationInfoMapper
;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.SupervisoryCodeInfoMapper
;
import
com.yeejoin.amos.boot.module.ymt.api.mapper.*
;
import
com.yeejoin.amos.component.feign.model.FeignClientResult
;
import
com.yeejoin.amos.feign.systemctl.Systemctl
;
import
com.yeejoin.amos.feign.workflow.Workflow
;
...
...
@@ -88,19 +86,8 @@ public class JgTransferNoticeServiceImpl extends BaseService<JgTransferNoticeDto
@Autowired
RedisUtils
redisUtils
;
public
static
byte
[]
file2byte
(
File
file
)
{
try
{
FileInputStream
in
=
new
FileInputStream
(
file
);
//当文件没有结束时,每次读取一个字节显示
byte
[]
data
=
new
byte
[
in
.
available
()];
in
.
read
(
data
);
in
.
close
();
return
data
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
null
;
}
}
@Autowired
private
TzBaseUnitLicenceMapper
baseUnitLicenceMapper
;
/**
* 根据sequenceNbr查询
...
...
@@ -188,6 +175,23 @@ public class JgTransferNoticeServiceImpl extends BaseService<JgTransferNoticeDto
}
Map
<
String
,
Object
>
maintain
=
informationList
.
get
(
0
);
String
useCode
=
String
.
valueOf
(
maintain
.
get
(
"useCode"
));
LambdaQueryWrapper
<
TzBaseUnitLicence
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
eq
(
TzBaseUnitLicence:
:
getUnitCode
,
useCode
);
List
<
TzBaseUnitLicence
>
list
=
baseUnitLicenceMapper
.
selectList
(
wrapper
);
ArrayList
<
String
>
installLicenseNoList
=
new
ArrayList
<>();
ArrayList
<
String
>
installLicenseExpirationDateList
=
new
ArrayList
<>();
if
(!
CollectionUtils
.
isEmpty
(
list
))
{
list
.
forEach
(
tzBaseUnitLicence
->
{
// 因模板许可证编号配置最多支持三个,再多样式混乱,目前返回三个
if
(
installLicenseNoList
.
size
()
<
3
)
{
installLicenseNoList
.
add
(
tzBaseUnitLicence
.
getCertNo
());
installLicenseExpirationDateList
.
add
(
DateUtils
.
convertDateToString
(
tzBaseUnitLicence
.
getExpiryDate
(),
DateUtils
.
DATE_PATTERN
));
}
});
}
Function
<
String
,
String
>
getValue
=
key
->
maintain
.
getOrDefault
(
key
,
""
).
toString
();
// 组装模板变量
...
...
@@ -217,23 +221,10 @@ public class JgTransferNoticeServiceImpl extends BaseService<JgTransferNoticeDto
String
qrCode
=
ImageUtils
.
generateQRCode
(
getValue
.
apply
(
"applyNo"
),
300
,
300
);
placeholders
.
put
(
"qrCode"
,
qrCode
);
// word转pdf
File
pdfFile
;
try
{
pdfFile
=
this
.
wordToPdf
(
"installation-notification-report.ftl"
,
placeholders
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
placeholders
.
put
(
"installLicenseNoList"
,
installLicenseNoList
);
placeholders
.
put
(
"installLicenseExpirationDateList"
,
installLicenseExpirationDateList
);
// 上传pdf至文件服务器
String
url
=
this
.
uploadFile
(
pdfFile
);
// 删除临时文件
try
{
Files
.
deleteIfExists
(
pdfFile
.
toPath
());
}
catch
(
IOException
e
)
{
log
.
error
(
"删除临时文件失败:{}"
,
e
);
}
String
url
=
WordTemplateUtils
.
templateToPdf
(
"installation-notification-report.ftl"
,
placeholders
);
// 更新到数据库
jgTransferNotice
.
setNoticeReportUrl
(
url
);
...
...
@@ -242,39 +233,6 @@ public class JgTransferNoticeServiceImpl extends BaseService<JgTransferNoticeDto
return
url
;
}
/**
* word 转 pdf
*
* @param wordPath word文件路径
*/
private
File
wordToPdf
(
String
wordPath
,
Map
<
String
,
Object
>
placeholders
)
throws
Exception
{
Assert
.
hasText
(
wordPath
,
"word文件路径不能为空"
);
String
tempFileName
=
"移装告知单_"
+
System
.
currentTimeMillis
()
+
"_temp.pdf"
;
WordTemplateUtils
instance
=
WordTemplateUtils
.
getInstance
();
return
instance
.
fillAndConvertDocFile
(
wordPath
,
tempFileName
,
placeholders
,
SaveFormat
.
PDF
);
}
/**
* 上传文件至文件服务器
*
* @param file 文件
*/
private
String
uploadFile
(
File
file
)
{
Assert
.
notNull
(
file
,
"文件不能为空"
);
MultipartFile
multipartFile
=
new
ByteArrayMultipartFile
(
"file"
,
"file.pdf"
,
"application/pdf"
,
file2byte
(
file
));
FeignClientResult
<
Map
<
String
,
String
>>
result
=
Systemctl
.
fileStorageClient
.
updateCommonFile
(
multipartFile
);
String
urlString
=
""
;
if
(
result
!=
null
)
{
for
(
String
s
:
result
.
getResult
().
keySet
())
{
urlString
=
s
;
}
}
return
urlString
;
}
/**
* 更新移装告知
...
...
amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-biz/src/main/java/com/yeejoin/amos/boot/module/jg/biz/utils/WordTemplateUtils.java
View file @
a51480c7
...
...
@@ -2,11 +2,17 @@ package com.yeejoin.amos.boot.module.jg.biz.utils;
import
com.aspose.words.Document
;
import
com.aspose.words.License
;
import
com.aspose.words.SaveFormat
;
import
com.yeejoin.amos.boot.module.jg.api.dto.ByteArrayMultipartFile
;
import
com.yeejoin.amos.component.feign.model.FeignClientResult
;
import
com.yeejoin.amos.feign.systemctl.Systemctl
;
import
freemarker.template.Configuration
;
import
freemarker.template.Template
;
import
freemarker.template.TemplateException
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.util.Assert
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.*
;
import
java.nio.charset.StandardCharsets
;
...
...
@@ -124,4 +130,74 @@ public class WordTemplateUtils {
}
return
result
;
}
public
static
String
templateToPdf
(
String
wordPath
,
Map
<
String
,
Object
>
placeholders
)
{
// word转pdf
File
pdfFile
;
try
{
pdfFile
=
wordToPdf
(
wordPath
,
placeholders
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
// 上传pdf至文件服务器
String
url
=
uploadFile
(
pdfFile
);
// 删除临时文件
try
{
Files
.
deleteIfExists
(
pdfFile
.
toPath
());
}
catch
(
IOException
e
)
{
log
.
error
(
"删除临时文件失败:{}"
,
e
);
}
return
url
;
}
public
static
byte
[]
file2byte
(
File
file
)
{
try
{
FileInputStream
in
=
new
FileInputStream
(
file
);
//当文件没有结束时,每次读取一个字节显示
byte
[]
data
=
new
byte
[
in
.
available
()];
in
.
read
(
data
);
in
.
close
();
return
data
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
null
;
}
}
/**
* 上传文件至文件服务器
*
* @param file 文件
*/
private
static
String
uploadFile
(
File
file
)
{
Assert
.
notNull
(
file
,
"文件不能为空"
);
MultipartFile
multipartFile
=
new
ByteArrayMultipartFile
(
"file"
,
"file.pdf"
,
"application/pdf"
,
file2byte
(
file
));
FeignClientResult
<
Map
<
String
,
String
>>
result
=
Systemctl
.
fileStorageClient
.
updateCommonFile
(
multipartFile
);
String
urlString
=
""
;
if
(
result
!=
null
)
{
for
(
String
s
:
result
.
getResult
().
keySet
())
{
urlString
=
s
;
}
}
return
urlString
;
}
/**
* word 转 pdf
*
* @param wordPath word文件路径
*/
private
static
File
wordToPdf
(
String
wordPath
,
Map
<
String
,
Object
>
placeholders
)
throws
Exception
{
Assert
.
hasText
(
wordPath
,
"word文件路径不能为空"
);
String
tempFileName
=
"安装告知单_"
+
System
.
currentTimeMillis
()
+
"_temp.pdf"
;
WordTemplateUtils
instance
=
WordTemplateUtils
.
getInstance
();
return
instance
.
fillAndConvertDocFile
(
wordPath
,
tempFileName
,
placeholders
,
SaveFormat
.
PDF
);
}
}
amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-biz/src/main/resources/templates/installation-notification-report.docx
View file @
a51480c7
No preview for this file type
amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-biz/src/main/resources/templates/installation-notification-report.ftl
View file @
a51480c7
This source diff could not be displayed because it is too large. You can
view the blob
instead.
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