|
|
@ -66,12 +66,12 @@ import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.io.ByteArrayOutputStream; |
|
|
|
import java.io.File; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.InputStream; |
|
|
|
import javax.servlet.ServletOutputStream; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.io.*; |
|
|
|
import java.net.HttpURLConnection; |
|
|
|
import java.net.URL; |
|
|
|
import java.net.URLEncoder; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
@ -335,7 +335,7 @@ public class FinPaymentrecordService extends MybatisBaseService<FinPaymentrecord |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<String> createPdf(String sid) { |
|
|
|
public ResultBean createPdf(String sid) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
FinPaymentrecord finPaymentrecord = fetchBySid(sid); |
|
|
|
Map<String, Object> dataMap = new HashMap<String, Object>(); |
|
|
@ -418,7 +418,51 @@ public class FinPaymentrecordService extends MybatisBaseService<FinPaymentrecord |
|
|
|
//生成出门证文件名
|
|
|
|
String pdfName = "预付款申请_" + dateStr + seconds + ".pdf"; |
|
|
|
WordConvertUtils.doc2pdf(wordPath, targetPath, pdfName); |
|
|
|
return rb.success().setData(pdfName); |
|
|
|
HttpServletResponse response = null; |
|
|
|
try { |
|
|
|
download(response,pdfName); |
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
|
|
|
|
public void download(HttpServletResponse response, String path) throws IOException { |
|
|
|
String filePath = fileUploadComponent.getUrlPrefix(); |
|
|
|
File file = null; |
|
|
|
InputStream inputStream = null; |
|
|
|
ServletOutputStream out = null; |
|
|
|
if (path.indexOf(filePath) > -1) { |
|
|
|
path = path.replace(filePath, ""); |
|
|
|
} |
|
|
|
try { |
|
|
|
String realPath = fileUploadComponent.getUploadPath(); |
|
|
|
file = new File(realPath + path); |
|
|
|
inputStream = new FileInputStream(file); |
|
|
|
response.setCharacterEncoding("utf-8"); |
|
|
|
response.setContentType("application/pdf"); |
|
|
|
response.setHeader("content-disposition", "attachment;filename=" |
|
|
|
+ URLEncoder.encode(path, "UTF-8")); |
|
|
|
out = response.getOutputStream(); |
|
|
|
byte[] buffer = new byte[512]; // 缓冲区
|
|
|
|
int bytesToRead = -1; |
|
|
|
// 通过循环将读入的Excel文件的内容输出到浏览器中
|
|
|
|
while ((bytesToRead = inputStream.read(buffer)) != -1) { |
|
|
|
out.write(buffer, 0, bytesToRead); |
|
|
|
} |
|
|
|
out.flush(); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} finally { |
|
|
|
if (inputStream != null) { |
|
|
|
inputStream.close(); |
|
|
|
} |
|
|
|
if (out != null) { |
|
|
|
out.close(); |
|
|
|
} |
|
|
|
if (file != null) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public static String image2Base64(String imgUrl) { |
|
|
|