提交 ad198e35 authored 作者: 133's avatar 133

[]

上级 0f43dcbc
...@@ -156,16 +156,18 @@ public class JavaToPdfHtmlFreeMarker { ...@@ -156,16 +156,18 @@ public class JavaToPdfHtmlFreeMarker {
List<DocumentDevice> list=documents.getDocumentDevices(); List<DocumentDevice> list=documents.getDocumentDevices();
List<List<DocumentDevice>> listList=toList(list); List<List<DocumentDevice>> listList=toList(list);
int count=listList.size();
for (int i=1; i<=3; i++){ for (int i=1; i<=3; i++){
Integer page=1;
for (List<DocumentDevice> list1:listList) { for (List<DocumentDevice> list1:listList) {
String htmlname=htmlPath+ UUID.randomUUID().toString()+".html"; String htmlname=htmlPath+ UUID.randomUUID().toString()+".html";
// 合并数据模型与模板 // 合并数据模型与模板
FileWriter fileWriter = new FileWriter(new File(htmlname)); FileWriter fileWriter = new FileWriter(new File(htmlname));
template.process(toMap(documents,list1,MAP.get(i)),fileWriter); template.process(toMap(documents,list1,MAP.get(i),page,count),fileWriter);
out.flush(); out.flush();
strings[index]=htmlname; strings[index]=htmlname;
index++; index++;
page++;
} }
} }
return strings; return strings;
...@@ -181,7 +183,7 @@ public class JavaToPdfHtmlFreeMarker { ...@@ -181,7 +183,7 @@ public class JavaToPdfHtmlFreeMarker {
return null; return null;
} }
private static Map<String,Object> toMap(Documents documents,List<DocumentDevice> list,String test){ private static Map<String,Object> toMap(Documents documents,List<DocumentDevice> list,String test,Integer page,Integer count){
Map<String,Object> data = new HashMap(); Map<String,Object> data = new HashMap();
data.put("ul",test); data.put("ul",test);
data.put("number",documents.getNumber()); data.put("number",documents.getNumber());
...@@ -189,6 +191,8 @@ public class JavaToPdfHtmlFreeMarker { ...@@ -189,6 +191,8 @@ public class JavaToPdfHtmlFreeMarker {
data.put("receiveUnit",documents.getReceiveUnit()); data.put("receiveUnit",documents.getReceiveUnit());
data.put("replyNum",documents.getReplyNum()); data.put("replyNum",documents.getReplyNum());
data.put("senderUnit",documents.getSenderUnit()); data.put("senderUnit",documents.getSenderUnit());
data.put("page",page);
data.put("count",count);
AtomicInteger i= new AtomicInteger(1); AtomicInteger i= new AtomicInteger(1);
list.forEach( list.forEach(
documentDevice -> { documentDevice -> {
...@@ -201,9 +205,11 @@ public class JavaToPdfHtmlFreeMarker { ...@@ -201,9 +205,11 @@ public class JavaToPdfHtmlFreeMarker {
} }
private static Map<String,Object> toConfirmMap(Confirm confirm, List<DocumentDevice> list){ private static Map<String,Object> toConfirmMap(Confirm confirm, List<DocumentDevice> list,Integer page,Integer count){
Map<String,Object> data = new HashMap(); Map<String,Object> data = new HashMap();
data.put("title",confirm.getTitle()); data.put("title",confirm.getTitle());
data.put("page",page);
data.put("count",count);
AtomicInteger i= new AtomicInteger(1); AtomicInteger i= new AtomicInteger(1);
list.forEach( list.forEach(
documentDevice -> { documentDevice -> {
...@@ -216,13 +222,15 @@ public class JavaToPdfHtmlFreeMarker { ...@@ -216,13 +222,15 @@ public class JavaToPdfHtmlFreeMarker {
} }
private static Map<String,Object> toDestructionMap(Destruction destruction, List<DocumentDevice> list,String test){ private static Map<String,Object> toDestructionMap(Destruction destruction, List<DocumentDevice> list,String test,Integer page,Integer count){
Map<String,Object> data = new HashMap(); Map<String,Object> data = new HashMap();
data.put("title",destruction.getTitle()); data.put("title",destruction.getTitle());
data.put("ul",test); data.put("ul",test);
data.put("unitName",destruction.getDisposeUnitName()); data.put("unitName",destruction.getDisposeUnitName());
data.put("number",destruction.getNumber()); data.put("number",destruction.getNumber());
data.put("time",destruction.getTime()); data.put("time",destruction.getTime());
data.put("page",page);
data.put("count",count);
AtomicInteger i= new AtomicInteger(1); AtomicInteger i= new AtomicInteger(1);
list.forEach( list.forEach(
documentDevice -> { documentDevice -> {
...@@ -252,7 +260,7 @@ public class JavaToPdfHtmlFreeMarker { ...@@ -252,7 +260,7 @@ public class JavaToPdfHtmlFreeMarker {
boolean falg=true; boolean falg=true;
Integer page=0; Integer page=0;
int pageNum = page + 1; int pageNum = page + 1;
int pageSize = 20; int pageSize = 19;
Integer totalNum = list.size(); Integer totalNum = list.size();
//默认从零分页,这里要考虑这种情况,下面要计算。 //默认从零分页,这里要考虑这种情况,下面要计算。
...@@ -275,7 +283,7 @@ public class JavaToPdfHtmlFreeMarker { ...@@ -275,7 +283,7 @@ public class JavaToPdfHtmlFreeMarker {
String htmlname=htmlPath+ UUID.randomUUID().toString()+".html"; String htmlname=htmlPath+ UUID.randomUUID().toString()+".html";
// 合并数据模型与模板 // 合并数据模型与模板
FileWriter fileWriter = new FileWriter(new File(htmlname)); FileWriter fileWriter = new FileWriter(new File(htmlname));
template.process(toConfirmMap(confirm,list.subList(startPoint, endPoint)),fileWriter); template.process(toConfirmMap(confirm,list.subList(startPoint, endPoint),pageNum,totalPage),fileWriter);
out.flush(); out.flush();
strings[index]=htmlname; strings[index]=htmlname;
index++; index++;
...@@ -353,15 +361,18 @@ public class JavaToPdfHtmlFreeMarker { ...@@ -353,15 +361,18 @@ public class JavaToPdfHtmlFreeMarker {
template.setEncoding("UTF-8"); template.setEncoding("UTF-8");
List<DocumentDevice> list=destruction.getConfirmDevices(); List<DocumentDevice> list=destruction.getConfirmDevices();
List<List<DocumentDevice>> listList=toList(list); List<List<DocumentDevice>> listList=toList(list);
Integer count=listList.size();
for (int i=1; i<=3; i++){ for (int i=1; i<=3; i++){
Integer page=1;
for (List<DocumentDevice> list1:listList) { for (List<DocumentDevice> list1:listList) {
String htmlname=htmlPath+ UUID.randomUUID().toString()+".html"; String htmlname=htmlPath+ UUID.randomUUID().toString()+".html";
// 合并数据模型与模板 // 合并数据模型与模板
FileWriter fileWriter = new FileWriter(new File(htmlname)); FileWriter fileWriter = new FileWriter(new File(htmlname));
template.process(toDestructionMap(destruction,list1,MAP.get(i)),fileWriter); template.process(toDestructionMap(destruction,list1,MAP.get(i),page,count),fileWriter);
out.flush(); out.flush();
strings[index]=htmlname; strings[index]=htmlname;
index++; index++;
page++;
} }
} }
return strings; return strings;
......
...@@ -13,6 +13,13 @@ ...@@ -13,6 +13,13 @@
@page { @page {
size:210mm 297mm; size:210mm 297mm;
} }
.bottomTxt {
text-align: center;
font-size: 10px;
color: #646464;
height: 10px;
line-height: 10px;
}
.returnTablePrint{ .returnTablePrint{
width: 100%; width: 100%;
height: 100%; height: 100%;
...@@ -150,7 +157,7 @@ ...@@ -150,7 +157,7 @@
} }
.returnTablePrint .line3 .left{ .returnTablePrint .line3 .left{
border-right: 1px solid #7f7f7f; border-right: 1px solid #7f7f7f;
height: 106px; height: 96px;
} }
.returnTablePrint .line3 .left>span { .returnTablePrint .line3 .left>span {
text-indent: 10px; text-indent: 10px;
...@@ -161,7 +168,7 @@ ...@@ -161,7 +168,7 @@
} }
.returnTablePrint .line3 .right{ .returnTablePrint .line3 .right{
height: 100%; height: 100%;
height: 106px; height: 96px;
} }
.returnTablePrint .line3 .left>span>span:nth-child(2),.returnTablePrint .line3 .right>span>span:nth-child(2){ .returnTablePrint .line3 .left>span>span:nth-child(2),.returnTablePrint .line3 .right>span>span:nth-child(2){
display: inline-block; display: inline-block;
...@@ -363,6 +370,7 @@ ...@@ -363,6 +370,7 @@
</div> </div>
</div> </div>
</div> </div>
<p class="bottomTxt">第${page}页/共${count}页</p >
</div> </div>
<!--<script type="text/javascript">--> <!--<script type="text/javascript">-->
<!--function altRows(id){--> <!--function altRows(id){-->
......
...@@ -17,6 +17,13 @@ ...@@ -17,6 +17,13 @@
/*border: thin solid black;*/ /*border: thin solid black;*/
/*padding: 1em;*/ /*padding: 1em;*/
} }
.bottomTxt {
text-align: center;
font-size: 10px;
color: #646464;
height: 10px;
line-height: 10px;
}
.returnTablePrint{ .returnTablePrint{
width: 100%; width: 100%;
height: 100%; height: 100%;
...@@ -145,7 +152,7 @@ ...@@ -145,7 +152,7 @@
} }
.returnTablePrint .line3{ .returnTablePrint .line3{
width: 100%; width: 100%;
height: 106px; height: 50px;
/* box-sizing: border-box; */ /* box-sizing: border-box; */
/*height:150px;*/ /*height:150px;*/
/*display: flex;*/ /*display: flex;*/
...@@ -158,7 +165,7 @@ ...@@ -158,7 +165,7 @@
box-sizing: border-box; box-sizing: border-box;
/*padding-left: 20px;*/ /*padding-left: 20px;*/
position: relative; position: relative;
line-height: 106px; line-height: 50px;
} }
.returnTablePrint .line3 .left{ .returnTablePrint .line3 .left{
border-right: 1px solid #7f7f7f; border-right: 1px solid #7f7f7f;
...@@ -310,12 +317,12 @@ ...@@ -310,12 +317,12 @@
${dev.code} ${dev.code}
</#if> </#if>
</td> </td>
<td>${dev.model}</td><td>${dev.parts}</td><td>${dev.securityClassification}</td><td>${dev.applicationField}</td> <td>${dev.model}</td><td>${dev.category}</td><td>${dev.securityClassification}</td><td>${dev.applicationField}</td>
<td> <td>
<#if dev.count != 0> <#if dev.count != 0>
${dev.count} ${dev.count}
</#if> </#if>
</td><td style="text-align: left;">${dev.deviceSerialNumber}</td> </td><td>${dev.deviceSerialNumber}</td>
</tr> </tr>
</#list> </#list>
</table> </table>
...@@ -351,6 +358,7 @@ ...@@ -351,6 +358,7 @@
</div> </div>
</div> </div>
</div> </div>
<p class="bottomTxt">第${page}页/共${count}页</p >
</div> </div>
</body> </body>
......
...@@ -7,6 +7,13 @@ ...@@ -7,6 +7,13 @@
body{ body{
font-family:SimHei; font-family:SimHei;
} }
.bottomTxt {
text-align: center;
font-size: 10px;
color: #646464;
height: 10px;
line-height: 10px;
}
/*@page{size:297mm 210mm;}<!-- 设置PDF页面大小,此配置只对生成PDF文件有效,不会对页面显示生效 -->*/ /*@page{size:297mm 210mm;}<!-- 设置PDF页面大小,此配置只对生成PDF文件有效,不会对页面显示生效 -->*/
@page { @page {
size:210mm 297mm; size:210mm 297mm;
...@@ -151,7 +158,12 @@ ...@@ -151,7 +158,12 @@
</tr> </tr>
<#list documentDevices as dev> <#list documentDevices as dev>
<tr> <tr>
<td>${dev.model}</td><td>${dev.model}</td><td>${dev.category}</td><td>${dev.securityClassification}</td><td>${dev.applicationField}</td><td>${dev.deviceSerialNumber}</td> <td>
<#if dev.code != 0>
${dev.code}
</#if>
</td>
<td>${dev.model}</td><td>${dev.category}</td><td>${dev.securityClassification}</td><td>${dev.applicationField}</td><td>${dev.deviceSerialNumber}</td>
</tr> </tr>
</#list> </#list>
</table> </table>
...@@ -163,6 +175,7 @@ ...@@ -163,6 +175,7 @@
</div> </div>
</div> </div>
</div> </div>
<p class="bottomTxt">第${page}页/共${count}页</p >
</div> </div>
<!--<script type="text/javascript">--> <!--<script type="text/javascript">-->
<!--function altRows(id){--> <!--function altRows(id){-->
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论