【亚伟-苍穹系列】之代码实现列表界面动态加载-流程当前处理人原创
金蝶云社区-王亚伟
王亚伟
17人赞赏了该文章 2,502次浏览 未经作者许可,禁止转载编辑于2023年03月10日 16:44:14

一、单据新增文本字段‘当前处理人’(nextauditor);

二、列表界面将该字段设置显示;

三、新增列表界面插件,增加如下代码实现:

-----------List插件代码

/** 

* @Description 列表界面创建列表数据前查询工作流当前处理人写入当前列表单据

*/

@Override

public void beforeCreateListDataProvider(BeforeCreateListDataProviderArgs args) {

super.beforeCreateListDataProvider(args);

args.setListDataProvider(new ListDataProvider() {

        @Override

        public DynamicObjectCollection getData(int start, int limit) {  //组装单据对应的当前处理人

            DynamicObjectCollection dynObjs = super.getData(start, limit);

            List<String> ids = new ArrayList<>();

            dynObjs.forEach((v) -> {

                ids.add(String.valueOf(v.getPkValue()));

            });

            if (ids.size() > 0) {

                setNextAuditor(dynObjs, ids);

            }

            return dynObjs;

        }

    });

}

/**

* 设置当前处理人

*/

private void setNextAuditor(DynamicObjectCollection collection, List<String> ids) {

    Map<String, String> nextAuditor = ViewFlowchartUtil.getNextAuditor(ids);

    collection.forEach((v) -> {

        String id = String.valueOf(v.getPkValue());

        v.set("nextauditor", nextAuditor.get(id) == null ? "" : nextAuditor.get(id));

    });

}


-----------util类

package com.kingdee.fi.som.perfmanage.utilplugin;


import java.util.HashMap;

import java.util.Iterator;

import java.util.List;

import java.util.Map;


import kd.bos.servicehelper.workflow.WorkflowServiceHelper;

import kd.bos.workflow.api.BizProcessStatus;


/**

 * @Description 查看工作流信息工具类

 */

public class ViewFlowchartUtil {


/**

* 描述:根据单据的id获取单据当前的工作流节点

*/

public static Map<String, String> getNextAuditor(List<String> pkIds) {

    Map<String, String> nodeMap = new HashMap<>(10);

    String[] ids = new String[pkIds.size()];

    pkIds.toArray(ids);

    Map<String, List<BizProcessStatus>> allPro = WorkflowServiceHelper.getBizProcessStatus(ids);

    Iterator<Map.Entry<String, List<BizProcessStatus>>> var5 = allPro.entrySet().iterator();


    while(var5.hasNext()) {

        String pkid = var5.next().getKey();

        List<BizProcessStatus> node = allPro.get(pkid);

        node.forEach((e) -> {

            String nodeStr = e.getCurrentNodeName();

            String auditor = e.getParticipantName();

            if (auditor != null && !"".equals(auditor.trim())) {

                nodeStr = nodeStr + " / " + auditor;

            }

            nodeMap.put(pkid, nodeStr);

        });

    }

    return nodeMap;

}

}


赞 17