|
|
|
@ -6,9 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import jnpf.config.ConfigValueUtil;
|
|
|
|
|
import jnpf.mobilePort.utils.ExportPdf;
|
|
|
|
|
import jnpf.mobilePort.utils.MultipartFileDto;
|
|
|
|
|
import jnpf.paymentdoc.entity.PaymentdocEntity;
|
|
|
|
|
import jnpf.paymentdoc.entity.PaymentdocItem0Entity;
|
|
|
|
|
import jnpf.paymentdoc.entity.PaymentdocItem1Entity;
|
|
|
|
@ -26,15 +24,17 @@ import jnpf.supplier.service.SupplierService;
|
|
|
|
|
import jnpf.util.ServletUtil;
|
|
|
|
|
import jnpf.util.StringUtil;
|
|
|
|
|
import jnpf.util.UserProvider;
|
|
|
|
|
import lombok.Cleanup;
|
|
|
|
|
import org.apache.http.entity.ContentType;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.io.*;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.io.BufferedOutputStream;
|
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
@ -362,46 +362,49 @@ public class PaymentdocServiceImpl extends ServiceImpl<PaymentdocMapper, Payment
|
|
|
|
|
return paymentdocItem2Service.list(queryWrapper);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private ConfigValueUtil configValueUtil;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void getPaymentDocPdf(String id) {
|
|
|
|
|
public void getPaymentDocPdf(String id) throws IOException {
|
|
|
|
|
List<PaymentdocItem2Entity> item2Entities = this.GetPaymentdocItem2List(id);
|
|
|
|
|
List<Map<String, Object>> paymentDocNodeInfo = paymentdocMapper.getPaymentDocNodeInfo(id);
|
|
|
|
|
String templateFilePath = configValueUtil.getTemplateFilePath() ;
|
|
|
|
|
// String templateFilePath = configValueUtil.getTemplateFilePath() +"paymentDocPdf//";
|
|
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
|
|
|
map.put("reportList",paymentDocNodeInfo);
|
|
|
|
|
byte[] bytes = null;
|
|
|
|
|
ByteArrayOutputStream out = null;
|
|
|
|
|
ByteArrayOutputStream out = null;
|
|
|
|
|
ExportPdf exportPdf = new ExportPdf();
|
|
|
|
|
// word模板
|
|
|
|
|
try {
|
|
|
|
|
out = exportPdf.createPdf(map, "paymentDoc.ftl", "/templates/export");
|
|
|
|
|
bytes = out.toByteArray();
|
|
|
|
|
out.close();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
bytes = out.toByteArray();
|
|
|
|
|
String fileName = "2023年3月30日.pdf";
|
|
|
|
|
// fileName = URLEncoder.encode(fileName, "utf-8");
|
|
|
|
|
|
|
|
|
|
// 存在本地文件中
|
|
|
|
|
String fileName = "城市矿产请示.pdf";
|
|
|
|
|
|
|
|
|
|
MultipartFile file = null;
|
|
|
|
|
HttpServletResponse response = ServletUtil.getResponse();
|
|
|
|
|
response.reset();
|
|
|
|
|
String excelTitle = fileName;
|
|
|
|
|
String filen = null;
|
|
|
|
|
try {
|
|
|
|
|
@Cleanup InputStream inputStream = new ByteArrayInputStream(bytes);
|
|
|
|
|
file = new MultipartFileDto(ContentType.APPLICATION_OCTET_STREAM.toString(), inputStream);
|
|
|
|
|
// FileUtil.upFile(file, templateFilePath+"/wc/", fileName);
|
|
|
|
|
File f = new File(templateFilePath, fileName);
|
|
|
|
|
|
|
|
|
|
//将上传的文件存储到指定位置
|
|
|
|
|
file.transferTo(f);
|
|
|
|
|
filen = URLEncoder.encode(excelTitle, "UTF-8").replaceAll("\\+", "%20");
|
|
|
|
|
} catch (UnsupportedEncodingException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
// 设置response的Header
|
|
|
|
|
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + filen );
|
|
|
|
|
response.setContentType("application/x-download;charset=utf-8");
|
|
|
|
|
BufferedOutputStream toClient = null;
|
|
|
|
|
try {
|
|
|
|
|
toClient = new BufferedOutputStream(response.getOutputStream());
|
|
|
|
|
toClient.write(out.toByteArray());
|
|
|
|
|
toClient.flush();
|
|
|
|
|
toClient.close();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.warn("pdf文件生成成功!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|