diff --git a/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/report/AccountbankReportPlugin.java b/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/report/AccountbankReportPlugin.java index 2c9fa36..fe8cff8 100644 --- a/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/report/AccountbankReportPlugin.java +++ b/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/report/AccountbankReportPlugin.java @@ -3,6 +3,7 @@ package shkd.sys.sys.plugin.report; import kd.bos.algo.DataSet; import kd.bos.algo.JoinDataSet; import kd.bos.algo.JoinType; +import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObjectCollection; import kd.bos.db.DB; import kd.bos.db.DBRoute; @@ -20,6 +21,7 @@ import kd.bos.util.CollectionUtils; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; public class AccountbankReportPlugin extends AbstractReportListDataPlugin { @@ -75,15 +77,7 @@ public class AccountbankReportPlugin extends AbstractReportListDataPlugin { , null, null); String[] fieldNames = accountbankDataSet.getRowMeta().getFieldNames(); - // 创建一个新的数组,长度是原数组长度 + 2(因为要添加两个字段) - String[] newFieldNames = new String[fieldNames.length + 2]; - - // 将原来的字段名数组复制到新数组 - System.arraycopy(fieldNames, 0, newFieldNames, 0, fieldNames.length); - - // 添加两个新的字段到新数组的末尾 - newFieldNames[fieldNames.length] = "fid"; // 第一个新字段 - newFieldNames[fieldNames.length + 1] = "fbasedataid as shkd_bz"; // 第二个新字段 + String[] newFieldNames = ExpansionArray(fieldNames, Arrays.asList("fid", "fbasedataid as shkd_bz")); // 查询多选币别 DataSet currencydata = DB.queryDataSet(this.getClass().getSimpleName(), DBRoute.of("sys"), @@ -94,30 +88,35 @@ public class AccountbankReportPlugin extends AbstractReportListDataPlugin { DataSet finish = join.on("id", "fid").select(newFieldNames).finish(); String[] fieldNames1 = finish.getRowMeta().getFieldNames(); - // 创建一个新的数组,长度是原数组长度 + 2(因为要添加两个字段) - String[] newFieldNames1 = new String[fieldNames1.length + 3]; - // 将原来的字段名数组复制到新数组 - System.arraycopy(fieldNames1, 0, newFieldNames1, 0, fieldNames1.length); - - // 添加两个新的字段到新数组的末尾 - newFieldNames1[fieldNames1.length] = "shkd_zhyeyb"; // 第一个新字段 - newFieldNames1[fieldNames1.length + 1] = "shkd_zhyebb"; // 第二个新字段 - newFieldNames1[fieldNames1.length + 2] = "shkd_zhyesj"; // 第三个新字段 -// DynamicObjectCollection srcCollection = ORM.create().toPlainDynamicObjectCollection(finish.copy()); + String[] newFieldNames1 = ExpansionArray(fieldNames1, Arrays.asList("shkd_zhyeyb", "shkd_zhyebb", "shkd_zhyesj")); //查询余额 StringBuilder sqlBuilder = new StringBuilder("/*dialect*/ \n"); sqlBuilder.append("SELECT fbankacctid ,SUM(FDebitAmount-FCreditAmount) as shkd_zhyeyb,SUM(FDebitAmount*fexchangerate-FCreditAmount*fexchangerate) as shkd_zhyebb,fcurrencyid,MAX(FBizDate) as shkd_zhyesj\n" + - "FROM t_cas_bankjournal \n" + + "FROM t_cas_bankjournal WHERE FBizDate<'"+dateList.get(0)+"' \n" + "GROUP BY fbankacctid, fcurrencyid"); DataSet res = DB.queryDataSet(this.getClass().getSimpleName(), DBRoute.of("fi"), sqlBuilder.toString());//财务云 JoinDataSet join1 = finish.join(res, JoinType.LEFT);//左连接 DataSet finish1 = join1.on("id", "fbankacctid").on("shkd_bz", "fcurrencyid").select(newFieldNames1).finish(); - DynamicObjectCollection srcCollection = ORM.create().toPlainDynamicObjectCollection(finish1.copy()); return finish1; } + String[] ExpansionArray(String[] fieldNames,List list){ + + + // 创建一个新的数组,长度是原数组长度 + 3(因为要添加两个字段) + String[] newFieldNames = new String[fieldNames.length + list.size()]; + + // 将原来的字段名数组复制到新数组 + System.arraycopy(fieldNames, 0, newFieldNames, 0, fieldNames.length); + + for (int i = 0; i < list.size(); i++) { + // 添加两个新的字段到新数组的末尾 + newFieldNames[fieldNames.length+i] = list.get(i); // 第i个新字段 + } + return newFieldNames; + } }