提交 234b64c5 编写于 作者: liyi_hz2008's avatar liyi_hz2008

Merge branch 'fix/CMS.getMajorIdentityWithPerson' into 'develop'

[内容管理]修复在没有设置主身份时,内容管理和考勤管理中根据用户名查询主身份报错的问题

See merge request o2oa/o2oa!1712
......@@ -385,13 +385,15 @@ public class UserManagerService {
if (ListTools.isNotEmpty( identities )) {
if( identities.size() == 1 ) {
return identities.get(0);
}
for (String identity : identities) {
Identity obj = business.organization().identity().getObject(identity);
if (obj!= null && obj.getMajor() !=null && obj.getMajor() ) {
return identity;
}else{
for (String identity : identities) {
Identity obj = business.organization().identity().getObject(identity);
if (obj.getMajor()) {
return identity;
}
}
}
return identities.get(0);
}
return null;
} catch (Exception e) {
......
......@@ -182,7 +182,7 @@ public class ActionPersistPublishByWorkFlow extends BaseAction {
wi.setCreatorTopUnitName("xadmin");
}else {
//尝试一下根据当前用户获取用户的第一个身份
wi.setCreatorIdentity(userManagerService.getMajorIdentityWithPerson( effectivePerson.getDistinguishedName()) );
wi.setCreatorIdentity( userManagerService.getMajorIdentityWithPerson( effectivePerson.getDistinguishedName()) );
}
}
......
......@@ -199,7 +199,7 @@ public class ActionPersistPublishContent extends BaseAction {
wi.setCreatorTopUnitName("xadmin");
}else {
//尝试一下根据传入的用户或者当前用户获取用户的第一个身份
wi.setCreatorIdentity(userManagerService.getMajorIdentityWithPerson( wi.getCreatorPerson() ) );
wi.setCreatorIdentity( userManagerService.getMajorIdentityWithPerson( wi.getCreatorPerson() ) );
}
}
......
......@@ -166,7 +166,7 @@ public class UserManagerService {
* @return
* @throws Exception
*/
public String getMajorIdentityWithPerson(String personName) throws Exception {
public String getMajorIdentityWithPerson( String personName ) throws Exception {
List<String> identities = null;
Business business = null;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
......@@ -179,16 +179,18 @@ public class UserManagerService {
}
}
identities = business.organization().identity().listWithPerson(personName);
if (identities != null && !identities.isEmpty()) {
if (ListTools.isNotEmpty( identities )) {
if( identities.size() == 1 ) {
return identities.get(0);
}
for (String identity : identities) {
Identity obj = business.organization().identity().getObject(identity);
if (obj.getMajor()) {
return identity;
}else{
for (String identity : identities) {
Identity obj = business.organization().identity().getObject(identity);
if (obj.getMajor()) {
return identity;
}
}
}
return identities.get(0);
}
return null;
} catch (Exception e) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册