@ -98,7 +98,8 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
* /
* /
@Transactional
@Transactional
@Override
@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 ) ;
Project project = projectMapper . queryByCode ( projectCode ) ;
// check user access for project
// check user access for project
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , null ) ;
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , null ) ;
@ -115,11 +116,14 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
return result ;
return result ;
}
}
updateProcessDefiniteVersion ( loginUser , result , processDefinition ) ;
updateProcessDefiniteVersion ( loginUser , result , processDefinition ) ;
List < ProcessTaskRelation > processTaskRelationList = processTaskRelationMapper . queryByProcessCode ( projectCode , processDefinitionCode ) ;
List < ProcessTaskRelation > processTaskRelationList =
processTaskRelationMapper . queryByProcessCode ( projectCode , processDefinitionCode ) ;
List < ProcessTaskRelation > processTaskRelations = Lists . newArrayList ( processTaskRelationList ) ;
List < ProcessTaskRelation > processTaskRelations = Lists . newArrayList ( processTaskRelationList ) ;
if ( ! processTaskRelations . isEmpty ( ) ) {
if ( ! processTaskRelations . isEmpty ( ) ) {
Map < Long , ProcessTaskRelation > preTaskCodeMap = processTaskRelations . stream ( ) . filter ( r - > r . getPostTaskCode ( ) = = postTaskCode )
Map < Long , ProcessTaskRelation > preTaskCodeMap =
. collect ( Collectors . toMap ( ProcessTaskRelation : : getPreTaskCode , processTaskRelation - > processTaskRelation ) ) ;
processTaskRelations . stream ( ) . filter ( r - > r . getPostTaskCode ( ) = = postTaskCode )
. collect ( Collectors . toMap ( ProcessTaskRelation : : getPreTaskCode ,
processTaskRelation - > processTaskRelation ) ) ;
if ( ! preTaskCodeMap . isEmpty ( ) ) {
if ( ! preTaskCodeMap . isEmpty ( ) ) {
if ( preTaskCodeMap . containsKey ( preTaskCode ) | | ( ! preTaskCodeMap . containsKey ( 0L ) & & preTaskCode = = 0L ) ) {
if ( preTaskCodeMap . containsKey ( preTaskCode ) | | ( ! preTaskCodeMap . containsKey ( 0L ) & & preTaskCode = = 0L ) ) {
putMsg ( result , Status . PROCESS_TASK_RELATION_EXIST , String . valueOf ( processDefinitionCode ) ) ;
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 ) ;
ProcessTaskRelation processTaskRelation = setRelation ( processDefinition , postTaskDefinition ) ;
if ( preTaskCode ! = 0L ) {
if ( preTaskCode ! = 0L ) {
TaskDefinition preTaskDefinition = taskDefinitionMapper . queryByCode ( preTaskCode ) ;
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
// upstream is or not exist
if ( upstreamTaskRelationList . isEmpty ( ) ) {
if ( upstreamTaskRelationList . isEmpty ( ) ) {
ProcessTaskRelation preProcessTaskRelation = setRelation ( processDefinition , preTaskDefinition ) ;
ProcessTaskRelation preProcessTaskRelation = setRelation ( processDefinition , preTaskDefinition ) ;
@ -169,7 +174,8 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
return processTaskRelation ;
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 ) ;
int insertVersion = processService . saveProcessDefine ( loginUser , processDefinition , Boolean . TRUE , Boolean . TRUE ) ;
if ( insertVersion < = 0 ) {
if ( insertVersion < = 0 ) {
putMsg ( result , Status . UPDATE_PROCESS_DEFINITION_ERROR ) ;
putMsg ( result , Status . UPDATE_PROCESS_DEFINITION_ERROR ) ;
@ -189,7 +195,8 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
* /
* /
@Transactional
@Transactional
@Override
@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 ) ;
Project project = projectMapper . queryByCode ( projectCode ) ;
// check user access for project
// check user access for project
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , null ) ;
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , null ) ;
@ -210,7 +217,8 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
putMsg ( result , Status . TASK_DEFINE_NOT_EXIST , String . valueOf ( taskCode ) ) ;
putMsg ( result , Status . TASK_DEFINE_NOT_EXIST , String . valueOf ( taskCode ) ) ;
return result ;
return result ;
}
}
List < ProcessTaskRelation > processTaskRelations = processTaskRelationMapper . queryByProcessCode ( projectCode , processDefinitionCode ) ;
List < ProcessTaskRelation > processTaskRelations =
processTaskRelationMapper . queryByProcessCode ( projectCode , processDefinitionCode ) ;
List < ProcessTaskRelation > processTaskRelationList = Lists . newArrayList ( processTaskRelations ) ;
List < ProcessTaskRelation > processTaskRelationList = Lists . newArrayList ( processTaskRelations ) ;
if ( CollectionUtils . isEmpty ( processTaskRelationList ) ) {
if ( CollectionUtils . isEmpty ( processTaskRelationList ) ) {
putMsg ( result , Status . DATA_IS_NULL , "processTaskRelationList" ) ;
putMsg ( result , Status . DATA_IS_NULL , "processTaskRelationList" ) ;
@ -246,8 +254,10 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
private void updateRelation ( User loginUser , Map < String , Object > result , ProcessDefinition processDefinition ,
private void updateRelation ( User loginUser , Map < String , Object > result , ProcessDefinition processDefinition ,
List < ProcessTaskRelation > processTaskRelationList ) {
List < ProcessTaskRelation > processTaskRelationList ) {
List < ProcessTaskRelationLog > relationLogs = processTaskRelationList . stream ( ) . map ( ProcessTaskRelationLog : : new ) . collect ( Collectors . toList ( ) ) ;
List < ProcessTaskRelationLog > relationLogs =
int insertResult = processService . saveTaskRelation ( loginUser , processDefinition . getProjectCode ( ) , processDefinition . getCode ( ) ,
processTaskRelationList . stream ( ) . map ( ProcessTaskRelationLog : : new ) . collect ( Collectors . toList ( ) ) ;
int insertResult = processService . saveTaskRelation ( loginUser , processDefinition . getProjectCode ( ) ,
processDefinition . getCode ( ) ,
processDefinition . getVersion ( ) , relationLogs , Lists . newArrayList ( ) , Boolean . TRUE ) ;
processDefinition . getVersion ( ) , relationLogs , Lists . newArrayList ( ) , Boolean . TRUE ) ;
if ( insertResult = = Constants . EXIT_CODE_SUCCESS ) {
if ( insertResult = = Constants . EXIT_CODE_SUCCESS ) {
putMsg ( result , Status . SUCCESS ) ;
putMsg ( result , Status . SUCCESS ) ;
@ -269,7 +279,8 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
* /
* /
@Transactional
@Transactional
@Override
@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 ) ;
Project project = projectMapper . queryByCode ( projectCode ) ;
// check user access for project
// check user access for project
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , null ) ;
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , null ) ;
@ -286,12 +297,14 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
return result ;
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 ) ) {
if ( preTaskCodeList . contains ( 0L ) ) {
putMsg ( result , Status . DATA_IS_NULL , "preTaskCodes" ) ;
putMsg ( result , Status . DATA_IS_NULL , "preTaskCodes" ) ;
return result ;
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 ) ) {
if ( currentUpstreamList . contains ( 0L ) ) {
putMsg ( result , Status . DATA_IS_NOT_VALID , "currentUpstreamList" ) ;
putMsg ( result , Status . DATA_IS_NOT_VALID , "currentUpstreamList" ) ;
return result ;
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 ) ) ;
putMsg ( result , Status . DATA_IS_NOT_VALID , StringUtils . join ( preTaskCodeList , Constants . COMMA ) ) ;
return result ;
return result ;
}
}
ProcessDefinition processDefinition = processDefinitionMapper . queryByCode ( upstreamList . get ( 0 ) . getProcessDefinitionCode ( ) ) ;
ProcessDefinition processDefinition =
processDefinitionMapper . queryByCode ( upstreamList . get ( 0 ) . getProcessDefinitionCode ( ) ) ;
if ( processDefinition = = null ) {
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 ;
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 > processTaskRelationList = Lists . newArrayList ( processTaskRelations ) ;
List < ProcessTaskRelation > processTaskRelationWaitRemove = Lists . newArrayList ( ) ;
List < ProcessTaskRelation > processTaskRelationWaitRemove = Lists . newArrayList ( ) ;
for ( ProcessTaskRelation processTaskRelation : processTaskRelationList ) {
for ( ProcessTaskRelation processTaskRelation : processTaskRelationList ) {
@ -318,7 +334,8 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
processTaskRelationWaitRemove . add ( processTaskRelation ) ;
processTaskRelationWaitRemove . add ( processTaskRelation ) ;
}
}
} else {
} else {
if ( processTaskRelation . getPostTaskCode ( ) = = taskCode & & ( currentUpstreamList . isEmpty ( ) | | tmpCurrent . isEmpty ( ) ) ) {
if ( processTaskRelation . getPostTaskCode ( ) = = taskCode
& & ( currentUpstreamList . isEmpty ( ) | | tmpCurrent . isEmpty ( ) ) ) {
processTaskRelation . setPreTaskVersion ( 0 ) ;
processTaskRelation . setPreTaskVersion ( 0 ) ;
processTaskRelation . setPreTaskCode ( 0L ) ;
processTaskRelation . setPreTaskCode ( 0L ) ;
}
}
@ -341,7 +358,8 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
* /
* /
@Transactional
@Transactional
@Override
@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 ) ;
Project project = projectMapper . queryByCode ( projectCode ) ;
// check user access for project
// check user access for project
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , null ) ;
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , null ) ;
@ -352,24 +370,31 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
putMsg ( result , Status . DATA_IS_NULL , "postTaskCodes" ) ;
putMsg ( result , Status . DATA_IS_NULL , "postTaskCodes" ) ;
return result ;
return result ;
}
}
List < ProcessTaskRelation > downstreamList = processTaskRelationMapper . queryDownstreamByCode ( projectCode , taskCode ) ;
List < ProcessTaskRelation > downstreamList =
processTaskRelationMapper . queryDownstreamByCode ( projectCode , taskCode ) ;
if ( CollectionUtils . isEmpty ( downstreamList ) ) {
if ( CollectionUtils . isEmpty ( downstreamList ) ) {
putMsg ( result , Status . DATA_IS_NULL , "taskCode" ) ;
putMsg ( result , Status . DATA_IS_NULL , "taskCode" ) ;
return result ;
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 ) ) {
if ( postTaskCodeList . contains ( 0L ) ) {
putMsg ( result , Status . DATA_IS_NULL , "postTaskCodes" ) ;
putMsg ( result , Status . DATA_IS_NULL , "postTaskCodes" ) ;
return result ;
return result ;
}
}
ProcessDefinition processDefinition = processDefinitionMapper . queryByCode ( downstreamList . get ( 0 ) . getProcessDefinitionCode ( ) ) ;
ProcessDefinition processDefinition =
processDefinitionMapper . queryByCode ( downstreamList . get ( 0 ) . getProcessDefinitionCode ( ) ) ;
if ( processDefinition = = null ) {
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 ;
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 > 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 ) ;
updateProcessDefiniteVersion ( loginUser , result , processDefinition ) ;
updateRelation ( loginUser , result , processDefinition , processTaskRelationList ) ;
updateRelation ( loginUser , result , processDefinition , processTaskRelationList ) ;
return result ;
return result ;
@ -391,7 +416,8 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
return result ;
return result ;
}
}
List < ProcessTaskRelation > processTaskRelationList = processTaskRelationMapper . queryUpstreamByCode ( projectCode , taskCode ) ;
List < ProcessTaskRelation > processTaskRelationList =
processTaskRelationMapper . queryUpstreamByCode ( projectCode , taskCode ) ;
List < TaskDefinitionLog > taskDefinitionLogList = new ArrayList < > ( ) ;
List < TaskDefinitionLog > taskDefinitionLogList = new ArrayList < > ( ) ;
if ( CollectionUtils . isNotEmpty ( processTaskRelationList ) ) {
if ( CollectionUtils . isNotEmpty ( processTaskRelationList ) ) {
Set < TaskDefinition > taskDefinitions = processTaskRelationList
Set < TaskDefinition > taskDefinitions = processTaskRelationList
@ -427,7 +453,8 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
if ( result . get ( Constants . STATUS ) ! = Status . SUCCESS ) {
return result ;
return result ;
}
}
List < ProcessTaskRelation > processTaskRelationList = processTaskRelationMapper . queryDownstreamByCode ( projectCode , taskCode ) ;
List < ProcessTaskRelation > processTaskRelationList =
processTaskRelationMapper . queryDownstreamByCode ( projectCode , taskCode ) ;
List < TaskDefinitionLog > taskDefinitionLogList = new ArrayList < > ( ) ;
List < TaskDefinitionLog > taskDefinitionLogList = new ArrayList < > ( ) ;
if ( CollectionUtils . isNotEmpty ( processTaskRelationList ) ) {
if ( CollectionUtils . isNotEmpty ( processTaskRelationList ) ) {
Set < TaskDefinition > taskDefinitions = processTaskRelationList
Set < TaskDefinition > taskDefinitions = processTaskRelationList
@ -459,7 +486,8 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
* /
* /
@Transactional
@Transactional
@Override
@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 ) ;
Project project = projectMapper . queryByCode ( projectCode ) ;
// check user access for project
// check user access for project
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , null ) ;
Map < String , Object > result = projectService . checkProjectAndAuth ( loginUser , project , projectCode , null ) ;
@ -471,7 +499,8 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
putMsg ( result , Status . PROCESS_DEFINE_NOT_EXIST , String . valueOf ( processDefinitionCode ) ) ;
putMsg ( result , Status . PROCESS_DEFINE_NOT_EXIST , String . valueOf ( processDefinitionCode ) ) ;
return result ;
return result ;
}
}
List < ProcessTaskRelation > processTaskRelations = processTaskRelationMapper . queryByProcessCode ( projectCode , processDefinitionCode ) ;
List < ProcessTaskRelation > processTaskRelations =
processTaskRelationMapper . queryByProcessCode ( projectCode , processDefinitionCode ) ;
List < ProcessTaskRelation > processTaskRelationList = Lists . newArrayList ( processTaskRelations ) ;
List < ProcessTaskRelation > processTaskRelationList = Lists . newArrayList ( processTaskRelations ) ;
if ( CollectionUtils . isEmpty ( processTaskRelationList ) ) {
if ( CollectionUtils . isEmpty ( processTaskRelationList ) ) {
putMsg ( result , Status . DATA_IS_NULL , "processTaskRelationList" ) ;
putMsg ( result , Status . DATA_IS_NULL , "processTaskRelationList" ) ;
@ -522,6 +551,7 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
private TaskDefinition buildTaskDefinition ( ) {
private TaskDefinition buildTaskDefinition ( ) {
return new TaskDefinition ( ) {
return new TaskDefinition ( ) {
@Override
@Override
public boolean equals ( Object o ) {
public boolean equals ( Object o ) {
if ( this = = o ) {
if ( this = = o ) {