Commit d79e6b73 by java-lixy

保存附件地址乱码

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