付款单模板,榜单导入 支持多种类型数据

product
chuang 2 years ago
parent 2ecd9e8553
commit 4b5b00d6e5

@ -84,6 +84,7 @@ public class WebFilterConfig implements WebMvcConfigurer {
list.add("/favicon.ico"); list.add("/favicon.ico");
list.add("/api/info/exportPdf/**"); list.add("/api/info/exportPdf/**");
list.add("/api/info/getPaymentDocPdf/**");
return list; return list;
} }

@ -53,7 +53,7 @@ public class MobilePortController {
* @throws Exception * @throws Exception
*/ */
@GetMapping(value = "/getPaymentDocPdf/{id}", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @GetMapping(value = "/getPaymentDocPdf/{id}", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public void getPaymentDocPdf(HttpServletResponse response,@PathVariable("id") String id) { public void getPaymentDocPdf(HttpServletResponse response,@PathVariable("id") String id) throws IOException {
String idd="410787543580384837"; String idd="410787543580384837";
paymentdocService.getPaymentDocPdf(idd); paymentdocService.getPaymentDocPdf(idd);
} }

@ -7,6 +7,7 @@ import jnpf.paymentdoc.entity.PaymentdocItem1Entity;
import jnpf.paymentdoc.entity.PaymentdocItem2Entity; import jnpf.paymentdoc.entity.PaymentdocItem2Entity;
import jnpf.paymentdoc.model.paymentdoc.PaymentdocPagination; import jnpf.paymentdoc.model.paymentdoc.PaymentdocPagination;
import java.io.IOException;
import java.util.List; import java.util.List;
/** /**
* *
@ -39,5 +40,5 @@ public interface PaymentdocService extends IService<PaymentdocEntity> {
//列表子表数据方法 //列表子表数据方法
void getPaymentDocPdf(String id); void getPaymentDocPdf(String id) throws IOException;
} }

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

@ -1459,7 +1459,12 @@ public class PurchaseorderitemServiceImpl extends ServiceImpl<PurchaseorderitemM
if (model.getPoundDate() != null && !model.getPoundDate().isEmpty() && !model.getPoundDate().equals("null")) { if (model.getPoundDate() != null && !model.getPoundDate().isEmpty() && !model.getPoundDate().equals("null")) {
// model.setCreatorTime(DateUtil.cstFormat(model.getCreatorTime())); // model.setCreatorTime(DateUtil.cstFormat(model.getCreatorTime()));
Date date = new SimpleDateFormat("yyyy.MM.dd").parse(model.getPoundDate()); Date date = null;
if (model.getPoundDate().contains(".")){
date = new SimpleDateFormat("yyyy.MM.dd").parse(model.getPoundDate());
}else if (model.getPoundDate().contains("-")){
date = new SimpleDateFormat("yyyy-MM-dd").parse(model.getPoundDate());
}
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
model.setPoundDate(formatter.format(date)); model.setPoundDate(formatter.format(date));
// 单位 // 单位

Loading…
Cancel
Save