Commit 85f0a102 authored by xixinzhao's avatar xixinzhao

交接班pdf样式

parent fdbbbbc7
...@@ -27,36 +27,7 @@ public class PdfUtils { ...@@ -27,36 +27,7 @@ public class PdfUtils {
return document; return document;
} }
/** public static PdfPCell createCell(Object value, Font font, int align, int colspan, int row, int size,int top,int right,int bottom,int left){
*
* @param value 单元格数据
* @param font 单元格样式
* @param align 位置
* @param colspan 占几列
* @param row 占几行
* @param size 高度
* @return
*/
public static PdfPCell createCell(Object value, Font font, int align, int colspan, int row, int size){
String cellValue;
if (value == null) {
cellValue = "";
} else {
cellValue = value.toString();
}
PdfPCell cell = new PdfPCell();
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell.setHorizontalAlignment(align);
cell.setColspan(colspan);
cell.setPhrase(new Phrase(cellValue,font));
cell.setFixedHeight(size);
if (row != 1) {
cell.setRowspan(row);
}
return cell;
}
public static PdfPCell createCell(Object value, Font font, int align, int colspan, int row, int size,boolean flag){
String cellValue; String cellValue;
if (value == null) { if (value == null) {
cellValue = ""; cellValue = "";
...@@ -72,16 +43,10 @@ public class PdfUtils { ...@@ -72,16 +43,10 @@ public class PdfUtils {
if (row != 1) { if (row != 1) {
cell.setRowspan(row); cell.setRowspan(row);
} }
if (flag) { cell.setBorderWidthLeft(left);
cell.setBorderWidthLeft(0); cell.setBorderWidthRight(right);
cell.setBorderWidthTop(0); cell.setBorderWidthTop(top);
cell.setBorderWidthBottom(0); cell.setBorderWidthBottom(bottom);
} else {
cell.setBorderWidthLeft(0);
cell.setBorderWidthRight(0);
cell.setBorderWidthTop(0);
cell.setBorderWidthBottom(0);
}
return cell; return cell;
} }
public static PdfPCell createCell(Image image, int align, int colspan){ public static PdfPCell createCell(Image image, int align, int colspan){
......
...@@ -168,7 +168,7 @@ public class ShiftChangeServiceImpl extends BaseService<ShiftChangeDto, ShiftCha ...@@ -168,7 +168,7 @@ public class ShiftChangeServiceImpl extends BaseService<ShiftChangeDto, ShiftCha
// 表格内容 // 表格内容
PdfPTable table1 = PdfUtils.createTable(8); PdfPTable table1 = PdfUtils.createTable(8);
int[] widths = { 12,25, 25, 25, 25, 20, 25, 25 }; int[] widths = { 12, 25, 25, 25, 25, 20, 25, 25 };
table1.setWidthPercentage(100); table1.setWidthPercentage(100);
table1.setSpacingBefore(10); table1.setSpacingBefore(10);
table1.setWidths(widths); table1.setWidths(widths);
...@@ -177,34 +177,41 @@ public class ShiftChangeServiceImpl extends BaseService<ShiftChangeDto, ShiftCha ...@@ -177,34 +177,41 @@ public class ShiftChangeServiceImpl extends BaseService<ShiftChangeDto, ShiftCha
String recDare = shiftChange.getRecDate() != null ? sdf.format(shiftChange.getRecDate()) : ""; String recDare = shiftChange.getRecDate() != null ? sdf.format(shiftChange.getRecDate()) : "";
// 第一行 // 第一行
table1.addCell(PdfUtils.createCell("时间", cellTitle,Element.ALIGN_CENTER,1,1,size)); table1.addCell(PdfUtils.createCell("时间", cellTitle,Element.ALIGN_CENTER,1,1,
table1.addCell(PdfUtils.createCell(recDare, cellContent,Element.ALIGN_CENTER,3,1,size)); size,1,1,0,1));
table1.addCell(PdfUtils.createCell("值班领导", cellTitle,Element.ALIGN_CENTER,1,1,size)); table1.addCell(PdfUtils.createCell(recDare, cellContent,Element.ALIGN_CENTER,3,1,
table1.addCell(PdfUtils.createCell(shiftChangeInfoDto.getJsDutyLeader(), cellContent,Element.ALIGN_CENTER,3,1,size)); size,1,1,0,0));
table1.addCell(PdfUtils.createCell("值班领导", cellTitle,Element.ALIGN_CENTER,1,1,
size,1,1,0,0));
table1.addCell(PdfUtils.createCell(shiftChangeInfoDto.getJsDutyLeader(), cellContent,Element.ALIGN_CENTER,3,1,
size,1,1,0,0));
// 第二行 // 第二行
table1.addCell(PdfUtils.createCell("值\n班\n员", cellTitle,Element.ALIGN_CENTER,1,3,size)); table1.addCell(PdfUtils.createCell("值\n班\n员", cellTitle,Element.ALIGN_CENTER,1,3,
table1.addCell(PdfUtils.createCell("正班", cellTitle,Element.ALIGN_CENTER,1,1,size)); size,1,1,0,1));
table1.addCell(PdfUtils.createCell(shiftChangeInfoDto.getDutyPersonOne(), cellContent,Element.ALIGN_CENTER,1,1,size)); table1.addCell(PdfUtils.createCell("正班", cellTitle,Element.ALIGN_CENTER,1,1,
table1.addCell(PdfUtils.createCell("值班开始时间", cellContent,Element.ALIGN_CENTER,1,1,size)); size,1,1,0,0));
table1.addCell(PdfUtils.createCell("交接班时间", cellContent,Element.ALIGN_CENTER,1,1,size)); table1.addCell(PdfUtils.createCell(shiftChangeInfoDto.getDutyPersonOne(), cellContent,Element.ALIGN_CENTER,1,1,
table1.addCell(PdfUtils.createCell("接班员", cellTitle,Element.ALIGN_CENTER,1,3,size)); size,1,1,0,0));
table1.addCell(PdfUtils.createCell("正班", cellTitle,Element.ALIGN_CENTER,1,1,size)); table1.addCell(PdfUtils.createCell("值班开始时间", cellContent,Element.ALIGN_CENTER,1,1,size,1,1,0,0));
table1.addCell(PdfUtils.createCell(shiftChangeInfoDto.getSucceedPersonOne(), cellContent,Element.ALIGN_CENTER,1,1,size)); table1.addCell(PdfUtils.createCell("交接班时间", cellContent,Element.ALIGN_CENTER,1,1,size,1,1,0,0));
table1.addCell(PdfUtils.createCell("接班员", cellTitle,Element.ALIGN_CENTER,1,3,size,1,1,0,0));
table1.addCell(PdfUtils.createCell("正班", cellTitle,Element.ALIGN_CENTER,1,1,size,1,1,0,0));
table1.addCell(PdfUtils.createCell(shiftChangeInfoDto.getSucceedPersonOne(), cellContent,Element.ALIGN_CENTER,1,1,size,1,1,0,0));
// 第三行 // 第三行
table1.addCell(PdfUtils.createCell("副班", cellTitle,Element.ALIGN_CENTER,1,1,size)); table1.addCell(PdfUtils.createCell("副班", cellTitle,Element.ALIGN_CENTER,1,1,size,1,1,0,0));
table1.addCell(PdfUtils.createCell(shiftChangeInfoDto.getDutyPersonTwo(), cellContent,Element.ALIGN_CENTER,1,1,size)); table1.addCell(PdfUtils.createCell(shiftChangeInfoDto.getDutyPersonTwo(), cellContent,Element.ALIGN_CENTER,1,1,size,1,1,0,0));
table1.addCell(PdfUtils.createCell(shiftChangeInfoDto.getBeginDate(), cellContent,Element.ALIGN_CENTER,1,1,size)); table1.addCell(PdfUtils.createCell(shiftChangeInfoDto.getBeginDate(), cellContent,Element.ALIGN_CENTER,1,1,size,1,1,0,0));
table1.addCell(PdfUtils.createCell(shiftChangeInfoDto.getEndDate(), cellContent,Element.ALIGN_CENTER,1,1,size)); table1.addCell(PdfUtils.createCell(shiftChangeInfoDto.getEndDate(), cellContent,Element.ALIGN_CENTER,1,1,size,1,1,0,0));
table1.addCell(PdfUtils.createCell("副班", cellTitle,Element.ALIGN_CENTER,1,1,size)); table1.addCell(PdfUtils.createCell("副班", cellTitle,Element.ALIGN_CENTER,1,1,size,1,1,0,0));
table1.addCell(PdfUtils.createCell(shiftChangeInfoDto.getSucceedPersonTwo(), cellContent,Element.ALIGN_CENTER,1,1,size)); table1.addCell(PdfUtils.createCell(shiftChangeInfoDto.getSucceedPersonTwo(), cellContent,Element.ALIGN_CENTER,1,1,size,1,1,0,0));
// 第四行 // 第四行
table1.addCell(PdfUtils.createCell("经理", cellTitle,Element.ALIGN_CENTER,1,1,size)); table1.addCell(PdfUtils.createCell("经理", cellTitle,Element.ALIGN_CENTER,1,1,size,1,1,0,0));
table1.addCell(PdfUtils.createCell(shiftChangeInfoDto.getDutyPersonLeader(), cellContent,Element.ALIGN_CENTER,3,1,size)); table1.addCell(PdfUtils.createCell(shiftChangeInfoDto.getDutyPersonLeader(), cellContent,Element.ALIGN_CENTER,3,1,size,1,1,0,0));
table1.addCell(PdfUtils.createCell("经理", cellTitle,Element.ALIGN_CENTER,1,1,size)); table1.addCell(PdfUtils.createCell("经理", cellTitle,Element.ALIGN_CENTER,1,1,size,1,1,0,0));
table1.addCell(PdfUtils.createCell(shiftChangeInfoDto.getSucceedPersonLeader(), cellContent,Element.ALIGN_CENTER,1,1,size)); table1.addCell(PdfUtils.createCell(shiftChangeInfoDto.getSucceedPersonLeader(), cellContent,Element.ALIGN_CENTER,1,1,size,1,1,0,0));
JSONObject dutyJson = shiftChange.getDutyJson(); JSONObject dutyJson = shiftChange.getDutyJson();
JSONObject powerJson = shiftChange.getPowerJson(); JSONObject powerJson = shiftChange.getPowerJson();
...@@ -226,33 +233,33 @@ public class ShiftChangeServiceImpl extends BaseService<ShiftChangeDto, ShiftCha ...@@ -226,33 +233,33 @@ public class ShiftChangeServiceImpl extends BaseService<ShiftChangeDto, ShiftCha
String powerRemark = powerDto.getPowerRemark() == null ? "无" : powerDto.getPowerRemark(); String powerRemark = powerDto.getPowerRemark() == null ? "无" : powerDto.getPowerRemark();
// 值班情况 // 值班情况
table1.addCell(PdfUtils.createCell("值\n班\n情\n况", cellTitle,Element.ALIGN_CENTER,1,6+powerSize+infoSize,size)); table1.addCell(PdfUtils.createCell("值\n班\n情\n况", cellTitle,Element.ALIGN_CENTER,1,6+powerSize+infoSize,size,1,1,0,1));
table1.addCell(PdfUtils.createCell("接警情况:", cellContent,Element.ALIGN_LEFT,7,1,size,true)); table1.addCell(PdfUtils.createCell("接警情况:", cellTitle,Element.ALIGN_LEFT,7,1,size,1,1,0,0));
table1.addCell(PdfUtils.createCell("接警"+ dutyDto.getCalledCount() +"起", cellContent, Element.ALIGN_CENTER,1,1,smallSize,false)); table1.addCell(PdfUtils.createCell("接警"+ dutyDto.getCalledCount() +"起", cellContent, Element.ALIGN_CENTER,1,1,smallSize,0,0,0,0));
table1.addCell(PdfUtils.createCell("未结案" + dutyDto.getUnFinishedCount() + "起", cellContent,Element.ALIGN_CENTER,2,1,smallSize,false)); table1.addCell(PdfUtils.createCell("未结案" + dutyDto.getUnFinishedCount() + "起", cellContent,Element.ALIGN_CENTER,2,1,smallSize,0,0,0,0));
table1.addCell(PdfUtils.createCell("已结案" + dutyDto.getFinishedCount() + "起", cellContent,Element.ALIGN_CENTER,2,1,smallSize,false)); table1.addCell(PdfUtils.createCell("已结案" + dutyDto.getFinishedCount() + "起", cellContent,Element.ALIGN_CENTER,2,1,smallSize,0,0,0,0));
table1.addCell(PdfUtils.createCell("重大警情" + dutyDto.getMajorAlertCount() + "起", cellContent,Element.ALIGN_CENTER,2,1,smallSize,true)); table1.addCell(PdfUtils.createCell("重大警情" + dutyDto.getMajorAlertCount() + "起", cellContent,Element.ALIGN_CENTER,2,1,smallSize,0,1,0,0));
if (!ObjectUtils.isEmpty(infoList)) { if (!ObjectUtils.isEmpty(infoList)) {
for (String info : infoList) { for (String info : infoList) {
table1.addCell(PdfUtils.createCell(info, cellContent,Element.ALIGN_LEFT,7,1,smallSize,true)); table1.addCell(PdfUtils.createCell(info, cellContent,Element.ALIGN_LEFT,7,1,smallSize,0,1,0,0));
} }
} }
table1.addCell(PdfUtils.createCell("备注:"+alarmRemark, cellContent,Element.ALIGN_LEFT,7,1,smallSize,true)); table1.addCell(PdfUtils.createCell("备注:"+alarmRemark, cellContent,Element.ALIGN_LEFT,7,1,smallSize,0,1,0,0));
table1.addCell(PdfUtils.createCell("力量出动:", cellContent,Element.ALIGN_LEFT,7,1,size,true)); table1.addCell(PdfUtils.createCell("力量出动:", cellTitle,Element.ALIGN_LEFT,7,1,size,0,1,0,0));
table1.addCell(PdfUtils.createCell("调派任务"+ powerDto.getTransfer_count() +"起", cellContent,Element.ALIGN_CENTER,1,1,smallSize,false)); table1.addCell(PdfUtils.createCell("调派任务"+ powerDto.getTransfer_count() +"起", cellContent,Element.ALIGN_CENTER,1,1,smallSize,0,0,0,0));
table1.addCell(PdfUtils.createCell("调派车辆" + powerDto.getCar_count() + "起", cellContent,Element.ALIGN_CENTER,2,1,smallSize,false)); table1.addCell(PdfUtils.createCell("调派车辆" + powerDto.getCar_count() + "辆次", cellContent,Element.ALIGN_CENTER,2,1,smallSize,0,0,0,0));
table1.addCell(PdfUtils.createCell("已完成任务" + powerDto.getEnd_count() + "起", cellContent,Element.ALIGN_CENTER,2,1,smallSize,false)); table1.addCell(PdfUtils.createCell("已完成任务" + powerDto.getEnd_count() + "起", cellContent,Element.ALIGN_CENTER,2,1,smallSize,0,0,0,0));
table1.addCell(PdfUtils.createCell("未归队车辆" + powerDto.getNo_return_car_count() + "起", cellContent,Element.ALIGN_CENTER,2,1,smallSize,true)); table1.addCell(PdfUtils.createCell("未归队车辆" + powerDto.getNo_return_car_count() + "辆", cellContent,Element.ALIGN_CENTER,2,1,smallSize,0,1,0,0));
if (!ObjectUtils.isEmpty(powerList)) { if (!ObjectUtils.isEmpty(powerList)) {
for (String powerInfo : powerList) { for (String powerInfo : powerList) {
table1.addCell(PdfUtils.createCell(powerInfo, cellContent,Element.ALIGN_LEFT,7,1,smallSize,true)); table1.addCell(PdfUtils.createCell(powerInfo, cellContent,Element.ALIGN_LEFT,7,1,smallSize,0,1,0,0));
} }
} }
table1.addCell(PdfUtils.createCell("备注:"+powerRemark, cellContent,Element.ALIGN_LEFT,7,1,smallSize,true)); table1.addCell(PdfUtils.createCell("备注:"+powerRemark, cellContent,Element.ALIGN_LEFT,7,1,smallSize,0,1,0,0));
// 移交事宜 // 移交事宜
table1.addCell(PdfUtils.createCell("移\n交\n事\n宜", cellTitle,Element.ALIGN_CENTER,1,1,size)); table1.addCell(PdfUtils.createCell("移\n交\n事\n宜", cellTitle,Element.ALIGN_CENTER,1,1,size,1,1,1,1));
table1.addCell(PdfUtils.createCell(shiftChange.getRemark(), cellContent,Element.ALIGN_LEFT,7,1,120)); table1.addCell(PdfUtils.createCell(shiftChange.getRemark(), cellContent,Element.ALIGN_LEFT,7,1,120,1,1,1,0));
try{ try{
document.add(docTitle); document.add(docTitle);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment