拼接sql

//        var from="""
//                    FROM
//                        biz_value_added_tax_info a
//                    WHERE
//                        sys_status = 1
//                  """
//        var paras = mutableListOf<Any>()
//
//        //核心企业
//        if(StringUtils.notBlank(coreEnterpriseId)  ){
//            from += " AND a.core_enterprise_id = ? "
//            var  coreEnterpriseId="${coreEnterpriseId?.trim()}"
//            paras.add(coreEnterpriseId)
//        }
//        //年份
//        if(StringUtils.notBlank(billingYear) ){
//            from += " AND a.billing_year = ? "
//            var years="${billingYear?.trim()}"
//            paras.add(years)
//        }
//        //月份
//        if(StringUtils.notBlank(billingMonth) ){
//            from += " AND a.billing_month = ? "
//            var mouths = "${billingMonth?.trim()}"
//            paras.add(mouths.trim())
//        }
        //获取付款单信息列表
//        var IncomeInfoList  = dbp.find(select+from,*paras.toTypedArray<Any>())
 // 主画面的 select 语句
    var select= """
                    SELECT
                        id,
                        CONVERT(billing_year, char) AS billing_year,
                        billing_month,
                        core_enterprise_id,
                        assets_trusteeship_income,
                        account_receivable,
                        billing_amount,
                        tax_amount,
                        total_amount,
                        service_fee_income,
                        asset_custody_income,
                        service_charge_income,
                        input_tax,
                        transfer_input_tax,
                        real_payment
                    """
    /**
     * 主画面查询from SQL构造
     * @param ctl
     * @throws ActiveRecordException
     */
    fun fromSql( coreEnterpriseId:String ?, billingYear:String?, billingMonth:String? ): String? {
        var from="""
                    FROM
                        biz_value_added_tax_info a
                    WHERE
                        sys_status = 1
                  """
        var where = ""
        //核心企业
        if(StringUtils.notBlank(coreEnterpriseId)  ){
            where += " AND a.core_enterprise_id = '" + coreEnterpriseId?.trim() + "' "
        }
        //年份
        if(StringUtils.notBlank(billingYear) ){
            from += " AND a.billing_year = ' "+billingYear?.trim()+"' "
        }
        //月份
        if(StringUtils.notBlank(billingMonth) ){
            from += " AND a.billing_month = ' "+billingMonth?.trim()+"' "
        }
        return  from+where
    }
   /**
     * 财务部ABS费用表:管理一览画面
     * @param  billingYear
     *               年份
     * @param billingMonth
     *               月份
     * @param  coreEnterpriseId
     *               核心企业
     */
    fun pages(iwebReq: IwebReq, pageInfo: PageInfo, coreEnterpriseId:String ?, billingYear:String?, billingMonth:String? ): Page<Record>? {
        var dbp = DbPro.use(iwebReq.dsName)
        var pageIndex = pageInfo?.pageIndex ?: 1
        var pageSize = pageInfo?.pageSize ?: IwebConstant.DEFAULT_PAGE_SIZE

//        var from="""
//                    FROM
//                        biz_value_added_tax_info a
//                    WHERE
//                        sys_status = 1
//                  """
//        var paras = mutableListOf<Any>()
//
//        //核心企业
//        if(StringUtils.notBlank(coreEnterpriseId)  ){
//            from += " AND a.core_enterprise_id = ? "
//            var  coreEnterpriseId="${coreEnterpriseId?.trim()}"
//            paras.add(coreEnterpriseId)
//        }
//        //年份
//        if(StringUtils.notBlank(billingYear) ){
//            from += " AND a.billing_year = ? "
//            var years="${billingYear?.trim()}"
//            paras.add(years)
//        }
//        //月份
//        if(StringUtils.notBlank(billingMonth) ){
//            from += " AND a.billing_month = ? "
//            var mouths = "${billingMonth?.trim()}"
//            paras.add(mouths.trim())
//        }
//        return dbp.paginate(pageIndex,pageSize,select,from,*paras.toTypedArray<Any>())
        var fromql=fromSql( coreEnterpriseId, billingYear, billingMonth)
        return dbp.paginate(pageIndex,pageSize,select,fromql)
    }

 

posted on 2019-01-09 14:48  小白菜好吃  阅读(369)  评论(0编辑  收藏  举报

导航