Przeglądaj źródła

Merge branch 'fix/Calendar.SYSTEM' into 'develop'

Merge for fix/Calendar.SYSTEM[考勤管理]修复在某些特殊情况下,日程管理编辑时报错的问题以及对可见日程列表查询的相关优化

See merge request o2oa/o2oa!700
李义 5 lat temu
rodzic
commit
26dcccc629

+ 13 - 1
o2server/x_calendar_assemble_control/src/main/java/com/x/calendar/assemble/control/jaxrs/calendar/ActionFollowCalendar.java

@@ -57,7 +57,19 @@ public class ActionFollowCalendar extends BaseAction {
 				logger.error( e, effectivePerson, request, null);
 			}
 		}
-		
+
+		if( check ){
+			if(
+					( StringUtils.equalsAnyIgnoreCase( calendar.getCreateor(), effectivePerson.getDistinguishedName() ) ) ||
+					( StringUtils.equalsAnyIgnoreCase( calendar.getTarget(), effectivePerson.getDistinguishedName() ) ) ||
+					( StringUtils.equalsAnyIgnoreCase( calendar.getCreateor(), "SYSTEM" ) )
+			){
+				check = false;
+				Exception exception = new ExceptionCalendarInfoProcess( "不需要关注自己的日历.ID:" + id );
+				result.error( exception );
+			}
+		}
+
 		if( check ){
 			try {
 				check = calendarServiceAdv.follow( effectivePerson, id );

+ 35 - 2
o2server/x_calendar_assemble_control/src/main/java/com/x/calendar/assemble/control/jaxrs/calendar/ActionGet.java

@@ -5,6 +5,7 @@ import java.util.List;
 
 import javax.servlet.http.HttpServletRequest;
 
+import com.x.base.core.project.tools.ListTools;
 import org.apache.commons.lang3.StringUtils;
 
 import com.x.base.core.project.annotation.FieldDescribe;
@@ -68,10 +69,42 @@ public class ActionGet extends BaseAction {
 		if( check ){
 			try {
 				wrap = Wo.copier.copy( calendar );
+				if( StringUtils.equalsAnyIgnoreCase("SYSTEM", calendar.getCreateor() )){
+					wrap.setCreateor( effectivePerson.getDistinguishedName() );
+				}
 				wrap.setManageable( ThisApplication.isCalendarManager( effectivePerson, wrap ) );
-				wrap.setPublishable( ThisApplication.isCalendarPublisher( effectivePerson, unitNames, groupNames, wrap ) );	
+				wrap.setPublishable( ThisApplication.isCalendarPublisher( effectivePerson, unitNames, groupNames, wrap ) );
+
+				if(ListTools.isNotEmpty( wrap.getManageablePersonList() )){
+					for( String person : wrap.getManageablePersonList() ){
+						if( StringUtils.equalsAnyIgnoreCase( person, "SYSTEM")){
+							if( !wrap.getManageablePersonList().contains( effectivePerson.getDistinguishedName() )){
+								wrap.getManageablePersonList().add( effectivePerson.getDistinguishedName() );
+							}
+						}
+					}
+				}
+
+				if(ListTools.isNotEmpty( wrap.getViewablePersonList() )){
+					for( String person : wrap.getViewablePersonList() ){
+						if( StringUtils.equalsAnyIgnoreCase( person, "SYSTEM")){
+							if( !wrap.getViewablePersonList().contains( effectivePerson.getDistinguishedName() )){
+								wrap.getViewablePersonList().add( effectivePerson.getDistinguishedName() );
+							}
+						}
+					}
+				}
+
+				if(ListTools.isNotEmpty( wrap.getViewablePersonList() )){
+					for( String person : wrap.getViewablePersonList() ){
+						if( StringUtils.equalsAnyIgnoreCase( person, "SYSTEM")){
+							if( !wrap.getViewablePersonList().contains( effectivePerson.getDistinguishedName() )){
+								wrap.getViewablePersonList().add( effectivePerson.getDistinguishedName() );
+							}
+						}
+					}
+				}
 			} catch (Exception e) {
-				check = false;
 				Exception exception = new ExceptionCalendarInfoProcess( e, "将所有查询到的日历信息对象转换为可以输出的信息时发生异常." );
 				result.error( exception );
 				logger.error( e, effectivePerson, request, null);

+ 21 - 17
o2server/x_calendar_assemble_control/src/main/java/com/x/calendar/assemble/control/jaxrs/calendar/ActionListWhatICanView.java

@@ -78,13 +78,21 @@ public class ActionListWhatICanView extends BaseAction {
 					woCalendar.setPublishable( ThisApplication.isCalendarPublisher( effectivePerson, unitNames, groupNames, calendar ) );	
 					//将所有的日历分为三类,放在三个不同的LIST里
 					//组织日历
-					if( "UNIT".equalsIgnoreCase( calendar.getType() ) ) {
-						wo.addUnitCalendar( woCalendar );
-					}else {
-						if( calendar.getCreateor().equalsIgnoreCase( effectivePerson.getDistinguishedName() )
-								|| StringUtils.equalsAnyIgnoreCase("SYSTEM", calendar.getCreateor() )) {
-							if( StringUtils.equalsAnyIgnoreCase("SYSTEM", calendar.getCreateor() )) {
+					if( ListTools.isNotEmpty( calendar.getFollowers() ) && calendar.getFollowers().contains( effectivePerson.getDistinguishedName() )){
+						//我关注的日历
+						wo.addFollowCalendar( woCalendar );
+					}else{
+						//个人或者组织日历
+						if( "UNIT".equalsIgnoreCase( calendar.getType() ) ) {
+							//组织日历
+							wo.addUnitCalendar( woCalendar );
+						}else {
+							//个人日历
+//							Boolean isMineCalendar = calendar.getCreateor().equalsIgnoreCase( effectivePerson.getDistinguishedName() );
+							Boolean isSystemCreate = StringUtils.equalsAnyIgnoreCase("SYSTEM", calendar.getCreateor() );
+							if( isSystemCreate ) {
 								if( !existsSystemDefaultCalendar ){
+									woCalendar.setCreateor( effectivePerson.getDistinguishedName() );
 									wo.addMyCalendar( woCalendar );
 									existsSystemDefaultCalendar = true;
 								}else{
@@ -94,9 +102,6 @@ public class ActionListWhatICanView extends BaseAction {
 							}else{
 								wo.addMyCalendar( woCalendar );
 							}
-
-						}else {
-							wo.addFollowCalendar( woCalendar );
 						}
 					}
 				}
@@ -173,7 +178,7 @@ public class ActionListWhatICanView extends BaseAction {
 		
 		static {
 			Excludes.add(  JpaObject.sequence_FIELDNAME );
-			Excludes.add( "updateTime" );
+//			Excludes.add( "updateTime" );
 			Excludes.add( "manageablePersonList" );
 			Excludes.add( "viewablePersonList" );
 			Excludes.add( "viewableUnitList" );
@@ -183,13 +188,13 @@ public class ActionListWhatICanView extends BaseAction {
 			Excludes.add( "publishableGroupList" );
 			Excludes.add( "status" );
 			Excludes.add( "distributeFactor" );
-			Excludes.add( "isPublic" );
+//			Excludes.add( "isPublic" );
 			Excludes.add( "followers" );
-			Excludes.add( "description" );
-			Excludes.add( "target" );
-			Excludes.add( "createor" );
-			Excludes.add( "source" );
-			Excludes.add( "createTime" );		
+//			Excludes.add( "description" );
+//			Excludes.add( "target" );
+//			Excludes.add( "createor" );
+//			Excludes.add( "source" );
+//			Excludes.add( "createTime" );
 		}
 		
 		@FieldDescribe("用户是否可以对该日历进行管理.")
@@ -215,6 +220,5 @@ public class ActionListWhatICanView extends BaseAction {
 		public void setPublishable(Boolean publishable) {
 			this.publishable = publishable;
 		}
-		
 	}
 }

+ 10 - 7
o2server/x_calendar_assemble_control/src/main/java/com/x/calendar/assemble/control/service/CalendarServiceAdv.java

@@ -74,23 +74,23 @@ public class CalendarServiceAdv{
 		//管理者应该都有可见权限
 		if( ListTools.isNotEmpty( calendar.getManageablePersonList() )) {
 			for( String managerName : calendar.getManageablePersonList() ) {
-				addStringToList( managerName, calendar.getViewablePersonList() );
+				addStringToList( managerName, effectivePerson, calendar.getViewablePersonList() );
 			}
 		}
 		
 		//对日历信息进行权限设置,至少自己创建的日历自己可以管理 ,可以发布,可以查看
-		addStringToList( calendar.getCreateor(), calendar.getManageablePersonList() );
-		addStringToList( calendar.getCreateor(), calendar.getPublishablePersonList() );
-		addStringToList( calendar.getCreateor(), calendar.getViewablePersonList() );
+		addStringToList( calendar.getCreateor(), effectivePerson, calendar.getManageablePersonList() );
+		addStringToList( calendar.getCreateor(), effectivePerson, calendar.getPublishablePersonList() );
+		addStringToList( calendar.getCreateor(), effectivePerson, calendar.getViewablePersonList() );
 		
 		if( "UNIT".equals( calendar.getType() )) {
 			if( ListTools.isEmpty(calendar.getViewableUnitList() )
 				&& ListTools.isEmpty(calendar.getViewableGroupList() )
 				&& ListTools.isEmpty(calendar.getViewablePersonList() )){
-				addStringToList( calendar.getTarget(), calendar.getViewableUnitList() );
+				addStringToList( calendar.getTarget(), effectivePerson, calendar.getViewableUnitList() );
 			}
 		}else {
-			addStringToList( calendar.getTarget(), calendar.getViewablePersonList() );
+			addStringToList( calendar.getTarget(), effectivePerson, calendar.getViewablePersonList() );
 		}		
 		
 		if( StringUtils.isEmpty( calendar.getColor() )) {
@@ -130,10 +130,13 @@ public class CalendarServiceAdv{
 	 * @param distinguishedName
 	 * @param manageablePersonList
 	 */
-	private void addStringToList(String distinguishedName, List<String> manageablePersonList) {
+	private void addStringToList(String distinguishedName, EffectivePerson effectivePerson, List<String> manageablePersonList) {
 		if( manageablePersonList == null ) {
 			manageablePersonList = new ArrayList<>();
 		}
+		if( StringUtils.equalsAnyIgnoreCase( distinguishedName, "SYSTEM")){
+			distinguishedName = effectivePerson.getDistinguishedName();
+		}
 		if( StringUtils.isNotEmpty( distinguishedName ) ) {
 			if( !manageablePersonList.contains( distinguishedName )) {
 				manageablePersonList.add( distinguishedName );