当前位置: 首页 > 知识库问答 >
问题:

如何打印所有发票ID并使用iReport循环它们

洪逸清
2023-03-14

我已经创建了一个报告来打印详细信息。我需要在同一个文档中打印所有的invoiceid,并循环浏览它们,但我找不到方法。我需要如何打印所有发票?

主要报告:

<?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="esr-design-40" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="595" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" >
<property name="com.jasperassistant.designer.GridHeight" value="12"/>
<property name="com.jasperassistant.designer.GridWidth" value="12"/>
<property name="com.jasperassistant.designer.SnapToGrid" value="false"/>
<property name="com.jasperassistant.designer.Grid" value="false"/>
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="16"/>
<property name="ireport.y" value="0"/>
<scriptlet name="esrgenerator" class="dk.comtalk.billing.server.util.ESRGenerator"/>
<parameter name="printAmount" class="java.lang.String"/>
<parameter name="invoiceId" class="java.lang.Integer"/>
<parameter name="customerId" class="java.lang.String"/>
<parameter name="entityName" class="java.lang.String"/>
<parameter name="entityAddress" class="java.lang.String"/>
<parameter name="entityCity" class="java.lang.String"/>
<parameter name="entityProvince" class="java.lang.String"/>
<parameter name="entityPostalCode" class="java.lang.String"/>
<parameter name="customerName" class="java.lang.String"/>
<parameter name="customerAddress" class="java.lang.String"/>
<parameter name="customerCity" class="java.lang.String"/>
<parameter name="customerProvince" class="java.lang.String"/>
<parameter name="customerPostalCode" class="java.lang.String"/>
<parameter name="entityLogo" class="java.io.File"/>
<parameter name="countryCode" class="java.lang.String"/>
<parameter name="balance" class="java.lang.String"/>
<parameter name="carriedBalance" class="java.lang.String"/>
<parameter name="invoiceDueDate" class="java.lang.String"/>
<parameter name="totalWithTax" class="java.lang.String"/>
<parameter name="newStatusId" class="java.lang.Integer"/>
<parameter name="invoiceDate" class="java.lang.String"/>
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
    <defaultValueExpression><![CDATA["D:\\Ravi Workspace\\Openbrm\\open-brm-openbrm-2.0\\resources\\designs\\"]]></defaultValueExpression>
</parameter>
<queryString>
    <![CDATA[select count(*) from payment_invoice p where p.invoice_id=$P{invoiceId};]]>
</queryString>
<field name="payment_count" class="java.lang.Integer"/>
<group name="invoice_total">
    <groupFooter>
        <band/>
    </groupFooter>
