@ -44,6 +44,7 @@ import org.apache.dolphinscheduler.service.process.ProcessService;
import org.apache.commons.lang.StringUtils ;
import org.apache.commons.lang.StringUtils ;
import java.util.ArrayList ;
import java.util.Arrays ;
import java.util.Arrays ;
import java.util.Date ;
import java.util.Date ;
import java.util.HashMap ;
import java.util.HashMap ;
@ -104,7 +105,7 @@ public class DataAnalysisServiceImpl extends BaseServiceImpl implements DataAnal
projectCode ,
projectCode ,
startDate ,
startDate ,
endDate ,
endDate ,
( start , end , projectCodes ) - > this . taskInstanceMapper . countTaskInstanceStateByUser ( start , end , projectCodes ) ) ;
( start , end , projectCodes ) - > this . taskInstanceMapper . countTaskInstanceStateByProjectCodes ( start , end , projectCodes ) ) ;
}
}
/ * *
/ * *
@ -123,7 +124,7 @@ public class DataAnalysisServiceImpl extends BaseServiceImpl implements DataAnal
projectCode ,
projectCode ,
startDate ,
startDate ,
endDate ,
endDate ,
( start , end , projectCodes ) - > this . processInstanceMapper . countInstanceStateByUser ( start , end , projectCodes ) ) ;
( start , end , projectCodes ) - > this . processInstanceMapper . countInstanceStateByProjectCodes ( start , end , projectCodes ) ) ;
// process state count needs to remove state of forced success
// process state count needs to remove state of forced success
if ( result . containsKey ( Constants . STATUS ) & & result . get ( Constants . STATUS ) . equals ( Status . SUCCESS ) ) {
if ( result . containsKey ( Constants . STATUS ) & & result . get ( Constants . STATUS ) . equals ( Status . SUCCESS ) ) {
( ( TaskCountDto ) result . get ( Constants . DATA_LIST ) ) . removeStateFromCountList ( ExecutionStatus . FORCED_SUCCESS ) ;
( ( TaskCountDto ) result . get ( Constants . DATA_LIST ) ) . removeStateFromCountList ( ExecutionStatus . FORCED_SUCCESS ) ;
@ -131,6 +132,14 @@ public class DataAnalysisServiceImpl extends BaseServiceImpl implements DataAnal
return result ;
return result ;
}
}
/ * *
* Wrapper function of counting process instance state and task state
*
* @param loginUser login user
* @param projectCode project code
* @param startDate start date
* @param endDate end date
* /
private Map < String , Object > countStateByProject ( User loginUser , long projectCode , String startDate , String endDate
private Map < String , Object > countStateByProject ( User loginUser , long projectCode , String startDate , String endDate
, TriFunction < Date , Date , Long [ ] , List < ExecuteStatusCount > > instanceStateCounter ) {
, TriFunction < Date , Date , Long [ ] , List < ExecuteStatusCount > > instanceStateCounter ) {
Map < String , Object > result = new HashMap < > ( ) ;
Map < String , Object > result = new HashMap < > ( ) ;
@ -154,10 +163,13 @@ public class DataAnalysisServiceImpl extends BaseServiceImpl implements DataAnal
}
}
}
}
List < ExecuteStatusCount > processInstanceStateCounts = new ArrayList < > ( ) ;
Long [ ] projectCodeArray = projectCode = = 0 ? getProjectCodesArrays ( loginUser )
Long [ ] projectCodeArray = projectCode = = 0 ? getProjectCodesArrays ( loginUser )
: new Long [ ] { projectCode } ;
: new Long [ ] { projectCode } ;
List < ExecuteStatusCount > processInstanceStateCounts =
instanceStateCounter . apply ( start , end , projectCodeArray ) ;
if ( projectCodeArray . length ! = 0 | | loginUser . getUserType ( ) = = UserType . ADMIN_USER ) {
processInstanceStateCounts = instanceStateCounter . apply ( start , end , projectCodeArray ) ;
}
if ( processInstanceStateCounts ! = null ) {
if ( processInstanceStateCounts ! = null ) {
TaskCountDto taskCountResult = new TaskCountDto ( processInstanceStateCounts ) ;
TaskCountDto taskCountResult = new TaskCountDto ( processInstanceStateCounts ) ;
@ -169,7 +181,9 @@ public class DataAnalysisServiceImpl extends BaseServiceImpl implements DataAnal
/ * *
/ * *
* statistics the process definition quantities of certain person
* statistics the process definition quantities of a certain person
* < p >
* We only need projects which users have permission to see to determine whether the definition belongs to the user or not .
*
*
* @param loginUser login user
* @param loginUser login user
* @param projectCode project code
* @param projectCode project code
@ -187,10 +201,12 @@ public class DataAnalysisServiceImpl extends BaseServiceImpl implements DataAnal
}
}
}
}
List < DefinitionGroupByUser > defineGroupByUsers = new ArrayList < > ( ) ;
Long [ ] projectCodeArray = projectCode = = 0 ? getProjectCodesArrays ( loginUser )
Long [ ] projectCodeArray = projectCode = = 0 ? getProjectCodesArrays ( loginUser )
: new Long [ ] { projectCode } ;
: new Long [ ] { projectCode } ;
List < DefinitionGroupByUser > defineGroupByUsers = processDefinitionMapper . countDefinitionGroupByUser (
if ( projectCodeArray . length ! = 0 | | loginUser . getUserType ( ) = = UserType . ADMIN_USER ) {
loginUser . getId ( ) , projectCodeArray , isAdmin ( loginUser ) ) ;
defineGroupByUsers = processDefinitionMapper . countDefinitionByProjectCodes ( projectCodeArray ) ;
}
DefineUserDto dto = new DefineUserDto ( defineGroupByUsers ) ;
DefineUserDto dto = new DefineUserDto ( defineGroupByUsers ) ;
result . put ( Constants . DATA_LIST , dto ) ;
result . put ( Constants . DATA_LIST , dto ) ;