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,182 +205,186 @@ public class ReportToWordController { ...@@ -205,182 +205,186 @@ 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(); //段落 第三段 举报信息补充
XWPFRun runSupplement = paragraphSupplement.createRun(); XWPFParagraph paragraphSupplement = document.createParagraph();
runSupplement.setText("举报信息补充"); XWPFRun runSupplement = paragraphSupplement.createRun();
runSupplement.setColor("696969"); runSupplement.setText("举报信息补充");
runSupplement.setFontSize(16); runSupplement.setColor("696969");
runSupplement.setFontSize(16);
//换行
XWPFParagraph newLine4 = document.createParagraph(); //换行
XWPFRun paragraphRun4 = newLine4.createRun(); XWPFParagraph newLine4 = document.createParagraph();
paragraphRun4.setText("\r"); XWPFRun paragraphRun4 = newLine4.createRun();
paragraphRun4.setText("\r");
//举报信息补充表格
XWPFTable supplementInfoTable = document.createTable(); //举报信息补充表格
//去表格边框 XWPFTable supplementInfoTable = document.createTable();
supplementInfoTable.getCTTbl().getTblPr().unsetTblBorders(); //去表格边框
//列宽自动分割 supplementInfoTable.getCTTbl().getTblPr().unsetTblBorders();
CTTblWidth supplementInfoTableWidth = supplementInfoTable.getCTTbl().addNewTblPr().addNewTblW(); //列宽自动分割
supplementInfoTableWidth.setType(STTblWidth.AUTO); CTTblWidth supplementInfoTableWidth = supplementInfoTable.getCTTbl().addNewTblPr().addNewTblW();
supplementInfoTableWidth.setW(BigInteger.valueOf(9072)); supplementInfoTableWidth.setType(STTblWidth.AUTO);
supplementInfoTableWidth.setW(BigInteger.valueOf(9072));
//表格第一行
XWPFTableRow supplementTitle = supplementInfoTable.getRow(0); //表格第一行
supplementTitle.getCell(0).setText("标题:"); XWPFTableRow supplementTitle = supplementInfoTable.getRow(0);
supplementTitle.addNewTableCell().setText(reportEntity.getSupplementTitle()==null?"":reportEntity.getSupplementTitle()); supplementTitle.getCell(0).setText("标题:");
//表格第二行 supplementTitle.addNewTableCell().setText(reportEntity.getSupplementTitle() == null ? "" : reportEntity.getSupplementTitle());
XWPFTableRow supplementCompany = supplementInfoTable.createRow(); //表格第二行
supplementCompany.getCell(0).setText("被举报公司:"); XWPFTableRow supplementCompany = supplementInfoTable.createRow();
supplementCompany.getCell(1).setText(reportEntity.getSupplementCompany() == null ? "" : reportEntity.getSupplementCompany()); supplementCompany.getCell(0).setText("被举报公司:");
//表格第三行 supplementCompany.getCell(1).setText(reportEntity.getSupplementCompany() == null ? "" : reportEntity.getSupplementCompany());
XWPFTableRow supplementDepartment = supplementInfoTable.createRow(); //表格第三行
supplementDepartment.getCell(0).setText("被举报部门:"); XWPFTableRow supplementDepartment = supplementInfoTable.createRow();
supplementDepartment.getCell(1).setText(reportEntity.getSupplementDepartment()==null?"":reportEntity.getSupplementDepartment()); supplementDepartment.getCell(0).setText("被举报部门:");
//表格第四行 supplementDepartment.getCell(1).setText(reportEntity.getSupplementDepartment() == null ? "" : reportEntity.getSupplementDepartment());
XWPFTableRow supplementType = supplementInfoTable.createRow(); //表格第四行
supplementType.getCell(0).setText("业务类型:"); XWPFTableRow supplementType = supplementInfoTable.createRow();
String supplement_type = reportEntity.getSupplementType(); supplementType.getCell(0).setText("业务类型:");
if (StringUtils.isNotBlank(supplement_type)) { String supplement_type = reportEntity.getSupplementType();
if (supplement_type.equals("1")) { if (StringUtils.isNotBlank(supplement_type)) {
supplement_type = "营销"; if (supplement_type.equals("1")) {
} else if (supplement_type.equals("2")) { supplement_type = "营销";
supplement_type = "工程"; } else if (supplement_type.equals("2")) {
} else if (supplement_type.equals("3")) { supplement_type = "工程";
supplement_type = "成本"; } else if (supplement_type.equals("3")) {
} else if (supplement_type.equals("4")) { supplement_type = "成本";
supplement_type = "招采"; } else if (supplement_type.equals("4")) {
} else if (supplement_type.equals("5")) { supplement_type = "招采";
supplement_type = "人力"; } else if (supplement_type.equals("5")) {
} else if (supplement_type.equals("6")) { supplement_type = "人力";
supplement_type = "物业"; } else if (supplement_type.equals("6")) {
} else if (supplement_type.equals("7")) { supplement_type = "物业";
supplement_type = "投诉"; } else if (supplement_type.equals("7")) {
supplement_type = "投诉";
}
} else {
supplement_type = "";
} }
} else { supplementType.getCell(1).setText(supplement_type);
supplement_type = ""; //表格第五行
} XWPFTableRow supplementArea = supplementInfoTable.createRow();
supplementType.getCell(1).setText(supplement_type); supplementArea.getCell(0).setText("被举报区域:");
//表格第五行 String supplement_area = reportEntity.getSupplementArea();
XWPFTableRow supplementArea = supplementInfoTable.createRow(); if (StringUtils.isNotBlank(supplement_area)) {
supplementArea.getCell(0).setText("被举报区域:"); if (supplement_area.equals("North China")) {
String supplement_area = reportEntity.getSupplementArea(); supplement_area = "华北区域公司";
if (StringUtils.isNotBlank(supplement_area)) { } else if (supplement_area.equals("BeiJing")) {
if (supplement_area.equals("North China")) { supplement_area = "北京区域公司";
supplement_area = "华北区域公司"; } else if (supplement_area.equals("ShangHai")) {
} else if (supplement_area.equals("BeiJing")) { supplement_area = "上海区域公司";
supplement_area = "北京区域公司"; } else if (supplement_area.equals("SouthWest")) {
} else if (supplement_area.equals("ShangHai")) { supplement_area = "西南区域公司";
supplement_area = "上海区域公司"; } else if (supplement_area.equals("SouthEast")) {
} else if (supplement_area.equals("SouthWest")) { supplement_area = "东南区域公司";
supplement_area = "西南区域公司"; } else if (supplement_area.equals("Central China")) {
} else if (supplement_area.equals("SouthEast")) { supplement_area = "华中区域公司";
supplement_area = "东南区域公司"; } else if (supplement_area.equals("GuangShen")) {
} else if (supplement_area.equals("Central China")) { supplement_area = "广深区域公司";
supplement_area = "华中区域公司"; } else if (supplement_area.equals("Hainan")) {
} else if (supplement_area.equals("GuangShen")) { supplement_area = "海南区域公司";
supplement_area = "广深区域公司"; } else if (supplement_area.equals("Group")) {
} else if (supplement_area.equals("Hainan")) { supplement_area = "集团本部";
supplement_area = "海南区域公司"; }
} else if (supplement_area.equals("Group")) { } else {
supplement_area = "集团本部"; supplement_area = "";
} }
} else { supplementArea.getCell(1).setText(supplement_area);
supplement_area = ""; //表格第六行
} XWPFTableRow supplementContent = supplementInfoTable.createRow();
supplementArea.getCell(1).setText(supplement_area); supplementContent.getCell(0).setText("内容:");
//表格第六行 supplementContent.getCell(1).setText(reportEntity.getSupplementContent() == null ? "" : reportEntity.getSupplementContent());
XWPFTableRow supplementContent = supplementInfoTable.createRow(); //表格 附件行
supplementContent.getCell(0).setText("内容:"); //获取附件列表
supplementContent.getCell(1).setText(reportEntity.getSupplementContent()==null?"":reportEntity.getSupplementContent()); ReportAttachmentEntity supplementAttachmentBean = new ReportAttachmentEntity();
//表格 附件行 supplementAttachmentBean.setReportId(reportEntity.getId());
//获取附件列表 supplementAttachmentBean.setAttachmentType("1");
ReportAttachmentEntity supplementAttachmentBean = new ReportAttachmentEntity(); List<ReportAttachmentEntity> list1 = reportService.getAttachmentInfo(supplementAttachmentBean);
supplementAttachmentBean.setReportId(reportEntity.getId());
supplementAttachmentBean.setAttachmentType("1"); if (list1 != null && list1.size() != 0) {
List<ReportAttachmentEntity> list1 = reportService.getAttachmentInfo(supplementAttachmentBean); for (int i = 0; i < list1.size(); i++) {
XWPFTableRow reportAttachment = supplementInfoTable.createRow();
if (list1 != null && list1.size() != 0) { reportAttachment.getCell(0).setText("附件:");
for (int i = 0;i < list1.size();i++) { reportAttachment.getCell(1).setText(list1.get(i).getAttachmentPath());
XWPFTableRow reportAttachment = supplementInfoTable.createRow(); }
reportAttachment.getCell(0).setText("附件:");
reportAttachment.getCell(1).setText(list1.get(i).getAttachmentPath());
} }
} if (list1.size() > 1) {
if (list1.size() > 1) { mergeCellsVertically(supplementInfoTable, 0, 6, 6 + list1.size() - 1);
mergeCellsVertically(supplementInfoTable, 0, 6, 6 + list1.size() - 1);
}
this.setCellWidth(supplementInfoTable);
supplementInfoTable.setCellMargins(0, 100, 0, 100);
//两个表格之间加个换行
XWPFParagraph newLine5 = document.createParagraph();
XWPFRun paragraphRun5 = newLine5.createRun();
paragraphRun5.setText("\r");
//段落 第四段 处理结果
XWPFParagraph paragraphResult = document.createParagraph();
XWPFRun runResult = paragraphResult.createRun();
runResult.setText("处理结果");
runResult.setColor("696969");
runResult.setFontSize(16);
//换行
XWPFParagraph newLine7 = document.createParagraph();
XWPFRun paragraphRun7 = newLine7.createRun();
paragraphRun7.setText("\r");
//举报信息补充表格
XWPFTable resultInfoTable = document.createTable();
//去表格边框
resultInfoTable.getCTTbl().getTblPr().unsetTblBorders();
//列宽自动分割
CTTblWidth resultInfoTableWidth = resultInfoTable.getCTTbl().addNewTblPr().addNewTblW();
resultInfoTableWidth.setType(STTblWidth.AUTO);
resultInfoTableWidth.setW(BigInteger.valueOf(9072));
//表格第一行
XWPFTableRow dealPersonName = resultInfoTable.getRow(0);
dealPersonName.getCell(0).setText("处理人:");
dealPersonName.addNewTableCell().setText(reportEntity.getDealPersonName()==null?"":reportEntity.getDealPersonName());
//表格 附件行
//获取附件列表
ReportAttachmentEntity dealAttachmentBean = new ReportAttachmentEntity();
dealAttachmentBean.setReportId(reportEntity.getId());
dealAttachmentBean.setAttachmentType("2");
List<ReportAttachmentEntity> list2 = reportService.getAttachmentInfo(dealAttachmentBean);
if (list2 != null && list2.size() != 0) {
for (int i = 0;i < list2.size();i++) {
XWPFTableRow reportAttachment = resultInfoTable.createRow();
reportAttachment.getCell(0).setText("附件:");
reportAttachment.getCell(1).setText(list2.get(i).getAttachmentPath());
} }
this.setCellWidth(supplementInfoTable);
supplementInfoTable.setCellMargins(0, 100, 0, 100);
//两个表格之间加个换行
XWPFParagraph newLine5 = document.createParagraph();
XWPFRun paragraphRun5 = newLine5.createRun();
paragraphRun5.setText("\r");
} }
if (list2.size() > 1) {
mergeCellsVertically(resultInfoTable, 0, 1, 1 + list2.size() - 1);
}
this.setCellWidth(resultInfoTable);
resultInfoTable.setCellMargins(0, 100, 0, 100);
//表格第三行 if (reportEntity.getReportStatus().equals("2")) {
XWPFTableRow dealResult = resultInfoTable.createRow(); //段落 第四段 处理结果
dealResult.getCell(0).setText("处理结论:"); XWPFParagraph paragraphResult = document.createParagraph();
String deal_result = reportEntity.getDealResult(); XWPFRun runResult = paragraphResult.createRun();
if (StringUtils.isNotBlank(deal_result)) { runResult.setText("处理结果");
if (deal_result.equals("1")) { runResult.setColor("696969");
deal_result = "投诉"; runResult.setFontSize(16);
} else if (deal_result.equals("2")) {
deal_result = "举报无效"; //换行
} else if (deal_result.equals("3")) { XWPFParagraph newLine7 = document.createParagraph();
deal_result = "举报属实"; XWPFRun paragraphRun7 = newLine7.createRun();
paragraphRun7.setText("\r");
//举报信息补充表格
XWPFTable resultInfoTable = document.createTable();
//去表格边框
resultInfoTable.getCTTbl().getTblPr().unsetTblBorders();
//列宽自动分割
CTTblWidth resultInfoTableWidth = resultInfoTable.getCTTbl().addNewTblPr().addNewTblW();
resultInfoTableWidth.setType(STTblWidth.AUTO);
resultInfoTableWidth.setW(BigInteger.valueOf(9072));
//表格第一行
XWPFTableRow dealPersonName = resultInfoTable.getRow(0);
dealPersonName.getCell(0).setText("处理人:");
dealPersonName.addNewTableCell().setText(reportEntity.getDealPersonName() == null ? "" : reportEntity.getDealPersonName());
//表格 附件行
//获取附件列表
ReportAttachmentEntity dealAttachmentBean = new ReportAttachmentEntity();
dealAttachmentBean.setReportId(reportEntity.getId());
dealAttachmentBean.setAttachmentType("2");
List<ReportAttachmentEntity> list2 = reportService.getAttachmentInfo(dealAttachmentBean);
if (list2 != null && list2.size() != 0) {
for (int i = 0; i < list2.size(); i++) {
XWPFTableRow reportAttachment = resultInfoTable.createRow();
reportAttachment.getCell(0).setText("附件:");
reportAttachment.getCell(1).setText(list2.get(i).getAttachmentPath());
}
} }
} else { if (list2.size() > 1) {
deal_result = ""; mergeCellsVertically(resultInfoTable, 0, 1, 1 + list2.size() - 1);
}
this.setCellWidth(resultInfoTable);
resultInfoTable.setCellMargins(0, 100, 0, 100);
//表格第三行
XWPFTableRow dealResult = resultInfoTable.createRow();
dealResult.getCell(0).setText("处理结论:");
String deal_result = reportEntity.getDealResult();
if (StringUtils.isNotBlank(deal_result)) {
if (deal_result.equals("1")) {
deal_result = "投诉";
} else if (deal_result.equals("2")) {
deal_result = "举报无效";
} else if (deal_result.equals("3")) {
deal_result = "举报属实";
}
} else {
deal_result = "";
}
dealResult.getCell(1).setText(deal_result);
this.setCellWidth(basicInfoTable);
} }
dealResult.getCell(1).setText(deal_result);
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