|
@@ -46,6 +46,7 @@ import java.io.ByteArrayOutputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.UUID;
|
|
|
|
|
@@ -190,33 +191,91 @@ public class QyFrontlineWarehouseServiceImpl extends ServiceImpl<QyFrontlineWare
|
|
|
PdfWriter.getInstance(document, os);
|
|
|
document.open();
|
|
|
|
|
|
- String headName = "入库凭证";
|
|
|
+ String headName = "入库单";
|
|
|
|
|
|
if("1".equals(qyFrontlineWarehouse.getWarehouseType())){
|
|
|
- headName = "出库凭证";
|
|
|
+ headName = "出库单";
|
|
|
+ }
|
|
|
+ //公用
|
|
|
+ String warehouseTypeName = "入库" ;
|
|
|
+ if("1".equals(qyFrontlineWarehouse.getWarehouseType())){
|
|
|
+ warehouseTypeName = "出库";
|
|
|
}
|
|
|
|
|
|
+ headName = qyFrontlineWarehouse.getCompanyName() + headName;
|
|
|
+
|
|
|
//创建表格
|
|
|
- PdfPTable pdfPTable = CommonPdfUtil.createPdfPTable(7);
|
|
|
+ PdfPTable pdfPTable = CommonPdfUtil.createPdfPTable(8);
|
|
|
// //设置列宽
|
|
|
// pdfPTable.setWidths(new float[]{2f,6f,3f,2f,2f,3f,5f});
|
|
|
//设置表头
|
|
|
- PdfPCell firstHead = CommonPdfUtil.createCenterPdfPCell(headName, 2, 7, CommonPdfUtil.BOLDFONT);
|
|
|
+ PdfPCell firstHead = CommonPdfUtil.createCenterPdfPCell(headName, 2, 8, CommonPdfUtil.BOLDFONT);
|
|
|
pdfPTable.addCell(firstHead);
|
|
|
|
|
|
- //设置账册编号
|
|
|
- PdfPCell accountCodeCell = CommonPdfUtil.createCenterPdfPCell("NO:"+qyFrontlineWarehouse.getAccountCode(), 1, 7, CommonPdfUtil.NORMALFONT);
|
|
|
- //设置文字居右
|
|
|
- accountCodeCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
|
|
|
- pdfPTable.addCell(accountCodeCell);
|
|
|
+ //第二行内容_出入库类型
|
|
|
+ String typeName = warehouseTypeName + "类型:";
|
|
|
+ PdfPCell typeHead = CommonPdfUtil.createCenterPdfPCell(typeName+"销售"+warehouseTypeName, 1, 3, CommonPdfUtil.NORMALFONT);
|
|
|
+ typeHead.setHorizontalAlignment(Element.ALIGN_LEFT);
|
|
|
+ pdfPTable.addCell(typeHead);
|
|
|
+
|
|
|
+ //第二行内容_仓库
|
|
|
+ String ckName = warehouseTypeName + "仓库:";
|
|
|
+ PdfPCell ckHead = CommonPdfUtil.createCenterPdfPCell(ckName+"料件仓库", 1, 3, CommonPdfUtil.NORMALFONT);
|
|
|
+ ckHead.setHorizontalAlignment(Element.ALIGN_LEFT);
|
|
|
+ pdfPTable.addCell(ckHead);
|
|
|
+
|
|
|
+ //第二行内容_单号
|
|
|
+ String dhName = warehouseTypeName + "单号:";
|
|
|
+ PdfPCell dhHead = CommonPdfUtil.createCenterPdfPCell(dhName+qyFrontlineWarehouse.getWarehouseNumber(), 1, 2, CommonPdfUtil.NORMALFONT);
|
|
|
+ dhHead.setHorizontalAlignment(Element.ALIGN_LEFT);
|
|
|
+ pdfPTable.addCell(dhHead);
|
|
|
+
|
|
|
+ //第三行内容_往来对象
|
|
|
+ String wldxName = "往来对象:";
|
|
|
+ PdfPCell wldxHead = CommonPdfUtil.createCenterPdfPCell(wldxName+"哈尔滨怡康药业邮箱公司", 1, 3, CommonPdfUtil.NORMALFONT);
|
|
|
+ wldxHead.setHorizontalAlignment(Element.ALIGN_LEFT);
|
|
|
+ pdfPTable.addCell(wldxHead);
|
|
|
+
|
|
|
+ //第三行内容_经手人
|
|
|
+ String jsrName = "经手人:";
|
|
|
+ PdfPCell jsrHead = CommonPdfUtil.createCenterPdfPCell(jsrName+"钱晓红", 1, 3, CommonPdfUtil.NORMALFONT);
|
|
|
+ jsrHead.setHorizontalAlignment(Element.ALIGN_LEFT);
|
|
|
+ pdfPTable.addCell(jsrHead);
|
|
|
+
|
|
|
+
|
|
|
+ //第三行内容_经手人
|
|
|
+ String rqName = warehouseTypeName + "日期:";
|
|
|
+ Date warehouseTime = qyFrontlineWarehouse.getWarehouseTime();
|
|
|
+ String rqValue ="";
|
|
|
+ if(warehouseTime != null){
|
|
|
+ rqValue = new SimpleDateFormat("yyyy-MM-dd").format(warehouseTime);
|
|
|
+ }
|
|
|
+ PdfPCell rqHead = CommonPdfUtil.createCenterPdfPCell(rqName+rqValue, 1, 2, CommonPdfUtil.NORMALFONT);
|
|
|
+ rqHead.setHorizontalAlignment(Element.ALIGN_LEFT);
|
|
|
+ pdfPTable.addCell(rqHead);
|
|
|
+
|
|
|
+
|
|
|
+ //第四行内容——地址备注
|
|
|
+ String dzName = "地址备注:";
|
|
|
+ PdfPCell dzHead = CommonPdfUtil.createCenterPdfPCell(dzName+"顺丰快递", 1, 7, CommonPdfUtil.NORMALFONT);
|
|
|
+ dzHead.setHorizontalAlignment(Element.ALIGN_LEFT);
|
|
|
+ pdfPTable.addCell(dzHead);
|
|
|
+
|
|
|
+ String ymName = "第1/1页";
|
|
|
+ PdfPCell ymHead = CommonPdfUtil.createCenterPdfPCell(ymName, 1, 1, CommonPdfUtil.NORMALFONT);
|
|
|
+ ymHead.setHorizontalAlignment(Element.ALIGN_RIGHT);
|
|
|
+ pdfPTable.addCell(ymHead);
|
|
|
|
|
|
//设置二级表头
|
|
|
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 commodityNameHead = CommonPdfUtil.createCenterPdfPCell("品名", 1, 1, CommonPdfUtil.NORMALFONT);
|
|
|
+ PdfPCell specsHead = CommonPdfUtil.createCenterPdfPCell("规格型号", 1, 1, CommonPdfUtil.NORMALFONT);
|
|
|
PdfPCell accountNumberHead = CommonPdfUtil.createCenterPdfPCell("数量", 1, 1, CommonPdfUtil.NORMALFONT);
|
|
|
+ PdfPCell unitHead = CommonPdfUtil.createCenterPdfPCell("单位", 1, 1, CommonPdfUtil.NORMALFONT);
|
|
|
PdfPCell unitPriceHead= CommonPdfUtil.createCenterPdfPCell("单价", 1, 1, CommonPdfUtil.NORMALFONT);
|
|
|
+
|
|
|
+ PdfPCell jeHead= CommonPdfUtil.createCenterPdfPCell("金额", 1, 1, CommonPdfUtil.NORMALFONT);
|
|
|
+
|
|
|
PdfPCell remarkHead = CommonPdfUtil.createCenterPdfPCell("备注", 1, 1, CommonPdfUtil.NORMALFONT);
|
|
|
pdfPTable.addCell(indexNoHead);
|
|
|
pdfPTable.addCell(commodityNameHead);
|
|
@@ -224,18 +283,31 @@ public class QyFrontlineWarehouseServiceImpl extends ServiceImpl<QyFrontlineWare
|
|
|
pdfPTable.addCell(unitHead);
|
|
|
pdfPTable.addCell(accountNumberHead);
|
|
|
pdfPTable.addCell(unitPriceHead);
|
|
|
+ pdfPTable.addCell(jeHead);
|
|
|
pdfPTable.addCell(remarkHead);
|
|
|
|
|
|
|
|
|
+ //金额
|
|
|
BigDecimal amount = BigDecimal.ZERO;
|
|
|
+ //数量
|
|
|
+ BigDecimal total = BigDecimal.ZERO;
|
|
|
|
|
|
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 unitCell = CommonPdfUtil.createCenterPdfPCell(item.getMeasurementUnit(), 1, 1, CommonPdfUtil.NORMALFONT);
|
|
|
+ BigDecimal subAmount = BigDecimal.ZERO;
|
|
|
+ try {
|
|
|
+ subAmount = new BigDecimal(item.getAccountNumber()).multiply(new BigDecimal(item.getUnitPrice()));
|
|
|
+ }catch (Exception e){
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ PdfPCell jeCell = CommonPdfUtil.createCenterPdfPCell(subAmount.toPlainString(), 1, 1, CommonPdfUtil.NORMALFONT);
|
|
|
PdfPCell unitPriceCell = CommonPdfUtil.createCenterPdfPCell(item.getUnitPrice(), 1, 1, CommonPdfUtil.NORMALFONT);
|
|
|
PdfPCell remarkCell = CommonPdfUtil.createCenterPdfPCell(item.getRemark(), 1, 1, CommonPdfUtil.NORMALFONT);
|
|
|
|
|
@@ -244,30 +316,49 @@ public class QyFrontlineWarehouseServiceImpl extends ServiceImpl<QyFrontlineWare
|
|
|
pdfPTable.addCell(specsCell);
|
|
|
pdfPTable.addCell(unitCell);
|
|
|
pdfPTable.addCell(accountNumberCell);
|
|
|
+ pdfPTable.addCell(jeCell);
|
|
|
pdfPTable.addCell(unitPriceCell);
|
|
|
pdfPTable.addCell(remarkCell);
|
|
|
-
|
|
|
+ //防止错填数据转换不成数字类型报错导致报错
|
|
|
+ amount = amount.add(subAmount);
|
|
|
try {
|
|
|
- //防止错填数据转换不成数字类型报错导致报错
|
|
|
- amount = amount.add(new BigDecimal(item.getAccountNumber()).multiply(new BigDecimal(item.getUnitPrice())));
|
|
|
-
|
|
|
+ total = total.add(new BigDecimal(item.getAccountNumber()));
|
|
|
}catch (Exception e){
|
|
|
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- //计算合计
|
|
|
|
|
|
- PdfPCell amountCell = CommonPdfUtil.createCenterPdfPCell("合计:"+amount.toPlainString(),1, 2, CommonPdfUtil.NORMALFONT);
|
|
|
+ //底部第一行_数量总计
|
|
|
+ PdfPCell slCell = CommonPdfUtil.createCenterPdfPCell("数量总计:"+total.toPlainString(),1, 3, CommonPdfUtil.NORMALFONT);
|
|
|
+ slCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
|
|
+ PdfPCell amountCell = CommonPdfUtil.createCenterPdfPCell("金额总计:"+amount.toPlainString(),1, 3, CommonPdfUtil.NORMALFONT);
|
|
|
amountCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
|
|
- PdfPCell companyNameCell = CommonPdfUtil.createCenterPdfPCell("单位: " + qyFrontlineWarehouse.getCompanyName() ,1, 3, CommonPdfUtil.NORMALFONT);
|
|
|
- companyNameCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
|
|
+ //底部第一行_实收
|
|
|
+ PdfPCell ssCell = CommonPdfUtil.createCenterPdfPCell("实收 现金¥:"+amount.toPlainString(),1, 2, CommonPdfUtil.NORMALFONT);
|
|
|
+ ssCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
|
|
+ //底部第二行_制单人
|
|
|
PdfPCell creatorCell = CommonPdfUtil.createCenterPdfPCell("制单人: "+qyFrontlineWarehouse.getCreator(),1, 2, CommonPdfUtil.NORMALFONT);
|
|
|
- creatorCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
|
|
+ //底部第二行_审核人
|
|
|
+ PdfPCell shrCell = CommonPdfUtil.createCenterPdfPCell("审核人: "+"王凯",1, 2, CommonPdfUtil.NORMALFONT);
|
|
|
+ //底部第二行_发货人
|
|
|
+ PdfPCell fhrCell = CommonPdfUtil.createCenterPdfPCell("发货人: "+"刘晨",1, 2, CommonPdfUtil.NORMALFONT);
|
|
|
+ //底部第二行_收货人
|
|
|
+ PdfPCell shCell = CommonPdfUtil.createCenterPdfPCell("收货人: "+"张详",1, 2, CommonPdfUtil.NORMALFONT);
|
|
|
+
|
|
|
+
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ pdfPTable.addCell(slCell);
|
|
|
pdfPTable.addCell(amountCell);
|
|
|
- pdfPTable.addCell(companyNameCell);
|
|
|
+ pdfPTable.addCell(ssCell);
|
|
|
pdfPTable.addCell(creatorCell);
|
|
|
+ pdfPTable.addCell(shrCell);
|
|
|
+ pdfPTable.addCell(fhrCell);
|
|
|
+ pdfPTable.addCell(shCell);
|
|
|
+
|
|
|
|
|
|
document.add(pdfPTable);
|
|
|
|