Pārlūkot izejas kodu

feat(perf): 优化绩效报表批量查询和全选功能

- 在PerfBatchPrintListPlugin中添加beforeQuery方法实现报表列表全选
- 在PrintPerfDetailReportListDataPlugin中实现queryBatchBy方法支持分批查询
- 添加权限过滤和批次大小控制,提升大数据量查询性能
- 在AnnualPerfDetailFormPlugin中继承AbstractReportFormPlugin并实现全选功能
- 在AnnualPerfDetailReportListDataPlugin中实现分批查询和数据过滤机制
- 增加HashSet和Row等必要的导入包和数据结构支持
wyc 6 dienas atpakaļ
vecāks
revīzija
4f61c85d79

+ 7 - 0
code/opmc/nckd-jxccl-opmc/src/main/java/nckd/jxccl/opmc/pm/plugin/form/print/PerfBatchPrintListPlugin.java

@@ -7,6 +7,7 @@ import kd.bos.dataentity.entity.DynamicObjectCollection;
 import kd.bos.dataentity.utils.StringUtils;
 import kd.bos.entity.datamodel.events.PackageDataEvent;
 import kd.bos.entity.report.ReportColumn;
+import kd.bos.entity.report.ReportQueryParam;
 import kd.bos.form.CloseCallBack;
 import kd.bos.form.FormShowParameter;
 import kd.bos.form.ShowType;
@@ -48,6 +49,12 @@ public class PerfBatchPrintListPlugin extends AbstractReportFormPlugin implement
         toolbar.addItemClickListener(this);
     }
 
+    @Override
+    public void beforeQuery(ReportQueryParam queryParam) {
+        ReportList reportList = this.getControl("reportlistap");
+        reportList.setSelectedAll(true);
+    }
+
     @Override
     public void itemClick(ItemClickEvent evt) {
         String itemKey = evt.getItemKey();

+ 30 - 0
code/opmc/nckd-jxccl-opmc/src/main/java/nckd/jxccl/opmc/pm/plugin/form/print/PrintPerfDetailReportListDataPlugin.java

@@ -13,6 +13,7 @@ import kd.bos.entity.report.AbstractReportColumn;
 import kd.bos.entity.report.AbstractReportListDataPlugin;
 import kd.bos.entity.report.DynamicReportColumnEvent;
 import kd.bos.entity.report.FastFilter;
+import kd.bos.entity.report.IReportBatchQueryInfo;
 import kd.bos.entity.report.ReportColumn;
 import kd.bos.entity.report.ReportQueryParam;
 import kd.bos.orm.query.QCP;
@@ -52,6 +53,23 @@ public class PrintPerfDetailReportListDataPlugin extends AbstractReportListDataP
         super.getDynamicColumns(event);
     }
 
