Commit 405ee238c74dc3cc2d76a4367793defaad3f3562
1 parent
63e8153e
任务明细打印
Showing
3 changed files
with
59 additions
and
6 deletions
src/main/java/com/huaheng/pc/task/taskDetail/controller/TaskDetailController.java
... | ... | @@ -25,6 +25,7 @@ import org.springframework.web.bind.annotation.*; |
25 | 25 | |
26 | 26 | import javax.annotation.Resource; |
27 | 27 | import javax.sql.rowset.serial.SerialException; |
28 | +import java.math.BigDecimal; | |
28 | 29 | import java.util.ArrayList; |
29 | 30 | import java.util.List; |
30 | 31 | |
... | ... | @@ -41,6 +42,8 @@ public class TaskDetailController extends BaseController { |
41 | 42 | |
42 | 43 | @Resource |
43 | 44 | private TaskDetailService taskDetailService; |
45 | + @Resource | |
46 | + private TaskHeaderService taskHeaderService; | |
44 | 47 | |
45 | 48 | @RequiresPermissions("task:taskHeader:view") |
46 | 49 | @GetMapping("/{taskId}") |
... | ... | @@ -89,12 +92,24 @@ public class TaskDetailController extends BaseController { |
89 | 92 | } |
90 | 93 | } |
91 | 94 | |
92 | - @RequiresPermissions("shipment:bill:report") | |
95 | + //@RequiresPermissions("task:taskHeader:report") | |
93 | 96 | @Log(title = "任务", operating = "打印任务明细报表", action = BusinessType.OTHER) |
94 | 97 | @GetMapping("/report/{ids}") |
95 | 98 | public String report(@PathVariable("ids") Integer[] ids, ModelMap mmap) { |
96 | 99 | List<TaskDetail> taskDetailList = taskDetailService.findByTaskId(ids); |
97 | 100 | mmap.put("task", taskDetailList); |
101 | + TaskHeader taskHeader = taskHeaderService.getById(taskDetailList.get(0).getTaskId()); | |
102 | + mmap.put("taskHeader",taskHeader); | |
103 | + //总行数,总物料数 | |
104 | + int totalLines = 0; | |
105 | + totalLines = taskDetailList.size(); | |
106 | + //总物料数 | |
107 | + BigDecimal t = taskDetailList.stream() | |
108 | + .map(TaskDetail::getQty) | |
109 | + .reduce(BigDecimal.ZERO,BigDecimal::add); | |
110 | + int totalQty = t.intValue(); | |
111 | + mmap.put("totalLines",totalLines); | |
112 | + mmap.put("totalQty",totalQty); | |
98 | 113 | return prefix + "/report"; |
99 | 114 | } |
100 | 115 | } |
... | ... |
src/main/java/com/huaheng/pc/task/taskDetail/service/TaskDetailServiceImpl.java
src/main/resources/templates/task/taskDetail/report.html
... | ... | @@ -6,17 +6,20 @@ |
6 | 6 | <div class="container" style="color: #333;"> |
7 | 7 | <div class="row"> |
8 | 8 | <table id="reportTable" width="100%" border="1" cellspacing="0" cellpadding="0" class="dy-report"> |
9 | + | |
9 | 10 | <thead style="display:table-header-group;"> |
10 | 11 | <tr> |
11 | 12 | <td colspan="7"> |
12 | - <h2 style="width:20%;text-align:center;float:left;padding-top:10px;">任务</h2> | |
13 | + <span style="padding-top:40px;width: 40%; float:left;" th:text="${#dates.format(taskHeader.created,'yyyy-MM-dd HH:mm:ss')}"></span> | |
14 | + <h2 style="width:20%;text-align:center;float:left;padding-top:10px;">拣货明细</h2> | |
15 | + <span style="float:right; text-align:right">任务ID:<span th:text="${taskHeader['id']}"></span></span> | |
13 | 16 | </td> |
14 | 17 | </tr> |
15 | 18 | <tr style="padding:15px 0 5px 0;border-bottom:1px solid #606060"> |
16 | 19 | <td colspan="7"> |
17 | 20 | <div style="width:50%; float:right; text-align:right"> |
18 | - <span>明细条数:<span>1</span></span> | |
19 | - <span style="padding-left:20px;">明细总数:<span>1</span></span> | |
21 | + <span>总条数:<span th:text="${totalLines}"></span></span> | |
22 | + <span style="padding-left:20px;">总物料数:<span th:text="${totalQty}"></span></span> | |
20 | 23 | <span class="noprint" style="padding-left:20px;"><button type="button" onClick="a()"><i class="fa fa-print"></i> 打印</button></span> |
21 | 24 | </div> |
22 | 25 | </td> |
... | ... | @@ -40,11 +43,45 @@ |
40 | 43 | <td th:text="${row.materialCode}"></td> |
41 | 44 | <td th:text="${row.materialName}"></td> |
42 | 45 | <td th:text="${row.qty}"></td> |
43 | - <td th:text="${row.id}"></td> | |
46 | + <td><img></img></td> | |
44 | 47 | </tr> |
45 | 48 | </tbody> |
46 | 49 | </table> |
47 | 50 | </div> |
48 | 51 | </div> |
49 | 52 | <div th:include="include :: footer"></div> |
53 | +<script charset="utf-8" type="text/javascript" th:src="@{/js/barcode/JsBarcode.all.js} "></script> | |
54 | +<script charset="utf-8" type="text/javascript" th:src="@{/js/jquery-1.4.4.min.js}"></script> | |
55 | +<script charset="utf-8" type="text/javascript" th:src="@{/js/jquery.jqprint-0.3.js}"></script> | |
56 | +<script th:inline="javascript"> | |
57 | + | |
58 | + var barcodeStyle = { | |
59 | + format: "CODE128",//选择要使用的条形码类型 | |
60 | + width:1,//设置条之间的宽度 | |
61 | + height:40,//高度 | |
62 | + displayValue:true,//是否在条形码下方显示文字 | |
63 | + // text:"456",//覆盖显示的文本 | |
64 | + // fontOptions:"bold italic",//使文字加粗体或变斜体 | |
65 | + font:"monospace",//设置文本的字体fantasy | |
66 | + textAlign:"center",//设置文本的水平对齐方式 | |
67 | + textPosition:"bottom",//设置文本的垂直位置 | |
68 | + textMargin:1,//设置条形码和文本之间的间距 | |
69 | + fontSize:12,//设置文本的大小 | |
70 | + background:"#ffffff",//设置条形码的背景 | |
71 | + lineColor:"#000000",//设置条和文本的颜色。 | |
72 | + margin:1//设置条形码周围的空白边距 | |
73 | + }; | |
74 | + | |
75 | + //$("#receiptCode").JsBarcode($("#receiptCode").attr("data"), barcodeStyle); | |
76 | + | |
77 | + $('#reportTable tbody tr').each(function(i) { | |
78 | + var barcodeText = $(this).children()[5].innerText; | |
79 | + JsBarcode($(this).children()[8].querySelector("img"), barcodeText, barcodeStyle); | |
80 | + }); | |
81 | + | |
82 | + function a(){ | |
83 | + $("#ddd").jqprint(); | |
84 | + } | |
85 | +</script> | |
86 | +</body> | |
50 | 87 | </html> |
51 | 88 | \ No newline at end of file |
... | ... |