From 8e95710c66a4b0c0df1b5ec59cf812422efaeb91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E8=B4=B5=E5=BC=BA?= Date: Tue, 15 Apr 2025 15:35:21 +0800 Subject: [PATCH] =?UTF-8?q?=E9=93=B6=E8=A1=8C=E5=A4=B4=E5=AF=B8=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fi/plugin/report/BankInfoFormReport.java | 68 ++++++ .../fi/plugin/report/BankInfoListReport.java | 220 ++++++++++++++++++ .../fi/plugin/report/FinancialFormReport.java | 2 +- .../fi/fi/plugin/report/util/ReportUtils.java | 2 + 4 files changed, 291 insertions(+), 1 deletion(-) create mode 100644 main/java/shjh/jhzj7/fi/fi/plugin/report/BankInfoFormReport.java create mode 100644 main/java/shjh/jhzj7/fi/fi/plugin/report/BankInfoListReport.java diff --git a/main/java/shjh/jhzj7/fi/fi/plugin/report/BankInfoFormReport.java b/main/java/shjh/jhzj7/fi/fi/plugin/report/BankInfoFormReport.java new file mode 100644 index 0000000..9cc5c45 --- /dev/null +++ b/main/java/shjh/jhzj7/fi/fi/plugin/report/BankInfoFormReport.java @@ -0,0 +1,68 @@ +package shjh.jhzj7.fi.fi.plugin.report; + +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.entity.report.ReportQueryParam; +import kd.bos.report.plugin.AbstractReportFormPlugin; +import kd.sdk.plugin.Plugin; + +import java.math.BigDecimal; +import java.util.Iterator; + +/** + * 报表界面插件 + * 银行头寸表 + */ +public class BankInfoFormReport extends AbstractReportFormPlugin implements Plugin { + + private static final String[] NEED_FIELDS = { + "shjh_accountname", "shjh_accountnumber", "shjh_currencynumber", "shjh_bankname", + "shjh_openbankname", "shjh_hostbankname", "shjh_hostbankbra", "shjh_accttype", + "shjh_acctstatus", "shjh_orgname", "shjh_acctstyle", "shjh_fixedfield1", + "shjh_fixedfield2", "shjh_fixedfield3", "shjh_monthamt", "shjh_yearamt", + "shjh_daymat", "shjh_availablebalance", "shjh_accountblance", "shjh_finalposition", + "shjh_exchangerate", "shjh_monthamt1", "shjh_yearamt1", "shjh_daymat1", + "shjh_availablebalance1", "shjh_accountblance1", "shjh_finalposition1", "shjh_textfield", + "shjh_fixedfield4", "shjh_sfzl", "shjh_province", "shjh_city", "shjh_fixedfield5", + "shjh_acctoutin", "shjh_fixedfield6", "shjh_fixedfield7", "shjh_fixedfield8", + "shjh_fixedfield9", "shjh_fixedfield10", "shjh_datetimefield", "shjh_datetimefield1"}; + + @Override + public void processRowData(String gridPK, DynamicObjectCollection rowData, ReportQueryParam queryParam) { + super.processRowData(gridPK, rowData, queryParam); + Iterator iterator = rowData.iterator(); + while (iterator.hasNext()) { + DynamicObject row = iterator.next(); + BigDecimal amount = row.getBigDecimal(NEED_FIELDS[14]); + if (amount != null && amount.compareTo(BigDecimal.ZERO) != 0) { + row.set(NEED_FIELDS[15], amount); + row.set(NEED_FIELDS[16], amount); + row.set(NEED_FIELDS[17], amount); + row.set(NEED_FIELDS[18], amount); + row.set(NEED_FIELDS[19], amount); + BigDecimal rate = row.getBigDecimal(NEED_FIELDS[20]); + if (rate != null && rate.compareTo(BigDecimal.ZERO) != 0) { + //按照最新头寸取值时间获取银行账户最后一笔交易明细中的余额*汇率 + BigDecimal multiply = rate.multiply(amount); + row.set(NEED_FIELDS[21], multiply); + row.set(NEED_FIELDS[22], multiply); + row.set(NEED_FIELDS[23], multiply); + row.set(NEED_FIELDS[24], multiply); + row.set(NEED_FIELDS[25], multiply); + row.set(NEED_FIELDS[26], multiply); + } + } + //【城市】:银行账户的开户行中城市名称,需要去掉“市”字 + String cityName = row.getString(NEED_FIELDS[32]); + if (cityName != null && cityName.endsWith("市")) { + cityName = cityName.substring(0, cityName.length() - 1); + row.set(NEED_FIELDS[32],cityName); + } + //【币种】:CNY需要转换为RMB + String currencyNumber= row.getString(NEED_FIELDS[2]); + if (currencyNumber!=null && currencyNumber.contains("CNY")){ + row.set(NEED_FIELDS[2], currencyNumber.replace("CNY", "RMB")); + } + } + } +} \ No newline at end of file diff --git a/main/java/shjh/jhzj7/fi/fi/plugin/report/BankInfoListReport.java b/main/java/shjh/jhzj7/fi/fi/plugin/report/BankInfoListReport.java new file mode 100644 index 0000000..a444e23 --- /dev/null +++ b/main/java/shjh/jhzj7/fi/fi/plugin/report/BankInfoListReport.java @@ -0,0 +1,220 @@ +package shjh.jhzj7.fi.fi.plugin.report; + +import kd.bos.algo.DataSet; +import kd.bos.algo.GroupbyDataSet; +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.entity.report.AbstractReportListDataPlugin; +import kd.bos.entity.report.FilterItemInfo; +import kd.bos.entity.report.ReportQueryParam; +import kd.bos.orm.query.QCP; +import kd.bos.orm.query.QFilter; +import kd.bos.servicehelper.QueryServiceHelper; +import kd.sdk.plugin.Plugin; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.concurrent.TimeUnit; + +/** + * 报表取数插件 + * 银行头寸表 + */ +public class BankInfoListReport extends AbstractReportListDataPlugin implements Plugin { + + private static final String[] BANK_FIELDS = { + "company.name","bankaccountnumber","currency.fbasedataid","bank.shjh_extname","name","bank.shjh_hostname", + "accttype","acctstatus","openorg.name","acctstyle","issetbankinterface","bank.province.name","bank.city.name", + "shjh_acctoutin","id" + }; + + private static final String[] DETAIL_FIELDS = { + "accountbank","transbalance","bizdate" + }; + + private static final String[] CURRENCY_FIELDS = { + "id","number" + }; + + private static final String[] NEED_FIELDS = { + "shjh_accountname","shjh_accountnumber","shjh_currencynumber","shjh_bankname", + "shjh_openbankname","shjh_hostbankname","shjh_hostbankbra","shjh_accttype", + "shjh_acctstatus","shjh_orgname","shjh_acctstyle","shjh_fixedfield1", + "shjh_fixedfield2","shjh_fixedfield3","shjh_monthamt","shjh_yearamt", + "shjh_daymat","shjh_availablebalance","shjh_accountblance","shjh_finalposition", + "shjh_exchangerate","shjh_monthamt1","shjh_yearamt1","shjh_daymat1", + "shjh_availablebalance1","shjh_accountblance1","shjh_finalposition1","shjh_textfield", + "shjh_fixedfield4","shjh_sfzl","shjh_province","shjh_city","shjh_fixedfield5", + "shjh_acctoutin","shjh_fixedfield6","shjh_fixedfield7","shjh_fixedfield8", + "shjh_fixedfield9","shjh_fixedfield10","shjh_datetimefield","shjh_datetimefield1"}; + + @Override + public DataSet query(ReportQueryParam reportQueryParam, Object o) throws Throwable { + + StringBuilder selectFields = new StringBuilder(); + selectFields.append(BANK_FIELDS[0]).append(" AS ").append(NEED_FIELDS[0]).append(",") + .append(BANK_FIELDS[1]).append(" AS ").append(NEED_FIELDS[1]).append(",") + .append(BANK_FIELDS[3]).append(" AS ").append(NEED_FIELDS[3]).append(",") + .append(BANK_FIELDS[4]).append(" AS ").append(NEED_FIELDS[4]).append(",") + .append(BANK_FIELDS[5]).append(" AS ").append(NEED_FIELDS[5]).append(",") + .append("'其他'").append(" ").append(NEED_FIELDS[6]).append(",") + .append(BANK_FIELDS[6]).append(" AS ").append(NEED_FIELDS[7]).append(",") + .append(BANK_FIELDS[7]).append(" AS ").append(NEED_FIELDS[8]).append(",") + .append(BANK_FIELDS[8]).append(" AS ").append(NEED_FIELDS[9]).append(",") + .append(BANK_FIELDS[9]).append(" AS ").append(NEED_FIELDS[10]).append(",") + .append("'上海家化'").append(" ").append(NEED_FIELDS[11]).append(",") + .append("'上海家化'").append(" ").append(NEED_FIELDS[12]).append(",") + .append("'上海家化'").append(" ").append(NEED_FIELDS[13]).append(",") + .append("1").append(" ").append(NEED_FIELDS[20]).append(",") + .append("'是'").append(" ").append(NEED_FIELDS[28]).append(",") + .append(BANK_FIELDS[10]).append(" AS ").append(NEED_FIELDS[29]).append(",") + .append(BANK_FIELDS[11]).append(" AS ").append(NEED_FIELDS[30]).append(",") + .append(BANK_FIELDS[12]).append(" AS ").append(NEED_FIELDS[31]).append(",") + .append("'否'").append(" ").append(NEED_FIELDS[32]).append(",") + .append(BANK_FIELDS[13]).append(" AS ").append(NEED_FIELDS[33]).append(",") + .append("'上海家化'").append(" ").append(NEED_FIELDS[34]).append(",") + .append("'上海家化'").append(" ").append(NEED_FIELDS[35]).append(",") + .append("'非金板块'").append(" ").append(NEED_FIELDS[36]).append(",") + .append("'是'").append(" ").append(NEED_FIELDS[37]).append(",") + .append("'EX-ZENGWEI257'").append(" ").append(NEED_FIELDS[38]).append(","); + + + List filterItems = reportQueryParam.getFilter().getFilterItems(); + List qFilters1=new ArrayList<>(); + List qFilters2=new ArrayList<>(); + List typeList =new ArrayList<>(); + List statusList =new ArrayList<>(); + List styleList =new ArrayList<>(); + String accrualDate=null; + Long bankId=null; + for (FilterItemInfo filterItem : filterItems) { + switch (filterItem.getPropName()){ + case "shjh_date": + accrualDate=(filterItem.getDate()==null) ? null:new SimpleDateFormat("yyyy-MM-dd").format(filterItem.getDate()); + selectFields.append("'").append(accrualDate).append("'").append(" ").append(NEED_FIELDS[27]); + // 计算当前日期的下一天(用于 less_than 条件) + Date nextDay = new Date(filterItem.getDate().getTime() + TimeUnit.DAYS.toMillis(1)); + qFilters2.add(new QFilter("bizdate", QCP.large_equals,filterItem.getDate())); + qFilters2.add(new QFilter("bizdate",QCP.less_than,nextDay)); + break; + case "shjh_filteraccttype": + String type = (String) filterItem.getValue(); + if (type!=null){ + // 1. 按逗号拆分 + String[] parts = type.split(","); + // 2. 遍历数组,跳过空字符串 + for (String part : parts) { + if (!part.isEmpty()) { // 过滤掉空字符串(如开头和结尾的逗号) + typeList.add(part); + } + } + qFilters1.add(new QFilter("accttype", QCP.in,typeList)); + } + break; + case "shjh_filteracctstatus": + String status = (String) filterItem.getValue(); + if (status!=null){ + String[] parts = status.split(","); + for (String part : parts) { + if (!part.isEmpty()) { + statusList.add(part); + } + } + qFilters1.add(new QFilter("acctstatus", QCP.in,statusList)); + } + break; + case "shjh_filteracctstyle": + String style = (String) filterItem.getValue(); + if (style!=null){ + String[] parts = style.split(","); + for (String part : parts) { + if (!part.isEmpty()) { + styleList.add(part); + } + } + qFilters1.add(new QFilter("acctstyle", QCP.in,styleList)); + } + break; + case "shjh_bank": + bankId=(filterItem.getValue()==null) ? null: (Long) ((DynamicObject)filterItem.getValue()).getPkValue(); + break; + default: + break; + } + } + if (bankId!=null){ + qFilters1.add(new QFilter("id",QCP.equals,bankId)); + } + selectFields.append(",").append(BANK_FIELDS[14]) + .append(",").append(BANK_FIELDS[2]).append(" AS currid"); + //银行账户 + DataSet mainDataSet = QueryServiceHelper.queryDataSet( + this.getClass().getName(), + "am_accountbank", + String.valueOf(selectFields), + qFilters1.toArray(new QFilter[]{}), + null + ); + + //查询币别 + DataSet regionDataSet = QueryServiceHelper.queryDataSet(this.getClass().getName()+"currency", "bd_currency", + "id, number as shjh_currencynumber", null, null); + // join连接2个数据 + DataSet resultDataSet = mainDataSet.copy().leftJoin(regionDataSet).on("currid", "id") + .select(new String[]{ + "shjh_accountname","shjh_accountnumber", + "shjh_bankname", "shjh_openbankname","shjh_hostbankname","shjh_hostbankbra", + "shjh_accttype", "shjh_acctstatus","shjh_orgname","shjh_acctstyle","shjh_fixedfield1", + "shjh_fixedfield2","shjh_fixedfield3", "shjh_exchangerate", + "shjh_textfield", "shjh_fixedfield4","shjh_sfzl","shjh_province","shjh_city", + "shjh_fixedfield5", "shjh_acctoutin","shjh_fixedfield6","shjh_fixedfield7", + "shjh_fixedfield8", "shjh_fixedfield9","shjh_fixedfield10","id"}, new String[]{"shjh_currencynumber"}).finish(); + + // 将币别名称做分组合并 + GroupbyDataSet groupbyDataSet = resultDataSet.groupBy(new String[]{ + "shjh_accountname","shjh_accountnumber", + "shjh_bankname", "shjh_openbankname","shjh_hostbankname","shjh_hostbankbra", + "shjh_accttype", "shjh_acctstatus","shjh_orgname","shjh_acctstyle","shjh_fixedfield1", + "shjh_fixedfield2","shjh_fixedfield3", "shjh_exchangerate", + "shjh_textfield", "shjh_fixedfield4","shjh_sfzl","shjh_province","shjh_city", + "shjh_fixedfield5", "shjh_acctoutin","shjh_fixedfield6","shjh_fixedfield7", + "shjh_fixedfield8", "shjh_fixedfield9","shjh_fixedfield10","id"}); + + //然后以;隔开 + resultDataSet = groupbyDataSet.groupConcat("shjh_currencynumber",null,";").finish(); + + //收款入账中心-流水 + DataSet detailsDataSet = QueryServiceHelper.queryDataSet( + this.getClass().getName() + "details", + "bei_intelrec","accountbank,biztime,transbalance AS shjh_monthamt", + qFilters2.toArray(new QFilter[]{}), + null); + + + //取最大日期 + DataSet maxDataSet=detailsDataSet.groupBy(new String[]{"accountbank"}).max("biztime").finish(); + //重新排序 + maxDataSet=maxDataSet.join(detailsDataSet) + .on("accountbank","accountbank") + .select(new String[]{"accountbank","shjh_monthamt","biztime"}) + .finish(); + //过滤金额=null的数据 + maxDataSet=maxDataSet.filter("shjh_monthamt <> null"); + + //合并 + DataSet dataSet = resultDataSet.join(maxDataSet) + .on("id", "accountbank") + .select(new String[]{ + "shjh_accountname","shjh_accountnumber","shjh_currencynumber", + "shjh_bankname", "shjh_openbankname","shjh_hostbankname","shjh_hostbankbra", + "shjh_accttype", "shjh_acctstatus","shjh_orgname","shjh_acctstyle","shjh_fixedfield1", + "shjh_fixedfield2","shjh_fixedfield3","shjh_monthamt", "shjh_exchangerate", + "shjh_textfield", "shjh_fixedfield4","shjh_sfzl","shjh_province","shjh_city", + "shjh_fixedfield5", "shjh_acctoutin","shjh_fixedfield6","shjh_fixedfield7", + "shjh_fixedfield8", "shjh_fixedfield9","shjh_fixedfield10"}) + .finish(); + + return dataSet; + } +} \ No newline at end of file diff --git a/main/java/shjh/jhzj7/fi/fi/plugin/report/FinancialFormReport.java b/main/java/shjh/jhzj7/fi/fi/plugin/report/FinancialFormReport.java index a498010..7c1e2dc 100644 --- a/main/java/shjh/jhzj7/fi/fi/plugin/report/FinancialFormReport.java +++ b/main/java/shjh/jhzj7/fi/fi/plugin/report/FinancialFormReport.java @@ -52,7 +52,7 @@ public class FinancialFormReport extends AbstractReportFormPlugin implements Plu @Override public void processRowData(String gridPK, DynamicObjectCollection rowData, ReportQueryParam queryParam) { super.processRowData(gridPK, rowData, queryParam); - + // 获取筛选条件中的计提日 Date accrualDate = queryParam.getFilter().getDate(FILTER_DATE); Calendar calendar = Calendar.getInstance(); diff --git a/main/java/shjh/jhzj7/fi/fi/plugin/report/util/ReportUtils.java b/main/java/shjh/jhzj7/fi/fi/plugin/report/util/ReportUtils.java index 6d76a1a..bb2b9c9 100644 --- a/main/java/shjh/jhzj7/fi/fi/plugin/report/util/ReportUtils.java +++ b/main/java/shjh/jhzj7/fi/fi/plugin/report/util/ReportUtils.java @@ -177,4 +177,6 @@ public class ReportUtils { return cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR); } + + }