提交 32f3c70d 编写于 作者: O o2null

删除unit中的InheritControllerList属性

上级 0776fa1c
......@@ -53,8 +53,8 @@ public class Business {
public Business(EntityManagerContainer emc) throws Exception {
this.emc = emc;
this.cacheCategory = new CacheCategory(Group.class, Role.class, Person.class, PersonAttribute.class,
Unit.class, UnitDuty.class, UnitAttribute.class, Identity.class);
this.cacheCategory = new CacheCategory(Group.class, Role.class, Person.class, PersonAttribute.class, Unit.class,
UnitDuty.class, UnitAttribute.class, Identity.class);
}
public EntityManagerContainer entityManagerContainer() {
......@@ -128,9 +128,9 @@ public class Business {
public RoleFactory role() throws ExceptionRoleFactory {
if (null == this.role) {
try{
try {
this.role = new RoleFactory(this);
} catch (Exception e){
} catch (Exception e) {
throw new ExceptionRoleFactory(e);
}
}
......@@ -214,8 +214,8 @@ public class Business {
return true;
}
}
if (ListTools.isNotEmpty(unit.getInheritedControllerList())) {
List<Person> os = this.person().pick(unit.getInheritedControllerList());
for (Unit u : unit().pick(unit().listSupNested(unit.getId()))) {
List<Person> os = this.person().pick(u.getControllerList());
List<String> list = ListTools.extractProperty(os, JpaObject.DISTINGUISHEDNAME, String.class, true, true);
if (ListTools.contains(list, effectivePerson.getDistinguishedName())) {
return true;
......
......@@ -219,13 +219,13 @@ public class UnitFactory extends AbstractFactory {
// Collections.reverse(names);
names.add(o.getName());
o.setLevelName(StringUtils.join(names, PersistenceProperties.Unit.levelNameSplit));
List<String> inheritControllerList = new ArrayList<>();
for (Unit u : list) {
if (ListTools.isNotEmpty(u.getControllerList())) {
inheritControllerList.addAll(u.getControllerList());
}
}
o.setInheritedControllerList(ListTools.trim(inheritControllerList, true, true));
// List<String> inheritControllerList = new ArrayList<>();
// for (Unit u : list) {
// if (ListTools.isNotEmpty(u.getControllerList())) {
// inheritControllerList.addAll(u.getControllerList());
// }
// }
// o.setInheritedControllerList(ListTools.trim(inheritControllerList, true, true));
}
}
......
......@@ -153,7 +153,7 @@ class ActionDelete extends BaseAction {
List<Unit> os = em.createQuery(cq.select(root).where(p)).getResultList().stream().distinct().collect(Collectors.toList());
for (Unit o : os) {
o.getControllerList().remove(person.getId());
o.getInheritedControllerList().remove(person.getId());
//o.getInheritedControllerList().remove(person.getId());
}
}
......
......@@ -18,6 +18,8 @@ import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
import com.x.base.core.project.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
......@@ -26,8 +28,6 @@ import com.x.base.core.project.tools.StringTools;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Person;
import com.x.organization.core.entity.Person_;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
class ActionListPinyinInitial extends BaseAction {
......
package com.x.organization.assemble.control.jaxrs.person;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
......@@ -162,12 +163,16 @@ abstract class BaseAction extends StandardJaxrsAction {
if (null != person && t.getControllerList().contains(person.getId())) {
List<Identity> identities = this.listIdentity(business, t);
List<Unit> units = this.listUnit(business, identities);
List<Unit> supUnits = new ArrayList<>();
for (Unit u : units) {
supUnits.addAll(business.unit().listSupNestedObject(u));
}
units.addAll(supUnits);
if (ListTools.isNotEmpty(units)) {
allowEdit = false;
allowDelete = true;
for (Unit o : units) {
if (o.getControllerList().contains(person.getId())
|| o.getInheritedControllerList().contains(person.getId())) {
if (o.getControllerList().contains(person.getId())) {
allowEdit = true;
} else {
allowDelete = false;
......
......@@ -55,7 +55,7 @@ class ActionCreate extends BaseAction {
if (this.duplicateUniqueWhenNotEmpty(business, unit)) {
throw new ExceptionDuplicateUnique(unit.getName(), unit.getUnique());
}
if (this.checkNameInvalid(business,unit)){
if (this.checkNameInvalid(business, unit)) {
throw new ExceptionNameInvalid(unit.getName());
}
/** 判断同一级别下name不重复 */
......@@ -64,11 +64,11 @@ class ActionCreate extends BaseAction {
}
emc.beginTransaction(Unit.class);
business.unit().adjustInherit(unit);
emc.persist(unit,CheckPersistType.all);
emc.persist(unit, CheckPersistType.all);
emc.commit();
CacheManager.notify(Unit.class);
/**创建 组织变更org消息通信 */
/** 创建 组织变更org消息通信 */
OrgMessageFactory orgMessageFactory = new OrgMessageFactory();
orgMessageFactory.createMessageCommunicate("add", "unit", unit, effectivePerson);
......@@ -86,11 +86,14 @@ class ActionCreate extends BaseAction {
private static final long serialVersionUID = -6314932919066148113L;
// static WrapCopier<Wi, Unit> copier = WrapCopierFactory.wi(Wi.class, Unit.class, null,
// ListTools.toList(JpaObject.FieldsUnmodify, Unit.pinyin_FIELDNAME,
// Unit.pinyinInitial_FIELDNAME, Unit.level_FIELDNAME, Unit.levelName_FIELDNAME,
// Unit.inheritedControllerList_FIELDNAME));
static WrapCopier<Wi, Unit> copier = WrapCopierFactory.wi(Wi.class, Unit.class, null,
ListTools.toList(JpaObject.FieldsUnmodify, Unit.pinyin_FIELDNAME,
Unit.pinyinInitial_FIELDNAME, Unit.level_FIELDNAME, Unit.levelName_FIELDNAME,
Unit.inheritedControllerList_FIELDNAME));
ListTools.toList(JpaObject.FieldsUnmodify, Unit.pinyin_FIELDNAME, Unit.pinyinInitial_FIELDNAME,
Unit.level_FIELDNAME, Unit.levelName_FIELDNAME));
}
}
......@@ -63,14 +63,15 @@ class ActionEdit extends BaseAction {
Gson gsontool = new Gson();
String strOriginalUnit = gsontool.toJson(unit);
unit.setControllerList(ListTools.extractProperty(business.person().pick(ListTools.trim(unit.getControllerList(), true, true)),
unit.setControllerList(ListTools.extractProperty(
business.person().pick(ListTools.trim(unit.getControllerList(), true, true)),
JpaObject.id_FIELDNAME, String.class, true, true));
Wi.copier.copy(wi, unit);
/** 如果唯一标识不为空,要检查唯一标识是否唯一 */
if (this.duplicateUniqueWhenNotEmpty(business, unit)) {
throw new ExceptionDuplicateUnique(unit.getName(), unit.getUnique());
}
if (this.checkNameInvalid(business,unit)){
if (this.checkNameInvalid(business, unit)) {
throw new ExceptionNameInvalid(unit.getName());
}
/** 判断同一级别下name不重复 */
......@@ -78,8 +79,8 @@ class ActionEdit extends BaseAction {
throw new ExceptionDuplicateName(unit.getName());
}
/** 判断是否修改了组织级别或组织名称,如果修改了,需要重新计算当前组织及下属组织的组织级别 */
checkFlag = this.checkUnitTypeName(oldUnit,unit);
if(checkFlag){
checkFlag = this.checkUnitTypeName(oldUnit, unit);
if (checkFlag) {
business.unit().adjustInherit(unit);
}
emc.check(unit, CheckPersistType.all);
......@@ -87,13 +88,13 @@ class ActionEdit extends BaseAction {
CacheManager.notify(Unit.class);
/** 判断是否修改了组织级别或组织名称,如果修改了,需要重新计算当前组织及下属组织成员的身份(组织名称,组织级别名称) */
if(checkFlag){
if (checkFlag) {
this.updateIdentityUnitNameAndUnitLevelName(effectivePerson, flag, jsonElement);
}
/**创建 组织变更org消息通信 */
/** 创建 组织变更org消息通信 */
OrgMessageFactory orgMessageFactory = new OrgMessageFactory();
orgMessageFactory.createMessageCommunicate("modfiy", "unit",strOriginalUnit, unit, effectivePerson);
orgMessageFactory.createMessageCommunicate("modfiy", "unit", strOriginalUnit, unit, effectivePerson);
Wo wo = new Wo();
wo.setId(unit.getId());
......@@ -111,18 +112,23 @@ class ActionEdit extends BaseAction {
private static final long serialVersionUID = -7527954993386512109L;
// static WrapCopier<Wi, Unit> copier = WrapCopierFactory.wi(Wi.class, Unit.class, null,
// ListTools.toList(JpaObject.FieldsUnmodify, Unit.superior_FIELDNAME, Unit.pinyin_FIELDNAME,
// static WrapCopier<Wi, Unit> copier = WrapCopierFactory.wi(Wi.class,
// Unit.class, null,
// ListTools.toList(JpaObject.FieldsUnmodify, Unit.superior_FIELDNAME,
// Unit.pinyin_FIELDNAME,
// Unit.pinyinInitial_FIELDNAME, Unit.level_FIELDNAME, Unit.levelName_FIELDNAME,
// Unit.inheritedControllerList_FIELDNAME));
// static WrapCopier<Wi, Unit> copier = WrapCopierFactory.wi(Wi.class, Unit.class, null,
// ListTools.toList(JpaObject.FieldsUnmodify, Unit.pinyin_FIELDNAME, Unit.pinyinInitial_FIELDNAME, Unit.level_FIELDNAME,
// Unit.levelName_FIELDNAME, Unit.inheritedControllerList_FIELDNAME));
static WrapCopier<Wi, Unit> copier = WrapCopierFactory.wi(Wi.class, Unit.class, null,
ListTools.toList(JpaObject.FieldsUnmodify, Unit.pinyin_FIELDNAME, Unit.pinyinInitial_FIELDNAME, Unit.level_FIELDNAME,
Unit.levelName_FIELDNAME, Unit.inheritedControllerList_FIELDNAME));
ListTools.toList(JpaObject.FieldsUnmodify, Unit.pinyin_FIELDNAME, Unit.pinyinInitial_FIELDNAME,
Unit.level_FIELDNAME, Unit.levelName_FIELDNAME));
}
//根据组织标志列出身份列表
// 根据组织标志列出身份列表
private List<Identity> listIdentityByUnitFlag(Business business, Unit unit) throws Exception {
//Unit unit = business.unit().pick(unitFlag);
// Unit unit = business.unit().pick(unitFlag);
if (null == unit.getId() || StringUtils.isEmpty(unit.getId()) || null == unit) {
throw new ExceptionUnitNotExist(unit.getId());
}
......@@ -135,9 +141,9 @@ class ActionEdit extends BaseAction {
return os;
}
//列出所有递归下级组织(包含当前组织)
// 列出所有递归下级组织(包含当前组织)
private List<Unit> listUnit(Business business, String flag) throws Exception {
//Unit unit = business.unit().pick(flag);
// Unit unit = business.unit().pick(flag);
EntityManager em = business.entityManagerContainer().get(Unit.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
......@@ -158,17 +164,18 @@ class ActionEdit extends BaseAction {
throw new ExceptionUnitNotExist(flag);
}
//所有下级组织
// 所有下级组织
List<Unit> os = business.unit().listSubNestedObject(unit);
//把当前组织加入到os
// 把当前组织加入到os
List<Unit> _currentUnitSingleArray = new ArrayList<Unit>();
_currentUnitSingleArray.add(unit);
os = ListTools.add(_currentUnitSingleArray, true, true, os);
return os;
}
void updateIdentityUnitNameAndUnitLevelName(EffectivePerson effectivePerson, String flag, JsonElement jsonElement) throws Exception {
void updateIdentityUnitNameAndUnitLevelName(EffectivePerson effectivePerson, String flag, JsonElement jsonElement)
throws Exception {
CacheManager.notify(Unit.class);
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
......@@ -185,7 +192,7 @@ class ActionEdit extends BaseAction {
}
/*
* 同时更新unit下的所有身份的UnitLevelName,UnitName
* */
*/
List<Unit> unitList = this.listUnit(business, flag);
for (Unit u : unitList) {
......@@ -213,13 +220,12 @@ class ActionEdit extends BaseAction {
private boolean checkUnitTypeName(Unit oldUnit, Unit unit) throws Exception {
List<String> oldUnitType = oldUnit.getTypeList();
List<String> unitType = unit.getTypeList();
//判断两个list是否相同
if (oldUnitType.retainAll(unitType) || (!StringUtils.equals(oldUnit.getName(), unit.getName())) || (!StringUtils.equals(oldUnit.getSuperior(), unit.getSuperior()))) {
// 判断两个list是否相同
if (oldUnitType.retainAll(unitType) || (!StringUtils.equals(oldUnit.getName(), unit.getName()))
|| (!StringUtils.equals(oldUnit.getSuperior(), unit.getSuperior()))) {
return true;
}
return false;
}
}
......@@ -221,11 +221,11 @@ public class UnitFactory extends AbstractFactory {
names = names.stream().sorted(Comparator.reverseOrder()).collect(Collectors.toList());
names.add(o.getName());
o.setLevelName(StringUtils.join(names, "/"));
List<String> inheritControllerList = new ArrayList<>();
for (Unit u : list) {
inheritControllerList.addAll(u.getControllerList());
}
o.setInheritedControllerList(ListTools.trim(inheritControllerList, true, true));
// List<String> inheritControllerList = new ArrayList<>();
// for (Unit u : list) {
// inheritControllerList.addAll(u.getControllerList());
// }
// o.setInheritedControllerList(ListTools.trim(inheritControllerList, true, true));
}
}
......
......@@ -34,6 +34,7 @@ import javax.persistence.criteria.Root;
class ActionListObject extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionListObject.class);
@SuppressWarnings("unchecked")
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
......@@ -81,8 +82,11 @@ class ActionListObject extends BaseAction {
@FieldDescribe("直接下级身份数量")
private Long subDirectIdentityCount = 0L;
// static WrapCopier<Unit, Wo> copier = WrapCopierFactory.wo(Unit.class, Wo.class, null,
// ListTools.toList(JpaObject.FieldsInvisible,Unit.controllerList_FIELDNAME,Unit.inheritedControllerList_FIELDNAME));
static WrapCopier<Unit, Wo> copier = WrapCopierFactory.wo(Unit.class, Wo.class, null,
ListTools.toList(JpaObject.FieldsInvisible,Unit.controllerList_FIELDNAME,Unit.inheritedControllerList_FIELDNAME));
ListTools.toList(JpaObject.FieldsInvisible, Unit.controllerList_FIELDNAME));
public String getMatchKey() {
return matchKey;
......@@ -114,7 +118,7 @@ class ActionListObject extends BaseAction {
List<Wo> wos = new ArrayList<>();
for (String str : wi.getUnitList()) {
Unit o = business.unit().pick(str);
if(o!=null){
if (o != null) {
Wo wo = Wo.copier.copy(o);
wo.setMatchKey(str);
if (StringUtils.isNotEmpty(wo.getSuperior())) {
......
......@@ -210,11 +210,11 @@ public class UnitFactory extends AbstractFactory {
// Collections.reverse(names);
names.add(o.getName());
o.setLevelName(StringUtils.join(names, PersistenceProperties.Unit.levelNameSplit));
List<String> inheritControllerList = new ArrayList<>();
for (Unit u : list) {
inheritControllerList.addAll(u.getControllerList());
}
o.setInheritedControllerList(ListTools.trim(inheritControllerList, true, true));
// List<String> inheritControllerList = new ArrayList<>();
// for (Unit u : list) {
// inheritControllerList.addAll(u.getControllerList());
// }
// o.setInheritedControllerList(ListTools.trim(inheritControllerList, true, true));
}
}
......
......@@ -189,17 +189,17 @@ public class Unit extends SliceJpaObject {
@CheckPersist(allowEmpty = true, citationExists = @CitationExist(type = Person.class))
private List<String> controllerList;
public static final String inheritedControllerList_FIELDNAME = "inheritedControllerList";
@FieldDescribe("继承自上级组织的管理人员.")
@PersistentCollection(fetch = FetchType.EAGER)
@OrderColumn(name = ORDERCOLUMNCOLUMN)
@ContainerTable(name = TABLE + ContainerTableNameMiddle
+ inheritedControllerList_FIELDNAME, joinIndex = @Index(name = TABLE + IndexNameMiddle
+ inheritedControllerList_FIELDNAME + JoinIndexNameSuffix))
@ElementColumn(length = JpaObject.length_id, name = ColumnNamePrefix + inheritedControllerList_FIELDNAME)
@ElementIndex(name = TABLE + IndexNameMiddle + inheritedControllerList_FIELDNAME + ElementIndexNameSuffix)
@CheckPersist(allowEmpty = true, citationExists = @CitationExist(type = Person.class))
private List<String> inheritedControllerList;
// public static final String inheritedControllerList_FIELDNAME = "inheritedControllerList";
// @FieldDescribe("继承自上级组织的管理人员.")
// @PersistentCollection(fetch = FetchType.EAGER)
// @OrderColumn(name = ORDERCOLUMNCOLUMN)
// @ContainerTable(name = TABLE + ContainerTableNameMiddle
// + inheritedControllerList_FIELDNAME, joinIndex = @Index(name = TABLE + IndexNameMiddle
// + inheritedControllerList_FIELDNAME + JoinIndexNameSuffix))
// @ElementColumn(length = JpaObject.length_id, name = ColumnNamePrefix + inheritedControllerList_FIELDNAME)
// @ElementIndex(name = TABLE + IndexNameMiddle + inheritedControllerList_FIELDNAME + ElementIndexNameSuffix)
// @CheckPersist(allowEmpty = true, citationExists = @CitationExist(type = Person.class))
// private List<String> inheritedControllerList;
public static final String dingdingId_FIELDNAME = "dingdingId";
@FieldDescribe("钉钉部门ID.")
......@@ -351,13 +351,13 @@ public class Unit extends SliceJpaObject {
this.distinguishedName = distinguishedName;
}
public List<String> getInheritedControllerList() {
return inheritedControllerList;
}
public void setInheritedControllerList(List<String> inheritedControllerList) {
this.inheritedControllerList = inheritedControllerList;
}
// public List<String> getInheritedControllerList() {
// return inheritedControllerList;
// }
//
// public void setInheritedControllerList(List<String> inheritedControllerList) {
// this.inheritedControllerList = inheritedControllerList;
// }
public String getDescription() {
return description;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册