Преглед изворни кода

xwh增加小票批量打印

xwh пре 4 година
родитељ
комит
c089893eee

+ 51 - 3
kmall-admin/src/main/java/com/kmall/admin/controller/exportPDF/ExportPDFController.java

@@ -1,20 +1,25 @@
 package com.kmall.admin.controller.exportPDF;
 
+import com.kmall.admin.dto.StoreGoodsDto;
 import com.kmall.admin.service.GoodsService;
 import com.kmall.admin.utils.pdf.ViewPDF;
 import com.kmall.api.entity.exportpdf.PDFGoodsDto;
+import com.kmall.common.constant.JxlsXmlTemplateName;
+import com.kmall.common.utils.R;
+import com.kmall.common.utils.excel.ExcelUtil;
 import org.apache.http.HttpResponse;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.servlet.ModelAndView;
 
 import javax.servlet.http.HttpServletResponse;
 import java.math.BigDecimal;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
+import java.util.*;
 
 /**
  * @author zhangchuangbiao
@@ -31,6 +36,9 @@ public class ExportPDFController {
     @Value("${font.url}")
     private String fontUrl;
 
+    @Autowired
+    private ExcelUtil excelUtil;
+
 //    @Value("${upload.dir}")
 //    private String uploadDir;
 
@@ -87,6 +95,46 @@ public class ExportPDFController {
 
 
     }
+
+
+
+
+
+
+    /**
+     * 批量生成pdf
+     */
+    @RequestMapping("/batchPrintPdf")
+    @ResponseBody
+    public R batchPrintPdf(@RequestParam("file") MultipartFile file) {
+        List<PDFGoodsDto> PDFGoodsDtoList = new ArrayList<>();//信息
+        try {
+            PDFGoodsDto PDFGoodsDto = new PDFGoodsDto();
+            Map<String, Object> beans = new HashMap<String, Object>();
+            beans.put("PDFGoodsDto", PDFGoodsDto);
+            beans.put("PDFGoodsDtoList", PDFGoodsDtoList);
+            if (file.isEmpty()) {
+                return R.error("文件不能为空!");
+            }
+            excelUtil.readExcel(JxlsXmlTemplateName.PDF_GOODS_DTO_LIST, beans, file.getInputStream());
+        } catch (Exception e) {
+            e.printStackTrace();
+            return R.error("导入失败!");
+        }
+        //上传文件
+        return R.ok("导入成功!").put("PDFGoodsDtoList",PDFGoodsDtoList);
+    }
+
+
+
+
+
+
+
+
+
+
+
 }
 
 

+ 23 - 0
kmall-admin/src/main/resources/XmlTemplate/PDFGoodsDtoList.xml

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<workbook>
+    <worksheet name="Sheet1">
+        <section startRow="0" endRow="1"/>
+        <loop startRow="1" endRow="1" items="PDFGoodsDtoList" var="PDFGoodsDto"
+              varType="com.kmall.api.entity.exportpdf.PDFGoodsDto">
+            <section startRow="1" endRow="1">
+                <mapping row="1" col="0">PDFGoodsDto.storeId</mapping>
+                <mapping row="1" col="1">PDFGoodsDto.sku</mapping>
+                <mapping row="1" col="2">PDFGoodsDto.prodBarcode</mapping>
+                <mapping row="1" col="3">PDFGoodsDto.head</mapping>
+                <mapping row="1" col="4">PDFGoodsDto.isPrintRate</mapping>
+                <mapping row="1" col="5">PDFGoodsDto.type</mapping>
+                <mapping row="1" col="6">PDFGoodsDto.headUrl</mapping>
+            </section>
+            <loopbreakcondition>
+                <rowcheck offset="0">
+                    <cellcheck offset="0"></cellcheck>
+                </rowcheck>
+            </loopbreakcondition>
+        </loop>
+    </worksheet>
+</workbook>

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

@@ -40,6 +40,15 @@
         <div class="row" style="border:0;margin-bottom:10px">
 <!--            <i-button  v-bind:disabled="selectButtonDisabled"  @click="selectLabelHead" >选择标签头</i-button>-->
             <i-button type="primary" @click="exportPdf"><i class="fa fa-cloud-download"></i>&nbsp;标签pdf制作</i-button>
