//通过凭证日期排序 recordList.sortBy({it.loanDate}) var certificateNumber = 1 recordList.forEachIndexed{index,item -> (index > 0).y { (item.loanDate == recordList.get(index - 1).loanDate).y { item.certificateNumber = certificateNumber } other { certificateNumber++ item.certificateNumber = certificateNumber } } other { item.certificateNumber = certificateNumber } }
/** * 凭证模板管理一览画面 * @param startPaymentTime * 开始支付时间 * @param endPaymentTime * 结束支付时间 * @param periods * 期数 * @param coreEnterpriseId * 核心企业 * @param financialInstitutionId * 金融机构 pageInfo: PageInfo */ fun pages(iwebReq: IwebReq,coreEnterpriseId:String ?, financialInstitutionsId:String?, periods:String?, startPaymentTime :String? , endPaymentTime:String?): List<Record> { var dbp = DbPro.use(iwebReq.dsName) // var pageIndex = pageInfo?.pageIndex ?: 1 // var pageSize = pageInfo?.pageSize ?: IwebConstant.DEFAULT_PAGE_SIZE // var pageSize = pageInfo?.pageSize ?: 0 var select= """ SELECT a.core_enterprise_id , a.financial_institutions_name, a.financial_type , a.pay_id, a.periods , a.loan_date , YEAR (a.loan_date) as year, MONTH (a.loan_date) as month, financial_institutions_id, account_receivable, accounting_item_number, item_company_name, suppliers_name """ var from=""" FROM biz_pay_comfirm_info a WHERE a.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(financialInstitutionsId) ){ from += " AND a.financial_institutions_id = ? " var financialInstitutionId="${financialInstitutionsId?.trim()}" paras.add(financialInstitutionId) } //期数 if(StringUtils.notBlank(periods) ){ from += " AND a.periods = ? " var periods = "${periods?.trim()}" paras.add(periods.trim()) } // 开始支付时间,结束支付时间 拼接在一起查 if(StringUtils.notBlank(startPaymentTime)){ from += "and loan_date >= ? " var spaymentTime = "${startPaymentTime?.trim()}" paras.add(spaymentTime) } if(StringUtils.notBlank(endPaymentTime)){ from += "and loan_date <= ? " var epaymentTime = "${endPaymentTime?.trim()}" paras.add(epaymentTime) } if (StringUtils.notBlank(from)){ from += "order by a.loan_date" } // var pageList= dbp.paginate(pageIndex,pageSize,select,from,*paras.toTypedArray<Any>()) var recordList= dbp.find(select+from,*paras.toTypedArray<Any>()) // 凭证号 var voucherNo = 0 // 分录序号 var entrySequenceNumber = 0 // 放款日期 var loanDate = recordList.get(0).getDate("loanDate") // 循环查询结果设置凭证摘要,凭证号、分录序号等信息 for (list in recordList){ // 凭证摘要 var abstract = "" // 金融机构类型 var financialType= list.getStr("financialType") //1:银行保理 2:ABS保理 if (financialType.equals("1")){ abstract = "确认${list.getStr("financialInstitutionsName")}保理款转让"+"(批次:"+ list.getDate("loanDate")+ list.getStr("payId") }else if(financialType.equals("2")){ abstract = "确认"+list.getStr("financialInstitutionsName")+ "ABS款转让"+"(批次:"+list.getDate("loanDate")+ list.getStr("payId") } // 设置凭证摘要 list.set("abstract",abstract) // 核算项目 var accountingProgram = "" // 核算项目编号不为空时 if(StringUtils.notBlank(list.getStr("accountingItemNumber"))){ // 核算项目: 客户/供应商+ --- +编号+ --- +公司名 accountingProgram = "供应商---" + list.getStr("accountingItemNumber") + "---" + list.getStr("suppliersName") } // 设置核算项目 list.set("accountingProgram",accountingProgram) // 若放款日与上一条数据的放款日不同时,凭证号加1,分录序号设置为0 if (loanDate != list.getDate("loanDate")){ // 设置上一条数据的放款日 loanDate = list.getDate("loanDate") // 设置凭证号 voucherNo ++ // 分录序号 entrySequenceNumber = 0 } // 设置凭证号 list.set("voucherNo",voucherNo) // 设置分录序号 list.set("entrySequenceNumber",entrySequenceNumber) entrySequenceNumber++ } return recordList }