feat: 导出pdf功能调整

This commit is contained in:
曹鹏飞 2025-03-24 11:22:13 +08:00
parent 84b9043cb4
commit 658353d636
3 changed files with 55 additions and 54 deletions

View File

@ -509,7 +509,7 @@ public class TicketController extends ControllerBase {
.setUrgency(ticket.getUrgency())
.setUpdateTime(DateTimeUtil.format(ticket.getUpdateTime()))
.setHandleUserName(handle)
.setSolution(ticket.getReason())
.setReason(ticket.getReason())
.setImages(images)
.setFiles(files);
Map<String, Object> variables = new HashMap<>();
@ -609,9 +609,11 @@ public class TicketController extends ControllerBase {
.setUrgency(ticket.getUrgency())
.setUpdateTime(DateTimeUtil.format(ticket.getUpdateTime()))
.setHandleUserName(handle)
.setSolution(ticket.getReason())
.setReason(ticket.getReason())
.setDeviceAddress(ticket.getDeviceAddress())
.setImages(images)
.setFiles(files);
.setFiles(files)
.setMeasures(ticketSolutionService.getSolutionMeasures(ticket.getId()));
Map<String, Object> variables = new HashMap<>();
variables.put("ticket", vo);
// 渲染HTML
@ -623,7 +625,7 @@ public class TicketController extends ControllerBase {
Context context = new Context();
context.setVariables(variables);
String html = templateEngine.process("ticketpdf", context);
String html = templateEngine.process("ticketpdf1", context);
response.setContentType(MediaType.APPLICATION_PDF_VALUE);
String encode = URLEncoder.encode(ticket.getTitle() + ".pdf", StandardCharsets.UTF_8);

View File

@ -51,67 +51,61 @@
<td colspan="2">反馈日期</td>
<td colspan="2" th:text="${ticket.createTime}"></td>
</tr>
<tr>
<td>问题详细描述</td>
<td colspan="3" th:text="${ticket.description}"></td>
</tr>
<tr>
<td>工单编号</td>
<td th:text="${ticket.no}"></td>
</tr>
<tr>
<td>机型</td>
<td th:text="${ticket.modelNo}"></td>
<td>使用时长</td>
<td th:text="${ticket.useTime}"></td>
</tr>
<tr>
<td>问题部位</td>
<td colspan="3" th:text="${ticket.component}"></td>
</tr>
<tr>
<td>紧急程度</td>
<td th:text="${ticket.urgencyDesc}"></td>
<td>解决状态</td>
<td th:text="${ticket.stateDesc}"></td>
<td>提交人</td>
<td colspan="2" th:text="${ticket.createUserName}"></td>
<td>设备地点</td>
<td colspan="4" th:text="${ticket.deviceAddress}"></td>
<td colspan="2">设备运行时间</td>
<td colspan="2" th:text="${ticket.useTime}"></td>
</tr>
<tr>
<td>处理人</td>
<td th:text="${ticket.handleUserName}"></td>
<td>解决时间</td>
<td th:text="${ticket.updateTime}"></td>
<td colspan="11" th:text="${ticket.handleUserName}"></td>
</tr>
<tr>
<td>解决方案</td>
<td colspan="3" th:text="${ticket.solution}"></td>
<td>问题描述</td>
<td colspan="11" th:text="${ticket.description}"></td>
</tr>
<tr>
<td>提交人</td>
<td th:text="${ticket.createUserName}"></td>
</tr>
<tr>
<td colspan="4">文件</td>
</tr>
<tr>
<td colspan="4">
<div>
<a th:each="file:${ticket.files}" th:href="${file.url}" th:text="${file.name}"></a>
</div>
</td>
</tr>
<tr>
<td colspan="4">图片</td>
</tr>
<tr>
<td colspan="4">
<td>图片</td>
<td colspan="11">
<div th:each="file:${ticket.images}">
<img class="cimg" alt="" th:src="${file.url}"/>
</div>
</td>
</tr>
<tr>
<td colspan="12">原因分析</td>
</tr>
<tr>
<td colspan="12" th:text="${ticket.reason}"></td>
</tr>
<tr>
<td colspan="12">解决方案</td>
</tr>
<div th:replace="::measureRow(${ticket.measures})"></div>
</table>
<div th:fragment="measureItemRow(items)">
<tr th:each="item,iterStat: ${items}">
<td th:text="${iterStat.index+1}"></td>
<td colspan="5" th:text="${item.name}"></td>
<td th:text="${item.superintendent}"></td>
<td th:text="${item.scheduleDate}"></td>
<td th:text="${item.confirmedDate}"></td>
<td colspan="3" th:text="${item.remark}"></td>
</tr>
</div>
<div th:fragment="measureRow(measures)">
<tr th:each="measure : ${measures}">
<td>NO.</td>
<td colspan="5" th:text="${measure.name}"></td>
<td>负责人</td>
<td>计划日期</td>
<td>确认日期</td>
<td colspan="3">备注</td>
</tr>
<div th:if="${measure != null and not #lists.isEmpty(measure.items)}" th:replace="::measureItemRow(${measure.items})"></div>
</div>
</body>
</html>

View File

@ -55,8 +55,8 @@ public class TicketPdfVO {
private String updateTime;
//处理人
private String handleUserName;
//解决方案
private String solution;
//原因分析
private String reason;
//图片
private List<FileInfo> images;
//文件
@ -73,4 +73,9 @@ public class TicketPdfVO {
public String getStateDesc() {
return TicketState.findByValue(state).getDescription();
}
//设备地址
private String deviceAddress;
private List<SolutionMeasuresVO> measures;
}