zoukankan      html  css  js  c++  java
  • 写法

        /**
         * 如果号码相邻的发票号码没有用“-”连接,就修改为“-”连接
         * @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);
                    }
  • 相关阅读:
    Android 自定义View (一)
    Java enum的用法详解
    Android Application的使用及其生命周期
    android 支持的语言列表(汇总)
    android 使用String.format("%.2f",67.876)自已定义语言(俄语、西班牙语)会把小数点变为逗号
    TN2151:崩溃报告
    android 各国语言对应的缩写
    uva 1401 dp+Trie
    教你3网页特效免费下载栅极材料必不可少的一步,无需工具
    编译命令行终端 swift
  • 原文地址:https://www.cnblogs.com/xiaoniuniu886/p/10979432.html
Copyright © 2011-2022 走看看