提交 ae7747c3 authored 作者: 133's avatar 133

[清退 FILE] 修改代码 以及添加了生成单据、word

上级 ffa39774
...@@ -65,6 +65,11 @@ ...@@ -65,6 +65,11 @@
<artifactId>xmlworker</artifactId> <artifactId>xmlworker</artifactId>
<version>5.5.8</version> <version>5.5.8</version>
</dependency> </dependency>
<dependency>
<groupId>com.deepoove</groupId>
<artifactId>poi-tl</artifactId>
<version>1.5.0</version>
</dependency>
</dependencies> </dependencies>
......
...@@ -6,6 +6,7 @@ import com.itextpdf.text.Image; ...@@ -6,6 +6,7 @@ import com.itextpdf.text.Image;
import com.itextpdf.text.PageSize; import com.itextpdf.text.PageSize;
import com.itextpdf.text.pdf.PdfWriter; import com.itextpdf.text.pdf.PdfWriter;
import com.tykj.dev.config.swagger.AutoDocument; import com.tykj.dev.config.swagger.AutoDocument;
import com.tykj.dev.device.file.entity.DocumentDevice;
import com.tykj.dev.device.file.entity.Documents; import com.tykj.dev.device.file.entity.Documents;
import com.tykj.dev.device.file.entity.FileRet; import com.tykj.dev.device.file.entity.FileRet;
import com.tykj.dev.device.file.service.UseReportFIleService; import com.tykj.dev.device.file.service.UseReportFIleService;
...@@ -16,10 +17,7 @@ import lombok.extern.slf4j.Slf4j; ...@@ -16,10 +17,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest; import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.multipart.MultipartRequest; import org.springframework.web.multipart.MultipartRequest;
...@@ -59,10 +57,44 @@ public class FileController { ...@@ -59,10 +57,44 @@ public class FileController {
@ApiOperation(value = "生成单据") @ApiOperation(value = "生成单据")
@PostMapping("/printDocuments") @PostMapping("/printDocuments")
public ResponseEntity printDocuments(@RequestBody Documents documents) throws IOException, DocumentException { public ResponseEntity printDocuments(@RequestBody Documents documents) throws IOException, DocumentException {
String[] content = JavaToPdfHtmlFreeMarker.freeMarkerRender(documents); String[] content = JavaToPdfHtmlFreeMarker.freeMarkerRender(documents,url+"htmlModel/");
log.info("[file] 调用了生成出入单据对接口");
return ResponseEntity.ok(JavaToPdfHtmlFreeMarker.createPdf(content,url,preview)); return ResponseEntity.ok(JavaToPdfHtmlFreeMarker.createPdf(content,url,preview));
} }
/**
* 生成单据
* @return
*/
@ApiOperation(value = "生成单据1")
@GetMapping("/printDocuments1")
public ResponseEntity printDocuments(HttpServletResponse response) throws IOException, DocumentException {
Documents documents=new Documents();
documents.setNumber("NO:第221321134号");
documents.setReceiveUnit("杭州机要");
documents.setReplyNum("123123123131");
documents.setSenderUnit("浙江省");
documents.setTitle("密码装备清退单");
List<DocumentDevice> documentDevices=new ArrayList<>();
for (int i=0;i<20;i++){
DocumentDevice documentDevice=new DocumentDevice();
documentDevice.setCount(i);
documentDevice.setModel("MM001");
documentDevice.setRemark("备注");
documentDevice.setApplicationField("省一级");
documentDevice.setDeviceSerialNumber("asdq1231232");
documentDevice.setProductionSerialNumber("12312312312");
documentDevice.setParts("密码机");
documentDevice.setCategory("装备");
documentDevice.setSecurityClassification("机密");
documentDevices.add(documentDevice);
}
documents.setDocumentDevices(documentDevices);
String[] content = JavaToPdfHtmlFreeMarker.freeMarkerRender(documents,url+"htmlModel/");
showPdf(response,JavaToPdfHtmlFreeMarker.createPdf(content,url,preview).getFilePath());
return ResponseEntity.ok("ok");
}
/** /**
...@@ -115,7 +147,7 @@ public class FileController { ...@@ -115,7 +147,7 @@ public class FileController {
@ApiOperation(value = "上传图片转pdf") @ApiOperation(value = "上传图片转pdf")
@PostMapping("/print/pdf/{type}") @PostMapping("/print/pdf/{type}")
public ResponseEntity fileUpload(HttpServletRequest request, @PathVariable int type) throws IOException, DocumentException { public ResponseEntity fileUpload(HttpServletRequest request, @PathVariable int type) throws IOException, DocumentException {
log.info("触发图片转pdf的接口"); log.info("{}触发图片转pdf的接口");
List<MultipartFile> multipartFiles = ((MultipartHttpServletRequest) request).getFiles("file"); List<MultipartFile> multipartFiles = ((MultipartHttpServletRequest) request).getFiles("file");
log.info("数量{}",multipartFiles.size()); log.info("数量{}",multipartFiles.size());
File file1 = new File(url + "print/"); File file1 = new File(url + "print/");
...@@ -172,7 +204,6 @@ public class FileController { ...@@ -172,7 +204,6 @@ public class FileController {
private FileRet fileUpload(MultipartFile file) { private FileRet fileUpload(MultipartFile file) {
String originalFilename = file.getOriginalFilename(); String originalFilename = file.getOriginalFilename();
System.out.println(originalFilename);
File file1 = new File(url); File file1 = new File(url);
if (!file1.exists()) { if (!file1.exists()) {
file1.mkdirs(); file1.mkdirs();
...@@ -230,7 +261,6 @@ public class FileController { ...@@ -230,7 +261,6 @@ public class FileController {
private FileRet fileUpload1(MultipartFile file) { private FileRet fileUpload1(MultipartFile file) {
String originalFilename = file.getOriginalFilename(); String originalFilename = file.getOriginalFilename();
System.out.println(originalFilename);
File file1 = new File(url); File file1 = new File(url);
if (!file1.exists()) { if (!file1.exists()) {
file1.mkdirs(); file1.mkdirs();
...@@ -286,5 +316,17 @@ public class FileController { ...@@ -286,5 +316,17 @@ public class FileController {
return new FileRet(originalFilename, url + newName, preview + newName); return new FileRet(originalFilename, url + newName, preview + newName);
} }
private static void showPdf( HttpServletResponse response, String fileName) throws IOException{
response.setContentType("application/pdf");
FileInputStream in = new FileInputStream(new File(fileName));
OutputStream out = response.getOutputStream();
byte[] b = new byte[1024];
while ((in.read(b))!=-1) {
out.write(b);
}
out.flush();
in.close();
out.close();
}
} }
...@@ -2,6 +2,7 @@ package com.tykj.dev.device.file.service.Impl; ...@@ -2,6 +2,7 @@ package com.tykj.dev.device.file.service.Impl;
import com.tykj.dev.device.file.entity.WrodParameter; import com.tykj.dev.device.file.entity.WrodParameter;
import com.tykj.dev.device.file.service.UseReportFIleService; import com.tykj.dev.device.file.service.UseReportFIleService;
import com.tykj.dev.device.file.util.WordUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.poi.xwpf.usermodel.ParagraphAlignment; import org.apache.poi.xwpf.usermodel.ParagraphAlignment;
import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.apache.poi.xwpf.usermodel.XWPFDocument;
...@@ -9,10 +10,13 @@ import org.apache.poi.xwpf.usermodel.XWPFParagraph; ...@@ -9,10 +10,13 @@ import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.apache.poi.xwpf.usermodel.XWPFRun; import org.apache.poi.xwpf.usermodel.XWPFRun;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ResourceUtils;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.*; import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID; import java.util.UUID;
/** /**
...@@ -32,76 +36,22 @@ public class UseReportFIleServiceImpl implements UseReportFIleService { ...@@ -32,76 +36,22 @@ public class UseReportFIleServiceImpl implements UseReportFIleService {
@Override @Override
public void findToFileService(WrodParameter wrodParameter, HttpServletResponse response, HttpServletRequest httpServletRequest) throws IOException { public void findToFileService(WrodParameter wrodParameter, HttpServletResponse response, HttpServletRequest httpServletRequest) throws IOException {
XWPFDocument doc = new XWPFDocument();// 创建Word文件 Map<String, Object> params = new HashMap<>();
XWPFParagraph p = doc.createParagraph();// 新建一个段落 // 渲染文本
// p.setAlignment(ParagraphAlignment.CENTER);// 设置段落的对齐方式 params.put("title1",wrodParameter.getTitle1());
// p.setBorderBottom(Borders.DOUBLE);//设置下边框 params.put("title2",wrodParameter.getTitle2());
// p.setBorderTop(Borders.DOUBLE);//设置上边框 params.put("total",wrodParameter.getTotal());
// p.setBorderRight(Borders.DOUBLE);//设置右边框 params.put("comfirm",wrodParameter.getComfirmCheck());
// p.setBorderLeft(Borders.DOUBLE);//设置左边框 params.put("unitName",wrodParameter.getUnitsName());
p.setAlignment(ParagraphAlignment.CENTER);
XWPFRun title1 = p.createRun();//创建段落文本
title1.setText(wrodParameter.getTitle1());
title1.setBold(true);//设置为粗体
// r.setColor("FF0000");
p = doc.createParagraph(); params.put("time",wrodParameter.getTime());
p.setAlignment(ParagraphAlignment.CENTER);// 新建一个段落
XWPFRun title2 = p.createRun();
title2.setText(wrodParameter.getTitle2());
p = doc.createParagraph();
p.setIndentationFirstLine(100);
p.setSpacingBeforeLines(50);
XWPFRun z = p.createRun();
z.setText("根据相关规定要求,我省/本单位辖区范围内本年度装备使用情况统计如下:");
//总的统计内容
p = doc.createParagraph();
p.setIndentationFirstLine(100);
p.setSpacingBeforeLines(50);
XWPFRun title3 = p.createRun();
title3.setText(wrodParameter.getTotal());
//自查统计内容
p = doc.createParagraph();
p.setIndentationFirstLine(100);
p.setSpacingBeforeLines(50);
XWPFRun title4 = p.createRun();
title4.setText(wrodParameter.getComfirmCheck());
//核查统计内容
p = doc.createParagraph();
p.setIndentationFirstLine(100);
p.setSpacingBeforeLines(50);
// p.setSpacingAfterLines(150);
XWPFRun title5 = p.createRun();
title5.setText(wrodParameter.getSelfCheck());
p = doc.createParagraph();
p.setIndentationFirstLine(100);
p.setSpacingBeforeLines(50);
// p.setSpacingAfterLines(150);
XWPFRun c = p.createRun();
c.setText("装备使用过程中未发现装备丢失、报废、泄密等事件,装备运行情况良好,符合实际业务需求。");
//单位
p = doc.createParagraph();
XWPFRun title6 = p.createRun();
title6.setText("专管员签字: " + wrodParameter.getUnitsName());
//时间
p = doc.createParagraph();
p.setAlignment(ParagraphAlignment.RIGHT);
XWPFRun title7 = p.createRun();
title7.setText(wrodParameter.getTime());
String fileName = wrodParameter.getTitle1() + ".doc"; String fileName = wrodParameter.getTitle1() + ".doc";
url = url + UUID.randomUUID().toString().replace("-", "") + ".doc"; String templatePath = ResourceUtils.getURL("classpath:").getPath()+"docxModel.docx";
FileOutputStream out = new FileOutputStream(url); url=url+"report/";
doc.write(out); String uuidName=UUID.randomUUID().toString().replace("-", "") + ".doc";
out.close(); String fileUrl= WordUtil.createWord(templatePath,url,uuidName,params);
response.setContentType("application/x-download"); response.setContentType("application/x-download");
try { try {
...@@ -116,7 +66,7 @@ public class UseReportFIleServiceImpl implements UseReportFIleService { ...@@ -116,7 +66,7 @@ public class UseReportFIleServiceImpl implements UseReportFIleService {
BufferedInputStream bs = null; BufferedInputStream bs = null;
byte[] buffer = new byte[1024]; byte[] buffer = new byte[1024];
try { try {
is = new FileInputStream(new File(url)); is = new FileInputStream(new File(fileUrl));
bs = new BufferedInputStream(is); bs = new BufferedInputStream(is);
os = response.getOutputStream(); os = response.getOutputStream();
int i = bs.read(buffer); int i = bs.read(buffer);
...@@ -150,7 +100,6 @@ public class UseReportFIleServiceImpl implements UseReportFIleService { ...@@ -150,7 +100,6 @@ public class UseReportFIleServiceImpl implements UseReportFIleService {
@Override @Override
public void download(String url, String name, HttpServletResponse response, HttpServletRequest httpServletRequest) { public void download(String url, String name, HttpServletResponse response, HttpServletRequest httpServletRequest) {
String fileName = name; String fileName = name;
log.info("---------");
// response.setHeader("content-type", "application/octet-stream"); // response.setHeader("content-type", "application/octet-stream");
response.setContentType("application/x-download"); response.setContentType("application/x-download");
try { try {
......
...@@ -12,6 +12,7 @@ import com.tykj.dev.device.file.entity.FileRet; ...@@ -12,6 +12,7 @@ import com.tykj.dev.device.file.entity.FileRet;
import freemarker.template.Configuration; import freemarker.template.Configuration;
import freemarker.template.Template; import freemarker.template.Template;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.ResourceUtils;
import org.xhtmlrenderer.pdf.ITextFontResolver; import org.xhtmlrenderer.pdf.ITextFontResolver;
import org.xhtmlrenderer.pdf.ITextRenderer; import org.xhtmlrenderer.pdf.ITextRenderer;
...@@ -48,7 +49,7 @@ public class JavaToPdfHtmlFreeMarker { ...@@ -48,7 +49,7 @@ public class JavaToPdfHtmlFreeMarker {
freemarkerCfg =new Configuration(); freemarkerCfg =new Configuration();
//freemarker的模板目录 //freemarker的模板目录
try { try {
freemarkerCfg.setDirectoryForTemplateLoading(new File("/Users/zjm/Downloads/equip/dev-file/src/main/resources/")); freemarkerCfg.setDirectoryForTemplateLoading(new File(ResourceUtils.getURL("classpath:").getPath()));
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -81,7 +82,7 @@ public class JavaToPdfHtmlFreeMarker { ...@@ -81,7 +82,7 @@ public class JavaToPdfHtmlFreeMarker {
documentDevices.add(documentDevice); documentDevices.add(documentDevice);
} }
documents.setDocumentDevices(documentDevices); documents.setDocumentDevices(documentDevices);
String[] content = JavaToPdfHtmlFreeMarker.freeMarkerRender(documents); String[] content = JavaToPdfHtmlFreeMarker.freeMarkerRender(documents,"/Users/zjm/code/test-tu/htmlModel/");
JavaToPdfHtmlFreeMarker.createPdf(content,"/Users/zjm/code/test-tu/","12313"); JavaToPdfHtmlFreeMarker.createPdf(content,"/Users/zjm/code/test-tu/","12313");
} }
...@@ -93,9 +94,10 @@ public class JavaToPdfHtmlFreeMarker { ...@@ -93,9 +94,10 @@ public class JavaToPdfHtmlFreeMarker {
Long startTime = System.currentTimeMillis(); Long startTime = System.currentTimeMillis();
Document document = new Document(); Document document = new Document();
String name=UUID.randomUUID().toString()+".pdf"; String name=UUID.randomUUID().toString()+".pdf";
String pdfPath=path+"documents/"+name;
PdfCopy pdfCopy = null; //创建一个新文件 PdfCopy pdfCopy = null; //创建一个新文件
try { try {
pdfCopy = new PdfCopy(document, new FileOutputStream(path+name)); pdfCopy = new PdfCopy(document, new FileOutputStream(pdfPath));
document.open(); document.open();
for (String htmlFile : htmlFiles) { for (String htmlFile : htmlFiles) {
if (htmlFile != null) { if (htmlFile != null) {
...@@ -118,7 +120,7 @@ public class JavaToPdfHtmlFreeMarker { ...@@ -118,7 +120,7 @@ public class JavaToPdfHtmlFreeMarker {
} }
Long endTime = System.currentTimeMillis(); Long endTime = System.currentTimeMillis();
System.out.print("Itext parse Html to Pdf End -> " + (endTime - startTime)); System.out.print("Itext parse Html to Pdf End -> " + (endTime - startTime));
return new FileRet("", path + "print/" + name, preview + "print/" + name); return new FileRet("", pdfPath, preview +"documents/"+ name);
} catch (IOException | DocumentException e) { } catch (IOException | DocumentException e) {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
...@@ -132,10 +134,10 @@ public class JavaToPdfHtmlFreeMarker { ...@@ -132,10 +134,10 @@ public class JavaToPdfHtmlFreeMarker {
/** /**
* freemarker渲染html * freemarker渲染html
*/ */
public static String[] freeMarkerRender(Documents documents) { public static String[] freeMarkerRender(Documents documents,String htmlPath) {
Writer out = new StringWriter(); Writer out = new StringWriter();
String [] strings=new String[100000]; String [] strings=new String[100000];
Integer index=0; int index=0;
try { try {
// 获取模板,并设置编码方式 // 获取模板,并设置编码方式
Template template = freemarkerCfg.getTemplate("bill.html"); Template template = freemarkerCfg.getTemplate("bill.html");
...@@ -165,7 +167,7 @@ public class JavaToPdfHtmlFreeMarker { ...@@ -165,7 +167,7 @@ public class JavaToPdfHtmlFreeMarker {
endPoint = totalNum; endPoint = totalNum;
} }
String htmlname="/Users/zjm/code/Template/"+ UUID.randomUUID().toString()+".html"; String htmlname=htmlPath+ UUID.randomUUID().toString()+".html";
// 合并数据模型与模板 // 合并数据模型与模板
FileWriter fileWriter = new FileWriter(new File(htmlname)); FileWriter fileWriter = new FileWriter(new File(htmlname));
template.process(toMap(documents,list.subList(startPoint, endPoint),MAP.get(i)),fileWriter); template.process(toMap(documents,list.subList(startPoint, endPoint),MAP.get(i)),fileWriter);
...@@ -175,7 +177,6 @@ public class JavaToPdfHtmlFreeMarker { ...@@ -175,7 +177,6 @@ public class JavaToPdfHtmlFreeMarker {
pageNum++; pageNum++;
} }
} }
return strings; return strings;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
......
package com.tykj.dev.device.file.util;
import com.deepoove.poi.XWPFTemplate;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
/**
* @author zjm
* @version 1.0.0
* @ClassName util.java
* @Description TODO
* @createTime 2021年01月24日 14:19:00
*/
public class WordUtil {
/**
* 根据模板填充内容生成word
* 调用方法参考下面的main方法,详细文档参考官方文档
* Poi-tl模板引擎官方文档:http://deepoove.com/poi-tl/
*
* @param templatePath word模板文件路径
* @param fileDir 生成的文件存放地址
* @param fileName 生成的文件名,不带格式。假如要生成abc.docx,则fileName传入abc即可
* @param paramMap 替换的参数集合
* @return 生成word成功返回生成的文件的路径,失败返回空字符串
*/
public static String createWord(String templatePath, String fileDir, String fileName, Map<String, Object> paramMap) {
// 生成的word格式
String formatSuffix = ".docx";
// 拼接后的文件名
fileName = fileName + formatSuffix;
// 生成的文件的存放路径
if (!fileDir.endsWith("/")) {
fileDir = fileDir + File.separator;
}
File dir = new File(fileDir);
if (!dir.exists()) {
dir.mkdirs();
}
String filePath = fileDir + fileName;
// 读取模板templatePath并将paramMap的内容填充进模板,即编辑模板+渲染数据
XWPFTemplate template = XWPFTemplate.compile(templatePath).render(paramMap);
try {
// 将填充之后的模板写入filePath
template.writeToFile(filePath);
template.close();
} catch (Exception e) {
e.printStackTrace();
return "";
}
return filePath;
}
public static void main(String[] args) {
Map<String, Object> params = new HashMap<>();
// 渲染文本
params.put("title1","2021年度省机要局装备使用情况报告");
params.put("title2","2021年1月至2021年一月使用");
params.put("total","2021年度本单位总件数11,其中入库总台数0,维修建设");
params.put("comfirm","列装总台数0台,退装总数0台");
params.put("unitName","省机要局");
params.put("time","2021年10月1日");
// 渲染图片
// TODO 渲染其他类型的数据请参考官方文档
String templatePath = "/Users/zjm/code/ty/spring-cloud-study-poi/src/main/resources/人物模板2.docx";
String fileDir = "/Users/zjm/code/ty/spring-cloud-study-poi/src/main/resources/";
String fileName = "zdd2";
String wordPath = WordUtil.createWord(templatePath, fileDir, fileName, params);
System.out.println("生成文档路径:" + wordPath);
}
}
...@@ -291,15 +291,15 @@ ...@@ -291,15 +291,15 @@
<p class="title"> <p class="title">
<div class="main-title"> <div class="main-title">
<span> <span>
密码装备清退单 ${title}
</span> </span>
</div> </div>
<div style="width:100%;text-align:left"> <div style="width:100%;text-align:left">
<div style="text-align:left;display: inline-block; width: 33%" class="number"> <div style="text-align:left;display: inline-block; width: 33%" class="number">
<span class="number">No:第37463473647号</span> <span class="number">${number}</span>
</div> </div>
<div style="text-align:center;display: inline-block; width: 29%" class="number"> <div style="text-align:center;display: inline-block; width: 29%" class="number">
<span >(第一联XXX单位)</span> <span >${ul}</span>
</div> </div>
<div style="text-align:right;display: inline-block; width: 33%" class="number"> <div style="text-align:right;display: inline-block; width: 33%" class="number">
<span>机密</span> <span>机密</span>
...@@ -310,11 +310,11 @@ ...@@ -310,11 +310,11 @@
<div class="line1"> <div class="line1">
<span class="sendTo"> <span class="sendTo">
<span>发往:</span> <span>发往:</span>
<span></span> <span>${receiveUnit}</span>
</span> </span>
<span class="sendNum"> <span class="sendNum">
<span>批复文号:</span> <span>批复文号:</span>
<span></span> <span>${replyNum}</span>
</span> </span>
</div> </div>
<div class="line2 tableList"> <div class="line2 tableList">
...@@ -333,7 +333,7 @@ ...@@ -333,7 +333,7 @@
<span class="left"> <span class="left">
<span> <span>
<span class="label">发件单位:</span> <span class="label">发件单位:</span>
<span class="value"></span> <span class="value">${senderUnit}</span>
</span> </span>
<span> <span>
<span class="label">签发人:</span> <span class="label">签发人:</span>
...@@ -356,7 +356,7 @@ ...@@ -356,7 +356,7 @@
<span class="right"> <span class="right">
<span> <span>
<span class="label">收件单位:</span> <span class="label">收件单位:</span>
<span class="value"></span> <span class="value">${receiveUnit}</span>
</span> </span>
<span> <span>
<span class="label">经办人:</span> <span class="label">经办人:</span>
......
...@@ -6,6 +6,12 @@ import com.tykj.dev.device.sendback.entity.vo.ModelAndTypeVo; ...@@ -6,6 +6,12 @@ import com.tykj.dev.device.sendback.entity.vo.ModelAndTypeVo;
import com.tykj.dev.device.sendback.entity.vo.RepelManagementVo; import com.tykj.dev.device.sendback.entity.vo.RepelManagementVo;
import com.tykj.dev.device.sendback.entity.vo.SendBackOutFormVo; import com.tykj.dev.device.sendback.entity.vo.SendBackOutFormVo;
import com.tykj.dev.device.sendback.service.RepelQueryService; import com.tykj.dev.device.sendback.service.RepelQueryService;
import com.tykj.dev.device.task.service.TaskService;
import com.tykj.dev.device.task.subject.vo.TaskSelectVo;
import com.tykj.dev.device.task.subject.vo.TaskUserVo;
import com.tykj.dev.device.task.utils.TaskUtils;
import com.tykj.dev.misc.utils.PageUtil;
import com.tykj.dev.misc.utils.ResultUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -13,6 +19,7 @@ import org.springframework.http.ResponseEntity; ...@@ -13,6 +19,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* @author zjm * @author zjm
...@@ -29,6 +36,12 @@ public class RepelQueryController { ...@@ -29,6 +36,12 @@ public class RepelQueryController {
@Autowired @Autowired
RepelQueryService repelQueryService; RepelQueryService repelQueryService;
@Autowired
TaskService taskService;
@Autowired
TaskUtils taskUtils;
@GetMapping(value ="/repelTaskStatistical/{taskId}/{billId}") @GetMapping(value ="/repelTaskStatistical/{taskId}/{billId}")
@ApiOperation(value = "省、市清退任务的统计页面详情", notes = "省、市清退任务的统计页面") @ApiOperation(value = "省、市清退任务的统计页面详情", notes = "省、市清退任务的统计页面")
public ResponseEntity findRepelTaskStatisticals(@PathVariable Integer taskId, @PathVariable Integer billId){ public ResponseEntity findRepelTaskStatisticals(@PathVariable Integer taskId, @PathVariable Integer billId){
...@@ -125,9 +138,25 @@ public class RepelQueryController { ...@@ -125,9 +138,25 @@ public class RepelQueryController {
return ResponseEntity.ok(repelQueryService.findRepelListModelNameGroup(modelAndTypeVo)); return ResponseEntity.ok(repelQueryService.findRepelListModelNameGroup(modelAndTypeVo));
} }
/**
* 查询清退单列表
*/
@ApiOperation(value = "查询清退单列表") @ApiOperation(value = "查询清退单列表")
@GetMapping("/getList") @GetMapping("/getList")
public ResponseEntity getList() { public ResponseEntity getList() {
return ResponseEntity.ok(repelQueryService.getList()); return ResponseEntity.ok(repelQueryService.getList());
} }
/**
* 查询清退任务
* @param taskSelectVo
* @return
*/
@ApiOperation(value = "查询清退任务", notes = "可以通过这个接口查询查询清退任务")
@PostMapping(value = "/taskList")
public ResponseEntity selectRepairTasks(@RequestBody TaskSelectVo taskSelectVo){
List<TaskUserVo> taskUserVos = taskService.getManageList(taskSelectVo).stream().filter(taskUserVo -> taskUserVo.getBusinessType()==18||taskUserVo.getBusinessType()==16).collect(Collectors.toList());
return ResultUtil.success(PageUtil.getPerPage(taskSelectVo.getPage(), taskSelectVo.getSize(), taskUtils.orderByTopDesc(taskUserVos), taskSelectVo.getPageable()));
}
} }
...@@ -113,7 +113,6 @@ public class RepelBusinessServiceImpl implements RepelBusinessService { ...@@ -113,7 +113,6 @@ public class RepelBusinessServiceImpl implements RepelBusinessService {
deviceRepel.getModels().forEach(i->{ deviceRepel.getModels().forEach(i->{
modelCounts.add(new ModelCount(i,0)); modelCounts.add(new ModelCount(i,0));
}); });
String model=JacksonUtil.toJSon(modelCounts);
deviceRepel.getTaskScopes().forEach( deviceRepel.getTaskScopes().forEach(
unisId-> { unisId-> {
if (unisId != units.getUnitId()) { if (unisId != units.getUnitId()) {
...@@ -147,9 +146,11 @@ public class RepelBusinessServiceImpl implements RepelBusinessService { ...@@ -147,9 +146,11 @@ public class RepelBusinessServiceImpl implements RepelBusinessService {
deviceRepelDetail.setSendUnit(units.getName()); deviceRepelDetail.setSendUnit(units.getName());
deviceRepelDetail.setId(null); deviceRepelDetail.setId(null);
if (directlUnderUnit.get()&&deviceLibraryDao.existsAllByPackingIdInAndOwnUnitIn(deviceRepel.getFieldingIds(), directlUnderUnitNames)){ if (directlUnderUnit.get()&&deviceLibraryDao.existsAllByPackingIdInAndOwnUnitIn(deviceRepel.getFieldingIds(), directlUnderUnitNames)){
deviceRepel.getModels().forEach(i->{ if (deviceRepel.getRepelStatus()==1) {
modelCounts.add(new ModelCount(i,deviceLibraryDao.countAllByModelAndOwnUnitIn(i,directlUnderUnitNames))); deviceRepel.getModels().forEach(i -> {
modelCounts.add(new ModelCount(i, deviceLibraryDao.countAllByModelAndOwnUnitIn(i, directlUnderUnitNames)));
}); });
}
TaskBto taskBto2 = directlyUnderTask(units.getUnitId(), deviceRepelDetailService.saveDeviceRepelDetail(deviceRepelDetail).getId(), taskBto.getId(),deviceRepel.getTitle()); TaskBto taskBto2 = directlyUnderTask(units.getUnitId(), deviceRepelDetailService.saveDeviceRepelDetail(deviceRepelDetail).getId(), taskBto.getId(),deviceRepel.getTitle());
list.add(new RepelTaskStatistical(deviceRepel1.getId(), taskBto.getId(), taskBto2.getId(), 0, "省直属", JacksonUtil.toJSon(modelCounts), "")); list.add(new RepelTaskStatistical(deviceRepel1.getId(), taskBto.getId(), taskBto2.getId(), 0, "省直属", JacksonUtil.toJSon(modelCounts), ""));
} }
...@@ -158,9 +159,12 @@ public class RepelBusinessServiceImpl implements RepelBusinessService { ...@@ -158,9 +159,12 @@ public class RepelBusinessServiceImpl implements RepelBusinessService {
strings.add(units.getName()); strings.add(units.getName());
if (correspondingLevel.get()&&deviceLibraryDao.existsAllByPackingIdInAndOwnUnitIn(deviceRepel.getFieldingIds(),strings)){ if (correspondingLevel.get()&&deviceLibraryDao.existsAllByPackingIdInAndOwnUnitIn(deviceRepel.getFieldingIds(),strings)){
deviceRepel.getModels().forEach(i->{ if (deviceRepel.getRepelStatus()==1) {
modelCounts.add(new ModelCount(i,deviceLibraryDao.countAllByModelAndOwnUnitIn(i,strings)));
deviceRepel.getModels().forEach(i -> {
modelCounts.add(new ModelCount(i, deviceLibraryDao.countAllByModelAndOwnUnitIn(i, strings)));
}); });
}
TaskBto taskBto1 = oneselfTask(units.getUnitId(),deviceRepelDetailService.saveDeviceRepelDetail(deviceRepelDetail).getId(), taskBto.getId(),deviceRepel.getTitle()); TaskBto taskBto1 = oneselfTask(units.getUnitId(),deviceRepelDetailService.saveDeviceRepelDetail(deviceRepelDetail).getId(), taskBto.getId(),deviceRepel.getTitle());
list.add(new RepelTaskStatistical(deviceRepel1.getId(),taskBto.getId(),taskBto1.getId(),0,"省本级",JacksonUtil.toJSon(modelCounts),"")); list.add(new RepelTaskStatistical(deviceRepel1.getId(),taskBto.getId(),taskBto1.getId(),0,"省本级",JacksonUtil.toJSon(modelCounts),""));
} }
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<title>Document</title>
<style>
body{
font-family:SimHei;
}
/*@page{size:297mm 210mm;}<!-- 设置PDF页面大小,此配置只对生成PDF文件有效,不会对页面显示生效 -->*/
@page {
size:297mm 210mm;//纸张大小A4
/*margin: 0.25in;*/
/*-fs-flow-bottom: "footer";*/
/*-fs-flow-left: "left";*/
/*-fs-flow-right: "right";*/
/*border: thin solid black;*/
/*padding: 1em;*/
}
#footer {
font-size: 90%; font-style: italic;
position: absolute; top: 0; left: 0;
-fs-move-to-flow: "footer";
}
#pagenumber:before {
content: counter(page);
}
#pagecount:before {content: counter(pages);
}
.returnTablePrint{
width: 100%;
height: 100%;
overflow: hidden;
color: #000;
cursor: default;
}
.returnTablePrint .content{
width: 100%;
height: 100%;
/* background: url("../../../assets/img/detailsBg.png") no-repeat; */
/*background-size: 100% 100%;*/
/*padding: 30px;*/
/*box-sizing: border-box;*/
}
.returnTablePrint .content>div{
width: 100%;
height: 100%;
background: #fff;
/* padding: 30px; */
box-sizing: border-box;
}
.returnTablePrint .content>p{
width: 100%;
text-align: center;
font-size: 22px;
font-weight: bold;
color: #4a475d;
}
.returnTablePrint .listWrapper{
/* width: 92%; */
margin: 0 auto;
/* padding: 0px 20px 20px 20px; */
height: calc(100% - 70px);
/*padding: 10px 30px;*/
box-sizing: border-box;
}
.returnTablePrint .list{
/* width: 92%; */
margin: 0 auto;
/* padding: 0px 20px 20px 20px; */
/* height: calc(100% - 75px); */
height:calc(100% - 12px)
}
.returnTablePrint .title{
width: 100%;
font-size: 20px;
text-align: center;
position: relative;
margin: 0 0 15px;
padding:0 20px;
box-sizing: border-box;
}
.returnTablePrint .title span:nth-child(2){
font-size: 28px;
color: #000000;
}
.returnTablePrint .title span:nth-child(2) span{
font-size: 20px;
color: #141414;
}
.returnTablePrint .title .number{
font-size: 20px;
color: #646464;
}
.returnTablePrint .other{
width: 100%;
color: #141414;
font-size: 20px;
margin-top: 20px;
padding-left: 50px;
position: relative;
box-sizing: border-box;
margin-bottom: 20px;
}
.returnTablePrint .other>span span:nth-child(2){
display: inline-block;
margin:0 40px 0 10px;
}
.returnTablePrint .listCon{
height: calc(100% - 90px);
border: 1px solid #7f7f7f;
}
.returnTablePrint .line1{
width: 100%;
font-size: 20px;
box-sizing: border-box;
border-bottom: 1px solid #7f7f7f;
color:#000;
line-height: 60px;
}
.returnTablePrint .line1 .sendTo {
display: inline-block;
width: 49%;
text-indent: 20px;
box-sizing: border-box;
/*padding-left: 20px;*/
}
.returnTablePrint .line1 .sendNum {
display: inline-block;
width: 49%;
box-sizing: border-box;
/*padding-left: 20px;*/
}
.returnTablePrint .line1 .sendTo{
border-right: 1px solid #7f7f7f;
}
.returnTablePrint .line1 .sendTo span:nth-child(2),.returnTablePrint .line1 .sendNum span:nth-child(2){
color: #4a475d;
display: inline-block;
margin-left: 20px;
}
.returnTablePrint .line2{
height: 100%;
/* padding: 20px; */
border-bottom: 1px solid #7f7f7f;
}
.returnTablePrint .tableList{
height: 300px;
}
.returnTablePrint .line2>>>.el-table tbody tr:nth-child(odd) {
background-color:#fff;
}
.returnTablePrint .line2>>>.el-table tbody tr:nth-child(even) {
background-color:#fff;
}
.returnTablePrint .line3{
width: 100%;
/* box-sizing: border-box; */
/*height:150px;*/
/*display: flex;*/
/* height:170px; */
/* padding:20px 0 20px 0; */
}
.returnTablePrint .line3 .left {
display: inline-block;
width: 49%;
box-sizing: border-box;
/*padding-left: 20px;*/
position: relative;
}
.returnTablePrint .line3 .right {
display: inline-block;
width: 50%;
box-sizing: border-box;
/*padding-left: 20px;*/
position: relative;
}
.returnTablePrint .line3 .left{
border-right: 1px solid #7f7f7f;
/*padding-bottom: 40px;*/
}
.returnTablePrint .line3 .left>span {
text-indent: 10px;
}
.returnTablePrint .line3 .left>span,.returnTablePrint .line3 .right>span{
display: block;
margin: 15px 0px;
}
.returnTablePrint .line3 .right{
height: 100%;
}
.returnTablePrint .line3 .left>span>span:nth-child(2),.returnTablePrint .line3 .right>span>span:nth-child(2){
display: inline-block;
margin-left: 20px;
}
.returnTablePrint .line3 i{
display: block;
text-align: right;
position: absolute;
right: 5px;
bottom: 5px;
font-style: normal;
}
.returnTablePrint .line3 .right i{
font-style: normal;
/* right: -10px;
bottom: -60px; */
}
.returnTablePrint .line3 i>span>span{
display: block;
}
.returnTablePrint>>>.el-scrollbar__wrap {
overflow-x: hidden;
margin-bottom:0;
}
.returnTablePrint .checkName span:nth-child(2){
color: #4a475d;
display: inline-block;
margin-left: 20px;
}
.returnTablePrint>>>.el-table tbody .cell{
color: #141414;
}
.returnTablePrint .label{
color: #646464;
font-size: 20px;;
}
.returnTablePrint .value{
color: #000;
font-size: 20px;;
}
.returnTablePrint .main-title {
font-size: 28px;
color: #000000;
margin-bottom: 20px;
text-align: center;
}
.returnTablePrint .footer{
display: flex;
justify-content:flex-end;
padding:0 40px;
box-sizing: border-box;
}
.button-submit{
margin-left:50px;
}
table.altrowstable {
width: 100%;
font-size:20px;
color:#141414;
border-width: 0px;
border-color: #a9c6c9;
border-collapse: collapse;
text-align: center;
/*table-layout: fixed;*/
/*word-break:break-all;*/
}
table.altrowstable th {
border-width: 0px;
padding: 8px;
border-style: solid;
border-color: #a9c6c9;
}
table.altrowstable td {
border-width: 0px;
padding: 8px;
border-style: solid;
border-color: #a9c6c9;
/*word-break:break-all;*/
/*word-wrap : break-word;*/
}
.oddrowcolor{
background-color:#fff;
}
.evenrowcolor{
background-color:#fafafa;
}
</style>
</head>
<body>
<!--<div id="footer" style=""> Page <span id="pagenumber"/> of <span id="pagecount"/> </div>-->
<div class="returnTablePrint">
<div class="content">
<div>
<div class="listWrapper">
<div class="list">
<p class="title">
<div class="main-title">
<span>
${title}
</span>
</div>
<div style="width:100%;text-align:left">
<div style="text-align:left;display: inline-block; width: 33%" class="number">
<span class="number">${number}</span>
</div>
<div style="text-align:center;display: inline-block; width: 29%" class="number">
<span >${ul}</span>
</div>
<div style="text-align:right;display: inline-block; width: 33%" class="number">
<span>机密</span>
</div>
</div>
</p>
<div class="listCon">
<div class="line1">
<span class="sendTo">
<span>发往:</span>
<span>${receiveUnit}</span>
</span>
<span class="sendNum">
<span>批复文号:</span>
<span>${replyNum}</span>
</span>
</div>
<div class="line2 tableList">
<table class="altrowstable" id="alternatecolor">
<tr>
<th>型号</th><th>部件</th><th>类型</th><th>密级</th><th>应用领域</th><th>数量</th><th>装备序列号</th><th>生产序列号</th><th>备注</th>
</tr>
<#list documentDevices as dev>
<tr>
<td>${dev.model}</td><td>${dev.parts}</td><td>${dev.category}</td><td>${dev.securityClassification}</td><td>${dev.applicationField}</td><td>${dev.count}</td><td>${dev.deviceSerialNumber}</td><td>${dev.productionSerialNumber}</td><td>${dev.remark}</td>
</tr>
</#list>
</table>
</div>
<div class="line3">
<span class="left">
<span>
<span class="label">发件单位:</span>
<span class="value">${senderUnit}</span>
</span>
<span>
<span class="label">签发人:</span>
<span class="value"></span>
</span>
<span>
<span class="label">经办人:</span>
<span class="value"></span>
</span>
<i>
<span style="position: relative;color: #646464">
<span style="margin-bottom: 20px;">(公章)</span>
<span><span style="color: #fff;">1234</span><span style="color: #fff;">0121</span><span style="color: #fff;">0232</span></span>
<div style="position: absolute">
<div id="pos0" ></div>
</div>
</span>
</i>
</span>
<span class="right">
<span>
<span class="label">收件单位:</span>
<span class="value">${receiveUnit}</span>
</span>
<span>
<span class="label">经办人:</span>
<span class="value">xxxxxx</span>
</span>
<span>
<span class="label">经办人:</span>
<span class="value"></span>
</span>
<i>
<span style="color: #646464">
<span style="margin-bottom: 20px;">(公章)</span>
<span><span style="color: #fff;">1234</span><span style="color: #fff;">0121</span><span style="color: #fff;">0232</span></span>
</span>
</i>
</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!--<script type="text/javascript">-->
<!--function altRows(id){-->
<!--if(document.getElementsByTagName){-->
<!--var table = document.getElementById(id);-->
<!--var rows = table.getElementsByTagName("tr");-->
<!--for(i = 0; i < rows.length; i++){-->
<!--if(i % 2 == 0){-->
<!--rows[i].className = "evenrowcolor";-->
<!--}else{-->
<!--rows[i].className = "oddrowcolor";-->
<!--}-->
<!--}-->
<!--}-->
<!--}-->
<!--window.onload=function(){-->
<!--altRows('alternatecolor');-->
<!--}-->
<!--</script>-->
</body>
</html>
\ No newline at end of file
...@@ -176,8 +176,9 @@ public class UserServiceImpl implements UserService { ...@@ -176,8 +176,9 @@ public class UserServiceImpl implements UserService {
boolean isName = user.getName().contains(userConditionsVo.getDim()); boolean isName = user.getName().contains(userConditionsVo.getDim());
boolean isSex = user.getSex() != 1 ? "男".contains(userConditionsVo.getDim()) : "女".contains(userConditionsVo.getDim()); boolean isSex = user.getSex() != 1 ? "男".contains(userConditionsVo.getDim()) : "女".contains(userConditionsVo.getDim());
boolean isUnit = unitsService.findById(user.getUnitsId()).getName().contains(userConditionsVo.getDim()); boolean isUnit = unitsService.findById(user.getUnitsId()).getName().contains(userConditionsVo.getDim());
boolean isMobile=user.getMobile()!=null&&user.getMobile().contains(userConditionsVo.getDim());
boolean isPosition = user.getPosition() == 1 ? "领导".contains(userConditionsVo.getDim()) : "专管员".contains(userConditionsVo.getDim()); boolean isPosition = user.getPosition() == 1 ? "领导".contains(userConditionsVo.getDim()) : "专管员".contains(userConditionsVo.getDim());
return isName || isSex || isUnit || isPosition; return isName || isSex || isUnit || isPosition||isMobile;
}else { }else {
return true; return true;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论