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

[工作交接] 代码提交

上级 7e057efb
...@@ -81,7 +81,7 @@ public class FileController { ...@@ -81,7 +81,7 @@ public class FileController {
@ApiOperation(value = "生成工作交接的单据") @ApiOperation(value = "生成工作交接的单据")
@PostMapping("/wordHandover") @PostMapping("/wordHandover")
public ResponseEntity wordHandover(@RequestBody WorkHandoverDoc workHandoverDoc) { public ResponseEntity wordHandover(@RequestBody WorkHandoverDoc workHandoverDoc) {
String[] content = JavaToPdfHtmlFreeMarker.freeMarkerRenderWorkHandover(workHandoverDoc,url+"htmlModel/"); String[] content = JavaToPdfHtmlFreeMarker.freeMarkerRenderWorkHandover2(workHandoverDoc,url+"htmlModel/");
log.info("[file] 生成工作交接的单据"); log.info("[file] 生成工作交接的单据");
return ResponseEntity.ok(JavaToPdfHtmlFreeMarker.createPdf(content,url,preview,"workHandover/")); return ResponseEntity.ok(JavaToPdfHtmlFreeMarker.createPdf(content,url,preview,"workHandover/"));
} }
......
...@@ -59,6 +59,8 @@ public class WorkHandoverDevice { ...@@ -59,6 +59,8 @@ public class WorkHandoverDevice {
@ApiModelProperty(value = "序列号区间") @ApiModelProperty(value = "序列号区间")
public String seqs; public String seqs;
public int oneCount;
public Integer getLen(){ public Integer getLen(){
return seqs.length(); return seqs.length();
} }
......
...@@ -823,7 +823,6 @@ public class JavaToPdfHtmlFreeMarker { ...@@ -823,7 +823,6 @@ public class JavaToPdfHtmlFreeMarker {
} }
List<String> endList = strings.subList((count - 1) * 6 * 30, strings.size()); List<String> endList = strings.subList((count - 1) * 6 * 30, strings.size());
Integer max4 = toMaxList(endList); Integer max4 = toMaxList(endList);
int count1 = (max4 % 30 > 0) ? max4 / 30 + 1 : max4 / 30;
if (max4 == 30) { if (max4 == 30) {
Check check1 = new Check(); Check check1 = new Check();
check1.setSeqStirng(toALLSeqStirng(endList)); check1.setSeqStirng(toALLSeqStirng(endList));
...@@ -1411,7 +1410,7 @@ public class JavaToPdfHtmlFreeMarker { ...@@ -1411,7 +1410,7 @@ public class JavaToPdfHtmlFreeMarker {
} }
/** /**
* 计算每一页打印的内容 * 计算每一页打印的内容 (遗弃)
* 判断是否超过一页展示的最多的内容 * 判断是否超过一页展示的最多的内容
* 如大于 * 如大于
* 直接生成一个页面的数据 放入到集合中 List<List<DocumentDevice>> * 直接生成一个页面的数据 放入到集合中 List<List<DocumentDevice>>
...@@ -2001,4 +2000,143 @@ public class JavaToPdfHtmlFreeMarker { ...@@ -2001,4 +2000,143 @@ public class JavaToPdfHtmlFreeMarker {
return allStirng.toString(); return allStirng.toString();
} }
/**
* 工作交接计算每一页数据
* @param deviceList
* @return
* @throws UnsupportedEncodingException
*/
public static List<List<WorkHandoverDevice>> toWorkHandoverDeviceList(List<WorkHandoverDevice> deviceList) throws UnsupportedEncodingException {
List<List<WorkHandoverDevice>> lists=new ArrayList<>();
List<WorkHandoverDevice> revenues=new ArrayList<>();
deviceList=deviceList.stream().sorted(Comparator.comparing(WorkHandoverDevice::getModel).thenComparing(WorkHandoverDevice::getName)).collect(Collectors.toList());
Integer code=0;
int i=0;
for (int j=0;j< deviceList.size();j++){
WorkHandoverDevice workHandoverDevice=deviceList.get(j);
int max= toWorkHandoverMax(workHandoverDevice);
if (i+max==19){
workHandoverDevice.setModel(String.join("",toListString(workHandoverDevice.getModel(),16)));
workHandoverDevice.setName(String.join("",toListString(workHandoverDevice.getName(),16)));
workHandoverDevice.setSeqs(String.join("",toListString(workHandoverDevice.getSeqs(),32)));
workHandoverDevice.setOneCount(max);
code++;
workHandoverDevice.setCode(code);
revenues.add(workHandoverDevice);
lists.add(revenues);
revenues = new ArrayList<>();
i=0;
}else if (i+max>19){
//当前页面少了多少行
int differ=19-i;
List<String> modelList= toListString(workHandoverDevice.getModel(),16);
List<String> nameList=toListString(workHandoverDevice.getName(),16);
List<String> seqList=toListString(workHandoverDevice.getSeqs(),32);
WorkHandoverDevice workHandoverDevice1=new WorkHandoverDevice();
if (modelList.size()>differ){
workHandoverDevice.setModel(String.join("",modelList.subList(0,differ)));
workHandoverDevice1.setModel(String.join("",modelList.subList(differ,modelList.size())));
}else {
workHandoverDevice.setModel(String.join("",modelList));
}
if (nameList.size()>differ){
workHandoverDevice.setName(String.join("",nameList.subList(0,differ)));
workHandoverDevice1.setName(String.join("",nameList.subList(differ,nameList.size())));
}else {
workHandoverDevice.setName(String.join("",nameList));
}
if (seqList.size()>differ){
workHandoverDevice.setSeqs(String.join("",seqList.subList(0,differ)));
workHandoverDevice1.setSeqs(String.join("",seqList.subList(differ,seqList.size())));
}else {
workHandoverDevice.setSeqs(String.join("",seqList));
}
code++;
workHandoverDevice.setCode(code);
workHandoverDevice.setOneCount(differ);
revenues.add(workHandoverDevice);
lists.add(revenues);
revenues=new ArrayList<>();
workHandoverDevice1.setOneCount(max-differ);
code++;
workHandoverDevice1.setCode(code);
revenues.add(workHandoverDevice1);
i=max-differ;
}else {
code++;
workHandoverDevice.setModel(String.join("",toListString(workHandoverDevice.getModel(),16)));
workHandoverDevice.setName(String.join("",toListString(workHandoverDevice.getName(),16)));
workHandoverDevice.setSeqs(String.join("",toListString(workHandoverDevice.getSeqs(),32)));
workHandoverDevice.setCode(code);
workHandoverDevice.setOneCount(max);
revenues.add(workHandoverDevice);
i=i+max;
}
}
if (revenues.size()!=0){
lists.add(revenues);
}
return lists;
}
private static Integer toWorkHandoverMax(WorkHandoverDevice workHandoverDevice){
int nameCount=String_length(workHandoverDevice.getName());
int modelCount=String_length(workHandoverDevice.getModel());
int seqCount=String_length(workHandoverDevice.getSeqs());
int name = (nameCount%16>0) ? nameCount/16 + 1 : nameCount/16;
int model=(modelCount%16>0) ? modelCount/16 + 1 : modelCount/16;
int seq=(seqCount%32>0) ? seqCount/32 + 1 : seqCount/32;
int max=name;
//求最大
if(max<model){
max=model;
}
if (max<seq){
max=seq;
}
return max;
}
/**
* freemarker渲染html workHandoverDoc
*/
public static String[] freeMarkerRenderWorkHandover2(WorkHandoverDoc workHandoverDoc,String htmlPath) {
Writer out = new StringWriter();
String [] strings=new String[100000];
int index=0;
try {
// 获取模板,并设置编码方式
Template template = freemarkerCfg.getTemplate("bill13.html");
template.setEncoding("UTF-8");
List<WorkHandoverDevice> list = workHandoverDoc.getWorkHandoverDeviceList();
List<List<WorkHandoverDevice>> listList=toWorkHandoverDeviceList(list);
Integer count=listList.size();
for (int i=1; i<=3; i++){
Integer page=1;
for (List<WorkHandoverDevice> list1:listList) {
String htmlname=htmlPath+ UUID.randomUUID().toString()+".html";
// 合并数据模型与模板
FileWriter fileWriter = new FileWriter(new File(htmlname));
template.process(toMapWork(workHandoverDoc,list1,MAP1.get(i),page,count),fileWriter);
out.flush();
strings[index]=htmlname;
index++;
page++;
}
}
return strings;
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
out.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
return null;
}
} }
<!DOCTYPE html>
<html lang="en">
<!--工作交接模版-->
<head>
<meta charset="UTF-8" />
<title>Document</title>
<style>
body,span,p,tr,td {
font-size: 15px;
font-family: SimHei;
margin: 0;
padding: 0;
}
/*@page{size:297mm 210mm;}<!-- 设置PDF页面大小,此配置只对生成PDF文件有效,不会对页面显示生效 -->*/
@page {
size: 297mm 210mm;
}
.bottomTxt {
text-align: center;
font-size: 15px;
color: #000;
height: 16px;
margin-top: 4px;
line-height: 16px;
}
.returnTablePrint {
width: 100%;
height: 100%;
overflow: hidden;
color: #000;
cursor: default;
}
.returnTablePrint .content {
width: 100%;
height: 100%;
}
.returnTablePrint .content>div {
width: 100%;
height: 100%;
background: #fff;
/* padding: 30px; */
box-sizing: border-box;
}
/* .returnTablePrint .content>p{
width: 100%;
text-align: center;
font-size: 22px;
font-weight: bold;
color: #4a475d;
} */
.returnTablePrint .listWrapper {
/*margin: 0 auto;*/
/* height: calc(100% - 40px); */
box-sizing: border-box;
}
.returnTablePrint .list {
/*margin: 0 auto;*/
height: calc(100% - 12px)
}
.returnTablePrint .title {
width: 100%;
font-size: 22px;
text-align: center;
position: relative;
/* margin: 0 0 15px; */
box-sizing: border-box;
}
/* .returnTablePrint .title span:nth-child(2){
font-size: 28px;
color: #000000;
}
.returnTablePrint .title span:nth-child(2) span{
font-size: 20px;
color: #141414;
} */
.returnTablePrint .title .number {
font-size: 15px;
color: #000;
}
/* .returnTablePrint .other{
width: 100%;
color: #141414;
font-size: 20px;
margin-top: 20px;
padding-left: 50px;
position: relative;
box-sizing: border-box;
margin-bottom: 20px;
}
.returnTablePrint .other>span span:nth-child(2){
display: inline-block;
margin:0 40px 0 10px;
} */
.returnTablePrint .listCon {
height: 100%;
border: 1px solid #7f7f7f;
}
.returnTablePrint .line1 {
width: 100%;
font-size: 15px;
box-sizing: border-box;
border-bottom: 1px solid #7f7f7f;
color: #000;
line-height: 20px;
}
.returnTablePrint .line1 .sendTo {
display: inline-block;
width: 49%;
text-indent: 5px;
box-sizing: border-box;
/*padding-left: 20px;*/
}
.returnTablePrint .line1 .sendNum {
display: inline-block;
width: 49%;
box-sizing: border-box;
/*padding-left: 20px;*/
}
.returnTablePrint .line1 .sendTo {
border-right: 1px solid #7f7f7f;
}
.returnTablePrint .line1 .sendTo span:nth-child(2),
.returnTablePrint .line1 .sendNum span:nth-child(2) {
color: #000;
display: inline-block;
margin-left: 5px;
}
.returnTablePrint .line2 {
height: 100%;
/* padding: 20px; */
border-bottom: 1px solid #7f7f7f;
}
.returnTablePrint .tableList {
height:500px;
border-bottom: none;
overflow: hidden;
}
.returnTablePrint .line2>>>.el-table tbody tr:nth-child(odd) {
background-color: #fff;
}
.returnTablePrint .line2>>>.el-table tbody tr:nth-child(even) {
background-color: #fff;
}
.returnTablePrint .line3 {
border-bottom: 1px solid #7f7f7f;
border-top: none;
width: 100%;
height: 94px;
/* box-sizing: border-box; */
/*height:150px;*/
/*display: flex;*/
/* height:170px; */
/* padding:20px 0 20px 0; */
}
.returnTablePrint .line3 .left {
display: inline-block;
width: 32%;
text-align: center;
box-sizing: border-box;
/*padding-left: 20px;*/
position: relative;
line-height: 94px;
}
.returnTablePrint .line3 .left span{
width: 100%;
}
.returnTablePrint .line3 .left {
/*border-right: 1px solid #7f7f7f;*/
/*padding-bottom: 40px;*/
}
.returnTablePrint .line3 .left:last-child {
/*padding-bottom: 40px;*/
}
.returnTablePrint .line3 .left>span {
display: block;
/* margin: 15px 0px; */
}
.returnTablePrint .line3 .left>span>span:nth-child(2) {
display: inline-block;
margin-left: 10px;
}
.returnTablePrint>>>.el-scrollbar__wrap {
overflow-x: hidden;
margin-bottom: 0;
}
.returnTablePrint .checkName span:nth-child(2) {
color: #000;
display: inline-block;
margin-left: 20px;
}
.returnTablePrint>>>.el-table tbody .cell {
color: #141414;
}
.returnTablePrint .label {
color: #000;
font-size: 15px;
}
.returnTablePrint .value {
color: #000;
font-size: 15px;
}
.returnTablePrint .main-title span{
font-size: 22px;
color: #333;
font-weight: bold;
}
.returnTablePrint .main-title {
font-size: 17px;
color: #000000;
line-height: 17px;
text-align: center;
margin-top: 9px;
}
.returnTablePrint .footer {
display: flex;
justify-content: flex-end;
padding: 0 40px;
box-sizing: border-box;
}
.button-submit {
margin-left: 50px;
}
table.altrowstable2 {
width: 100%;
font-size: 16px;
color: #000;
border-width: 0px;
border-color: #a9c6c9;
border-collapse: collapse;
text-align: center;
table-layout: fixed;
word-break: break-all;
}
table.altrowstable2 th {
height: 25px;
line-height:25px;
font-size: 15px;
background-color: #fff;
border:1px solid #bebebe;
padding-top: 0;
}
table.altrowstable2 td {
height: 25px;
line-height:25px;
font-size: 15px;
word-break: break-all;
word-wrap: break-word;
border:1px solid #bebebe;
width: 100%;
}
.td2{
height: 50px !important;
}
.td3{
height: 75px !important;
}
.td4{
height: 100px !important;
}
.td5{
height: 125px !important;
}
.td6{
height: 150px !important;
}
.td7{
height: 175px !important;
}
.td8{
height: 200px !important;
}
.td9{
height: 225px !important;
}
.td10{
height: 250px !important;
}
.td11{
height: 275px !important;
}
.td12{
height: 300px !important;
}
.td13{
height: 325px !important;
}
table.altrowstable {
width: 100%;
font-size: 16px;
color: #000;
border-width: 0px;
border-color: #a9c6c9;
border-collapse: collapse;
text-align: center;
table-layout: fixed;
word-break: break-all;
}
table.altrowstable th {
height: 24px;
line-height:24px;
font-size: 15px;
background-color: #ebebeb;
marign-top:none;
border:1px solid #bebebe;
padding-top: 0;
padding-bottom: 0;
}
table.altrowstable td {
height: 24px;
line-height:24px;
font-size: 15px;
word-break: normal;
word-wrap: normal;
border:1px solid #bebebe;
border-bottom: none;
width: 100%;
}
table.altrowstable tr:nth-child(odd){
background-color: #f8f8f8;
}
.oddrowcolor {
background-color: #fff;
}
.evenrowcolor {
background-color: #fafafa;
}
/*tr:nth-child(odd) {*/
/* background: #fafafa;*/
/*}*/
</style>
</head>
<body>
<div class="returnTablePrint">
<div class="content">
<div>
<div class="listWrapper">
<div class="list">
<div class="title">
<div class="main-title">
<span>
工作装备交接单
</span>
</div>
<div style="width:100%;text-align:left;font-size: 1px;margin-bottom:2px">
<div style="text-align:left;display: inline-block; width: 49%" class="number">
</div>
<!-- <div style="text-align:center;display: inline-block; width: 34%" class="number">
<span></span>
</div> -->
<div style="text-align:right;display: inline-block; width: 50%" class="number">
</div>
</div>
</div>
<div class="listCon">
<div class="line2 tableList">
<table class="altrowstable" id="alternatecolor">
<tr>
<th width="70px" >序号</th>
<th width="150px" >型号</th>
<th width="150px" >名称</th>
<th width="40px">数量</th>
<th width="40px">在库</th>
<th width="40px">维修</th>
<th width="40px">报废</th>
<th width="40px">清退</th>
<th width="40px">销毁</th>
<th width="40px">配发</th>
<th width="40px">在用</th>
<th width="40px">其他</th>
<th >装备序列号</th>
</tr>
<#list documentDevices as dev>
<tr>
<td>
${dev.code!}
</td>
<td>${dev.model!}</td>
<td>${dev.name!}</td>
<td>${dev.deviceNumber!}</td>
<td>${dev.inLibraryNum!}</td>
<td>${dev.repairNum!}</td>
<td>${dev.destoryNum!}</td>
<td>${dev.retiredNum!}</td>
<td>${dev.scrappedNum!}</td>
<td>${dev.allotNum!}</td>
<td>${dev.useNum!}</td>
<td>${dev.otherNum!}</td>
<#if dev.oneCount == 1>
<td>${dev.seqs!}</td>
<#elseif dev.oneCount == 2>
<td class="td2">${dev.seqs!}</td>
<#elseif dev.oneCount == 3>
<td class="td3">${dev.seqs!}</td>
<#elseif dev.oneCount == 4>
<td class="td4">${dev.seqs!}</td>
<#elseif dev.oneCount == 5>
<td class="td5">${dev.seqs!}</td>
<#elseif dev.oneCount == 6>
<td class="td6">${dev.seqs!}</td>
<#elseif dev.oneCount == 7>
<td class="td7">${dev.seqs!}</td>
<#elseif dev.oneCount == 8>
<td class="td8">${dev.seqs!}</td>
<#elseif dev.oneCount == 9>
<td class="td9">${dev.seqs!}</td>
<#elseif dev.oneCount == 10>
<td class="td10">${dev.seqs!}</td>
<#elseif dev.oneCount == 11>
<td class="td11">${dev.seqs!}</td>
<#elseif dev.oneCount == 12>
<td class="td12">${dev.seqs!}</td>
<#elseif dev.oneCount == 13>
<td class="td13">${dev.seqs!}</td>
<#elseif dev.oneCount == 14>
<td class="td14">${dev.seqs!}</td>
</#if>
</tr>
</#list>
</table>
<table class="altrowstable2" id="alternatecolor">
<tr style="border-bottom: 1px solid #dedede;">
<th width="70px" ></th>
<th width="150px" ></th>
<th width="150px" ></th>
<th width="40px"></th>
<th width="40px"></th>
<th width="40px"></th>
<th width="40px"></th>
<th width="40px"></th>
<th width="40px"></th>
<th width="40px"></th>
<th width="40px"></th>
<th width="40px"></th>
<th ></th>
</tr>
<tr class="altrowstableTr">
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class="altrowstableTr">
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class="altrowstableTr">
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class="altrowstableTr">
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class="altrowstableTr">
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class="altrowstableTr">
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class="altrowstableTr">
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class="altrowstableTr">
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class="altrowstableTr">
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class="altrowstableTr">
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class="altrowstableTr">
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class="altrowstableTr">
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class="altrowstableTr">
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class="altrowstableTr">
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class="altrowstableTr">
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class="altrowstableTr">
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</div>
</div>
<div class="line3" style="position: relative;">
<span class="left">
<span>
<span style="position: absolute; top: 0px; left: 8px;"
class="label">单位盖章:</span>
<span class="value"></span>
</span>
</span>
<span class="left">
<span>
<span style="position: absolute; top: 0px; left: 8px;"
class="label">专管员签名:</span>
<span class="value"></span>
</span>
</span>
<span class="left">
<span>
<span style="position: absolute; top: 0px; left: 8px;"
class="label">专管员签名:</span>
<span class="value"></span>
</span>
</span>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="bottomTxt">第${page}页/共${count}页</p>
</body>
</html>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论