</group>
<title>
    <band height="430">
        <image>
            <reportElement x="8" y="0" width="185" height="48" />
            <imageExpression><![CDATA[$P{entityLogo}]]></imageExpression>
        </image>
        <textField>
            <reportElement x="57" y="120" width="181" height="14" />
            <textFieldExpression><![CDATA[$P{customerName}]]> </textFieldExpression>
        </textField>
        <textField>
            <reportElement x="57" y="148" width="294" height="14" />
            <textFieldExpression><![CDATA[$P{customerPostalCode}+ " " + $P{customerCity}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="57" y="162" width="211" height="14" />
            <textFieldExpression><![CDATA[$P{countryCode}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="57" y="134" width="181" height="14" />
            <textFieldExpression><![CDATA[$P{customerAddress}]]></textFieldExpression>
        </textField>
        <staticText>
            <reportElement x="384" y="103" width="200" height="28" />
            <textElement>
                <font size="11" isBold="true"/>
            </textElement>
            <text><![CDATA[1. opomena za neizmireni racun]]></text>
        </staticText>
        <staticText>
            <reportElement x="405" y="173" width="179" height="14" />
            <text><![CDATA[Wangen b. Brüttisellen, 13.12.2015]]></text>
        </staticText>
        <staticText>
            <reportElement x="36" y="201" width="328" height="19" />
            <text><![CDATA[Postovani gospodine/postovana gospodjo,]]></text>
        </staticText>
        <staticText>
            <reportElement x="36" y="220" width="544" height="35" />
            <text><![CDATA[Dozvolite da Vas podsetimo da je, po podacima naseg knjigovodstva od danasnjeg dana, sledeci telefonski racun jos otvoren:]]></text>
        </staticText>
        <staticText>
            <reportElement x="35" y="317" width="549" height="34" />
            <text><![CDATA[Ukoliko je Vasa uplata za ovde navedeni racun u medjuvremenu vec izvrsena, nemojte uzimati ovu opomenu u obzir. Ukoliko jos nije, molimo Vas da izvrsite uplatu izvrsite odmah.]]></text>
        </staticText>
        <staticText>
            <reportElement x="35" y="351" width="557" height="69" />
            <text><![CDATA[Imajte u vidu da se kod opomena, uz regularni racun, placa administrativna taksa za obradu u visini od Fr. 20.00. Ev.deaktivacija servisa se, takodje, naplacuje, dodatnih Fr. 20.00. Molimo Vas stoga za postovanje nasih rokova uplate.

  Najlepse hvala.]]></text>
        </staticText>
        <subreport>
            <reportElement x="36" y="268" width="559" height="60" />
            <subreportParameter name="invoiceId">
                <subreportParameterExpression><![CDATA[$P{invoiceId}]]></subreportParameterExpression>
            </subreportParameter>
            <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
            <subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "ageing-esr-40-srpski-subreport.jasper"]]></subreportExpression>
        </subreport>
    </band>
</title>
<pageHeader>
    <band height="117">
        <staticText>
            <reportElement x="36" y="101" width="576" height="16" />
            <text><![CDATA[Symphonica AG | Hegnaustrasse 17 | 8602 Wangen b. Brüttisellen | Telefon 0840 988 988 | Fax 043 536 05 43]]></text>
        </staticText>
        <staticText>
            <reportElement x="35" y="8" width="243" height="26" />
            <text><![CDATA[S postovanjem,
     BALKATEL | Symphonica A.D.]]></text>
        </staticText>
    </band>
</pageHeader>
<summary>
    <band height="294">
        <textField>
            <reportElement x="5" y="56" width="123" height="14" />
            <textFieldExpression><![CDATA[$P{entityName}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="5" y="68" width="153" height="14" />
            <textFieldExpression><![CDATA[$P{entityAddress}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="5" y="81" width="226" height="14" />
            <textFieldExpression><![CDATA[$P{entityPostalCode}+ " " + $P{entityCity}]]></textFieldExpression>
        </textField>
        <staticText>
            <reportElement x="5" y="26" width="100" height="15" />
            <text><![CDATA[6301 Zug]]></text>
        </staticText>
        <staticText>
            <reportElement x="179" y="26" width="100" height="15" />
            <text><![CDATA[6301 Zug]]></text>
        </staticText>
        <textField>
            <reportElement x="179" y="56" width="123" height="14" />
            <textFieldExpression><![CDATA[$P{entityName}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="179" y="68" width="149" height="14" />
            <textFieldExpression><![CDATA[$P{entityAddress}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="179" y="81" width="226" height="14" />
            <textFieldExpression><![CDATA[$P{entityPostalCode}+ " " + $P{entityCity}]]></textFieldExpression>
        </textField>
        <staticText>
            <reportElement x="97" y="110" width="100" height="14" />
            <text><![CDATA[01-2653-5]]></text>
        </staticText>
        <staticText>
            <reportElement x="272" y="110" width="100" height="16" />
            <text><![CDATA[01-2653-5]]></text>
        </staticText>
        <textField>
            <reportElement x="169" y="236" width="640" height="30" />
            <textElement textAlignment="Left">
                <font fontName="SansSerif" size="13"/>
            </textElement>
            <textFieldExpression><![CDATA[$P{esrgenerator_SCRIPTLET}.generateCodeline($P{printAmount}.split("\\s+")[1],"01",">","971786","+","0126535",">",$P{invoiceId})]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="353" y="132" width="181" height="14" />
            <textFieldExpression><![CDATA[$P{customerName}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="353" y="144" width="181" height="14" />
            <textFieldExpression><![CDATA[$P{customerAddress}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="353" y="158" width="294" height="14" />
            <textFieldExpression><![CDATA[$P{customerPostalCode}+ " " + $P{customerCity}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="8" y="193" width="181" height="14" />
            <textFieldExpression><![CDATA[$P{customerName}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="8" y="205" width="181" height="14" />
            <textFieldExpression><![CDATA[$P{customerAddress}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="8" y="218" width="251" height="14" />
            <textFieldExpression><![CDATA[$P{customerPostalCode}+ " " + $P{customerCity}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="353" y="172" width="211" height="14" />
            <textFieldExpression><![CDATA[$P{countryCode}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="8" y="230" width="194" height="14" />
            <textFieldExpression><![CDATA[$P{countryCode}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="353" y="92" width="424" height="19" />
            <textElement>
                <font fontName="SansSerif" size="11" isBold="true"/>
            </textElement>
            <textFieldExpression><![CDATA[$P{esrgenerator_SCRIPTLET}.getReferenceNumber("971786",$P{invoiceId})]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="8" y="172" width="186" height="16" />
            <textFieldExpression><![CDATA[$P{esrgenerator_SCRIPTLET}.getReferenceNumber("971786",$P{invoiceId})]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="132" y="142" width="47" height="15" />
            <textElement>
                <font fontName="SansSerif" size="11"/>
            </textElement>
            <textFieldExpression><![CDATA[$P{esrgenerator_SCRIPTLET}.splitAmount($P{printAmount}.split("\\s+")[1].split("\\.")[1])]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="301" y="142" width="40" height="15" />
            <textElement>
                <font fontName="SansSerif" size="11"/>
            </textElement>
            <textFieldExpression><![CDATA[$P{esrgenerator_SCRIPTLET}.splitAmount($P{printAmount}.split("\\s+")[1].split("\\.")[1])]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="2" y="142" width="105" height="15" />
            <textElement textAlignment="Right">
                <font fontName="SansSerif" size="11"/>
            </textElement>
            <textFieldExpression><![CDATA[$P{esrgenerator_SCRIPTLET}.splitAmount($P{printAmount}.split("\\s+")[1].split("\\.")[0]).trim()]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="173" y="142" width="105" height="15" />
            <textElement textAlignment="Right">
                <font fontName="SansSerif" size="11"/>
             </textElement>
            <textFieldExpression> <![CDATA[$P{esrgenerator_SCRIPTLET}.splitAmount($P{printAmount}.split("\\s+")[1].split("\\.")[0]).trim()]]></textFieldExpression>
        </textField>
    </band>
 </summary>
 </jasperReport>

文件<代码>子报告。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="ageing-esr-40-srpski-subreport" pageWidth="595" pageHeight="70" whenNoDataType="AllSectionsNoDetail" columnWidth="595" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" >
<property name="com.jasperassistant.designer.GridHeight" value="12"/>
<property name="com.jasperassistant.designer.GridWidth" value="12"/>
<property name="com.jasperassistant.designer.SnapToGrid" value="false"/>
<property name="com.jasperassistant.designer.Grid" value="false"/>
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<parameter name="customerId" class="java.lang.String"/>
<parameter name="invoiceDate" class="java.lang.String"/>
<parameter name="invoiceId" class="java.lang.Integer"/>
<parameter name="invoiceDueDate" class="java.lang.String"/>
<parameter name="newStatusId" class="java.lang.Integer"/>
<parameter name="printAmount" class="java.lang.String"/>
<parameter name="balance" class="java.lang.String"/>
<title>
    <band height="30">
        <staticText>
            <reportElement x="2" y="14" width="65" height="14" />
            <textElement>
                <font size="10" isBold="true"/>
            </textElement>
            <text><![CDATA[Racun od]]></text>
        </staticText>
        <staticText>
            <reportElement x="83" y="14" width="65" height="14" />
            <textElement>
                <font size="10" isBold="true"/>
            </textElement>
            <text><![CDATA[Nacin pl.]]></text>
        </staticText>
        <staticText>
            <reportElement x="164" y="14" width="85" height="14" />
            <textElement textAlignment="Left">
                <font size="10" isBold="true"/>
            </textElement>
            <text><![CDATA[Broj racuna]]></text>
        </staticText>
        <staticText>
            <reportElement x="262" y="14" width="85" height="14" />
            <textElement textAlignment="Left">
                <font size="10" isBold="true"/>
            </textElement>
            <text><![CDATA[Rok istekao]]></text>
        </staticText>
        <staticText>
            <reportElement x="375" y="14" width="48" height="14" />
            <textElement>
                <font size="10" isBold="true"/>
            </textElement>
            <text><![CDATA[Iznos]]></text>
        </staticText>
        <staticText>
            <reportElement x="437" y="14" width="58" height="14" />
            <textElement>
                <font size="10" isBold="true"/>
            </textElement>
            <text><![CDATA[Otvoreno]]></text>
        </staticText>
        <staticText>
            <reportElement x="504" y="14" width="52" height="14" />
            <textElement>
                <font size="10" isBold="true"/>
            </textElement>
            <text><![CDATA[Step.nap]]></text>
        </staticText>
    </band>
</title>
<pageHeader>
    <band height="19">
        <textField>
            <reportElement x="495" y="3" width="34" height="12" />
            <textElement textAlignment="Right">
                <font fontName="SansSerif" size="9"/>
            </textElement>
            <textFieldExpression class="java.lang.Integer"><![CDATA[$P{newStatusId}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="356" y="3" width="67" height="15" />
            <textElement textAlignment="Right">
                <font fontName="SansSerif" size="9"/>
            </textElement>
            <textFieldExpression><![CDATA[$P{printAmount}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="262" y="3" width="100" height="14" />
            <textFieldExpression><![CDATA[$P{invoiceDueDate}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="164" y="3" width="75" height="14" />
            <textFieldExpression class="java.lang.Integer"><![CDATA[$P{invoiceId}]]></textFieldExpression>
        </textField>
        <staticText>
            <reportElement x="83" y="3" width="77" height="14" />
            <textElement>
                <font size="10" isBold="false"/>
            </textElement>
            <text><![CDATA[Racun]]></text>
        </staticText>
        <textField>
            <reportElement x="2" y="3" width="75" height="14" />
            <textFieldExpression><![CDATA[$P{invoiceDate}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="423" y="2" width="67" height="15" />
            <textElement textAlignment="Right">
                <font fontName="SansSerif" size="9"/>
            </textElement>
            <textFieldExpression><![CDATA[$P{printAmount}]]></textFieldExpression>
        </textField>
    </band>
</pageHeader>
<summary>
    <band height="20">
        <staticText>
            <reportElement x="266" y="0" width="163" height="15" />
            <textElement>
                <font size="10" isBold="true"/>
            </textElement>
            <text><![CDATA[Ukupno CHF. . . . . . . . . . . . . . . .]]></text>
        </staticText>
        <textField>
            <reportElement x="423" y="0" width="67" height="15" />
            <textElement textAlignment="Right">
                <font fontName="SansSerif" size="9"/>
            </textElement>
            <textFieldExpression><![CDATA[$P{printAmount}]]></textFieldExpression>
        </textField>
    </band>
</summary>
</jasperReport>

JAVA代码:

public static JasperPrint generateAgeingESRFile(InvoiceDTO invoice, Integer userId, Integer entityId , Integer newStatusId) throws FileNotFoundException,
        SessionInternalError {

    try {

     ContactDTOEx to=null;
     ContactDTOEx from=null;

        // This is needed for JasperRerpots to work, for some twisted XWindows issue
        System.setProperty("java.awt.headless", "true");
    /*
        String designFile = com.sapienter.jbilling.common.Util.getSysProp("base_dir")
                            + "designs/" + "ageing-esr-" + entityId + ".jasper";
    */

        String design = "ageing-esr-" + entityId;

    String designFile = getAgeingESRDesignFile(design, invoice);

        File compiledDesign = new File(designFile);
        LOG.debug("Generating paper esr with design file : " + designFile +  "The Ageing Step is " + newStatusId);
        FileInputStream stream = new FileInputStream(compiledDesign);
        Locale locale = (new UserBL(userId).getLocale());

    ContactBL contact = new ContactBL();
        contact.setInvoice(invoice.getId());
        to = contact.getDTO();

        entityId = invoice.getBaseUser().getEntity().getId();
        Date lastStatusChangeDate = invoice.getBaseUser().getLastStatusChange();
        contact.setEntity(entityId);
        from = contact.getDTO();

    //LOG.debug("The ageing step is " + newStatusId);
        // add all the invoice data


    HashMap<String, Object> parameters = new HashMap<String, Object>();
        parameters.put("invoiceNumber", invoice.getPublicNumber());
        parameters.put("invoiceId", invoice.getId());
    parameters.put("newStatusId", newStatusId);
    parameters.put("totalWithTax", Util.formatMoney(invoice.getTotal(),
        invoice.getUserId(), invoice.getCurrency().getId(), false));
        parameters.put("customerId", invoice.getUserId().toString());
        parameters.put("invoiceDate", Util.formatDate(invoice.getCreateDatetime(), invoice.getUserId()));
        parameters.put("invoiceDueDate", Util.formatDate(invoice.getDueDate(), invoice.getUserId()));
        parameters.put("invoiceGeneratedDate", Util.formatDate(invoice.getCreateTimestamp(), invoice.getUserId()));
        parameters.put("statusChangeDate", Util.formatDate(lastStatusChangeDate, invoice.getUserId()));

    parameters.put("entityName", printable(from.getOrganizationName()));
        parameters.put("entityAddress", printable(from.getAddress1()));
        parameters.put("entityAddress2", printable(from.getAddress2()));
        parameters.put("entityPostalCode", printable(from.getPostalCode()));
        parameters.put("entityCity", printable(from.getCity()));
        parameters.put("entityProvince", printable(from.getStateProvince()));
        parameters.put("entityPhoneCountryCode", printable(from.getPhoneCountryCode().toString()));
    parameters.put("entityPhoneAreaCode", printable(from.getPhoneAreaCode().toString()));
    parameters.put("entityPhoneContry", printable(from.getPhoneNumber().toString()));

        parameters.put("customerOrganization", printable(to.getOrganizationName()));
        parameters.put("customerName", printable(to.getFirstName(), to.getLastName()));
        parameters.put("customerAddress", printable(to.getAddress1()));
        parameters.put("customerAddress2", printable(to.getAddress2()));
        parameters.put("customerPostalCode", printable(to.getPostalCode()));
        parameters.put("customerCity", printable(to.getCity()));
        parameters.put("customerProvince", printable(to.getStateProvince()));
        parameters.put("countryCode", printable(to.getCountryCode()));            
        parameters.put("carriedBalance", Util.formatMoney(invoice.getCarriedBalance(),
        invoice.getUserId(), invoice.getCurrency().getId(), false));

    Collection invoicePaymentMaps = invoice.getPaymentMap();
    List list = new ArrayList(invoicePaymentMaps);
    if(list==null || list.isEmpty()){
    LOG.debug("invoicePaymentMaps is null, so pass totalWithTax as param ");
    parameters.put("printAmount", Util.formatMoney(invoice.getTotal(),
            invoice.getUserId(), invoice.getCurrency().getId(), false));
    }else{
    LOG.debug("invoicePaymentMaps is not null, so pass balance as param ");
    parameters.put("printAmount", Util.formatMoney(invoice.getBalance(),
            invoice.getUserId(), invoice.getCurrency().getId(), false));
   }

        // the logo is a file
        File logo = new File(com.sapienter.jbilling.common.Util
                .getSysProp("base_dir")
                + "logos/entity-" + entityId + ".jpg");
        parameters.put("entityLogo", logo);

        BigDecimal taxTotal = new BigDecimal(0);
        int taxItemIndex = 0;
        // set report locale
        parameters.put(JRParameter.REPORT_LOCALE, locale);

        // at last, generate the report
        JasperPrint report = null;
        report = JasperFillManager.fillReport(stream, parameters, new JREmptyDataSource());

        stream.close();

        return report;
} catch (Exception e) {
        LOG.error("Exception generating ESR receipt", e);
        return null;
    }
}  
    public JasperPrint getMultipleIdReport(List<Integer> idInvoiceList, JasperReport report) throws JRException { 
 List<JasperPrint> printList = new ArrayList<JasperPrint>();
  for (Integer id : idInvoiceList) {
   printList.add(generateAgeingESRFile(InvoiceDTO invoice, Integer userId, Integer entityId , Integer newStatusId));
   }

  JasperPrint printFinal = null;
   for (JasperPrint jp : printList) {
  if (printFinal == null) {
    printFinal = jp;
   } else {
    List<JRPrintPage> pages = jp.getPages();
    for (JRPrintPage page : pages) {
        printFinal.addPage(page);
    }
  }
  }
 return printFinal;
  }

共有1个答案

咸星波
2023-03-14

您可以更改报告(查询和结构),以获取列表

然而,避免修改报告的纯java方法是将多个单个id报告的所有页面添加到单个JasperPrint对象

示例

//Method to add multiple single id report to single JasperPrint
public JasperPrint getMultipleIdReport(List<Integer> idInvoiceList, JasperReport report) throws JRException { 
  List<JasperPrint> printList = new ArrayList<JasperPrint>();
  for (Integer id : idInvoiceList) {
    printList.add(getSingleIdReport(id, report));
  }

  JasperPrint printFinal = null;
  for (JasperPrint jp : printList) {
    if (printFinal == null) {
        printFinal = jp;
    } else {
        List<JRPrintPage> pages = jp.getPages();
        for (JRPrintPage page : pages) {
            printFinal.addPage(page);
        }
    }
  }
  return printFinal;
}

//Method to get a single id report, similar to your current code
public JasperPrint getSingleIdReport(int idInvoice, JasperReport report) throws JRException {
   //fill the parameter and the return the the JasperPrint for single id
   return JasperFillManager.fillReport(report, parameters, connection);
}

 类似资料:
  • 我们可以用这里所述的算法求有向图中的圈数。我需要理解算法。 (1)最后那句话到底有什么用处?对algo的工作原理进行简短的描述会很有帮助。由于算法基本上是统计从一个节点返回到同一节点的周期数,所以我们可以使用另一个数组,称之为v,并做以下技巧: (2)我不能实现我刚才写的算法。这是主要的问题,但我认为我需要理解上面的(1)来理解打印所有循环的代码。 我了解到互联网上有算法,我正在尝试使用这个算法。

  • 我必须用热敏打印机打印发票收据。我用Zjiang热敏打印机打印收据。他们还提供了手册和演示项目。在演示项目中,他们使用一个库“btsdk.jar”来实现连接和打印。 我已经成功地建立了打印机和android设备之间的连接。但是没有关于文本对齐(中心、左、右)&单元格宽度、高度的指导原则。 我试过了。它只通过改变format2变量来改变文本高度。 打印信息- 发票收据

  • 当我运行下面的程序时,没有输出,程序也不会退出。它应该打印素数。程序需要使用while循环运行。哪里出了问题?

  • 问题内容: 考虑这个二维数组 使用经典方式,如果我们要访问二维数组的每个元素,则需要使用两个for循环遍历二维数组。 是否有使用Java 8功能(Lambda,方法参考,Streams等)循环和打印2D数组的新方法? 到目前为止,我尝试过的是: 输出: 问题答案: 保持与循环相同的输出: (请参阅。) 也类似: 产生如下输出: (请参阅。) 也: 产生如下输出: (请参阅。) 联接是Java 8讨

  • 我试图使用条件打印表中的值 我有三列A、B、C 我的条件是如果列A=="user" 然后在列B中打印值或使其为空 这会导致类型转换错误

  • 我有一个超文本标记语言表: 现在我想打印每行的所有td[1]值,因此我的输出应该是: 净利润 净利润 因此,我执行了以下代码: 但这会带来错误: 硒。常见的例外情况。NoSuchElementException:消息:没有这样的元素:无法定位元素:{“方法”:“xpath”,“选择器”:”//div[@class='report-data']/以下同级::table/tbody/tr“}