Commit d79e6b73 by java-lixy

保存附件地址乱码

新增转为word文档功能
parent de72a624
...@@ -95,6 +95,8 @@ public class ReportService extends CrudService<ReportDao, ReportEntity> { ...@@ -95,6 +95,8 @@ public class ReportService extends CrudService<ReportDao, ReportEntity> {
if (StringUtils.isNotBlank(fileName)) { if (StringUtils.isNotBlank(fileName)) {
reportAttachmentEntity.setAttachmentName(fileName); reportAttachmentEntity.setAttachmentName(fileName);
} }
int index = path.lastIndexOf("/")+1;
path = path.substring(0, index) + fileName;
reportAttachmentEntity.setAttachmentPath(path); reportAttachmentEntity.setAttachmentPath(path);
File file = new File(reportAttachmentEntity.getAttachmentPath()); File file = new File(reportAttachmentEntity.getAttachmentPath());
long length = file.length(); long length = file.length();
...@@ -165,6 +167,8 @@ public class ReportService extends CrudService<ReportDao, ReportEntity> { ...@@ -165,6 +167,8 @@ public class ReportService extends CrudService<ReportDao, ReportEntity> {
if (StringUtils.isNotBlank(fileName)) { if (StringUtils.isNotBlank(fileName)) {
reportAttachmentEntity.setAttachmentName(fileName); reportAttachmentEntity.setAttachmentName(fileName);
} }
int index = path.lastIndexOf("/")+1;
path = path.substring(0, index) + fileName;
reportAttachmentEntity.setAttachmentPath(path); reportAttachmentEntity.setAttachmentPath(path);
File file = new File(reportAttachmentEntity.getAttachmentPath()); File file = new File(reportAttachmentEntity.getAttachmentPath());
long length = file.length(); long length = file.length();
......
...@@ -57,8 +57,8 @@ public class ReportToWordController { ...@@ -57,8 +57,8 @@ public class ReportToWordController {
if (reportProjectTitle.contains("\\")){ if (reportProjectTitle.contains("\\")){
reportProjectTitle = reportProjectTitle.replace("\\","|"); reportProjectTitle = reportProjectTitle.replace("\\","|");
} }
// FileOutputStream out = new FileOutputStream(GConstants.FILE_UPLOAD_DIR+"pdf/"+reportProjectTitle+"_"+reportEntity.getId()+".pdf"); FileOutputStream out = new FileOutputStream(GConstants.FILE_UPLOAD_DIR+"pdf/"+reportProjectTitle+"_"+reportEntity.getId()+".docx");
FileOutputStream out = new FileOutputStream("D:/1.docx"); // FileOutputStream out = new FileOutputStream("D:/1.docx");
//添加标题 //添加标题
XWPFParagraph titleParagraph = document.createParagraph(); XWPFParagraph titleParagraph = document.createParagraph();
//设置段落居中 //设置段落居中
...@@ -205,6 +205,7 @@ public class ReportToWordController { ...@@ -205,6 +205,7 @@ public class ReportToWordController {
XWPFRun paragraphRun6 = newLine6.createRun(); XWPFRun paragraphRun6 = newLine6.createRun();
paragraphRun6.setText("\r"); paragraphRun6.setText("\r");
if (!reportEntity.getReportStatus().equals("0")) {
//段落 第三段 举报信息补充 //段落 第三段 举报信息补充
XWPFParagraph paragraphSupplement = document.createParagraph(); XWPFParagraph paragraphSupplement = document.createParagraph();
XWPFRun runSupplement = paragraphSupplement.createRun(); XWPFRun runSupplement = paragraphSupplement.createRun();
...@@ -229,7 +230,7 @@ public class ReportToWordController { ...@@ -229,7 +230,7 @@ public class ReportToWordController {
//表格第一行 //表格第一行
XWPFTableRow supplementTitle = supplementInfoTable.getRow(0); XWPFTableRow supplementTitle = supplementInfoTable.getRow(0);
supplementTitle.getCell(0).setText("标题:"); supplementTitle.getCell(0).setText("标题:");
supplementTitle.addNewTableCell().setText(reportEntity.getSupplementTitle()==null?"":reportEntity.getSupplementTitle()); supplementTitle.addNewTableCell().setText(reportEntity.getSupplementTitle() == null ? "" : reportEntity.getSupplementTitle());
//表格第二行 //表格第二行
XWPFTableRow supplementCompany = supplementInfoTable.createRow(); XWPFTableRow supplementCompany = supplementInfoTable.createRow();
supplementCompany.getCell(0).setText("被举报公司:"); supplementCompany.getCell(0).setText("被举报公司:");
...@@ -237,7 +238,7 @@ public class ReportToWordController { ...@@ -237,7 +238,7 @@ public class ReportToWordController {
//表格第三行 //表格第三行
XWPFTableRow supplementDepartment = supplementInfoTable.createRow(); XWPFTableRow supplementDepartment = supplementInfoTable.createRow();
supplementDepartment.getCell(0).setText("被举报部门:"); supplementDepartment.getCell(0).setText("被举报部门:");
supplementDepartment.getCell(1).setText(reportEntity.getSupplementDepartment()==null?"":reportEntity.getSupplementDepartment()); supplementDepartment.getCell(1).setText(reportEntity.getSupplementDepartment() == null ? "" : reportEntity.getSupplementDepartment());
//表格第四行 //表格第四行
XWPFTableRow supplementType = supplementInfoTable.createRow(); XWPFTableRow supplementType = supplementInfoTable.createRow();
supplementType.getCell(0).setText("业务类型:"); supplementType.getCell(0).setText("业务类型:");
...@@ -293,7 +294,7 @@ public class ReportToWordController { ...@@ -293,7 +294,7 @@ public class ReportToWordController {
//表格第六行 //表格第六行
XWPFTableRow supplementContent = supplementInfoTable.createRow(); XWPFTableRow supplementContent = supplementInfoTable.createRow();
supplementContent.getCell(0).setText("内容:"); supplementContent.getCell(0).setText("内容:");
supplementContent.getCell(1).setText(reportEntity.getSupplementContent()==null?"":reportEntity.getSupplementContent()); supplementContent.getCell(1).setText(reportEntity.getSupplementContent() == null ? "" : reportEntity.getSupplementContent());
//表格 附件行 //表格 附件行
//获取附件列表 //获取附件列表
ReportAttachmentEntity supplementAttachmentBean = new ReportAttachmentEntity(); ReportAttachmentEntity supplementAttachmentBean = new ReportAttachmentEntity();
...@@ -302,7 +303,7 @@ public class ReportToWordController { ...@@ -302,7 +303,7 @@ public class ReportToWordController {
List<ReportAttachmentEntity> list1 = reportService.getAttachmentInfo(supplementAttachmentBean); List<ReportAttachmentEntity> list1 = reportService.getAttachmentInfo(supplementAttachmentBean);
if (list1 != null && list1.size() != 0) { if (list1 != null && list1.size() != 0) {
for (int i = 0;i < list1.size();i++) { for (int i = 0; i < list1.size(); i++) {
XWPFTableRow reportAttachment = supplementInfoTable.createRow(); XWPFTableRow reportAttachment = supplementInfoTable.createRow();
reportAttachment.getCell(0).setText("附件:"); reportAttachment.getCell(0).setText("附件:");
reportAttachment.getCell(1).setText(list1.get(i).getAttachmentPath()); reportAttachment.getCell(1).setText(list1.get(i).getAttachmentPath());
...@@ -318,7 +319,9 @@ public class ReportToWordController { ...@@ -318,7 +319,9 @@ public class ReportToWordController {
XWPFParagraph newLine5 = document.createParagraph(); XWPFParagraph newLine5 = document.createParagraph();
XWPFRun paragraphRun5 = newLine5.createRun(); XWPFRun paragraphRun5 = newLine5.createRun();
paragraphRun5.setText("\r"); paragraphRun5.setText("\r");
}
if (reportEntity.getReportStatus().equals("2")) {
//段落 第四段 处理结果 //段落 第四段 处理结果
XWPFParagraph paragraphResult = document.createParagraph(); XWPFParagraph paragraphResult = document.createParagraph();
XWPFRun runResult = paragraphResult.createRun(); XWPFRun runResult = paragraphResult.createRun();
...@@ -343,7 +346,7 @@ public class ReportToWordController { ...@@ -343,7 +346,7 @@ public class ReportToWordController {
//表格第一行 //表格第一行
XWPFTableRow dealPersonName = resultInfoTable.getRow(0); XWPFTableRow dealPersonName = resultInfoTable.getRow(0);
dealPersonName.getCell(0).setText("处理人:"); dealPersonName.getCell(0).setText("处理人:");
dealPersonName.addNewTableCell().setText(reportEntity.getDealPersonName()==null?"":reportEntity.getDealPersonName()); dealPersonName.addNewTableCell().setText(reportEntity.getDealPersonName() == null ? "" : reportEntity.getDealPersonName());
//表格 附件行 //表格 附件行
//获取附件列表 //获取附件列表
ReportAttachmentEntity dealAttachmentBean = new ReportAttachmentEntity(); ReportAttachmentEntity dealAttachmentBean = new ReportAttachmentEntity();
...@@ -352,7 +355,7 @@ public class ReportToWordController { ...@@ -352,7 +355,7 @@ public class ReportToWordController {
List<ReportAttachmentEntity> list2 = reportService.getAttachmentInfo(dealAttachmentBean); List<ReportAttachmentEntity> list2 = reportService.getAttachmentInfo(dealAttachmentBean);
if (list2 != null && list2.size() != 0) { if (list2 != null && list2.size() != 0) {
for (int i = 0;i < list2.size();i++) { for (int i = 0; i < list2.size(); i++) {
XWPFTableRow reportAttachment = resultInfoTable.createRow(); XWPFTableRow reportAttachment = resultInfoTable.createRow();
reportAttachment.getCell(0).setText("附件:"); reportAttachment.getCell(0).setText("附件:");
reportAttachment.getCell(1).setText(list2.get(i).getAttachmentPath()); reportAttachment.getCell(1).setText(list2.get(i).getAttachmentPath());
...@@ -381,6 +384,7 @@ public class ReportToWordController { ...@@ -381,6 +384,7 @@ public class ReportToWordController {
} }
dealResult.getCell(1).setText(deal_result); dealResult.getCell(1).setText(deal_result);
this.setCellWidth(basicInfoTable); this.setCellWidth(basicInfoTable);
}
CTSectPr sectPr = document.getDocument().getBody().addNewSectPr(); CTSectPr sectPr = document.getDocument().getBody().addNewSectPr();
XWPFHeaderFooterPolicy policy = new XWPFHeaderFooterPolicy(document, sectPr); XWPFHeaderFooterPolicy policy = new XWPFHeaderFooterPolicy(document, sectPr);
...@@ -390,7 +394,7 @@ public class ReportToWordController { ...@@ -390,7 +394,7 @@ public class ReportToWordController {
PrintWriter printWriter = response.getWriter(); PrintWriter printWriter = response.getWriter();
response.setContentType("application/json;charset=utf-8"); response.setContentType("application/json;charset=utf-8");
printWriter.write(GConstants.FILE_PREFIX_URL+"pdf/"+reportProjectTitle+"_"+reportEntity.getId()+".pdf"); printWriter.write(GConstants.FILE_PREFIX_URL+"pdf/"+reportProjectTitle+"_"+reportEntity.getId()+".docx");
printWriter.close(); printWriter.close();
} }
......
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
function openDownloadDialog(id){ function openDownloadDialog(id){
if (requestFlag == true){ if (requestFlag == true){
$.ajax({ $.ajax({
url: "${ctx}/report/document?id="+id, url: "${ctx}/report/toWord?id="+id,
dataType: "text", dataType: "text",
traditional: true,//这里设置为true traditional: true,//这里设置为true
cache: false, cache: false,
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
function openDownloadDialog(id){ function openDownloadDialog(id){
if (requestFlag == true){ if (requestFlag == true){
$.ajax({ $.ajax({
url: "${ctx}/report/document?id="+id, url: "${ctx}/report/toWord?id="+id,
dataType: "text", dataType: "text",
traditional: true,//这里设置为true traditional: true,//这里设置为true
cache: false, cache: false,
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
//发邮件 //发邮件
$("#btnMail").click(function () { $("#btnMail").click(function () {
var supplementType = $("#supplementType").find("option:selected").text(); var supplementType = $("#supplementType").find("option:selected").text();
var supplementInformant = $("#supplementInformant").val(); var supplementInformant = "${report.supplementInformant}";
var path = "mailto:?subject=举报核查-"+supplementType+"-"+supplementInformant+"违规操作"; var path = "mailto:?subject=举报核查-"+supplementType+"-"+supplementInformant+"违规操作";
path += "&body=Dear,<br/>附件是举报核查-"+supplementType+"-"+supplementInformant+"违规操作,请核实是否属实。<br/>谢谢!"; path += "&body=Dear,<br/>附件是举报核查-"+supplementType+"-"+supplementInformant+"违规操作,请核实是否属实。<br/>谢谢!";
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
var url = $(this).text(); var url = $(this).text();
path += url; path += url;
}); });
path += "举报人信息</br>"; path += "</br>举报人信息</br>";
path += "姓名:${report.reportPersonName}</br>"; path += "姓名:${report.reportPersonName}</br>";
path += "手机号:${report.reportPersonTel}</br>"; path += "手机号:${report.reportPersonTel}</br>";
path += "Email:${report.reportPersonEmail}</br>"; path += "Email:${report.reportPersonEmail}</br>";
......
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