瀏覽代碼

一二线pdf生成

wenjinbiao 8 月之前
父節點
當前提交
c17d306769

+ 24 - 0
snowy-common/pom.xml

@@ -118,6 +118,11 @@
             <artifactId>easypoi-spring-boot-starter</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-test</artifactId>
+        </dependency>
+
         <!-- sm-crypto -->
         <dependency>
             <groupId>com.antherd</groupId>
@@ -129,5 +134,24 @@
             <groupId>com.alibaba</groupId>
             <artifactId>easyexcel</artifactId>
         </dependency>
+
+        <!-- pdf图表生成工具 -->
+        <dependency>
+            <groupId>com.itextpdf</groupId>
+            <artifactId>itextpdf</artifactId>
+            <version>5.5.13</version>
+        </dependency>
+        <dependency>
+            <groupId>com.itextpdf</groupId>
+            <artifactId>itext-asian</artifactId>
+            <version>5.2.0</version>
+        </dependency>
+        <dependency>
+            <groupId>com.itextpdf.tool</groupId>
+            <artifactId>xmlworker</artifactId>
+            <version>5.5.13</version>
+        </dependency>
     </dependencies>
+
+
 </project>

+ 23 - 0
snowy-common/src/main/java/vip/xiaonuo/common/util/CommonFileUtil.java

