若依+lodop+jasperreports+ireport 设计打印票据格式(二)
使用Field绑定Java传入数据
设计页表页数和当前页号
![在这里插入图片描述](https://img-blog.csdnimg.cn/7091542bd5954845b8fcf39d71d4c9e4.png#pic_cente![在这里插入图片描述](https://img-blog.csdnimg.cn/44afe6c7ddc6411392103c8237da03bb.png#pic_cen
表格绑定数据
jrxml文件内容
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="HYpdb" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="16515bc7-744b-43c7-8b4b-3a37e9b57403">
<property name="ireport.zoom" value="1.0000000000000007"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<style name="table">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 1">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table 1_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 1_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 1_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<subDataset name="tableList" uuid="1b7f8546-ab60-45af-a20a-2158a17027dd">
<field name="yYpmc" class="java.lang.String"/>
<field name="hCrdj" class="java.math.BigDecimal"/>
<field name="hCrdjSum" class="java.math.BigDecimal"/>
<field name="yCrjjSum" class="java.math.BigDecimal"/>
<field name="gxc" class="java.math.BigDecimal"/>
<field name="yCdmc" class="java.lang.String"/>
<field name="yScrq" class="java.util.Date"/>
<field name="yYxrq" class="java.util.Date"/>
<field name="yYpph" class="java.lang.String"/>
<field name="yPzwh" class="java.lang.String"/>
<field name="yYpgg" class="java.lang.String"/>
<field name="yCrjj" class="java.math.BigDecimal"/>
<field name="hCrsl" class="java.math.BigDecimal"/>
<field name="yDwmc" class="java.lang.String"/>
</subDataset>
<field name="hCrkVoList" class="java.util.Collection"/>
<field name="deptName" class="java.lang.String"/>
<field name="userName" class="java.lang.String"/>
<field name="listSize" class="java.lang.String"/>
<field name="hHdpzh" class="java.lang.String"/>
<field name="nowDate" class="java.lang.String"/>
<field name="yfmc" class="java.lang.String"/>
<field name="lwdw" class="java.lang.String"/>
<field name="sumDj" class="java.lang.String"/>
<field name="sumJj" class="java.lang.String"/>
<field name="djjjCe" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="48" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="403" height="48" uuid="9bc432eb-412f-4fa6-87bc-f4979bae2831"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font fontName="宋体" size="24"/>
</textElement>
<textFieldExpression><![CDATA[$F{deptName}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="403" y="0" width="23" height="48" uuid="43a7b71c-7e12-462a-977d-c5adde3f89cf"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="宋体" size="24"/>
</textElement>
<text><![CDATA[-]]></text>
</staticText>
<textField>
<reportElement x="426" y="0" width="376" height="48" uuid="afa8484c-037e-42ba-ae7f-48b95d97ab95"/>
<textElement verticalAlignment="Middle">
<font fontName="宋体" size="24"/>
</textElement>
<textFieldExpression><![CDATA[$F{yfmc}]]></textFieldExpression>
</textField>
</band>
</title>
<pageHeader>
<band height="32" splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="28" splitType="Stretch">
<textField>
<reportElement x="0" y="8" width="150" height="20" uuid="45fa7d17-689e-47a9-8ea4-3b34dde2db0c"/>
<textElement>
<font fontName="宋体"/>
</textElement>
<textFieldExpression><![CDATA[$F{lwdw}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="498" y="8" width="39" height="20" uuid="301c6d85-08c2-4977-9f7a-fb6b3a338abe"/>
<textElement>
<font fontName="宋体"/>
</textElement>
<text><![CDATA[页号:]]></text>
</staticText>
<textField>
<reportElement x="569" y="8" width="19" height="20" uuid="65b3af04-50bf-489a-919a-50353950514e"/>
<textElement textAlignment="Right">
<font fontName="宋体"/>
</textElement>
<textFieldExpression><![CDATA[$V{PAGE_COUNT}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="555" y="8" width="14" height="20" uuid="e2143495-2de2-4fd6-b170-73cee1f5b607"/>
<textElement textAlignment="Center">
<font fontName="宋体"/>
</textElement>
<text><![CDATA[-]]></text>
</staticText>
<textField>
<reportElement x="537" y="8" width="18" height="20" uuid="2ad349b7-57f8-4fa9-a26f-df2dc303ff66"/>
<textElement>
<font fontName="宋体"/>
</textElement>
<textFieldExpression><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="280" y="8" width="86" height="20" uuid="41ffad24-9820-4d9c-b9d1-e52976e31522"/>
<textElement textAlignment="Right">
<font fontName="宋体"/>
</textElement>
<textFieldExpression><![CDATA[$F{nowDate}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="654" y="8" width="148" height="20" uuid="50c1e0a9-6122-49d6-a889-3f07de5768e4"/>
<textElement>
<font fontName="宋体"/>
</textElement>
<textFieldExpression><![CDATA[$F{hHdpzh}]]></textFieldExpression>
</textField>
</band>
</columnHeader>
<detail>
<band height="95" splitType="Stretch">
<componentElement>
<reportElement key="table 1" style="table 1" x="0" y="0" width="802" height="95" uuid="c97d6a22-30cd-4919-879b-062db782bae7"/>
<jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
<datasetRun subDataset="tableList" uuid="38b661af-5c5e-4661-adb4-a137e67f061a">
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{hCrkVoList})]]></dataSourceExpression>
</datasetRun>
<jr:column width="187" uuid="639ead4d-d1ac-457f-a08e-7940c42d0a43">
<jr:columnHeader style="table_TD" height="90" rowSpan="2">
<staticText>
<reportElement x="0" y="0" width="187" height="90" uuid="7aaeac31-9655-4db5-ab2d-61ccefd5afc3"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="宋体"/>
</textElement>
<text><![CDATA[药品名称]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="table_TD" height="29" rowSpan="1"/>
<jr:detailCell style="table 1_TD" height="30" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="187" height="30" uuid="e4d22836-5a05-416d-bcd6-3e1cd6d7fa08"/>
<textElement>
<font fontName="宋体"/>
</textElement>
<textFieldExpression><![CDATA[$F{yYpmc}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="50" uuid="e8d7f867-ad3d-4e80-a32a-7cb71da70b76">
<jr:tableHeader height="0" rowSpan="1"/>
<jr:tableFooter height="0" rowSpan="1"/>
<jr:columnHeader style="table_TD" height="90" rowSpan="2">
<staticText>
<reportElement x="0" y="0" width="50" height="90" uuid="9d8aa18d-bbe3-4d0d-9014-6b5dcf82bd34"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="宋体"/>
</textElement>
<text><![CDATA[出入数量]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="table_TD" height="29" rowSpan="1"/>
<jr:detailCell style="table 1_TD" height="30" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="29" height="15" uuid="af691569-e360-4599-afef-5180bbb037d8"/>
<textElement>
<font fontName="宋体"/>
</textElement>
<textFieldExpression><![CDATA[$F{hCrsl}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="29" y="0" width="21" height="15" uuid="c43b1193-174f-44b2-9ee4-f4e2cee7c954"/>
<textElement>
<font fontName="宋体"/>
</textElement>
<textFieldExpression><![CDATA[$F{yDwmc}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:columnGroup width="100" uuid="b64ad506-24df-4b74-ab3e-6c9bc6032136">
<jr:columnHeader style="table_TD" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="100" height="30" uuid="6bbad341-1ab3-4064-af18-8c5407b0fe71"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[购进]]></text>
</staticText>
</jr:columnHeader>
<jr:column width="50" uuid="b236e509-9bfb-48ba-81f5-31a7e2bcd5a7">
<jr:columnHeader style="table_TD" height="60" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="50" height="60" uuid="c727fb4f-c821-4133-a9de-0192f59cfdf3"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="宋体"/>
</textElement>
<text><![CDATA[单价]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="table_TD" height="29" rowSpan="1"/>
<jr:detailCell style="table 1_TD" height="30" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="50" height="30" uuid="e21da28e-e6c8-4236-b611-3090aef3654e"/>
<textElement>
<font fontName="宋体"/>
</textElement>
<textFieldExpression><![CDATA[$F{yCrjj}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="50" uuid="425e0c7b-1d40-466a-86c3-7627c4187fca">
<jr:columnHeader style="table_TD" height="60" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="50" height="60" uuid="f6980d54-b4cd-4065-ad85-505cad317c52"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="宋体"/>
</textElement>
<text><![CDATA[金额]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="table_TD" height="29" rowSpan="1"/>
<jr:detailCell style="table 1_TD" height="30" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="50" height="30" uuid="65f12aa5-c0a5-42eb-a336-b5cb732849af"/>
<textElement>
<font fontName="宋体"/>
</textElement>
<textFieldExpression><![CDATA[$F{yCrjjSum}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:columnGroup>
<jr:columnGroup width="100" uuid="69d05199-174f-4e2b-ba4e-4b3952f27ae5">
<jr:columnHeader style="table_TD" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="100" height="30" uuid="0a633d9d-cc93-49d5-a409-deddf69ccabb"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="宋体"/>
</textElement>
<text><![CDATA[零售]]></text>
</staticText>
</jr:columnHeader>
<jr:column width="50" uuid="7c403cfb-09ed-441e-a923-c504738dafc5">
<jr:columnHeader style="table_TD" height="60" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="50" height="60" uuid="5d231d1e-d942-4bde-a440-7cfc260e3652"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="宋体"/>
</textElement>
<text><![CDATA[单价]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="table_TD" height="29" rowSpan="1"/>
<jr:detailCell style="table 1_TD" height="30" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="50" height="30" uuid="aebc4466-b55e-45aa-b6ba-473a696de453"/>
<textFieldExpression><![CDATA[$F{hCrdj}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="50" uuid="e8319626-d2da-4cf7-bf6f-221e4a5f85a9">
<jr:columnHeader style="table_TD" height="60" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="50" height="60" uuid="9238b6cc-2289-4b78-af67-9571207634f8"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="宋体"/>
</textElement>
<text><![CDATA[金额]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="table_TD" height="29" rowSpan="1"/>
<jr:detailCell style="table 1_TD" height="30" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="50" height="30" uuid="bf6e7415-5c8e-4d6a-aa18-0f9fc2627fef"/>
<textElement>
<font fontName="宋体"/>
</textElement>
<textFieldExpression><![CDATA[$F{hCrdjSum}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:columnGroup>
<jr:column width="50" uuid="031aed40-561e-4120-b1a7-a09235c9b53c">
<jr:columnHeader style="table_TD" height="90" rowSpan="2">
<staticText>
<reportElement x="0" y="0" width="50" height="90" uuid="2f3103b8-d1a1-46d3-8a82-92b5b5159ea2"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="宋体"/>
</textElement>
<text><![CDATA[购销差]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="table_TD" height="29" rowSpan="1"/>
<jr:detailCell style="table 1_TD" height="30" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="50" height="30" uuid="d0430f10-6f4f-4620-8dca-cd9a204b8e70"/>
<textElement>
<font fontName="宋体"/>
</textElement>
<textFieldExpression><![CDATA[$F{gxc}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="130" uuid="d2adb8ab-d1f5-4492-a856-dc90238affca">
<jr:columnHeader style="table_TD" height="90" rowSpan="2">
<staticText>
<reportElement x="0" y="0" width="130" height="90" uuid="06776ada-7d2e-4d9f-a574-632a0ff21ece"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="宋体"/>
</textElement>
<text><![CDATA[产地]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="table_TD" height="29" rowSpan="1"/>
<jr:detailCell style="table 1_TD" height="30" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="130" height="30" uuid="bd654576-6528-474c-a8a9-c28d63d69a4e"/>
<textElement>
<font fontName="宋体"/>
</textElement>
<textFieldExpression><![CDATA[$F{yCdmc}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="70" uuid="ab5d070a-72fb-4289-89d1-57d3d7463806">
<jr:tableHeader height="0" rowSpan="1"/>
<jr:tableFooter height="0" rowSpan="1"/>
<jr:columnHeader style="table_TD" height="90" rowSpan="2">
<staticText>
<reportElement x="0" y="0" width="70" height="90" uuid="a3d60bad-d27a-4de4-b956-0981bd6c5dbe"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="宋体"/>
</textElement>
<text><![CDATA[生产日期]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="table_TD" height="29" rowSpan="1"/>
<jr:detailCell style="table 1_TD" height="30" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="70" height="30" uuid="31d7590d-0002-40d8-a913-bfedb922ba54"/>
<textElement>
<font fontName="宋体"/>
</textElement>
<textFieldExpression><![CDATA[$F{yScrq}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="70" uuid="b372b8bb-92a7-4bad-ba7c-5a2f6394bc26">
<jr:tableHeader height="0" rowSpan="1"/>
<jr:tableFooter height="0" rowSpan="1"/>
<jr:columnHeader style="table_TD" height="90" rowSpan="2">
<staticText>
<reportElement x="0" y="0" width="70" height="90" uuid="ab8422c1-bf3b-455b-87e4-33af3513454a"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="宋体"/>
</textElement>
<text><![CDATA[有效日期]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="table_TD" height="29" rowSpan="1"/>
<jr:detailCell style="table 1_TD" height="30" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="70" height="30" uuid="a5933046-200b-4826-81fc-4b7b5f63c92e"/>
<textElement>
<font fontName="宋体"/>
</textElement>
<textFieldExpression><![CDATA[$F{yYxrq}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="70" uuid="660e4b59-7cc3-4fb9-8780-1d2d1b5754f1">
<jr:tableHeader height="0" rowSpan="1"/>
<jr:tableFooter height="0" rowSpan="1"/>
<jr:columnHeader style="table_TD" height="90" rowSpan="2">
<staticText>
<reportElement x="0" y="0" width="70" height="90" uuid="1d1e1d95-2ee0-4e43-858e-736d50ae59ad"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="宋体"/>
</textElement>
<text><![CDATA[批号]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="table_TD" height="29" rowSpan="1"/>
<jr:detailCell style="table 1_TD" height="30" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="70" height="30" uuid="92d09bf7-f403-4838-9be3-c8059b6b2b45"/>
<textElement>
<font fontName="宋体"/>
</textElement>
<textFieldExpression><![CDATA[$F{yYpph}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90" uuid="f3862395-b1bb-46c6-a715-5a5452458e2a">
<jr:tableHeader height="0" rowSpan="1"/>
<jr:tableFooter height="0" rowSpan="1"/>
<jr:columnHeader style="table_TD" height="90" rowSpan="2">
<staticText>
<reportElement x="0" y="0" width="90" height="90" uuid="8d8860e3-e356-488b-9359-b7e9b0f80f46"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="宋体"/>
</textElement>
<text><![CDATA[批准文号]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="table_TD" height="29" rowSpan="1"/>
<jr:detailCell style="table 1_TD" height="30" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="90" height="30" uuid="c89a3f92-4ce1-477e-b7cb-8a0318dc8b5b"/>
<textElement>
<font fontName="宋体"/>
</textElement>
<textFieldExpression><![CDATA[$F{yPzwh}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</band>
</detail>
<columnFooter>
<band height="47" splitType="Stretch">
<textField>
<reportElement x="726" y="0" width="76" height="20" uuid="af3e3a6c-b9cc-4bf1-a45b-65ab2cbaeecf"/>
<textElement textAlignment="Right">
<font fontName="宋体"/>
</textElement>
<textFieldExpression><![CDATA[$F{userName}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="0" width="85" height="20" uuid="21610dec-a675-4a5e-a162-40bb90ec200e"/>
<textElement>
<font fontName="宋体"/>
</textElement>
<textFieldExpression><![CDATA[$F{listSize}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="180" y="0" width="116" height="20" uuid="9b11f388-9a9c-4810-a069-4af7dc5df0e4"/>
<textElement>
<font fontName="宋体"/>
</textElement>
<textFieldExpression><![CDATA[$F{sumDj}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="326" y="0" width="125" height="20" uuid="a660e22c-da82-45d5-85d3-b3d85e3781f8"/>
<textElement>
<font fontName="宋体"/>
</textElement>
<textFieldExpression><![CDATA[$F{sumJj}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="512" y="0" width="114" height="20" uuid="dd7f30c5-985f-4996-831e-707e88fc1e29"/>
<textElement>
<font fontName="宋体"/>
</textElement>
<textFieldExpression><![CDATA[$F{djjjCe}]]></textFieldExpression>
</textField>
</band>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport>
java 代码
package com.qlh.yhis.web.controller.yf.ireport.prints.bean;
import com.qlh.yhis.common.utils.SecurityUtils;
import com.qlh.yhis.web.controller.yf.ireport.prints.IHandler;
import com.qlh.yhis.web.controller.yf.ireport.prints.PrintSetting;
import com.qlh.yhis.yf.domain.HCrk;
import com.qlh.yhis.yf.service.IHCrkService;
import com.qlh.yhis.yf.vo.HCrkVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
@Component
public class HCrkPrint implements IHandler {
protected Logger logger = LoggerFactory.getLogger(HCrkPrint.class);
@Autowired
private IHCrkService hCrkService;
/**
* 如果不设置的话 那么就取默认的
*
* @param setting
* @return
*/
@Override
public void getPrintSetting(PrintSetting setting) {
}
@Override
public void getParameters(Map<String, Object> map, Map<String, Object> response) {
try{
}catch (Exception e){
e.printStackTrace();
logger.error("打印失败:{}",e.getMessage());
}
}
/**
* 获取Field参数
*
* @param request
* @param records
*/
@Override
public void getFields(Map<String, Object> request, List<Map<String, Object>> records) {
HCrk hCrk = new HCrk();
String hHdpzh = request.get("hHdpzh")+"";
hCrk.sethHdpzh(hHdpzh);
hCrk.sethCk(new Long(request.get("hCk")+""));
hCrk.setDeptId(SecurityUtils.getDeptId());
List<HCrkVo> list = hCrkService.selectHCrkVoList(hCrk);
//显示数据
Map<String, Object> response = new HashMap<>();
//核对凭证号
response.put("hHdpzh","No:"+hHdpzh);
//打印时间
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String time = sdf.format(new Date());
response.put("nowDate",time);
//机构名
response.put("deptName", SecurityUtils.getDept().getDeptName());
//出库还是入库
if("1"==request.get("hCk")+"" ||"1".equals(request.get("hCk")+"")){
//药房名
response.put("yfmc",list.get(0).gethYfmc()+"-出库单");
}else{
response.put("yfmc",list.get(0).gethYfmc()+"-入库单");
};
List<HCrkVo> hCrkVoList = new ArrayList<>();
//总销售价与进价
BigDecimal sumdj = new BigDecimal("0.00");
BigDecimal sumjj = new BigDecimal("0.00");
for (int i = 0; i < list.size(); i++) {
HCrkVo hCrkVo = list.get(i);
sumdj = sumdj.add(hCrkVo.gethCrdjSum());
sumjj = sumjj.add(hCrkVo.getyCrjjSum());
//设置药品名称规格
hCrkVo.setyYpmc(hCrkVo.getyYpmc()+"/"+hCrkVo.getyYpgg());
hCrkVoList.add(hCrkVo);
};
response.put("sumDj","零售:"+sumdj);
response.put("sumPj","购进:"+sumjj);
response.put("djjjCe","差额:"+(sumdj.subtract(sumjj)));
//往来单位
response.put("lwdw",list.get(0).getWlDwmc());
if("P".equals(hHdpzh.charAt(0)+"") || "P" == hHdpzh.charAt(0)+"" ){
response.put("lwdw","往来单位:盘点");
} else if ("D".equals(hHdpzh.charAt(0)+"") || "D" == hHdpzh.charAt(0)+"" ){
response.put("lwdw","往来单位:调拨");
}else{
response.put("lwdw","往来单位:"+list.get(0).getWlDwmc());
}
;
//表单数据
response.put("hCrkVoList",hCrkVoList);
//制单人
response.put("userName","制单人:"+SecurityUtils.getLoginUser().getUsername());
//总条数
response.put("listSize","总笔数:"+hCrkVoList.size());
records.add(response);
}
}