|
@@ -1,31 +1,38 @@
|
|
|
package com.lc.ibps.bpmn.plugin.usercalc.pos.runtime;
|
|
package com.lc.ibps.bpmn.plugin.usercalc.pos.runtime;
|
|
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
|
-import java.util.Collections;
|
|
|
|
|
-import java.util.HashMap;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
-import java.util.Map;
|
|
|
|
|
-
|
|
|
|
|
-import javax.annotation.Resource;
|
|
|
|
|
-
|
|
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
-
|
|
|
|
|
import com.lc.ibps.api.base.model.PartyEntity;
|
|
import com.lc.ibps.api.base.model.PartyEntity;
|
|
|
import com.lc.ibps.api.org.constant.PartyType;
|
|
import com.lc.ibps.api.org.constant.PartyType;
|
|
|
|
|
+import com.lc.ibps.base.core.constants.StringPool;
|
|
|
import com.lc.ibps.base.core.exception.BaseException;
|
|
import com.lc.ibps.base.core.exception.BaseException;
|
|
|
import com.lc.ibps.base.core.util.BeanUtils;
|
|
import com.lc.ibps.base.core.util.BeanUtils;
|
|
|
import com.lc.ibps.bpmn.api.constant.BpmConstants;
|
|
import com.lc.ibps.bpmn.api.constant.BpmConstants;
|
|
|
|
|
+import com.lc.ibps.bpmn.api.constant.ExtractType;
|
|
|
|
|
+import com.lc.ibps.bpmn.api.constant.LogicType;
|
|
|
import com.lc.ibps.bpmn.api.model.identity.BpmIdentity;
|
|
import com.lc.ibps.bpmn.api.model.identity.BpmIdentity;
|
|
|
import com.lc.ibps.bpmn.api.model.task.IBpmTaskApproval;
|
|
import com.lc.ibps.bpmn.api.model.task.IBpmTaskApproval;
|
|
|
import com.lc.ibps.bpmn.api.plugin.define.IBpmPluginDefine;
|
|
import com.lc.ibps.bpmn.api.plugin.define.IBpmPluginDefine;
|
|
|
import com.lc.ibps.bpmn.api.plugin.session.BpmUserCalcPluginSession;
|
|
import com.lc.ibps.bpmn.api.plugin.session.BpmUserCalcPluginSession;
|
|
|
import com.lc.ibps.bpmn.api.service.BpmApprovalService;
|
|
import com.lc.ibps.bpmn.api.service.BpmApprovalService;
|
|
|
import com.lc.ibps.bpmn.plugin.core.runtime.AbstractUserCalcPlugin;
|
|
import com.lc.ibps.bpmn.plugin.core.runtime.AbstractUserCalcPlugin;
|
|
|
|
|
+import com.lc.ibps.bpmn.plugin.usercalc.ExecutorVar;
|
|
|
|
|
+import com.lc.ibps.bpmn.plugin.usercalc.UserCalcHelper;
|
|
|
import com.lc.ibps.bpmn.plugin.usercalc.UserCalcPluginUtil;
|
|
import com.lc.ibps.bpmn.plugin.usercalc.UserCalcPluginUtil;
|
|
|
import com.lc.ibps.bpmn.plugin.usercalc.pos.def.PosPluginDefine;
|
|
import com.lc.ibps.bpmn.plugin.usercalc.pos.def.PosPluginDefine;
|
|
|
import com.lc.ibps.cloud.entity.APIResult;
|
|
import com.lc.ibps.cloud.entity.APIResult;
|
|
|
|
|
+import com.lc.ibps.org.api.IPartyEntityService;
|
|
|
import com.lc.ibps.org.api.IPartyPositionService;
|
|
import com.lc.ibps.org.api.IPartyPositionService;
|
|
|
|
|
+import com.lc.ibps.org.party.persistence.entity.PartyEntityTreePo;
|
|
|
import com.lc.ibps.org.party.persistence.entity.PartyPositionPo;
|
|
import com.lc.ibps.org.party.persistence.entity.PartyPositionPo;
|
|
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 岗位插件
|
|
* 岗位插件
|
|
@@ -39,12 +46,13 @@ import com.lc.ibps.org.party.persistence.entity.PartyPositionPo;
|
|
|
*/
|
|
*/
|
|
|
public class PosPlugin extends AbstractUserCalcPlugin
|
|
public class PosPlugin extends AbstractUserCalcPlugin
|
|
|
{
|
|
{
|
|
|
-
|
|
|
|
|
|
|
+ private static final Logger logger = LoggerFactory.getLogger(PosPlugin.class);
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IPartyPositionService partyPositionService;
|
|
private IPartyPositionService partyPositionService;
|
|
|
@Resource
|
|
@Resource
|
|
|
private BpmApprovalService bpmApprovalService;
|
|
private BpmApprovalService bpmApprovalService;
|
|
|
-
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IPartyEntityService partyEntityService ;
|
|
|
@Override
|
|
@Override
|
|
|
public List<BpmIdentity> queryByPluginDef(BpmUserCalcPluginSession pluginSession, IBpmPluginDefine pluginDef)
|
|
public List<BpmIdentity> queryByPluginDef(BpmUserCalcPluginSession pluginSession, IBpmPluginDefine pluginDef)
|
|
|
{
|
|
{
|
|
@@ -71,8 +79,7 @@ public class PosPlugin extends AbstractUserCalcPlugin
|
|
|
if(BeanUtils.isNotEmpty(list)){
|
|
if(BeanUtils.isNotEmpty(list)){
|
|
|
return getIdentity(list);
|
|
return getIdentity(list);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- return Collections.emptyList();
|
|
|
|
|
|
|
+ return getIdentityExtend(def, pluginSession, vars, source);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private List<PartyEntity> getPoses(PosPluginDefine def, BpmUserCalcPluginSession pluginSession,
|
|
private List<PartyEntity> getPoses(PosPluginDefine def, BpmUserCalcPluginSession pluginSession,
|
|
@@ -147,6 +154,66 @@ public class PosPlugin extends AbstractUserCalcPlugin
|
|
|
}
|
|
}
|
|
|
return getBpmIdentityConverter().convertByMapList(gs);
|
|
return getBpmIdentityConverter().convertByMapList(gs);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * if type of newBpmIdentities is position, we NEED TO:
|
|
|
|
|
+ * 1. filter the existBpmIdentities when the id don't belong to newBpmIdentities
|
|
|
|
|
+ * 2. if the filtered list is empty, existBpmIdentities should be returned.
|
|
|
|
|
+ *
|
|
|
|
|
+ */
|
|
|
|
|
+ private List<BpmIdentity> getIdentityExtend(PosPluginDefine def, BpmUserCalcPluginSession pluginSession, Map<String, Object> vars, String source) {
|
|
|
|
|
+ if("var".equals(source) && def.getLogicCal().getKey().equals(LogicType.EXCLUDE.getKey())){
|
|
|
|
|
+ //we don't need to exact user for this rule.
|
|
|
|
|
+ def.setExtract(ExtractType.EXACT_NOEXACT);
|
|
|
|
|
+ List<BpmIdentity> list = new ArrayList<BpmIdentity>();
|
|
|
|
|
+ ExecutorVar executorVar = def.getExecutorVar();
|
|
|
|
|
+ UserCalcHelper uch = new UserCalcHelper();
|
|
|
|
|
+ List<String> pks = uch.getCalcsPKByExecutor(executorVar, pluginSession);
|
|
|
|
|
+ String[] pkArray = pks.toArray(new String[pks.size()]);
|
|
|
|
|
+ //find all position nodes
|
|
|
|
|
+ APIResult<List<PartyEntityTreePo>> tree = partyEntityService.findTreeByType(PartyType.POSITION.getValue());
|
|
|
|
|
+ if(!tree.isSuccess()) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ List<PartyEntityTreePo> treeData = tree.getData();
|
|
|
|
|
+ //remove root node
|
|
|
|
|
+ treeData = treeData.stream().filter(x -> !x.getId().equals(StringPool.ZERO)).collect(Collectors.toList());
|
|
|
|
|
+ //get child
|
|
|
|
|
+ List<String> posWithChild = treeData.stream().filter(x -> StringUtils.containsAny(x.getPath(), pkArray))
|
|
|
|
|
+ .map(PartyEntityTreePo::getId)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ //get parent nodes
|
|
|
|
|
+ List<String> posWithParent = treeData.stream().filter(x -> StringUtils.containsAny(x.getId(), pkArray))
|
|
|
|
|
+ .flatMap(y -> Arrays.stream(y.getPath().split("\\.",0)))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ //combine and distinct
|
|
|
|
|
+ List<String> pksWithParentChild = Stream.of(posWithChild, posWithParent)
|
|
|
|
|
+ .flatMap(Collection::stream)
|
|
|
|
|
+ .distinct()
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
|
|
+ List<BpmIdentity> calcBpmIdentity = (List<BpmIdentity>)pluginSession.getVariables().get("calcBpmIdentity");
|
|
|
|
|
+ for(BpmIdentity identity: calcBpmIdentity) {
|
|
|
|
|
+
|
|
|
|
|
+ APIResult<List<PartyPositionPo>> usersResult = partyPositionService.findByUserId(identity.getId());
|
|
|
|
|
+ if(usersResult.isSuccess()) {
|
|
|
|
|
+ List<PartyPositionPo> pos = usersResult.getData();
|
|
|
|
|
+ if (BeanUtils.isNotEmpty(pos)) {
|
|
|
|
|
+ List<String> ids = pos.stream().map(PartyPositionPo::getId).collect(Collectors.toList());
|
|
|
|
|
+ //filter
|
|
|
|
|
+ if(Collections.disjoint(ids, pksWithParentChild)){
|
|
|
|
|
+ list.add(identity);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if(CollectionUtils.isNotEmpty(list)){
|
|
|
|
|
+ logger.info("skipped users: {}",list.toString());
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return Collections.emptyList();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
public boolean supportRuntimePreView(){
|
|
public boolean supportRuntimePreView(){
|
|
|
return true;
|
|
return true;
|