@@ -0,0 +1,23 @@
+package vip.xiaonuo.common.util;
+
+import org.springframework.mock.web.MockMultipartFile;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.*;
+
+public class CommonFileUtil {
+
+    public static MultipartFile bytesToMultipartFile(String fileName,String suffix,byte[] bytes) throws IOException {
+        File file = File.createTempFile(fileName, suffix);
+        FileOutputStream fos = new FileOutputStream(file);
+        fos.write(bytes);
+        MultipartFile result = null;
+            try (FileInputStream input = new FileInputStream(file)) {
+                result = new MockMultipartFile(file.getName().concat("temp"), file.getName(), "text/plain", input);
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+
+        return result;
+    }
+}

+ 98 - 0
snowy-common/src/main/java/vip/xiaonuo/common/util/CommonPdfUtil.java

@@ -0,0 +1,98 @@
+package vip.xiaonuo.common.util;
+
+
+import com.itextpdf.text.*;
+import com.itextpdf.text.pdf.BaseFont;
+import com.itextpdf.text.pdf.PdfPCell;
+import com.itextpdf.text.pdf.PdfPTable;
+public class CommonPdfUtil {
+
+    /** 标准字体 */
+    public static Font NORMALFONT;
+    /** 加粗字体 */
+    public static Font BOLDFONT;
+
+    /** 固定高 */
+    public static float fixedHeight = 27f;
+    /** 间距 */
+    public static int spacing = 5;
+
+    /**
+     * 设置中文格式防止乱码
+     */
+    static {
+        try {
+            BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
+            NORMALFONT = new Font(bfChinese, 10, Font.NORMAL);
+            BOLDFONT = new Font(bfChinese, 14, Font.BOLD);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     *
+     * @return
+     */
+    public static Document createDocument() {
+        //生成pdf
+        Document document = new Document();
+        // 页面大小
+        Rectangle rectangle = new Rectangle(PageSize.A4);
+        // 页面背景颜色
+        rectangle.setBackgroundColor(BaseColor.WHITE);
+        document.setPageSize(rectangle);
+        // 页边距 左,右,上,下
+        document.setMargins(20, 20, 20, 20);
+        return document;
+    }
+    /**
+     * @param len 表格列数
+     * @return
+     */
+    public static PdfPTable createPdfPTable(int len) {
+        PdfPTable pdfPTable = new PdfPTable(len);
+        pdfPTable.setSpacingBefore(5);
+        pdfPTable.setHorizontalAlignment(Element.ALIGN_CENTER);
+        return pdfPTable;
+    }
+
+    /**
+     * 创建指定文字得单元格
+     * @param text
+     * @return
+     */
+    public static PdfPCell createCenterPdfPCell(String text, int rowSpan, int colSpan, Font font) {
+        PdfPCell cell = new PdfPCell(new Paragraph(text, font));
+        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
+        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
+        cell.setFixedHeight(fixedHeight);
+        cell.setRowspan(rowSpan);
+        cell.setColspan(colSpan);
+        return cell;
+    }
+    /**
+     * @param text 段落内容
+     * @return
+     */
+    public static Paragraph createParagraph(String text, Font font) {
+        Paragraph elements = new Paragraph(text, font != null ? font :createFont(10, Font.NORMAL,BaseColor.BLACK) );
+        elements.setSpacingBefore(5);
+        elements.setSpacingAfter(5);
+        elements.setSpacingAfter(spacing);
+        return elements;
+    }
+
+
+    public static Font createFont(int fontSize, int fontStyle, BaseColor fontColor) {
+        //中文字体 ----不然中文会乱码
+        BaseFont bf = null;
+        try {
+            bf = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
+            return new Font(bf, fontSize, fontStyle, fontColor);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return new Font(bf, Font.DEFAULTSIZE, Font.NORMAL, BaseColor.BLACK);
+    }
+}

+ 27 - 0
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/qyfrontlinewarehouse/controller/QyFrontlineWarehouseController.java

@@ -171,4 +171,31 @@ public class QyFrontlineWarehouseController {
     public CommonResult<QyFrontlineWarehouse> detail(@Valid QyFrontlineWarehouseIdParam qyFrontlineWarehouseIdParam) {
         return CommonResult.data(qyFrontlineWarehouseService.detail(qyFrontlineWarehouseIdParam));
     }
+
+    /**
+     * 获取一线径予放行业务记账管理详情
+     *
+     * @author 曹钊瑞
+     * @date  2024/07/04 15:16
+     */
+    @Operation(summary = "获取一线径予放行记账凭证pdf链接")
+    @SaCheckPermission("/biz/qyfrontlinewarehouse/accountVoucherPdf")
+    @GetMapping("/biz/qyfrontlinewarehouse/accountVoucherPdf")
+    public CommonResult<String> accountVoucherPdf(@Valid QyFrontlineWarehouseIdParam qyFrontlineWarehouseIdParam) throws Exception {
+        return CommonResult.data(qyFrontlineWarehouseService.accountVoucherPdf(qyFrontlineWarehouseIdParam));
+    }
+
+    /**
+     * 获取一线径予放行业务记账管理详情
+     *
+     * @author 曹钊瑞
+     * @date  2024/07/04 15:16
+     */
+    @Operation(summary = "获取一线径予放行记账列表pdf")
+    @SaCheckPermission("/biz/qyfrontlinewarehouse/printPdf")
+    @GetMapping("/biz/qyfrontlinewarehouse/printPdf")
+    public CommonResult<String> printPdf(@Valid QyFrontlineWarehousePageParam qyFrontlineWarehousePageParam) throws Exception {
+        return CommonResult.data(qyFrontlineWarehouseService.printPdf(qyFrontlineWarehousePageParam));
+    }
+
 }

+ 4 - 0
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/qyfrontlinewarehouse/service/QyFrontlineWarehouseService.java

@@ -77,4 +77,8 @@ public interface QyFrontlineWarehouseService extends IService<QyFrontlineWarehou
      * @date  2024/07/04 15:16
      **/
     QyFrontlineWarehouse queryEntity(String id);
+
+    String accountVoucherPdf(QyFrontlineWarehouseIdParam qyFrontlineWarehouseIdParam) throws Exception;
+
+    String printPdf(QyFrontlineWarehousePageParam qyFrontlineWarehousePageParam) throws Exception;
 }

+ 210 - 0
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/qyfrontlinewarehouse/service/impl/QyFrontlineWarehouseServiceImpl.java

@@ -12,6 +12,7 @@
  */
 package vip.xiaonuo.biz.modular.qyfrontlinewarehouse.service.impl;
 
+import cn.afterturn.easypoi.pdf.PdfExportUtil;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollStreamUtil;
 import cn.hutool.core.util.ObjectUtil;
@@ -19,6 +20,12 @@ import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.itextpdf.text.*;
+import com.itextpdf.text.pdf.PdfPCell;
+import com.itextpdf.text.pdf.PdfPTable;
+import com.itextpdf.text.pdf.PdfWriter;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.AutoConfigureOrder;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import vip.xiaonuo.common.enums.CommonSortOrderEnum;
@@ -31,8 +38,15 @@ import vip.xiaonuo.biz.modular.qyfrontlinewarehouse.param.QyFrontlineWarehouseEd
 import vip.xiaonuo.biz.modular.qyfrontlinewarehouse.param.QyFrontlineWarehouseIdParam;
 import vip.xiaonuo.biz.modular.qyfrontlinewarehouse.param.QyFrontlineWarehousePageParam;
 import vip.xiaonuo.biz.modular.qyfrontlinewarehouse.service.QyFrontlineWarehouseService;
+import vip.xiaonuo.common.util.CommonFileUtil;
+import vip.xiaonuo.common.util.CommonPdfUtil;
+import vip.xiaonuo.dev.api.DevFileApi;
 
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
 import java.util.List;
+import java.util.UUID;
 
 /**
  * 一线径予放行业务记账管理Service接口实现类
@@ -43,6 +57,9 @@ import java.util.List;
 @Service
 public class QyFrontlineWarehouseServiceImpl extends ServiceImpl<QyFrontlineWarehouseMapper, QyFrontlineWarehouse> implements QyFrontlineWarehouseService {
 
+    @Autowired
+    private DevFileApi devFileApi;
+
     @Override
     public Page<QyFrontlineWarehouse> page(QyFrontlineWarehousePageParam qyFrontlineWarehousePageParam) {
         QueryWrapper<QyFrontlineWarehouse> queryWrapper = new QueryWrapper<QyFrontlineWarehouse>().checkSqlInjection();
@@ -145,4 +162,197 @@ public class QyFrontlineWarehouseServiceImpl extends ServiceImpl<QyFrontlineWare
         }
         return qyFrontlineWarehouse;
     }
+
+    /**
+     * 一线放行入账入账凭证pdf
+     * @param qyFrontlineWarehouseIdParam
+     * @return
+     * @throws DocumentException
+     * @throws IOException
+     */
+    @Override
+    public String accountVoucherPdf(QyFrontlineWarehouseIdParam qyFrontlineWarehouseIdParam) throws Exception {
+        String id = qyFrontlineWarehouseIdParam.getId();
+        QyFrontlineWarehouse qyFrontlineWarehouse = this.getById(id);
+        if(ObjectUtil.isEmpty(qyFrontlineWarehouse)) {
+            throw new CommonException("一线径予放行业务记账管理不存在,id值为:{}", id);
+        }
+
+        QueryWrapper<QyFrontlineWarehouse> queryWrapper = new QueryWrapper<QyFrontlineWarehouse>().checkSqlInjection();
+
+        queryWrapper.lambda().eq(QyFrontlineWarehouse::getWarehouseNumber,qyFrontlineWarehouse.getWarehouseNumber());
+
+        List<QyFrontlineWarehouse> list = this.list(queryWrapper);
+
+        ByteArrayOutputStream os = new ByteArrayOutputStream();
+        Document document = CommonPdfUtil.createDocument();
+        PdfWriter.getInstance(document, os);
+        document.open();
+
+        //创建表格
+        PdfPTable pdfPTable = CommonPdfUtil.createPdfPTable(7);
+
+        //设置表头
+        PdfPCell firstHead = CommonPdfUtil.createCenterPdfPCell("入库凭证", 2, 7, CommonPdfUtil.BOLDFONT);
+        pdfPTable.addCell(firstHead);
+
+        //设置账册编号
+        PdfPCell accountCodeCell = CommonPdfUtil.createCenterPdfPCell(qyFrontlineWarehouse.getAccountCode(), 1, 7, CommonPdfUtil.NORMALFONT);
+        pdfPTable.addCell(accountCodeCell);
+
+        //设置二级表头
+        PdfPCell indexNoHead = CommonPdfUtil.createCenterPdfPCell("序号", 1, 1, CommonPdfUtil.NORMALFONT);
+        PdfPCell commodityNameHead = CommonPdfUtil.createCenterPdfPCell("商品名称", 1, 1, CommonPdfUtil.NORMALFONT);
+        PdfPCell specsHead = CommonPdfUtil.createCenterPdfPCell("规格", 1, 1, CommonPdfUtil.NORMALFONT);
+        PdfPCell unitHead = CommonPdfUtil.createCenterPdfPCell("单位", 1, 1, CommonPdfUtil.NORMALFONT);
+        PdfPCell accountNumberHead = CommonPdfUtil.createCenterPdfPCell("数量", 1, 1, CommonPdfUtil.NORMALFONT);
+        PdfPCell unitPriceHead= CommonPdfUtil.createCenterPdfPCell("单价", 1, 1, CommonPdfUtil.NORMALFONT);
+        PdfPCell remarkHead = CommonPdfUtil.createCenterPdfPCell("备注", 1, 1, CommonPdfUtil.NORMALFONT);
+        pdfPTable.addCell(indexNoHead);
+        pdfPTable.addCell(commodityNameHead);
+        pdfPTable.addCell(specsHead);
+        pdfPTable.addCell(unitHead);
+        pdfPTable.addCell(accountNumberHead);
+        pdfPTable.addCell(unitPriceHead);
+        pdfPTable.addCell(remarkHead);
+
+
+
+        for (int i = 1; i <= list.size(); i++) {
+            QyFrontlineWarehouse item = list.get(i - 1);
+            PdfPCell indexNoCell = CommonPdfUtil.createCenterPdfPCell(String.valueOf(i),1, 1, CommonPdfUtil.NORMALFONT);
+            PdfPCell commodityNameCell = CommonPdfUtil.createCenterPdfPCell(item.getCommodityName(), 1, 1, CommonPdfUtil.NORMALFONT);
+            PdfPCell specsCell = CommonPdfUtil.createCenterPdfPCell(item.getSpecs(), 1, 1, CommonPdfUtil.NORMALFONT);
+            PdfPCell unitCell = CommonPdfUtil.createCenterPdfPCell(item.getMeasurementUnit(), 1, 1, CommonPdfUtil.NORMALFONT);
+            PdfPCell accountNumberCell = CommonPdfUtil.createCenterPdfPCell(item.getAccountNumber(), 1, 1, CommonPdfUtil.NORMALFONT);
+            PdfPCell unitPriceCell = CommonPdfUtil.createCenterPdfPCell(item.getUnitPrice(), 1, 1, CommonPdfUtil.NORMALFONT);
+            PdfPCell remarkCell = CommonPdfUtil.createCenterPdfPCell(item.getRemark(), 1, 1, CommonPdfUtil.NORMALFONT);
+
+            pdfPTable.addCell(indexNoCell);
+            pdfPTable.addCell(commodityNameCell);
+            pdfPTable.addCell(specsCell);
+            pdfPTable.addCell(unitCell);
+            pdfPTable.addCell(accountNumberCell);
+            pdfPTable.addCell(unitPriceCell);
+            pdfPTable.addCell(remarkCell);
+        }
+        PdfPCell amountCell = CommonPdfUtil.createCenterPdfPCell("合计",1, 2, CommonPdfUtil.NORMALFONT);
+        PdfPCell companyNameCell = CommonPdfUtil.createCenterPdfPCell("单位: " + qyFrontlineWarehouse.getCompanyName() ,1, 3, CommonPdfUtil.NORMALFONT);
+        PdfPCell creatorCell = CommonPdfUtil.createCenterPdfPCell("制单人: "+qyFrontlineWarehouse.getCreator(),1, 2, CommonPdfUtil.NORMALFONT);
+
+        pdfPTable.addCell(amountCell);
+        pdfPTable.addCell(companyNameCell);
+        pdfPTable.addCell(creatorCell);
+
+        document.add(pdfPTable);
+
+        document.close();
+
+        //上传
+
+        return devFileApi.storageFileWithReturnUrlLocal(CommonFileUtil.bytesToMultipartFile("一线放予入账凭证" + System.currentTimeMillis(),".pdf" ,os.toByteArray()));
+
+    }
+
+    /**
+     * 打印pdf
+     *
+     * @param qyFrontlineWarehousePageParam
+     * @return
+     * @throws Exception
+     */
+    @Override
+    public String printPdf(QyFrontlineWarehousePageParam qyFrontlineWarehousePageParam) throws Exception {
+        qyFrontlineWarehousePageParam.setSize(Integer.MAX_VALUE);
+        Page<QyFrontlineWarehouse> page = this.page(qyFrontlineWarehousePageParam);
+
+        List<QyFrontlineWarehouse> records = page.getRecords();
+
+        ByteArrayOutputStream os = new ByteArrayOutputStream();
+        Document document = CommonPdfUtil.createDocument();
+        //横向打印
+        Rectangle rectangle = new Rectangle(PageSize.A4.rotate());
+        document.setPageSize(rectangle);
+        PdfWriter.getInstance(document, os);
+        document.open();
+
+        //创建表格
+        PdfPTable pdfPTable = CommonPdfUtil.createPdfPTable(13);
+
+        //设置表头
+        PdfPCell indexNoHead = CommonPdfUtil.createCenterPdfPCell("序号", 1, 1, CommonPdfUtil.NORMALFONT);
+        PdfPCell companyCodeHead = CommonPdfUtil.createCenterPdfPCell("企业编号", 1, 1, CommonPdfUtil.NORMALFONT);
+        PdfPCell companyNameHead = CommonPdfUtil.createCenterPdfPCell("企业名称", 1, 1, CommonPdfUtil.NORMALFONT);
+        PdfPCell accountTypeHead = CommonPdfUtil.createCenterPdfPCell("账册类型", 1, 1, CommonPdfUtil.NORMALFONT);
+        PdfPCell accountCodeHead = CommonPdfUtil.createCenterPdfPCell("账册编号", 1, 1, CommonPdfUtil.NORMALFONT);
+        PdfPCell commodityCodeHead = CommonPdfUtil.createCenterPdfPCell("商品编码", 1, 1, CommonPdfUtil.NORMALFONT);
+        PdfPCell commodityNameHead = CommonPdfUtil.createCenterPdfPCell("商品名称", 1, 1, CommonPdfUtil.NORMALFONT);
+        PdfPCell businessTypeHead = CommonPdfUtil.createCenterPdfPCell("业务类型", 1, 1, CommonPdfUtil.NORMALFONT);
+        PdfPCell accountNumberHead = CommonPdfUtil.createCenterPdfPCell("记账数量", 1, 1, CommonPdfUtil.NORMALFONT);
+        PdfPCell unitHead = CommonPdfUtil.createCenterPdfPCell("法定计量单位", 1, 1, CommonPdfUtil.NORMALFONT);
+        PdfPCell frontlineRelesasNumberHead = CommonPdfUtil.createCenterPdfPCell("一线径予放行单号", 1, 1, CommonPdfUtil.NORMALFONT);
+        PdfPCell warehouseNumberHead = CommonPdfUtil.createCenterPdfPCell("入库单号", 1, 1, CommonPdfUtil.NORMALFONT);
+        PdfPCell warehouseTimeHead = CommonPdfUtil.createCenterPdfPCell("入库日期", 1, 1, CommonPdfUtil.NORMALFONT);
+        PdfPCell accountTimeHead = CommonPdfUtil.createCenterPdfPCell("记账时间", 1, 1, CommonPdfUtil.NORMALFONT);
+
+        pdfPTable.addCell(indexNoHead);
+        pdfPTable.addCell(companyCodeHead);
+        pdfPTable.addCell(companyNameHead);
+        pdfPTable.addCell(accountTypeHead);
+        pdfPTable.addCell(accountCodeHead);
+        pdfPTable.addCell(commodityCodeHead);
+        pdfPTable.addCell(commodityNameHead);
+        pdfPTable.addCell(businessTypeHead);
+        pdfPTable.addCell(accountNumberHead);
+        pdfPTable.addCell(unitHead);
+        pdfPTable.addCell(frontlineRelesasNumberHead);
+        pdfPTable.addCell(warehouseNumberHead);
+        pdfPTable.addCell(warehouseTimeHead);
+        pdfPTable.addCell(accountTimeHead);
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        for (int i = 1; i <= records.size(); i++) {
+
+            QyFrontlineWarehouse item = records.get(i - 1);
+
+            PdfPCell indexNoCell = CommonPdfUtil.createCenterPdfPCell(String.valueOf(i), 1, 1, CommonPdfUtil.NORMALFONT);
+            PdfPCell companyCodeCell = CommonPdfUtil.createCenterPdfPCell(item.getCompanyCode(), 1, 1, CommonPdfUtil.NORMALFONT);
+            PdfPCell companyNameCell = CommonPdfUtil.createCenterPdfPCell(item.getCompanyName(), 1, 1, CommonPdfUtil.NORMALFONT);
+            PdfPCell accountTypeCell = CommonPdfUtil.createCenterPdfPCell(item.getAccountType(), 1, 1, CommonPdfUtil.NORMALFONT);
+            PdfPCell accountCodeCell = CommonPdfUtil.createCenterPdfPCell(item.getAccountCode(), 1, 1, CommonPdfUtil.NORMALFONT);
+            PdfPCell commodityCodeCell = CommonPdfUtil.createCenterPdfPCell(item.getCommodityCode(), 1, 1, CommonPdfUtil.NORMALFONT);
+            PdfPCell commodityNameCell = CommonPdfUtil.createCenterPdfPCell(item.getCommodityName(), 1, 1, CommonPdfUtil.NORMALFONT);
+            PdfPCell businessTypeCell = CommonPdfUtil.createCenterPdfPCell(item.getBusinessType(), 1, 1, CommonPdfUtil.NORMALFONT);
+            PdfPCell accountNumberCell = CommonPdfUtil.createCenterPdfPCell(item.getAccountNumber(), 1, 1, CommonPdfUtil.NORMALFONT);
+            PdfPCell unitCell = CommonPdfUtil.createCenterPdfPCell(item.getMeasurementUnit(), 1, 1, CommonPdfUtil.NORMALFONT);
+            PdfPCell frontlineRelesasNumberCell = CommonPdfUtil.createCenterPdfPCell(item.getFrontlineRelesasNumber(), 1, 1, CommonPdfUtil.NORMALFONT);
+            PdfPCell warehouseNumberCell = CommonPdfUtil.createCenterPdfPCell(item.getWarehouseNumber(), 1, 1, CommonPdfUtil.NORMALFONT);
+            PdfPCell warehouseTimeCell = CommonPdfUtil.createCenterPdfPCell(item.getAccountTime() != null ? dateFormat.format(item.getWarehouseTime()) : "", 1, 1, CommonPdfUtil.NORMALFONT);
+            PdfPCell accountTimeCell = CommonPdfUtil.createCenterPdfPCell(item.getAccountTime() != null ? dateFormat.format(item.getAccountTime()) : "", 1, 1, CommonPdfUtil.NORMALFONT);
+
+
+            pdfPTable.addCell(indexNoCell);
+            pdfPTable.addCell(companyCodeCell);
+            pdfPTable.addCell(companyNameCell);
+            pdfPTable.addCell(accountTypeCell);
+            pdfPTable.addCell(accountCodeCell);
+            pdfPTable.addCell(commodityCodeCell);
+            pdfPTable.addCell(commodityNameCell);
+            pdfPTable.addCell(businessTypeCell);
+            pdfPTable.addCell(accountNumberCell);
+            pdfPTable.addCell(unitCell);
+            pdfPTable.addCell(frontlineRelesasNumberCell);
+            pdfPTable.addCell(warehouseNumberCell);
+            pdfPTable.addCell(warehouseTimeCell);
+            pdfPTable.addCell(accountTimeCell);
+
+        }
+
+        document.add(pdfPTable);
+
+        document.close();
+
+        //上传
+        return devFileApi.storageFileWithReturnUrlLocal(CommonFileUtil.bytesToMultipartFile("一线径予放行入库业务记账管理表" + System.currentTimeMillis(),".pdf" ,os.toByteArray()));
+
+    }
 }

+ 14 - 0
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/qysecondlinewarehouse/controller/QySecondlineWarehouseController.java

@@ -171,4 +171,18 @@ public class QySecondlineWarehouseController {
     public CommonResult<QySecondlineWarehouse> detail(@Valid QySecondlineWarehouseIdParam qySecondlineWarehouseIdParam) {
         return CommonResult.data(qySecondlineWarehouseService.detail(qySecondlineWarehouseIdParam));
     }
+
+    @Operation(summary = "获取二线出岛业务记账凭证pdf")
+    @SaCheckPermission("/biz/qysecondlinewarehouse/accountVoucherPdf")
+    @GetMapping("/biz/qysecondlinewarehouse/accountVoucherPdf")
+    public CommonResult<String> accountVoucherPdf(@Valid QySecondlineWarehouseIdParam qySecondlineWarehouseIdParam) throws Exception {
+        return CommonResult.data(qySecondlineWarehouseService.accountVoucherPdf(qySecondlineWarehouseIdParam));
+    }
+
+    @Operation(summary = "获取二线出岛业务管理打印pdf")
+    @SaCheckPermission("/biz/qysecondlinewarehouse/printPdf")
+    @GetMapping("/biz/qysecondlinewarehouse/printPdf")
+    public CommonResult<String> printPdf(@Valid QySecondlineWarehousePageParam qySecondlineWarehousePageParam) throws Exception {
+        return CommonResult.data(qySecondlineWarehouseService.printPdf(qySecondlineWarehousePageParam));
+    }
 }

+ 4 - 0
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/qysecondlinewarehouse/service/QySecondlineWarehouseService.java

@@ -77,4 +77,8 @@ public interface QySecondlineWarehouseService extends IService<QySecondlineWareh
      * @date  2024/07/04 15:39
      **/
     QySecondlineWarehouse queryEntity(String id);
+
+    String accountVoucherPdf(QySecondlineWarehouseIdParam qySecondlineWarehouseIdParam) throws Exception;
+
+    String printPdf(QySecondlineWarehousePageParam qySecondlineWarehousePageParam) throws Exception;
 }

+ 200 - 1
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/qysecondlinewarehouse/service/impl/QySecondlineWarehouseServiceImpl.java

@@ -19,9 +19,18 @@ import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.itextpdf.text.Document;
+import com.itextpdf.text.PageSize;
+import com.itextpdf.text.Rectangle;
+import com.itextpdf.text.pdf.PdfPCell;
+import com.itextpdf.text.pdf.PdfPTable;
+import com.itextpdf.text.pdf.PdfWriter;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import vip.xiaonuo.biz.modular.qyfrontlinewarehouse.entity.QyFrontlineWarehouse;
+import vip.xiaonuo.biz.modular.qyfrontlinewarehouse.param.QyFrontlineWarehouseIdParam;
+import vip.xiaonuo.biz.modular.qyfrontlinewarehouse.param.QyFrontlineWarehousePageParam;
 import vip.xiaonuo.common.enums.CommonSortOrderEnum;
 import vip.xiaonuo.common.exception.CommonException;
 import vip.xiaonuo.common.page.CommonPageRequest;
@@ -32,7 +41,12 @@ import vip.xiaonuo.biz.modular.qysecondlinewarehouse.param.QySecondlineWarehouse
 import vip.xiaonuo.biz.modular.qysecondlinewarehouse.param.QySecondlineWarehouseIdParam;
 import vip.xiaonuo.biz.modular.qysecondlinewarehouse.param.QySecondlineWarehousePageParam;
 import vip.xiaonuo.biz.modular.qysecondlinewarehouse.service.QySecondlineWarehouseService;
+import vip.xiaonuo.common.util.CommonFileUtil;
+import vip.xiaonuo.common.util.CommonPdfUtil;
+import vip.xiaonuo.dev.api.DevFileApi;
 
+import java.io.ByteArrayOutputStream;
+import java.text.SimpleDateFormat;
 import java.util.List;
 
 /**
@@ -43,7 +57,8 @@ import java.util.List;
  **/
 @Service
 public class QySecondlineWarehouseServiceImpl extends ServiceImpl<QySecondlineWarehouseMapper, QySecondlineWarehouse> implements QySecondlineWarehouseService {
-
+    @Autowired
+    private DevFileApi devFileApi;
     @Override
     public Page<QySecondlineWarehouse> page(QySecondlineWarehousePageParam qySecondlineWarehousePageParam) {
         QueryWrapper<QySecondlineWarehouse> queryWrapper = new QueryWrapper<QySecondlineWarehouse>().checkSqlInjection();
@@ -141,4 +156,188 @@ public class QySecondlineWarehouseServiceImpl extends ServiceImpl<QySecondlineWa
         }
         return qySecondlineWarehouse;
     }
+
+    /**
+     * 记账凭证pdf
+     * @param qySecondlineWarehouseIdParam
+     * @return
+     * @throws Exception
+     */
+    @Override
+    public String accountVoucherPdf(QySecondlineWarehouseIdParam qySecondlineWarehouseIdParam) throws Exception {
+        String id = qySecondlineWarehouseIdParam.getId();
+        QySecondlineWarehouse qySecondlineWarehouse = this.getById(id);
+        if(ObjectUtil.isEmpty(qySecondlineWarehouse)) {
+            throw new CommonException("二线出岛业务记账管理不存在,id值为:{}", id);
+        }
+
+        QueryWrapper<QySecondlineWarehouse> queryWrapper = new QueryWrapper<QySecondlineWarehouse>().checkSqlInjection();
+
+        queryWrapper.lambda().eq(QySecondlineWarehouse::getWarehouseNumber,qySecondlineWarehouse.getWarehouseNumber());
+
+        List<QySecondlineWarehouse> list = this.list(queryWrapper);
+
+        ByteArrayOutputStream os = new ByteArrayOutputStream();
+        Document document = CommonPdfUtil.createDocument();
+        PdfWriter.getInstance(document, os);
+        document.open();
+
+        //创建表格
+        PdfPTable pdfPTable = CommonPdfUtil.createPdfPTable(7);
+
+        //设置表头
+        PdfPCell firstHead = CommonPdfUtil.createCenterPdfPCell("入库凭证", 2, 7, CommonPdfUtil.BOLDFONT);
+        pdfPTable.addCell(firstHead);
+
+        //设置账册编号
+        PdfPCell accountCodeCell = CommonPdfUtil.createCenterPdfPCell(qySecondlineWarehouse.getAccountCode(), 1, 7, CommonPdfUtil.NORMALFONT);
+        pdfPTable.addCell(accountCodeCell);
+
+        //设置二级表头
+        PdfPCell indexNoHead = CommonPdfUtil.createCenterPdfPCell("序号", 1, 1, CommonPdfUtil.NORMALFONT);
+        PdfPCell commodityNameHead = CommonPdfUtil.createCenterPdfPCell("商品名称", 1, 1, CommonPdfUtil.NORMALFONT);
+        PdfPCell specsHead = CommonPdfUtil.createCenterPdfPCell("规格", 1, 1, CommonPdfUtil.NORMALFONT);
+        PdfPCell unitHead = CommonPdfUtil.createCenterPdfPCell("单位", 1, 1, CommonPdfUtil.NORMALFONT);
+        PdfPCell accountNumberHead = CommonPdfUtil.createCenterPdfPCell("数量", 1, 1, CommonPdfUtil.NORMALFONT);
+        PdfPCell unitPriceHead= CommonPdfUtil.createCenterPdfPCell("单价", 1, 1, CommonPdfUtil.NORMALFONT);
+        PdfPCell remarkHead = CommonPdfUtil.createCenterPdfPCell("备注", 1, 1, CommonPdfUtil.NORMALFONT);
+        pdfPTable.addCell(indexNoHead);
+        pdfPTable.addCell(commodityNameHead);
+        pdfPTable.addCell(specsHead);
+        pdfPTable.addCell(unitHead);
+        pdfPTable.addCell(accountNumberHead);
+        pdfPTable.addCell(unitPriceHead);
+        pdfPTable.addCell(remarkHead);
+
+
+
+        for (int i = 1; i <= list.size(); i++) {
+            QySecondlineWarehouse item = list.get(i - 1);
+            PdfPCell indexNoCell = CommonPdfUtil.createCenterPdfPCell(String.valueOf(i),1, 1, CommonPdfUtil.NORMALFONT);
+            PdfPCell commodityNameCell = CommonPdfUtil.createCenterPdfPCell(item.getCommodityName(), 1, 1, CommonPdfUtil.NORMALFONT);
+            PdfPCell specsCell = CommonPdfUtil.createCenterPdfPCell(item.getSpecs(), 1, 1, CommonPdfUtil.NORMALFONT);
+            PdfPCell unitCell = CommonPdfUtil.createCenterPdfPCell(item.getMeasurementUnit(), 1, 1, CommonPdfUtil.NORMALFONT);
+            PdfPCell accountNumberCell = CommonPdfUtil.createCenterPdfPCell(item.getAccountNumber(), 1, 1, CommonPdfUtil.NORMALFONT);
+            PdfPCell unitPriceCell = CommonPdfUtil.createCenterPdfPCell(item.getUnitPrice(), 1, 1, CommonPdfUtil.NORMALFONT);
+            PdfPCell remarkCell = CommonPdfUtil.createCenterPdfPCell(item.getRemark(), 1, 1, CommonPdfUtil.NORMALFONT);
+
+            pdfPTable.addCell(indexNoCell);
+            pdfPTable.addCell(commodityNameCell);
+            pdfPTable.addCell(specsCell);
+            pdfPTable.addCell(unitCell);
+            pdfPTable.addCell(accountNumberCell);
+            pdfPTable.addCell(unitPriceCell);
+            pdfPTable.addCell(remarkCell);
+        }
+        PdfPCell amountCell = CommonPdfUtil.createCenterPdfPCell("合计",1, 2, CommonPdfUtil.NORMALFONT);
+        PdfPCell companyNameCell = CommonPdfUtil.createCenterPdfPCell("单位: " + qySecondlineWarehouse.getCompanyName() ,1, 3, CommonPdfUtil.NORMALFONT);
+        PdfPCell creatorCell = CommonPdfUtil.createCenterPdfPCell("制单人: "+qySecondlineWarehouse.getCreator(),1, 2, CommonPdfUtil.NORMALFONT);
+
+        pdfPTable.addCell(amountCell);
+        pdfPTable.addCell(companyNameCell);
+        pdfPTable.addCell(creatorCell);
+
+        document.add(pdfPTable);
+
+        document.close();
+
+        //上传
+
+        return devFileApi.storageFileWithReturnUrlLocal(CommonFileUtil.bytesToMultipartFile("二线出岛入账凭证" + System.currentTimeMillis(),".pdf" ,os.toByteArray()));
+
+    }
+
+    @Override
+    public String printPdf(QySecondlineWarehousePageParam qySecondlineWarehousePageParam) throws Exception {
+        qySecondlineWarehousePageParam.setSize(Integer.MAX_VALUE);
+        Page<QySecondlineWarehouse> page = this.page(qySecondlineWarehousePageParam);
+
+        List<QySecondlineWarehouse> records = page.getRecords();
+
+        ByteArrayOutputStream os = new ByteArrayOutputStream();
+        Document document = CommonPdfUtil.createDocument();
+        //横向打印
+        Rectangle rectangle = new Rectangle(PageSize.A4.rotate());
+        document.setPageSize(rectangle);
+        PdfWriter.getInstance(document, os);
+        document.open();
+
+        //创建表格
+        PdfPTable pdfPTable = CommonPdfUtil.createPdfPTable(13);
+
+        //设置表头
+        PdfPCell indexNoHead = CommonPdfUtil.createCenterPdfPCell("序号", 1, 1, CommonPdfUtil.NORMALFONT);
+        PdfPCell companyCodeHead = CommonPdfUtil.createCenterPdfPCell("企业编号", 1, 1, CommonPdfUtil.NORMALFONT);
+        PdfPCell companyNameHead = CommonPdfUtil.createCenterPdfPCell("企业名称", 1, 1, CommonPdfUtil.NORMALFONT);
+        PdfPCell accountTypeHead = CommonPdfUtil.createCenterPdfPCell("账册类型", 1, 1, CommonPdfUtil.NORMALFONT);
+        PdfPCell accountCodeHead = CommonPdfUtil.createCenterPdfPCell("账册编号", 1, 1, CommonPdfUtil.NORMALFONT);
+        PdfPCell commodityCodeHead = CommonPdfUtil.createCenterPdfPCell("商品编码", 1, 1, CommonPdfUtil.NORMALFONT);
+        PdfPCell commodityNameHead = CommonPdfUtil.createCenterPdfPCell("商品名称", 1, 1, CommonPdfUtil.NORMALFONT);
+        PdfPCell businessTypeHead = CommonPdfUtil.createCenterPdfPCell("业务类型", 1, 1, CommonPdfUtil.NORMALFONT);
+        PdfPCell accountNumberHead = CommonPdfUtil.createCenterPdfPCell("记账数量", 1, 1, CommonPdfUtil.NORMALFONT);
+        PdfPCell unitHead = CommonPdfUtil.createCenterPdfPCell("法定计量单位", 1, 1, CommonPdfUtil.NORMALFONT);
+        PdfPCell frontlineRelesasNumberHead = CommonPdfUtil.createCenterPdfPCell("二线出岛申请单号", 1, 1, CommonPdfUtil.NORMALFONT);
+        PdfPCell warehouseNumberHead = CommonPdfUtil.createCenterPdfPCell("出库单号", 1, 1, CommonPdfUtil.NORMALFONT);
+        PdfPCell warehouseTimeHead = CommonPdfUtil.createCenterPdfPCell("出库日期", 1, 1, CommonPdfUtil.NORMALFONT);
+        PdfPCell accountTimeHead = CommonPdfUtil.createCenterPdfPCell("记账时间", 1, 1, CommonPdfUtil.NORMALFONT);
+
+        pdfPTable.addCell(indexNoHead);
+        pdfPTable.addCell(companyCodeHead);
+        pdfPTable.addCell(companyNameHead);
+        pdfPTable.addCell(accountTypeHead);
+        pdfPTable.addCell(accountCodeHead);
+        pdfPTable.addCell(commodityCodeHead);
+        pdfPTable.addCell(commodityNameHead);
+        pdfPTable.addCell(businessTypeHead);
+        pdfPTable.addCell(accountNumberHead);
+        pdfPTable.addCell(unitHead);
+        pdfPTable.addCell(frontlineRelesasNumberHead);
+        pdfPTable.addCell(warehouseTimeHead);
+        pdfPTable.addCell(warehouseNumberHead);
+
+        pdfPTable.addCell(accountTimeHead);
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        for (int i = 1; i <= records.size(); i++) {
+
+            QySecondlineWarehouse item = records.get(i - 1);
+
+            PdfPCell indexNoCell = CommonPdfUtil.createCenterPdfPCell(String.valueOf(i), 1, 1, CommonPdfUtil.NORMALFONT);
+            PdfPCell companyCodeCell = CommonPdfUtil.createCenterPdfPCell(item.getCompanyCode(), 1, 1, CommonPdfUtil.NORMALFONT);
+            PdfPCell companyNameCell = CommonPdfUtil.createCenterPdfPCell(item.getCompanyName(), 1, 1, CommonPdfUtil.NORMALFONT);
+            PdfPCell accountTypeCell = CommonPdfUtil.createCenterPdfPCell(item.getAccountType(), 1, 1, CommonPdfUtil.NORMALFONT);
+            PdfPCell accountCodeCell = CommonPdfUtil.createCenterPdfPCell(item.getAccountCode(), 1, 1, CommonPdfUtil.NORMALFONT);
+            PdfPCell commodityCodeCell = CommonPdfUtil.createCenterPdfPCell(item.getCommodityCode(), 1, 1, CommonPdfUtil.NORMALFONT);
+            PdfPCell commodityNameCell = CommonPdfUtil.createCenterPdfPCell(item.getCommodityName(), 1, 1, CommonPdfUtil.NORMALFONT);
+            PdfPCell businessTypeCell = CommonPdfUtil.createCenterPdfPCell(item.getBusinessType(), 1, 1, CommonPdfUtil.NORMALFONT);
+            PdfPCell accountNumberCell = CommonPdfUtil.createCenterPdfPCell(item.getAccountNumber(), 1, 1, CommonPdfUtil.NORMALFONT);
+            PdfPCell unitCell = CommonPdfUtil.createCenterPdfPCell(item.getMeasurementUnit(), 1, 1, CommonPdfUtil.NORMALFONT);
+            PdfPCell frontlineRelesasNumberCell = CommonPdfUtil.createCenterPdfPCell(item.getSecondlineOutislandNumber(), 1, 1, CommonPdfUtil.NORMALFONT);
+            PdfPCell warehouseNumberCell = CommonPdfUtil.createCenterPdfPCell(item.getWarehouseNumber(), 1, 1, CommonPdfUtil.NORMALFONT);
+            PdfPCell warehouseTimeCell = CommonPdfUtil.createCenterPdfPCell(item.getWarehouseTime() != null ? dateFormat.format(item.getAccountTime()) : "", 1, 1, CommonPdfUtil.NORMALFONT);
+            PdfPCell accountTimeCell = CommonPdfUtil.createCenterPdfPCell(item.getAccountTime() != null ? dateFormat.format(item.getAccountTime()) : "", 1, 1, CommonPdfUtil.NORMALFONT);
+            pdfPTable.addCell(indexNoCell);
+            pdfPTable.addCell(companyCodeCell);
+            pdfPTable.addCell(companyNameCell);
+            pdfPTable.addCell(accountTypeCell);
+            pdfPTable.addCell(accountCodeCell);
+            pdfPTable.addCell(commodityCodeCell);
+            pdfPTable.addCell(commodityNameCell);
+            pdfPTable.addCell(businessTypeCell);
+            pdfPTable.addCell(accountNumberCell);
+            pdfPTable.addCell(unitCell);
+            pdfPTable.addCell(frontlineRelesasNumberCell);
+            pdfPTable.addCell(warehouseNumberCell);
+            pdfPTable.addCell(warehouseTimeCell);
+            pdfPTable.addCell(accountTimeCell);
+
+        }
+
+        document.add(pdfPTable);
+
+        document.close();
+
+        //上传
+        return devFileApi.storageFileWithReturnUrlLocal(CommonFileUtil.bytesToMultipartFile("二线出岛业务记账管理表" + System.currentTimeMillis(),".pdf" ,os.toByteArray()));
+
+    }
 }