|
|
@@ -41,6 +41,7 @@ import java.math.BigDecimal; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.*; |
|
|
|
import java.util.List; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* 巡检报告表 服务实现类 |
|
|
@@ -567,6 +568,352 @@ public class ReportServiceImpl extends BaseServiceImpl<ReportMapper, Report> imp |
|
|
|
return UploadFileConfig.docDownLoad+"/lc/doc/"+fileName; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public String exportReportHandleWord(Integer reportId, HttpServletRequest request, HttpServletResponse response) throws Exception { |
|
|
|
ReportInfoVO reportInfoVO = detail(reportId); |
|
|
|
//创建word |
|
|
|
String fileName = "汤山林场无人机处理报告【"+ reportInfoVO.getReportNo() + "】.doc"; |
|
|
|
String filePath = UploadFileConfig.uploadFolder+"doc/"+fileName; |
|
|
|
File fd = new File(UploadFileConfig.uploadFolder+"doc"); |
|
|
|
File f = new File(filePath); |
|
|
|
if(!fd.exists()){ |
|
|
|
fd.mkdirs(); |
|
|
|
} |
|
|
|
WordUtilsOld wordUtils = new WordUtilsOld(); |
|
|
|
|
|
|
|
SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
try { |
|
|
|
if(f.exists()){ |
|
|
|
f.delete(); |
|
|
|
f.createNewFile(); |
|
|
|
} |
|
|
|
log.info("开始编写word文件,文件为:{}",filePath); |
|
|
|
wordUtils.openDocument(filePath); |
|
|
|
wordUtils.getDocument().setPageSize(PageSize.A4); |
|
|
|
wordUtils.getDocument().setMargins(71f, 71f, 72f, 72f); |
|
|
|
//标题 |
|
|
|
wordUtils.insertTitlePattern("汤山林场无人机处理报告", WordUtilsOld.rtfGsBt1); |
|
|
|
wordUtils.insertContext("报告编号:"+reportInfoVO.getReportNo(),10, Font.NORMAL, Element.ALIGN_RIGHT,20,0,0); |
|
|
|
wordUtils.insertTitlePatternThird("一:林场信息", WordUtilsOld.rtfGsBt3); |
|
|
|
Table table = new Table(2);//生成一表格 |
|
|
|
table.setOffset(1f); |
|
|
|
int[] width = {1, 1}; |
|
|
|
table.setWidths(width);//设置系列所占比例 |
|
|
|
table.setWidth(100); |
|
|
|
table.setAutoFillEmptyCells(true); |
|
|
|
table.setAlignment(Element.ALIGN_LEFT);//居中显示 |
|
|
|
for (int i = 0; i < 6; i++) { |
|
|
|
Cell cell = new Cell(); |
|
|
|
String str; |
|
|
|
cell.setVerticalAlignment(Element.ALIGN_RIGHT); |
|
|
|
cell.setHorizontalAlignment(Element.ALIGN_CENTER); |
|
|
|
Font font = new Font(); |
|
|
|
font.setSize(10.5f); |
|
|
|
font.setStyle(Font.BOLD); |
|
|
|
if (i == 0) { |
|
|
|
str = "责任单位"; |
|
|
|
font.setStyle(Font.NORMAL); |
|
|
|
} else if (i == 1) { |
|
|
|
str = reportInfoVO.getCompany(); |
|
|
|
} else if (i == 2) { |
|
|
|
str = "林场名称"; |
|
|
|
font.setStyle(Font.NORMAL); |
|
|
|
} else if (i == 3) { |
|
|
|
str = reportInfoVO.getLcName(); |
|
|
|
} else if (i == 4) { |
|
|
|
str = "巡查里程"; |
|
|
|
font.setStyle(Font.NORMAL); |
|
|
|
} else { |
|
|
|
if(StringUtils.isNotEmpty(reportInfoVO.getMission().getMileage())){ |
|
|
|
try{ |
|
|
|
BigDecimal mileageBd = new BigDecimal(reportInfoVO.getMission().getMileage()).divide(new BigDecimal(1000)); |
|
|
|
str = mileageBd + "公里"; |
|
|
|
}catch (Exception e){ |
|
|
|
log.info("转换里程出错:{}",e.getMessage()); |
|
|
|
str=""; |
|
|
|
} |
|
|
|
}else{ |
|
|
|
str = ""; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
Paragraph p = new Paragraph(str, font); |
|
|
|
cell.add(p); |
|
|
|
table.addCell(cell); |
|
|
|
} |
|
|
|
wordUtils.getDocument().add(table); |
|
|
|
log.info("林场信息写入完成"); |
|
|
|
|
|
|
|
wordUtils.insertTitlePatternThird("二:巡检信息", WordUtilsOld.rtfGsBt3); |
|
|
|
Table table2 = new Table(2);//生成一表格 |
|
|
|
table2.setOffset(1f); |
|
|
|
int[] width2 = {1, 1}; |
|
|
|
table2.setWidths(width2);//设置系列所占比例 |
|
|
|
table2.setWidth(100); |
|
|
|
table2.setAutoFillEmptyCells(true); |
|
|
|
table2.setAlignment(Element.ALIGN_CENTER);//居中显示 |
|
|
|
table2.setAlignment(Element.ALIGN_MIDDLE);//垂直居中显示 |
|
|
|
|
|
|
|
for (int i = 0; i < 12; i++) { |
|
|
|
Cell cell = new Cell(); |
|
|
|
String str; |
|
|
|
cell.setVerticalAlignment(Element.ALIGN_LEFT); |
|
|
|
cell.setHorizontalAlignment(Element.ALIGN_CENTER); |
|
|
|
Font font = new Font(); |
|
|
|
font.setSize(10.5f); |
|
|
|
font.setStyle(Font.BOLD); |
|
|
|
if (i == 0) { |
|
|
|
str = "气象信息"; |
|
|
|
} else if (i == 1) { |
|
|
|
str = reportInfoVO.getAirWeather(); |
|
|
|
font.setStyle(Font.NORMAL); |
|
|
|
} else if (i == 2) { |
|
|
|
str = "巡检方式"; |
|
|
|
} else if (i == 3) { |
|
|
|
//巡检方式 1 机场服务,2 人工巡检 |
|
|
|
str = reportInfoVO.getMission().getInspectionType().equals(1) ? "机场服务" :"人工巡检"; |
|
|
|
font.setStyle(Font.NORMAL); |
|
|
|
} else if (i == 4) { |
|
|
|
str = "巡检设备"; |
|
|
|
} else if (i == 5) { |
|
|
|
str = reportInfoVO.getMission().getDroneName(); |
|
|
|
font.setStyle(Font.NORMAL); |
|
|
|
} else if (i == 6) { |
|
|
|
str = "巡检开始时间"; |
|
|
|
} else if (i == 7) { |
|
|
|
str = simpleDateFormat.format(reportInfoVO.getMission().getExecutionStartTime()); |
|
|
|
font.setStyle(Font.NORMAL); |
|
|
|
} else if (i == 8) { |
|
|
|
str = "巡检结束时间"; |
|
|
|
}else if (i == 9) { |
|
|
|
str = simpleDateFormat.format(reportInfoVO.getMission().getExecutionEndTime()); |
|
|
|
font.setStyle(Font.NORMAL); |
|
|
|
} else if (i == 10) { |
|
|
|
str = "问题数量"; |
|
|
|
} else { |
|
|
|
Integer questionCount = reportInfoVO.getQuestionCount(); |
|
|
|
str = ObjectUtil.isNotEmpty(questionCount)?questionCount.toString():"0"; |
|
|
|
font.setStyle(Font.NORMAL); |
|
|
|
} |
|
|
|
|
|
|
|
Paragraph p = new Paragraph(str, font); |
|
|
|
cell.add(p); |
|
|
|
table2.addCell(cell); |
|
|
|
} |
|
|
|
wordUtils.getDocument().add(table2); |
|
|
|
log.info("巡检信息写入完成"); |
|
|
|
|
|
|
|
List<QuestionTypeCountVO> questionTypeInfo = reportInfoVO.getQuestionTypeInfo(); |
|
|
|
Map<String, Integer> questionCount=new HashMap<>(); |
|
|
|
for (QuestionTypeCountVO questionTypeCountVO : questionTypeInfo) { |
|
|
|
questionCount.put(questionTypeCountVO.getType(),questionTypeCountVO.getQuantity()); |
|
|
|
} |
|
|
|
|
|
|
|
if(questionTypeInfo.size()>0) { |
|
|
|
wordUtils.insertTitlePatternThird("三:巡检结果", WordUtilsOld.rtfGsBt3); |
|
|
|
Table table3 = new Table(2);//生成一表格 |
|
|
|
table3.setOffset(1f); |
|
|
|
int[] width3 = {1, 1}; |
|
|
|
table3.setWidths(width3);//设置系列所占比例 |
|
|
|
table3.setWidth(100); |
|
|
|
table3.setAutoFillEmptyCells(true); |
|
|
|
table3.setAlignment(Element.ALIGN_CENTER);//居中显示 |
|
|
|
table3.setAlignment(Element.ALIGN_MIDDLE);//垂直居中显示 |
|
|
|
|
|
|
|
for (int i = 0; i < 10; i++) { |
|
|
|
Cell cell = new Cell(); |
|
|
|
String str; |
|
|
|
cell.setVerticalAlignment(Element.ALIGN_CENTER); |
|
|
|
cell.setHorizontalAlignment(Element.ALIGN_CENTER); |
|
|
|
Font font = new Font(); |
|
|
|
font.setSize(10.5f); |
|
|
|
font.setStyle(Font.BOLD); |
|
|
|
if (i == 0) { |
|
|
|
str = "巡检内容"; |
|
|
|
} else if (i == 1) { |
|
|
|
str = "巡检检查结果"; |
|
|
|
} else if (i == 2) { |
|
|
|
str = "林场问题图斑"; |
|
|
|
} else if (i == 3) { |
|
|
|
if(questionCount.containsKey("002000")){ |
|
|
|
str = questionCount.get("002000").toString().trim(); |
|
|
|
font.setStyle(Font.NORMAL); |
|
|
|
}else{ |
|
|
|
str = "0"; |
|
|
|
font.setStyle(Font.NORMAL); |
|
|
|
} |
|
|
|
} else if (i == 4) { |
|
|
|
str = "病死树"; |
|
|
|
} else if (i == 5) { |
|
|
|
if(questionCount.containsKey("002001")){ |
|
|
|
str = questionCount.get("002001").toString().trim(); |
|
|
|
font.setStyle(Font.NORMAL); |
|
|
|
}else{ |
|
|
|
str = "0"; |
|
|
|
font.setStyle(Font.NORMAL); |
|
|
|
} |
|
|
|
} else if (i == 6) { |
|
|
|
str = "人员活动"; |
|
|
|
} else if (i == 7) { |
|
|
|
if(questionCount.containsKey("002003")){ |
|
|
|
str = questionCount.get("002003").toString().trim(); |
|
|
|
font.setStyle(Font.NORMAL); |
|
|
|
}else{ |
|
|
|
str = "0"; |
|
|
|
font.setStyle(Font.NORMAL); |
|
|
|
} |
|
|
|
} else if (i == 8) { |
|
|
|
str = "火灾隐患"; |
|
|
|
} else{ |
|
|
|
if(questionCount.containsKey("002004")){ |
|
|
|
str = questionCount.get("002004").toString().trim(); |
|
|
|
font.setStyle(Font.NORMAL); |
|
|
|
}else{ |
|
|
|
str = "0"; |
|
|
|
font.setStyle(Font.NORMAL); |
|
|
|
} |
|
|
|
} |
|
|
|
Paragraph p = new Paragraph(str, font); |
|
|
|
cell.add(p); |
|
|
|
table3.addCell(cell); |
|
|
|
} |
|
|
|
wordUtils.getDocument().add(table3); |
|
|
|
} |
|
|
|
|
|
|
|
log.info("巡检结果写入完成"); |
|
|
|
if (reportInfoVO.getQuestionReportList().size() > 0) { |
|
|
|
wordUtils.insertTitlePatternThird("四:问题清单", WordUtilsOld.rtfGsBt3); |
|
|
|
log.info("报告标题四成功"); |
|
|
|
for (int i = 0; i < reportInfoVO.getQuestionReportList().size(); i++) { |
|
|
|
Table table4 = new Table(2);//生成一表格 |
|
|
|
table4.setOffset(1f); |
|
|
|
int[] width4 = {1, 2}; |
|
|
|
table4.setWidths(width4);//设置系列所占比例 |
|
|
|
table4.setWidth(100); |
|
|
|
table4.setAutoFillEmptyCells(true); |
|
|
|
table4.setAlignment(Element.ALIGN_LEFT);//居中显示 |
|
|
|
table4.setAlignment(Element.ALIGN_MIDDLE);//垂直居中显示 |
|
|
|
//查询处理数据 |
|
|
|
List<QuestionHandleVO> questionHandleList = questionHandleMapper.getList(reportInfoVO.getQuestionReportList().get(i).getId()); |
|
|
|
for (int j = 0; j < 15; j++) { |
|
|
|
Cell cell = new Cell(); |
|
|
|
String str = ""; |
|
|
|
Font font = new Font(); |
|
|
|
font.setSize(10.5f); |
|
|
|
cell.setVerticalAlignment(Element.ALIGN_CENTER); |
|
|
|
if (j == 0) { |
|
|
|
font.setSize(12); |
|
|
|
str = " 问题" + (i + 1); |
|
|
|
cell.add(new Paragraph(str, font)); |
|
|
|
cell.setColspan(2); |
|
|
|
font.setStyle(Font.BOLD); |
|
|
|
} else if (j == 1) { |
|
|
|
str = " 坐标"; |
|
|
|
cell.add(new Paragraph(str, font)); |
|
|
|
} else if (j == 2) { |
|
|
|
str = reportInfoVO.getQuestionReportList().get(i).getLng() + "," + reportInfoVO.getQuestionReportList().get(i).getLat(); |
|
|
|
cell.add(new Paragraph(str, font)); |
|
|
|
} else if (j == 3) { |
|
|
|
str = " 问题描述"; |
|
|
|
cell.add(new Paragraph(str, font)); |
|
|
|
} else if (j == 4) { |
|
|
|
str = reportInfoVO.getQuestionReportList().get(i).getQuestionDesc(); |
|
|
|
cell.add(new Paragraph(str, font)); |
|
|
|
} else if (j == 5) { |
|
|
|
str = " 问题图片"; |
|
|
|
cell.add(new Paragraph(str, font)); |
|
|
|
} else if (j == 6) { |
|
|
|
Image image = null; |
|
|
|
String url = reportInfoVO.getQuestionReportList().get(i).getFileMarkerUrl(); |
|
|
|
if (new UrlResource(url).exists()) { |
|
|
|
try { |
|
|
|
image = Image.getInstance(Base64.getDecoder().decode(ImgTypeConvert.requestUrlToBase64(url))); |
|
|
|
image.setAlignment(Image.ALIGN_CENTER); |
|
|
|
image.scalePercent(100); //依照比例缩放 |
|
|
|
image.setAbsolutePosition(0, 0); |
|
|
|
image.scaleToFit(300, 300);//自定义大 |
|
|
|
cell.add(image); |
|
|
|
}catch (Exception e){ |
|
|
|
log.info("图片获取失败!"); |
|
|
|
e.printStackTrace(); |
|
|
|
cell.add(new Paragraph("")); |
|
|
|
} |
|
|
|
} else { |
|
|
|
log.error("图片不存在!" + url); |
|
|
|
} |
|
|
|
}else if (j == 7) { |
|
|
|
str = " 处理人员"; |
|
|
|
cell.add(new Paragraph(str, font)); |
|
|
|
}else if (j == 8) { |
|
|
|
if(StringUtils.isNotEmpty(questionHandleList)){ |
|
|
|
str = questionHandleList.get(0).getHandlerUserName(); |
|
|
|
} |
|
|
|
cell.add(new Paragraph(str, font)); |
|
|
|
}else if (j == 9) { |
|
|
|
str = " 处理时间"; |
|
|
|
cell.add(new Paragraph(str, font)); |
|
|
|
}else if (j == 10) { |
|
|
|
if(StringUtils.isNotEmpty(questionHandleList)){ |
|
|
|
String handlerTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, questionHandleList.get(0).getHandlerTime()); |
|
|
|
str = handlerTime; |
|
|
|
} |
|
|
|
cell.add(new Paragraph(str, font)); |
|
|
|
}else if (j == 11) { |
|
|
|
str = " 处理描述"; |
|
|
|
cell.add(new Paragraph(str, font)); |
|
|
|
}else if (j == 12) { |
|
|
|
if(StringUtils.isNotEmpty(questionHandleList)){ |
|
|
|
str = questionHandleList.get(0).getHandlerResult(); |
|
|
|
} |
|
|
|
cell.add(new Paragraph(str, font)); |
|
|
|
}else if (j == 13) { |
|
|
|
str = " 处理图片"; |
|
|
|
cell.add(new Paragraph(str, font)); |
|
|
|
}else if (j == 14) { |
|
|
|
Image image = null; |
|
|
|
String handlerImage = questionHandleList.get(0).getHandlerImage(); |
|
|
|
|
|
|
|
//拼接图片域名 |
|
|
|
String[] imgHanders = new String[0]; |
|
|
|
if(StringUtils.isNotEmpty(handlerImage)){ |
|
|
|
imgHanders = handlerImage.split(","); |
|
|
|
for (int h = 0; h < imgHanders.length; h++) { |
|
|
|
imgHanders[h] = CommonConfig.imageURL + imgHanders[h]; |
|
|
|
} |
|
|
|
} |
|
|
|
if (new UrlResource(imgHanders[0]).exists()) { |
|
|
|
try { |
|
|
|
image = Image.getInstance(Base64.getDecoder().decode(ImgTypeConvert.requestUrlToBase64(imgHanders[0]))); |
|
|
|
image.setAlignment(Image.ALIGN_CENTER); |
|
|
|
image.scalePercent(100); //依照比例缩放 |
|
|
|
image.setAbsolutePosition(0, 0); |
|
|
|
image.scaleToFit(300, 300);//自定义大 |
|
|
|
cell.add(image); |
|
|
|
}catch (Exception e){ |
|
|
|
log.info("图片获取失败!"); |
|
|
|
e.printStackTrace(); |
|
|
|
cell.add(new Paragraph("")); |
|
|
|
} |
|
|
|
} else { |
|
|
|
log.error("图片不存在!" + imgHanders[0]); |
|
|
|
} |
|
|
|
} |
|
|
|
table4.addCell(cell); |
|
|
|
} |
|
|
|
wordUtils.getDocument().add(table4); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
wordUtils.closeDocument(); |
|
|
|
log.info("问题清单写入完成"); |
|
|
|
}catch (Exception e){ |
|
|
|
log.info("异常信息:{}",e.getMessage()); |
|
|
|
e.printStackTrace(); |
|
|
|
}finally { |
|
|
|
wordUtils.closeDocument(); |
|
|
|
} |
|
|
|
return UploadFileConfig.docDownLoad+"/lc/doc/"+fileName; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |