|
|
@@ -12,10 +12,7 @@ import com.tuoheng.admin.entity.domain.Report; |
|
|
|
import com.tuoheng.admin.entity.domain.ThMission; |
|
|
|
import com.tuoheng.admin.entity.request.ReportRequest; |
|
|
|
import com.tuoheng.admin.entity.vo.*; |
|
|
|
import com.tuoheng.admin.enums.MarkTypeEnum; |
|
|
|
import com.tuoheng.admin.enums.QuestionStatusEnum; |
|
|
|
import com.tuoheng.admin.enums.ReportStatusEnum; |
|
|
|
import com.tuoheng.admin.enums.UpdateOrCreateEnum; |
|
|
|
import com.tuoheng.admin.enums.*; |
|
|
|
import com.tuoheng.admin.mapper.ReportMapper; |
|
|
|
import com.tuoheng.admin.mapper.ThInspectionMapper; |
|
|
|
import com.tuoheng.admin.mapper.ThMissionMapper; |
|
|
@@ -25,6 +22,7 @@ import com.tuoheng.admin.service.IThInspectionService; |
|
|
|
import com.tuoheng.admin.utils.WeatherUtil; |
|
|
|
import com.tuoheng.admin.utils.WordUtilsOld; |
|
|
|
import com.tuoheng.common.common.BaseServiceImpl; |
|
|
|
import com.tuoheng.common.config.CommonConfig; |
|
|
|
import com.tuoheng.common.config.UploadFileConfig; |
|
|
|
import com.tuoheng.common.exception.ServiceException; |
|
|
|
import com.tuoheng.common.utils.DateUtils; |
|
|
@@ -32,9 +30,11 @@ import com.tuoheng.common.utils.JsonResult; |
|
|
|
import com.tuoheng.common.utils.StringUtils; |
|
|
|
import com.tuoheng.system.service.impl.UserServiceImpl; |
|
|
|
import com.tuoheng.system.utils.ShiroUtils; |
|
|
|
import io.swagger.models.auth.In; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.core.io.UrlResource; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
@@ -234,9 +234,10 @@ public class ReportServiceImpl extends BaseServiceImpl<ReportMapper, Report> imp |
|
|
|
|
|
|
|
SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
try { |
|
|
|
if(!f.exists()||f.length()<1000) { |
|
|
|
f.delete(); |
|
|
|
f.createNewFile(); |
|
|
|
if(f.exists()){ |
|
|
|
f.delete(); |
|
|
|
f.createNewFile(); |
|
|
|
} |
|
|
|
wordUtils.openDocument(filePath); |
|
|
|
wordUtils.getDocument().setPageSize(PageSize.A4); |
|
|
|
wordUtils.getDocument().setMargins(71f, 71f, 72f, 72f); |
|
|
@@ -253,14 +254,15 @@ public class ReportServiceImpl extends BaseServiceImpl<ReportMapper, Report> imp |
|
|
|
table.setAlignment(Element.ALIGN_LEFT);//居中显示 |
|
|
|
for (int i = 0; i < 6; i++) { |
|
|
|
Cell cell = new Cell(); |
|
|
|
String str = null; |
|
|
|
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 = "责任单位";cell.setColspan(6); |
|
|
|
str = "责任单位"; |
|
|
|
font.setStyle(Font.NORMAL); |
|
|
|
} else if (i == 1) { |
|
|
|
str = reportInfoVO.getCompany(); |
|
|
|
} else if (i == 2) { |
|
|
@@ -283,7 +285,7 @@ public class ReportServiceImpl extends BaseServiceImpl<ReportMapper, Report> imp |
|
|
|
wordUtils.insertTitlePatternThird("二:巡检信息", WordUtilsOld.rtfGsBt3); |
|
|
|
Table table2 = new Table(2);//生成一表格 |
|
|
|
table2.setOffset(1f); |
|
|
|
int[] width2 = {1, 1, 1, 1, 1, 1}; |
|
|
|
int[] width2 = {1, 1}; |
|
|
|
table2.setWidths(width2);//设置系列所占比例 |
|
|
|
table2.setWidth(100); |
|
|
|
table2.setAutoFillEmptyCells(true); |
|
|
@@ -293,7 +295,7 @@ public class ReportServiceImpl extends BaseServiceImpl<ReportMapper, Report> imp |
|
|
|
|
|
|
|
for (int i = 0; i < 12; i++) { |
|
|
|
Cell cell = new Cell(); |
|
|
|
String str = null; |
|
|
|
String str; |
|
|
|
cell.setVerticalAlignment(Element.ALIGN_LEFT); |
|
|
|
cell.setHorizontalAlignment(Element.ALIGN_CENTER); |
|
|
|
Font font = new Font(); |
|
|
@@ -324,6 +326,7 @@ public class ReportServiceImpl extends BaseServiceImpl<ReportMapper, Report> imp |
|
|
|
str = "巡检结束时间"; |
|
|
|
}else if (i == 9) { |
|
|
|
str = simpleDateFormat.format(reportInfoVO.getMission().getExecutionEndTime()); |
|
|
|
font.setStyle(Font.NORMAL); |
|
|
|
} else if (i == 10) { |
|
|
|
str = "问题数量"; |
|
|
|
} else { |
|
|
@@ -338,39 +341,157 @@ public class ReportServiceImpl extends BaseServiceImpl<ReportMapper, Report> imp |
|
|
|
} |
|
|
|
wordUtils.getDocument().add(table2); |
|
|
|
|
|
|
|
List<QuestionTypeCountVO> questionTypeInfo = reportInfoVO.getQuestionTypeInfo(); |
|
|
|
Map<String, Integer> questionCount=new HashMap<>(); |
|
|
|
for (QuestionTypeCountVO questionTypeCountVO : questionTypeInfo) { |
|
|
|
questionCount.put(questionTypeCountVO.getType(),questionTypeCountVO.getQuantity()); |
|
|
|
} |
|
|
|
|
|
|
|
wordUtils.insertTitlePatternThird("三:巡检结果", WordUtilsOld.rtfGsBt3); |
|
|
|
Table table3 = new Table(5);//生成一表格 |
|
|
|
table3.setOffset(1f); |
|
|
|
int[] width3 = {1,2, 3, 14, 3}; |
|
|
|
table3.setWidths(width3);//设置系列所占比例 |
|
|
|
table3.setWidth(100); |
|
|
|
table3.setAutoFillEmptyCells(true); |
|
|
|
// table3.setAlignment(Element.ALIGN_CENTER);//居中显示 |
|
|
|
// table3.setAlignment(Element.ALIGN_MIDDLE);//垂直居中显示 |
|
|
|
int cellSize = reportInfoVO.getQuestionTypeInfo().size() * 2 + 2; |
|
|
|
for (int i = 0; i < cellSize; i++) { |
|
|
|
Cell cell = new Cell(); |
|
|
|
String str = null; |
|
|
|
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 = "巡检监测结果";cell.setColspan(2); |
|
|
|
} else if (i == 2) { str = "巡检内容"; |
|
|
|
} else if (i == 3) { str = "巡检监测结果"; |
|
|
|
} else if (i == 4) { str = "一";cell.setRowspan(7); |
|
|
|
} else if (i == 5) { str = "水面";cell.setRowspan(7); |
|
|
|
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("LC001")){ |
|
|
|
str = questionCount.get("LC001").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("LC002")){ |
|
|
|
str = questionCount.get("LC002").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("LC003")){ |
|
|
|
str = questionCount.get("LC003").toString().trim(); |
|
|
|
font.setStyle(Font.NORMAL); |
|
|
|
}else{ |
|
|
|
str = "0"; |
|
|
|
font.setStyle(Font.NORMAL); |
|
|
|
} |
|
|
|
} else if (i == 8) { |
|
|
|
str = "火灾隐患"; |
|
|
|
} else{ |
|
|
|
if(questionCount.containsKey("LC004")){ |
|
|
|
str = questionCount.get("LC004").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); |
|
|
|
} |
|
|
|
|
|
|
|
if (reportInfoVO.getQuestionReportList().size() > 0) { |
|
|
|
wordUtils.insertTitlePatternThird("四:问题清单", WordUtilsOld.rtfGsBt3); |
|
|
|
log.info("报告标题四成功"); |
|
|
|
// wordUtils.getDocument().add(new Paragraph("")); |
|
|
|
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);//垂直居中显示 |
|
|
|
for (int j = 0; j < 7; j++) { |
|
|
|
Cell cell = new Cell(); |
|
|
|
//cell.setVerticalAlignment(Element.ALIGN_LEFT); |
|
|
|
//cell.setHorizontalAlignment(Element.ALIGN_CENTER); |
|
|
|
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); |
|
|
|
//cell.setVerticalAlignment(Element.ALIGN_LEFT); |
|
|
|
} 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{ |
|
|
|
Image image = null; |
|
|
|
//String url = CommonConfig.imageURL + reportInfoVO.getQuestionReportList().get(i).getFileMarkerUrl(); |
|
|
|
String url = reportInfoVO.getQuestionReportList().get(i).getFileMarkerUrl(); |
|
|
|
if (new UrlResource(url).exists()) { |
|
|
|
image = Image.getInstance(url); |
|
|
|
image.setAlignment(Image.ALIGN_CENTER); |
|
|
|
image.scalePercent(100); //依照比例缩放 |
|
|
|
image.setAbsolutePosition(400, 600); |
|
|
|
image.scaleToFit(300, 300);//自定义大 |
|
|
|
} else { |
|
|
|
log.error("图片不存在!" + url); |
|
|
|
} |
|
|
|
if (new UrlResource(url).exists()) { |
|
|
|
cell.add(image); |
|
|
|
} else { |
|
|
|
cell.add(new Paragraph("")); |
|
|
|
} |
|
|
|
} |
|
|
|
table4.addCell(cell); |
|
|
|
|
|
|
|
} |
|
|
|
wordUtils.getDocument().add(table4); |
|
|
|
} |
|
|
|
Paragraph p = new Paragraph(str, font); |
|
|
|
cell.add(p); |
|
|
|
table3.addCell(cell); |
|
|
|
} |
|
|
|
wordUtils.getDocument().add(table3); |
|
|
|
|
|
|
|
wordUtils.closeDocument(); |
|
|
|
} |
|
|
|
|
|
|
|
//清空缓存 |
|
|
|
response.reset(); |
|
|
|
// 定义浏览器响应表头,并定义下载名 |