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
5e08ef36
Commit
5e08ef36
authored
Dec 27, 2023
by
xixinzhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(jg): 安装告知打印告知单改为下载
parent
b9c554b1
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
63 additions
and
29 deletions
+63
-29
IJgInstallationNoticeService.java
...t/module/jg/api/service/IJgInstallationNoticeService.java
+2
-1
JgInstallationNoticeMapper.xml
.../src/main/resources/mapper/JgInstallationNoticeMapper.xml
+2
-1
JgInstallationNoticeController.java
...ule/jg/biz/controller/JgInstallationNoticeController.java
+3
-2
JgInstallationNoticeServiceImpl.java
.../jg/biz/service/impl/JgInstallationNoticeServiceImpl.java
+16
-13
JgMaintainNoticeServiceImpl.java
...dule/jg/biz/service/impl/JgMaintainNoticeServiceImpl.java
+2
-1
JgReformNoticeServiceImpl.java
...module/jg/biz/service/impl/JgReformNoticeServiceImpl.java
+2
-1
JgTransferNoticeServiceImpl.java
...dule/jg/biz/service/impl/JgTransferNoticeServiceImpl.java
+3
-3
WordTemplateUtils.java
...join/amos/boot/module/jg/biz/utils/WordTemplateUtils.java
+33
-7
No files found.
amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-api/src/main/java/com/yeejoin/amos/boot/module/jg/api/service/IJgInstallationNoticeService.java
View file @
5e08ef36
...
...
@@ -7,6 +7,7 @@ import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import
com.yeejoin.amos.boot.module.jg.api.dto.JgInstallationNoticeDto
;
import
com.yeejoin.amos.boot.module.jg.api.entity.JgInstallationNotice
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.Map
;
/**
...
...
@@ -65,5 +66,5 @@ public interface IJgInstallationNoticeService extends IService<JgInstallationNot
* @param sequenceNbr 主键
* @return pdf文件路径
*/
String
generateInstallationNoticeReport
(
Long
sequenceNbr
);
void
generateInstallationNoticeReport
(
Long
sequenceNbr
,
HttpServletResponse
response
);
}
amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-api/src/main/resources/mapper/JgInstallationNoticeMapper.xml
View file @
5e08ef36
...
...
@@ -107,7 +107,8 @@
ei.legal_person AS safetyManager,
ei.legal_phone AS safetyManagerPhone,
ei.address AS address,
ei.use_code AS useCode
ei.use_code AS useCode,
isn.install_unit_credit_code AS installUnitCreditCode
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-biz/src/main/java/com/yeejoin/amos/boot/module/jg/biz/controller/JgInstallationNoticeController.java
View file @
5e08ef36
...
...
@@ -18,6 +18,7 @@ import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import
org.typroject.tyboot.core.restful.utils.ResponseHelper
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -141,7 +142,7 @@ public class JgInstallationNoticeController extends BaseController {
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"安装告知列表全部数据查询"
,
notes
=
"安装告知列表全部数据查询"
)
@GetMapping
(
value
=
"/generate-report"
)
public
ResponseModel
<
String
>
generateReport
(
@RequestParam
(
"sequenceNbr"
)
Long
sequenceNbr
)
{
return
ResponseHelper
.
buildResponse
(
iJgInstallationNoticeService
.
generateInstallationNoticeReport
(
sequenceNbr
)
);
public
void
generateReport
(
HttpServletResponse
response
,
@RequestParam
(
"sequenceNbr"
)
Long
sequenceNbr
)
{
iJgInstallationNoticeService
.
generateInstallationNoticeReport
(
sequenceNbr
,
response
);
}
}
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 @
5e08ef36
...
...
@@ -65,6 +65,7 @@ import java.nio.file.Files;
import
org.typroject.tyboot.core.restful.exception.instance.BadRequest
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.*
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
...
...
@@ -310,7 +311,7 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
* @return pdf文件路径
*/
@Override
public
String
generateInstallationNoticeReport
(
Long
sequenceNbr
)
{
public
void
generateInstallationNoticeReport
(
Long
sequenceNbr
,
HttpServletResponse
response
)
{
if
(
Objects
.
isNull
(
sequenceNbr
))
{
throw
new
IllegalArgumentException
(
"参数不能为空"
);
}
...
...
@@ -322,7 +323,7 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
}
Map
<
String
,
Object
>
installation
=
informationList
.
get
(
0
);
String
useCode
=
String
.
valueOf
(
installation
.
get
(
"
use
Code"
));
String
useCode
=
String
.
valueOf
(
installation
.
get
(
"
installUnitCredit
Code"
));
LambdaQueryWrapper
<
TzBaseUnitLicence
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
eq
(
TzBaseUnitLicence:
:
getUnitCode
,
useCode
);
List
<
TzBaseUnitLicence
>
list
=
baseUnitLicenceMapper
.
selectList
(
wrapper
);
...
...
@@ -372,13 +373,15 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
String
qrCode
=
ImageUtils
.
generateQRCode
(
getValue
.
apply
(
"applyNo"
),
300
,
300
);
placeholders
.
put
(
"qrCode"
,
qrCode
);
String
url
=
WordTemplateUtils
.
templateToPdf
(
"installation-notification-report.ftl"
,
placeholders
);
//
String url = WordTemplateUtils.templateToPdf("installation-notification-report.ftl", placeholders);
// 更新到数据库
jgInstallationNotice
.
setNoticeReportUrl
(
url
);
this
.
updateById
(
jgInstallationNotice
);
return
url
;
// jgInstallationNotice.setNoticeReportUrl(url);
// this.updateById(jgInstallationNotice);
//
// return url;
String
tempFileName
=
"安装告知单_"
+
System
.
currentTimeMillis
()
+
"_temp"
;
WordTemplateUtils
.
templateToPdfDownload
(
tempFileName
,
"installation-notification-report.ftl"
,
placeholders
,
response
);
}
@Override
...
...
@@ -776,12 +779,12 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
useInfoService
.
saveOrUpdateData
(
useInfo
);
}
TransactionSynchronizationManager
.
registerSynchronization
(
new
TransactionSynchronization
()
{
@Override
public
void
afterCommit
()
{
generateInstallationNoticeReport
(
jgInstallationNotice
.
getSequenceNbr
());
}
});
//
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
//
@Override
//
public void afterCommit() {
//
generateInstallationNoticeReport(jgInstallationNotice.getSequenceNbr());
//
}
//
});
}
else
{
jgInstallationNotice
.
setNextExecuteIds
(
String
.
join
(
","
,
roleList
));
if
(!
ObjectUtils
.
isEmpty
(
jgInstallationNotice
.
getInstanceStatus
()))
{
...
...
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 @
5e08ef36
...
...
@@ -318,7 +318,8 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto
placeholders
.
put
(
"qrCode"
,
qrCode
);
placeholders
.
put
(
"installLicenseNoList"
,
installLicenseNoList
);
//许可证编号
placeholders
.
put
(
"installLicenseExpirationDateList"
,
installLicenseExpirationDateList
);
//许可证有效期
String
url
=
WordTemplateUtils
.
templateToPdf
(
"installation-notification-report.ftl"
,
placeholders
);
String
tempFileName
=
"安装告知单_"
+
System
.
currentTimeMillis
()
+
"_temp"
;
String
url
=
WordTemplateUtils
.
templateToPdf
(
tempFileName
,
"installation-notification-report.ftl"
,
placeholders
);
// 更新到数据库
JgMaintainNotice
.
setNoticeReportUrl
(
url
);
this
.
updateById
(
JgMaintainNotice
);
...
...
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 @
5e08ef36
...
...
@@ -344,7 +344,8 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
placeholders
.
put
(
"installLicenseNoList"
,
installLicenseNoList
);
placeholders
.
put
(
"installLicenseExpirationDateList"
,
installLicenseExpirationDateList
);
log
.
info
(
"改造告知单 => {}"
,
JSON
.
toJSONString
(
placeholders
));
String
url
=
WordTemplateUtils
.
templateToPdf
(
"installation-notification-report.ftl"
,
placeholders
);
String
tempFileName
=
"安装告知单_"
+
System
.
currentTimeMillis
()
+
"_temp"
;
String
url
=
WordTemplateUtils
.
templateToPdf
(
tempFileName
,
"installation-notification-report.ftl"
,
placeholders
);
// 更新到数据库
JgReformNotice
.
setNoticeReportUrl
(
url
);
...
...
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 @
5e08ef36
...
...
@@ -175,7 +175,7 @@ public class JgTransferNoticeServiceImpl extends BaseService<JgTransferNoticeDto
}
Map
<
String
,
Object
>
maintain
=
informationList
.
get
(
0
);
String
useCode
=
String
.
valueOf
(
maintain
.
get
(
"
use
Code"
));
String
useCode
=
String
.
valueOf
(
maintain
.
get
(
"
installUnitCredit
Code"
));
LambdaQueryWrapper
<
TzBaseUnitLicence
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
eq
(
TzBaseUnitLicence:
:
getUnitCode
,
useCode
);
List
<
TzBaseUnitLicence
>
list
=
baseUnitLicenceMapper
.
selectList
(
wrapper
);
...
...
@@ -223,8 +223,8 @@ public class JgTransferNoticeServiceImpl extends BaseService<JgTransferNoticeDto
placeholders
.
put
(
"installLicenseNoList"
,
installLicenseNoList
);
placeholders
.
put
(
"installLicenseExpirationDateList"
,
installLicenseExpirationDateList
);
String
url
=
WordTemplateUtils
.
templateToPdf
(
"installation-notification-report.ftl"
,
placeholders
);
String
tempFileName
=
"安装告知单_"
+
System
.
currentTimeMillis
()
+
"_temp"
;
String
url
=
WordTemplateUtils
.
templateToPdf
(
tempFileName
,
"installation-notification-report.ftl"
,
placeholders
);
// 更新到数据库
jgTransferNotice
.
setNoticeReportUrl
(
url
);
...
...
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 @
5e08ef36
...
...
@@ -13,7 +13,9 @@ import lombok.extern.slf4j.Slf4j;
import
org.springframework.util.Assert
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.typroject.tyboot.core.restful.exception.instance.BadRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.*
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.file.Files
;
...
...
@@ -131,11 +133,11 @@ public class WordTemplateUtils {
return
result
;
}
public
static
String
templateToPdf
(
String
wordPath
,
Map
<
String
,
Object
>
placeholders
)
{
public
static
String
templateToPdf
(
String
pdfName
,
String
wordPath
,
Map
<
String
,
Object
>
placeholders
)
{
// word转pdf
File
pdfFile
;
try
{
pdfFile
=
wordToPdf
(
wordPath
,
placeholders
);
pdfFile
=
wordToPdf
(
pdfName
,
wordPath
,
placeholders
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
...
...
@@ -152,7 +154,33 @@ public class WordTemplateUtils {
return
url
;
}
public
static
byte
[]
file2byte
(
File
file
)
{
public
static
void
templateToPdfDownload
(
String
pdfName
,
String
wordPath
,
Map
<
String
,
Object
>
placeholders
,
HttpServletResponse
response
)
{
// word转pdf
File
pdfFile
;
try
{
pdfFile
=
wordToPdf
(
pdfName
,
wordPath
,
placeholders
);
}
catch
(
Exception
e
)
{
log
.
error
(
"模板转pdf失败:"
,
e
);
throw
new
BadRequest
(
"模板转pdf失败"
);
}
try
{
byte
[]
bytes
=
file2byte
(
pdfFile
);
String
docTitle
=
pdfFile
.
getName
();
FileExporter
.
exportFile
(
FileExporter
.
FileType
.
valueOf
(
"pdf"
),
docTitle
,
bytes
,
response
);
}
catch
(
Exception
e
)
{
log
.
error
(
"文档导出失败:"
,
e
);
}
finally
{
try
{
Files
.
deleteIfExists
(
pdfFile
.
toPath
());
}
catch
(
Exception
e
)
{
log
.
error
(
"文件找不到,删除失败:"
,
e
);
}
}
}
private
static
byte
[]
file2byte
(
File
file
)
{
try
{
FileInputStream
in
=
new
FileInputStream
(
file
);
//当文件没有结束时,每次读取一个字节显示
...
...
@@ -191,13 +219,11 @@ public class WordTemplateUtils {
*
* @param wordPath word文件路径
*/
private
static
File
wordToPdf
(
String
wordPath
,
Map
<
String
,
Object
>
placeholders
)
throws
Exception
{
private
static
File
wordToPdf
(
String
pdfName
,
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
,
tempFile
Name
,
placeholders
,
SaveFormat
.
PDF
);
return
instance
.
fillAndConvertDocFile
(
wordPath
,
pdf
Name
,
placeholders
,
SaveFormat
.
PDF
);
}
}
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