From 1981f693b6164174f1a67667dcc5d043bc5392b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cwyx12345678=E2=80=9D?= <2816059288@qq.com> Date: Wed, 7 Aug 2024 09:30:09 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=84=E9=87=91=E6=97=A5=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../report/data/CapitalDayListDataPlugin.java | 142 +++++++++++++++++- 1 file changed, 134 insertions(+), 8 deletions(-) diff --git a/shkd-cosmic-debug/src/main/java/shkd/fi/cas/report/data/CapitalDayListDataPlugin.java b/shkd-cosmic-debug/src/main/java/shkd/fi/cas/report/data/CapitalDayListDataPlugin.java index 2e6a254..ea64c2c 100644 --- a/shkd-cosmic-debug/src/main/java/shkd/fi/cas/report/data/CapitalDayListDataPlugin.java +++ b/shkd-cosmic-debug/src/main/java/shkd/fi/cas/report/data/CapitalDayListDataPlugin.java @@ -12,6 +12,7 @@ import kd.bos.logging.LogFactory; import kd.bos.orm.query.QCP; import kd.bos.orm.query.QFilter; import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.bos.servicehelper.org.OrgUnitServiceHelper; import kd.sdk.plugin.Plugin; import java.math.BigDecimal; @@ -27,7 +28,7 @@ import java.util.*; public class CapitalDayListDataPlugin extends AbstractReportListDataPlugin implements Plugin { - private static final Log logger = LogFactory.getLog(CapitalDayDataListShkdPlugin.class); + private static final Log logger = LogFactory.getLog(CapitalDayListDataPlugin.class); @Override public DataSet query(ReportQueryParam reportQueryParam, Object o) throws Throwable { @@ -35,10 +36,25 @@ public class CapitalDayListDataPlugin extends AbstractReportListDataPlugin imple //获取过滤条件集合 Map paramMap = this.transQueryParam(reportQueryParam); DynamicObjectCollection companys = (DynamicObjectCollection)paramMap.get("shkd_filter_company");//使用组织集合 + DynamicObjectCollection groups = (DynamicObjectCollection)paramMap.get("shkd_filter_group");//使用组织集合 + String shkd_queryorgtype = paramMap.get("shkd_queryorgtype").toString();//使用组织集合 ArrayList longs = new ArrayList<>(); - for (DynamicObject company : companys) { - longs.add(company.getLong("id")); + String groupName = null; + //如果查询是查的集团,然后想要查询需查询下级及下级所有公司的id + if("group".equals(shkd_queryorgtype)){ + ArrayList grouplongs = new ArrayList<>(); + for (DynamicObject group : groups) { + groupName = group.getString("name"); + grouplongs.add(group.getLong("id")); + } + List allSubordinateOrgs = OrgUnitServiceHelper.getAllSubordinateOrgs(8L, grouplongs, true); + longs.addAll(allSubordinateOrgs); + }else{ + for (DynamicObject company : companys) { + longs.add(company.getLong("id")); + } } + Date firstDate = (Date)paramMap.get("shkd_firstdate");//开始时间 Date endDate = (Date)paramMap.get("shkd_enddate");//结束时间 DynamicObject orgcurrency = (DynamicObject) paramMap.get("shkd_orgcurrency"); @@ -67,7 +83,18 @@ public class CapitalDayListDataPlugin extends AbstractReportListDataPlugin imple Collection firmParams = null; if (cas_cashmgtinits != null){ firmParams = new ArrayList(cas_cashmgtinits.length);//多公司数据集合 + BigDecimal payTotal = BigDecimal.ZERO; //总计 期间支出合计 + BigDecimal recTotal = BigDecimal.ZERO; //总计 期间收入合计 + BigDecimal payLB = BigDecimal.ZERO; //内部往来,支出合计 + BigDecimal recLB = BigDecimal.ZERO; //内部往来 期间收入合计 for (int i = 0; i < cas_cashmgtinits.length; i++) { + //若是集团,需要在第一行拼接第一行的数据 + if("group".equals(shkd_queryorgtype)&&i == 0){ + Object[] firmParam = new Object[7];//存放公司数据 + firmParam[0] = i;//存放序号 + firmParam[1] = groupName;//存放集团名称,先优先考虑单集团的凭借 + firmParams.add(firmParam); + } DynamicObject startperiod = cas_cashmgtinits[i].getDynamicObject("startperiod"); if (startperiod != null){ Object pkValue = startperiod.getPkValue(); @@ -151,9 +178,13 @@ public class CapitalDayListDataPlugin extends AbstractReportListDataPlugin imple if (orgcurrency != null){ per_recQF.and("currency.id",QCP.equals,orgcurrencyId); } - per_recQF.and("payeedate",QCP.large_equals,startDate); - per_recQF.and("payeedate",QCP.less_equals,overDate); - DynamicObject[] per_cas_recbills = BusinessDataServiceHelper.load("cas_recbill", "id,org,org.id,org.number,actrecamt,currency", per_recQF.toArray()); + per_recQF.and("bizdate",QCP.large_equals,startDate); + per_recQF.and("bizdate",QCP.less_equals,overDate); + DynamicObject[] per_cas_recbills = BusinessDataServiceHelper.load("cas_recbill", "id,org,org.id,org.number,actrecamt,currency,payertype,customerf7,customerf7", per_recQF.toArray()); + BigDecimal transactions = this.getTransactions(per_cas_recbills); + recLB =recLB.add(transactions); //内部往来收入合计 + + for (DynamicObject per_cas_recbill : per_cas_recbills) { BigDecimal actrecamt = per_cas_recbill.getBigDecimal("actrecamt"); perRecAmountTotal = perRecAmountTotal.add(actrecamt);//添加收入金额 @@ -170,7 +201,10 @@ public class CapitalDayListDataPlugin extends AbstractReportListDataPlugin imple per_payQF.and("org.id",QCP.equals,orgPkValue); per_payQF.and("paydate",QCP.large_equals,startDate); per_payQF.and("paydate",QCP.less_equals,overDate); - DynamicObject[] per_cas_paybills = BusinessDataServiceHelper.load("cas_paybill", "id,org,org.id,org.number,payeenumber,actpayamt,currency", per_payQF.toArray()); + DynamicObject[] per_cas_paybills = BusinessDataServiceHelper.load("cas_paybill", "id,org,org.id,org.number,payeenumber,actpayamt,currency,payeetype,payee", per_payQF.toArray()); + BigDecimal transactionsByfk = this.getTransactionsByfk(per_cas_paybills); + payLB =payLB.add(transactionsByfk); //内部往来收入合计 + for (DynamicObject per_cas_paybill : per_cas_paybills) { String payNumber = per_cas_paybill.getDynamicObject("org").getString("number"); String recNumber = per_cas_paybill.getString("payeenumber"); @@ -186,10 +220,27 @@ public class CapitalDayListDataPlugin extends AbstractReportListDataPlugin imple BigDecimal endAmount = startAmount.add(perRecAmountTotal).subtract(perPayAmountTotal); firmParam[5] = endAmount; firmParams.add(firmParam); + payTotal = payTotal.add(perPayAmountTotal); + recTotal = recTotal.add(perRecAmountTotal); } + } } + //总计行的组装 + Object[] firmParam = new Object[7];//存放公司数据 + firmParam[1] = "总计"; + firmParam[3] = recTotal; //今日收入合计 + firmParam[4] = payTotal; //今日收入合计 + firmParams.add(firmParam); + + Object[] firmParam2 = new Object[7];//存放公司数据 + firmParam2[1] = "内部往来"; + firmParam2[3] = recLB; //今日收入合计 + firmParam2[4] = payLB; //今日收入合计 + firmParams.add(firmParam2); + //内部收支净额的组装 + } @@ -276,4 +327,79 @@ public class CapitalDayListDataPlugin extends AbstractReportListDataPlugin imple Date endOfDay = Date.from(startOfDay.atZone(ZoneId.systemDefault()).toInstant()); return endOfDay; } -} \ No newline at end of file + //内部往来收款单组装 + public BigDecimal getTransactions(DynamicObject[] per_cas_recbills){ + BigDecimal recAmountTotal = BigDecimal.ZERO; + for (DynamicObject per_cas_recbill : per_cas_recbills) { + //查询收款单,为内部往来的公司 + String payertype = per_cas_recbill.getString("payertype");//付款人类型 + if("bd_customer".equals(payertype)||"bd_supplier".equals(payertype)||"bos_org".equals(payertype)){ + if("bd_supplier".equals(payertype)){ + DynamicObject f7_payer = per_cas_recbill.getDynamicObject("f7_payer");//供应商 + long id = f7_payer.getLong("id"); + QFilter per_recQF = new QFilter("billstatus", QCP.equals, "D"); + per_recQF.and("org.id",QCP.equals,id); + DynamicObject bd_supplier = BusinessDataServiceHelper.loadSingle("bd_supplier", "id,number,internal_company", per_recQF.toArray()); + DynamicObject internal_company = bd_supplier.getDynamicObject("internal_company"); + if(internal_company==null){ + continue; + } + + } else if ("bd_customer".equals(payertype)) { + DynamicObject customerf7 = per_cas_recbill.getDynamicObject("customerf7");//供应商 + long id = customerf7.getLong("id"); + QFilter per_recQF = new QFilter("billstatus", QCP.equals, "D"); + per_recQF.and("org.id",QCP.equals,id); + DynamicObject bd_supplier = BusinessDataServiceHelper.loadSingle("bd_supplier", "id,number,internal_company", per_recQF.toArray()); + DynamicObject internal_company = bd_supplier.getDynamicObject("internal_company"); + if(internal_company==null){ + continue; + } + } + BigDecimal actrecamt = per_cas_recbill.getBigDecimal("actrecamt"); + recAmountTotal = recAmountTotal.add(actrecamt);//添加收入金额 + + } + } + return recAmountTotal; + } + + //内部往来付款合计 + public BigDecimal getTransactionsByfk(DynamicObject[] per_cas_paybills){ + BigDecimal perPayAmountTotal = BigDecimal.ZERO; + for (DynamicObject per_cas_paybill : per_cas_paybills) { + //查询收款单,为内部往来的公司 + String payertype = per_cas_paybill.getString("payeetype");//收款人款人类型 + Long payerid = per_cas_paybill.getLong("payee");//供应商 + + if("bd_customer".equals(payertype)||"bd_supplier".equals(payertype)||"bos_org".equals(payertype)){ + if("bd_supplier".equals(payertype)){ + QFilter per_recQF = new QFilter("id",QCP.equals,payerid); + DynamicObject bd_supplier = BusinessDataServiceHelper.loadSingle("bd_supplier", "id,number,internal_company", per_recQF.toArray()); + DynamicObject internal_company = bd_supplier.getDynamicObject("internal_company"); + if(internal_company==null){ + continue; + } + + } else if ("bd_customer".equals(payertype)) { + QFilter per_recQF = new QFilter("org.id",QCP.equals,payerid); + DynamicObject bd_supplier = BusinessDataServiceHelper.loadSingle("bd_supplier", "id,number,internal_company", per_recQF.toArray()); + DynamicObject internal_company = bd_supplier.getDynamicObject("internal_company"); + if(internal_company==null){ + continue; + } + } + String payNumber = per_cas_paybill.getDynamicObject("org").getString("number"); + String recNumber = per_cas_paybill.getString("payeenumber"); + BigDecimal actpayamt = per_cas_paybill.getBigDecimal("actpayamt"); + perPayAmountTotal = perPayAmountTotal.add(actpayamt); + if (payNumber.equals(recNumber)){//当付款编码同收款编码时 + perPayAmountTotal = perPayAmountTotal.add(actpayamt);//补充收款数据 + } + + + } + } + return perPayAmountTotal; + } +}