ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

写法

2019-06-05 14:45:06  阅读:260  来源: 互联网

标签:BigDecimal invoiceNo get records toString new 写法


    /**
     * 如果号码相邻的发票号码没有用“-”连接,就修改为“-”连接
     * @param controller
     * @return 发票说明
     * @throws ActiveRecordException
     */
    private static String createInvoiceDescription(String payUuid) throws ActiveRecordException {
        // 查询发票号码
        String selSql = String.format(
                "select invoice_no from %s where draft_id=? and sys_status=%s order by invoice_no asc",
                BizInvoiceDraft.dao.getTable().getName(), BlConstant.SYS_STATUS_VALUE);
        // db查询
        List<Record> records = Db.find(selSql, payUuid);
        BigDecimal b1 = null;
        BigDecimal b2 = null;
        if (records.size() == 0) {
            // 没有发票信息,发票说明为空
            return "";
        } else if (records.size() == 1) {
            // 只有一条发票信息
            return records.get(0).get("invoiceNo");
        } else if (records.size() == 2) {
            // 只有两条发票信息
            b1 = new BigDecimal(records.get(0).get("invoiceNo").toString());
            b2 = new BigDecimal(records.get(1).get("invoiceNo").toString());
            // 判断发票号码是否相邻
            if (b2.compareTo(b1.add(new BigDecimal(1))) == 0) {
                // 相邻
                return records.get(0).get("invoiceNo").toString() + "-" + records.get(1).get("invoiceNo").toString();
            } else {
                // 不相邻
                return records.get(0).get("invoiceNo").toString() + "," + records.get(1).get("invoiceNo").toString();
            }
        } else {
            // 发票信息记录数大于2
            String tmpRtnStr = records.get(0).get("invoiceNo");
            String rtnStr = "";
            for (int i = 1; i < records.size(); i++) {
                b1 = new BigDecimal(records.get(i - 1).get("invoiceNo").toString());
                b2 = new BigDecimal(records.get(i).get("invoiceNo").toString());
                if (b2.compareTo(b1.add(new BigDecimal("1"))) == 0) {
                    // 当前两个发票号码相邻
                } else {
                    // 当前两个发票号码不相邻
                    if (new BigDecimal(tmpRtnStr)
                            .compareTo(new BigDecimal(records.get(i - 1).get("invoiceNo").toString())) == 0) {
                        rtnStr = rtnStr + records.get(i - 1).get("invoiceNo").toString() + ",";
                    } else {
                        tmpRtnStr = tmpRtnStr + "-" + records.get(i - 1).get("invoiceNo").toString();
                        rtnStr = rtnStr + tmpRtnStr + ",";
                    }

                    tmpRtnStr = records.get(i).get("invoiceNo").toString();
                }
                if (i == records.size() - 1) {
                    if ((new BigDecimal(tmpRtnStr))
                            .compareTo(new BigDecimal(records.get(i).get("invoiceNo").toString())) == 0) {

                    } else {
                        tmpRtnStr += "-" + records.get(i).get("invoiceNo").toString();
                    }
                    rtnStr = rtnStr + tmpRtnStr + ",";
                }
            }
            return rtnStr.substring(0, rtnStr.length() - 1);
        }

    }
if (!duplicatedPayIds.isEmpty()) {
                    // 记录校验不通过
                    isCheckPass = false;
                    // comment
                    String comment = "该付款确认书的BIP编码与";
                    int countNum = 0;
                    for (Record r : duplicatedPayIds) {
                        if (0 < countNum) {
                            comment += "、";
                        }
                        comment += r.getStr("payId");
                        countNum ++;
                    }
                    comment += "的BIP编码重复;";
                    // 数据校验不通过
                    bizPayComfirmDraftErrorStr.append(comment);
                }

 

标签:BigDecimal,invoiceNo,get,records,toString,new,写法
来源: https://www.cnblogs.com/xiaowoniulx/p/10979432.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有