+    @Override
+    public DataSet queryBatchBy(ReportQueryParam queryParam){
+        QueryFieldBuilder queryFieldBuilder = QueryFieldBuilder.create()
+                .add(FormConstant.ID_KEY)
+                .orderDesc(FormConstant.NCKD_PERSON,PerfManagerFormConstant.NCKD_BEGINYEAR);
+        QFilter qFilter = QFilter.of("1=1");
+        //权限过滤
+        QFilter dataRule = HRPermissionServiceHelper.getDataRule(
+                RequestContext.get().getCurrUserId(), "nckd_pm", PerfManagerFormConstant.PERFMANAGER_ENTITYID,
+                PermissionStatus.View, new HashMap<>());
+        if(dataRule != null){
+            qFilter.and(dataRule);
+        }
+        IReportBatchQueryInfo byBatchInfo = queryParam.byBatchInfo();
+        byBatchInfo.setCountPerBatch(2000);
+        return QueryServiceHelper.queryDataSet(this.getClass().getName(),PerfManagerFormConstant.PERFMANAGER_ENTITYID, queryFieldBuilder.buildSelect(), new QFilter[]{qFilter}, queryFieldBuilder.buildOrder(),1000000);
+    }
 
     @Override
     public DataSet query(ReportQueryParam reportQueryParam, Object o) throws Throwable {
@@ -68,10 +86,22 @@ public class PrintPerfDetailReportListDataPlugin extends AbstractReportListDataP
         Date endDate = DateUtil.toDate(LocalDate.of(currentYear, 1, 1));
 
 
+        // 分批加载过滤
+        IReportBatchQueryInfo byBatchInfo = reportQueryParam.byBatchInfo();
+        // 获取当前批次的分批依据行
+        List<Row> currentBatchRows = byBatchInfo.getCurrentBatchRows();
+        Set<Long> idsOfCurrentBatch = new HashSet<>(3000);
+        for (Row currentBatchRow : currentBatchRows) {
+            Long matId = currentBatchRow.getLong(0);
+            idsOfCurrentBatch.add(matId);
+        }
         //查询最近5年的数据
         /*QFilter qFilter = new QFilter(PerfManagerFormConstant.NCKD_BEGINYEAR, QCP.less_equals, endDate)
                 .and(new QFilter(PerfManagerFormConstant.NCKD_ENDYEAR, QCP.large_equals, beginDate));*/
         QFilter qFilter = QFilter.of("1=1");
+        if(!idsOfCurrentBatch.isEmpty()){
+            qFilter.and(new QFilter(FormConstant.ID_KEY, QCP.in, idsOfCurrentBatch));
+        }
         qFilter.and(String.join(".", FormConstant.HRPI_EMPPOSORGREL, FormConstant.POS_STATUS,FormConstant.POST_STATE_CLS, FormConstant.NUMBER_KEY),QCP.equals,"1010_S");
 
         // 处理快速过滤条件

+ 10 - 1
code/opmc/nckd-jxccl-opmc/src/main/java/nckd/jxccl/opmc/pm/plugin/form/result/AnnualPerfDetailFormPlugin.java

@@ -7,6 +7,7 @@ import kd.bos.entity.operate.OperateOptionConst;
 import kd.bos.entity.operate.result.IOperateInfo;
 import kd.bos.entity.operate.result.OperateErrorInfo;
 import kd.bos.entity.operate.result.OperationResult;
+import kd.bos.entity.report.ReportQueryParam;
 import kd.bos.entity.validate.ErrorLevel;
 import kd.bos.form.FormShowParameter;
 import kd.bos.form.MessageBoxOptions;
@@ -15,6 +16,7 @@ import kd.bos.form.events.AfterDoOperationEventArgs;
 import kd.bos.form.events.PreOpenFormEventArgs;
 import kd.bos.form.plugin.AbstractFormPlugin;
 import kd.bos.report.ReportList;
+import kd.bos.report.plugin.AbstractReportFormPlugin;
 import kd.bos.servicehelper.operation.OperationServiceHelper;
 import kd.sdk.plugin.Plugin;
 import nckd.jxccl.base.common.constant.FormConstant;
@@ -35,7 +37,7 @@ import java.util.stream.Stream;
 * @date 2025/11/15 21:51
 * @version 1.0
 */
-public class AnnualPerfDetailFormPlugin extends AbstractFormPlugin implements Plugin {
+public class AnnualPerfDetailFormPlugin extends AbstractReportFormPlugin implements Plugin {
 
     @Override
     public void preOpenForm(PreOpenFormEventArgs e) {
@@ -46,6 +48,13 @@ public class AnnualPerfDetailFormPlugin extends AbstractFormPlugin implements Pl
         super.preOpenForm(e);
     }
 
+    @Override
+    public void beforeQuery(ReportQueryParam queryParam) {
+        ReportList reportList = this.getControl("reportlistap");
+        reportList.setSelectedAll(true);
+    }
+
+
     @Override
     public void afterDoOperation(AfterDoOperationEventArgs e) {
         if(e.getOperationResult() != null && e.getOperationResult().isSuccess()) {

+ 38 - 0
code/opmc/nckd-jxccl-opmc/src/main/java/nckd/jxccl/opmc/pm/plugin/form/result/AnnualPerfDetailReportListDataPlugin.java

@@ -2,17 +2,21 @@ package nckd.jxccl.opmc.pm.plugin.form.result;
 
 import kd.bos.algo.DataSet;
 import kd.bos.algo.GroupbyDataSet;
+import kd.bos.algo.Row;
 import kd.bos.context.RequestContext;
+import kd.bos.dataentity.entity.DynamicObjectCollection;
 import kd.bos.dataentity.entity.LocaleString;
 import kd.bos.entity.EntityMetadataCache;
 import kd.bos.entity.QueryEntityType;
 import kd.bos.entity.report.AbstractReportColumn;
 import kd.bos.entity.report.AbstractReportListDataPlugin;
 import kd.bos.entity.report.FastFilter;
+import kd.bos.entity.report.IReportBatchQueryInfo;
 import kd.bos.entity.report.ReportColumn;
 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.bos.servicehelper.model.PermissionStatus;
 import kd.hr.hbp.business.servicehelper.HRQueryEntityHelper;
 import kd.sdk.hr.hbp.business.helper.permission.HRPermissionServiceHelper;
@@ -26,8 +30,10 @@ import nckd.jxccl.opmc.pm.common.PerfManagerFormConstant;
 import java.time.LocalDate;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 /**
 * 年度绩效结果明细-报表取数插件
@@ -38,6 +44,23 @@ import java.util.Map;
 */
 public class AnnualPerfDetailReportListDataPlugin extends AbstractReportListDataPlugin implements Plugin {
 
+    @Override
+    public DataSet queryBatchBy(ReportQueryParam queryParam){
+        QueryFieldBuilder queryFieldBuilder = QueryFieldBuilder.create()
+                .add(FormConstant.ID_KEY)
+                .orderDesc(FormConstant.NCKD_PERSON,PerfManagerFormConstant.NCKD_BEGINYEAR);
+        QFilter qFilter = QFilter.of("1=1");
+        //权限过滤
+        QFilter dataRule = HRPermissionServiceHelper.getDataRule(
+                RequestContext.get().getCurrUserId(), "nckd_pm", PerfManagerFormConstant.PERFMANAGER_ENTITYID,
+                PermissionStatus.View, new HashMap<>());
+        if(dataRule != null){
+            qFilter.and(dataRule);
+        }
+        IReportBatchQueryInfo byBatchInfo = queryParam.byBatchInfo();
+        byBatchInfo.setCountPerBatch(3000);
+        return QueryServiceHelper.queryDataSet(this.getClass().getName(),PerfManagerFormConstant.PERFMANAGER_ENTITYID, queryFieldBuilder.buildSelect(), new QFilter[]{qFilter}, queryFieldBuilder.buildOrder(),1000000);
+    }
 
     @Override
     public DataSet query(ReportQueryParam reportQueryParam, Object o) throws Throwable {
@@ -52,10 +75,25 @@ public class AnnualPerfDetailReportListDataPlugin extends AbstractReportListData
 
         int currentYear = LocalDate.now().getYear(); // 不包含今年
         Date endDate = DateUtil.toDate(LocalDate.of(currentYear, 1, 1));
+
+        // 分批加载过滤
+        IReportBatchQueryInfo byBatchInfo = reportQueryParam.byBatchInfo();
+        // 获取当前批次的分批依据行
+        List<Row> currentBatchRows = byBatchInfo.getCurrentBatchRows();
+        Set<Long> idsOfCurrentBatch = new HashSet<>(3000);
+        for (Row currentBatchRow : currentBatchRows) {
+            Long matId = currentBatchRow.getLong(0);
+            idsOfCurrentBatch.add(matId);
+        }
         //查询最近5年的数据
         /*QFilter qFilter = new QFilter(PerfManagerFormConstant.NCKD_BEGINYEAR, QCP.less_equals, endDate)
                 .and(new QFilter(PerfManagerFormConstant.NCKD_ENDYEAR, QCP.large_equals, beginDate));*/
         QFilter qFilter = QFilter.of("1=1");
+        if(!idsOfCurrentBatch.isEmpty()){
+            qFilter.and(new QFilter(FormConstant.ID_KEY, QCP.in, idsOfCurrentBatch));
+        }
+
+
         qFilter.and(String.join(".", FormConstant.HRPI_EMPPOSORGREL, FormConstant.POS_STATUS,FormConstant.POST_STATE_CLS, FormConstant.NUMBER_KEY),QCP.equals,"1010_S");
 
         // 处理快速过滤条件