1为数据库查询的数据中加一排序号,2判断为查询出来的字段赋值

 @Override
    public String getSqlByFileCodeForExport(String strTime, String strCompany) {
        StringBuffer strSb = new StringBuffer();
        //加序号代码
        strSb.append("select a.*,concat((@i :=@i + 1),'','') AS CON from ");
        strSb.append("((SELECT  results.ORDER_NO AS ORDERNO, ");
        strSb.append(" results.POLICY_NO AS POLICYNO,");
        strSb.append(" results.TRADE_AMT AS TRADEAMT, ");
        strSb.append(" results.CAEJ_ORDER_NO AS CAEJORDERNO, ");
        strSb.append(" results.CAEJ_POLICY_NO AS CAEJPOLICYNO, ");
        strSb.append(" results.TRADE_SN AS TRADESN, ");
        strSb.append(" results.ORDER_AMT AS ORDERAMT, ");
        strSb.append(" results.ORDER_BUY_NUM AS ORDERBUYNUM, ");
        strSb.append(" case when results.CHK_RESULT_TYPE  = '01' then '成功' ");
        strSb.append(" else '失败' end as CHKRESULTTYPE, ");
        strSb.append(" DATE_FORMAT(results.RECONCIL_TIME,'%Y-%m-%d %H:%i:%S') as RECONCILTIME ");
        strSb.append(" FROM R_DATA_RESULT results ");
        strSb.append(" where  1=1 AND results.BUSINESS_INTERFACE='01'   ");
        if (StringUtils.isNotEmpty(strTime)) {
            // strTime = strTime.substring(0, strTime.lastIndexOf(","));
            strSb.append(" and results.RECONCIL_TIME like '%" + strTime + "%' ");
        }
        if (StringUtils.isNotEmpty(strCompany)) {
            strSb.append(" and results.SETTLE_MODE in (" + strCompany + ")");
        }
        //加序号代码
        strSb.append(") a ,(select  @i:=0)   as   it) ");
        return strSb.toString();
    }

通过数据库查询的条件判断,直接给字段赋值

 // 导出数据所用sql rdatatotal
    @Override
    public String getSqlByExport(String ids) {
        StringBuffer strSb = new StringBuffer();
        if (StringUtil.isNotEmpty(ids)) {
            ids = ids.substring(0, ids.lastIndexOf(","));
            strSb.append(
                " select a.RFILERECORDID,a.SETTLEMODE,a.TYPECODE,a.TOTALCOUNT,a.TOTALAMT,a.TOTALTYPE,"
                         + "a.BUSINESSINTERFACE,a.ACCOUNTDAY ,a.RECONCILTIME,a.SETTLE_MODE, concat((@i :=@i + 1),'','') AS CON from ");
            strSb.append(
                "( ( select recon.R_FILE_RECORDID as RFILERECORDID,recon.SETTLE_MODE as  SETTLE_MODE,");
            strSb.append(
                " case when recon.SETTLE_MODE  = 'HKBX' then '弘康' when recon.SETTLE_MODE  = 'YGBX' then '阳光' else ''  end as SETTLEMODE,");
            strSb.append(
                " case when recon.TYPE_CODE  = '1' then '追加' else '赎回' end as TYPECODE, ");
            strSb.append(" recon.TOTAL_COUNT as TOTALCOUNT, recon.TOTAL_AMT as TOTALAMT, ");
            strSb.append(
                " case when recon.TOTAL_TYPE  = '01' then '成功' else '失败' end as TOTALTYPE ,");
            strSb.append(
                " case when recon.BUSINESS_INTERFACE  = '01' then '新契约对账接口' else '保全对账接口' end  as BUSINESSINTERFACE, ");
            strSb.append(" recon.ACCOUNT_DAY as ACCOUNTDAY, ");
            strSb.append(" DATE_FORMAT(recon.RECONCIL_TIME,'%Y-%m-%d %H:%i:%S') as RECONCILTIME ");
            strSb.append(" from R_DATA_TOTAL recon");
            strSb.append(" where 1=1 AND recon.BUSINESS_INTERFACE='01' AND recon.R_TOTAL_ID in ("
                         + ids + ") ");
            strSb.append(" order by recon.R_FILE_RECORDID desc ) a ,(select  @i:=0)   as   it) ");
            return strSb.toString();
        } else {
            return "";
        }
    }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值