榆叶和晨曦,人员分开

This commit is contained in:
“wyx12345678” 2024-07-15 17:34:19 +08:00
parent 6e4c9c3c8f
commit 65884bbc8f
2 changed files with 118 additions and 0 deletions

View File

@ -0,0 +1,25 @@
package shkd.user.plugin;
import kd.bos.entity.datamodel.ITreeModel;
import kd.bos.entity.filter.FilterParameter;
import kd.bos.form.control.events.RefreshNodeEvent;
import kd.bos.form.plugin.AbstractFormPlugin;
import kd.bos.list.BillList;
import kd.bos.list.plugin.AbstractListPlugin;
import kd.sdk.plugin.Plugin;
import java.util.EventObject;
/**
* 动态表单插件
*/
public class UserF7FormPlugin extends AbstractListPlugin implements Plugin {
@Override
public void beforeBindData(EventObject e) {
super.afterBindData(e);
BillList billList = this.getControl("billlistap");
FilterParameter queryFilterParameter = billList.getQueryFilterParameter();
System.out.println();
}
}

View File

@ -0,0 +1,93 @@
package shkd.user.plugin;
import kd.bos.context.RequestContext;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.filter.FilterParameter;
import kd.bos.entity.tree.TreeNode;
import kd.bos.filter.events.ExpandEvent;
import kd.bos.form.control.events.RefreshNodeEvent;
import kd.bos.form.events.FilterContainerInitArgs;
import kd.bos.form.events.SetFilterEvent;
import kd.bos.form.field.events.BeforeFilterF7SelectEvent;
import kd.bos.form.plugin.AbstractFormPlugin;
import kd.bos.list.BillList;
import kd.bos.list.plugin.AbstractListPlugin;
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.util.EventObject;
import java.util.List;
/**
* 动态表单插件
*/
public class UserTreeListPlugin extends kd.bos.sec.user.plugin.UserTreeListPlugin implements Plugin {
@Override
public void initializeTree(EventObject e) {
super.initializeTree(e);
}
@Override
public void refreshNode(RefreshNodeEvent e) {
super.refreshNode(e);
List<TreeNode> childNodes = e.getChildNodes();
System.out.println();
// childNodes.remove(0);
// e.setChildNodes(childNodes);
long currUserId = RequestContext.get().getCurrUserId();
QFilter qFilter = new QFilter("id", QCP.equals, currUserId);
DynamicObject bos_user = BusinessDataServiceHelper.loadSingle("bos_user", qFilter.toArray());
DynamicObjectCollection entryentity = bos_user.getDynamicObjectCollection("entryentity");
Boolean isCh = false; //晨曦
Boolean isYY = false; //榆叶
for (DynamicObject dynamicObject : entryentity) {
DynamicObject dpt = dynamicObject.getDynamicObject("dpt");
Boolean isYuYe = this.getIsYuYe(dpt);
if(isYuYe){
isYY = true;
}else{
isCh = true;
}
}
if(!isCh|| !isYY){ //没有晨曦的权限
for (int i=childNodes.size()-1;i>=0;i--) {
TreeNode childNode = childNodes.get(i);
String id = childNode.getId();
if("noOrg".equals(id)){
continue;
}
QFilter qf = new QFilter("id", QCP.equals, Long.valueOf(id));
DynamicObject bos_adminorg = BusinessDataServiceHelper.loadSingle("bos_adminorg", qf.toArray());
String number = bos_adminorg.getString("number");
if(!isYY&&"16004610".equals(number)){ //榆叶
childNodes.remove(childNode);
}else if(!isCh&&"16005873".equals(number)){ //晨曦
childNodes.remove(childNode);
}
}
}
}
//判断是否榆叶下的部门
private Boolean getIsYuYe( DynamicObject dpt){
List<Long> allSuperiorOrges = OrgUnitServiceHelper.getAllSuperiorOrgs("01", dpt.getLong("id"));
QFilter qf = new QFilter("number", QCP.equals, "16004610");
DynamicObject org_yuye = BusinessDataServiceHelper.loadSingle("bos_adminorg", qf.toArray());
Long id = org_yuye.getLong("id");
boolean contains = allSuperiorOrges.contains(id);
return contains;
}
}