@ -98,10 +98,11 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
* /
@Transactional
@Override
public Map < String , Object > createProcessTaskRelation ( User loginUser , long projectCode , long processDefinitionCode , long preTaskCode , long postTaskCode ) {
public Map < String , Object > createProcessTaskRelation ( User loginUser , long projectCode , long processDefinitionCode ,
long preTaskCode , long postTaskCode ) {
Project project = projectMapper . queryByCode ( projectCode ) ;
//check user access for project
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , null ) ;
// check user access for project
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , null ) ;
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
return result ;
}
@ -115,11 +116,14 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
return result ;
}
updateProcessDefiniteVersion ( loginUser , result , processDefinition ) ;
List < ProcessTaskRelation > processTaskRelationList = processTaskRelationMapper . queryByProcessCode ( projectCode , processDefinitionCode ) ;
List < ProcessTaskRelation > processTaskRelationList =
processTaskRelationMapper . queryByProcessCode ( projectCode , processDefinitionCode ) ;
List < ProcessTaskRelation > processTaskRelations = Lists . newArrayList ( processTaskRelationList ) ;
if ( ! processTaskRelations . isEmpty ( ) ) {
Map < Long , ProcessTaskRelation > preTaskCodeMap = processTaskRelations . stream ( ) . filter ( r - > r . getPostTaskCode ( ) = = postTaskCode )
. collect ( Collectors . toMap ( ProcessTaskRelation : : getPreTaskCode , processTaskRelation - > processTaskRelation ) ) ;
Map < Long , ProcessTaskRelation > preTaskCodeMap =
processTaskRelations . stream ( ) . filter ( r - > r . getPostTaskCode ( ) = = postTaskCode )
. collect ( Collectors . toMap ( ProcessTaskRelation : : getPreTaskCode ,
processTaskRelation - > processTaskRelation ) ) ;
if ( ! preTaskCodeMap . isEmpty ( ) ) {
if ( preTaskCodeMap . containsKey ( preTaskCode ) | | ( ! preTaskCodeMap . containsKey ( 0L ) & & preTaskCode = = 0L ) ) {
putMsg ( result , Status . PROCESS_TASK_RELATION_EXIST , String . valueOf ( processDefinitionCode ) ) ;
@ -135,7 +139,8 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
ProcessTaskRelation processTaskRelation = setRelation ( processDefinition , postTaskDefinition ) ;
if ( preTaskCode ! = 0L ) {
TaskDefinition preTaskDefinition = taskDefinitionMapper . queryByCode ( preTaskCode ) ;
List < ProcessTaskRelation > upstreamTaskRelationList = processTaskRelations . stream ( ) . filter ( r - > r . getPostTaskCode ( ) = = preTaskCode ) . collect ( Collectors . toList ( ) ) ;
List < ProcessTaskRelation > upstreamTaskRelationList = processTaskRelations . stream ( )
. filter ( r - > r . getPostTaskCode ( ) = = preTaskCode ) . collect ( Collectors . toList ( ) ) ;
// upstream is or not exist
if ( upstreamTaskRelationList . isEmpty ( ) ) {
ProcessTaskRelation preProcessTaskRelation = setRelation ( processDefinition , preTaskDefinition ) ;
@ -169,7 +174,8 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
return processTaskRelation ;
}
private void updateProcessDefiniteVersion ( User loginUser , Map < String , Object > result , ProcessDefinition processDefinition ) {
private void updateProcessDefiniteVersion ( User loginUser , Map < String , Object > result ,
ProcessDefinition processDefinition ) {
int insertVersion = processService . saveProcessDefine ( loginUser , processDefinition , Boolean . TRUE , Boolean . TRUE ) ;
if ( insertVersion < = 0 ) {
putMsg ( result , Status . UPDATE_PROCESS_DEFINITION_ERROR ) ;
@ -189,10 +195,11 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
* /
@Transactional
@Override
public Map < String , Object > deleteTaskProcessRelation ( User loginUser , long projectCode , long processDefinitionCode , long taskCode ) {
public Map < String , Object > deleteTaskProcessRelation ( User loginUser , long projectCode , long processDefinitionCode ,
long taskCode ) {
Project project = projectMapper . queryByCode ( projectCode ) ;
//check user access for project
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , null ) ;
// check user access for project
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , null ) ;
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
return result ;
}
@ -210,7 +217,8 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
putMsg ( result , Status . TASK_DEFINE_NOT_EXIST , String . valueOf ( taskCode ) ) ;
return result ;
}
List < ProcessTaskRelation > processTaskRelations = processTaskRelationMapper . queryByProcessCode ( projectCode , processDefinitionCode ) ;
List < ProcessTaskRelation > processTaskRelations =
processTaskRelationMapper . queryByProcessCode ( projectCode , processDefinitionCode ) ;
List < ProcessTaskRelation > processTaskRelationList = Lists . newArrayList ( processTaskRelations ) ;
if ( CollectionUtils . isEmpty ( processTaskRelationList ) ) {
putMsg ( result , Status . DATA_IS_NULL , "processTaskRelationList" ) ;
@ -232,8 +240,8 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
updateProcessDefiniteVersion ( loginUser , result , processDefinition ) ;
updateRelation ( loginUser , result , processDefinition , processTaskRelationList ) ;
if ( TASK_TYPE_CONDITIONS . equals ( taskDefinition . getTaskType ( ) )
| | TASK_TYPE_DEPENDENT . equals ( taskDefinition . getTaskType ( ) )
| | TASK_TYPE_SUB_PROCESS . equals ( taskDefinition . getTaskType ( ) ) ) {
| | TASK_TYPE_DEPENDENT . equals ( taskDefinition . getTaskType ( ) )
| | TASK_TYPE_SUB_PROCESS . equals ( taskDefinition . getTaskType ( ) ) ) {
int deleteTaskDefinition = taskDefinitionMapper . deleteByCode ( taskCode ) ;
if ( 0 = = deleteTaskDefinition ) {
putMsg ( result , Status . DELETE_TASK_DEFINE_BY_CODE_ERROR ) ;
@ -246,9 +254,11 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
private void updateRelation ( User loginUser , Map < String , Object > result , ProcessDefinition processDefinition ,
List < ProcessTaskRelation > processTaskRelationList ) {
List < ProcessTaskRelationLog > relationLogs = processTaskRelationList . stream ( ) . map ( ProcessTaskRelationLog : : new ) . collect ( Collectors . toList ( ) ) ;
int insertResult = processService . saveTaskRelation ( loginUser , processDefinition . getProjectCode ( ) , processDefinition . getCode ( ) ,
processDefinition . getVersion ( ) , relationLogs , Lists . newArrayList ( ) , Boolean . TRUE ) ;
List < ProcessTaskRelationLog > relationLogs =
processTaskRelationList . stream ( ) . map ( ProcessTaskRelationLog : : new ) . collect ( Collectors . toList ( ) ) ;
int insertResult = processService . saveTaskRelation ( loginUser , processDefinition . getProjectCode ( ) ,
processDefinition . getCode ( ) ,
processDefinition . getVersion ( ) , relationLogs , Lists . newArrayList ( ) , Boolean . TRUE ) ;
if ( insertResult = = Constants . EXIT_CODE_SUCCESS ) {
putMsg ( result , Status . SUCCESS ) ;
result . put ( Constants . DATA_LIST , processDefinition ) ;
@ -269,10 +279,11 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
* /
@Transactional
@Override
public Map < String , Object > deleteUpstreamRelation ( User loginUser , long projectCode , String preTaskCodes , long taskCode ) {
public Map < String , Object > deleteUpstreamRelation ( User loginUser , long projectCode , String preTaskCodes ,
long taskCode ) {
Project project = projectMapper . queryByCode ( projectCode ) ;
//check user access for project
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , null ) ;
// check user access for project
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , null ) ;
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
return result ;
}
@ -286,12 +297,14 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
return result ;
}
List < Long > preTaskCodeList = Lists . newArrayList ( preTaskCodes . split ( Constants . COMMA ) ) . stream ( ) . map ( Long : : parseLong ) . collect ( Collectors . toList ( ) ) ;
List < Long > preTaskCodeList = Lists . newArrayList ( preTaskCodes . split ( Constants . COMMA ) ) . stream ( )
. map ( Long : : parseLong ) . collect ( Collectors . toList ( ) ) ;
if ( preTaskCodeList . contains ( 0L ) ) {
putMsg ( result , Status . DATA_IS_NULL , "preTaskCodes" ) ;
return result ;
}
List < Long > currentUpstreamList = upstreamList . stream ( ) . map ( ProcessTaskRelation : : getPreTaskCode ) . collect ( Collectors . toList ( ) ) ;
List < Long > currentUpstreamList =
upstreamList . stream ( ) . map ( ProcessTaskRelation : : getPreTaskCode ) . collect ( Collectors . toList ( ) ) ;
if ( currentUpstreamList . contains ( 0L ) ) {
putMsg ( result , Status . DATA_IS_NOT_VALID , "currentUpstreamList" ) ;
return result ;
@ -303,12 +316,15 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
putMsg ( result , Status . DATA_IS_NOT_VALID , StringUtils . join ( preTaskCodeList , Constants . COMMA ) ) ;
return result ;
}
ProcessDefinition processDefinition = processDefinitionMapper . queryByCode ( upstreamList . get ( 0 ) . getProcessDefinitionCode ( ) ) ;
ProcessDefinition processDefinition =
processDefinitionMapper . queryByCode ( upstreamList . get ( 0 ) . getProcessDefinitionCode ( ) ) ;
if ( processDefinition = = null ) {
putMsg ( result , Status . PROCESS_DEFINE_NOT_EXIST , String . valueOf ( upstreamList . get ( 0 ) . getProcessDefinitionCode ( ) ) ) ;
putMsg ( result , Status . PROCESS_DEFINE_NOT_EXIST ,
String . valueOf ( upstreamList . get ( 0 ) . getProcessDefinitionCode ( ) ) ) ;
return result ;
}
List < ProcessTaskRelation > processTaskRelations = processTaskRelationMapper . queryByProcessCode ( projectCode , processDefinition . getCode ( ) ) ;
List < ProcessTaskRelation > processTaskRelations =
processTaskRelationMapper . queryByProcessCode ( projectCode , processDefinition . getCode ( ) ) ;
List < ProcessTaskRelation > processTaskRelationList = Lists . newArrayList ( processTaskRelations ) ;
List < ProcessTaskRelation > processTaskRelationWaitRemove = Lists . newArrayList ( ) ;
for ( ProcessTaskRelation processTaskRelation : processTaskRelationList ) {
@ -318,7 +334,8 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
processTaskRelationWaitRemove . add ( processTaskRelation ) ;
}
} else {
if ( processTaskRelation . getPostTaskCode ( ) = = taskCode & & ( currentUpstreamList . isEmpty ( ) | | tmpCurrent . isEmpty ( ) ) ) {
if ( processTaskRelation . getPostTaskCode ( ) = = taskCode
& & ( currentUpstreamList . isEmpty ( ) | | tmpCurrent . isEmpty ( ) ) ) {
processTaskRelation . setPreTaskVersion ( 0 ) ;
processTaskRelation . setPreTaskCode ( 0L ) ;
}
@ -341,10 +358,11 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
* /
@Transactional
@Override
public Map < String , Object > deleteDownstreamRelation ( User loginUser , long projectCode , String postTaskCodes , long taskCode ) {
public Map < String , Object > deleteDownstreamRelation ( User loginUser , long projectCode , String postTaskCodes ,
long taskCode ) {
Project project = projectMapper . queryByCode ( projectCode ) ;
//check user access for project
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , null ) ;
// check user access for project
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , null ) ;
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
return result ;
}
@ -352,24 +370,31 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
putMsg ( result , Status . DATA_IS_NULL , "postTaskCodes" ) ;
return result ;
}
List < ProcessTaskRelation > downstreamList = processTaskRelationMapper . queryDownstreamByCode ( projectCode , taskCode ) ;
List < ProcessTaskRelation > downstreamList =
processTaskRelationMapper . queryDownstreamByCode ( projectCode , taskCode ) ;
if ( CollectionUtils . isEmpty ( downstreamList ) ) {
putMsg ( result , Status . DATA_IS_NULL , "taskCode" ) ;
return result ;
}
List < Long > postTaskCodeList = Lists . newArrayList ( postTaskCodes . split ( Constants . COMMA ) ) . stream ( ) . map ( Long : : parseLong ) . collect ( Collectors . toList ( ) ) ;
List < Long > postTaskCodeList = Lists . newArrayList ( postTaskCodes . split ( Constants . COMMA ) ) . stream ( )
. map ( Long : : parseLong ) . collect ( Collectors . toList ( ) ) ;
if ( postTaskCodeList . contains ( 0L ) ) {
putMsg ( result , Status . DATA_IS_NULL , "postTaskCodes" ) ;
return result ;
}
ProcessDefinition processDefinition = processDefinitionMapper . queryByCode ( downstreamList . get ( 0 ) . getProcessDefinitionCode ( ) ) ;
ProcessDefinition processDefinition =
processDefinitionMapper . queryByCode ( downstreamList . get ( 0 ) . getProcessDefinitionCode ( ) ) ;
if ( processDefinition = = null ) {
putMsg ( result , Status . PROCESS_DEFINE_NOT_EXIST , String . valueOf ( downstreamList . get ( 0 ) . getProcessDefinitionCode ( ) ) ) ;
putMsg ( result , Status . PROCESS_DEFINE_NOT_EXIST ,
String . valueOf ( downstreamList . get ( 0 ) . getProcessDefinitionCode ( ) ) ) ;
return result ;
}
List < ProcessTaskRelation > processTaskRelations = processTaskRelationMapper . queryByProcessCode ( projectCode , processDefinition . getCode ( ) ) ;
List < ProcessTaskRelation > processTaskRelations =
processTaskRelationMapper . queryByProcessCode ( projectCode , processDefinition . getCode ( ) ) ;
List < ProcessTaskRelation > processTaskRelationList = Lists . newArrayList ( processTaskRelations ) ;
processTaskRelationList . removeIf ( processTaskRelation - > postTaskCodeList . contains ( processTaskRelation . getPostTaskCode ( ) ) & & processTaskRelation . getPreTaskCode ( ) = = taskCode ) ;
processTaskRelationList
. removeIf ( processTaskRelation - > postTaskCodeList . contains ( processTaskRelation . getPostTaskCode ( ) )
& & processTaskRelation . getPreTaskCode ( ) = = taskCode ) ;
updateProcessDefiniteVersion ( loginUser , result , processDefinition ) ;
updateRelation ( loginUser , result , processDefinition , processTaskRelationList ) ;
return result ;
@ -386,24 +411,25 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
@Override
public Map < String , Object > queryUpstreamRelation ( User loginUser , long projectCode , long taskCode ) {
Project project = projectMapper . queryByCode ( projectCode ) ;
//check user access for project
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , null ) ;
// check user access for project
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , null ) ;
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
return result ;
}
List < ProcessTaskRelation > processTaskRelationList = processTaskRelationMapper . queryUpstreamByCode ( projectCode , taskCode ) ;
List < ProcessTaskRelation > processTaskRelationList =
processTaskRelationMapper . queryUpstreamByCode ( projectCode , taskCode ) ;
List < TaskDefinitionLog > taskDefinitionLogList = new ArrayList < > ( ) ;
if ( CollectionUtils . isNotEmpty ( processTaskRelationList ) ) {
Set < TaskDefinition > taskDefinitions = processTaskRelationList
. stream ( )
. map ( processTaskRelation - > {
TaskDefinition taskDefinition = buildTaskDefinition ( ) ;
taskDefinition . setProjectCode ( processTaskRelation . getProjectCode ( ) ) ;
taskDefinition . setCode ( processTaskRelation . getPreTaskCode ( ) ) ;
taskDefinition . setVersion ( processTaskRelation . getPreTaskVersion ( ) ) ;
return taskDefinition ;
} )
. collect ( Collectors . toSet ( ) ) ;
. stream ( )
. map ( processTaskRelation - > {
TaskDefinition taskDefinition = buildTaskDefinition ( ) ;
taskDefinition . setProjectCode ( processTaskRelation . getProjectCode ( ) ) ;
taskDefinition . setCode ( processTaskRelation . getPreTaskCode ( ) ) ;
taskDefinition . setVersion ( processTaskRelation . getPreTaskVersion ( ) ) ;
return taskDefinition ;
} )
. collect ( Collectors . toSet ( ) ) ;
taskDefinitionLogList = taskDefinitionLogMapper . queryByTaskDefinitions ( taskDefinitions ) ;
}
result . put ( Constants . DATA_LIST , taskDefinitionLogList ) ;
@ -422,24 +448,25 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
@Override
public Map < String , Object > queryDownstreamRelation ( User loginUser , long projectCode , long taskCode ) {
Project project = projectMapper . queryByCode ( projectCode ) ;
//check user access for project
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , null ) ;
// check user access for project
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , null ) ;
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
return result ;
}
List < ProcessTaskRelation > processTaskRelationList = processTaskRelationMapper . queryDownstreamByCode ( projectCode , taskCode ) ;
List < ProcessTaskRelation > processTaskRelationList =
processTaskRelationMapper . queryDownstreamByCode ( projectCode , taskCode ) ;
List < TaskDefinitionLog > taskDefinitionLogList = new ArrayList < > ( ) ;
if ( CollectionUtils . isNotEmpty ( processTaskRelationList ) ) {
Set < TaskDefinition > taskDefinitions = processTaskRelationList
. stream ( )
. map ( processTaskRelation - > {
TaskDefinition taskDefinition = buildTaskDefinition ( ) ;
taskDefinition . setProjectCode ( processTaskRelation . getProjectCode ( ) ) ;
taskDefinition . setCode ( processTaskRelation . getPostTaskCode ( ) ) ;
taskDefinition . setVersion ( processTaskRelation . getPostTaskVersion ( ) ) ;
return taskDefinition ;
} )
. collect ( Collectors . toSet ( ) ) ;
. stream ( )
. map ( processTaskRelation - > {
TaskDefinition taskDefinition = buildTaskDefinition ( ) ;
taskDefinition . setProjectCode ( processTaskRelation . getProjectCode ( ) ) ;
taskDefinition . setCode ( processTaskRelation . getPostTaskCode ( ) ) ;
taskDefinition . setVersion ( processTaskRelation . getPostTaskVersion ( ) ) ;
return taskDefinition ;
} )
. collect ( Collectors . toSet ( ) ) ;
taskDefinitionLogList = taskDefinitionLogMapper . queryByTaskDefinitions ( taskDefinitions ) ;
}
result . put ( Constants . DATA_LIST , taskDefinitionLogList ) ;
@ -459,10 +486,11 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
* /
@Transactional
@Override
public Map < String , Object > deleteEdge ( User loginUser , long projectCode , long processDefinitionCode , long preTaskCode , long postTaskCode ) {
public Map < String , Object > deleteEdge ( User loginUser , long projectCode , long processDefinitionCode ,
long preTaskCode , long postTaskCode ) {
Project project = projectMapper . queryByCode ( projectCode ) ;
//check user access for project
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , null ) ;
// check user access for project
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , null ) ;
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
return result ;
}
@ -471,7 +499,8 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
putMsg ( result , Status . PROCESS_DEFINE_NOT_EXIST , String . valueOf ( processDefinitionCode ) ) ;
return result ;
}
List < ProcessTaskRelation > processTaskRelations = processTaskRelationMapper . queryByProcessCode ( projectCode , processDefinitionCode ) ;
List < ProcessTaskRelation > processTaskRelations =
processTaskRelationMapper . queryByProcessCode ( projectCode , processDefinitionCode ) ;
List < ProcessTaskRelation > processTaskRelationList = Lists . newArrayList ( processTaskRelations ) ;
if ( CollectionUtils . isEmpty ( processTaskRelationList ) ) {
putMsg ( result , Status . DATA_IS_NULL , "processTaskRelationList" ) ;
@ -522,6 +551,7 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
private TaskDefinition buildTaskDefinition ( ) {
return new TaskDefinition ( ) {
@Override
public boolean equals ( Object o ) {
if ( this = = o ) {
@ -532,8 +562,8 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
}
TaskDefinition that = ( TaskDefinition ) o ;
return getCode ( ) = = that . getCode ( )
& & getVersion ( ) = = that . getVersion ( )
& & getProjectCode ( ) = = that . getProjectCode ( ) ;
& & getVersion ( ) = = that . getVersion ( )
& & getProjectCode ( ) = = that . getProjectCode ( ) ;
}
@Override