代码实现列表界面动态加载-流程当前处理人
一、单据新增文本字段‘当前处理人’(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);
Listids = 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, Listids) {
MapnextAuditor = 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.hisense.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 MapgetNextAuditor(ListpkIds) {
MapnodeMap = new HashMap<>(10);
String[] ids = new String[pkIds.size()];
pkIds.toArray(ids);
Map<string, list> allPro = WorkflowServiceHelper.getBizProcessStatus(ids);
Iterator<map.entry<string, list>> var5 = allPro.entrySet().iterator();
while(var5.hasNext()) {
String pkid = var5.next().getKey();
Listnode = 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;
}
}