|
@@ -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()));
|
|
|
+
|
|
|
+ }
|
|
|
}
|