| | |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.core.io.ClassPathResource; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.net.URLEncoder; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | |
| | | if (Objects.isNull(complaintAuditRecord)) { |
| | | throw new ServiceException("上报申请记录不存在"); |
| | | } |
| | | complaintAuditRecord.setAuditorName(systemUser.getName()); |
| | | complaintAuditRecord.setAuditorPhone(systemUser.getPhone()); |
| | | if (complaintReporAuditDTO.getAuditResult().equals(1)) { |
| | | complaintAuditRecord.setAuditStatus(1); |
| | | complaintAuditRecord.setAuditorId(loginUserInfoVO.getUserId()); |
| | |
| | | String fileName = ""; |
| | | switch (type) { |
| | | case 1: |
| | | fileName = "社区问题单"; |
| | | fileName = "community_question.docx"; |
| | | break; |
| | | case 2: |
| | | fileName = "问题处理单"; |
| | | fileName = "question_handle.docx"; |
| | | if (Objects.nonNull(partyMember)) { |
| | | community = community + "-" + partyMember.getServiceTarget(); |
| | | } |
| | |
| | | if (Objects.nonNull(record)) { |
| | | reportType = record.getReportType(); |
| | | } |
| | | fileName = "协调通知单"; |
| | | fileName = "notice.docx"; |
| | | break; |
| | | } |
| | | Map<String, Object> map = new HashMap<>(); |
| | |
| | | response.setContentType("application/octet-stream"); |
| | | String fileNameEncode = URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20"); |
| | | response.setHeader("Content-disposition", "attachment;filename=\"" + fileNameEncode + ".docx" + "\""); |
| | | String fileTemplateName = FileUtil.getPath() + "template/" + fileName + ".docx"; |
| | | XWPFTemplate.compile(fileTemplateName).render(map).writeAndClose(response.getOutputStream()); |
| | | InputStream resourceAsStream = this.getClass().getResourceAsStream("/template/" + fileName); |
| | | XWPFTemplate.compile(resourceAsStream).render(map).writeAndClose(response.getOutputStream()); |
| | | } |
| | | |
| | | |
| | |
| | | String content = "第一行内容\n第二行内容\n第三行内容"; |
| | | map.put("complaintProgress", content); |
| | | map.put("status", "处理中"); |
| | | XWPFTemplate.compile("F:\\DeskTop\\zhihuishequ\\springcloud_k8s_panzhihuazhihuishequ\\service_sangeshenbian\\src\\main\\resources\\template\\社区问题单.docx").render(map).writeToFile("F:\\DeskTop\\社区.docx"); |
| | | XWPFTemplate.compile("F:\\DeskTop\\zhihuishequ\\springcloud_k8s_panzhihuazhihuishequ\\service_sangeshenbian\\src\\main\\resources\\template\\community_question.docx").render(map).writeToFile("F:\\DeskTop\\社区.docx"); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |