Browse Source

Merge branch 'master' of xwh/kmall-pt-general into master

肖文浩 4 years ago
parent
commit
603695c98d

+ 10 - 1
kmall-admin/src/main/java/com/kmall/admin/controller/exportPDF/ExportPDFController.java

@@ -36,7 +36,7 @@ public class ExportPDFController {
 
     //打印pdf
     @RequestMapping("/printPdf")
-    public ModelAndView printPdf(String head , String type, String sku, String storeId, String headUrl, String prodBarcode, HttpServletResponse response) throws Exception {
+    public ModelAndView printPdf(String head , String type, String sku, String storeId, String headUrl, String prodBarcode,String isPrintRate, HttpServletResponse response) throws Exception {
 
         PDFGoodsDto pdfGoodsDto = goodsService.queryForPDFData(sku, storeId, prodBarcode);
         if (Objects.isNull(pdfGoodsDto)) {
@@ -46,6 +46,13 @@ public class ExportPDFController {
             return null;
         }
 
+        if ("1".equals(isPrintRate) && Objects.isNull(pdfGoodsDto.getStartFax())){
+            response.setContentType("text/html;charset=utf-8");
+            response.getWriter().write("<script>alert('该商品无税率,不可打印,请选择不打印税率或设置商品税率');</script>");
+            response.getWriter().flush();
+            return null;
+        }
+
         String uploadDir="";
         if ("1".equals(head)) {
             Map<String, Object> model = new HashMap<>();
@@ -55,6 +62,7 @@ public class ExportPDFController {
             model.put("fontUrl", fontUrl);
             model.put("uploadDir", uploadDir);
             model.put("headUrl", headUrl);
+            model.put("isPrintRate", isPrintRate);
             return new ModelAndView(new ViewPDF(), model);
         }else if ("0".equals(head)){
             Map<String, Object> model = new HashMap<>();
@@ -63,6 +71,7 @@ public class ExportPDFController {
             model.put("head",head);
             model.put("fontUrl",fontUrl);
             model.put("uploadDir",uploadDir);
+            model.put("isPrintRate", isPrintRate);
             return new ModelAndView(new ViewPDF(), model);
         }else{
             return null;

+ 9 - 9
kmall-admin/src/main/java/com/kmall/admin/utils/pdf/PdfUtil.java

@@ -11,40 +11,40 @@ import java.io.IOException;
 public class PdfUtil {
 
   public void createPDF(Document document, PdfWriter writer, PDFGoodsDto pdfGoodsDto,
-                        String type, String fontUrl, String uploadDir,String head, String headUrl) throws IOException, com.lowagie.text.DocumentException {
+                        String type, String fontUrl, String uploadDir,String head, String headUrl,String isPrintRate) throws IOException, com.lowagie.text.DocumentException {
 
       switch (type){
           case "1":
               PDFWrite pdfWrite = new PDFWrite();
-              pdfWrite.write(document,writer,pdfGoodsDto,fontUrl,uploadDir,headUrl);
+              pdfWrite.write(document,writer,pdfGoodsDto,fontUrl,uploadDir,headUrl,isPrintRate);
               break;
           case "2":
               PDFWrite_2 pdfWrite2 = new PDFWrite_2();
-              pdfWrite2.write(document,writer,pdfGoodsDto,fontUrl,uploadDir,headUrl);
+              pdfWrite2.write(document,writer,pdfGoodsDto,fontUrl,uploadDir,headUrl,isPrintRate);
               break;
           case "4":
               PDFWrite_4 pdfWrite4 = new PDFWrite_4();
-              pdfWrite4.write(document,writer,pdfGoodsDto,fontUrl,uploadDir,headUrl);;
+              pdfWrite4.write(document,writer,pdfGoodsDto,fontUrl,uploadDir,headUrl,isPrintRate);;
               break;
           case "9":
               PDFWrite_9 pdfWrite9 = new PDFWrite_9();
-              pdfWrite9.write(document,writer,pdfGoodsDto,fontUrl,uploadDir,headUrl);
+              pdfWrite9.write(document,writer,pdfGoodsDto,fontUrl,uploadDir,headUrl,isPrintRate);
               break;
           case "12":
               PDFWrite_12 pdfWrite12 = new PDFWrite_12();
-              pdfWrite12.write(document,writer,pdfGoodsDto,fontUrl,uploadDir,headUrl);
+              pdfWrite12.write(document,writer,pdfGoodsDto,fontUrl,uploadDir,headUrl,isPrintRate);
               break;
           case "18":
               PDFWrite_18 pdfWrite18 = new PDFWrite_18();
-              pdfWrite18.write(document,writer,pdfGoodsDto,fontUrl,uploadDir,headUrl);
+              pdfWrite18.write(document,writer,pdfGoodsDto,fontUrl,uploadDir,headUrl,isPrintRate);
               break;
           case "36":
               if ("1".equals(head)) {
                   PDFWrite_36 pdfWrite36 = new PDFWrite_36();
-                  pdfWrite36.write(document,writer,pdfGoodsDto,fontUrl,uploadDir,headUrl);
+                  pdfWrite36.write(document,writer,pdfGoodsDto,fontUrl,uploadDir,headUrl,isPrintRate);
               }else if ("0".equals(head)){
                   PDFWrite_nohead_36 pdfWrite_nohead_36 = new PDFWrite_nohead_36();
-                  pdfWrite_nohead_36.write(document, writer, pdfGoodsDto, fontUrl, uploadDir);
+                  pdfWrite_nohead_36.write(document, writer, pdfGoodsDto, fontUrl, uploadDir,isPrintRate);
               }
               break;
           default:

+ 2 - 1
kmall-admin/src/main/java/com/kmall/admin/utils/pdf/ViewPDF.java

@@ -29,6 +29,7 @@ public class ViewPDF extends AbstractPdfView {
       String uploadDir = (String) model.get("uploadDir");
       String head = (String) model.get("head");
       String headUrl = (String) model.get("headUrl");
-      pdfUtil.createPDF(document,writer,pdfGoodsDto,type,fontUrl,uploadDir,head,headUrl);
+      String isPrintRate = (String) model.get("isPrintRate");
+      pdfUtil.createPDF(document,writer,pdfGoodsDto,type,fontUrl,uploadDir,head,headUrl,isPrintRate);
   }
 }

+ 13 - 10
kmall-admin/src/main/java/com/kmall/admin/utils/pdf/type/PDFWrite.java

@@ -17,7 +17,7 @@ public class PDFWrite {
 
 
     public void write(Document doc, PdfWriter writer, PDFGoodsDto pdfGoodsDto
-            , String fontUrl, String uploadDir, String headUrl) throws IOException, DocumentException {
+            , String fontUrl, String uploadDir, String headUrl,String isPrintRate) throws IOException, DocumentException {
         // 设置字体
         BaseFont bfHei = BaseFont.createFont(fontUrl,BaseFont.IDENTITY_H,BaseFont.NOT_EMBEDDED);
         Font FontChinese11 = new Font(bfHei, 11);
@@ -120,15 +120,18 @@ public class PDFWrite {
         doc.add(blankRow31);
 
         // --------------底部2-------------------------------
-        PdfPTable pdfPTable6 = new PdfPTable(1);
-        font = new Font(bfHei, 26);
-        Paragraph tax = new Paragraph("税率:"+pdfGoodsDto.getStartFax(), font);
-        PdfPCell taxCell = new PdfPCell(tax);
-        taxCell.setBorder(0);
-        taxCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 水平居中
-        taxCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 垂直居中
-        pdfPTable6.addCell(taxCell);
-        doc.add(pdfPTable6);
+        if ("1".equals(isPrintRate)){
+            PdfPTable pdfPTable6 = new PdfPTable(1);
+            font = new Font(bfHei, 26);
+            Paragraph tax = new Paragraph("税率:"+pdfGoodsDto.getStartFax(), font);
+            PdfPCell taxCell = new PdfPCell(tax);
+            taxCell.setBorder(0);
+            taxCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 水平居中
+            taxCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 垂直居中
+            pdfPTable6.addCell(taxCell);
+            doc.add(pdfPTable6);
+        }
+
 
         // --------------空格--------------
         blankRow31 = new Paragraph(18f, " ", FontChinese11);

+ 13 - 10
kmall-admin/src/main/java/com/kmall/admin/utils/pdf/type/PDFWrite_12.java

@@ -15,7 +15,7 @@ public class PDFWrite_12 {
 
 
     public void write(Document doc, PdfWriter writer, PDFGoodsDto pdfGoodsDto
-            , String fontUrl, String uploadDir, String headUrl) throws IOException, DocumentException {
+            , String fontUrl, String uploadDir, String headUrl,String isPrintRate) throws IOException, DocumentException {
 
         // 设置字体
         BaseFont bfHei = BaseFont.createFont(fontUrl,BaseFont.IDENTITY_H,BaseFont.NOT_EMBEDDED);
@@ -31,17 +31,17 @@ public class PDFWrite_12 {
 
         // -----------------------标签头----------------------
 //        PdfPTable table = getPdfPTable(FontChinese11, bfHei, doc);
-        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl);
-        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl);
-        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl);
-        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl);
+        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl,isPrintRate);
+        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl,isPrintRate);
+        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl,isPrintRate);
+        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl,isPrintRate);
 
 
         doc.close();  //记得关闭document
 
     }
 
-    private static void getPdfPTable(Font fontChinese11, BaseFont bfHei, Document doc, PDFGoodsDto pdfGoodsDto,String headUrl) throws IOException, DocumentException {
+    private static void getPdfPTable(Font fontChinese11, BaseFont bfHei, Document doc, PDFGoodsDto pdfGoodsDto,String headUrl,String isPrintRate) throws IOException, DocumentException {
         PdfPTable table = new PdfPTable(3);
         table = new PdfPTable(3);
 
@@ -154,11 +154,14 @@ public class PDFWrite_12 {
 
 
         // --------------底部2-------------------------------
-        table = new PdfPTable(3);
-        for (int i = 0; i < 3; i++) {
-            setTable(bfHei, table, 10, "税率:"+pdfGoodsDto.getStartFax());
+        if ("1".equals(isPrintRate)){
+            table = new PdfPTable(3);
+            for (int i = 0; i < 3; i++) {
+                setTable(bfHei, table, 10, "税率:"+pdfGoodsDto.getStartFax());
+            }
+            doc.add(table);
         }
-        doc.add(table);
+
 
         table = new PdfPTable(3);
         for (int i = 0; i < 3; i++) {

+ 12 - 9
kmall-admin/src/main/java/com/kmall/admin/utils/pdf/type/PDFWrite_18.java

@@ -18,7 +18,7 @@ public class PDFWrite_18 {
 
 
     public void write(com.lowagie.text.Document doc, com.lowagie.text.pdf.PdfWriter writer, PDFGoodsDto pdfGoodsDto
-            , String fontUrl, String uploadDir, String headUrl) throws IOException, com.lowagie.text.DocumentException {
+            , String fontUrl, String uploadDir, String headUrl,String isPrintRate) throws IOException, com.lowagie.text.DocumentException {
 
         // 设置字体
         com.lowagie.text.pdf.BaseFont bfHei = com.lowagie.text.pdf.BaseFont.createFont(fontUrl, com.lowagie.text.pdf.BaseFont.IDENTITY_H, com.lowagie.text.pdf.BaseFont.NOT_EMBEDDED);
@@ -33,9 +33,9 @@ public class PDFWrite_18 {
         doc.open();// 打开文档
 
         // -----------------------标签头----------------------
-        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl);
-        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl);
-        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl);
+        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl,isPrintRate);
+        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl,isPrintRate);
+        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl,isPrintRate);
 
 
         doc.close();  //记得关闭document
@@ -43,7 +43,7 @@ public class PDFWrite_18 {
     }
 
     private static void getPdfPTable(com.lowagie.text.Font fontChinese11, BaseFont bfHei, Document doc,
-                                     PDFGoodsDto pdfGoodsDto, String headUrl) throws IOException, com.lowagie.text.DocumentException {
+                                     PDFGoodsDto pdfGoodsDto, String headUrl,String isPrintRate) throws IOException, com.lowagie.text.DocumentException {
         PdfPTable table = new PdfPTable(3);
         table = new PdfPTable(6);
 
@@ -157,11 +157,14 @@ public class PDFWrite_18 {
 
 
         // --------------底部2-------------------------------
-        table = new PdfPTable(6);
-        for (int i = 0; i < 6; i++) {
-            setTable(bfHei, table, 8, "税率:"+pdfGoodsDto.getStartFax());
+        if ("1".equals(isPrintRate)){
+            table = new PdfPTable(6);
+            for (int i = 0; i < 6; i++) {
+                setTable(bfHei, table, 8, "税率:"+pdfGoodsDto.getStartFax());
+            }
+            doc.add(table);
         }
-        doc.add(table);
+
 
         table = new PdfPTable(6);
         for (int i = 0; i < 6; i++) {

+ 10 - 7
kmall-admin/src/main/java/com/kmall/admin/utils/pdf/type/PDFWrite_2.java

@@ -15,7 +15,7 @@ public class PDFWrite_2 {
 
 
     public void write(Document doc, PdfWriter writer, PDFGoodsDto pdfGoodsDto
-            , String fontUrl, String uploadDir, String headUrl) throws IOException, DocumentException {
+            , String fontUrl, String uploadDir, String headUrl,String isPrintRate) throws IOException, DocumentException {
         // 设置字体
         BaseFont bfHei = BaseFont.createFont(fontUrl,BaseFont.IDENTITY_H,BaseFont.NOT_EMBEDDED);
         Font FontChinese11 = new Font(bfHei, 11);
@@ -28,13 +28,13 @@ public class PDFWrite_2 {
         writer.setPdfVersion(PdfWriter.PDF_VERSION_1_2);//版本(默认1.4)
         doc.open();// 打开文档
         // -----------------------标签头----------------------
-        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl);
+        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl,isPrintRate);
 
         doc.close();  //记得关闭document
 
     }
 
-    private static void getPdfPTable(Font fontChinese11, BaseFont bfHei, Document doc, PDFGoodsDto pdfGoodsDto,String headUrl) throws IOException, DocumentException {
+    private static void getPdfPTable(Font fontChinese11, BaseFont bfHei, Document doc, PDFGoodsDto pdfGoodsDto,String headUrl,String isPrintRate) throws IOException, DocumentException {
         PdfPTable table = new PdfPTable(2);
 
         for (int i = 0; i < 2; i++) {
@@ -137,11 +137,14 @@ public class PDFWrite_2 {
 
 
         // --------------底部2-------------------------------
-        table = new PdfPTable(2);
-        for (int i = 0; i < 2; i++) {
-            setTable(bfHei, table, 16, "税率:"+pdfGoodsDto.getStartFax());
+        if ("1".equals(isPrintRate)){
+            table = new PdfPTable(2);
+            for (int i = 0; i < 2; i++) {
+                setTable(bfHei, table, 16, "税率:"+pdfGoodsDto.getStartFax());
+            }
+            doc.add(table);
         }
-        doc.add(table);
+
 
         table = new PdfPTable(2);
         for (int i = 0; i < 2; i++) {

+ 16 - 12
kmall-admin/src/main/java/com/kmall/admin/utils/pdf/type/PDFWrite_36.java

@@ -15,7 +15,7 @@ public class PDFWrite_36 {
 
 
     public void write(Document doc, PdfWriter writer, PDFGoodsDto pdfGoodsDto
-            , String fontUrl, String uploadDir, String headUrl) throws IOException, DocumentException {
+            , String fontUrl, String uploadDir, String headUrl,String isPrintRate) throws IOException, DocumentException {
 
         // 设置字体
         BaseFont bfHei = BaseFont.createFont(fontUrl,BaseFont.IDENTITY_H,BaseFont.NOT_EMBEDDED);
@@ -30,19 +30,20 @@ public class PDFWrite_36 {
         doc.open();// 打开文档
 
         // -----------------------标签头----------------------
-        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl);
-        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl);
-        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl);
-        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl);
-        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl);
-        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl);
+        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl,isPrintRate);
+        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl,isPrintRate);
+        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl,isPrintRate);
+        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl,isPrintRate);
+        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl,isPrintRate);
+        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl,isPrintRate);
 
 
         doc.close();  //记得关闭document
 
     }
 
-    private static void getPdfPTable(Font fontChinese11, BaseFont bfHei, Document doc, PDFGoodsDto pdfGoodsDto,String headUrl) throws IOException, DocumentException {
+    private static void getPdfPTable(Font fontChinese11, BaseFont bfHei, Document doc, PDFGoodsDto pdfGoodsDto,
+                                     String headUrl,String isPrintRate) throws IOException, DocumentException {
         PdfPTable table = new PdfPTable(3);
         table = new PdfPTable(6);
 
@@ -161,11 +162,14 @@ public class PDFWrite_36 {
 
 
         // --------------底部2-------------------------------
-        table = new PdfPTable(6);
-        for (int i = 0; i < 6; i++) {
-            setTable(bfHei, table, 6, "税率:"+pdfGoodsDto.getStartFax());
+        if ("1".equals(isPrintRate)){
+            table = new PdfPTable(6);
+            for (int i = 0; i < 6; i++) {
+                setTable(bfHei, table, 6, "税率:"+pdfGoodsDto.getStartFax());
+            }
+            doc.add(table);
+
         }
-        doc.add(table);
 
 
         table = new PdfPTable(6);

+ 11 - 8
kmall-admin/src/main/java/com/kmall/admin/utils/pdf/type/PDFWrite_4.java

@@ -14,7 +14,7 @@ public class PDFWrite_4 {
 
 
     public void write(Document doc, PdfWriter writer, PDFGoodsDto pdfGoodsDto
-            , String fontUrl, String uploadDir, String headUrl) throws IOException, DocumentException {
+            , String fontUrl, String uploadDir, String headUrl,String isPrintRate) throws IOException, DocumentException {
         // 设置字体
         BaseFont bfHei = BaseFont.createFont(fontUrl,BaseFont.IDENTITY_H,BaseFont.NOT_EMBEDDED);
         Font FontChinese11 = new Font(bfHei, 11);
@@ -28,14 +28,14 @@ public class PDFWrite_4 {
         doc.open();// 打开文档
         // -----------------------标签头----------------------
 //        PdfPTable table = getPdfPTable(FontChinese11, bfHei, doc);
-        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl);
-        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl);
+        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl,isPrintRate);
+        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl,isPrintRate);
 
         doc.close();  //记得关闭document
 
     }
 
-    private static void getPdfPTable(Font fontChinese11, BaseFont bfHei, Document doc, PDFGoodsDto pdfGoodsDto,String headUrl) throws IOException, DocumentException {
+    private static void getPdfPTable(Font fontChinese11, BaseFont bfHei, Document doc, PDFGoodsDto pdfGoodsDto,String headUrl,String isPrintRate) throws IOException, DocumentException {
         PdfPTable table = new PdfPTable(2);
 
         for (int i = 0; i < 2; i++) {
@@ -147,11 +147,14 @@ public class PDFWrite_4 {
 
 
         // --------------底部2-------------------------------
-        table = new PdfPTable(2);
-        for (int i = 0; i < 2; i++) {
-            setTable(bfHei, table, 16, "税率:"+pdfGoodsDto.getStartFax());
+        if ("1".equals(isPrintRate)){
+            table = new PdfPTable(2);
+            for (int i = 0; i < 2; i++) {
+                setTable(bfHei, table, 16, "税率:"+pdfGoodsDto.getStartFax());
+            }
+            doc.add(table);
         }
-        doc.add(table);
+
 
         table = new PdfPTable(2);
         for (int i = 0; i < 2; i++) {

+ 12 - 9
kmall-admin/src/main/java/com/kmall/admin/utils/pdf/type/PDFWrite_9.java

@@ -15,7 +15,7 @@ public class PDFWrite_9 {
 
 
     public void write(Document doc, PdfWriter writer, PDFGoodsDto pdfGoodsDto
-            , String fontUrl, String uploadDir, String headUrl) throws IOException, DocumentException {
+            , String fontUrl, String uploadDir, String headUrl,String isPrintRate) throws IOException, DocumentException {
         // 设置字体
         BaseFont bfHei = BaseFont.createFont(fontUrl,BaseFont.IDENTITY_H,BaseFont.NOT_EMBEDDED);
         Font FontChinese11 = new Font(bfHei, 11);
@@ -29,16 +29,16 @@ public class PDFWrite_9 {
         doc.open();// 打开文档
         // -----------------------标签头----------------------
 //        PdfPTable table = getPdfPTable(FontChinese11, bfHei, doc);
-        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl);
-        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl);
-        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl);
+        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl,isPrintRate);
+        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl,isPrintRate);
+        getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,headUrl,isPrintRate);
 
 
         doc.close();  //记得关闭document
 
     }
 
-    private static void getPdfPTable(Font fontChinese11, BaseFont bfHei, Document doc, PDFGoodsDto pdfGoodsDto,String headUrl) throws IOException, DocumentException {
+    private static void getPdfPTable(Font fontChinese11, BaseFont bfHei, Document doc, PDFGoodsDto pdfGoodsDto,String headUrl,String isPrintRate) throws IOException, DocumentException {
         PdfPTable table = new PdfPTable(3);
         table = new PdfPTable(3);
 
@@ -151,11 +151,14 @@ public class PDFWrite_9 {
 
 
         // --------------底部2-------------------------------
-        table = new PdfPTable(3);
-        for (int i = 0; i < 3; i++) {
-            setTable(bfHei, table, 10, "税率:"+pdfGoodsDto.getStartFax());
+        if ("1".equals(isPrintRate)){
+            table = new PdfPTable(3);
+            for (int i = 0; i < 3; i++) {
+                setTable(bfHei, table, 10, "税率:"+pdfGoodsDto.getStartFax());
+            }
+            doc.add(table);
         }
-        doc.add(table);
+
 
         table = new PdfPTable(3);
         for (int i = 0; i < 3; i++) {

+ 12 - 6
kmall-admin/src/main/java/com/kmall/admin/utils/pdf/type/PDFWrite_nohead_36.java

@@ -24,7 +24,7 @@ public class PDFWrite_nohead_36 {
 
 
     public void write(Document doc, PdfWriter writer, PDFGoodsDto pdfGoodsDto
-            , String fontUrl, String uploadDir) throws IOException, DocumentException {
+            , String fontUrl, String uploadDir,String isPrintRate) throws IOException, DocumentException {
 
         // 设置字体
         BaseFont bfHei = BaseFont.createFont(fontUrl,BaseFont.IDENTITY_H,BaseFont.NOT_EMBEDDED);
@@ -42,14 +42,15 @@ public class PDFWrite_nohead_36 {
         String uploadUrl = FileManager.upload(dtoBarCode + UUID.randomUUID().toString(), bytes, String.valueOf(bytes.length));
         // -----------------------标签头----------------------
         for (int i = 0; i < 9; i++) {
-            getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,uploadUrl);
+            getPdfPTable(FontChinese11, bfHei, doc,pdfGoodsDto,uploadUrl,isPrintRate);
         }
 
         doc.close();  //记得关闭document
 
     }
 
-    private static void getPdfPTable(Font fontChinese11, BaseFont bfHei, Document doc, PDFGoodsDto pdfGoodsDto,String uploadUrl) throws IOException, DocumentException {
+    private static void getPdfPTable(Font fontChinese11, BaseFont bfHei, Document doc, PDFGoodsDto pdfGoodsDto,
+                                     String uploadUrl,String isPrintRate) throws IOException, DocumentException {
         PdfPTable table = new PdfPTable(4);
 
         // --------------产品名称-------------------------------
@@ -110,11 +111,16 @@ public class PDFWrite_nohead_36 {
             // ----------------test-----------------------
             PdfPTable pdfPTable8 = new PdfPTable(2);
             pdfPTable8.setWidths(new int[]{10,11});
-            font = new Font(bfHei, 6);
+            font = new Font(bfHei, 5);
             // --------------左上的字-------------------------------
-            Paragraph leftParagraph1 = new Paragraph("\n建议零售价省¥"+pdfGoodsDto.getSavings()+"\n\n", font);
+            Paragraph leftParagraph1 = new Paragraph("\n建议零售价省¥"+pdfGoodsDto.getSavings()+"\n\n", font);
             font = new Font(bfHei, 4.5f);
-            Paragraph leftParagraph2 = new Paragraph("税率:"+pdfGoodsDto.getStartFax()+"\n", font);
+            Paragraph leftParagraph2;
+            if ("1".equals(isPrintRate)) {
+                leftParagraph2 = new Paragraph("税率:" + pdfGoodsDto.getStartFax() + "\n", font);
+            }else {
+                leftParagraph2 = new Paragraph("\n", font);
+            }
             leftParagraph1.add(leftParagraph2);
             PdfPCell leftCell1 = new PdfPCell(leftParagraph1);
             leftCell1.setBorder(0);

+ 8 - 0
kmall-admin/src/main/webapp/WEB-INF/page/shop/goodsexportpdf.html

@@ -65,6 +65,14 @@
             </i-col>
 
             <i-col span="3">
+                <i-select v-model="q.isPrintRate" placeholder="是否打印税率" filterable label-in-value>
+                    <i-option v-for="isPrintRate in isPrintRates" :value="isPrintRate.id"
+                              :key="isPrintRate.id">{{isPrintRate.name}}
+                    </i-option>
+                </i-select>
+            </i-col>
+
+            <i-col span="3">
                 <i-select v-model="q.pdfType" placeholder="打印规格" filterable label-in-value>
                     <i-option v-for="pdfType in pdfTypes" :value="pdfType.id"
                               :key="pdfType.id">{{pdfType.name}}

+ 14 - 3
kmall-admin/src/main/webapp/js/shop/goodsexportpdf.js

@@ -12,7 +12,8 @@ let vm = new Vue({
             sku: '',
             isHead: '0',
             pdfType: '36',
-            headUrl: ''
+            headUrl: '',
+            isPrintRate:'1'
         },
         stores: [],
         labels:[],
@@ -23,6 +24,13 @@ let vm = new Vue({
         	id: '1',
 			name: '有标签头'
         }],
+        isPrintRates: [{
+            id: '0',
+            name: '不打印税率'
+        }, {
+            id: '1',
+            name: '打印税率'
+        }],
 
         pdfTypes: [ {id: '36',
             name: '36规格'}
@@ -88,9 +96,12 @@ let vm = new Vue({
                 return;
             }
 
-            window.open("../pdf/printPdf?type="+vm.q.pdfType+"&sku="+vm.q.sku+"&prodBarcode="+vm.q.barCode+"&head="+vm.q.isHead+"&headUrl="+vm.q.headUrl+"&storeId="+vm.q.storeId);
+            window.open("../pdf/printPdf?type="+vm.q.pdfType+"&sku="+vm.q.sku+"&prodBarcode="
+                +vm.q.barCode+"&head="+vm.q.isHead+"&headUrl="+vm.q.headUrl+"&storeId="+vm.q.storeId+"&isPrintRate="+vm.q.isPrintRate);
+
 
-            $.get("../pdf/printPdf?type="+vm.q.pdfType+"&sku="+vm.q.sku+"&prodBarcode="+vm.q.barCode+"&head="+vm.q.isHead+"&headUrl="+vm.q.headUrl+"&storeId="+vm.q.storeId, function (r) {
+            $.get("../pdf/printPdf?type="+vm.q.pdfType+"&sku="+vm.q.sku+"&prodBarcode="
+                +vm.q.barCode+"&head="+vm.q.isHead+"&headUrl="+vm.q.headUrl+"&storeId="+vm.q.storeId+"&isPrintRate="+vm.q.isPrintRate, function (r) {
                 console.log(r)
                 alert(r)
             });