+
+            <i-col style="display: inline-grid;">
+                <Upload :show-upload-list="false" :on-success="uploadExcelSuccess" :on-format-error="uploadExcelFormatError"
+                        :format="['xls','xlsx']"
+                        action="../pdf/batchPrintPdf">
+                    <i-button type="ghost" icon="ios-cloud-upload-outline">标签pdf制作模板导入</i-button>
+                </Upload>
+            </i-col>
+            &nbsp;&nbsp;&nbsp;<a href="../statics/file/pdf_goods_export_yyyy_mm_dd_v1.0.0.xls">标签pdf制作模板下载</a>&nbsp;&nbsp;&nbsp;&nbsp;
             <i-col span="3">
                 <i-select v-model="q.storeId" placeholder="门店" filterable label-in-value>
                     <i-option v-for="store in stores" :value="store.id"

+ 23 - 0
kmall-admin/src/main/webapp/js/shop/goodsexportpdf.js

@@ -108,6 +108,29 @@ let vm = new Vue({
 		},
         barCodeEnter:function () {
             this.exportPdf();
+        },
+        uploadExcelSuccess: function (data) {
+            if(data.code==0){
+                console.log(data)
+                var PDFGoodsDtoList = data.PDFGoodsDtoList;
+                for(var i=0;i<PDFGoodsDtoList.length;i++){
+                    var pdfGoodsDto = PDFGoodsDtoList[i];
+                    window.open("../pdf/printPdf?type="+pdfGoodsDto.type+"&sku="+pdfGoodsDto.sku+"&prodBarcode="
+                        +pdfGoodsDto.prodBarcode+"&head="+pdfGoodsDto.head+"&headUrl="+pdfGoodsDto.headUrl+"&storeId="+pdfGoodsDto.storeId+"&isPrintRate="+pdfGoodsDto.isPrintRate);
+                }
+            }else{
+                console.log(data)
+            }
+        },
+        uploadExcelError: function (data) {
+            console.log(data);
+            alert('上传出现异常,请重试!');
+        },
+        uploadExcelFormatError: function (file) {
+            this.$Notice.warning({
+                title: '文件格式不正确',
+                desc: '文件 ' + file.name + ' 格式不正确,请上传 xls 或 xlsx 格式的文件。'
+            });
         }
 
 	},

BIN
kmall-admin/src/main/webapp/statics/file/pdf_goods_export_yyyy_mm_dd_v1.0.0.xlsx


+ 64 - 1
kmall-api/src/main/java/com/kmall/api/entity/exportpdf/PDFGoodsDto.java

@@ -6,7 +6,7 @@ package com.kmall.api.entity.exportpdf;
  * 2020-09-14 16:35
  */
 public class PDFGoodsDto {
-
+    // , , , , , ,String isPrintRate
     private String productName; // 产品名称
     private String englishName; // 产品英文名称
     private String price; // 价格
@@ -16,6 +16,69 @@ public class PDFGoodsDto {
     private String plu;
     private String barCode;
 
+    private String head;// 是否需要标签头
+    private String type;
+    private String sku;
+    private String storeId;
+    private String headUrl;// 标签头地址
+    private String prodBarcode;// 条形码
+    private String isPrintRate;// 是否打印税率
+
+    public String getHead() {
+        return head;
+    }
+
+    public void setHead(String head) {
+        this.head = head;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public String getSku() {
+        return sku;
+    }
+
+    public void setSku(String sku) {
+        this.sku = sku;
+    }
+
+    public String getStoreId() {
+        return storeId;
+    }
+
+    public void setStoreId(String storeId) {
+        this.storeId = storeId;
+    }
+
+    public String getHeadUrl() {
+        return headUrl;
+    }
+
+    public void setHeadUrl(String headUrl) {
+        this.headUrl = headUrl;
+    }
+
+    public String getProdBarcode() {
+        return prodBarcode;
+    }
+
+    public void setProdBarcode(String prodBarcode) {
+        this.prodBarcode = prodBarcode;
+    }
+
+    public String getIsPrintRate() {
+        return isPrintRate;
+    }
+
+    public void setIsPrintRate(String isPrintRate) {
+        this.isPrintRate = isPrintRate;
+    }
 
     public String getProductName() {
         return productName;

+ 2 - 0
kmall-common/src/main/java/com/kmall/common/constant/JxlsXmlTemplateName.java

@@ -16,6 +16,8 @@ public class JxlsXmlTemplateName {
     public static final String SYS_USER_DTO_LIST = "/XmlTemplate/SysUserDtoList.xml";
     //门店商品导入
     public static final String STORE_GOODS_DTO_LIST = "/XmlTemplate/StoreGoodsDtoList.xml";
+    //打印标签批量导入
+    public static final String PDF_GOODS_DTO_LIST = "/XmlTemplate/PDFGoodsDtoList.xml";
     //活动商品价格导入
     public static final String STORE_TOPIC_DTO_LIST = "/XmlTemplate/StoreTopicDtoList.xml";